diff --git a/stepmania/src/RageDisplay_OGL.cpp b/stepmania/src/RageDisplay_OGL.cpp index cb2e325eaa..a93c8ef267 100644 --- a/stepmania/src/RageDisplay_OGL.cpp +++ b/stepmania/src/RageDisplay_OGL.cpp @@ -1,39 +1,13 @@ #include "global.h" -/* ours may be more up-to-date */ -#define __glext_h_ - -#if defined(WIN32) -#include -#endif - -#if !defined(MACOSX) -# include -# include -#else -# include -# include -#endif - -#undef __glext_h_ -#include "glext.h" +#include "RageDisplay_OGL.h" +#include "RageDisplay_OGL_Helpers.h" +using namespace RageDisplay_OGL_Helpers; #include "RageSurface.h" #include "RageSurfaceUtils.h" - -/* Windows's broken gl.h defines GL_EXT_paletted_texture incompletely: */ -#ifndef GL_TEXTURE_INDEX_SIZE_EXT -#define GL_TEXTURE_INDEX_SIZE_EXT 0x80ED -#endif -#include -#include - -#include "RageDisplay.h" -#include "RageDisplay_OGL.h" -#include "RageDisplay_OGL_Helpers.h" #include "RageUtil.h" #include "RageLog.h" -#include "RageTimer.h" #include "RageException.h" #include "RageTextureManager.h" #include "RageMath.h" @@ -41,7 +15,6 @@ #include "RageUtil.h" #include "EnumHelper.h" #include "Foreach.h" -#include "ProductInfo.h" #include "DisplayResolutions.h" #include "LocalizedString.h" @@ -49,6 +22,9 @@ #include "arch/arch.h" +#include +#include + #if defined(_MSC_VER) #pragma comment(lib, "opengl32.lib") #pragma comment(lib, "glu32.lib") @@ -143,30 +119,6 @@ static RageDisplay::PixelFormatDesc PIXEL_FORMAT_DESC[NUM_PixelFormat] = { } }; -static map g_Strings; -static void InitStringMap() -{ - static bool Initialized = false; - if(Initialized) return; - Initialized = true; - #define X(a) g_Strings[a] = #a; - X(GL_RGBA8); X(GL_RGBA4); X(GL_RGB5_A1); X(GL_RGB5); X(GL_RGBA); X(GL_RGB); - X(GL_BGR); X(GL_BGRA); - X(GL_COLOR_INDEX8_EXT); X(GL_COLOR_INDEX4_EXT); X(GL_COLOR_INDEX); - X(GL_UNSIGNED_BYTE); X(GL_UNSIGNED_SHORT_4_4_4_4); X(GL_UNSIGNED_SHORT_5_5_5_1); - X(GL_UNSIGNED_SHORT_1_5_5_5_REV); - X(GL_INVALID_ENUM); X(GL_INVALID_VALUE); X(GL_INVALID_OPERATION); - X(GL_STACK_OVERFLOW); X(GL_STACK_UNDERFLOW); X(GL_OUT_OF_MEMORY); -} - -static RString GLToString( GLenum e ) -{ - if( g_Strings.find(e) != g_Strings.end() ) - return g_Strings[e]; - - return ssprintf( "%i", int(e) ); -} - /* g_GLPixFmtInfo is used for both texture formats and surface formats. For example, * it's fine to ask for a PixelFormat_RGB5 texture, but to supply a surface matching * PixelFormat_RGB8. OpenGL will simply discard the extra bits. @@ -289,7 +241,7 @@ RageDisplay_OGL::RageDisplay_OGL() LOG->MapLog("renderer", "Current renderer: OpenGL"); FixLittleEndian(); - InitStringMap(); + RageDisplay_OGL_Helpers::Init(); g_pWind = NULL; g_bTextureMatrixShader = 0; diff --git a/stepmania/src/RageDisplay_OGL.h b/stepmania/src/RageDisplay_OGL.h index d5664b8557..50a54c1b2b 100644 --- a/stepmania/src/RageDisplay_OGL.h +++ b/stepmania/src/RageDisplay_OGL.h @@ -3,6 +3,8 @@ #ifndef RAGEDISPLAY_OGL_H #define RAGEDISPLAY_OGL_H +#include "RageDisplay.h" + class RageDisplay_OGL: public RageDisplay { public: diff --git a/stepmania/src/RageDisplay_OGL_Helpers.cpp b/stepmania/src/RageDisplay_OGL_Helpers.cpp index 1186ebcc94..c82f7f0f6a 100644 --- a/stepmania/src/RageDisplay_OGL_Helpers.cpp +++ b/stepmania/src/RageDisplay_OGL_Helpers.cpp @@ -1,29 +1,50 @@ #include "global.h" - -#define __glext_h_ - -#if defined(WIN32) -#include -#endif - -#include - -#if !defined(MACOSX) -# include -# include -#else -# include -# include -#endif - -#undef __glext_h_ -#include "glext.h" - #include "RageDisplay_OGL_Helpers.h" +#include "RageUtil.h" + #include "RageLog.h" #include "RageUtil.h" #include "arch/LowLevelWindow/LowLevelWindow.h" +#include +#include + +namespace +{ + map g_Strings; + void InitStringMap() + { + static bool bInitialized = false; + if( bInitialized ) + return; + bInitialized = true; + +#define X(a) g_Strings[a] = #a; + X(GL_RGBA8); X(GL_RGBA4); X(GL_RGB5_A1); X(GL_RGB5); X(GL_RGBA); X(GL_RGB); + X(GL_BGR); X(GL_BGRA); + X(GL_COLOR_INDEX8_EXT); X(GL_COLOR_INDEX4_EXT); X(GL_COLOR_INDEX); + X(GL_UNSIGNED_BYTE); X(GL_UNSIGNED_SHORT_4_4_4_4); X(GL_UNSIGNED_SHORT_5_5_5_1); + X(GL_UNSIGNED_SHORT_1_5_5_5_REV); + X(GL_INVALID_ENUM); X(GL_INVALID_VALUE); X(GL_INVALID_OPERATION); + X(GL_STACK_OVERFLOW); X(GL_STACK_UNDERFLOW); X(GL_OUT_OF_MEMORY); +#undef X + } +}; + +void RageDisplay_OGL_Helpers::Init() +{ + InitStringMap(); +} + +RString RageDisplay_OGL_Helpers::GLToString( GLenum e ) +{ + if( g_Strings.find(e) != g_Strings.end() ) + return g_Strings[e]; + + return ssprintf( "%i", int(e) ); +} + + GLExt_t GLExt; /* Available extensions: */ @@ -192,7 +213,7 @@ void GLExt_t::Load( LowLevelWindow *pWind ) } /* - * Copyright (c) 2002-2005 Glenn Maynard + * Copyright (c) 2001-2005 Chris Danford, Glenn Maynard * All rights reserved. * * Permission is hereby granted, free of charge, to any person obtaining a diff --git a/stepmania/src/RageDisplay_OGL_Helpers.h b/stepmania/src/RageDisplay_OGL_Helpers.h index 26ba1b2697..7f40ed2771 100644 --- a/stepmania/src/RageDisplay_OGL_Helpers.h +++ b/stepmania/src/RageDisplay_OGL_Helpers.h @@ -1,11 +1,38 @@ -/* RageDisplay_OGL_Extensions - OpenGL extension helpers. */ +#ifndef RAGE_DISPLAY_OGL_HELPERS_H +#define RAGE_DISPLAY_OGL_HELPERS_H -#ifndef RAGE_DISPLAY_OGL_EXTENSIONS_H -#define RAGE_DISPLAY_OGL_EXTENSIONS_H +/* ours may be more up-to-date */ +#define __glext_h_ + +#if defined(WIN32) +#include +#endif + +#if !defined(MACOSX) +# include +# include +#else +# include +# include +#endif + +#undef __glext_h_ +#include "glext.h" + +/* Windows defines GL_EXT_paletted_texture incompletely: */ +#ifndef GL_TEXTURE_INDEX_SIZE_EXT +#define GL_TEXTURE_INDEX_SIZE_EXT 0x80ED +#endif /* Not in glext.h: */ typedef bool (APIENTRY * PWSWAPINTERVALEXTPROC) (int interval); +namespace RageDisplay_OGL_Helpers +{ + void Init(); + RString GLToString( GLenum e ); +}; + class LowLevelWindow; struct GLExt_t { @@ -61,7 +88,7 @@ extern GLExt_t GLExt; #endif /* - * Copyright (c) 2003-2005 Glenn Maynard + * Copyright (c) 2001-2004 Chris Danford, Glenn Maynard * All rights reserved. * * Permission is hereby granted, free of charge, to any person obtaining a