GL plugin now centers video output, you can set it to render to the full window and FPS can be shown. FPS and stretch to Window res is set in INI. Maybe also the window res actually changes correctly when resizing window in Windows?
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@287 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
parent
98b9cfb2de
commit
05cbb94cbb
|
@ -529,18 +529,18 @@ bool SetScissorRect()
|
||||||
//printf("xoff: %d yoff: %d\n", xoff, yoff);
|
//printf("xoff: %d yoff: %d\n", xoff, yoff);
|
||||||
RECT rc;
|
RECT rc;
|
||||||
rc.left = bpmem.scissorTL.x + xoff - 342;
|
rc.left = bpmem.scissorTL.x + xoff - 342;
|
||||||
rc.left *= MValue;
|
rc.left *= MValueX;
|
||||||
if (rc.left < 0) rc.left = 0;
|
if (rc.left < 0) rc.left = 0;
|
||||||
rc.top = bpmem.scissorTL.y + yoff - 342;
|
rc.top = bpmem.scissorTL.y + yoff - 342;
|
||||||
rc.top *= MValue;
|
rc.top *= MValueY;
|
||||||
if (rc.top < 0) rc.top = 0;
|
if (rc.top < 0) rc.top = 0;
|
||||||
|
|
||||||
rc.right = bpmem.scissorBR.x + xoff - 342 +1;
|
rc.right = bpmem.scissorBR.x + xoff - 342 +1;
|
||||||
rc.right *= MValue;
|
rc.right *= MValueX;
|
||||||
if (rc.right > 640 * MValue) rc.right = 640 * MValue;
|
if (rc.right > 640 * MValueX) rc.right = 640 * MValueX;
|
||||||
rc.bottom = bpmem.scissorBR.y + yoff - 342 +1;
|
rc.bottom = bpmem.scissorBR.y + yoff - 342 +1;
|
||||||
rc.bottom *= MValue;
|
rc.bottom *= MValueY;
|
||||||
if (rc.bottom > 480 * MValue) rc.bottom = 480 * MValue;
|
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);
|
//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.
|
//Need another rc here to get it to scale.
|
||||||
TRectangle multirc = {
|
TRectangle multirc = {
|
||||||
(int)(bpmem.copyTexSrcXY.x * MValue),
|
(int)(bpmem.copyTexSrcXY.x * MValueX),
|
||||||
(int)(bpmem.copyTexSrcXY.y * MValue),
|
(int)(bpmem.copyTexSrcXY.y * MValueY),
|
||||||
(int)((bpmem.copyTexSrcXY.x * MValue + bpmem.copyTexSrcWH.x * MValue)),
|
(int)((bpmem.copyTexSrcXY.x * MValueX + bpmem.copyTexSrcWH.x * MValueX)),
|
||||||
(int)((bpmem.copyTexSrcXY.y * MValue + bpmem.copyTexSrcWH.y * MValue))
|
(int)((bpmem.copyTexSrcXY.y * MValueY + bpmem.copyTexSrcWH.y * MValueY))
|
||||||
};
|
};
|
||||||
|
|
||||||
UPE_Copy PE_copy;
|
UPE_Copy PE_copy;
|
||||||
|
|
|
@ -32,6 +32,7 @@
|
||||||
|
|
||||||
// screen offset
|
// screen offset
|
||||||
int nBackbufferWidth, nBackbufferHeight;
|
int nBackbufferWidth, nBackbufferHeight;
|
||||||
|
int nXoff, nYoff;
|
||||||
|
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
GLWindow GLWin;
|
GLWindow GLWin;
|
||||||
|
@ -148,8 +149,20 @@ bool OpenGL_Create(SVideoInitialize &_VideoInitialize, int _iwidth, int _iheight
|
||||||
float FactorH = 480.0f / (float)nBackbufferHeight;
|
float FactorH = 480.0f / (float)nBackbufferHeight;
|
||||||
|
|
||||||
float Max = (FactorW < FactorH) ? FactorH : FactorW;
|
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.pPeekMessages = &Callback_PeekMessages;
|
||||||
g_VideoInitialize.pUpdateFPSDisplay = &UpdateFPSDisplay;
|
g_VideoInitialize.pUpdateFPSDisplay = &UpdateFPSDisplay;
|
||||||
|
|
||||||
|
@ -485,12 +498,26 @@ void OpenGL_Update()
|
||||||
::MoveWindow(EmuWindow::GetWnd(), 0,0,width,height, FALSE);
|
::MoveWindow(EmuWindow::GetWnd(), 0,0,width,height, FALSE);
|
||||||
nBackbufferWidth = width;
|
nBackbufferWidth = width;
|
||||||
nBackbufferHeight = height;
|
nBackbufferHeight = height;
|
||||||
float FactorW = (float)640 / (float)nBackbufferWidth;
|
float FactorW = 640.0f / (float)nBackbufferWidth;
|
||||||
float FactorH = (float)480 / (float)nBackbufferHeight;
|
float FactorH = 480.0f / (float)nBackbufferHeight;
|
||||||
|
|
||||||
float Max = (FactorW < FactorH) ? FactorH : FactorW;
|
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 TmpAAx = (width / 640) - 1;
|
||||||
u32 TmpAAy = (height / 480) - 1;
|
u32 TmpAAy = (height / 480) - 1;
|
||||||
|
|
|
@ -51,6 +51,7 @@ extern GLWindow GLWin;
|
||||||
|
|
||||||
// yeah yeah, these should be hidden
|
// yeah yeah, these should be hidden
|
||||||
extern int nBackbufferWidth, nBackbufferHeight;
|
extern int nBackbufferWidth, nBackbufferHeight;
|
||||||
|
extern int nXoff, nYoff;
|
||||||
|
|
||||||
bool OpenGL_Create(SVideoInitialize &_VideoInitialize, int _width, int _height);
|
bool OpenGL_Create(SVideoInitialize &_VideoInitialize, int _width, int _height);
|
||||||
bool OpenGL_MakeCurrent();
|
bool OpenGL_MakeCurrent();
|
||||||
|
|
|
@ -29,7 +29,7 @@
|
||||||
|
|
||||||
#include "IniFile.h"
|
#include "IniFile.h"
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
float MValue;
|
float MValueX, MValueY; // Since it can Stretch to fit Window, we need two different multiplication values//
|
||||||
int frameCount;
|
int frameCount;
|
||||||
|
|
||||||
Config g_Config;
|
Config g_Config;
|
||||||
|
@ -82,6 +82,8 @@ void Config::Load()
|
||||||
|
|
||||||
iniFile.Get("Enhancements", "ForceFiltering", &bForceFiltering, 0);
|
iniFile.Get("Enhancements", "ForceFiltering", &bForceFiltering, 0);
|
||||||
iniFile.Get("Enhancements", "ForceMaxAniso", &bForceMaxAniso, 0);
|
iniFile.Get("Enhancements", "ForceMaxAniso", &bForceMaxAniso, 0);
|
||||||
|
iniFile.Get("Enhancements", "StretchToFit", &bStretchToFit, false);
|
||||||
|
iniFile.Get("Enhancements", "ShowFPS", &bShowFPS, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Config::Save()
|
void Config::Save()
|
||||||
|
@ -107,6 +109,8 @@ void Config::Save()
|
||||||
|
|
||||||
iniFile.Set("Enhancements", "ForceFiltering", bForceFiltering);
|
iniFile.Set("Enhancements", "ForceFiltering", bForceFiltering);
|
||||||
iniFile.Set("Enhancements", "ForceMaxAniso", bForceMaxAniso);
|
iniFile.Set("Enhancements", "ForceMaxAniso", bForceMaxAniso);
|
||||||
|
iniFile.Set("Enhancements", "StretchToFit", bStretchToFit);
|
||||||
|
iniFile.Set("Enhancements", "ShowFPS", bShowFPS);
|
||||||
iniFile.Save("gfx_opengl.ini");
|
iniFile.Save("gfx_opengl.ini");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -85,7 +85,7 @@ struct RECT
|
||||||
#define GL_TEXTURE_STENCIL_SIZE_EXT 0x88F1
|
#define GL_TEXTURE_STENCIL_SIZE_EXT 0x88F1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
extern float MValue;
|
extern float MValueX, MValueY;
|
||||||
|
|
||||||
#define ERROR_LOG __Log
|
#define ERROR_LOG __Log
|
||||||
|
|
||||||
|
@ -137,6 +137,8 @@ struct Config
|
||||||
|
|
||||||
bool bForceFiltering;
|
bool bForceFiltering;
|
||||||
bool bForceMaxAniso;
|
bool bForceMaxAniso;
|
||||||
|
bool bStretchToFit;
|
||||||
|
bool bShowFPS;
|
||||||
|
|
||||||
bool bTexFmtOverlayEnable;
|
bool bTexFmtOverlayEnable;
|
||||||
bool bTexFmtOverlayCenter;
|
bool bTexFmtOverlayCenter;
|
||||||
|
|
|
@ -641,7 +641,6 @@ u32 Renderer::GetZBufferTarget()
|
||||||
{
|
{
|
||||||
return nZBufferRender > 0 ? s_ZBufferTarget : 0;
|
return nZBufferRender > 0 ? s_ZBufferTarget : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Renderer::Swap(const TRectangle& rc)
|
void Renderer::Swap(const TRectangle& rc)
|
||||||
{
|
{
|
||||||
OpenGL_Update(); // just updates the render window position and the backbuffer size
|
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
|
// render to the real buffer now
|
||||||
glBindFramebufferEXT( GL_FRAMEBUFFER_EXT, 0 ); // switch to the backbuffer
|
glBindFramebufferEXT( GL_FRAMEBUFFER_EXT, 0 ); // switch to the backbuffer
|
||||||
glViewport(0, 0, nBackbufferWidth, nBackbufferHeight);
|
glViewport(nXoff, nYoff, nBackbufferWidth, nBackbufferHeight);
|
||||||
|
|
||||||
ResetGLState();
|
ResetGLState();
|
||||||
|
|
||||||
|
@ -674,23 +673,22 @@ void Renderer::Swap(const TRectangle& rc)
|
||||||
glBindTexture(GL_TEXTURE_RECTANGLE_NV, 0);
|
glBindTexture(GL_TEXTURE_RECTANGLE_NV, 0);
|
||||||
TextureMngr::DisableStage(0);
|
TextureMngr::DisableStage(0);
|
||||||
|
|
||||||
// static int fpscount = 0;
|
static int fpscount;
|
||||||
// static float s_fps = 0;
|
static int s_fps;
|
||||||
// static u32 lasttime = timeGetTime();
|
static unsigned long lasttime;
|
||||||
//
|
++fpscount;
|
||||||
// if( ++fpscount >= 16 ) {
|
if( timeGetTime() - lasttime > 1000 )
|
||||||
// s_fps = 16*1000.0f/(float)(timeGetTime() - lasttime);
|
{
|
||||||
// lasttime = timeGetTime();
|
lasttime = timeGetTime();
|
||||||
// fpscount = 0;
|
s_fps = fpscount;
|
||||||
// }
|
fpscount = 0;
|
||||||
//
|
}
|
||||||
// char strfps[25];
|
|
||||||
// sprintf(strfps, "fps: %2.1f\n", s_fps);
|
|
||||||
// Renderer::RenderText(strfps, 20, 20, 0xFF00FFFF);
|
|
||||||
|
|
||||||
if (g_Config.bOverlayStats) {
|
if (g_Config.bOverlayStats) {
|
||||||
char st[2048];
|
char st[2048];
|
||||||
char *p = st;
|
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 created: %i\n",stats.numTexturesCreated);
|
||||||
p+=sprintf(p,"Num textures alive: %i\n",stats.numTexturesAlive);
|
p+=sprintf(p,"Num textures alive: %i\n",stats.numTexturesAlive);
|
||||||
p+=sprintf(p,"Num pshaders created: %i\n",stats.numPixelShadersCreated);
|
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);
|
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();
|
Renderer::ProcessMessages();
|
||||||
|
|
||||||
|
|
|
@ -530,10 +530,10 @@ void TextureMngr::CopyRenderTargetToTexture(u32 address, bool bFromZBuffer, bool
|
||||||
GL_REPORT_ERRORD();
|
GL_REPORT_ERRORD();
|
||||||
|
|
||||||
glBegin(GL_QUADS);
|
glBegin(GL_QUADS);
|
||||||
glTexCoord2f((float)source->left * 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 * MValue, Renderer::GetTargetHeight()-(float)source->top * MValue); glVertex2f(-1,-1);
|
glTexCoord2f((float)source->left * MValueX, Renderer::GetTargetHeight()-(float)source->top * MValueY); glVertex2f(-1,-1);
|
||||||
glTexCoord2f((float)source->right * MValue, Renderer::GetTargetHeight()-(float)source->top * MValue); glVertex2f(1,-1);
|
glTexCoord2f((float)source->right * MValueX, Renderer::GetTargetHeight()-(float)source->top * MValueY); glVertex2f(1,-1);
|
||||||
glTexCoord2f((float)source->right * MValue, Renderer::GetTargetHeight()-(float)source->bottom * MValue); glVertex2f(1,1);
|
glTexCoord2f((float)source->right * MValueX, Renderer::GetTargetHeight()-(float)source->bottom * MValueY); glVertex2f(1,1);
|
||||||
glEnd();
|
glEnd();
|
||||||
|
|
||||||
GL_REPORT_ERRORD();
|
GL_REPORT_ERRORD();
|
||||||
|
|
|
@ -322,7 +322,7 @@ void VertexShaderMngr::SetConstants(VERTEXSHADER& vs)
|
||||||
// [5] = 16777215 * farz
|
// [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,
|
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);
|
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);
|
glDepthRange((rawViewport[5]-rawViewport[2])/16777215.0f, rawViewport[5]/16777215.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue