Sign in to follow this  

Render queues...

This topic is 3593 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm writing a game in my spare time which is roughly following the MVC pattern (roughly). I am in need of a nudge in the right direction as far as sending the data to the renderer to draw. In the past I had something similar to Renderer::DrawMesh(Mesh& mesh). In this design the scene graph had to know about the renderer. Which I am currently trying to avoid. My current idea is something along the lines of this. The controller contains a render queue. The scene graph (who knows about the controller) traverses the tree and adds any objects which are not culled to the controller. The renderer (who knows about the controller) is given the queue which is then sorted and drawn by the renderer. The controller acts as a middle-man. I still can't picture in my head how I would implement this. And before I spend too much effort on this idea I would like to know what those of you who have some experience in something like this thought of my plan. Note: I'm not trying to follow the MVC (or any other pattern) completely. Just drawing ideas from it.

Share this post


Link to post
Share on other sites
You don't need a middle-man. The renderer can collect a list of objects that should be rendered this frame from the scene graph, sort them, and then render. The scene graph is actually doing some of the culling work by only flagging a subset of objects to be rendered, so it's not entirely a "model" in the MVC pattern since there is some implicit view logic there.

Share this post


Link to post
Share on other sites
Yeah, that's cool.

Now the question is what data do I send and how do I send it to the renderer and how does the renderer know how to render it.

I bummed around in Ogres code to see what they did. Looks like they have an abstract class Renderable, then scene nodes inherit the Renderable class. Then the render queue would be a list of pointers to Rendereables correct? Hows does the renderer know what kind of renderable it is and how to render it?

Share this post


Link to post
Share on other sites
Quote:
Original post by c_olin
I bummed around in Ogres code to see what they did. Looks like they have an abstract class Renderable, then scene nodes inherit the Renderable class. Then the render queue would be a list of pointers to Rendereables correct? Hows does the renderer know what kind of renderable it is and how to render it?

I've never been a huge fan of that approach, precisely because of the type of questions you're asking. How does one render "objects"? I know how to render "models", I know how to render "sprites", I know how to render "points" and "lines" and tons of other such primitives, but not "objects"; that's too abstract. To me it doesn't make sense to make an object a renderable, because it's not the object that's being rendered, it's the object's model or sprite representation that's being rendered. So the representation is a renderable, the object itself is not. They are not one and the same, which results in a has-a relationship as opposed to an is-a relationship.

This means that during rendering you aren't going to be calling a Render method on your objects, since they aren't renderables. What you will do is broadcast to them that rendering is starting, and ask them what is is they would like to do. Of course most objects would just say "Hey, here's a pointer to my model/sprite, render it please!". But some objects might actually serve as helpers that perform other actions like set renderstate, or trigger sorting, or something else that might not technically be "rendering".

That's just my two cents, though. I'm sure others have their own reasons for doing things differently [smile]

Share this post


Link to post
Share on other sites
Thanks, that helps. I'll go in a similar direction you suggest. Any links to articles or other threads related to this or any other input from anyone else would be helpful.

Thanks.

Share this post


Link to post
Share on other sites

This topic is 3593 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this