Some OpenGL code I have written beginning of January, 2001

Here you may find several interesting OpenGL demos implemented in C. 
The main purpose behind them is to learn the API and be able to create
stunning animations ;)
Most of those demos deal with mathematical phenomena or semi-scientific 
simulation of particles, water, etc...
Code is included and may be modified at will (well, i have used somebody
else's code at the beginning -- one has to learn from others, right?)

Oh, and by the way, pardon the lack of comments in the code.. 
I'm still learning and every line of the display() functions has 
been modified too many times in order to have any decent comments 
associated with it (once i was happy with the result i simply put it 
here for your perusal)

note: you need glut32.dll to run those

Fireworks.. a very simple (but nice looking) opengl implementation... 
(source, executable, scrshot)

Another fireworks example (same as above, but with gravity enabled).. 
small changes in code...
(source, executable, scrshot)

Galaxy collision... This is a port of the galaxy collision 
simulation I wrote for a graphics class... Now mucho faster in OpenGL... 
(source, executable, scrshot)

Sierpinski's gasket in 3d (using cubes).. this is basically a redo 
of the abovementioned Java program, but this time the light has been 
omitted (had problems with it) and a bug has been fixed in depth 
calculation. if you have a chance of running this program on a good machine, 
tell me how it behaves for depths above 8... 
(source, executable, scrshot)

Sierpinski's gasket in 3d (using pyramids).. same as above :)
(source, executable, scrshot)

Ok, this one is pretty lame, but I'm putting it on anyway.. it's a 
*cough* ripoff *cough* of a program that comes together with the mesa demos. 
It displays a NURB plane, where all the control points are moving on a 
sinusoidal curve of some sort and so on and so on... this is a pre-attempt 
to simulate water (of course using somebody else's ideas, but i'll write 
about them when they're ready)...
(source, executable, scrshot)


Finally done (29.01.01) -- my first decent water simulation! I used 
a paper/code by a guy on devnet, had to convert his algorithm from 
pascal but I think it's worth it.. The program here shows raindrops on
a water surface (not too deep ;)... Move with the mouse, drop some rain with
the space bar (press space bar quickly for a small thunderstorm ;)
(source, executable, scrshot)

And now, the moment you've all been waiting for... Water with textures!!! :)
This is the same application as above, however i have used texture mapping 
i have stolen form other people's code :) enjoy!!!
(source, executable, texture.c, texture.h)

This one is still water, but this time I have played with lightning -- the cyan
square you see on the screenshot is denoting the light's position. The mesh here
is twice as big as the others, because lighting up the scene involves 
generating tons of surface normals, which make the image sharpy if the surface is not
big enough... Anyways, enjoy but be careful -- it's a bit slow...
(source, executable, scrshot)


This one is the one I like the most.. my girlfriend told me "i know you 
can do water ripples and raindrops, but can you do a rose?" so i guess i
had to obey.. originally i was thinking of manipulating triangles to get
the effect of a flower blossoming, but decided to do it with NURBS since 
they are much better shaded... I started with a 3x3 mesh and moved point
[0,0] up and to the center until it started looking like a closed flower...
Then I did the same for [2,0], [0,2] and [2,2] and then ran everything 
backwards :) simple, eh? I had to move point [1,1] in the opposite direction
to compensate and keep the center stable in one place... The rest is history
-- i created a second NURBS to achieve the 'constant blossom' effect and put
textures and lightning...
note: be careful when looking at the code.. it is written in haste and is
*rather* messy even for me :)
(source, executable, scrshot, texture.c, texture.h, texture image)

Same as above, but the movements are a bit funnier and the texture has been 
removed (speed increase)
(source, executable, scrshot)



STARFIELD: i am very proud of this one. it took me 7 hours to complete from
scratch, and at the end i think it became pretty good... well, at least i
like it :)

it depicts motion through a field of stars. the mouse moves the point of
view, while the space bar shoots something very green, that could (or could
not) be used in some sort of an arcade game :) the blue objects are default
glut figures, drawn there just for fun.
(source, executable, scrshot)