18
« on: January 17, 2012, 08:02:16 am »
Hey dude, here's a tip for your scene export thing: use a timestep and finite state machine.
Explanation:
Use fsm (finite state machine) to record current game status, and use timestep to synchonize it to frames.
Also, here some Opengl tips...
-Always use the vector forms of these methods: glvertex,glColor,glTexCoord and glNormal.
-> gl(Vertex|Color|texCoord|Normal)(2|3|4)(f|i|d)v(array_of_values)
-Use display lists for materials and texture units, using glColorMaterial(face,mode) to reduce function call overload:
->glColorMaterialf(GL_FRONT,GL_AMBIENT), now glColor3f() will affect current material ambient. To enable glColorMaterial use: glEnable(GL_COLOR_MATERIAL).
-Use Vertex buffer objects for animated meshs and terrains, or use interpolation between frames (Lerp or qLerp).
-Keep non-gl code before Opengl code, it speeds Opengl rendering.
-use delta-timing for Syncronism (principally for networked games).
->//Loop beginning
time := glutGet(GLUT_ELAPSED_TIME) //or similar like GetTickCount()
delta := time - delay
delay := time
deltasec := delta/1000 //convert to seconds
playerpos.x += player_velocity.x * (0.5 * deltasec) //moves 0.5 units in x, independent of application speed.
Sleep((1000/frames_per_second)-time) //Frame limiting (obs: it don't work in my Engine)
//Opengl Code
...And that's just some tips (and tricks) to speedup your application. I've attached 2 screens of my 3d Engine.