More cleanup again I hope I didn't break anything, please check

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@1593 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
nakeee 2008-12-19 13:56:53 +00:00
parent db15121b5d
commit b5dcdcf779
8 changed files with 92 additions and 26 deletions

View File

@ -97,7 +97,7 @@ vars.AddVariables(
BoolVariable('nowx', 'Set For Building with no WX libs (WIP)', False),
BoolVariable('wxgl', 'Set For Building with WX GL libs (WIP)', False),
BoolVariable('sdlgl', 'Set For Building with SDL GL libs (WIP)', False),
BoolVariable('gltext', 'temp don\'t use (WIP)', False),
BoolVariable('gltest', 'temp don\'t use (WIP)', False),
EnumVariable('flavor', 'Choose a build flavor', 'release',
allowed_values = ('release', 'devel', 'debug', 'fastlog'),
ignorecase = 2
@ -234,7 +234,7 @@ if env['sdlgl']:
env['USE_WX'] = 0
env['GLTEST'] = 0
if env['gltext']:
if env['gltest']:
env['GLTEST'] = 1
conf.Define('GLTEST', env['GLTEST'])

View File

@ -67,6 +67,28 @@ void OpenGL_SwapBuffers()
#endif
}
int OpenGL_GetXoff() {
return nXoff;
}
int OpenGL_GetYoff() {
return nYoff;
}
u32 OpenGL_GetWidth() {
return nBackbufferWidth;
}
u32 OpenGL_GetHeight() {
return nBackbufferHeight;
}
void OpenGL_SetSize(u32 width, u32 height) {
nBackbufferWidth = width;
nBackbufferHeight = height;
}
void OpenGL_SetWindowText(const char *text)
{
#if USE_SDL

View File

@ -118,9 +118,14 @@ extern GLWindow GLWin;
#endif
int OpenGL_GetXoff();
int OpenGL_GetYoff();
u32 OpenGL_GetWidth();
u32 OpenGL_GetHeight();
void OpenGL_SetSize(u32 width, u32 height);
// yeah yeah, these should be hidden
extern int nBackbufferWidth, nBackbufferHeight;
extern int nXoff, nYoff;
//extern int nBackbufferWidth, nBackbufferHeight;
//extern int nXoff, nYoff;
bool OpenGL_Create(SVideoInitialize &_VideoInitialize, int _width, int _height);
bool OpenGL_MakeCurrent();

View File

@ -17,6 +17,7 @@
class GLWindow {
private:
u32 width, height;
int yOffset, xOffset;
public:
/* int screen;
int x, y;
@ -30,10 +31,17 @@ class GLWindow {
virtual void SetSize(u32 newWidth, u32 newHeight) {
width = newWidth;
height = newHeight;
};
}
void SetOffset(int x, int y) {
yOffset = y;
xOffset = x;
}
u32 GetWidth() {return width;}
u32 GetHeight() {return height;}
int GetYoff() {return yOffset;}
int GetXoff() {return xOffset;}
virtual bool valid() { return false; }
// bool GLwindow(SVideoInitialize &_VideoInitialize, int _iwidth, int _iheight) {};

View File

@ -172,6 +172,9 @@ bool Renderer::Create2()
_assert_( glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT) == GL_FRAMEBUFFER_COMPLETE_EXT );
glBindFramebufferEXT( GL_FRAMEBUFFER_EXT, s_uFramebuffer );
int nBackbufferWidth = (int)OpenGL_GetWidth();
int nBackbufferHeight = (int)OpenGL_GetHeight();
// create the framebuffer targets
glGenTextures(ARRAYSIZE(s_RenderTargets), (GLuint *)s_RenderTargets);
for(u32 i = 0; i < ARRAYSIZE(s_RenderTargets); ++i) {
@ -378,7 +381,7 @@ bool Renderer::Initialize()
glDisable(GL_STENCIL_TEST);
glEnable(GL_SCISSOR_TEST);
glScissor(0, 0, nBackbufferWidth, nBackbufferHeight);
glScissor(0, 0, (int)OpenGL_GetWidth(), (int)OpenGL_GetHeight());
glBlendColorEXT(0, 0, 0, 0.5f);
glClearDepth(1.0f);
@ -442,6 +445,8 @@ void Renderer::ProcessMessages()
void Renderer::RenderText(const char* pstr, int left, int top, u32 color)
{
int nBackbufferWidth = (int)OpenGL_GetWidth();
int nBackbufferHeight = (int)OpenGL_GetHeight();
glColor4f(
((color>>16) & 0xff)/255.0f,
((color>> 8) & 0xff)/255.0f,
@ -461,7 +466,8 @@ void Renderer::ReinitView(int nNewWidth, int nNewHeight)
int oldscreen = s_bFullscreen;
OpenGL_Shutdown();
int oldwidth = nBackbufferWidth, oldheight = nBackbufferHeight;
int oldwidth = (int)OpenGL_GetWidth,
oldheight = (int)OpenGL_GetHeight();
if (!OpenGL_Create(g_VideoInitialize, nNewWidth, nNewHeight)) {//nNewWidth&~7, nNewHeight&~7) ) {
ERROR_LOG("Failed to recreate, reverting to old settings\n");
if (!OpenGL_Create(g_VideoInitialize, oldwidth, oldheight)) {
@ -491,23 +497,17 @@ void Renderer::ReinitView(int nNewWidth, int nNewHeight)
#endif
}
nBackbufferWidth = nNewWidth > 16 ? nNewWidth : 16;
nBackbufferHeight = nNewHeight > 16 ? nNewHeight : 16;
OpenGL_SetSize(nNewWidth > 16 ? nNewWidth : 16,
nNewHeight > 16 ? nNewHeight : 16);
}
int Renderer::GetTargetWidth()
{
if(g_Config.bStretchToFit)
return 640;
else
return nBackbufferWidth; // return the actual window width
return (g_Config.bStretchToFit?640:(int)OpenGL_GetWidth());
}
int Renderer::GetTargetHeight()
{
if(g_Config.bStretchToFit)
return 480;
else
return nBackbufferHeight; // return the actual window height
return (g_Config.bStretchToFit?480:(int)OpenGL_GetHeight());
}
bool Renderer::CanBlendLogicOp()
@ -673,8 +673,8 @@ void Renderer::FlushZBufferAlphaToTarget()
if(g_Config.bStretchToFit)
{
//TODO: Do Correctly in a bit
float FactorW = (float)640 / (float)nBackbufferWidth;
float FactorH = (float)480 / (float)nBackbufferHeight;
float FactorW = (float)640 / (float)OpenGL_GetWidth();
float FactorH = (float)480 / (float)OpenGL_GetHeight();
float Max = (FactorW < FactorH) ? FactorH : FactorW;
float Temp = 1 / Max;
@ -793,7 +793,7 @@ void Renderer::Swap(const TRectangle& rc)
#else
glBindFramebufferEXT( GL_FRAMEBUFFER_EXT, 0 ); // switch to the backbuffer
#endif
glViewport(nXoff, nYoff, nBackbufferWidth, nBackbufferHeight);
glViewport(OpenGL_GetXoff(),OpenGL_GetYoff() , (int)OpenGL_GetWidth(), (int)OpenGL_GetHeight());
ResetGLState();
@ -951,6 +951,9 @@ void Renderer::SwapBuffers()
bool Renderer::SaveRenderTarget(const char* filename, int jpeg)
{
bool bflip = true;
int nBackbufferHeight = (int)OpenGL_GetHeight();
int nBackbufferWidth = (int)OpenGL_GetWidth();
std::vector<u32> data(nBackbufferWidth * nBackbufferHeight);
glReadPixels(0, 0, nBackbufferWidth, nBackbufferHeight, GL_BGRA, GL_UNSIGNED_BYTE, &data[0]);
if (glGetError() != GL_NO_ERROR)

View File

@ -56,6 +56,7 @@ void XFB_Shutdown()
void XFB_Write(u8 *xfb_in_ram, const TRectangle& sourceRc, u32 dstWd, u32 dstHt)
{
u32 nBackbufferHeight = OpenGL_GetHeight();
TRectangle renderSrcRc;
renderSrcRc.left = sourceRc.left;
renderSrcRc.right = sourceRc.right;
@ -79,7 +80,8 @@ void XFB_Draw(u8 *xfb_in_ram, u32 width, u32 height, s32 yOffset)
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, xfb_decoded_texture);
glViewport(nXoff, nYoff, nBackbufferWidth, nBackbufferHeight);
glViewport(OpenGL_GetXoff(), OpenGL_GetYoff(),
(int)OpenGL_GetWidth(), (int)OpenGL_GetHeight);
GL_REPORT_ERRORD();
float w = (float)width;

View File

@ -86,5 +86,24 @@ void OpenGL_Update()
// ----------------
void OpenGL_Shutdown()
{
glWin->Shutdown();
delete glWin;
}
u32 OpenGL_GetWidth() {
return glWin->GetHeight();
}
u32 OpenGL_GetHeight() {
return glWin->GetWidth();
void OpenGL_SetSize(u32 width, u32 height) {
glWin->SetSize(width, height);
}
int OpenGL_GetXoff() {
return glWin->GetXoff();
}
int OpenGL_GetYoff() {
return glWin->GetYoff();
}

View File

@ -40,11 +40,18 @@
#else
#define GL_REPORT_ERRORD()
#endif
// OLD interface todo remove
// TODO old interface removal
bool OpenGL_Create(SVideoInitialize &_VideoInitialize, int _width, int _height);
bool OpenGL_MakeCurrent();
void OpenGL_SwapBuffers();
void OpenGL_SetWindowText(const char *text);
void OpenGL_Shutdown();
void OpenGL_Update();
u32 OpenGL_GetWidth();
u32 OpenGL_GetHeight();
void OpenGL_SetSize(u32 width, u32 height);
int OpenGL_GetXoff();
int OpenGL_GetYoff();
#endif