more code clean up

gltest compiles on linux, not working yet


git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@1615 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
nakeee 2008-12-20 22:18:52 +00:00
parent a85ea787c8
commit d640dec401
14 changed files with 88 additions and 117 deletions

View File

@ -34,31 +34,32 @@ void Config::Load()
iniFile.Load(FULL_CONFIG_DIR "gfx_opengl.ini");
// get resolution
iniFile.Get("Hardware", "WindowedRes", &temp, 0);
if(temp.empty())
temp = "640x480";
strcpy(iWindowedRes, temp.c_str());
iniFile.Get("Hardware", "FullscreenRes", &temp, 0);
if(temp.empty())
temp = "640x480";
strcpy(iFSResolution, temp.c_str());
iniFile.Get("Hardware", "WindowedRes", &temp, "640x480");
strncpy(iWindowedRes, temp.c_str(), 16);
iniFile.Get("Hardware", "FullscreenRes", &temp, "640x480");
strncpy(iFSResolution, temp.c_str(), 16);
iniFile.Get("Settings", "Backend", &temp, "");
strncpy(iBackend, temp.c_str(), 16);
iniFile.Get("Hardware", "Fullscreen", &bFullscreen, 0); // Hardware
iniFile.Get("Hardware", "RenderToMainframe", &renderToMainframe, 0);
iniFile.Get("Settings", "StretchToFit", &bStretchToFit, false);
iniFile.Get("Settings", "KeepAR", &bKeepAR, false);
iniFile.Get("Settings", "HideCursor", &bHideCursor, false);
iniFile.Get("Hardware", "RenderToMainframe", &renderToMainframe, 0);
iniFile.Get("Settings", "StretchToFit", &bStretchToFit, false);
iniFile.Get("Settings", "KeepAR", &bKeepAR, false);
iniFile.Get("Settings", "HideCursor", &bHideCursor, false);
iniFile.Get("Settings", "SafeTextureCache", &bSafeTextureCache, false); // Settings
iniFile.Get("Settings", "ShowFPS", &bShowFPS, false); // Settings
iniFile.Get("Settings", "OverlayStats", &bOverlayStats, false);
iniFile.Get("Settings", "OverlayStats", &bOverlayStats, false);
iniFile.Get("Settings", "DLOptimize", &iCompileDLsLevel, 0);
iniFile.Get("Settings", "DumpTextures", &bDumpTextures, 0);
iniFile.Get("Settings", "ShowShaderErrors", &bShowShaderErrors, 0);
iniFile.Get("Settings", "Multisample", &iMultisampleMode, 0);
if (iMultisampleMode == 0)
iMultisampleMode = 1;
std::string s;
std::string s;
iniFile.Get("Settings", "TexDumpPath", &s, 0);
if (s.size() < sizeof(texDumpPath) )
strcpy(texDumpPath, s.c_str());
@ -66,21 +67,21 @@ void Config::Load()
strncpy(texDumpPath, s.c_str(), sizeof(texDumpPath)-1);
texDumpPath[sizeof(texDumpPath)-1] = 0;
}
iniFile.Get("Settings", "TexFmtOverlayEnable", &bTexFmtOverlayEnable, 0);
iniFile.Get("Settings", "TexFmtOverlayCenter", &bTexFmtOverlayCenter, 0);
iniFile.Get("Settings", "UseXFB", &bUseXFB, 0);
iniFile.Get("Settings", "WireFrame", &bWireFrame, 0);
iniFile.Get("Settings", "DisableLighting", &bDisableLighting, 0);
iniFile.Get("Settings", "DisableTexturing", &bDisableTexturing, 0);
iniFile.Get("Settings", "TexFmtOverlayEnable", &bTexFmtOverlayEnable, 0);
iniFile.Get("Settings", "TexFmtOverlayCenter", &bTexFmtOverlayCenter, 0);
iniFile.Get("Settings", "UseXFB", &bUseXFB, 0);
iniFile.Get("Settings", "WireFrame", &bWireFrame, 0);
iniFile.Get("Settings", "DisableLighting", &bDisableLighting, 0);
iniFile.Get("Settings", "DisableTexturing", &bDisableTexturing, 0);
iniFile.Get("Enhancements", "ForceFiltering", &bForceFiltering, 0);
iniFile.Get("Enhancements", "MaxAnisotropy", &iMaxAnisotropy, 3); // NOTE - this is x in (1 << x)
iniFile.Get("Hacks", "EFBToTextureDisable", &bEFBToTextureDisable, 0);
iniFile.Get("Hacks", "EFBToTextureDisableHotKey", &bEFBToTextureDisableHotKey, 0);
iniFile.Get("Hacks", "ProjectionHax1", &bProjectionHax1, 0);
iniFile.Get("Hacks", "ProjectionHax2", &bProjectionHax2, 0);
iniFile.Get("Hacks", "EFBToTextureDisable", &bEFBToTextureDisable, 0);
iniFile.Get("Hacks", "EFBToTextureDisableHotKey", &bEFBToTextureDisableHotKey, 0);
iniFile.Get("Hacks", "ProjectionHax1", &bProjectionHax1, 0);
iniFile.Get("Hacks", "ProjectionHax2", &bProjectionHax2, 0);
}
void Config::Save()
@ -90,33 +91,35 @@ void Config::Save()
iniFile.Set("Hardware", "WindowedRes", iWindowedRes);
iniFile.Set("Hardware", "FullscreenRes", iFSResolution);
iniFile.Set("Hardware", "Fullscreen", bFullscreen);
iniFile.Set("Hardware", "RenderToMainframe", renderToMainframe);
iniFile.Set("Settings", "StretchToFit", bStretchToFit);
iniFile.Set("Settings", "KeepAR", bKeepAR);
iniFile.Set("Settings", "HideCursor", bHideCursor);
iniFile.Set("Hardware", "RenderToMainframe", renderToMainframe);
iniFile.Set("Settings", "StretchToFit", bStretchToFit);
iniFile.Set("Settings", "KeepAR", bKeepAR);
iniFile.Set("Settings", "HideCursor", bHideCursor);
iniFile.Set("Settings", "Backend", iBackend);
iniFile.Set("Settings", "SafeTextureCache", bSafeTextureCache);
iniFile.Set("Settings", "ShowFPS", bShowFPS);
iniFile.Set("Settings", "OverlayStats", bOverlayStats);
iniFile.Set("Settings", "OverlayStats", bOverlayStats);
iniFile.Set("Settings", "DLOptimize", iCompileDLsLevel);
iniFile.Set("Settings", "DumpTextures", bDumpTextures);
iniFile.Set("Settings", "ShowShaderErrors", bShowShaderErrors);
iniFile.Set("Settings", "Multisample", iMultisampleMode);
iniFile.Set("Settings", "TexDumpPath", texDumpPath);
iniFile.Set("Settings", "TexFmtOverlayEnable", bTexFmtOverlayEnable);
iniFile.Set("Settings", "TexFmtOverlayCenter", bTexFmtOverlayCenter);
iniFile.Set("Settings", "UseXFB", bUseXFB);
iniFile.Set("Settings", "Wireframe", bWireFrame);
iniFile.Set("Settings", "DisableLighting", bDisableLighting);
iniFile.Set("Settings", "DisableTexturing", bDisableTexturing);
iniFile.Set("Settings", "TexFmtOverlayEnable", bTexFmtOverlayEnable);
iniFile.Set("Settings", "TexFmtOverlayCenter", bTexFmtOverlayCenter);
iniFile.Set("Settings", "UseXFB", bUseXFB);
iniFile.Set("Settings", "Wireframe", bWireFrame);
iniFile.Set("Settings", "DisableLighting", bDisableLighting);
iniFile.Set("Settings", "DisableTexturing", bDisableTexturing);
iniFile.Set("Enhancements", "ForceFiltering", bForceFiltering);
iniFile.Set("Enhancements", "MaxAnisotropy", iMaxAnisotropy);
iniFile.Set("Hacks", "EFBToTextureDisable", bEFBToTextureDisable);
iniFile.Set("Hacks", "EFBToTextureDisableHotKey", bEFBToTextureDisableHotKey);
iniFile.Set("Hacks", "ProjectionHax1", bProjectionHax1);
iniFile.Set("Hacks", "ProjectionHax2", bProjectionHax2);
iniFile.Set("Hacks", "EFBToTextureDisable", bEFBToTextureDisable);
iniFile.Set("Hacks", "EFBToTextureDisableHotKey", bEFBToTextureDisableHotKey);
iniFile.Set("Hacks", "ProjectionHax1", bProjectionHax1);
iniFile.Set("Hacks", "ProjectionHax2", bProjectionHax2);
iniFile.Save(FULL_CONFIG_DIR "gfx_opengl.ini");
}

