From 086bf5bf891467d7ba49cf9ef7095245d439c390 Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Tue, 12 Nov 2002 20:39:08 +0000 Subject: [PATCH] move extension tests to after opengl init --- stepmania/src/RageDisplay.cpp | 50 ++++++++++++++++++++++------------- stepmania/src/RageDisplay.h | 1 + 2 files changed, 32 insertions(+), 19 deletions(-) diff --git a/stepmania/src/RageDisplay.cpp b/stepmania/src/RageDisplay.cpp index d8ea88c4af..947145b56b 100644 --- a/stepmania/src/RageDisplay.cpp +++ b/stepmania/src/RageDisplay.cpp @@ -84,19 +84,6 @@ RageDisplay::RageDisplay( bool windowed, int width, int height, int bpp, int rat SetVideoMode( windowed, width, height, bpp, rate, vsync ); - double fGLVersion = atof( (const char *) glGetString(GL_VERSION) ); - g_glVersion = int(roundf(fGLVersion * 10)); - LOG->Trace( "OpenGL version %.1f", g_glVersion / 10.); - GetGLExtensions(g_glExts); - if(g_glExts.find("GL_EXT_texture_env_combine") != g_glExts.end()) - g_GL_EXT_texture_env_combine = true; - - glBlendFuncSeparate = (PFNGLBLENDFUNCSEPARATEPROC) SDL_GL_GetProcAddress ("glBlendFuncSeparate"); - - /* Windows vsync: */ - if(g_glExts.find("WGL_EXT_swap_control") != g_glExts.end()) - wglSwapIntervalEXT = (PWSWAPINTERVALEXTPROC) SDL_GL_GetProcAddress("wglSwapIntervalEXT"); - SetupOpenGL(); } @@ -117,11 +104,31 @@ void RageDisplay::SetupOpenGL() glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); } + RageDisplay::~RageDisplay() { SDL_QuitSubSystem(SDL_INIT_VIDEO); } +void RageDisplay::SetupExtensions() +{ + double fGLVersion = atof( (const char *) glGetString(GL_VERSION) ); + g_glVersion = int(roundf(fGLVersion * 10)); + LOG->Trace( "OpenGL version %.1f", g_glVersion / 10.); + GetGLExtensions(g_glExts); + if(g_glExts.find("GL_EXT_texture_env_combine") != g_glExts.end()) + g_GL_EXT_texture_env_combine = true; + + glBlendFuncSeparate = (PFNGLBLENDFUNCSEPARATEPROC) SDL_GL_GetProcAddress ("glBlendFuncSeparate"); + + /* Windows vsync: */ + if(g_glExts.find("WGL_EXT_swap_control") != g_glExts.end()) { + wglSwapIntervalEXT = (PWSWAPINTERVALEXTPROC) SDL_GL_GetProcAddress("wglSwapIntervalEXT"); + if(wglSwapIntervalEXT) + LOG->Trace("Got wglSwapIntervalEXT"); + } +} + /* Set the video mode. In some cases, changing the video mode will reset * the rendering context; returns true if we need to reload textures. */ bool RageDisplay::SetVideoMode( bool windowed, int width, int height, int bpp, int rate, bool vsync ) @@ -179,11 +186,6 @@ bool RageDisplay::SetVideoMode( bool windowed, int width, int height, int bpp, i } #endif - /* Set vsync the Windows way, if we can. (What other extensions are there - * to do this, for other archs?) */ - if(wglSwapIntervalEXT) - wglSwapIntervalEXT(vsync); - if(!g_screen) { g_screen = SDL_SetVideoMode(width, height, bpp, g_flags); if(!g_screen) @@ -198,6 +200,16 @@ bool RageDisplay::SetVideoMode( bool windowed, int width, int height, int bpp, i } #endif + /* 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(wglSwapIntervalEXT) { + wglSwapIntervalEXT(vsync); + } + if(need_reload) { /* OpenGL state was lost; set up again. */ SetupOpenGL(); @@ -240,7 +252,7 @@ void RageDisplay::Flip() g_iVertsRenderedSinceLastCheck = 0; g_iDPF = g_iDrawsSinceLastCheck / g_iFPS; g_iDrawsSinceLastCheck = 0; - //LOG->Trace( "FPS: %d, VPF: %d, DPF: %d", m_iFPS, m_iVPF, m_iDPF ); + LOG->Trace( "FPS: %d, VPF: %d, DPF: %d", g_iFPS, g_iVPF, g_iDPF ); } } diff --git a/stepmania/src/RageDisplay.h b/stepmania/src/RageDisplay.h index b544c2c24d..06d7d5a035 100644 --- a/stepmania/src/RageDisplay.h +++ b/stepmania/src/RageDisplay.h @@ -81,6 +81,7 @@ protected: void AddVerts( const RageVertex v[], int iNumVerts ); void SetBlendMode(int src, int dst); void SetupOpenGL(); + void SetupExtensions(); };