summaryrefslogtreecommitdiff
path: root/Source
diff options
context:
space:
mode:
authornakeee <nakeee@gmail.com>2008-12-21 21:02:43 +0000
committernakeee <nakeee@gmail.com>2008-12-21 21:02:43 +0000
commita7c4697d223106d5b5994171ffd2e804c60f96e8 (patch)
tree9e166549c3b79cb1dca2f4d1c884c05cacb6c9fb /Source
parent1b0cb56d2b1265f6c6a3ef9e9c27f71dd2d1ced3 (diff)
more code cleanup
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@1622 8ced0084-cf51-0410-be5f-012b33b47a6e
Diffstat (limited to 'Source')
-rw-r--r--Source/Plugins/Plugin_VideoOGL/Src/BPStructs.cpp4
-rw-r--r--Source/Plugins/Plugin_VideoOGL/Src/GLUtil.cpp9
-rw-r--r--Source/Plugins/Plugin_VideoOGL/Src/GLUtil.h2
-rw-r--r--Source/Plugins/Plugin_VideoOGL/Src/GLWindow.h26
-rw-r--r--Source/Plugins/Plugin_VideoOGL/Src/Render.cpp4
-rw-r--r--Source/Plugins/Plugin_VideoOGL/Src/Render.h1
-rw-r--r--Source/Plugins/Plugin_VideoOGL/Src/SDLWindow.cpp25
-rw-r--r--Source/Plugins/Plugin_VideoOGL/Src/SDLWindow.h2
-rw-r--r--Source/Plugins/Plugin_VideoOGL/Src/TextureMngr.cpp2
-rw-r--r--Source/Plugins/Plugin_VideoOGL/Src/VertexShaderManager.cpp6
-rw-r--r--Source/Plugins/Plugin_VideoOGL/Src/WXGLWindow.cpp24
-rw-r--r--Source/Plugins/Plugin_VideoOGL/Src/WXGLWindow.h2
-rw-r--r--Source/Plugins/Plugin_VideoOGL/Src/X11Window.cpp10
-rw-r--r--Source/Plugins/Plugin_VideoOGL/Src/X11Window.h1
-rw-r--r--Source/Plugins/Plugin_VideoOGL/Src/nGLUtil.cpp8
-rw-r--r--Source/Plugins/Plugin_VideoOGL/Src/nGLUtil.h2
16 files changed, 73 insertions, 55 deletions
diff --git a/Source/Plugins/Plugin_VideoOGL/Src/BPStructs.cpp b/Source/Plugins/Plugin_VideoOGL/Src/BPStructs.cpp
index 022d770cae..113b62a99e 100644
--- a/Source/Plugins/Plugin_VideoOGL/Src/BPStructs.cpp
+++ b/Source/Plugins/Plugin_VideoOGL/Src/BPStructs.cpp
@@ -434,7 +434,9 @@ void BPWritten(int addr, int changes, int newval)
(int)((bpmem.copyTexSrcXY.x + bpmem.copyTexSrcWH.x)),
(int)((bpmem.copyTexSrcXY.y + bpmem.copyTexSrcWH.y))
};
- //Need another rc here to get it to scale.
+ float MValueX = OpenGL_GetXmax();
+ float MValueY = OpenGL_GetYmax();
+ //Need another rc here to get it to scale.
//Here the bottom right is the out of the rectangle.
TRectangle multirc = {
(int)(bpmem.copyTexSrcXY.x * MValueX),
diff --git a/Source/Plugins/Plugin_VideoOGL/Src/GLUtil.cpp b/Source/Plugins/Plugin_VideoOGL/Src/GLUtil.cpp
index 5109cda43d..dcfac3376f 100644
--- a/Source/Plugins/Plugin_VideoOGL/Src/GLUtil.cpp
+++ b/Source/Plugins/Plugin_VideoOGL/Src/GLUtil.cpp
@@ -40,6 +40,7 @@ struct RECT
int gleft, gright, gtop, gbottom;
int nBackbufferWidth, nBackbufferHeight; // screen width
int nXoff, nYoff; // screen offset
+float MValueX, MValueY;
float AR; // aspect ratio
#ifndef _WIN32
@@ -67,6 +68,14 @@ void OpenGL_SwapBuffers()
#endif
}
+float OpenGL_GetXmax() {
+ return MValueX;
+}
+
+float OpenGL_GetYmax() {
+ return MValueY;
+}
+
int OpenGL_GetXoff() {
return nXoff;
}
diff --git a/Source/Plugins/Plugin_VideoOGL/Src/GLUtil.h b/Source/Plugins/Plugin_VideoOGL/Src/GLUtil.h
index d4b6a7bf54..56aa484210 100644
--- a/Source/Plugins/Plugin_VideoOGL/Src/GLUtil.h
+++ b/Source/Plugins/Plugin_VideoOGL/Src/GLUtil.h
@@ -118,6 +118,8 @@ extern GLWindow GLWin;
#endif
+float OpenGL_GetXmax();
+float OpenGL_GetYmax();
int OpenGL_GetXoff();
int OpenGL_GetYoff();
u32 OpenGL_GetWidth();
diff --git a/Source/Plugins/Plugin_VideoOGL/Src/GLWindow.h b/Source/Plugins/Plugin_VideoOGL/Src/GLWindow.h
index 0279d6f9d2..5126847ac2 100644
--- a/Source/Plugins/Plugin_VideoOGL/Src/GLWindow.h
+++ b/Source/Plugins/Plugin_VideoOGL/Src/GLWindow.h
@@ -18,31 +18,37 @@ class GLWindow {
private:
u32 width, height;
int yOffset, xOffset;
+ float xMax, yMax;
public:
- /* int screen;
- int x, y;
- unsigned int depth;*/
-
+
virtual void SwapBuffers() {};
virtual void SetWindowText(const char *text) {};
virtual bool PeekMessages() {return false;};
virtual void Update() {};;
virtual bool MakeCurrent() {return false;};
- virtual void SetSize(u32 newWidth, u32 newHeight) {
+
+
+ u32 GetWidth() {return width;}
+ u32 GetHeight() {return height;}
+ void SetSize(u32 newWidth, u32 newHeight) {
width = newWidth;
height = newHeight;
}
+ int GetYoff() {return yOffset;}
+ int GetXoff() {return xOffset;}
void SetOffset(int x, int y) {
yOffset = y;
xOffset = x;
}
- u32 GetWidth() {return width;}
- u32 GetHeight() {return height;}
- int GetYoff() {return yOffset;}
- int GetXoff() {return xOffset;}
-
+ void SetMax(float x, float y) {
+ yMax = y;
+ xMax = x;
+ }
+ float GetXmax() {return xMax;}
+ float GetYmax() {return yMax;}
+
static bool valid() { return false; }
// bool GLwindow(SVideoInitialize &_VideoInitialize, int _iwidth, int _iheight) {};
// setResolution
diff --git a/Source/Plugins/Plugin_VideoOGL/Src/Render.cpp b/Source/Plugins/Plugin_VideoOGL/Src/Render.cpp
index de39385070..896b2b24ae 100644
--- a/Source/Plugins/Plugin_VideoOGL/Src/Render.cpp
+++ b/Source/Plugins/Plugin_VideoOGL/Src/Render.cpp
@@ -83,7 +83,6 @@ static Renderer::RenderMode s_RenderMode = Renderer::RM_Normal;
static int s_nCurTarget = 0;
bool g_bBlendLogicOp = false;
-float MValueX, MValueY; // Since it can Stretch to fit Window, we need two different multiplication values
int frameCount;
void HandleCgError(CGcontext ctx, CGerror err, void* appdata);
@@ -587,7 +586,8 @@ bool Renderer::SetScissorRect()
{
int xoff = bpmem.scissorOffset.x * 2 - 342;
int yoff = bpmem.scissorOffset.y * 2 - 342;
-
+ float MValueX = OpenGL_GetXmax();
+ float MValueY = OpenGL_GetYmax();
float rc_left = bpmem.scissorTL.x - xoff - 342; // left = 0
rc_left *= MValueX;
if (rc_left < 0) rc_left = 0;
diff --git a/Source/Plugins/Plugin_VideoOGL/Src/Render.h b/Source/Plugins/Plugin_VideoOGL/Src/Render.h
index 5b88f7b65d..f80e58e1e3 100644
--- a/Source/Plugins/Plugin_VideoOGL/Src/Render.h
+++ b/Source/Plugins/Plugin_VideoOGL/Src/Render.h
@@ -26,7 +26,6 @@
extern CGcontext g_cgcontext;
extern CGprofile g_cgvProf, g_cgfProf;
-extern float MValueX, MValueY;
extern int frameCount;
class Renderer
diff --git a/Source/Plugins/Plugin_VideoOGL/Src/SDLWindow.cpp b/Source/Plugins/Plugin_VideoOGL/Src/SDLWindow.cpp
index d618a28a4a..f83b9412ce 100644
--- a/Source/Plugins/Plugin_VideoOGL/Src/SDLWindow.cpp
+++ b/Source/Plugins/Plugin_VideoOGL/Src/SDLWindow.cpp
@@ -24,14 +24,12 @@ void SDLWindow::Update() {
// AR = (float)surface->w / (float)surface->h;;
if (g_Config.bStretchToFit) {
- MValueX = 1;
- MValueY = 1;
+ SetMax(1,1);
SetOffset(0,0);
} else {
- MValueX = 1.0f / Max;
- MValueY = 1.0f / Max;
- SetOffset((int)((surface->w - (640 * MValueX)) / 2),
- (int)((surface->h - (480 * MValueY)) / 2));
+ SetMax(1.0f / Max, 1.0f / Max);
+ SetOffset((int)((surface->w - (640 * GetXmax())) / 2),
+ (int)((surface->h - (480 * GetYmax())) / 2));
}
SetSize(surface->w, surface->h);
@@ -49,7 +47,7 @@ bool SDLWindow::MakeCurrent() {
// Fetch video info.
const SDL_VideoInfo *videoInfo = SDL_GetVideoInfo();
if (!videoInfo) {
- // TODO: Display an error message.
+ PanicAlert("Couldn't get video info");
SDL_Quit();
return false;
}
@@ -62,7 +60,7 @@ bool SDLWindow::MakeCurrent() {
SDL_Surface *screen = SDL_SetVideoMode(GetWidth(), GetHeight(),
0, videoFlags);
if (!screen) {
- //TODO : Display an error message
+ PanicAlert("Couldn't set video mode");
SDL_Quit();
return false;
}
@@ -99,18 +97,17 @@ SDLWindow::SDLWindow(int _iwidth, int _iheight) {
float Max = (FactorW < FactorH) ? FactorH : FactorW;
if(g_Config.bStretchToFit) {
- MValueX = 1.0f / FactorW;
- MValueY = 1.0f / FactorH;
+ SetMax(1.0f / FactorW, 1.0f / FactorH);
SetOffset(0,0);
} else {
- MValueX = 1.0f / Max;
- MValueY = 1.0f / Max;
- SetOffset((int)((_twidth - (640 * MValueX)) / 2),
- (int)((_theight - (480 * MValueY)) / 2));
+ SetMax(1.0f / Max, 1.0f / Max);
+ SetOffset((int)((_twidth - (640 * GetXmax())) / 2),
+ (int)((_theight - (480 * GetYmax())) / 2));
}
//init sdl video
if (SDL_Init(SDL_INIT_VIDEO) < 0) {
+ PanicAlert("Failed to init SDL");
//TODO : Display an error message
SDL_Quit();
// return NULL;
diff --git a/Source/Plugins/Plugin_VideoOGL/Src/SDLWindow.h b/Source/Plugins/Plugin_VideoOGL/Src/SDLWindow.h
index 38a63360f2..d56908989d 100644
--- a/Source/Plugins/Plugin_VideoOGL/Src/SDLWindow.h
+++ b/Source/Plugins/Plugin_VideoOGL/Src/SDLWindow.h
@@ -8,8 +8,6 @@
class SDLWindow : public GLWindow
{
public:
- float MValueX, MValueY;
-
virtual void SwapBuffers();
virtual void SetWindowText(const char *text);
virtual bool PeekMessages();
diff --git a/Source/Plugins/Plugin_VideoOGL/Src/TextureMngr.cpp b/Source/Plugins/Plugin_VideoOGL/Src/TextureMngr.cpp
index 73543d0e96..77d68e4d06 100644
--- a/Source/Plugins/Plugin_VideoOGL/Src/TextureMngr.cpp
+++ b/Source/Plugins/Plugin_VideoOGL/Src/TextureMngr.cpp
@@ -583,6 +583,8 @@ void TextureMngr::CopyRenderTargetToTexture(u32 address, bool bFromZBuffer, bool
GL_REPORT_ERRORD();
glBegin(GL_QUADS);
+ float MValueX = OpenGL_GetXmax();
+ float MValueY = OpenGL_GetYmax();
glTexCoord2f((float)source->left * MValueX, Renderer::GetTargetHeight()-(float)source->bottom * MValueY); glVertex2f(-1,1);
glTexCoord2f((float)source->left * MValueX, Renderer::GetTargetHeight()-(float)source->top * MValueY); glVertex2f(-1,-1);
glTexCoord2f((float)source->right * MValueX, Renderer::GetTargetHeight()-(float)source->top * MValueY); glVertex2f(1,-1);
diff --git a/Source/Plugins/Plugin_VideoOGL/Src/VertexShaderManager.cpp b/Source/Plugins/Plugin_VideoOGL/Src/VertexShaderManager.cpp
index cbf5804d12..709ae7e3de 100644
--- a/Source/Plugins/Plugin_VideoOGL/Src/VertexShaderManager.cpp
+++ b/Source/Plugins/Plugin_VideoOGL/Src/VertexShaderManager.cpp
@@ -415,8 +415,10 @@ void VertexShaderMngr::SetConstants()
}
else
{
- glViewport((int)(xfregs.rawViewport[3]-xfregs.rawViewport[0]-342-scissorXOff) * MValueX,
- Renderer::GetTargetHeight()-((int)(xfregs.rawViewport[4]-xfregs.rawViewport[1]-342-scissorYOff)) * MValueY,
+ float MValueX = OpenGL_GetXmax();
+ float MValueY = OpenGL_GetYmax();
+ glViewport((int)(xfregs.rawViewport[3]-xfregs.rawViewport[0]-342-scissorXOff) * MValueX,
+ Renderer::GetTargetHeight()-((int)(xfregs.rawViewport[4]-xfregs.rawViewport[1]-342-scissorYOff)) * MValueY,
abs((int)(2 * xfregs.rawViewport[0])) * MValueX, abs((int)(2 * xfregs.rawViewport[1])) * MValueY);
}
glDepthRange((xfregs.rawViewport[5]- xfregs.rawViewport[2])/16777215.0f, xfregs.rawViewport[5]/16777215.0f);
diff --git a/Source/Plugins/Plugin_VideoOGL/Src/WXGLWindow.cpp b/Source/Plugins/Plugin_VideoOGL/Src/WXGLWindow.cpp
index 636ec6cd73..eb36509621 100644
--- a/Source/Plugins/Plugin_VideoOGL/Src/WXGLWindow.cpp
+++ b/Source/Plugins/Plugin_VideoOGL/Src/WXGLWindow.cpp
@@ -19,15 +19,13 @@ void WXGLWindow::Update() {
float Max = (FactorW < FactorH) ? FactorH : FactorW;
//AR = (float)nBackbufferWidth / (float)nBackbufferHeight;
- if (g_Config.bStretchToFit) {
- MValueX = 1;
- MValueY = 1;
+ if(g_Config.bStretchToFit) {
+ SetMax(1,1);
SetOffset(0,0);
} else {
- MValueX = 1.0f / Max;
- MValueY = 1.0f / Max;
- SetOffset((int)((surface->w - (640 * MValueX)) / 2),
- (int)((surface->h - (480 * MValueY)) / 2));
+ SetMax(1.0f / Max, 1.0f / Max);
+ SetOffset((int)((GetWidth() - (640 * GetXmax())) / 2),
+ (int)((GetHeight() - (480 * GetYmax())) / 2));
}
}
@@ -65,15 +63,13 @@ WXGLWindow::WXGLWindow(int _iwidth, int _iheight) {
float FactorH = 480.0f / (float)_theight;
float Max = (FactorW < FactorH) ? FactorH : FactorW;
- if(g_Config.bStretchToFit) {
- MValueX = 1.0f / FactorW;
- MValueY = 1.0f / FactorH;
+ if(g_Config.bStretchToFit) {
+ SetMax(1.0f / FactorW, 1.0f / FactorH);
SetOffset(0,0);
} else {
- MValueX = 1.0f / Max;
- MValueY = 1.0f / Max;
- SetOffset((int)((_twidth - (640 * MValueX)) / 2),
- (int)((_theight - (480 * MValueY)) / 2));
+ SetMax(1.0f / Max, 1.0f / Max);
+ SetOffset((int)((_twidth - (640 * GetXmax())) / 2),
+ (int)((_theight - (480 * GetYmax())) / 2));
}
int args[] = {WX_GL_RGBA, WX_GL_DOUBLEBUFFER, WX_GL_DEPTH_SIZE, 16, 0};
diff --git a/Source/Plugins/Plugin_VideoOGL/Src/WXGLWindow.h b/Source/Plugins/Plugin_VideoOGL/Src/WXGLWindow.h
index c3acb58425..8cbcf5d9a7 100644
--- a/Source/Plugins/Plugin_VideoOGL/Src/WXGLWindow.h
+++ b/Source/Plugins/Plugin_VideoOGL/Src/WXGLWindow.h
@@ -15,8 +15,6 @@ private:
public:
- float MValueX, MValueY;
-
virtual void SwapBuffers();
virtual void SetWindowText(const char *text);
virtual bool PeekMessages();
diff --git a/Source/Plugins/Plugin_VideoOGL/Src/X11Window.cpp b/Source/Plugins/Plugin_VideoOGL/Src/X11Window.cpp
index b07fea76fc..011218e2f3 100644
--- a/Source/Plugins/Plugin_VideoOGL/Src/X11Window.cpp
+++ b/Source/Plugins/Plugin_VideoOGL/Src/X11Window.cpp
@@ -27,14 +27,12 @@ X11Window::X11Window(int _iwidth, int _iheight) {
float Max = (FactorW < FactorH) ? FactorH : FactorW;
if(g_Config.bStretchToFit) {
- MValueX = 1.0f / FactorW;
- MValueY = 1.0f / FactorH;
+ SetMax(1.0f / FactorW, 1.0f / FactorH);
SetOffset(0,0);
} else {
- MValueX = 1.0f / Max;
- MValueY = 1.0f / Max;
- SetOffset((int)((_twidth - (640 * MValueX)) / 2),
- (int)((_theight - (480 * MValueY)) / 2));
+ SetMax(1.0f / Max, 1.0f / Max);
+ SetOffset((int)((_twidth - (640 * GetXmax())) / 2),
+ (int)((_theight - (480 * GetYmax())) / 2));
}
XVisualInfo *vi;
diff --git a/Source/Plugins/Plugin_VideoOGL/Src/X11Window.h b/Source/Plugins/Plugin_VideoOGL/Src/X11Window.h
index 02d06b9ec9..acd762955a 100644
--- a/Source/Plugins/Plugin_VideoOGL/Src/X11Window.h
+++ b/Source/Plugins/Plugin_VideoOGL/Src/X11Window.h
@@ -23,7 +23,6 @@ public:
Bool fs;
Bool doubleBuffered;
XF86VidModeModeInfo deskMode;
- float MValueX, MValueY;
virtual void SwapBuffers();
virtual void SetWindowText(const char *text);
diff --git a/Source/Plugins/Plugin_VideoOGL/Src/nGLUtil.cpp b/Source/Plugins/Plugin_VideoOGL/Src/nGLUtil.cpp
index 4411bf7c39..45b04eb092 100644
--- a/Source/Plugins/Plugin_VideoOGL/Src/nGLUtil.cpp
+++ b/Source/Plugins/Plugin_VideoOGL/Src/nGLUtil.cpp
@@ -111,6 +111,14 @@ int OpenGL_GetYoff() {
return glWin->GetYoff();
}
+float OpenGL_GetXmax() {
+ return glWin->GetXmax();
+}
+
+float OpenGL_GetYmax() {
+ return glWin->GetYmax();
+}
+
void OpenGL_AddBackends(ConfigDialog *frame) {
if(SDLWindow::valid())
frame->AddRenderBackend("SDL");
diff --git a/Source/Plugins/Plugin_VideoOGL/Src/nGLUtil.h b/Source/Plugins/Plugin_VideoOGL/Src/nGLUtil.h
index ca70c576d6..44cbb6850a 100644
--- a/Source/Plugins/Plugin_VideoOGL/Src/nGLUtil.h
+++ b/Source/Plugins/Plugin_VideoOGL/Src/nGLUtil.h
@@ -57,5 +57,7 @@ u32 OpenGL_GetHeight();
void OpenGL_SetSize(u32 width, u32 height);
int OpenGL_GetXoff();
int OpenGL_GetYoff();
+float OpenGL_GetXmax();
+float OpenGL_GetYmax();
#endif