You should be able to do wglMakeCurrent(NULL, NULL), according to MSDN, since
the first parameter is ignored if the second is NULL, but this causes problems
on some drivers, so make sure we always have a valid HDC in the first
parameter (and exit early if we already have no current context in the
NULL, NULL case).
The SDL OpenGL context code is now properly thread aware. There are two new functions which return the current OpenGL window and context for the current thread.
There are still places in the cocoa driver where the OpenGL context needs to be updated when the view changes. These will need a different solution and still use the last globally set context to avoid changing behavior.
We now do FULL or NO accel based on the app's preference. If the app didn't
specify, we do FULL then fall back to NO.
(Not specifying anything--a true "don't care" scenario--breaks some ATI
drivers, so we try to keep to the spirit of it while forcing a specific
state.)
Previously, it would always do FULL, and try NO if it failed and the app
had requested NO or DONTCARE.
This is a transplant of hg changesets a04171d6fa11 and d0b7c45e982e from the
SDL-1.2 branch.
Fixes Bugzilla #1254.
--HG--
extra : rebase_source : db951d96e685e17a4d71fe2aa3d65043661ccccc
This lets us change things like this...
if (Failed) {
SDL_SetError("We failed");
return -1;
}
...into this...
if (Failed) {
return SDL_SetError("We failed");
}
Fixes Bugzilla #1778.
Matthias Bentrup 2012-08-09 12:53:17 PDT
With OpenGL 4.3 the ARB added a new context flag for context reset isolation
and renamed the existing ES2 profile bit to ES profile bit, as it can be used
to request GLES 3 compatible contexts, too.
This patch adds these changes to SDL on Linux and Windows.
Also SDL lacks the ability to create shared contexts. This patch also adds a
new GL attribute to enable context sharing. As casting a GL context to int is
not portable, I added only a boolean attribute
SDL_GL_SHARE_WITH_CURRENT_CONTEXT, which makes the new context share resources
with the context current on the creating thread.
This required a small public API change: SDL_GL_SetSwapInterval() now accepts
negative values, and SDL_GL_GetSwapInterval() doesn't report errors anymore
(if it can't work, it'll return zero as a reasonable default).
If you need to test for errors, such as a lack of swap_control_tear support,
check the results of SDL_GL_SetSwapInterval() when you set your desired
value.
Matthias Bentrup 2011-10-30 03:58:24 PDT
I've updated the context creation patch to include the bugfixes by Martin
Schreiber and also included a profile bit to request a ES2 compatible profile.
The wgl context creation may use 2 call to wglChoosePixelFormat if no
acceleration attribute is selected, this should work around a bug with buggy
AMD drivers (see #1254).
Jesse Anders 2011-03-05 23:30:09 PST
It seems that in Windows XP, setting SDL_GL_ACCELERATED_VISUAL to 1 actually
disables hardware acceleration and puts OpenGL in software mode.
In the source code, the corresponding WGL attribute is first set here:
*iAttr++ = WGL_ACCELERATION_ARB;
*iAttr++ = WGL_FULL_ACCELERATION_ARB;
Later, this code:
if (_this->gl_config.accelerated >= 0) {
*iAttr++ = WGL_ACCELERATION_ARB;
*iAttr++ =
(_this->gl_config.accelerated ? WGL_GENERIC_ACCELERATION_ARB :
WGL_NO_ACCELERATION_ARB);
}
Sets it again if SDL_GL_ACCELERATED_VISUAL has a value other than the default.
More importantly, the documentation I found states that
WGL_GENERIC_ACCELERATION_ARB asks for an MDC driver, which, although I don't
know much about this topic, doesn't seem like the correct choice here. As
mentioned previously, the end effect is that requesting hardware acceleration
in Windows XP actually forces the renderer into software mode (on my system at
least), which I'm guessing isn't the desired behavior.
I think this also fixes the bug relating to non-latin characters in filenames, since UNICODE wasn't defined in SDL_rwops.c
--HG--
rename : src/SDL_android.cpp => src/core/android/SDL_android.cpp
rename : src/SDL_android.h => src/core/android/SDL_android.h