I started this program a long while ago and it never really advanced. But now I'm making progress again!
It's basically a little library (but not intended to be a library to link with) which handles the basic stuff you need for 3D:
-Drawing triangles and quads
-Bad wireframe mode
-Matrix stack (glPushMatrix, glPopMatrix)
-sin and cos LUT for the fixed point datatype with highest possible accuracy (degrees)
-OpenGL immediate-mode like API
-Written in C++ (operator overloading) but C-style API if needed
At first I tried to implement it with float, but that was ridiculously slow and laggy. Especially the z-buffering was painful to watch..
But after I implemented fixed point arithmetic things changed: The attached demo runs at ~100fps (1 degree rotation per frame) in the emulator and a bit slower on a real calc. I was curious how fast it really was, so I tried loading some .obj files and it was smooth until 2000 triangles. I'm sure it can be optimized further, it doesn't use a single line of assembler yet.
I tried to port glxgears but a quick and dirty port had some issues with the blue gear.
-No triangle-based clipping: pixel based is a bit slower (depends on the objects on screen) and if you're near a triangle, it may look weird or even crash
-Bad integer division algorithm (gcc's own): division through a small number takes ages
-Drawing triangles is still a bit slow, two increments, one multiplication and several comparisions per pixel (without textures)
-glRotatef not yet implemented
-Sometimes it tries to divide through zero and it hangs, I don't know why
-Textures lack perspective (difficult to optimize)
-Viewport is fixed: bottom: y=0 top: y=239 left: x=0 right: x=320, in OpenGL it's most times -1-1, so a scaling factor is needed
But nevertheless, I'm going to implement a simple 3D game (no, not minecraft) with this lib, but I don't know what kind of game:
- 3D Tetris (boring..)
- Motor race in 3D (how should the cars and the environment look like, also: collision detection)
- 3D snake (even more boring..)
Edit: Ok, it seems like I made a minecraft game nevertheless...Latest release of crafti: v1.2 GitHub
Source code and tutorial for nGL are on GitHub as well
-touchpad: camera rotation
-8-4-6-2: camera position
-x: rotate the four cubes
Do you think this is useful or will it stay an experiment forever?