summaryrefslogtreecommitdiff
path: root/Source
diff options
context:
space:
mode:
authornakeee <nakeee@gmail.com>2008-12-19 13:56:53 +0000
committernakeee <nakeee@gmail.com>2008-12-19 13:56:53 +0000
commitb5dcdcf779a7cc3db9d10f9794bbedbd7a4f7045 (patch)
treec41df723ca7dc1d0a607f7c717f41e95695896a8 /Source
parentdb15121b5d8de83d974fca46017915c6ccac9ba4 (diff)
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
Diffstat (limited to 'Source')
-rw-r--r--Source/Plugins/Plugin_VideoOGL/Src/GLUtil.cpp22
-rw-r--r--Source/Plugins/Plugin_VideoOGL/Src/GLUtil.h9
-rw-r--r--Source/Plugins/Plugin_VideoOGL/Src/GLWindow.h14
-rw-r--r--Source/Plugins/Plugin_VideoOGL/Src/Render.cpp33
-rw-r--r--Source/Plugins/Plugin_VideoOGL/Src/XFB.cpp6
-rw-r--r--Source/Plugins/Plugin_VideoOGL/Src/nGLUtil.cpp21
-rw-r--r--Source/Plugins/Plugin_VideoOGL/Src/nGLUtil.h9
7 files changed, 90 insertions, 24 deletions
diff --git a/Source/Plugins/Plugin_VideoOGL/Src/GLUtil.cpp b/Source/Plugins/Plugin_VideoOGL/Src/GLUtil.cpp
index 47e400188f..66ba7f041b 100644
--- a/Source/Plugins/Plugin_VideoOGL/Src/GLUtil.cpp
+++ b/Source/Plugins/Plugin_VideoOGL/Src/GLUtil.cpp
@@ -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
diff --git a/Source/Plugins/Plugin_VideoOGL/Src/GLUtil.h b/Source/Plugins/Plugin_VideoOGL/Src/GLUtil.h
index 930ad8b45c..d4b6a7bf54 100644
--- a/Source/Plugins/Plugin_VideoOGL/Src/GLUtil.h
+++ b/Source/Plugins/Plugin_VideoOGL/Src/GLUtil.h
@@ -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();
diff --git a/Source/Plugins/Plugin_VideoOGL/Src/GLWindow.h b/Source/Plugins/Plugin_VideoOGL/Src/GLWindow.h
index f0d56cbf83..3942b36f3c 100644
--- a/Source/Plugins/Plugin_VideoOGL/Src/GLWindow.h
+++ b/Source/Plugins/Plugin_VideoOGL/Src/GLWindow.h
@@ -17,6 +17,7 @@
class GLWindow {
private:
u32 width, height;
+ int yOffset, xOffset;
public:
/* int screen;
int x, y;
@@ -30,11 +31,18 @@ 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) {};
// setResolution
diff --git a/Source/Plugins/Plugin_VideoOGL/Src/Render.cpp b/Source/Plugins/Plugin_VideoOGL/Src/Render.cpp
index 4a69fc9370..ba7bb20318 100644
--- a/Source/Plugins/Plugin_VideoOGL/Src/Render.cpp
+++ b/Source/Plugins/Plugin_VideoOGL/Src/Render.cpp
@@ -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)
diff --git a/Source/Plugins/Plugin_VideoOGL/Src/XFB.cpp b/Source/Plugins/Plugin_VideoOGL/Src/XFB.cpp
index 6127b745e4..0075dda215 100644
--- a/Source/Plugins/Plugin_VideoOGL/Src/XFB.cpp
+++ b/Source/Plugins/Plugin_VideoOGL/Src/XFB.cpp
@@ -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;
@@ -228,4 +230,4 @@ void XFB_Draw(u8 *xfb_in_ram, u32 width, u32 height, s32 yOffset)
GL_REPORT_ERRORD();
}
-#endif \ No newline at end of file
+#endif
diff --git a/Source/Plugins/Plugin_VideoOGL/Src/nGLUtil.cpp b/Source/Plugins/Plugin_VideoOGL/Src/nGLUtil.cpp
index f40b419744..86fa66a90b 100644
--- a/Source/Plugins/Plugin_VideoOGL/Src/nGLUtil.cpp
+++ b/Source/Plugins/Plugin_VideoOGL/Src/nGLUtil.cpp
@@ -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();
}
diff --git a/Source/Plugins/Plugin_VideoOGL/Src/nGLUtil.h b/Source/Plugins/Plugin_VideoOGL/Src/nGLUtil.h
index ce15a4c0fe..a3578ba92c 100644
--- a/Source/Plugins/Plugin_VideoOGL/Src/nGLUtil.h
+++ b/Source/Plugins/Plugin_VideoOGL/Src/nGLUtil.h
@@ -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