Issue #234 resolved doesn't work properly inside a framebuffer

assassini avatarassassini created an issue

The y-coordinate of setScissor is always offset by the difference of the screen's height and the framebuffer's height.

I took a look at the source, and it looks like that you are flipping the y-coordinate in the Graphics::setScissor -method.

void Graphics::setScissor(int x, int y, int width, int height)
	glScissor(x, getHeight() - (y + height), width, height); // Compensates for the fact that our y-coordinate is reverse of OpenGLs.

Because binding to a framebuffer changes the viewport, this compensation will now return an incorrect value - causing the scissor to be offset.

This could be fixed by using the current viewport's height instead of the screen's height for the compensation.

I attached a love-file that draws two cubes. The first one is cut normally (doesn't work, the whole cube is invisible) and the second one is cut using a workaround (works fine, half of the cube is drawn).

Comments (10)

  1. Log in to comment
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.