Opengl Es 2 Color Buffer Not Working
I've recently started using OpenGL ES 2 for android. I followed their examples for drawing shapes, and I went further and created a cube. I'm now trying to achieve a nice color eff
Solution 1:
You're not doing anything with the color data in your shader programs, so you're uploading the data and not doing anything with it.
You need to add handling code for the new vertex attribute to your shaders; something like this:
privatefinalStringvertexShaderCode="uniform mat4 uMVPMatrix;" +
"attribute vec4 vPosition;" +
"attribute mediump vec4 vColor;" +
"varying mediump vec4 vaColor;" +
"void main() {" +
" vaColor = vColor;" +
" gl_Position = uMVPMatrix * vPosition;" +
"}";
privatefinalStringfragmentShaderCode="precision mediump float;" +
"varying mediump vec4 vaColor;" +
"void main() {" +
" gl_FragColor = vaColor;" +
"}";
Post a Comment for "Opengl Es 2 Color Buffer Not Working"