Problem with glScissors

Started by
20 comments, last by mldaalder 18 years, 4 months ago
The problem is that your window coordinate system is top left, but OpenGL's window coordinate system is bottom left, so you have to translate between them (sorry, should have realised this earlier):
// translate from bottom left to top left coordinate system// this is just offset from top = available height - (offset from bottom + quad height)scissor[1] = viewport[3] - (scissor[1] + scissor[3]);GLint newLeft = (viewport[2] * x) + scissor[0];GLint newTop = (viewport[3] * y) + scissor[1];GLint newRight = newLeft + (viewport[2] * w);GLint newBottom = newTop + (viewport[3] * h);GLint oldLeft = scissor[0];GLint oldTop = scissor[1];GLint oldRight = scissor[0] + scissor[2];GLint oldBottom = scissor[1] + scissor[3];GLint clippedLeft = std::max(newLeft, oldLeft);GLint clippedTop = std::max(newTop, oldTop);GLint clippedRight = std::min(newRight, oldRight);GLint clippedBottom = std::min(newBottom, oldBottom);// translate from top left to bottom left coordinate systemglScissor(clippedLeft, viewport[3] - clippedBottom, clippedRight - clippedLeft, clippedBottom - clippedTop);

The previous code was setting up the scissored areas mirrored vertically about your window.

Enigma
Advertisement
Thank you, that did the trick.


I think I'll spend a couple of days figuring out why I didn't think of it...
Basic math...

This topic is closed to new replies.

Advertisement