Jump to content
  • Advertisement

Archived

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

Laroche

Writing a 2D Renderer

This topic is 5645 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 have my own sprites class and texture class, and everything working perfectly with respect to drawing/rendering. The system I use is a batching system with multiple lock-unlock calls with a dynamic Vb. Now in order to minimize draw(...) calls, I want to group each object by layer and by texture. By layer I mean what to draw first.. I realize I could use a Z-buffer for this, but I dont feel comfortable enough with it. What I was thinking is that the CRenderer would have a 2d vector, the first one being layer the second being the objects, so each layer has a vector of objects to sort and draw. But I''m not to sure if this is a great idea, and I don''t know how to write an algorithm which would traverse the entire thing. What has everyone else done in respect to writing a renderer? Is it even worth it for a 2D game?

Share this post


Link to post
Share on other sites
Advertisement
First, I'll say that in the game I'm working on I simply draw everything from back to front. I have a little less control when it comes to rendering, like I can't draw objects between layers of the map, but I don't need this.

The method you described should not be too difficult to implement. I take it you are referring to 2d STL vector in your post, I got got confused when I first read your post thinking you meant a 2d vector like (x,y). Anyway, there is no such thing as a 2d STL vector, they're linear. However, you can make a 2d array to hold the objects for each layer.

digital radiation

[edited by - directrix on March 5, 2003 4:16:30 PM]

[edited by - directrix on March 5, 2003 4:17:23 PM]

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.

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!