Render to a portion of GLFW window?

Hi. I’m wondering if there’s a built-in way how to render objects just to a part of the screen. For example, the 0.1 of width and height are the border thicknesses, and lets say i just want to render the things i usually would in the full screen, but this time just from position (-0.9, 0.9) to (0.9, -0.9).

So is it possible to accomplish that by some built-in way, or do I have to modify the shaders?

With glScissor you can specify a rectangular area and with glEnable(GL_SCISSOR_TEST) you can activate scissor testing. When you render something and scissor testing is enabled then all fragments outside of the scissor area will be discarded. You can read about it here: https://www.opengl.org/sdk/docs/man2/xhtml/glScissor.xml

Aside from the scissor test, you may want to set the viewport. If you just set the scissor rectangle, everything will be drawn the same as for the full window but parts outside the scissor rectangle will be discarded. Setting the viewport will result in the same scene drawn within a smaller region of the window.

But changing the viewport alone isn’t sufficient, as the viewport only clips geometry, whereas the scissor rectangle clips rasterisation. Wide lines, points and anti-aliased polygon edges can all result in fragments being rendered outside of the viewport (as can bitmaps in the compatibility profile).

[QUOTE=GClements;1280233]Aside from the scissor test, you may want to set the viewport. If you just set the scissor rectangle, everything will be drawn the same as for the full window but parts outside the scissor rectangle will be discarded. Setting the viewport will result in the same scene drawn within a smaller region of the window.

But changing the viewport alone isn’t sufficient, as the viewport only clips geometry, whereas the scissor rectangle clips rasterisation. Wide lines, points and anti-aliased polygon edges can all result in fragments being rendered outside of the viewport (as can bitmaps in the compatibility profile).[/QUOTE]

thanks, i’ll try that.