diff --git a/desmume/src/OGLRender.cpp b/desmume/src/OGLRender.cpp index af9a3f25f..585fc306f 100644 --- a/desmume/src/OGLRender.cpp +++ b/desmume/src/OGLRender.cpp @@ -486,6 +486,7 @@ static void texDeleteCallback(TexCacheItem *item) _OGLRenderer->DeleteTexture(item); } +template static char OGLInit(void) { char result = 0; @@ -528,10 +529,19 @@ static char OGLInit(void) } // Create new OpenGL rendering object - if (OGLLoadEntryPoints_3_2_Func != NULL && OGLCreateRenderer_3_2_Func != NULL) + if(enable_3_2) { - OGLLoadEntryPoints_3_2_Func(); - OGLCreateRenderer_3_2_Func(&_OGLRenderer); + if (OGLLoadEntryPoints_3_2_Func != NULL && OGLCreateRenderer_3_2_Func != NULL) + { + OGLLoadEntryPoints_3_2_Func(); + OGLLoadEntryPoints_Legacy(); //zero 04-feb-2013 - this seems to be necessary as well + OGLCreateRenderer_3_2_Func(&_OGLRenderer); + } + else + { + if(require_profile) + return 0; + } } // If the renderer doesn't initialize with OpenGL v3.2 or higher, fall back @@ -667,9 +677,32 @@ static void OGLRenderFinish() ENDGL(); } +//automatically select 3.2 or old profile depending on whether 3.2 is available GPU3DInterface gpu3Dgl = { "OpenGL", - OGLInit, + OGLInit, + OGLReset, + OGLClose, + OGLRender, + OGLRenderFinish, + OGLVramReconfigureSignal +}; + +//forcibly use old profile +GPU3DInterface gpu3DglOld = { + "OpenGL", + OGLInit, + OGLReset, + OGLClose, + OGLRender, + OGLRenderFinish, + OGLVramReconfigureSignal +}; + +//forcibly use new profile +GPU3DInterface gpu3Dgl_3_2 = { + "OpenGL 3.2", + OGLInit, OGLReset, OGLClose, OGLRender, diff --git a/desmume/src/OGLRender.h b/desmume/src/OGLRender.h index b4eafd0d1..9a2f2e37c 100644 --- a/desmume/src/OGLRender.h +++ b/desmume/src/OGLRender.h @@ -355,6 +355,8 @@ class TexCacheItem; class OpenGLRenderer; extern GPU3DInterface gpu3Dgl; +extern GPU3DInterface gpu3DglOld; +extern GPU3DInterface gpu3Dgl_3_2; //This is called by OGLRender whenever it initializes. //Platforms, please be sure to set this up. diff --git a/desmume/src/windows/DeSmuME_2005.vcproj b/desmume/src/windows/DeSmuME_2005.vcproj index 9bfea6180..27500de71 100644 --- a/desmume/src/windows/DeSmuME_2005.vcproj +++ b/desmume/src/windows/DeSmuME_2005.vcproj @@ -2768,6 +2768,14 @@ RelativePath="..\OGLRender.h" > + + + + diff --git a/desmume/src/windows/DeSmuME_2008.vcproj b/desmume/src/windows/DeSmuME_2008.vcproj index f87977fc0..bcada0c84 100644 --- a/desmume/src/windows/DeSmuME_2008.vcproj +++ b/desmume/src/windows/DeSmuME_2008.vcproj @@ -1,7 +1,7 @@ + + + + diff --git a/desmume/src/windows/DeSmuME_2010.vcxproj b/desmume/src/windows/DeSmuME_2010.vcxproj index 06ad18c55..3fc03785b 100644 --- a/desmume/src/windows/DeSmuME_2010.vcxproj +++ b/desmume/src/windows/DeSmuME_2010.vcxproj @@ -1,4 +1,4 @@ - + @@ -432,6 +432,7 @@ + @@ -710,6 +711,7 @@ + diff --git a/desmume/src/windows/DeSmuME_2010.vcxproj.filters b/desmume/src/windows/DeSmuME_2010.vcxproj.filters index e9bf0480b..2aef8e997 100644 --- a/desmume/src/windows/DeSmuME_2010.vcxproj.filters +++ b/desmume/src/windows/DeSmuME_2010.vcxproj.filters @@ -774,6 +774,9 @@ Core\utils\AsmJit\x86 + + Core + @@ -1494,6 +1497,9 @@ Core\utils\AsmJit\x86 + + Core + diff --git a/desmume/src/windows/DeSmuME_2012.vcxproj b/desmume/src/windows/DeSmuME_2012.vcxproj index e6ba23159..683ec5f60 100644 --- a/desmume/src/windows/DeSmuME_2012.vcxproj +++ b/desmume/src/windows/DeSmuME_2012.vcxproj @@ -1,4 +1,4 @@ - + @@ -406,6 +406,7 @@ + @@ -650,6 +651,7 @@ + diff --git a/desmume/src/windows/DeSmuME_2012.vcxproj.filters b/desmume/src/windows/DeSmuME_2012.vcxproj.filters index d2b106cfc..33803ad87 100644 --- a/desmume/src/windows/DeSmuME_2012.vcxproj.filters +++ b/desmume/src/windows/DeSmuME_2012.vcxproj.filters @@ -762,6 +762,9 @@ Windows\tools + + Core + @@ -1283,6 +1286,9 @@ Windows\tools + + Core + diff --git a/desmume/src/windows/hotkey.cpp b/desmume/src/windows/hotkey.cpp index cdbfee024..f4cf0a26b 100644 --- a/desmume/src/windows/hotkey.cpp +++ b/desmume/src/windows/hotkey.cpp @@ -451,9 +451,9 @@ void HK_FrameAdvanceKeyDown(int, bool justPressed) { FrameAdvance(true); } void HK_FrameAdvanceKeyUp(int) { FrameAdvance(false); } void HK_ToggleRasterizer(int, bool justPressed) { - if(cur3DCore == GPU3D_OPENGL) + if(cur3DCore == GPU3D_OPENGL_OLD || cur3DCore == GPU3D_OPENGL_3_2) cur3DCore = GPU3D_SWRAST; - else cur3DCore = GPU3D_OPENGL; + else cur3DCore = GPU3D_OPENGL_3_2; Change3DCoreWithFallbackAndSave(cur3DCore); } diff --git a/desmume/src/windows/main.cpp b/desmume/src/windows/main.cpp index 0bb7ce650..7f3c2665a 100644 --- a/desmume/src/windows/main.cpp +++ b/desmume/src/windows/main.cpp @@ -48,6 +48,7 @@ #include "../addons.h" #include "../GPU_osd.h" #include "../OGLRender.h" +#include "../OGLRender_3_2.h" #include "../rasterize.h" #include "../gfx3d.h" #include "../render3D.h" @@ -466,8 +467,9 @@ SoundInterface_struct *SNDCoreList[] = { GPU3DInterface *core3DList[] = { &gpu3DNull, - &gpu3Dgl, + &gpu3Dgl_3_2, &gpu3DRasterize, + &gpu3DglOld, NULL }; @@ -2766,6 +2768,11 @@ int _main() dwMainThread = GetCurrentThreadId(); + //enable opengl 3.2 driver in this port + OGLLoadEntryPoints_3_2_Func = OGLLoadEntryPoints_3_2; + OGLCreateRenderer_3_2_Func = OGLCreateRenderer_3_2; + + #ifdef HAVE_WX wxInitialize(); #endif @@ -5949,13 +5956,31 @@ DOKEYDOWN: return DefWindowProc (hwnd, message, wParam, lParam); } -void Change3DCoreWithFallbackAndSave(int newCore, int fallbackCore) +void Change3DCoreWithFallbackAndSave(int newCore) { - if(!NDS_3D_ChangeCore(newCore) && newCore != fallbackCore) - NDS_3D_ChangeCore(fallbackCore); + if(newCore == GPU3D_OPENGL_OLD) + goto TRY_OGL; + + if(newCore == GPU3D_SWRAST) + goto TRY_SWRAST; + + if(!NDS_3D_ChangeCore(GPU3D_OPENGL_3_2)) + goto TRY_OGL; + goto DONE; + +TRY_OGL: + if(!NDS_3D_ChangeCore(GPU3D_OPENGL_OLD)) + goto TRY_SWRAST; + goto DONE; + +TRY_SWRAST: + NDS_3D_ChangeCore(GPU3D_SWRAST); + +DONE: int gpu3dSaveValue = ((cur3DCore != GPU3D_NULL) ? cur3DCore : GPU3D_NULL_SAVED); WritePrivateProfileInt("3D", "Renderer", gpu3dSaveValue, IniName); } + LRESULT CALLBACK HUDFontSettingsDlgProc(HWND hw, UINT msg, WPARAM wp, LPARAM lp) { switch(msg) diff --git a/desmume/src/windows/main.h b/desmume/src/windows/main.h index 29b0d2de6..362e3a2b3 100644 --- a/desmume/src/windows/main.h +++ b/desmume/src/windows/main.h @@ -48,8 +48,9 @@ extern bool FpsDisplay; extern bool ShowLagFrameCounter; #define GPU3D_NULL 0 -#define GPU3D_OPENGL 1 +#define GPU3D_OPENGL_3_2 1 #define GPU3D_SWRAST 2 +#define GPU3D_OPENGL_OLD 3 static const int LANGUAGE_ENGLISH = 0; static const int LANGUAGE_FRENCH = 1; @@ -60,7 +61,7 @@ static const int LANGUAGE_SPANISH = 6; static const int LANGUAGE_KOREAN = 7; static const int LANGUAGE_BRAZILIAN = 8; -extern void Change3DCoreWithFallbackAndSave(int newCore, int fallbackCore=GPU3D_SWRAST); +extern void Change3DCoreWithFallbackAndSave(int newCore); extern int backupmemorytype; extern u32 backupmemorysize;