mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-01-26 15:55:31 +01:00
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:
parent
6f1600304f
commit
e3d7c44a8e
@ -407,10 +407,7 @@ bool OpenGL_Create(SVideoInitialize &_VideoInitialize, int _iwidth, int _iheight
|
|||||||
XMapRaised(GLWin.dpy, GLWin.win);
|
XMapRaised(GLWin.dpy, GLWin.win);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
//SDL for other OS (osx, bsd, ...)
|
//SDL for other OS (osx, bsd, ...)
|
||||||
int videoFlags = SDL_OPENGL;
|
|
||||||
SDL_Surface *screen;
|
|
||||||
const SDL_VideoInfo *videoInfo;
|
|
||||||
|
|
||||||
//init sdl video
|
//init sdl video
|
||||||
if (SDL_Init(SDL_INIT_VIDEO) < 0) {
|
if (SDL_Init(SDL_INIT_VIDEO) < 0) {
|
||||||
@ -418,39 +415,14 @@ bool OpenGL_Create(SVideoInitialize &_VideoInitialize, int _iwidth, int _iheight
|
|||||||
SDL_Quit();
|
SDL_Quit();
|
||||||
return false;
|
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
|
//setup ogl to use double buffering
|
||||||
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
|
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
|
#endif
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool OpenGL_MakeCurrent()
|
bool OpenGL_MakeCurrent()
|
||||||
{
|
{
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
@ -475,10 +447,36 @@ bool OpenGL_MakeCurrent()
|
|||||||
XSelectInput(GLWin.dpy, GLWin.win, ExposureMask | KeyPressMask | KeyReleaseMask |
|
XSelectInput(GLWin.dpy, GLWin.win, ExposureMask | KeyPressMask | KeyReleaseMask |
|
||||||
ButtonPressMask | StructureNotifyMask | EnterWindowMask | LeaveWindowMask |
|
ButtonPressMask | StructureNotifyMask | EnterWindowMask | LeaveWindowMask |
|
||||||
FocusChangeMask );
|
FocusChangeMask );
|
||||||
#else
|
#else
|
||||||
|
// Note: The reason for having the call to SDL_SetVideoMode in here instead
|
||||||
//TODO
|
// 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
|
#endif
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user