mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-23 06:09:50 -06:00
more code cleanup
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@1622 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
@ -434,6 +434,8 @@ void BPWritten(int addr, int changes, int newval)
|
|||||||
(int)((bpmem.copyTexSrcXY.x + bpmem.copyTexSrcWH.x)),
|
(int)((bpmem.copyTexSrcXY.x + bpmem.copyTexSrcWH.x)),
|
||||||
(int)((bpmem.copyTexSrcXY.y + bpmem.copyTexSrcWH.y))
|
(int)((bpmem.copyTexSrcXY.y + bpmem.copyTexSrcWH.y))
|
||||||
};
|
};
|
||||||
|
float MValueX = OpenGL_GetXmax();
|
||||||
|
float MValueY = OpenGL_GetYmax();
|
||||||
//Need another rc here to get it to scale.
|
//Need another rc here to get it to scale.
|
||||||
//Here the bottom right is the out of the rectangle.
|
//Here the bottom right is the out of the rectangle.
|
||||||
TRectangle multirc = {
|
TRectangle multirc = {
|
||||||
|
@ -40,6 +40,7 @@ struct RECT
|
|||||||
int gleft, gright, gtop, gbottom;
|
int gleft, gright, gtop, gbottom;
|
||||||
int nBackbufferWidth, nBackbufferHeight; // screen width
|
int nBackbufferWidth, nBackbufferHeight; // screen width
|
||||||
int nXoff, nYoff; // screen offset
|
int nXoff, nYoff; // screen offset
|
||||||
|
float MValueX, MValueY;
|
||||||
float AR; // aspect ratio
|
float AR; // aspect ratio
|
||||||
|
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
@ -67,6 +68,14 @@ void OpenGL_SwapBuffers()
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float OpenGL_GetXmax() {
|
||||||
|
return MValueX;
|
||||||
|
}
|
||||||
|
|
||||||
|
float OpenGL_GetYmax() {
|
||||||
|
return MValueY;
|
||||||
|
}
|
||||||
|
|
||||||
int OpenGL_GetXoff() {
|
int OpenGL_GetXoff() {
|
||||||
return nXoff;
|
return nXoff;
|
||||||
}
|
}
|
||||||
|
@ -118,6 +118,8 @@ extern GLWindow GLWin;
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
float OpenGL_GetXmax();
|
||||||
|
float OpenGL_GetYmax();
|
||||||
int OpenGL_GetXoff();
|
int OpenGL_GetXoff();
|
||||||
int OpenGL_GetYoff();
|
int OpenGL_GetYoff();
|
||||||
u32 OpenGL_GetWidth();
|
u32 OpenGL_GetWidth();
|
||||||
|
@ -18,30 +18,36 @@ class GLWindow {
|
|||||||
private:
|
private:
|
||||||
u32 width, height;
|
u32 width, height;
|
||||||
int yOffset, xOffset;
|
int yOffset, xOffset;
|
||||||
|
float xMax, yMax;
|
||||||
public:
|
public:
|
||||||
/* int screen;
|
|
||||||
int x, y;
|
|
||||||
unsigned int depth;*/
|
|
||||||
|
|
||||||
virtual void SwapBuffers() {};
|
virtual void SwapBuffers() {};
|
||||||
virtual void SetWindowText(const char *text) {};
|
virtual void SetWindowText(const char *text) {};
|
||||||
virtual bool PeekMessages() {return false;};
|
virtual bool PeekMessages() {return false;};
|
||||||
virtual void Update() {};;
|
virtual void Update() {};;
|
||||||
virtual bool MakeCurrent() {return false;};
|
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;
|
width = newWidth;
|
||||||
height = newHeight;
|
height = newHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int GetYoff() {return yOffset;}
|
||||||
|
int GetXoff() {return xOffset;}
|
||||||
void SetOffset(int x, int y) {
|
void SetOffset(int x, int y) {
|
||||||
yOffset = y;
|
yOffset = y;
|
||||||
xOffset = x;
|
xOffset = x;
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 GetWidth() {return width;}
|
void SetMax(float x, float y) {
|
||||||
u32 GetHeight() {return height;}
|
yMax = y;
|
||||||
int GetYoff() {return yOffset;}
|
xMax = x;
|
||||||
int GetXoff() {return xOffset;}
|
}
|
||||||
|
float GetXmax() {return xMax;}
|
||||||
|
float GetYmax() {return yMax;}
|
||||||
|
|
||||||
static bool valid() { return false; }
|
static bool valid() { return false; }
|
||||||
// bool GLwindow(SVideoInitialize &_VideoInitialize, int _iwidth, int _iheight) {};
|
// bool GLwindow(SVideoInitialize &_VideoInitialize, int _iwidth, int _iheight) {};
|
||||||
|
@ -83,7 +83,6 @@ static Renderer::RenderMode s_RenderMode = Renderer::RM_Normal;
|
|||||||
static int s_nCurTarget = 0;
|
static int s_nCurTarget = 0;
|
||||||
bool g_bBlendLogicOp = false;
|
bool g_bBlendLogicOp = false;
|
||||||
|
|
||||||
float MValueX, MValueY; // Since it can Stretch to fit Window, we need two different multiplication values
|
|
||||||
int frameCount;
|
int frameCount;
|
||||||
|
|
||||||
void HandleCgError(CGcontext ctx, CGerror err, void* appdata);
|
void HandleCgError(CGcontext ctx, CGerror err, void* appdata);
|
||||||
@ -587,7 +586,8 @@ bool Renderer::SetScissorRect()
|
|||||||
{
|
{
|
||||||
int xoff = bpmem.scissorOffset.x * 2 - 342;
|
int xoff = bpmem.scissorOffset.x * 2 - 342;
|
||||||
int yoff = bpmem.scissorOffset.y * 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
|
float rc_left = bpmem.scissorTL.x - xoff - 342; // left = 0
|
||||||
rc_left *= MValueX;
|
rc_left *= MValueX;
|
||||||
if (rc_left < 0) rc_left = 0;
|
if (rc_left < 0) rc_left = 0;
|
||||||
|
@ -26,7 +26,6 @@
|
|||||||
extern CGcontext g_cgcontext;
|
extern CGcontext g_cgcontext;
|
||||||
extern CGprofile g_cgvProf, g_cgfProf;
|
extern CGprofile g_cgvProf, g_cgfProf;
|
||||||
|
|
||||||
extern float MValueX, MValueY;
|
|
||||||
extern int frameCount;
|
extern int frameCount;
|
||||||
|
|
||||||
class Renderer
|
class Renderer
|
||||||
|
@ -24,14 +24,12 @@ void SDLWindow::Update() {
|
|||||||
// AR = (float)surface->w / (float)surface->h;;
|
// AR = (float)surface->w / (float)surface->h;;
|
||||||
|
|
||||||
if (g_Config.bStretchToFit) {
|
if (g_Config.bStretchToFit) {
|
||||||
MValueX = 1;
|
SetMax(1,1);
|
||||||
MValueY = 1;
|
|
||||||
SetOffset(0,0);
|
SetOffset(0,0);
|
||||||
} else {
|
} else {
|
||||||
MValueX = 1.0f / Max;
|
SetMax(1.0f / Max, 1.0f / Max);
|
||||||
MValueY = 1.0f / Max;
|
SetOffset((int)((surface->w - (640 * GetXmax())) / 2),
|
||||||
SetOffset((int)((surface->w - (640 * MValueX)) / 2),
|
(int)((surface->h - (480 * GetYmax())) / 2));
|
||||||
(int)((surface->h - (480 * MValueY)) / 2));
|
|
||||||
}
|
}
|
||||||
SetSize(surface->w, surface->h);
|
SetSize(surface->w, surface->h);
|
||||||
|
|
||||||
@ -49,7 +47,7 @@ bool SDLWindow::MakeCurrent() {
|
|||||||
// Fetch video info.
|
// Fetch video info.
|
||||||
const SDL_VideoInfo *videoInfo = SDL_GetVideoInfo();
|
const SDL_VideoInfo *videoInfo = SDL_GetVideoInfo();
|
||||||
if (!videoInfo) {
|
if (!videoInfo) {
|
||||||
// TODO: Display an error message.
|
PanicAlert("Couldn't get video info");
|
||||||
SDL_Quit();
|
SDL_Quit();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -62,7 +60,7 @@ bool SDLWindow::MakeCurrent() {
|
|||||||
SDL_Surface *screen = SDL_SetVideoMode(GetWidth(), GetHeight(),
|
SDL_Surface *screen = SDL_SetVideoMode(GetWidth(), GetHeight(),
|
||||||
0, videoFlags);
|
0, videoFlags);
|
||||||
if (!screen) {
|
if (!screen) {
|
||||||
//TODO : Display an error message
|
PanicAlert("Couldn't set video mode");
|
||||||
SDL_Quit();
|
SDL_Quit();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -99,18 +97,17 @@ SDLWindow::SDLWindow(int _iwidth, int _iheight) {
|
|||||||
float Max = (FactorW < FactorH) ? FactorH : FactorW;
|
float Max = (FactorW < FactorH) ? FactorH : FactorW;
|
||||||
|
|
||||||
if(g_Config.bStretchToFit) {
|
if(g_Config.bStretchToFit) {
|
||||||
MValueX = 1.0f / FactorW;
|
SetMax(1.0f / FactorW, 1.0f / FactorH);
|
||||||
MValueY = 1.0f / FactorH;
|
|
||||||
SetOffset(0,0);
|
SetOffset(0,0);
|
||||||
} else {
|
} else {
|
||||||
MValueX = 1.0f / Max;
|
SetMax(1.0f / Max, 1.0f / Max);
|
||||||
MValueY = 1.0f / Max;
|
SetOffset((int)((_twidth - (640 * GetXmax())) / 2),
|
||||||
SetOffset((int)((_twidth - (640 * MValueX)) / 2),
|
(int)((_theight - (480 * GetYmax())) / 2));
|
||||||
(int)((_theight - (480 * MValueY)) / 2));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//init sdl video
|
//init sdl video
|
||||||
if (SDL_Init(SDL_INIT_VIDEO) < 0) {
|
if (SDL_Init(SDL_INIT_VIDEO) < 0) {
|
||||||
|
PanicAlert("Failed to init SDL");
|
||||||
//TODO : Display an error message
|
//TODO : Display an error message
|
||||||
SDL_Quit();
|
SDL_Quit();
|
||||||
// return NULL;
|
// return NULL;
|
||||||
|
@ -8,8 +8,6 @@
|
|||||||
class SDLWindow : public GLWindow
|
class SDLWindow : public GLWindow
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
float MValueX, MValueY;
|
|
||||||
|
|
||||||
virtual void SwapBuffers();
|
virtual void SwapBuffers();
|
||||||
virtual void SetWindowText(const char *text);
|
virtual void SetWindowText(const char *text);
|
||||||
virtual bool PeekMessages();
|
virtual bool PeekMessages();
|
||||||
|
@ -583,6 +583,8 @@ void TextureMngr::CopyRenderTargetToTexture(u32 address, bool bFromZBuffer, bool
|
|||||||
GL_REPORT_ERRORD();
|
GL_REPORT_ERRORD();
|
||||||
|
|
||||||
glBegin(GL_QUADS);
|
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->bottom * MValueY); glVertex2f(-1,1);
|
||||||
glTexCoord2f((float)source->left * MValueX, Renderer::GetTargetHeight()-(float)source->top * 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);
|
glTexCoord2f((float)source->right * MValueX, Renderer::GetTargetHeight()-(float)source->top * MValueY); glVertex2f(1,-1);
|
||||||
|
@ -415,6 +415,8 @@ void VertexShaderMngr::SetConstants()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
float MValueX = OpenGL_GetXmax();
|
||||||
|
float MValueY = OpenGL_GetYmax();
|
||||||
glViewport((int)(xfregs.rawViewport[3]-xfregs.rawViewport[0]-342-scissorXOff) * MValueX,
|
glViewport((int)(xfregs.rawViewport[3]-xfregs.rawViewport[0]-342-scissorXOff) * MValueX,
|
||||||
Renderer::GetTargetHeight()-((int)(xfregs.rawViewport[4]-xfregs.rawViewport[1]-342-scissorYOff)) * MValueY,
|
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);
|
abs((int)(2 * xfregs.rawViewport[0])) * MValueX, abs((int)(2 * xfregs.rawViewport[1])) * MValueY);
|
||||||
|
@ -20,14 +20,12 @@ void WXGLWindow::Update() {
|
|||||||
//AR = (float)nBackbufferWidth / (float)nBackbufferHeight;
|
//AR = (float)nBackbufferWidth / (float)nBackbufferHeight;
|
||||||
|
|
||||||
if(g_Config.bStretchToFit) {
|
if(g_Config.bStretchToFit) {
|
||||||
MValueX = 1;
|
SetMax(1,1);
|
||||||
MValueY = 1;
|
|
||||||
SetOffset(0,0);
|
SetOffset(0,0);
|
||||||
} else {
|
} else {
|
||||||
MValueX = 1.0f / Max;
|
SetMax(1.0f / Max, 1.0f / Max);
|
||||||
MValueY = 1.0f / Max;
|
SetOffset((int)((GetWidth() - (640 * GetXmax())) / 2),
|
||||||
SetOffset((int)((surface->w - (640 * MValueX)) / 2),
|
(int)((GetHeight() - (480 * GetYmax())) / 2));
|
||||||
(int)((surface->h - (480 * MValueY)) / 2));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -66,14 +64,12 @@ WXGLWindow::WXGLWindow(int _iwidth, int _iheight) {
|
|||||||
float Max = (FactorW < FactorH) ? FactorH : FactorW;
|
float Max = (FactorW < FactorH) ? FactorH : FactorW;
|
||||||
|
|
||||||
if(g_Config.bStretchToFit) {
|
if(g_Config.bStretchToFit) {
|
||||||
MValueX = 1.0f / FactorW;
|
SetMax(1.0f / FactorW, 1.0f / FactorH);
|
||||||
MValueY = 1.0f / FactorH;
|
|
||||||
SetOffset(0,0);
|
SetOffset(0,0);
|
||||||
} else {
|
} else {
|
||||||
MValueX = 1.0f / Max;
|
SetMax(1.0f / Max, 1.0f / Max);
|
||||||
MValueY = 1.0f / Max;
|
SetOffset((int)((_twidth - (640 * GetXmax())) / 2),
|
||||||
SetOffset((int)((_twidth - (640 * MValueX)) / 2),
|
(int)((_theight - (480 * GetYmax())) / 2));
|
||||||
(int)((_theight - (480 * MValueY)) / 2));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int args[] = {WX_GL_RGBA, WX_GL_DOUBLEBUFFER, WX_GL_DEPTH_SIZE, 16, 0};
|
int args[] = {WX_GL_RGBA, WX_GL_DOUBLEBUFFER, WX_GL_DEPTH_SIZE, 16, 0};
|
||||||
|
@ -15,8 +15,6 @@ private:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
float MValueX, MValueY;
|
|
||||||
|
|
||||||
virtual void SwapBuffers();
|
virtual void SwapBuffers();
|
||||||
virtual void SetWindowText(const char *text);
|
virtual void SetWindowText(const char *text);
|
||||||
virtual bool PeekMessages();
|
virtual bool PeekMessages();
|
||||||
|
@ -27,14 +27,12 @@ X11Window::X11Window(int _iwidth, int _iheight) {
|
|||||||
float Max = (FactorW < FactorH) ? FactorH : FactorW;
|
float Max = (FactorW < FactorH) ? FactorH : FactorW;
|
||||||
|
|
||||||
if(g_Config.bStretchToFit) {
|
if(g_Config.bStretchToFit) {
|
||||||
MValueX = 1.0f / FactorW;
|
SetMax(1.0f / FactorW, 1.0f / FactorH);
|
||||||
MValueY = 1.0f / FactorH;
|
|
||||||
SetOffset(0,0);
|
SetOffset(0,0);
|
||||||
} else {
|
} else {
|
||||||
MValueX = 1.0f / Max;
|
SetMax(1.0f / Max, 1.0f / Max);
|
||||||
MValueY = 1.0f / Max;
|
SetOffset((int)((_twidth - (640 * GetXmax())) / 2),
|
||||||
SetOffset((int)((_twidth - (640 * MValueX)) / 2),
|
(int)((_theight - (480 * GetYmax())) / 2));
|
||||||
(int)((_theight - (480 * MValueY)) / 2));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
XVisualInfo *vi;
|
XVisualInfo *vi;
|
||||||
|
@ -23,7 +23,6 @@ public:
|
|||||||
Bool fs;
|
Bool fs;
|
||||||
Bool doubleBuffered;
|
Bool doubleBuffered;
|
||||||
XF86VidModeModeInfo deskMode;
|
XF86VidModeModeInfo deskMode;
|
||||||
float MValueX, MValueY;
|
|
||||||
|
|
||||||
virtual void SwapBuffers();
|
virtual void SwapBuffers();
|
||||||
virtual void SetWindowText(const char *text);
|
virtual void SetWindowText(const char *text);
|
||||||
|
@ -111,6 +111,14 @@ int OpenGL_GetYoff() {
|
|||||||
return glWin->GetYoff();
|
return glWin->GetYoff();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float OpenGL_GetXmax() {
|
||||||
|
return glWin->GetXmax();
|
||||||
|
}
|
||||||
|
|
||||||
|
float OpenGL_GetYmax() {
|
||||||
|
return glWin->GetYmax();
|
||||||
|
}
|
||||||
|
|
||||||
void OpenGL_AddBackends(ConfigDialog *frame) {
|
void OpenGL_AddBackends(ConfigDialog *frame) {
|
||||||
if(SDLWindow::valid())
|
if(SDLWindow::valid())
|
||||||
frame->AddRenderBackend("SDL");
|
frame->AddRenderBackend("SDL");
|
||||||
|
@ -57,5 +57,7 @@ u32 OpenGL_GetHeight();
|
|||||||
void OpenGL_SetSize(u32 width, u32 height);
|
void OpenGL_SetSize(u32 width, u32 height);
|
||||||
int OpenGL_GetXoff();
|
int OpenGL_GetXoff();
|
||||||
int OpenGL_GetYoff();
|
int OpenGL_GetYoff();
|
||||||
|
float OpenGL_GetXmax();
|
||||||
|
float OpenGL_GetYmax();
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Reference in New Issue
Block a user