Use correct height for y correction in set/getScissor (bug #234)

This commit is contained in:
Bart van Strien
2011-06-08 23:17:32 +02:00
parent efb8efb45e
commit 43a6357b54
4 changed files with 24 additions and 2 deletions
@@ -372,6 +372,16 @@ namespace opengl
strategy->deleteFBO(fbo, depthbuffer, img); strategy->deleteFBO(fbo, depthbuffer, img);
} }
int Framebuffer::getWidth()
{
return width;
}
int Framebuffer::getHeight()
{
return height;
}
} // opengl } // opengl
} // graphics } // graphics
} // love } // love
@@ -41,6 +41,9 @@ namespace opengl
void setWrap(const Image::Wrap &w); void setWrap(const Image::Wrap &w);
Image::Wrap getWrap() const; Image::Wrap getWrap() const;
int getWidth();
int getHeight();
bool loadVolatile(); bool loadVolatile();
void unloadVolatile(); void unloadVolatile();
+9 -2
View File
@@ -365,6 +365,13 @@ namespace opengl
return currentMode.height; return currentMode.height;
} }
int Graphics::getRenderHeight()
{
if (Framebuffer::current)
return Framebuffer::current->getHeight();
return currentMode.height;
}
bool Graphics::isCreated() bool Graphics::isCreated()
{ {
return (currentMode.width > 0) || (currentMode.height > 0); return (currentMode.width > 0) || (currentMode.height > 0);
@@ -409,7 +416,7 @@ namespace opengl
void Graphics::setScissor(int x, int y, int width, int height) void Graphics::setScissor(int x, int y, int width, int height)
{ {
glEnable(GL_SCISSOR_TEST); glEnable(GL_SCISSOR_TEST);
glScissor(x, getHeight() - (y + height), width, height); // Compensates for the fact that our y-coordinate is reverse of OpenGLs. glScissor(x, getRenderHeight() - (y + height), width, height); // Compensates for the fact that our y-coordinate is reverse of OpenGLs.
} }
void Graphics::setScissor() void Graphics::setScissor()
@@ -426,7 +433,7 @@ namespace opengl
glGetIntegerv(GL_SCISSOR_BOX, scissor); glGetIntegerv(GL_SCISSOR_BOX, scissor);
lua_pushnumber(L, scissor[0]); lua_pushnumber(L, scissor[0]);
lua_pushnumber(L, getHeight() - (scissor[1] + scissor[3])); // Compensates for the fact that our y-coordinate is reverse of OpenGLs. lua_pushnumber(L, getRenderHeight() - (scissor[1] + scissor[3])); // Compensates for the fact that our y-coordinate is reverse of OpenGLs.
lua_pushnumber(L, scissor[2]); lua_pushnumber(L, scissor[2]);
lua_pushnumber(L, scissor[3]); lua_pushnumber(L, scissor[3]);
+2
View File
@@ -118,6 +118,8 @@ namespace opengl
GLint matrixLimit; GLint matrixLimit;
GLint userMatrices; GLint userMatrices;
int getRenderHeight();
public: public:
Graphics(); Graphics();