diff --git a/desmume/src/frontend/windows/main.cpp b/desmume/src/frontend/windows/main.cpp index 7f8f781e0..bac24aa74 100755 --- a/desmume/src/frontend/windows/main.cpp +++ b/desmume/src/frontend/windows/main.cpp @@ -425,7 +425,7 @@ static int sndbuffersize=DESMUME_SAMPLE_RATE*8/60; int sndvolume=100; const int possibleMSAA[] = {0, 2, 4, 8, 16, 32}; -int maxSamples=32; +int maxSamples=0; SoundInterface_struct *SNDCoreList[] = { &SNDDummy, @@ -2630,7 +2630,7 @@ void CheckValidMSAA(int userVal) if(!validMSAA) { - CommonSettings.GFX3D_Renderer_MultisampleSize=0; //Just disable for now until I find a better solution + CommonSettings.GFX3D_Renderer_MultisampleSize=0; //Disable if user entered invalid value WritePrivateProfileInt("3D","MultisampleSize",0,IniName); } } @@ -5682,6 +5682,23 @@ LRESULT CALLBACK GFX3DSettingsDlgProc(HWND hw, UINT msg, WPARAM wp, LPARAM lp) { int i = 0, z = 0; HWND cur; + const char MSAADescriptions[6][9] = {"Disabled", "2x", "4x", "8x", "16x", "32x"}; + + if(cur3DCore != 0 && cur3DCore != 2) //Get max device samples from the current renderer only if it's OpenGL. + maxSamples=CurrentRenderer->GetDeviceInfo().maxSamples; + if (maxSamples == 0) { //If it already has a value it's likely correct so don't create again. + bool isTempContextCreated = windows_opengl_init(); //Create a context just to get max device samples. + if(isTempContextCreated) //Creating it here because it's only needed in this window. + { + GLint maxSamplesOGL=0; +#if defined(GL_MAX_SAMPLES) + glGetIntegerv(GL_MAX_SAMPLES,&maxSamplesOGL); +#elif defined(GL_MAX_SAMPLES_EXT) + glGetIntegerv(GL_MAX_SAMPLES_EXT,&maxSamplesOGL); +#endif + maxSamples=maxSamplesOGL; + } + } CheckDlgButton(hw,IDC_INTERPOLATECOLOR,CommonSettings.GFX3D_HighResolutionInterpolateColor); CheckDlgButton(hw,IDC_3DSETTINGS_EDGEMARK,CommonSettings.GFX3D_EdgeMark); @@ -5704,19 +5721,14 @@ LRESULT CALLBACK GFX3DSettingsDlgProc(HWND hw, UINT msg, WPARAM wp, LPARAM lp) SendDlgItemMessage(hw, IDC_NUD_PRESCALEHD, UDM_SETRANGE, 0, MAKELPARAM(16, 1)); SendDlgItemMessage(hw, IDC_NUD_PRESCALEHD, UDM_SETPOS, 0, video.prescaleHD); - const char MSAADescriptions[6][9] = {"Disabled", "2x", "4x", "8x", "16x", "32x"}; - CheckValidMSAA(CommonSettings.GFX3D_Renderer_MultisampleSize); - if(cur3DCore != 0 && cur3DCore != 2) //Not sure how to get maxSamples when renderer is null or softrast + if (CommonSettings.GFX3D_Renderer_MultisampleSize > maxSamples) { - maxSamples = CurrentRenderer->GetDeviceInfo().maxSamples; - if (CommonSettings.GFX3D_Renderer_MultisampleSize > maxSamples) - { - CommonSettings.GFX3D_Renderer_MultisampleSize = maxSamples; - WritePrivateProfileInt("3D", "MultisampleSize", maxSamples, IniName); - } + CommonSettings.GFX3D_Renderer_MultisampleSize = maxSamples; + WritePrivateProfileInt("3D", "MultisampleSize", maxSamples, IniName); } - while (z <= maxSamples && i < 6) //There's a better way of handling this, I just can't think of it atm. + + while (z <= maxSamples && i < 6) { ComboBox_AddString(GetDlgItem(hw,IDC_MULTISAMPLE_SIZE),MSAADescriptions[i]); if (z == CommonSettings.GFX3D_Renderer_MultisampleSize) diff --git a/desmume/src/frontend/windows/resources.rc b/desmume/src/frontend/windows/resources.rc index a09e697c4..fb409fc70 100644 --- a/desmume/src/frontend/windows/resources.rc +++ b/desmume/src/frontend/windows/resources.rc @@ -130,7 +130,7 @@ BEGIN LTEXT "Multisample Antialiasing:",ID_LABEL_MSAA_SAMPLES,13,145,78,8 COMBOBOX IDC_MULTISAMPLE_SIZE,95,144,84,138,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP CONTROL "Smooth Textures",IDC_TEX_SMOOTH,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,13,160,75,10 - GROUPBOX "General Options",IDC_STATIC,194,7,109,146 + GROUPBOX "General Options",IDC_STATIC,194,7,109,147 LTEXT "GPU Scaling Factor",IDC_STATIC,200,20,64,8 EDITTEXT IDC_TEXT_PRESCALEHD,267,17,20,14,ES_AUTOHSCROLL CONTROL "",IDC_NUD_PRESCALEHD,"msctls_updown32",UDS_SETBUDDYINT | UDS_AUTOBUDDY | UDS_ARROWKEYS,286,17,11,14 @@ -143,7 +143,7 @@ BEGIN CONTROL "Texture Scaling 4x",IDC_TEXSCALE_4,"Button",BS_AUTORADIOBUTTON,200,102,72,10 CONTROL "Enable Edge Marking",IDC_3DSETTINGS_EDGEMARK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,200,119,84,10 CONTROL "Enable Fog",IDC_3DSETTINGS_FOG,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,200,129,52,10 - CONTROL "Enable Textures",IDC_3DSETTINGS_TEXTURE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,200,138,67,10 + CONTROL "Enable Textures",IDC_3DSETTINGS_TEXTURE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,200,139,67,10 DEFPUSHBUTTON "OK",IDOK,194,159,50,15 PUSHBUTTON "Cancel",IDCANCEL,254,159,50,15 END