switching the renderer to SoftRasterizer instead of None in the case that the OpenGL renderer fails

This commit is contained in:
nitsuja 2009-11-28 23:30:55 +00:00
parent 8a40316fe3
commit f257f61412
5 changed files with 27 additions and 11 deletions

View File

@ -42,7 +42,7 @@ void NDS_3D_SetDriver (int core3DIndex)
gpu3D = core3DList[cur3DCore]; gpu3D = core3DList[cur3DCore];
} }
void NDS_3D_ChangeCore(int newCore) bool NDS_3D_ChangeCore(int newCore)
{ {
gpu3D->NDS_3D_Close(); gpu3D->NDS_3D_Close();
NDS_3D_SetDriver(newCore); NDS_3D_SetDriver(newCore);
@ -50,5 +50,7 @@ void NDS_3D_ChangeCore(int newCore)
{ {
NDS_3D_SetDriver(GPU3D_NULL); NDS_3D_SetDriver(GPU3D_NULL);
gpu3D->NDS_3D_Init(); gpu3D->NDS_3D_Init();
return false;
} }
return true;
} }

View File

@ -61,7 +61,7 @@ extern GPU3DInterface gpu3DNull;
extern GPU3DInterface *gpu3D; extern GPU3DInterface *gpu3D;
void NDS_3D_SetDriver (int core3DIndex); void NDS_3D_SetDriver (int core3DIndex);
void NDS_3D_ChangeCore(int newCore); bool NDS_3D_ChangeCore(int newCore);
#endif #endif

View File

@ -378,8 +378,7 @@ void HK_ToggleRasterizer(int, bool justPressed) {
cur3DCore = GPU3D_SWRAST; cur3DCore = GPU3D_SWRAST;
else cur3DCore = GPU3D_OPENGL; else cur3DCore = GPU3D_OPENGL;
NDS_3D_ChangeCore(cur3DCore); Change3DCoreWithFallbackAndSave(cur3DCore);
WritePrivateProfileInt("3D", "Renderer", cur3DCore, IniName);
} }
//====================================================================================== //======================================================================================

View File

