Jump to content
  • Advertisement
Sign in to follow this  
feti

OpenGL Is this possible to do and does it make sense?

This topic is 3942 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I want to do an isometric quasi 3d game in opengl. I want to represent forward and backward movement by using the Z axis instead of the Y axis. This way I can use GL_DEPTH_TEST to do my depth sorting for me. Now, all of the tiles will be rendered normally, but for sprites I will have a rectangle that should always be facing the screen, as if it's 2d, with the sprite texture mapped to it. Basically I want to harness opengl's ability to do depth sorting for me instead of me having to worry about it by hand. Another Gamedev fella (O-san) is working on an engine now that is just like what I want to do, but much more advanced, and he's using 3d cubes (with 3 faces) to represent each sprite. I'm wondering if I need to do that or if I can represent my sprites still using a single rectangle facing the screen at all times somehow. Now, I've already got a basic 2d example going where I render all of my tiles on the z axis, and then I rotate the camera so it looks isometric. But at which point would I be rendering my flat rectangles with mapped sprite textures? How do I determine which angle they need to face so they look flat when you're looking at them?

Share this post


Link to post
Share on other sites
Advertisement
I think you're being confused by the terminology. The depth buffer doesn't work based on the actual Z-coordinate, it works by the distance from the virtual camera (which is probably termed the Z distance in some places because it represents the "depth" to the object). Which means it doesn't matter how you represent your axes or how you orient them them, polygons will still be tested against their actual distance from the camera (which would be sqrt(dX^2 + dY^2 + dZ^2)).

For what you're doing, I'd set up an isometric projection and angle the camera appropriately. Then just draw your tiles in 3D.

Share this post


Link to post
Share on other sites
Oh, that makes sense I suppose. For some reason I was relating z depth to the actual way opengl determines its depth tests. Thanks, that's perfect.

Do you think if I'm using cubes with 3 faces for each sprite that I'll run into issues if they have alpha transparency on them? I'm not doing any fancy lighting that I know of. I just don't want the cubes to be represented in an incorrect manor due to the transparency and each side of the cube being separate, instead of in a 2d isometric world where it's 1 single rectangle.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!