GL Plugin Now has High res instead of stretching to the res. No AA yet and shadows are wrong, which causes Sunshine to trip and a few others to have shadows in the upper left corner

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@218 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
Sonicadvance1 2008-08-15 02:57:20 +00:00
parent 9edf51c64f
commit 980679d84d
6 changed files with 31 additions and 38 deletions

View File

@ -526,19 +526,23 @@ bool SetScissorRect()
{
int xoff = bpmem.scissorOffset.x*2-342;
int yoff = bpmem.scissorOffset.y*2-342;
//printf("xoff: %d yoff: %d\n", xoff, yoff);
RECT rc;
rc.left=bpmem.scissorTL.x + xoff - 342;
if (rc.left<0) rc.left=0;
rc.top=bpmem.scissorTL.y + yoff - 342;
if (rc.top<0) rc.top=0;
rc.left = bpmem.scissorTL.x + xoff - 342;
rc.left *= MValue;
if (rc.left < 0) rc.left = 0;
rc.top = bpmem.scissorTL.y + yoff - 342;
rc.top *= MValue;
if (rc.top < 0) rc.top = 0;
rc.right=bpmem.scissorBR.x + xoff - 342 +1;
if (rc.right>640) rc.right=640;
rc.bottom=bpmem.scissorBR.y + yoff - 342 +1;
if (rc.bottom>480) rc.bottom=480;
rc.right = bpmem.scissorBR.x + xoff - 342 +1;
rc.right *= MValue;
if (rc.right > 640 * MValue) rc.right = 640 * MValue;
rc.bottom = bpmem.scissorBR.y + yoff - 342 +1;
rc.bottom *= MValue;
if (rc.bottom > 480 * MValue) rc.bottom = 480 * MValue;
PRIM_LOG("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);
if( rc.right>=rc.left && rc.bottom>=rc.top ) {
glScissor(rc.left, Renderer::GetTargetHeight()-(rc.bottom), (rc.right-rc.left), (rc.bottom-rc.top));

View File

@ -32,8 +32,6 @@
// screen offset
int nBackbufferWidth, nBackbufferHeight;
u32 s_nTargetWidth = 0, s_nTargetHeight = 0;
u32 g_AAx = 0, g_AAy = 0;
#ifndef _WIN32
GLWindow GLWin;
@ -146,9 +144,11 @@ bool OpenGL_Create(SVideoInitialize &_VideoInitialize, int _iwidth, int _iheight
nBackbufferWidth = _twidth;
nBackbufferHeight = _theight;
// change later
s_nTargetWidth = 640 << g_AAx;
s_nTargetHeight = 480 << g_AAy;
float FactorW = (float)640 / (float)nBackbufferWidth;
float FactorH = (float)480 / (float)nBackbufferHeight;
float Max = (FactorW < FactorH) ? FactorH : FactorW;
MValue = 1 / Max;
g_VideoInitialize.pPeekMessages = &Callback_PeekMessages;
g_VideoInitialize.pUpdateFPSDisplay = &UpdateFPSDisplay;

View File

@ -22,7 +22,7 @@
#include "IniFile.h"
#include <assert.h>
float MValue;
int frameCount;
Config g_Config;

View File

@ -97,7 +97,7 @@ struct RECT
#define GL_DEPTH24_STENCIL8_EXT 0x88F0
#define GL_TEXTURE_STENCIL_SIZE_EXT 0x88F1
#endif
extern float MValue;
// several macros
// PLEASE DO NOT USE THE FOLLOWING SAFE*
// They only encourage sloppy coding, and hide bugs.

View File

@ -451,14 +451,14 @@ void Renderer::ReinitView(int nNewWidth, int nNewHeight)
//TODO: Return correct Values
int Renderer::GetTargetWidth()
{
return 640;
//return nBackbufferWidth;
//return 640;
return nBackbufferWidth;
}
int Renderer::GetTargetHeight()
{
return 480;
//return nBackbufferHeight;
//return 480;
return nBackbufferHeight;
}
bool Renderer::CanBlendLogicOp()
@ -663,21 +663,11 @@ void Renderer::Swap(const TRectangle& rc)
for(int i = 1; i < 8; ++i) TextureMngr::DisableStage(i);
GL_REPORT_ERRORD();
//TODO: Do Correctly in a bit
float FactorW = (float)640 / (float)nBackbufferWidth;
float FactorH = (float)480 / (float)nBackbufferHeight;
float Max = (FactorW < FactorH) ? FactorH : FactorW;
float Temp = 1 / Max;
FactorW *= Temp;
FactorH *= Temp;
glBegin(GL_QUADS);
glTexCoord2f(0, 0); glVertex2f(-FactorW,-FactorH);
glTexCoord2f(0, (float)GetTargetHeight()); glVertex2f(-FactorW,FactorH);
glTexCoord2f((float)GetTargetWidth(), (float)GetTargetHeight()); glVertex2f(FactorW,FactorH);
glTexCoord2f((float)GetTargetWidth(), 0); glVertex2f(FactorW,-FactorH);
glTexCoord2f(0, 0); glVertex2f(-1,-1);
glTexCoord2f(0, (float)GetTargetHeight()); glVertex2f(-1,1);
glTexCoord2f((float)GetTargetWidth(), (float)GetTargetHeight()); glVertex2f(1,1);
glTexCoord2f((float)GetTargetWidth(), 0); glVertex2f(1,-1);
glEnd();
glBindTexture(GL_TEXTURE_RECTANGLE_NV, 0);

View File

@ -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),Renderer::GetTargetHeight()-((int)(rawViewport[4]-rawViewport[1]-342)), abs((int)(2 * rawViewport[0])), abs((int)(2 * rawViewport[1])));
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);
glDepthRange((rawViewport[5]-rawViewport[2])/16777215.0f, rawViewport[5]/16777215.0f);
}
@ -482,7 +482,6 @@ void VertexShaderMngr::SetViewport(float* _Viewport)
if( *(u32*)(_Viewport + i) == 0x7f800000 )
return; // invalid number
}
memcpy(rawViewport, _Viewport, sizeof(rawViewport));
bViewportChanged = true;
}