@ -2134,6 +2134,9 @@ static void RefreshMicSettings()
} }
} }
#define GPU3D_NULL_SAVED -1
#define GPU3D_DEFAULT GPU3D_OPENGL
DWORD wmTimerRes; DWORD wmTimerRes;
int _main() int _main()
{ {
@ -2471,12 +2474,16 @@ int _main()
hKeyInputTimer = timeSetEvent (KeyInRepeatMSec, 0, KeyInputTimer, 0, TIME_PERIODIC); hKeyInputTimer = timeSetEvent (KeyInRepeatMSec, 0, KeyInputTimer, 0, TIME_PERIODIC);
cur3DCore = GetPrivateProfileInt("3D", "Renderer", GPU3D_OPENGL, IniName); cur3DCore = GetPrivateProfileInt("3D", "Renderer", GPU3D_DEFAULT, IniName);
if(cur3DCore == GPU3D_NULL_SAVED)
cur3DCore = GPU3D_NULL;
else if(cur3DCore == GPU3D_NULL) // this value shouldn't be saved anymore
cur3DCore = GPU3D_DEFAULT;
CommonSettings.GFX3D_HighResolutionInterpolateColor = GetPrivateProfileBool("3D", "HighResolutionInterpolateColor", 1, IniName); CommonSettings.GFX3D_HighResolutionInterpolateColor = GetPrivateProfileBool("3D", "HighResolutionInterpolateColor", 1, IniName);
CommonSettings.GFX3D_EdgeMark = GetPrivateProfileBool("3D", "EnableEdgeMark", 1, IniName); CommonSettings.GFX3D_EdgeMark = GetPrivateProfileBool("3D", "EnableEdgeMark", 1, IniName);
CommonSettings.GFX3D_Fog = GetPrivateProfileBool("3D", "EnableFog", 1, IniName); CommonSettings.GFX3D_Fog = GetPrivateProfileBool("3D", "EnableFog", 1, IniName);
//CommonSettings.gfx3d_flushMode = GetPrivateProfileInt("3D", "AlternateFlush", 0, IniName); //CommonSettings.gfx3d_flushMode = GetPrivateProfileInt("3D", "AlternateFlush", 0, IniName);
NDS_3D_ChangeCore(cur3DCore); Change3DCoreWithFallbackAndSave(cur3DCore);
#ifdef BETA_VERSION #ifdef BETA_VERSION
EnableMenuItem (mainMenu, IDM_SUBMITBUGREPORT, MF_GRAYED); EnableMenuItem (mainMenu, IDM_SUBMITBUGREPORT, MF_GRAYED);
@ -4991,6 +4998,14 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM
return DefWindowProc (hwnd, message, wParam, lParam); return DefWindowProc (hwnd, message, wParam, lParam);
} }
void Change3DCoreWithFallbackAndSave(int newCore, int fallbackCore)
{
if(!NDS_3D_ChangeCore(newCore) && newCore != fallbackCore)
NDS_3D_ChangeCore(fallbackCore);
int gpu3dSaveValue = ((cur3DCore != GPU3D_NULL) ? cur3DCore : GPU3D_NULL_SAVED);
WritePrivateProfileInt("3D", "Renderer", gpu3dSaveValue, IniName);
}
LRESULT CALLBACK GFX3DSettingsDlgProc(HWND hw, UINT msg, WPARAM wp, LPARAM lp) LRESULT CALLBACK GFX3DSettingsDlgProc(HWND hw, UINT msg, WPARAM wp, LPARAM lp)
{ {
switch(msg) switch(msg)
@ -5021,8 +5036,7 @@ LRESULT CALLBACK GFX3DSettingsDlgProc(HWND hw, UINT msg, WPARAM wp, LPARAM lp)
CommonSettings.GFX3D_HighResolutionInterpolateColor = IsDlgCheckboxChecked(hw,IDC_INTERPOLATECOLOR); CommonSettings.GFX3D_HighResolutionInterpolateColor = IsDlgCheckboxChecked(hw,IDC_INTERPOLATECOLOR);
CommonSettings.GFX3D_EdgeMark = IsDlgCheckboxChecked(hw,IDC_3DSETTINGS_EDGEMARK); CommonSettings.GFX3D_EdgeMark = IsDlgCheckboxChecked(hw,IDC_3DSETTINGS_EDGEMARK);
CommonSettings.GFX3D_Fog = IsDlgCheckboxChecked(hw,IDC_3DSETTINGS_FOG); CommonSettings.GFX3D_Fog = IsDlgCheckboxChecked(hw,IDC_3DSETTINGS_FOG);
NDS_3D_ChangeCore(ComboBox_GetCurSel(GetDlgItem(hw, IDC_3DCORE))); Change3DCoreWithFallbackAndSave(ComboBox_GetCurSel(GetDlgItem(hw, IDC_3DCORE)));
WritePrivateProfileInt("3D", "Renderer", cur3DCore, IniName);
WritePrivateProfileInt("3D", "HighResolutionInterpolateColor", CommonSettings.GFX3D_HighResolutionInterpolateColor?1:0, IniName); WritePrivateProfileInt("3D", "HighResolutionInterpolateColor", CommonSettings.GFX3D_HighResolutionInterpolateColor?1:0, IniName);
WritePrivateProfileInt("3D", "EnableEdgeMark", CommonSettings.GFX3D_EdgeMark?1:0, IniName); WritePrivateProfileInt("3D", "EnableEdgeMark", CommonSettings.GFX3D_EdgeMark?1:0, IniName);
WritePrivateProfileInt("3D", "EnableFog", CommonSettings.GFX3D_Fog?1:0, IniName); WritePrivateProfileInt("3D", "EnableFog", CommonSettings.GFX3D_Fog?1:0, IniName);
@ -5037,9 +5051,8 @@ LRESULT CALLBACK GFX3DSettingsDlgProc(HWND hw, UINT msg, WPARAM wp, LPARAM lp)
case IDC_DEFAULT: case IDC_DEFAULT:
{ {
NDS_3D_ChangeCore(GPU3D_OPENGL); Change3DCoreWithFallbackAndSave(GPU3D_DEFAULT);
ComboBox_SetCurSel(GetDlgItem(hw, IDC_3DCORE), GPU3D_OPENGL); ComboBox_SetCurSel(GetDlgItem(hw, IDC_3DCORE), cur3DCore);
WritePrivateProfileInt("3D", "Renderer", GPU3D_OPENGL, IniName);
//CommonSettings.gfx3d_flushMode = 0; //CommonSettings.gfx3d_flushMode = 0;
//WritePrivateProfileInt("3D", "AlternateFlush", CommonSettings.gfx3d_flushMode, IniName); //WritePrivateProfileInt("3D", "AlternateFlush", CommonSettings.gfx3d_flushMode, IniName);
} }

View File

@ -27,6 +27,8 @@ extern bool ShowLagFrameCounter;
#define GPU3D_OPENGL 1 #define GPU3D_OPENGL 1
#define GPU3D_SWRAST 2 #define GPU3D_SWRAST 2
extern void Change3DCoreWithFallbackAndSave(int newCore, int fallbackCore=GPU3D_SWRAST);
extern int backupmemorytype; extern int backupmemorytype;
extern u32 backupmemorysize; extern u32 backupmemorysize;