i'm attempting color object in opengl es 2.0 android when call following returns -1.
int mcolorhandle = gles20.getattributelocation(mprogram,"icolor"); shader:
private static final string sfragmentshadercode = "precision mediump float;" + "uniform vec4 icolor;" + "void main() {" + " gl_fragcolor = icolor;" + "}"; method call in context:
mprogram = gles20.glcreateprogram(); gles20.glattachshader(mprogram, vertexshader); gles20.glattachshader(mprogram, fragshader); gles20.gllinkprogram(mprogram); int mcolorhandle = gles20.getattributelocation(mprogram,"icolor"); log.i(tag,"mcolorhandle: "+integer.tostring(mcolorhandle)); any idea causing this?
you've declared icolor uniform, you'll need call gles20.glgetuniformlocation(mprogram,"icolor") if you're using uniform variable (which say, 1 icolor value many different primitives).
if have buffer of icolor values, 1 each vertex, you'll need declare icolor "attrib vec4 icolor;" in shader. after that, call gles20.glgetattributelocation(mprogram,"icolor") should return valid location.
Comments
Post a Comment