简体   繁体   中英

Rendering only a part of the window onto a framebuffer in opengl

I have been wanting to make edit menu using framebuffers in opengl(with c++). I then render some buttons in the menu space and then render the framebuffer. So while creating the framebuffer I just want it to be able to read and draw only a part of the screen (say coordinates between X1 and X2 and Y1 and Y2) which will then be converted into a texture attachment. The problem is I don't how to render a framebuffer which has a different size other than the window dimension. So I need to how to achieve this.

I think the code that needs to be changed is these 3 lines:

  1. glRenderBufferStorageMultiSample(GL_FRAMEBUFFER, 4, GL_RGB, SCREEN_WIDTH, SCREEN_HEIGHT);
  2. glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, SCREEN_WIDTH, SCREEN_HEIGHT, 0, GL_RGB, GL_UNSIGNED_BYTE, NULL);
  3. glBlitFrameBuffer(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0,0,SCREEN_WIDTH, SCREEN_HEIGHT, GL_COLOR_BUFFER_BIT, GL_NEAREST);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM