Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

my question is "What is the best way to structure rendering code".

Is it better to make a class with a render function that iterates through all game objects based on there name or type and have no state manager or is it better to make a class with functions like drawpolygon, drawmesh, drawline and use it in a state class something like this(http://gamedev.stackexchange.com/a/13245/18912). or is there something else that works better ?

Thank you in advance.

share|improve this question

closed as not constructive by Josh Petrie, Nathan Reed, Patrick Hughes, msell, Anko May 24 '13 at 13:12

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.If this question can be reworded to fit the rules in the help center, please edit the question.

    
This is a really broad question, specific versions of which have already been asked-and-answered here (for example). Voted to close. –  Josh Petrie May 23 '13 at 20:46
    
Layer things. You will have an API for drawing things and you will have an API for scene management. Build both dependent on your needs, which we can't possibly know for you. –  Sean Middleditch May 24 '13 at 8:16

2 Answers 2

A common thing people do is they make a drawing method for this. It's generally considered better the draw the object inside the class and directly use the API. It's also good if you can make a class to inherit which has the draw method inside, and allows polymorphism.

Generally the APIs have reasons why they are the way they are. It's best just use them as is without anything special for drawing. And wouldn't you have to eventually implement all the drawing code anyway? It just sounds like a waste of time to me.

Anyways, good luck!

share|improve this answer
2  
can you give me an example? –  user389006 May 23 '13 at 20:22
    
That depends from programming language to programming language. That's just a general answer. –  CPP_Person May 24 '13 at 12:57

This question is really complex, since it depends from game to game, and what you are going to render. But you know you have chosen a bad design when you constantly needs to update it for your doings.

There are so many different designs out there that you simply have to do some test with what is the best or what you feel is most efficient.

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.