-
Notifications
You must be signed in to change notification settings - Fork 109
OpenGL on N64
This documents highlights how to best use OpenGL on Nintendo 64 via the libdragon unstable branch. This branch features a OpenGL 1.1/1.2 implementation that implements several official extensions, plus some N64-specific extensions.
This is not an OpenGL guide. Reading this page requires some previous knowledge of classic OpenGL programming, as it only underlines specific optimizations or tricks required for maximum performance on Nintendo 64.
Classic OpenGL manages several "objects" like textures, vertex arrays, display lists, etc. These objects are referenced by IDs (of type GLuint
) which are normally allocated via a family of glGen*
functions. For instance, to create a vertex array, this is how it is normally done:
GLuint sphere_array;
// Generate one vertex array ID into sphere_array.
glGenVertexArrays(1, &sphere_array);
// Bind the vertex array (= make it "current")
glBindVertexArray(sphere_array);
// Procede to configure it
[...]
This is the standard code, which works on Nintendo 64 as well. Unfortunately, OpenGL specifications do not mandate the usage of glGen*
functions, but only recommends it. This means that an application is free to do this:
// Choose any ID I want
GLuint sphere_array = 0x1234;
// Bind the vertex array (= make it "current")
glBindVertexArray(sphere_array);
// Procede to configure it or use it
[...]
so basically an application can have its own ID allocation mechanism. For instance, GlQuake has its own texture ID generation system, which is simply:
int texture_id = 1; // next ID to allocate
int generate_texture_id(void) {
return texture_id++;
}
We decided to not support this style of ID self-allocation on Nintendo 64. In fact, to support it, we would have to slow down the implementation by adding hash table lookups for each function in OpenGL that references an ID.
If you try to use an ID not allocated via glGen*
functions, you will get an error screen like this:
In classic OpenGL, textures are managed via "texture objects": first, you allocate