It totally depends on the scope/scale of things and your goals. DirectX, though I haven't used SharpDx is in essence not all that different than XNA from what I'm aware of, if you take all the high-level abstractions away. Yout create your resources, set a bunch of states, bind those resources and issue a draw call. Things get a bit more complicated when you start using shader instead of the fixed function pipeline (which I'd recommend), but practically, your approach would work. Is this what you want, then go with it, you can do all that in each class that describes a renderable object. I personally wouldn't consider it a good design though, since it isn't flexible at all. As an advanced system, you would e.g. build a low level rendering system with render commands and queues, as thoroughly described in this thread (pages 2+ specially), and probably apply an entity/component-like system on the very top of things. Its certainly a hell lot of work to get things running, but once you have it, its totally satisfactory to use (if integrated right).
Well, i eventfully want to have better, faster, more efficient algorithms and designs but if you recon this approach is plausible for the time being i can use it as a crutch..
At the moment i'm still only experimenting in 2D, but when i start with 3D experimentation i would very much like a thorough understand of the best practices.
Two more things though, I'm uncertain if this is just because its sample code, but:
- class Sprite : Game ... so Sprite derives from Game? So your sprite IS a game? Inheritance is normally an IS-A relationship, so eighter this is a slight naming issue (Drawable instead of Game), or there is some serious design flaw going on I'd encourage you to look at more closely.
Its more complicated than the code i written above, but eventually something will inherit from game. Game being the main component in xna that has: "initialize", "Update" And "Draw" methods.
If i passed game as a parameter in the constructor, or passed it by some other means i could not invoke and override game.Draw() and not take advantage of polymorphisim. Unless i'm missing something?
I know inheritance is usually an "Is-A" model, but the way XNA seems to be constructed they kinda bend this rule abit..
- class Manager : there is some discussion about whether "manager" classes are too wide-ranged, unspecific and bloated, as IMHO, I'd agree that those classes often end up doing to much work, but this is up to you to decide. However, I assume too that this should really be DrawManager/RenderManager, since otherwise this would be one unspecific, possible monster class, and I'd suggest splitting that up a little bit too.
Hope that helps, and that those are thing you'd wanted to hear? (Your questions are a bit wague, so I'm not sure).
Yeah that's kinda the bulk of my question, If i had something that iterates through all the drawable objects in a level, Then invokes a draw method in a super class accordingly, wouldn't that be completely inefficient?
Seems you have pointed me in the right direction of some healthy alternatives so ill give them a read, shortly.
Although i know my way around code better, Directx and game programming concepts i'm still not too sharp on. Most of the information on directx programming is pretty much "how to draw a triangle" ect, but i haven't found any real "meaty" discussions on actual engine design, i'e how to draw a scene of triangles with different states.