Thanks. I'm still a little confused about why there is a glActiveTexture and a glBindTexture. Seems like there ought to be one function for setting the current texture.
On Thursday, December 13, 2012 4:14:52 AM UTC-6, a1 wrote:
--GLES20.glUniform1i(mTexSamplerHandle, 0); I would think it should be:GLES20.glUniform1i(mTexSamplerHandle, texId); But that doesn't work.Can someone help me understand this line?Each GPU has multiple texture units (at least 8 as required by GL ES 2.0 specification), sampler2D (and other samplers type) are used to reference texture unit in shader languages, therefore you set it to texture unit id ordinal (unitId - GL_TEXTURE0), texture is bound on client side by selecting texture unit, with call to glActiveTexture and then with glBindTexture, which binds texture name to given sample type (eg. sampler2D with GL_TEXTURE_2D) on currently selected texture unit.So to pass texture to shader you need to execute following sequence:GLES20.glActiveTexture(GL_TEXTURE0); // activate texture unit GLES20.glBindTexture(GL_TEXTURE_2D, textureName); // bind texture to 2D sampler on texture unit 0 /* setup progam, states etc... */GLES20.glUniform1i(uniformLocationForSampler, 0); // pass texture unit ordinal to shader --Bart
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
No comments:
Post a Comment