Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


OpenGL A possible idea for sorting 2d objects with openGL

This topic is 5404 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

Hey, I tought about something that could work for a 2d game. That would be for an openGL game in Ortho mode. If you want to make the polygons wich are under other polygons, on the Y axis, appear in front of them, you could just draw every polygons by using the value of Y for the Z-Axis. You would have to enable Z-Buffer, and openGL would do the job for you! Do you think this would work? Would it be faster than programming a routine to draw the polygons in the correct order? (btw, tell me if I wasn''t clear enought)

Share this post

Link to post
Share on other sites
hum, ok...

Well, lets say I have a 2d game with a lot of units on the map, the units wich is the most to the south should be drawn -over- the other units...
But if I just draw units randomly, there will be units draw over some units while they should logically have been under...

If i''m using Ortho mode, the Z position has no effect... but I could maybe assign the Y value of every units to its Z position.. and this Z position would be used by the openGL Z-Buffer, to determine wich units are in front of the other...

So that would automaticly sort my units to make the units on the south be drawn over the other...

I could be wrong, but I think it could work?

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!