OpenGL gradient fill on iPhone looks striped

When I draw a gradient fill using OpenGL, the result looks striped, that is, it displays only with the fourth possible color.

The rendering buffer displays all the colors, but not in the actual output.

I am developing an iPhone 3G running iOS4.

Any ideas?

Peter

===========

alt text

===========

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);
+3
source share
1 answer

Got it.

I needed to specify kEAGLColorFormatRGBA8 for the CAEAGLLayer properties.

+2
source

Source: https://habr.com/ru/post/1766486/


All Articles