how to set viewport color
I am working on opengl in android. Can some-one let me know how to set the background color for viewport(instead of the entire screen). I ha开发者_开发技巧ve 2 viewport in my application and I would like to set different color for the 2 viewports.
If glClear
affects the whole framebuffer and not only the current viewport (not sure about that), then you might also use the scissor test:
glScissor(x, y, w, h);
glEnable(GL_SCISSOR_TEST);
glClearColor(r, g, b, a);
glClear(GL_COLOR_BUFFER_BIT);
I'm pretty sure the scissor test influences glClear
.
For each viewport do:
glViewport(0, 0, width, height);
glClearColor(0.0, 0.0, 0.0, 1.0); // adapt this to the color you want
glClear(GL_COLOR_BUFFER_BIT);
Before drawing in it.
精彩评论