开发者

OpenGL ES2 GLubyte colors in vertex array not working

Apple suggests using the GLubyte data type for col开发者_如何学JAVAor data on iOS, so I am trying to get this to work. The result I get is that all color components <255 are completely black, and only components of colors set to 255 really are that color.

What I am doing: -Save the color of a single object in my own Color class in GLubytes (range 0-255) -Pass the colors to the shader in a vertex attribute array with type GLubyte (still range 0-255) -In the fragment shader, use the color directly or divide components by 255, both do not work.

EDIT: this does work, the problem was somewhere else in my code.


Where does Apple recommend using GLubyte for vertex attributes? I think you have misinterpreted that hint. What you actually want to do is store those values in a 256x1 grayscale (GL_LUMINANCE) texture and pass it as a uniform to the shader. This would be indeed faster than using arrays.


This does just work fine, the problem was somewhere else in my code.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