Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix typos in SDL2 example #70

Closed
wants to merge 2 commits into from

Conversation

AileenLumina
Copy link

I read through the OpenGL docs and I think I found a typo that caused the example to crash unless VSync fails. I believe this is not what you wanted. :p

@AileenLumina AileenLumina mentioned this pull request May 8, 2018
@coveralls
Copy link

coveralls commented May 8, 2018

Coverage Status

Coverage remained the same at 42.488% when pulling 382388f on hackofthewild:patch-1 into 427ead5 on swistakm:master.

@swistakm
Copy link
Member

swistakm commented May 8, 2018

Weird. Are you sure this is correct? The official docs say that SDL_GL_SetSwapInterval() returns -1 if it fails (link).

Anyway, by crash you mean something unexpected like in #71 or just exit(1) and message from print? If it's the latter could you share full stdout? Maybe there is problem with VSync. I will try to reproduce this on my own box.

@AileenLumina
Copy link
Author

Oh? Let me see.

@AileenLumina
Copy link
Author

This is the output I get without fixing the typo:

Warning: Unable to set VSync! SDL Error:  b'wglSwapIntervalEXT(): The operation completed successfully.\r\n'

I forgot, I also had to fix another error that involved explicitly casting the bytes returned by SDL_GetError() to a str. Let me add that to this PR.

@swistakm
Copy link
Member

swistakm commented May 8, 2018

Still, that would mean that SDL_GL_SetSwapInterval() failed and it seems odd to fail on normal VSync. I think we could try in that situation to retry with SDL_GL_SetSwapInterval(0) or maybe even do not bother with VSync or try all three options (-1, 1, 0) from the most preferable to the least preferable.

Really weird.

@AileenLumina
Copy link
Author

I tried all three options, always the same "issue". It looks like a warning is printed when actually, things work correctly (The operation completed successfully.) due to incorrect interpretation of the exit code of the operation.

@AileenLumina AileenLumina changed the title Fix typo in SDL2 example Fix typos in SDL2 example May 8, 2018
@swistakm
Copy link
Member

swistakm commented May 8, 2018

This is exactly why I find it really weird :)

See src/video/windows/SDL_windowsopengl.c:

826-int
827-WIN_GL_SetSwapInterval(_THIS, int interval)
828-{
829-    if ((interval < 0) && (!_this->gl_data->HAS_WGL_EXT_swap_control_tear)) {
830-        return SDL_SetError("Negative swap interval unsupported in this GL");
831:    } else if (_this->gl_data->wglSwapIntervalEXT) {
832:        if (_this->gl_data->wglSwapIntervalEXT(interval) != TRUE) {
833:            return WIN_SetError("wglSwapIntervalEXT()");
834-        }
835-    } else {
836-        return SDL_Unsupported();
837-    }
838-    return 0;
839-}

and src/video/SDL_video.c:

3475-int
3476:SDL_GL_SetSwapInterval(int interval)
3477-{
3478-    if (!_this) {
3479-        return SDL_UninitializedVideo();
3480-    } else if (SDL_GL_GetCurrentContext() == NULL) {
3481-        return SDL_SetError("No OpenGL context has been made current");
3482-    } else if (_this->GL_SetSwapInterval) {
3483-        return _this->GL_SetSwapInterval(_this, interval);
3484-    } else {
3485-        return SDL_SetError("Setting the swap interval is not supported");
3486-    }
3487-}

@AileenLumina
Copy link
Author

Looks like this was my device's fault. Not surprised, seeing as it is powered by an Intel Atom.

@swistakm swistakm closed this Jul 20, 2020
@swistakm
Copy link
Member

Closing because it was really old issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants