Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


Looking for advice to construct class structure for efficiency


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
3 replies to this topic

#1 arkenthe   Members   -  Reputation: 112

Like
0Likes
Like

Posted 23 July 2014 - 06:35 PM

So I have a base class of "actors" that will be drawn to the screen,which includes basic stuff like vertex,index buffers,some data types,information about geometry(index vertex count etc.). So here's my question:

 

Should I pass ID3D11Device* and ID3D11DeviceContext* to classes derived from base class and simply let this classes handle all rendering by themselves in a method such as virtual void Render( ID3D11DeviceContext* ),

 

or

 

Should I create a renderer class which takes this derived classes and their data and implement their rendering logic?

 

or better suggestions? I am building a huge project and I have never been worried about efficiency so I need your help.


Edited by arkenthe, 23 July 2014 - 06:35 PM.


Sponsor:

#2 L. Spiro   Crossbones+   -  Reputation: 14215

Like
5Likes
Like

Posted 23 July 2014 - 11:28 PM

This isn’t a matter of efficiency, it’s about modular design.

A renderer doesn’t know what a model/actor is, so your second idea simply doesn’t make sense.

 

Among your proposals, the first is the correct choice.

 

 

L. Spiro


It is amazing how often people try to be unique, and yet they are always trying to make others be like them. - L. Spiro 2011
I spent most of my life learning the courage it takes to go out and get what I want. Now that I have it, I am not sure exactly what it is that I want. - L. Spiro 2013
I went to my local Subway once to find some guy yelling at the staff. When someone finally came to take my order and asked, “May I help you?”, I replied, “Yeah, I’ll have one asshole to go.”
L. Spiro Engine: http://lspiroengine.com
L. Spiro Engine Forums: http://lspiroengine.com/forums

#3 Hodgman   Moderators   -  Reputation: 31786

Like
5Likes
Like

Posted 24 July 2014 - 12:34 AM

I don't like either of those options -- a model is too high level to know about a ID3D11DeviceContext, and the Device is too low-level to know about complex things like models.

 

I would choose option #2, but instead of the Device knowing how to draw "models", break that down into it's simplest parts -- vertex streams, a stream layout, a shader program, lists of texture bindings, lists of cbuffer bindings, and a "DrawPrimitives" operation. I'd have the device know how to draw something use all of those objects internally, and then I'd have the "Model" class have these as members (i.e. be composed out of these simpler objects).



#4 #Include Graphics   Members   -  Reputation: 405

Like
1Likes
Like

Posted 28 July 2014 - 05:37 AM

I am with L. Spiro here, the renderer should not have to know anything about how a model will be rendered, instead he will know about how are all the stuff in the world rendered:

 

1. Order of the models and the type being rendered ( fe: First the non alpha. then alpha models )

2. which effects are being applied and in which order.

3. Post effects applied

 

It is like a mix of multiplexor, manager and organizer system.

 

Hope it helps.






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS