1
votes

I am developing an engine and the way I am handling boundaries the player is not supposed to reach is to have actual polygons as these boundaries. Now, I am wondering how to "render" the polgon but have it non visible.

My main question is: does OpenGL have a way to do this natively?

If not, what if I was to create a texture the way I usually load in the texture but have this texture simply be a single pixel. I could set the alpha channel to that specific pixel color and then use an alpha mask as I do normally with masked textures.

Any advice?

3
"Now, I am wondering how to "render" the polgon but have it non visible." How do you render something that's not visible; what's the point? Why does what you render affect where the player can and cannot go? It sounds like your engine is very confused; what is drawn should not affect behavior (where things can go). - Nicol Bolas
@Nico Bolas I use my BSP tree to calculate collision. Collision effects the entire polygon. Now that i think about it, I could still calculate collision without rendering the polygon. Correct? - Satchmo Brown
Exactly. Your BSP polygons don't have to match what you actually render. - Nicol Bolas
@Nico Bolas Thank you. I am going to go ahead and check out the tutorials in your profile. Looks like a good way to learn. - Satchmo Brown

3 Answers

2
votes

My main question is: does OpenGL have a way to do this natively?

No!

OpenGL only draws nicely colored triangles, lines and point to a framebuffer, and that's it.

  • It is not a scene graph.
  • It is not a geometry library.
  • It is not a collision detection framework.
0
votes

The question comments solved the problem you are having but there's a way to do what you actually asked so I'm putting it here anyway.

The question as I understood it is about rendering something in the depth buffer (and maybe stencil) but nowhere else. To achieve this, you simply have to use glColorMask like so before drawing the transparent polygons:

glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);

and restore the color mask afterwards.

0
votes

If you want to render the boundaries as transparent polygons - you could use the blending method as given here : http://www.opengl.org/resources/faq/technical/transparency.htm

Is that what you were looking for ?