-2

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(https://gamedev.stackexchange.com/a/13245/18912). or is there something else that works better ?

Thank you in advance.

user389006
  • 31
  • 6
  • This is a really broad question, specific versions of which have already been asked-and-answered here (for example). Voted to close. –  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 08:16

2 Answers2

1

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!

LiquidFeline
  • 1,381
  • 1
  • 13
  • 31
-1

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.

Tordin
  • 1,622
  • 9
  • 11