Skip rendering obscured polygons - OpenGl

I am told there is a way to skip the rendering of obscured polygons in opengl. I am told it has something to do with stencils.

I would like to be able to render the polygons that are visible in wireframe, this is done through the use of glPolygonMode(GL_FRONT, GL_LINES), the problem being that you can see through anything rendered. As I am using a height map, I used glCullFace(GL_BACK), this hides the back orientation polygons, and so hides the other side of mountains. The problem with this method is that it still rendered "floor" polygons in wireframe, as they were still in "front" orientation to the viewer.

Is my idea do-able? I have attempted rendering in solid, but the problem is that I am using a raspberry pi 3, so it runs rather slowly when the polygons take up a large proportion of the perspective. This is also why I would prefer not to go down the route of rendering all back polygons in solid fill with background colour, because although this should have the same effect, it would still render and would slow the pi down.

There are no shaders or lighting to worry about, no impressive graphics are required, just some way of hiding the polygons not in direct line of sight.

Amy help is appreciated
Last edited on
You may use the z-buffer with a two-pass algorithm.
The first time you make the triangles solid, but do not write on the color buffer (glColorMask()), only on z-buffer. Then the second time you render in wireframe.


> I would like to be able to render the polygons that are visible in wireframe
> the problem being that you can see through anything rendered
that's the idea of wireframe. ¿why do you want wireframe then?

> As I am using a height map, I used glCullFace(GL_BACK)
unrelated. glCullFace() will simply kill polygons that may never be seen, as they don't face the eye. It is not a consequence of using a height map.

> and so hides the other side of mountains.
¿mountains? (my mistake, sorry)

> but the problem is that I am using a raspberry pi 3, so it runs rather slowly
making the processor speed increase from 900 MHz on the Pi 2 to up to 1.2GHz on the Pi 3.
you know, that seems to be quite fast, comparable to a Pentium III. It seems weird that you have so awful performance, given that you don't even have lighting computation.
Last edited on
Topic archived. No new replies allowed.