NickM13 NickM13 - 2 months ago 19
C++ Question

How to clip rendering to a given box

How to clip rendering to a given box/rectangle in OpenGL?

E.g. instead of rendering it unclipped/cropped like this

unclipped

I want to make it clipped like this

clipped

Answer

By using a combination of appropriately setting the viewport (glViewport), the scissor box (glScissor) and enable scissor testing (glEnable(GL_SCISSOR_TEST)).

Comments