OpenGL gradient fill on iPhone looks striped

让人想犯罪 __ 提交于 2019-12-22 10:16:14

问题


When I draw a gradient fill with OpenGL, the output looks striped, i.e. it's rendered with only about the a fourth of the possible colors.

In the render buffer all the colors appear but not in the actual output.

I'm developing on iPhone 3G running iOS4.

Any ideas?

Peter

==========

==========

GLint redBits, greenBits, blueBits;
glGetIntegerv (GL_RED_BITS, &redBits); // ==> 8
glGetIntegerv (GL_GREEN_BITS, &greenBits); // ==> 8
glGetIntegerv (GL_BLUE_BITS, &blueBits); // ==> 8

glDisable(GL_BLEND);
glDisable(GL_DITHER);
glDisable(GL_FOG);
glDisable(GL_LIGHTING);
glDisable(GL_TEXTURE_2D);
glShadeModel(GL_SMOOTH);

const GLfloat vertices[] = {
0, 0,
320, 0,
0, 480,
320, 480,
};

const GLubyte colors[] = {
255, 255, 255, 255,
255, 255, 255, 255,
200, 200, 200, 255,
200, 200, 200, 255,
};

glVertexPointer(2, GL_FLOAT, 0, vertices);
glEnableClientState(GL_VERTEX_ARRAY);
glColorPointer(4, GL_UNSIGNED_BYTE, 0, colors);
glEnableClientState(GL_COLOR_ARRAY);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);

回答1:


Got it.

I needed to specify kEAGLColorFormatRGBA8 for the CAEAGLLayer properties.



来源:https://stackoverflow.com/questions/3791351/opengl-gradient-fill-on-iphone-looks-striped

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!