Skip to main content
gamedev.net
🔒 Locked

Engine Design question

Started by andyb716 2 replies 800+ views
Original Post
andyb716
andyb716
Hi, I recently coded a Object factory where in you can pass objects and it will automatically render everything. My question is should I pass the device object into the Object factory and have that pass into the objects render method. Or should I have a device for every object and pass the device object into the constructor and have it throughout the entire class object. I was thinking I only need when Im rendering so I could just pass it into the render method. What do you guys think?
Morbo
Morbo
It's fairly common to pass around your render context rather than including it as state in the object. The most obvious benefit is you can switch the renderer on the fly (somewhat, anyway). Plus is avoids an unnecessary coupling of the objects and the renderer.
andyb716
andyb716
That post kind of confused me. So should I let the object factory handle the device or should I let every class handle it.
Morbo
Morbo
Have your factory handle it and just pass it to the objects render method.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.