Skip to main content
gamedev.net
🔒 Locked

Rendering System

Started by Stef3d Feb 3, 2004 at 12:45 AM 2 replies 500+ views
Original Post
Stef3d
Stef3d
I have been working on a game engine (i kno wi know, who isn''t?) and I would like to contain all the rendering within a single subsystem as much as I can. Currently the only way to do rendering that I am particularly familiar with is adding a virtual Render() method to the base GameEntity and then iterating through the list of entities and calling Render() on each one. This clearly is not the most efficient way of doing things, however I am not entirely sure of how to go about implementing a RenderSystem that will take care of all the rendering on its own and abstracting the API. A lot of the articles that I''ve read just talk about making a rendering system but don''t go any firther into the implementation or the details of it so any tips, tricks or links would be much appreciated. Thanks in advance.
Omaha
Omaha
You could, during your update phase, generate a list of all the "entities" that need to be rendered and then have the engine iterate through them in a manner that maximizes (or tries to maximize) efficiency by grouping those that have the same texture/material/shader/whatever and eliminating trivially invisibile once. Then if your rendering code is written to exploit efficient ordering, you should be able to head through that list and get the job done.
jamessharpe
jamessharpe
Basically the trick is to have some uniform method of passing the geometry data to the renderer and then be able to tell the render how you want it to look like.

The simplest system would consist of a simple ID that tells the renderer to ''set me to this state and then draw using method X.'' Of course you can get more complex systems with finer control over the parameters set to render, or the holy grail is a kind of meta description of what you want it to look like and the renderer then dynamically sets the states based upon the hardware capabilities.(for a discussion of this kind of system search for the infamous Material/Shader Implementation thread).

Of course the way in which you abstract the API is totally dependant upon the number and type of effects you wish to support. If all you wanted was a simple texture surfaces or gouraud shaded surfaces then you could get away very easily with the ID system, however when you want to support effects such as per-pixel lighting, then you require a more complex system. Again it becomes even more complex when you support true dynamic reflection/refraction as the renderer needs to be able to traverse you scene to retrieve(potentially different) scene information for rendering to another target.

James
Stef3d
Stef3d
Thanks for the posts guys. I think I know what I need to do now.
Everyone here is quite helpful.
Thanks again.

Topic Locked

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

Sign in to reply to this topic.