#1 glClear is unnaffected by glScissor

closed-works-for-me
nobody
None
5
2005-05-10
2005-04-08
Anonymous
No

I am investigating the use of a split-screen in a game
I'm making. Unfortunately, I cannot clear the two
viewports separately. glClear appears to clear the
entire window, regardless of my glScissor settings.

From MSDN:

"The pixel-ownership test, the scissor test, dithering,
and the buffer writemasks affect the operation of
glClear. The scissor box bounds the cleared region."

Here is a snippet of code to demonstrate:

// Viewport 1 (top)
glViewport(0, 160, 240, 160);
glScissor(0, 160, 240, 160);
glClearColor(0.125, 0.25, 0.5, 1.0f);
glClear(GL_COLOR_BUFFER_BIT);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);

// Viewport 2 (bottom)
glViewport(0, 0, 240, 160);
glScissor(0, 0, 240, 160);
glClearColor(0.25, 0.125, 0.5, 1.0f);
glClear(GL_COLOR_BUFFER_BIT);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 3);

Only the bottom viewport is visible, because its clear
overwrites the pixels drawn by the top viewport.

Submitted by Peter Mackay
a_pointy_stick at ihatespam_yahoo

Discussion

    • labels: 648054 -->
    • milestone: 363224 -->
    • status: open --> closed-works-for-me
     
  • Logged In: YES
    user_id=618887

    You are not enabling the scissor test, i.e.

    glEnable(GL_SCISSOR_TEST);

    is missing.

    Hope that helps,
    HM