summaryrefslogtreecommitdiff
path: root/Source
diff options
context:
space:
mode:
Diffstat (limited to 'Source')
-rw-r--r--Source/Plugins/Plugin_VideoOGL/Src/BPStructs.cpp20
-rw-r--r--Source/Plugins/Plugin_VideoOGL/Src/GLInit.cpp37
-rw-r--r--Source/Plugins/Plugin_VideoOGL/Src/GLInit.h1
-rw-r--r--Source/Plugins/Plugin_VideoOGL/Src/Globals.cpp6
-rw-r--r--Source/Plugins/Plugin_VideoOGL/Src/Globals.h4
-rw-r--r--Source/Plugins/Plugin_VideoOGL/Src/Render.cpp37
-rw-r--r--Source/Plugins/Plugin_VideoOGL/Src/TextureMngr.cpp8
-rw-r--r--Source/Plugins/Plugin_VideoOGL/Src/VertexShaderManager.cpp2
8 files changed, 78 insertions, 37 deletions
diff --git a/Source/Plugins/Plugin_VideoOGL/Src/BPStructs.cpp b/Source/Plugins/Plugin_VideoOGL/Src/BPStructs.cpp
index 5ce9b1a8f9..62f07fd4d5 100644
--- a/Source/Plugins/Plugin_VideoOGL/Src/BPStructs.cpp
+++ b/Source/Plugins/Plugin_VideoOGL/Src/BPStructs.cpp
@@ -529,18 +529,18 @@ bool SetScissorRect()
//printf("xoff: %d yoff: %d\n", xoff, yoff);
RECT rc;
rc.left = bpmem.scissorTL.x + xoff - 342;
- rc.left *= MValue;
+ rc.left *= MValueX;
if (rc.left < 0) rc.left = 0;
rc.top = bpmem.scissorTL.y + yoff - 342;
- rc.top *= MValue;
+ rc.top *= MValueY;
if (rc.top < 0) rc.top = 0;
rc.right = bpmem.scissorBR.x + xoff - 342 +1;
- rc.right *= MValue;
- if (rc.right > 640 * MValue) rc.right = 640 * MValue;
+ rc.right *= MValueX;
+ if (rc.right > 640 * MValueX) rc.right = 640 * MValueX;
rc.bottom = bpmem.scissorBR.y + yoff - 342 +1;
- rc.bottom *= MValue;
- if (rc.bottom > 480 * MValue) rc.bottom = 480 * MValue;
+ rc.bottom *= MValueY;
+ if (rc.bottom > 480 * MValueY) rc.bottom = 480 * MValueY;
//printf("scissor: lt=(%d,%d),rb=(%d,%d),off=(%d,%d)\n", rc.left, rc.top, rc.right, rc.bottom, xoff, yoff);
@@ -609,10 +609,10 @@ void LoadBPReg(u32 value0)
};
//Need another rc here to get it to scale.
TRectangle multirc = {
- (int)(bpmem.copyTexSrcXY.x * MValue),
- (int)(bpmem.copyTexSrcXY.y * MValue),
- (int)((bpmem.copyTexSrcXY.x * MValue + bpmem.copyTexSrcWH.x * MValue)),
- (int)((bpmem.copyTexSrcXY.y * MValue + bpmem.copyTexSrcWH.y * MValue))
+ (int)(bpmem.copyTexSrcXY.x * MValueX),
+ (int)(bpmem.copyTexSrcXY.y * MValueY),
+ (int)((bpmem.copyTexSrcXY.x * MValueX + bpmem.copyTexSrcWH.x * MValueX)),
+ (int)((bpmem.copyTexSrcXY.y * MValueY + bpmem.copyTexSrcWH.y * MValueY))
};
UPE_Copy PE_copy;
diff --git a/Source/Plugins/Plugin_VideoOGL/Src/GLInit.cpp b/Source/Plugins/Plugin_VideoOGL/Src/GLInit.cpp
index c999f6d4c4..ef5e4abd5d 100644
--- a/Source/Plugins/Plugin_VideoOGL/Src/GLInit.cpp
+++ b/Source/Plugins/Plugin_VideoOGL/Src/GLInit.cpp
@@ -32,6 +32,7 @@
// screen offset
int nBackbufferWidth, nBackbufferHeight;
+int nXoff, nYoff;
#ifndef _WIN32
GLWindow GLWin;
@@ -148,8 +149,20 @@ bool OpenGL_Create(SVideoInitialize &_VideoInitialize, int _iwidth, int _iheight
float FactorH = 480.0f / (float)nBackbufferHeight;
float Max = (FactorW < FactorH) ? FactorH : FactorW;
- MValue = 1.0f / Max;
-
+ if(g_Config.bStretchToFit)
+ {
+ MValueX = 1.0f / FactorW;
+ MValueY = 1.0f / FactorH;
+ nXoff = 0;
+ nYoff = 0;
+ }
+ else
+ {
+ MValueX = 1.0f / Max;
+ MValueY = 1.0f / Max;
+ nXoff = (nBackbufferWidth - (640 * MValueX)) / 2;
+ nYoff = (nBackbufferHeight - (480 * MValueY)) / 2;
+ }
g_VideoInitialize.pPeekMessages = &Callback_PeekMessages;
g_VideoInitialize.pUpdateFPSDisplay = &UpdateFPSDisplay;
@@ -485,12 +498,26 @@ void OpenGL_Update()
::MoveWindow(EmuWindow::GetWnd(), 0,0,width,height, FALSE);
nBackbufferWidth = width;
nBackbufferHeight = height;
- float FactorW = (float)640 / (float)nBackbufferWidth;
- float FactorH = (float)480 / (float)nBackbufferHeight;
+ float FactorW = 640.0f / (float)nBackbufferWidth;
+ float FactorH = 480.0f / (float)nBackbufferHeight;
float Max = (FactorW < FactorH) ? FactorH : FactorW;
- MValue = 1 / Max;
+ float Max = (FactorW < FactorH) ? FactorH : FactorW;
+ if(g_Config.bStretchToFit)
+ {
+ MValueX = 1.0f / FactorW;
+ MValueY = 1.0f / FactorH;
+ nXoff = 0;
+ nYoff = 0;
+ }
+ else
+ {
+ MValueX = 1.0f / Max;
+ MValueY = 1.0f / Max;
+ nXoff = (nBackbufferWidth - (640 * MValueX)) / 2;
+ nYoff = (nBackbufferHeight - (480 * MValueY)) / 2;
+ }
/*
u32 TmpAAx = (width / 640) - 1;
u32 TmpAAy = (height / 480) - 1;
diff --git a/Source/Plugins/Plugin_VideoOGL/Src/GLInit.h b/Source/Plugins/Plugin_VideoOGL/Src/GLInit.h
index 1941233eee..a598070ce1 100644
--- a/Source/Plugins/Plugin_VideoOGL/Src/GLInit.h
+++ b/Source/Plugins/Plugin_VideoOGL/Src/GLInit.h
@@ -51,6 +51,7 @@ extern GLWindow GLWin;
// yeah yeah, these should be hidden
extern int nBackbufferWidth, nBackbufferHeight;
+extern int nXoff, nYoff;
bool OpenGL_Create(SVideoInitialize &_VideoInitialize, int _width, int _height);
bool OpenGL_MakeCurrent();
diff --git a/Source/Plugins/Plugin_VideoOGL/Src/Globals.cpp b/Source/Plugins/Plugin_VideoOGL/Src/Globals.cpp
index 31d73b4329..fa62133927 100644
--- a/Source/Plugins/Plugin_VideoOGL/Src/Globals.cpp
+++ b/Source/Plugins/Plugin_VideoOGL/Src/Globals.cpp
@@ -29,7 +29,7 @@
#include "IniFile.h"
#include <assert.h>
-float MValue;
+float MValueX, MValueY; // Since it can Stretch to fit Window, we need two different multiplication values//
int frameCount;
Config g_Config;
@@ -82,6 +82,8 @@ void Config::Load()
iniFile.Get("Enhancements", "ForceFiltering", &bForceFiltering, 0);
iniFile.Get("Enhancements", "ForceMaxAniso", &bForceMaxAniso, 0);
+ iniFile.Get("Enhancements", "StretchToFit", &bStretchToFit, false);
+ iniFile.Get("Enhancements", "ShowFPS", &bShowFPS, false);
}
void Config::Save()
@@ -107,6 +109,8 @@ void Config::Save()
iniFile.Set("Enhancements", "ForceFiltering", bForceFiltering);
iniFile.Set("Enhancements", "ForceMaxAniso", bForceMaxAniso);
+ iniFile.Set("Enhancements", "StretchToFit", bStretchToFit);
+ iniFile.Set("Enhancements", "ShowFPS", bShowFPS);
iniFile.Save("gfx_opengl.ini");
}
diff --git a/Source/Plugins/Plugin_VideoOGL/Src/Globals.h b/Source/Plugins/Plugin_VideoOGL/Src/Globals.h
index 60ad8bc772..a5f517c3b2 100644
--- a/Source/Plugins/Plugin_VideoOGL/Src/Globals.h
+++ b/Source/Plugins/Plugin_VideoOGL/Src/Globals.h
@@ -85,7 +85,7 @@ struct RECT
#define GL_TEXTURE_STENCIL_SIZE_EXT 0x88F1
#endif
-extern float MValue;
+extern float MValueX, MValueY;
#define ERROR_LOG __Log
@@ -137,6 +137,8 @@ struct Config
bool bForceFiltering;
bool bForceMaxAniso;
+ bool bStretchToFit;
+ bool bShowFPS;
bool bTexFmtOverlayEnable;
bool bTexFmtOverlayCenter;
diff --git a/Source/Plugins/Plugin_VideoOGL/Src/Render.cpp b/Source/Plugins/Plugin_VideoOGL/Src/Render.cpp
index f029fc0221..653efee1f5 100644
--- a/Source/Plugins/Plugin_VideoOGL/Src/Render.cpp
+++ b/Source/Plugins/Plugin_VideoOGL/Src/Render.cpp
@@ -641,7 +641,6 @@ u32 Renderer::GetZBufferTarget()
{
return nZBufferRender > 0 ? s_ZBufferTarget : 0;
}
-
void Renderer::Swap(const TRectangle& rc)
{
OpenGL_Update(); // just updates the render window position and the backbuffer size
@@ -652,7 +651,7 @@ void Renderer::Swap(const TRectangle& rc)
// render to the real buffer now
glBindFramebufferEXT( GL_FRAMEBUFFER_EXT, 0 ); // switch to the backbuffer
- glViewport(0, 0, nBackbufferWidth, nBackbufferHeight);
+ glViewport(nXoff, nYoff, nBackbufferWidth, nBackbufferHeight);
ResetGLState();
@@ -674,23 +673,22 @@ void Renderer::Swap(const TRectangle& rc)
glBindTexture(GL_TEXTURE_RECTANGLE_NV, 0);
TextureMngr::DisableStage(0);
-// static int fpscount = 0;
-// static float s_fps = 0;
-// static u32 lasttime = timeGetTime();
-//
-// if( ++fpscount >= 16 ) {
-// s_fps = 16*1000.0f/(float)(timeGetTime() - lasttime);
-// lasttime = timeGetTime();
-// fpscount = 0;
-// }
-//
-// char strfps[25];
-// sprintf(strfps, "fps: %2.1f\n", s_fps);
-// Renderer::RenderText(strfps, 20, 20, 0xFF00FFFF);
+ static int fpscount;
+ static int s_fps;
+ static unsigned long lasttime;
+ ++fpscount;
+ if( timeGetTime() - lasttime > 1000 )
+ {
+ lasttime = timeGetTime();
+ s_fps = fpscount;
+ fpscount = 0;
+ }
if (g_Config.bOverlayStats) {
char st[2048];
char *p = st;
+ if(g_Config.bShowFPS)
+ p+=sprintf(p, "FPS: %d\n", s_fps); // So it shows up before the stats and doesn't make anyting ugly
p+=sprintf(p,"Num textures created: %i\n",stats.numTexturesCreated);
p+=sprintf(p,"Num textures alive: %i\n",stats.numTexturesAlive);
p+=sprintf(p,"Num pshaders created: %i\n",stats.numPixelShadersCreated);
@@ -715,6 +713,15 @@ void Renderer::Swap(const TRectangle& rc)
Renderer::RenderText(st, 20, 20, 0xFF00FFFF);
}
+ else
+ {
+ if(g_Config.bShowFPS)
+ {
+ char strfps[25];
+ sprintf(strfps, "%d\n", s_fps);
+ Renderer::RenderText(strfps, 20, 20, 0xFF00FFFF);
+ }
+ }
Renderer::ProcessMessages();
diff --git a/Source/Plugins/Plugin_VideoOGL/Src/TextureMngr.cpp b/Source/Plugins/Plugin_VideoOGL/Src/TextureMngr.cpp
index 03c811e316..dd2e1be8b6 100644
--- a/Source/Plugins/Plugin_VideoOGL/Src/TextureMngr.cpp
+++ b/Source/Plugins/Plugin_VideoOGL/Src/TextureMngr.cpp
@@ -530,10 +530,10 @@ void TextureMngr::CopyRenderTargetToTexture(u32 address, bool bFromZBuffer, bool
GL_REPORT_ERRORD();
glBegin(GL_QUADS);
- glTexCoord2f((float)source->left * MValue, Renderer::GetTargetHeight()-(float)source->bottom * MValue); glVertex2f(-1,1);
- glTexCoord2f((float)source->left * MValue, Renderer::GetTargetHeight()-(float)source->top * MValue); glVertex2f(-1,-1);
- glTexCoord2f((float)source->right * MValue, Renderer::GetTargetHeight()-(float)source->top * MValue); glVertex2f(1,-1);
- glTexCoord2f((float)source->right * MValue, Renderer::GetTargetHeight()-(float)source->bottom * MValue); 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->right * MValueX, Renderer::GetTargetHeight()-(float)source->top * MValueY); glVertex2f(1,-1);
+ glTexCoord2f((float)source->right * MValueX, Renderer::GetTargetHeight()-(float)source->bottom * MValueY); glVertex2f(1,1);
glEnd();
GL_REPORT_ERRORD();
diff --git a/Source/Plugins/Plugin_VideoOGL/Src/VertexShaderManager.cpp b/Source/Plugins/Plugin_VideoOGL/Src/VertexShaderManager.cpp
index bc05ca2c57..576e08225f 100644
--- a/Source/Plugins/Plugin_VideoOGL/Src/VertexShaderManager.cpp
+++ b/Source/Plugins/Plugin_VideoOGL/Src/VertexShaderManager.cpp
@@ -322,7 +322,7 @@ void VertexShaderMngr::SetConstants(VERTEXSHADER& vs)
// [5] = 16777215 * farz
INFO_LOG("view: topleft=(%f,%f), wh=(%f,%f), z=(%f,%f)\n",rawViewport[3]-rawViewport[0]-342,rawViewport[4]+rawViewport[1]-342,
2 * rawViewport[0], 2 * rawViewport[1], (rawViewport[5]-rawViewport[2])/16777215.0f, rawViewport[5]/16777215.0f);
- glViewport((int)(rawViewport[3]-rawViewport[0]-342) * MValue,Renderer::GetTargetHeight()-((int)(rawViewport[4]-rawViewport[1]-342)) * MValue, abs((int)(2 * rawViewport[0])) * MValue, abs((int)(2 * rawViewport[1])) * MValue);
+ glViewport((int)(rawViewport[3]-rawViewport[0]-342) * MValueX,Renderer::GetTargetHeight()-((int)(rawViewport[4]-rawViewport[1]-342)) * MValueY, abs((int)(2 * rawViewport[0])) * MValueX, abs((int)(2 * rawViewport[1])) * MValueY);
glDepthRange((rawViewport[5]-rawViewport[2])/16777215.0f, rawViewport[5]/16777215.0f);
}