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 xoff = bpmem.scissorOffset.x*2-342;
int yoff = bpmem.scissorOffset.y*2-342; int yoff = bpmem.scissorOffset.y*2-342;
//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;
if (rc.left<0) rc.left=0; rc.left *= MValue;
rc.top=bpmem.scissorTL.y + yoff - 342; if (rc.left < 0) rc.left = 0;
if (rc.top<0) rc.top=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; rc.right = bpmem.scissorBR.x + xoff - 342 +1;
if (rc.right>640) rc.right=640; rc.right *= MValue;
rc.bottom=bpmem.scissorBR.y + yoff - 342 +1; if (rc.right > 640 * MValue) rc.right = 640 * MValue;
if (rc.bottom>480) rc.bottom=480; 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 ) { if( rc.right>=rc.left && rc.bottom>=rc.top ) {
glScissor(rc.left, Renderer::GetTargetHeight()-(rc.bottom), (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 // screen offset
int nBackbufferWidth, nBackbufferHeight; int nBackbufferWidth, nBackbufferHeight;
u32 s_nTargetWidth = 0, s_nTargetHeight = 0;
u32 g_AAx = 0, g_AAy = 0;
#ifndef _WIN32 #ifndef _WIN32
GLWindow GLWin; GLWindow GLWin;
@ -146,9 +144,11 @@ bool OpenGL_Create(SVideoInitialize &_VideoInitialize, int _iwidth, int _iheight
nBackbufferWidth = _twidth; nBackbufferWidth = _twidth;
nBackbufferHeight = _theight; nBackbufferHeight = _theight;
// change later float FactorW = (float)640 / (float)nBackbufferWidth;
s_nTargetWidth = 640 << g_AAx; float FactorH = (float)480 / (float)nBackbufferHeight;
s_nTargetHeight = 480 << g_AAy;
float Max = (FactorW < FactorH) ? FactorH : FactorW;
MValue = 1 / Max;
g_VideoInitialize.pPeekMessages = &Callback_PeekMessages; g_VideoInitialize.pPeekMessages = &Callback_PeekMessages;
g_VideoInitialize.pUpdateFPSDisplay = &UpdateFPSDisplay; g_VideoInitialize.pUpdateFPSDisplay = &UpdateFPSDisplay;

View File

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

View File

@ -97,7 +97,7 @@ struct RECT
#define GL_DEPTH24_STENCIL8_EXT 0x88F0 #define GL_DEPTH24_STENCIL8_EXT 0x88F0
#define GL_TEXTURE_STENCIL_SIZE_EXT 0x88F1 #define GL_TEXTURE_STENCIL_SIZE_EXT 0x88F1
#endif #endif
extern float MValue;
// several macros // several macros
// PLEASE DO NOT USE THE FOLLOWING SAFE* // PLEASE DO NOT USE THE FOLLOWING SAFE*
// They only encourage sloppy coding, and hide bugs. // 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 //TODO: Return correct Values
int Renderer::GetTargetWidth() int Renderer::GetTargetWidth()
{ {
return 640; //return 640;
//return nBackbufferWidth; return nBackbufferWidth;
} }
int Renderer::GetTargetHeight() int Renderer::GetTargetHeight()
{ {
return 480; //return 480;
//return nBackbufferHeight; return nBackbufferHeight;
} }
bool Renderer::CanBlendLogicOp() bool Renderer::CanBlendLogicOp()
@ -663,21 +663,11 @@ void Renderer::Swap(const TRectangle& rc)
for(int i = 1; i < 8; ++i) TextureMngr::DisableStage(i); for(int i = 1; i < 8; ++i) TextureMngr::DisableStage(i);
GL_REPORT_ERRORD(); 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); glBegin(GL_QUADS);
glTexCoord2f(0, 0); glVertex2f(-FactorW,-FactorH); glTexCoord2f(0, 0); glVertex2f(-1,-1);
glTexCoord2f(0, (float)GetTargetHeight()); glVertex2f(-FactorW,FactorH); glTexCoord2f(0, (float)GetTargetHeight()); glVertex2f(-1,1);
glTexCoord2f((float)GetTargetWidth(), (float)GetTargetHeight()); glVertex2f(FactorW,FactorH); glTexCoord2f((float)GetTargetWidth(), (float)GetTargetHeight()); glVertex2f(1,1);
glTexCoord2f((float)GetTargetWidth(), 0); glVertex2f(FactorW,-FactorH); glTexCoord2f((float)GetTargetWidth(), 0); glVertex2f(1,-1);
glEnd(); glEnd();
glBindTexture(GL_TEXTURE_RECTANGLE_NV, 0); glBindTexture(GL_TEXTURE_RECTANGLE_NV, 0);

View File

@ -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),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); 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 ) if( *(u32*)(_Viewport + i) == 0x7f800000 )
return; // invalid number return; // invalid number
} }
memcpy(rawViewport, _Viewport, sizeof(rawViewport)); memcpy(rawViewport, _Viewport, sizeof(rawViewport));
bViewportChanged = true; bViewportChanged = true;
} }