OpenGL渐变填充iPhone看起来条纹 [英] OpenGL gradient fill on iPhone looks striped

查看:307
本文介绍了OpenGL渐变填充iPhone看起来条纹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我使用OpenGL绘制渐变填充时,输出看起来是条纹的,即它只用大约四分之一的颜色渲染。





我在运行iOS4的iPhone 3G上开发。



任何想法?



彼得



==========





==========

  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);


解决方案


我需要为CAEAGLLayer属性指定kEAGLColorFormatRGBA8。


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);

解决方案

Got it.

I needed to specify kEAGLColorFormatRGBA8 for the CAEAGLLayer properties.

这篇关于OpenGL渐变填充iPhone看起来条纹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