Green

Hey people. Well although Im not new to C++, OpenGL I only started about 3 or so months ago in bits and pieces.
Anyways, like a lot of people, Im starting a “project” in the form of a 2d tile engine. How original you cry. So the question I have is basically this:
I have a 20x20 map with a 20x20 overlay ontop of it containing things like buildings, trees etc. What I want to achieve is an effect whereby I can walk infront of it if Im infront of it and obviously behind it if Im behind it A sort of fake perspective basically. With DepthFunc set to GL_LEQUAL, I was wondering whether anybody had any good ideas as to what to do. Was thinking of a toggle maybe between GL_LESS and LEQUAL depending on where you are or something.
Thanks in Advance,
Montoya

I’m asumming you are using an orthographic projection. When I did something along these lines, I simply gave each layer of tiles a different depth. Then by simply adjusting the players z, I could intuitively position the player between any layers I wanted. Imagine looking at the 2d scene from overhead, what I basically had was seperated planes of tiles. The player actually was positioned inbetween two of those planes. So simply using a quantized z was enough to change the z-priority of the player, and I only used GL_LESS for the depth function.