diff --git a/Source/Plugins/Plugin_VideoOGL/Src/GLInit.cpp b/Source/Plugins/Plugin_VideoOGL/Src/GLInit.cpp index f7686a90bb..d8b216cb84 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/GLInit.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/GLInit.cpp @@ -16,6 +16,7 @@ // http://code.google.com/p/dolphin-emu/ #include "Globals.h" +#include "IniFile.h" #ifdef _WIN32 #include "svnrev.h" #include "OS\Win32.h" @@ -93,14 +94,40 @@ void UpdateFPSDisplay(const char *text) } -bool OpenGL_Create(SVideoInitialize &_VideoInitialize, int _width, int _height) +bool OpenGL_Create(SVideoInitialize &_VideoInitialize, int _iwidth, int _iheight) { + int _twidth, _theight; + if(g_Config.bFullscreen) + { + if(strlen(g_Config.iFSResolution) > 1) + { + sscanf(g_Config.iFSResolution, "%dx%d", &_twidth, &_theight); + } + else // No full screen reso set, fall back to default reso + { + _twidth = _iwidth; + _theight = _iheight; + } + + } + else // Going Windowed + { + if(strlen(g_Config.iWindowedRes) > 1) + { + sscanf(g_Config.iWindowedRes, "%dx%d", &_twidth, &_theight); + } + else // No Window reso set, fall back to default + { + _twidth = _iwidth; + _theight = _iheight; + } + } #ifdef _WIN32 - EmuWindow::SetSize(_width, _height); + EmuWindow::SetSize(_twidth, _theight); #endif - nBackbufferWidth = _width; - nBackbufferHeight = _height; + nBackbufferWidth = _twidth; + nBackbufferHeight = _theight; // change later s_nTargetWidth = 640<hdisplay == _width) && (modes[i]->vdisplay == _height)) { + if ((modes[i]->hdisplay == _twidth) && (modes[i]->vdisplay == _theight)) { bestMode = i; } } @@ -337,7 +364,7 @@ bool OpenGL_Create(SVideoInitialize &_VideoInitialize, int _width, int _height) GLWin.attr.event_mask = ExposureMask | KeyPressMask | ButtonPressMask | StructureNotifyMask; GLWin.win = XCreateWindow(GLWin.dpy, RootWindow(GLWin.dpy, vi->screen), - 0, 0, _width, _height, 0, vi->depth, InputOutput, vi->visual, + 0, 0, _twidth, _theight, 0, vi->depth, InputOutput, vi->visual, CWBorderPixel | CWColormap | CWEventMask, &GLWin.attr); // only set window title and handle wm_delete_events if in windowed mode wmDelete = XInternAtom(GLWin.dpy, "WM_DELETE_WINDOW", True); diff --git a/Source/Plugins/Plugin_VideoOGL/Src/GUI/ConfigDlg.cpp b/Source/Plugins/Plugin_VideoOGL/Src/GUI/ConfigDlg.cpp index 8ba760ce3e..ed9b28afb7 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/GUI/ConfigDlg.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/GUI/ConfigDlg.cpp @@ -68,12 +68,12 @@ void ConfigDialog::CreateGUIControls() // all other options doesnt to anything so lets disable them wxArrayString arrayStringFor_FullscreenCB; - m_FullscreenCB = new wxComboBox(m_PageVideo, ID_FULLSCREENCB, wxT("FullscreenCB"), wxPoint(132,72), wxSize(121,21), arrayStringFor_FullscreenCB, 0, wxDefaultValidator, wxT("FullscreenCB")); - m_FullscreenCB->Enable(false); + m_FullscreenCB = new wxComboBox(m_PageVideo, ID_FULLSCREENCB, wxT(""), wxPoint(132,72), wxSize(121,21), arrayStringFor_FullscreenCB, 0, wxDefaultValidator, wxT("FullscreenCB")); + m_FullscreenCB->Enable(true); wxArrayString arrayStringFor_WindowResolutionCB; - m_WindowResolutionCB = new wxComboBox(m_PageVideo, ID_WINDOWRESOLUTIONCB, wxT("WxComboBox1"), wxPoint(132,104), wxSize(121,21), arrayStringFor_WindowResolutionCB, 0, wxDefaultValidator, wxT("WindowResolutionCB")); - m_WindowResolutionCB->Enable(false); + m_WindowResolutionCB = new wxComboBox(m_PageVideo, ID_WINDOWRESOLUTIONCB, wxT(""), wxPoint(132,104), wxSize(121,21), arrayStringFor_WindowResolutionCB, 0, wxDefaultValidator, wxT("WindowResolutionCB")); + m_WindowResolutionCB->Enable(true); wxStaticText *WxStaticText1 = new wxStaticText(m_PageVideo, ID_WXSTATICTEXT1, wxT("Windowed Resolution:"), wxPoint(12,104), wxDefaultSize, 0, wxT("WxStaticText1")); wxStaticText *WxStaticText2 = new wxStaticText(m_PageVideo, ID_WXSTATICTEXT2, wxT("Fullscreen Video Mode:"), wxPoint(12,72), wxDefaultSize, 0, wxT("WxStaticText2")); @@ -97,7 +97,8 @@ void ConfigDialog::CreateGUIControls() m_DumpTextures->Enable(false); m_Statistics = new wxCheckBox(m_PageAdvanced, ID_STATISTICS, wxT("Overlay some statistics"), wxPoint(12,40), wxSize(233,25), 0, wxDefaultValidator, wxT("Statistics")); - m_Statistics->Enable(false); + m_Statistics->SetValue(g_Config.bOverlayStats); + m_Statistics->Enable(true); m_ShaderErrors = new wxCheckBox(m_PageAdvanced, ID_SHADERERRORS, wxT("Show shader compilation issues"), wxPoint(12,64), wxSize(233,25), 0, wxDefaultValidator, wxT("ShaderErrors")); m_ShaderErrors->Enable(false); @@ -112,10 +113,16 @@ void ConfigDialog::CreateGUIControls() SetIcon(wxNullIcon); SetSize(8,8,492,273); Center(); + m_Fullscreen->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( ConfigDialog::FullScreenCheck ), NULL, this ); + m_RenderToMainWindow->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( ConfigDialog::RenderMainCheck ), NULL, this ); + m_Statistics->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( ConfigDialog::OverlayCheck ), NULL, this ); + m_FullscreenCB->Connect( wxEVT_COMMAND_COMBOBOX_SELECTED, wxCommandEventHandler( ConfigDialog::FSCB ), NULL, this ); + m_WindowResolutionCB->Connect( wxEVT_COMMAND_COMBOBOX_SELECTED, wxCommandEventHandler( ConfigDialog::WMCB ), NULL, this ); } void ConfigDialog::OnClose(wxCloseEvent& /*event*/) { + g_Config.Save(); EndModal(0); } @@ -145,3 +152,31 @@ void ConfigDialog::OKClick(wxCommandEvent& event) Close(); } } +void ConfigDialog::AddFSReso(char *reso) +{ + m_FullscreenCB->Append(wxString::FromAscii(reso)); +} +void ConfigDialog::AddWindowReso(char *reso) +{ + m_WindowResolutionCB->Append(wxString::FromAscii(reso)); +} +void ConfigDialog::FullScreenCheck(wxCommandEvent& event) +{ + g_Config.bFullscreen = m_Fullscreen->IsChecked(); +} +void ConfigDialog::FSCB(wxCommandEvent& event) +{ + strcpy(g_Config.iFSResolution, m_FullscreenCB->GetValue().mb_str() ); +} +void ConfigDialog::WMCB(wxCommandEvent& event) +{ + strcpy(g_Config.iWindowedRes, m_WindowResolutionCB->GetValue().mb_str() ); +} +void ConfigDialog::RenderMainCheck(wxCommandEvent& event) +{ + g_Config.renderToMainframe = m_RenderToMainWindow->IsChecked(); +} +void ConfigDialog::OverlayCheck(wxCommandEvent& event) +{ + g_Config.bOverlayStats = m_Statistics->IsChecked(); +} diff --git a/Source/Plugins/Plugin_VideoOGL/Src/GUI/ConfigDlg.h b/Source/Plugins/Plugin_VideoOGL/Src/GUI/ConfigDlg.h index 1456b4e79e..bdb85968c0 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/GUI/ConfigDlg.h +++ b/Source/Plugins/Plugin_VideoOGL/Src/GUI/ConfigDlg.h @@ -44,6 +44,13 @@ class ConfigDialog : public wxDialog void ConfigDialogActivate(wxActivateEvent& event); void BrowseClick(wxCommandEvent& event); void OKClick(wxCommandEvent& event); + void AddFSReso(char *reso); + void AddWindowReso(char *reso); + void FullScreenCheck(wxCommandEvent& event); + void FSCB(wxCommandEvent& event); + void WMCB(wxCommandEvent& event); + void RenderMainCheck(wxCommandEvent& event); + void OverlayCheck(wxCommandEvent& event); private: diff --git a/Source/Plugins/Plugin_VideoOGL/Src/Globals.cpp b/Source/Plugins/Plugin_VideoOGL/Src/Globals.cpp index bf0092f3f5..35b10de80f 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/Globals.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/Globals.cpp @@ -25,16 +25,6 @@ int frameCount; -int g_Res[NUMWNDRES][2] = -{ - {640,480}, - {800,600}, - {1024,768}, - {1280,960}, - {1280,1024}, - {1600,1200}, -}; - Config g_Config; Statistics stats; @@ -50,11 +40,14 @@ Config::Config() void Config::Load() { + std::string temp; IniFile iniFile; iniFile.Load("gfx_opengl.ini"); iniFile.Get("Hardware", "Adapter", &iAdapter, 0); - iniFile.Get("Hardware", "WindowedRes", &iWindowedRes, 0); - iniFile.Get("Hardware", "FullscreenRes", &iFSResolution, 0); + iniFile.Get("Hardware", "WindowedRes", &temp, 0); + strcpy(iWindowedRes, temp.c_str()); + iniFile.Get("Hardware", "FullscreenRes", &temp, 0); + strcpy(iFSResolution, temp.c_str()); iniFile.Get("Hardware", "Fullscreen", &bFullscreen, 0); iniFile.Get("Hardware", "RenderToMainframe", &renderToMainframe, 0); if (iAdapter == -1) diff --git a/Source/Plugins/Plugin_VideoOGL/Src/Globals.h b/Source/Plugins/Plugin_VideoOGL/Src/Globals.h index 9740490e43..33114a4921 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/Globals.h +++ b/Source/Plugins/Plugin_VideoOGL/Src/Globals.h @@ -134,9 +134,6 @@ struct RECT extern int frameCount; -#define NUMWNDRES 6 -extern int g_Res[NUMWNDRES][2]; - #define CONF_LOG 1 #define CONF_PRIMLOG 2 #define CONF_SAVETEXTURES 4 @@ -149,7 +146,7 @@ struct Config void Save(); int iAdapter; - int iFSResolution; + char iFSResolution[16]; int iMultisampleMode; int iPostprocessEffect; @@ -173,7 +170,7 @@ struct Config bool bTruform; int iTruformLevel; - int iWindowedRes; + char iWindowedRes[16]; int aa; // anti-aliasing level char psProfile[16]; diff --git a/Source/Plugins/Plugin_VideoOGL/Src/main.cpp b/Source/Plugins/Plugin_VideoOGL/Src/main.cpp index 4b1c66c58b..614e50cc23 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/main.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/main.cpp @@ -61,7 +61,6 @@ void DllAbout(HWND _hParent) wxAboutBox(info); } - void DllConfig(HWND _hParent) { #ifdef _WIN32 @@ -77,6 +76,40 @@ void DllConfig(HWND _hParent) #else ConfigDialog frame(NULL); + g_Config.Load(); + printf("Window res: %s, size of: %d strlen %d\n", g_Config.iWindowedRes, sizeof(g_Config.iWindowedRes), strlen(g_Config.iWindowedRes)); + XVisualInfo *vi; + Colormap cmap; + int dpyWidth, dpyHeight; + int glxMajorVersion, glxMinorVersion; + int vidModeMajorVersion, vidModeMinorVersion; + GLWin.dpy = XOpenDisplay(0); + glXQueryVersion(GLWin.dpy, &glxMajorVersion, &glxMinorVersion); + XF86VidModeQueryVersion(GLWin.dpy, &vidModeMajorVersion, &vidModeMinorVersion); + //Get all full screen resos for the config dialog + XF86VidModeModeInfo **modes = NULL; + int modeNum = 0; + int bestMode = 0; + + // set best mode to current + bestMode = 0; + XF86VidModeGetAllModeLines(GLWin.dpy, GLWin.screen, &modeNum, &modes); + int px = 0, py = 0; + if (modeNum > 0 && modes != NULL) + { + for (int i = 0; i < modeNum; i++) + { + if(px != modes[i]->hdisplay && py != modes[i]->vdisplay) + { + char temp[32]; + sprintf(temp,"%dx%d", modes[i]->hdisplay, modes[i]->vdisplay); + frame.AddFSReso(temp); + frame.AddWindowReso(temp); //Add same to Window ones, since they should be nearly all that's needed + px = modes[i]->hdisplay;//Used to remove repeating from different screen depths + py = modes[i]->vdisplay; + } + } + } frame.ShowModal(); #endif } @@ -95,8 +128,8 @@ void Video_Initialize(SVideoInitialize* _pVideoInitialize) g_VideoInitialize = *_pVideoInitialize; InitLUTs(); g_Config.Load(); - - if (!OpenGL_Create(g_VideoInitialize, g_Res[g_Config.iWindowedRes][0], g_Res[g_Config.iWindowedRes][1])) { + + if (!OpenGL_Create(g_VideoInitialize, 640, 480)) { //640x480 will be the default if all else fails// g_VideoInitialize.pLog("Renderer::Create failed\n", TRUE); return; }