View File

@ -36,7 +36,7 @@ struct Config
bool renderToMainframe;
char iFSResolution[16];
char iWindowedRes[16];
char iBackend[10];
char iBackend[16];
bool bStretchToFit;
bool bKeepAR;
bool bHideCursor;

View File

@ -689,7 +689,7 @@ void OpenGL_Update()
float FactorW = 640.0f / (float)nBackbufferWidth;
float FactorH = 480.0f / (float)nBackbufferHeight;
float Max = (FactorW < FactorH) ? FactorH : FactorW;
AR = (float)nBackbufferWidth / (float)nBackbufferHeight;
AR = (float)nBackbufferWidth / (float)nBackbufferHeight;
if (g_Config.bStretchToFit)
{

View File

@ -303,7 +303,7 @@ void ConfigDialog::AddWindowReso(char *reso)
m_WindowResolutionCB->Append(wxString::FromAscii(reso));
}
void ConfigDialog::AddRenderBackend(char *backend)
void ConfigDialog::AddRenderBackend(const char *backend)
{
m_RenderBackend->Append(wxString::FromAscii(backend));
}

View File

@ -42,7 +42,7 @@ class ConfigDialog : public wxDialog
void AddFSReso(char *reso);
void AddWindowReso(char *reso);
void AddRenderBackend(char *backend);
void AddRenderBackend(const char *backend);
void AddAAMode(int mode);
private:

