reduce global SDLisms
This commit is contained in:
@@ -31,8 +31,7 @@ RageDisplay* DISPLAY = NULL;
|
|||||||
////////////
|
////////////
|
||||||
// Globals
|
// Globals
|
||||||
////////////
|
////////////
|
||||||
SDL_Surface *g_screen = NULL; // this class is a singleton, so there can be only one
|
bool g_Windowed;
|
||||||
int g_flags = 0; /* SDL video flags */
|
|
||||||
GLenum g_vertMode = GL_TRIANGLES;
|
GLenum g_vertMode = GL_TRIANGLES;
|
||||||
RageTimer g_LastCheckTimer;
|
RageTimer g_LastCheckTimer;
|
||||||
int g_iNumVerts;
|
int g_iNumVerts;
|
||||||
@@ -76,12 +75,8 @@ RageDisplay::RageDisplay( bool windowed, int width, int height, int bpp, int rat
|
|||||||
|
|
||||||
m_oglspecs = new oglspecs_t;
|
m_oglspecs = new oglspecs_t;
|
||||||
|
|
||||||
SDL_InitSubSystem(SDL_INIT_VIDEO);
|
|
||||||
|
|
||||||
SetVideoMode( windowed, width, height, bpp, rate, vsync );
|
SetVideoMode( windowed, width, height, bpp, rate, vsync );
|
||||||
|
|
||||||
SetupOpenGL();
|
|
||||||
|
|
||||||
// Log driver details
|
// Log driver details
|
||||||
LOG->Info("OGL Vendor: %s", glGetString(GL_VENDOR));
|
LOG->Info("OGL Vendor: %s", glGetString(GL_VENDOR));
|
||||||
LOG->Info("OGL Renderer: %s", glGetString(GL_RENDERER));
|
LOG->Info("OGL Renderer: %s", glGetString(GL_RENDERER));
|
||||||
@@ -212,15 +207,18 @@ void RageDisplay::SetupExtensions()
|
|||||||
bool RageDisplay::SetVideoMode( bool windowed, int width, int height, int bpp, int rate, bool vsync )
|
bool RageDisplay::SetVideoMode( bool windowed, int width, int height, int bpp, int rate, bool vsync )
|
||||||
{
|
{
|
||||||
// LOG->Trace( "RageDisplay::SetVideoMode( %d, %d, %d, %d, %d, %d )", windowed, width, height, bpp, rate, vsync );
|
// LOG->Trace( "RageDisplay::SetVideoMode( %d, %d, %d, %d, %d, %d )", windowed, width, height, bpp, rate, vsync );
|
||||||
|
if(!SDL_WasInit(SDL_INIT_VIDEO))
|
||||||
|
SDL_InitSubSystem(SDL_INIT_VIDEO);
|
||||||
|
|
||||||
g_flags = 0;
|
int flags = 0;
|
||||||
if( !windowed )
|
if( !windowed )
|
||||||
g_flags |= SDL_FULLSCREEN;
|
flags |= SDL_FULLSCREEN;
|
||||||
g_flags |= SDL_DOUBLEBUF;
|
flags |= SDL_DOUBLEBUF;
|
||||||
g_flags |= SDL_RESIZABLE;
|
flags |= SDL_RESIZABLE;
|
||||||
g_flags |= SDL_OPENGL;
|
flags |= SDL_OPENGL;
|
||||||
|
|
||||||
SDL_ShowCursor( ~g_flags & SDL_FULLSCREEN );
|
g_Windowed = windowed;
|
||||||
|
SDL_ShowCursor( g_Windowed );
|
||||||
|
|
||||||
ASSERT( bpp == 16 || bpp == 32 );
|
ASSERT( bpp == 16 || bpp == 32 );
|
||||||
switch( bpp )
|
switch( bpp )
|
||||||
@@ -248,8 +246,8 @@ bool RageDisplay::SetVideoMode( bool windowed, int width, int height, int bpp, i
|
|||||||
|
|
||||||
bool NewOpenGLContext = false;
|
bool NewOpenGLContext = false;
|
||||||
|
|
||||||
g_screen = SDL_SetVideoMode(width, height, bpp, g_flags);
|
SDL_Surface *screen = SDL_SetVideoMode(width, height, bpp, flags);
|
||||||
if(!g_screen)
|
if(!screen)
|
||||||
RageException::Throw("SDL_SetVideoMode failed: %s", SDL_GetError());
|
RageException::Throw("SDL_SetVideoMode failed: %s", SDL_GetError());
|
||||||
|
|
||||||
/* XXX: This event only exists in the SDL tree, and is only needed in
|
/* XXX: This event only exists in the SDL tree, and is only needed in
|
||||||
@@ -266,30 +264,12 @@ bool RageDisplay::SetVideoMode( bool windowed, int width, int height, int bpp, i
|
|||||||
if(TEXTUREMAN)
|
if(TEXTUREMAN)
|
||||||
TEXTUREMAN->InvalidateTextures();
|
TEXTUREMAN->InvalidateTextures();
|
||||||
|
|
||||||
SetupOpenGL();
|
|
||||||
|
|
||||||
SDL_WM_SetCaption("StepMania", "StepMania");
|
SDL_WM_SetCaption("StepMania", "StepMania");
|
||||||
|
|
||||||
NewOpenGLContext = true;
|
NewOpenGLContext = true;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
DumpOpenGLDebugInfo();
|
|
||||||
|
|
||||||
/* Now that we've initialized, we can search for extensions (some of which
|
|
||||||
* we may need to set up the video mode). */
|
|
||||||
SetupExtensions();
|
|
||||||
|
|
||||||
/* Set vsync the Windows way, if we can. (What other extensions are there
|
|
||||||
* to do this, for other archs?) */
|
|
||||||
if(m_oglspecs->WGL_EXT_swap_control) {
|
|
||||||
GLExt::wglSwapIntervalEXT(vsync);
|
|
||||||
}
|
|
||||||
|
|
||||||
g_CurrentWidth = g_screen->w;
|
|
||||||
g_CurrentHeight = g_screen->h;
|
|
||||||
g_CurrentBPP = bpp;
|
|
||||||
|
|
||||||
{
|
{
|
||||||
/* Find out what we really got. */
|
/* Find out what we really got. */
|
||||||
int r,g,b,a, colorbits, depth, stencil;
|
int r,g,b,a, colorbits, depth, stencil;
|
||||||
@@ -305,6 +285,23 @@ bool RageDisplay::SetVideoMode( bool windowed, int width, int height, int bpp, i
|
|||||||
colorbits, r, g, b, a, depth, stencil);
|
colorbits, r, g, b, a, depth, stencil);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SetupOpenGL();
|
||||||
|
DumpOpenGLDebugInfo();
|
||||||
|
|
||||||
|
/* Now that we've initialized, we can search for extensions (some of which
|
||||||
|
* we may need to set up the video mode). */
|
||||||
|
SetupExtensions();
|
||||||
|
|
||||||
|
/* Set vsync the Windows way, if we can. (What other extensions are there
|
||||||
|
* to do this, for other archs?) */
|
||||||
|
if(m_oglspecs->WGL_EXT_swap_control) {
|
||||||
|
GLExt::wglSwapIntervalEXT(vsync);
|
||||||
|
}
|
||||||
|
|
||||||
|
g_CurrentWidth = screen->w;
|
||||||
|
g_CurrentHeight = screen->h;
|
||||||
|
g_CurrentBPP = bpp;
|
||||||
|
|
||||||
SetViewport(0,0);
|
SetViewport(0,0);
|
||||||
|
|
||||||
/* Clear any junk that's in the framebuffer. */
|
/* Clear any junk that's in the framebuffer. */
|
||||||
@@ -482,7 +479,7 @@ void RageDisplay::SaveScreenshot( CString sPath )
|
|||||||
|
|
||||||
bool RageDisplay::IsWindowed() const
|
bool RageDisplay::IsWindowed() const
|
||||||
{
|
{
|
||||||
return !(g_flags & SDL_FULLSCREEN);
|
return g_Windowed;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RageDisplay::DrawQuad( const RageVertex v[4] ) // upper-left, upper-right, lower-right, lower-left
|
void RageDisplay::DrawQuad( const RageVertex v[4] ) // upper-left, upper-right, lower-right, lower-left
|
||||||
|
|||||||
Reference in New Issue
Block a user