For the SDL version of this driver, set the video mode in the CPU thread, otherwise GL calls will crash. There is a big comment block with all the details.

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@291 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
Maarten ter Huurne 2008-08-24 14:47:19 +00:00
parent 6f1600304f
commit e3d7c44a8e
1 changed files with 33 additions and 35 deletions

View File

@ -407,10 +407,7 @@ bool OpenGL_Create(SVideoInitialize &_VideoInitialize, int _iwidth, int _iheight
XMapRaised(GLWin.dpy, GLWin.win);
}
#else
//SDL for other OS (osx, bsd, ...)
int videoFlags = SDL_OPENGL;
SDL_Surface *screen;
const SDL_VideoInfo *videoInfo;
//SDL for other OS (osx, bsd, ...)
//init sdl video
if (SDL_Init(SDL_INIT_VIDEO) < 0) {
@ -418,39 +415,14 @@ bool OpenGL_Create(SVideoInitialize &_VideoInitialize, int _iwidth, int _iheight
SDL_Quit();
return false;
}
//fetch video info
videoInfo = SDL_GetVideoInfo();
if (!videoInfo) {
//TODO : Display an error message
SDL_Quit();
return false;
}
//hw or sw ogl ?
if (videoInfo->hw_available)
videoFlags |= SDL_HWSURFACE;
else
videoFlags |= SDL_SWSURFACE;
//fullscreen or not
if(g_Config.bFullscreen)
videoFlags |= SDL_FULLSCREEN;
//setup ogl to use double buffering
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
screen = SDL_SetVideoMode(_twidth, _theight, 0, videoFlags);
if (!screen) {
//TODO : Display an error message
SDL_Quit();
return false;
}
#endif
return true;
}
bool OpenGL_MakeCurrent()
{
#if defined(_WIN32)
@ -475,10 +447,36 @@ bool OpenGL_MakeCurrent()
XSelectInput(GLWin.dpy, GLWin.win, ExposureMask | KeyPressMask | KeyReleaseMask |
ButtonPressMask | StructureNotifyMask | EnterWindowMask | LeaveWindowMask |
FocusChangeMask );
#else
//TODO
#else
// Note: The reason for having the call to SDL_SetVideoMode in here instead
// of in OpenGL_Create() is that "make current" is part of the video
// mode setting and is not available as a separate call in SDL. We
// have to do "make current" here because this method runs in the CPU
// thread while OpenGL_Create() runs in a diferent thread and "make
// current" has to be done in the same thread that will be making
// calls to OpenGL.
// Fetch video info.
const SDL_VideoInfo *videoInfo = SDL_GetVideoInfo();
if (!videoInfo) {
// TODO: Display an error message.
SDL_Quit();
return false;
}
// Compute video mode flags.
const int videoFlags = SDL_OPENGL
| ( videoInfo->hw_available ? SDL_HWSURFACE : SDL_SWSURFACE )
| ( g_Config.bFullscreen ? SDL_FULLSCREEN : 0);
// Set vide mode.
// TODO: Can we use this field or is a separate field needed?
int _twidth = nBackbufferWidth;
int _theight = nBackbufferHeight;
SDL_Surface *screen = SDL_SetVideoMode(_twidth, _theight, 0, videoFlags);
if (!screen) {
//TODO : Display an error message
SDL_Quit();
return false;
}
#endif
return true;
}