开发者

how to set viewport color

开发者 https://www.devze.com 2023-04-05 01:56 出处:网络
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 l

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消