With Rectangle being the part of the B buffer I want to put A in. I already have a function that takes a texture and stretch it to display it on the whole framebuffer.
So I thought about using the glViewport so that I will write only texture from A into the specific part of framebuffer B I am interested in. But I was concerned about that fact that Viewport is related to the exact pixels in window-space. But my framebuffer B is not meant to be displayed, only to be given to another render call, soooo what’s the role of the viewport for that kind of problem ? And how can I use it to my advantage so that I can render to a specific part of my texture ?
I assume you want to have multiple view port some thing like this :
-use one FBO GLuint FBO
-use multiple textutre 2D (let’s 3 texture each one is going to render diffrent view ports
-change view port for example (glViewport(0,0,128,128) than an other window below it glViewport(128,128,256,256)… and so on)
-sweep betewen this texture (attach and disattach to Framebuffer when rendering)
If you want to copy A to B, try glBlitFramebuffer.
If you want to render A’s content directly to B in the first place (and never create A), use glViewport. The viewport doesn’t clip (#10), so you probably also need glScissor.
Geometry is clipped to the NDC unit cube before rasterisation, and the bounds of the NDC unit cube are mapped to the viewport. Thus, if you take the vertices which form the clipped geometry and project them to window (i.e. framebuffer) coordinates, the resulting 2D points will always lie within the viewport.
However, that doesn’t mean that nothing will be rendered outside of the viewport. In particular, points and lines have a width, meaning that rasterisation may affect pixels outside of the viewport. If you want to constrain rasterisation to a specific rectangle, you need to use scissoring (glEnable(GL_SCISSOR_TEST) and glScissor()).