Reputation: 1332
How do i temporarily disable textures on opengl es 2.x for ios in the render function? I am implementing color selection.
I am not using glkit. I am using shaders, so glDisable(GL_TEXTURE_2D)
doesn't work, nor did glBindTexture(GL_TEXTURE_2D,0)
Upvotes: 0
Views: 1093
Reputation: 3577
Depends on what you want to achieve. If you disable a texture what do you expect to have in your rendering?
If your shader calculates the color of a fragment based on a Texture sample, if you do not bind any texture, what should it use in place of the texture? A color?
I see 2 options:
A - use 2 shaders, one supporting textures, one using fixed colors (or vertex colors if you load the attribute)
B - use a single shader and pilot the rendering (texture or colors) using uniforms.
The option B offers much more performance.
Edit to first question on how to do it:
if (Texture == 0) {
gl_FragColor = vec4(1.0,0.0,0.0,0.0); //red color
} else{
gl_FragColor = texture2D(Texture, TexCoordOut);
}
Upvotes: 3