I know how to create a single texture, how to bind one texture with a shaders. But I don’t know how to bind two or more texture with the shaders, and for example how to show one texture over another texture.
I know how to modify the shaders for example in fragment shader I add the new code:
gl_FragColor = texture2D(a_texture, v_texCoord) + texture2D(a_texture2, v_texCoord2);
As I mentioned what I do not know is how to link the textures with the shaders or if I need to add other bytebuffer.
In this function I create my single texture:
public void CrearTextura(int[] texture) {
glGenTextures(1, texture, 0);
int id = mContext.getResources().getIdentifier("drawable/textureatlas", null, mContext.getPackageName());
Bitmap bmp0 = BitmapFactory.decodeResource(mContext.getResources(), id);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, texture[0]);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
texImage2D(GL_TEXTURE_2D, 0, bmp0, 0);
bmp0.recycle();
}
This is the code that I do not know how it works and how I should modify it.
private void Render(float[] m) {
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
int mPositionHandle = glGetAttribLocation(Shader.program_Image, vPosition);
glVertexAttribPointer(mPositionHandle, 3, GL_FLOAT, false, 0, vertexBuffer);
glEnableVertexAttribArray(mPositionHandle);
int mTexCoordLoc = glGetAttribLocation(Shader.program_Image, atexCoord);
glVertexAttribPointer(mTexCoordLoc, 2, GL_FLOAT, false, 0, uvBuffer);
glEnableVertexAttribArray(mTexCoordLoc);
int mtrxhandle = glGetUniformLocation(Shader.program_Image, matrix);
glUniformMatrix4fv(mtrxhandle, 1, false, m, 0);
int mSamplerLoc = glGetUniformLocation(Shader.program_Image, aTexture);
glUniform1i(mSamplerLoc, 0);
}