#### Archived

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.

## 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 on other sites
That makes no sense whatsoever . What are you trying to accomplish anyway?

<- Cow Soft, free software I''ve made
"Unfortunatly, when I sent the email, instead of writing "Best Regards" I ended up writing "Best Retards." - boolean

##### 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?

1. 1
2. 2
3. 3
4. 4
Rutin
15
5. 5

• 13
• 26
• 10
• 11
• 9
• ### Forum Statistics

• Total Topics
633724
• Total Posts
3013554
×