Time has been scarce for me to work on the project, but recently I have been on winter break and have made a little progress.
Some of the code is adapted from KGL, mostly the default matrix stack initialization, but carefully to ensure things are being done efficiently.
Some things that are different from KGL:
-Mixed-List Vertex Submission:
I have recently implemented a very nice vertex buffer solution that allows submitting mixed lists, meaning you can switch from rendering opaque polys and transparent polys at any given time by calling glEnable(GL_BLEND) for transparent polys, or calling glDisable(GL_BLEND) to switch back to opaque. There is no glKosFinishList() like before.
The vertex buffer is not using KOS DMA, instead my own solution. Why? I made some testing with KOS DMA, and the benchmark program I ran hits 1.25 mil verts/second at 60fps. With my solution, the benchmark program hits 2.5mil verts/sec at 60fps.
-Single Draw Call to the PVR
The scene is submitted by a call to glutSwapBuffers(), there is no glKosBeginFrame()/glKosFinishFrame().
Now, the vertex buffer stores generic pvr commands, so the headers or the vertices can be typecasted, this means the entire vertex array for each list for the scene is submitted in one transfer.
-Z Clipping ( Near and Far )
My experience with KGL demonstrated some wonky Near Z clipping that would often cause large polygons to be culled when they should clipped.
For this pipeline, I have written my own Near Z clipping algorithm, not based on KGL's code, that aims to remove those annoying bugs in KGL.
Also, it is possible to adjust the PVR's Far Z clipping that brings me to the point of this post.
So, with my OpenGL API up and running, I made a simple scene composed of triangle strips to simulate a large city street.
With no clipping enabled, the scene is quite ugly indeed. The large polygons disappear when they should be clipped, but are not. Also, the background color should be grey, this screen also shows a nasty bug in NullDC that does not display pvr_set_bg_color() correctly.
Now lets enable my Near Z clipping algorithm:
Looks better, but not what I had in mind. The large building disappears into the grey, and the viewing distance seems very poor. There is a skybox, but it can not be seen due to the draw distance.
This is because KOS sets the PVR's Far Z clipping to a relatively short distance.
We need to set the PVR's register to modify the draw distance:
Code: Select all
#include "pvr_internal.h"
#define FARZ_CLIP 0.00000001f /* Far Z Clipping - On PVR Smaller Value = Further Clip Pane */
pvr_state.zclip = FARZ_CLIP;
PVR_SET(PVR_BGPLANE_Z, FARZ_CLIP);
For testing purposes, I have included a .cdi of the demo to look at, you can move around the "city" in a first-person perspective: