I write this demo just to go though some key concepts of computer graphics.
The following features are implemented in this demo:
1) transform mesh from local space to world space, then to the camera space;
2) Do projection to convert 3d triangles to 2d triangles.
3) Do clip in the clip window space, and split into two triangles if need;
4) Shader 2D triangle with diffuse texture or vertex color;
5) A float array used fo depth buffer;
6) Back surface culling in world space or camera space;
6) Texture Address mode (Clamp, Wrap & Mirror) and sampling (Point and Linear ).
Operation
KeyZ, Show content of the depth buffer;
KeyC, Show content of the color buffer;
KeyD, Shader with diffuse texture;
KeyV, Shader with vertex color;
KeyW, Forward
KeyS, Backward
KeyP, Texture with nearest points sampling;
KeyL, Texture with linear sampling;
You cocould download the source code from here. SDL1.2 library used here to display the frame buffer content & depth buffer.