Objects?

Nibbie
Posts: 2
Joined: 2009.01
Post: #1
er, how can I make an object, lets say a couple of quads which will stay around, persist, so that I can do stuff with it? Its a pain in the ass to have to make the cube every time it loops, why can't I define it and have it stay defined?
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #2
OpenGL has no memory of what's been drawn, and no concept of "an object". You have to draw everything each frame because you might want to draw something different each frame.

Why can't you just make a function called drawCube() and call that each frame?

OpenGL does have the concept of a "display list", which is a set of OpenGL commands you're going to issue over and over again. These get "compiled" and stored on the video card. Then all you have to do is call glCallList(). For something like a cube, though, they're probably slower than drawing it each time yourself by hand Smile
Quote this message in a reply
Member
Posts: 177
Joined: 2002.08
Post: #3
Just to be complete, there are also vertex objects, which are closer to what you are asking for but overkill for "a couple of quads".
Quote this message in a reply
Member
Posts: 509
Joined: 2002.05
Post: #4
Quote:Originally posted by OneSadCookie
OpenGL does have the concept of a "display list", which is a set of OpenGL commands you're going to issue over and over again. These get "compiled" and stored on the video card. Then all you have to do is call glCallList(). For something like a cube, though, they're probably slower than drawing it each time yourself by hand Smile


Kind of offtopic, but i'm doing keyframe animation of a person moving, would it be the fastest to use a array for each keyframe, and then just interlope and send the polygons to the video card, or to make 60 or so frames and load them into lists at the start of the game? I will only need a few animations in my game if that matters.
Quote this message in a reply
Zoldar256
Unregistered
 
Post: #5
This sounds like a classic performance vs memory requirements question.

If you can spare the memory, 60 pre-computed display lists would be faster than computing the animation for each frame.

BUT! 60 pre-computed display lists will take more memory and be less flexible.
Quote this message in a reply
Jesse
Unregistered
 
Post: #6
About the keyframe thing, it might be safer to assume that at some point you will have more than a few animations, and caching all the frames won't be practical from a memory standpoint. Linear interpolation shouldn't be any slower than, say, skeletal animation, and a lot of games are doing that in real time now. So you might consider just interpolating in real time from the outset.

Level of detail selection can help here, but that's a whole other topic...
Quote this message in a reply
Post Reply