Back face texture not working


#1

Hello, I am trying to render a texture on the back face of a square. I am doing as follow:

in the setup method, I call

glEnable(GL_CULL_FACE);

When drawing my objects, one that needs to be drawn front face, and the other back face, I am applying the texture like this:

//back face textured mesh
tex.bind();
glFrontFace(GL_CW);
glCullFace(GL_BACK);
backFaceObject.draw();
tex.unbind();

// front face textured mesh
 tex.bind();
glCullFace(GL_FRONT);
frontFaceObject.draw();
tex.unbind();

The front face object is drawn as expected, as it was drawn before, without the gl calls. But I can’t see the backFaceObject.

I have also tried to use GL_FRONT_AND_BACK instead GL_BACK but without luck. Any idea about what I am doing wrong?


#2

i think you are doing it in the opposite order, glCullFace(GL_FRONT) means that front faces are going to get culled, not drawn so you should be doing, cull front draw back, cull back draw front not the other way around


#3

You are right, I do not even need to specify the winding. But I do have to remember to set it back once the back face has been drawn. Thanks :wink: