PDA

View Full Version : my starfield class



virtual
10-04-2011, 01:41 PM
my simple class trying to draw a cool looking univers !!

hope it will be usefull.

de_jean_7777
10-04-2011, 02:55 PM
The effect looks very nice, but the rendering is slow, this having to do with using glBegin() and glEnd(). You could use glDrawArrays to speed up the rendering. And you seem to be calculating the screen coordinates yourself, instead of using an OpenGL perspective projection which should do this task automatically (and thereby lowering the use of CPU immensely and speeding up rendering). You can store the star positions in an array which could be sent to OpenGL directly, and another array for star speeds. Although the points and speeds could be in a single array, but then you'd have to specify OpenGL stride (offset) for your point array.

I did something like this too, but in Turbo Pascal on a 486DX DOS machine where there was no OpenGL and I had to do the perspective calculations myself for each point.

code_glitch
10-04-2011, 05:31 PM
Looks fast enough in wine... Nice work btw, I might scrutinise the code and change it some, but overall, that is one nice effect.