Heillo! Is there a (easy) way to control the z-index of any given object? I understand that they are initially controlled by the order of which they are created, but is there a way to alter this, after they are already created? I tried using translate (0,0,-n), but that didn’t give any result other than the object itself getting smaller …
As a side question: is this part of the OPEN_GL syntax, and something one should, or must, know better in terms of getting the most out of openFrameworks? Are there books about OPEN_GL that would work well in terms of this?
you can translate along (0,0,z), for that to be effective you need to glEnable(GL_DEPTH_TEST); this will work for opaque objects, but unfortunately for semitransparent objects it will not. If you do need transparent objects, an easy solution is to store them all in an stl::vector or stl::list, and then sort the list on the z.
for opengl there is the big red book, which you can find online http://www.glprogramming.com/
also there is nehe.com and lighthouse3d.com
Thank you for your reply, memo I still couldn’t get it to work, though. The GL_DEPTH_TEST only had the effect, as far as I could see, to reverse the layer stack(?), without me doing anything with the z-depth or anything. And when I tried to alter the z-depth, nothing happened … You don’t have a working example of any sort on this, do you? I was trying different solutions with and without pushmatrix, but it didn’t change anything … Any clues? This is not such a big deal, though, more of a learning thing, experimenting, etc …
I know this is avery old post but this worked beautifully for me. Great trick! For anyone out there just include ofGraphics.h and then call glEnable(GL_DEPTH_TEST) in the setup();