I’m new at openGl programming and i’m working on meshes.
My problem is : i want to get the coordinates of the points belonging to the faces that are front-facing the Camera.
I tried this approach (i don’t know if it’s right): I used the functions glEnable(GL_CULL_FACE); glCullFace(GL_BACK); to tell OpengGl that he has to render me only the face facing the camera. (i take a Cube with 6 faces to test). OpenGl renders me that face that is facing the camera but, i don’t know what to do after
I think it depends on what you want to do with the front faces. OpenGL is a rendering API (specification) not a geometry processing API, which means that it can figure out what are the front/back faces to perform culling (to avoid rasterizing unwanted faces), but is not really set up to provide that information back to the caller. Now, it’s probably possible to encode the information you are after in the output of OpenGL (my first idea would probably be using a geometry shader and transform feedback) and thus (ab-)use the rendering API for computation, but that is not really what I’d consider a beginner level task.
You may be better off determining the front facing faces on the CPU yourself. The algorithm used by OpenGL is mentioned around page 449f of the spec (version 4.5) - implementing it exactly as stated there may be a bit annoying since that would require to clip primitives. A possibly simpler solution would be to compare the normal of a face (cross product of two non-collinear vectors in the face, e.g. two edges) with the view direction - but that does produce slightly different results from what OpenGL does.
If you’re using legacy OpenGL, you can use feedback mode to capture vertex data for rendered primitives. See glRenderMode() and glFeedbackBuffer() for more information.
The modern OpenGL equivalent is transform-feedback mode, but this captures the output from either the geometry shader (if present) or the vertex shader, so it will include both front-facing and back-facing primitives. However, you could perform back-face culling yourself, either in the geometry shader or on the returned data.