OpenGL: How to clear only a part of the screen?

前端 未结 3 1345
一向
一向 2021-01-17 10:54

Is it possible to not clear entire screen when using glClear() function? I need to clear only a part of the screen to save some rendering time, otherwise i would have to red

相关标签:
3条回答
  • 2021-01-17 11:01

    To clear only a specific rectangular region, enable ScissorTest and call Clear. Once enabled, only pixels within the scissor box will be affected by drawing commands, so disable ScissorTest when you need to modify the outside area again.

    OpenTK example:

    GL.Enable (EnableCap.ScissorTest);
    GL.Scissor (ViewportX, ViewportY, ViewportWidth, ViewportHeight);
    GL.Clear (ClearBufferMask.ColorBufferBit);
    GL.Disable (EnableCap.ScissorTest);
    
    0 讨论(0)
  • 2021-01-17 11:11

    Draw a giant quad :) Apply this to just half your screen.

    http://www.opengl.org/resources/faq/technical/transformations.htm#tran0090

    0 讨论(0)
  • 2021-01-17 11:21

    You might want to look into glScissor. From the documentation:

    While scissor test is enabled, only pixels that lie within the scissor box can be modified by drawing commands.

    0 讨论(0)
提交回复
热议问题