View File

@ -32,7 +32,7 @@
#include <windows.h>
#endif
#include "../GLUtil.h"
#if defined(HAVE_WX) && HAVE_WX
#include "../Debugger/Debugger.h" // for the CDebugger class
#include "../Debugger/PBView.h"
@ -57,7 +57,7 @@ extern bool gReset;
bool gOnlyLooping = false;
extern int gSaveFile;
extern int gleft, gright, gtop, gbottom; // from BPStructs.cpp
//extern int gleft, gright, gtop, gbottom; // from BPStructs.cpp
// ---------------------------------------------------------------------------------------
@ -106,13 +106,13 @@ std::string writeMessage(int a, int i)
/*
PRESET 0
"lef rig top bot | xof yof\n";
"000 000 000 000 | 000 000
"000 000 000 000 | 000 00
*/
if(a == 0)
{
sprintf(buf,"%03i %03i %03i %03i | %03i %03i",
gleft, gright, gtop, gbottom, gright-gleft, gbottom-gtop
);
0, OpenGL_GetWidth(), OpenGL_GetHeight(), 0,
OpenGL_GetXoff(), OpenGL_GetYoff());
}
sbuf = buf;

View File

@ -16,13 +16,7 @@ bool SDLWindow::PeekMessages() {
void SDLWindow::Update() {
SDL_Surface *surface = SDL_GetVideoSurface();
// RECT rcWindow;
if (!surface) return;
//nBackbufferWidth = surface->w;
//nBackbufferHeight = surface->h;
// rcWindow.right = surface->w;
// rcWindow.bottom = surface->h;
float FactorW = 640.0f / (float)surface->w;
float FactorH = 480.0f / (float)surface->h;
@ -32,18 +26,15 @@ void SDLWindow::Update() {
if (g_Config.bStretchToFit) {
MValueX = 1;
MValueY = 1;
nXoff = 0;
nYoff = 0;
SetOffset(0,0);
} else {
MValueX = 1.0f / Max;
MValueY = 1.0f / Max;
nXoff = (int)((surface->w - (640 * MValueX)) / 2);
nYoff = (int)((surface->h - (480 * MValueY)) / 2);
SetOffset((int)((surface->w - (640 * MValueX)) / 2),
(int)((surface->h - (480 * MValueY)) / 2));
}
SetSize(surface->w, surface->h);
// tell the debugger
// gleft = rcWindow.left; gright = rcWindow.right;
// gtop = rcWindow.top; gbottom = rcWindow.bottom;
}
bool SDLWindow::MakeCurrent() {
@ -110,13 +101,12 @@ SDLWindow::SDLWindow(int _iwidth, int _iheight) {
if(g_Config.bStretchToFit) {
MValueX = 1.0f / FactorW;
MValueY = 1.0f / FactorH;
nXoff = 0;
nYoff = 0;
SetOffset(0,0);
} else {
MValueX = 1.0f / Max;
MValueY = 1.0f / Max;
nXoff = (int)((_twidth - (640 * MValueX)) / 2);
nYoff = (int)((_theight - (480 * MValueY)) / 2);
SetOffset((int)((_twidth - (640 * MValueX)) / 2),
(int)((_theight - (480 * MValueY)) / 2));
}
//init sdl video

View File

@ -8,8 +8,6 @@
class SDLWindow : public GLWindow
{
public:
int nXoff, nYoff; // screen offset
// Since it can Stretch to fit Window, we need two different multiplication values
float MValueX, MValueY;
virtual void SwapBuffers();

View File

@ -42,8 +42,6 @@ VERTEXSHADER* VertexShaderMngr::pShaderLast = NULL;
float GC_ALIGNED16(g_fProjectionMatrix[16]);
extern int A, B;
extern float AR;
extern int nBackbufferWidth, nBackbufferHeight;
// Internal Variables
static int s_nMaxVertexInstructions;
@ -360,14 +358,14 @@ void VertexShaderMngr::SetConstants()
int scissorXOff = bpmem.scissorOffset.x * 2 - 342;
int scissorYOff = bpmem.scissorOffset.y * 2 - 342;
float fourThree = 4.0f / 3.0f;
float ratio = AR / fourThree;
float wAdj, hAdj;
float actualRatiow, actualRatioh;
int overfl;
int xoffs = 0, yoffs = 0;
int wid, hei, actualWid, actualHei;
int winw = nBackbufferWidth;
int winh = nBackbufferHeight;
int winw = OpenGL_GetWidth();
int winh = OpenGL_GetHeight();
float ratio = (float)winw / (float)winh / fourThree;
if (g_Config.bKeepAR)
{
// Check if height or width is the limiting factor

View File

@ -19,16 +19,15 @@ void WXGLWindow::Update() {
float Max = (FactorW < FactorH) ? FactorH : FactorW;
//AR = (float)nBackbufferWidth / (float)nBackbufferHeight;
if (g_Config.bStretchToFit) {
if (g_Config.bStretchToFit) {
MValueX = 1;
MValueY = 1;
nXoff = 0;
nYoff = 0;
SetOffset(0,0);
} else {
MValueX = 1.0f / Max;
MValueY = 1.0f / Max;
nXoff = (int)((GetWidth() - (640 * MValueX)) / 2);
nYoff = (int)((GetHeight() - (480 * MValueY)) / 2);
SetOffset((int)((surface->w - (640 * MValueX)) / 2),
(int)((surface->h - (480 * MValueY)) / 2));
}
}
@ -66,16 +65,15 @@ WXGLWindow::WXGLWindow(int _iwidth, int _iheight) {
float FactorH = 480.0f / (float)_theight;
float Max = (FactorW < FactorH) ? FactorH : FactorW;
if(g_Config.bStretchToFit) {
if(g_Config.bStretchToFit) {
MValueX = 1.0f / FactorW;
MValueY = 1.0f / FactorH;
nXoff = 0;
nYoff = 0;
SetOffset(0,0);
} else {
MValueX = 1.0f / Max;
MValueY = 1.0f / Max;
nXoff = (int)((_twidth - (640 * MValueX)) / 2);
nYoff = (int)((_theight - (480 * MValueY)) / 2);
SetOffset((int)((_twidth - (640 * MValueX)) / 2),
(int)((_theight - (480 * MValueY)) / 2));
}
int args[] = {WX_GL_RGBA, WX_GL_DOUBLEBUFFER, WX_GL_DEPTH_SIZE, 16, 0};

View File

@ -15,8 +15,6 @@ private:
public:
int nXoff, nYoff; // screen offset
// Since it can Stretch to fit Window, we need two different multiplication values
float MValueX, MValueY;
virtual void SwapBuffers();

View File

@ -22,32 +22,21 @@ X11Window::X11Window(int _iwidth, int _iheight) {
SetSize(_twidth, _theight);
// ---------------------------------------------------------------------------------------
// Control window size and picture scaling
// ------------------
// nBackbufferWidth and nBackbufferHeight = Screen resolution from ini, or 640x480
// See OpenGL_Update() for documentation of the other variables
// ------------------
nBackbufferWidth = _twidth;
nBackbufferHeight = _theight;
float FactorW = 640.0f / (float)nBackbufferWidth;
float FactorH = 480.0f / (float)nBackbufferHeight;
float FactorW = 640.0f / (float)_twidth;
float FactorH = 480.0f / (float)_theight;
float Max = (FactorW < FactorH) ? FactorH : FactorW;
if(g_Config.bStretchToFit) {
MValueX = 1.0f / FactorW;
MValueY = 1.0f / FactorH;
nXoff = 0;
nYoff = 0;
SetOffset(0,0);
} else {
MValueX = 1.0f / Max;
MValueY = 1.0f / Max;
nXoff = (int)((nBackbufferWidth - (640 * MValueX)) / 2);
nYoff = (int)((nBackbufferHeight - (480 * MValueY)) / 2);
SetOffset((int)((_twidth - (640 * MValueX)) / 2),
(int)((_theight - (480 * MValueY)) / 2));
}
XVisualInfo *vi;
Colormap cmap;
int dpyWidth, dpyHeight;
@ -263,8 +252,6 @@ void X11Window::Update() {
XGetGeometry(dpy, win, &winDummy, &x, &y,
&w, &h, &borderDummy, &depth);
SetSize(w, h);
nBackbufferWidth = w;
nBackbufferHeight = h;
break;
case ClientMessage: //TODO: We aren't reading this correctly, It could be anything, highest chance is that it's a close event though
Video_Shutdown(); // Calling from here since returning false does nothing

View File

@ -23,9 +23,6 @@ public:
Bool fs;
Bool doubleBuffered;
XF86VidModeModeInfo deskMode;
int nBackbufferWidth, nBackbufferHeight;
int nXoff, nYoff; // screen offset
// Since it can Stretch to fit Window, we need two different multiplication values
float MValueX, MValueY;
virtual void SwapBuffers();

View File

@ -55,13 +55,15 @@ bool OpenGL_Create(SVideoInitialize &_VideoInitialize,
g_VideoInitialize.pPeekMessages = &Callback_PeekMessages;
g_VideoInitialize.pUpdateFPSDisplay = &UpdateFPSDisplay;
if (strncmp(g_Config.iBackend, "sdl") == 0)
if (strncasecmp(g_Config.iBackend, "sdl", 10) == 0)
glWin = new SDLWindow(width, height);
else if (strncmp(g_Config.iBackend, "x11") == 0)
else if (strncasecmp(g_Config.iBackend, "x11", 10) == 0)
glWin = new X11Window(width, height);
else if (strncmp(g_Config.iBackend, "wxgl") == 0)
else if (strncasecmp(g_Config.iBackend, "wxgl", 10) == 0)
glWin = new WXGLWindow(width, height);
else
PanicAlert("Invalid backend %s", g_Config.iBackend);
return (glWin?true:false);
}