Skip to main content
gamedev.net
🔒 Locked

game rendering logic

Started by Enselic Jan 31, 2003 at 9:32 AM 2 replies 300+ views
Original Post
Enselic
Enselic
Im just wondering a good way to render a whole game. I don't want to start code till I know that the method im thinking of is not bad. Lets say I have a CWorld and CTrees class each with a render() method. The render method would look something like:
render()
{
  select vertex buffer
  drawprimitives
}
 
and then in my game loop:
if( render )
{
  BeginScene
  World->render()
  Trees->render()
  EndScene
}
  
Is this a correct way to do the rendering? Is there any other logic to do it? [edited by - Enselic on January 31, 2003 10:33:44 AM]
JoeyBlow2
JoeyBlow2
Thats the idea.

Later on, which you get more experienced, you will want to use visibility checks. Partition up the trees and world into smaller blocks then check to see if they are within the camera view and render just those.

Pseudo
Pseudo
Basically you have to decide what are the base objects that need to be rendered, and render them in the main loop. for instance, my mario clone how an object called Level that contains all the world data, so I tell it to render, and I also have an Object called EnitityList that renders all the entities that are visible. Finnally I have an object called HUD that display the status stuff, so I also need to render that. Part of my main loop looks kinda like this each frame:

HUD.Render();
EnitityList.Render();
Level.Render();

no, I don''t hardcode any specific entities, or level or anything. that gets taken care of by the level and enititylist.

so my point is that you might end up making tree''s part of the world object because that object could keep an octree or something that the tree could use as a speed boost. this would make visibility more centralized rather than having one octree for your world, and another for tree, and another for other entities/sprites

Topic Locked

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

Sign in to reply to this topic.