nds/arm9/videoGL.h File Reference

openGL (ish) interface to DS 3D hardware. More...

#include <nds/jtypes.h>
#include <nds/arm9/video.h>
#include <nds/dma.h>
#include <nds/memory.h>
#include <nds/bios.h>
#include <nds/arm9/math.h>
#include <nds/arm9/trig_lut.h>
#include <nds/arm9/cache.h>

Data Structures

struct  m3x3
 Holds a Matrix of 3x3. More...
struct  m4x4
 Holds a Matrix of 4x4. More...
struct  m4x3
 Holds a Matrix of 4x3. More...
struct  GLvector
 Holds a Vector
related functions: glScalev(), glTranslatev(). More...
struct  gl_hidden_globals

Defines

#define GL_STATIC_INL   static inline
#define LUT_SIZE   (512)
#define LUT_MASK   (0x1FF)
#define MAX_TEXTURES   2048
#define int_to_12d3(n)   ((n) << 3)
 convert int to fixed12d3
#define float_to_12d3(n)   ((fixed12d3)((n) * (1 << 3)))
 convert float to fixed12d3
#define GL_MAX_DEPTH   0x7FFF
 the maximum value for type fixed12d3
#define inttof32(n)   ((n) << 12)
 convert int to f32
#define f32toint(n)   ((n) >> 12)
 convert f32 to int
#define floattof32(n)   ((int32)((n) * (1 << 12)))
 convert float to f32
#define f32tofloat(n)   (((float)(n)) / (float)(1<<12))
 convert f32 to float
#define f32tot16(n)   ((t16)(n >> 8))
 convert f32 to t16
#define inttot16(n)   ((n) << 4)
 convert int to t16
#define t16toint(n)   ((n) >> 4)
 convert t16 to int
#define floattot16(n)   ((t16)((n) * (1 << 4)))
 convert float to t16
#define TEXTURE_PACK(u, v)   ((u & 0xFFFF) | ((v) << 16))
 Pack 2 t16 texture coordinate values into a 32bit value.
#define inttov16(n)   ((n) << 12)
 convert int to v16
#define f32tov16(n)   (n)
 f32 to v16
#define v16toint(n)   ((n) >> 12)
 convert v16 to int
#define floattov16(n)   ((v16)((n) * (1 << 12)))
 convert float to v16
#define VERTEX_PACK(x, y)   (((x) & 0xFFFF) | ((y) << 16))
 Pack to v16 values into one 32bit value.
#define inttov10(n)   ((n) << 9)
 convert int to v10
#define f32tov10(n)   ((v10)(n >> 3))
 convert f32 to v10
#define v10toint(n)   ((n) >> 9)
 convert v10 to int
#define floattov10(n)   ((n>.998) ? 0x1FF : ((v10)((n)*(1<<9))))
 convert float to v10
#define NORMAL_PACK(x, y, z)   (((x) & 0x3FF) | (((y) & 0x3FF) << 10) | ((z) << 20))
 Pack 3 v10 normals into a 32bit value.
#define GL_FALSE   0
#define GL_TRUE   1
#define FIFO_COMMAND_PACK(c1, c2, c3, c4)   (((c4) << 24) | ((c3) << 16) | ((c2) << 8) | (c1))
 packs four packed commands into a 32bit command for sending to the GFX FIFO
#define REG2ID(r)   (u8)( ( ((u32)(&(r)))-0x04000400 ) >> 2 )
 converts a GFX command for use in a packed command list
#define FIFO_NOP   REG2ID(GFX_FIFO)
 packed command for nothing, just here to pad your command lists
#define FIFO_STATUS   REG2ID(GFX_STATUS)
 packed command for geometry engine status register
GBATEK http://nocash.emubase.de/gbatek.htm#ds3dstatus
#define FIFO_COLOR   REG2ID(GFX_COLOR)
 packed command for vertex color directly
GBATEK http://nocash.emubase.de/gbatek.htm#ds3dpolygonattributes
#define FIFO_VERTEX16   REG2ID(GFX_VERTEX16)
 packed command for a vertex with 3 16bit paramaters(and 16bits of padding)
GBATEK http://nocash.emubase.de/gbatek.htm#ds3dpolygondefinitionsbyvertices
#define FIFO_TEX_COORD   REG2ID(GFX_TEX_COORD)
 packed command for a texture coordinate
GBATEK http://nocash.emubase.de/gbatek.htm#ds3dtexturecoordinates
#define FIFO_TEX_FORMAT   REG2ID(GFX_TEX_FORMAT)
 packed command for texture format
GBATEK http://nocash.emubase.de/gbatek.htm#ds3dtextureformats
#define FIFO_PAL_FORMAT   REG2ID(GFX_PAL_FORMAT)
 packed command for texture palette attributes
GBATEK http://nocash.emubase.de/gbatek.htm#ds3dtextureattributes
#define FIFO_CLEAR_COLOR   REG2ID(GFX_CLEAR_COLOR)
 packed command for clear color of the rear plane
GBATEK http://nocash.emubase.de/gbatek.htm#ds3drearplane
#define FIFO_CLEAR_DEPTH   REG2ID(GFX_CLEAR_DEPTH)
 sets depth of the rear plane
GBATEK http://nocash.emubase.de/gbatek.htm#ds3drearplane
#define FIFO_LIGHT_VECTOR   REG2ID(GFX_LIGHT_VECTOR)
 packed command for direction of a light source
GBATEK http://nocash.emubase.de/gbatek.htm#ds3dpolygonlightparameters
#define FIFO_LIGHT_COLOR   REG2ID(GFX_LIGHT_COLOR)
 packed command for color for a light
GBATEK http://nocash.emubase.de/gbatek.htm#ds3dpolygonlightparameters
#define FIFO_NORMAL   REG2ID(GFX_NORMAL)
 packed command for normal for following vertices
GBATEK http://nocash.emubase.de/gbatek.htm#ds3dpolygonlightparameters
#define FIFO_DIFFUSE_AMBIENT   REG2ID(GFX_DIFFUSE_AMBIENT)
 packed command for setting diffuse and ambient material properties for the following vertices
GBATEK http://nocash.emubase.de/gbatek.htm#ds3dpolygonlightparameters
#define FIFO_SPECULAR_EMISSION   REG2ID(GFX_SPECULAR_EMISSION)
 packed command for setting specular and emmissive material properties for the following vertices
GBATEK http://nocash.emubase.de/gbatek.htm#ds3dpolygonlightparameters
#define FIFO_SHININESS   REG2ID(GFX_SHININESS)
 packed command for setting the shininess table to be used for the following vertices
GBATEK http://nocash.emubase.de/gbatek.htm#ds3dpolygonlightparameters
#define FIFO_POLY_FORMAT   REG2ID(GFX_POLY_FORMAT)
 packed command for setting polygon attributes
GBATEK http://nocash.emubase.de/gbatek.htm#ds3dpolygonattributes
#define FIFO_BEGIN   REG2ID(GFX_BEGIN)
 packed command that starts a polygon vertex list
GBATEK http://nocash.emubase.de/gbatek.htm#ds3dpolygondefinitionsbyvertices
#define FIFO_END   REG2ID(GFX_END)
 packed command that has no discernable effect, it's probably best to never use it since it bloats the size of the list.
GBATEK http://nocash.emubase.de/gbatek.htm#ds3dpolygondefinitionsbyvertices
#define FIFO_FLUSH   REG2ID(GFX_FLUSH)
 packed command that has the same effect as swiWaitForVBlank()
GBATEK http://nocash.emubase.de/gbatek.htm#ds3ddisplaycontrol
#define FIFO_VIEWPORT   REG2ID(GFX_VIEWPORT)
 packed command for setting viewport
GBATEK http://nocash.emubase.de/gbatek.htm#ds3ddisplaycontrol

Typedefs

typedef uint16 fixed12d3
 Used for depth (glClearDepth, glCutoffDepth).
typedef short int t16
 text coordinate 12.4 fixed point
typedef short int v16
 vertex 4.12 fixed format
typedef short int v10
 normal .10 fixed point, NOT USED FOR 10bit VERTEXES!!!
typedef unsigned short rgb
 Holds a color value. 1bit alpha, 5bits red, 5bits green, 5bits blue.

Enumerations

enum  GL_GLBEGIN_ENUM {
  GL_TRIANGLES = 0, GL_QUADS = 1, GL_TRIANGLE_STRIP = 2, GL_QUAD_STRIP = 3,
  GL_TRIANGLE = 0, GL_QUAD = 1
}
 Enums selecting polygon draw mode
GBATEK http://nocash.emubase.de/gbatek.htm#ds3dpolygondefinitionsbyvertices
related functions: glBegin(). More...
enum  GL_MATRIX_MODE_ENUM { GL_PROJECTION = 0, GL_POSITION = 1, GL_MODELVIEW = 2, GL_TEXTURE = 3 }
 Enums selecting matrix mode
GBATEK http://nocash.emubase.de/gbatek.htm#ds3dmatrixloadmultiply
related functions: glMatrixMode(). More...
enum  GL_MATERIALS_ENUM {
  GL_AMBIENT = 0x01, GL_DIFFUSE = 0x02, GL_AMBIENT_AND_DIFFUSE = 0x03, GL_SPECULAR = 0x04,
  GL_SHININESS = 0x08, GL_EMISSION = 0x10
}
 Enums for setting up materials
GBATEK http://nocash.emubase.de/gbatek.htm#ds3dpolygonlightparameters
related functions: glMaterialf(). More...
enum  GL_POLY_FORMAT_ENUM {
  POLY_FORMAT_LIGHT0 = (1<<0), POLY_FORMAT_LIGHT1 = (1<<1), POLY_FORMAT_LIGHT2 = (1<<2), POLY_FORMAT_LIGHT3 = (1<<3),
  POLY_MODULATION = (0<<4), POLY_DECAL = (1<<4), POLY_TOON_HIGHLIGHT = (2<<4), POLY_SHADOW = (3<<4),
  POLY_CULL_FRONT = (1<<6), POLY_CULL_BACK = (2<<6), POLY_CULL_NONE = (3<<6), POLY_FOG = (1<<15)
}
 Enums for setting how polygons will be displayed
GBATEK http://nocash.emubase.de/gbatek.htm#ds3dpolygonattributes
related functions: glPolyFmt(), glInit(), POLY_ALPHA(), POLY_ID(). More...
enum  GL_TEXTURE_SIZE_ENUM {
  TEXTURE_SIZE_8 = 0, TEXTURE_SIZE_16 = 1, TEXTURE_SIZE_32 = 2, TEXTURE_SIZE_64 = 3,
  TEXTURE_SIZE_128 = 4, TEXTURE_SIZE_256 = 5, TEXTURE_SIZE_512 = 6, TEXTURE_SIZE_1024 = 7
}
 Enums for size of a texture, specify one for horizontal and one for vertical related functions: glTexImage2d(), glTexParameter(). More...
enum  GL_TEXTURE_PARAM_ENUM {
  GL_TEXTURE_WRAP_S = (1 << 16), GL_TEXTURE_WRAP_T = (1 << 17), GL_TEXTURE_FLIP_S = (1 << 18), GL_TEXTURE_FLIP_T = (1 << 19),
  GL_TEXTURE_COLOR0_TRANSPARENT = (1<<29), TEXGEN_OFF = (0<<30), TEXGEN_TEXCOORD = (1<<30), TEXGEN_NORMAL = (2<<30),
  TEXGEN_POSITION = (3<<30)
}
 Enums for texture parameters, such as texture wrapping and texture coord stuff
GBATEK http://nocash.emubase.de/gbatek.htm#ds3dtextureattributes
related functions: glTexImage2d(), glTexParameter(). More...
enum  GL_TEXTURE_TYPE_ENUM {
  GL_RGB32_A3 = 1, GL_RGB4 = 2, GL_RGB16 = 3, GL_RGB256 = 4,
  GL_COMPRESSED = 5, GL_RGB8_A5 = 6, GL_RGBA = 7, GL_RGB = 8
}
 Enums for texture formats
GBATEK http://nocash.emubase.de/gbatek.htm#ds3dtextureformats
related functions: glTexImage2d(), glTexParameter(). More...
enum  DISP3DCNT_ENUM {
  GL_TEXTURE_2D = (1<<0), GL_TOON_HIGHLIGHT = (1<<1), GL_ALPHA_TEST = (1<<2), GL_BLEND = (1<<3),
  GL_ANTIALIAS = (1<<4), GL_OUTLINE = (1<<5), GL_FOG_ONLY_ALPHA = (1<<6), GL_FOG = (1<<7),
  GL_COLOR_UNDERFLOW = (1<<12), GL_POLY_OVERFLOW = (1<<13), GL_CLEAR_BMP = (1<<14)
}
 3D Display Control Register Enums
GBATEK http://nocash.emubase.de/gbatek.htm#ds3ddisplaycontrol
related functions: glEnable(), glDisable(), glInit() More...
enum  GL_GET_ENUM {
  GL_GET_VERTEX_RAM_COUNT, GL_GET_POLYGON_RAM_COUNT, GL_GET_MATRIX_VECTOR, GL_GET_MATRIX_POSITION,
  GL_GET_MATRIX_PROJECTION, GL_GET_MATRIX_CLIP, GL_GET_TEXTURE_WIDTH, GL_GET_TEXTURE_HEIGHT
}
 Enums for reading stuff from the geometry engine
http://nocash.emubase.de/gbatek.htm#ds3diomap
related functions: glGetInt(), glGetFixed(). More...
enum  GLFLUSH_ENUM { GL_TRANS_MANUALSORT = (1<<0), GL_WBUFFERING = (1<<1) }
 Enums for glFlush()
GBATEK http://nocash.emubase.de/gbatek.htm#ds3ddisplaycontrol
related functions: glEnable(), glDisable(), glInit(). More...

Functions

void glRotatef32i (int angle, int32 x, int32 y, int32 z)
 Rotates the model view matrix by angle about the specified unit vector.
int glTexImage2D (int target, int empty1, GL_TEXTURE_TYPE_ENUM type, int sizeX, int sizeY, int empty2, int param, const uint8 *texture)
 Loads a 2D texture into texture memory and sets the currently bound texture ID to the attributes specified.
void glTexLoadPal (const u16 *pal, u16 count, u32 addr)
 Loads a palette into the specified texture addr.
int gluTexLoadPal (const u16 *pal, u16 count, uint8 format)
 Loads a palette into the next available palette slot, returns the addr on success or -1.
void glTexParameter (uint8 sizeX, uint8 sizeY, const uint32 *addr, GL_TEXTURE_TYPE_ENUM mode, uint32 param)
 Set parameters for the current texture. Although named the same as its gl counterpart, it is not compatible. Effort may be made in the future to make it so.
u32 glGetTexParameter ()
 Returns the active texture parameter (constructed from internal call to glTexParameter).
void * glGetTexturePointer (int name)
 returns the address alocated to the texure named by name
void glBindTexture (int target, int name)
 glBindTexure sets the current named texture to the active texture. Target is ignored as all DS textures are 2D
void glColorTable (uint8 format, uint32 addr)
 glColorTable establishes the location of the current palette. Roughly follows glColorTableEXT. Association of palettes with named textures is left to the application.
int glGenTextures (int n, int *names)
 Creates room for the specified number of textures.
void glResetTextures (void)
 Resets the gl texture state freeing all texture memory.
void glTexCoord2f32 (int32 u, int32 v)
 Sets texture coordinates for following vertices
GBATEK http://nocash.emubase.de/gbatek.htm#ds3dtextureattributes.
void glMaterialf (GL_MATERIALS_ENUM mode, rgb color)
 specify the material properties to be used in rendering lit polygons
void glInit_C (void)
gl_hidden_globalsglGetGlobals ()
GL_STATIC_INL uint32 POLY_ALPHA (int n)
 used in glPolyFmt() to set the alpha level for the following polygons, set to 0 for wireframe mode
GL_STATIC_INL uint32 POLY_ID (int n)
 used in glPolyFmt() to set the Polygon ID for the following polygons
GL_STATIC_INL void glBegin (GL_GLBEGIN_ENUM mode)
 Starts a polygon group.
GL_STATIC_INL void glEnd (void)
 Ends a polygon group, this seems to be a dummy function that does absolutely nothing, feel free to never use it.
GL_STATIC_INL void glClearDepth (fixed12d3 depth)
 reset the depth buffer to this value; generally set this to GL_MAX_DEPTH.
GBATEK http://nocash.emubase.de/gbatek.htm#ds3drearplane
GL_STATIC_INL void glColor3b (uint8 red, uint8 green, uint8 blue)
 Set the color for following vertices.
GL_STATIC_INL void glColor (rgb color)
 Set the color for following vertices.
GL_STATIC_INL void glVertex3v16 (v16 x, v16 y, v16 z)
 specifies a vertex
GL_STATIC_INL void glTexCoord2t16 (t16 u, t16 v)
 Sets texture coordinates for following vertices
GBATEK http://nocash.emubase.de/gbatek.htm#ds3dtextureattributes.
GL_STATIC_INL void glPushMatrix (void)
 Pushs the current matrix onto the stack
GBATEK http://nocash.emubase.de/gbatek.htm#ds3dmatrixstack.
GL_STATIC_INL void glPopMatrix (int32 num)
 Pops num matrices off the stack
GBATEK http://nocash.emubase.de/gbatek.htm#ds3dmatrixstack.
GL_STATIC_INL void glRestoreMatrix (int32 index)
 Restores the current matrix from a location in the stack
GBATEK http://nocash.emubase.de/gbatek.htm#ds3dmatrixstack.
GL_STATIC_INL void glStoreMatrix (int32 index)
 Place the current matrix into the stack at a location
GBATEK http://nocash.emubase.de/gbatek.htm#ds3dmatrixstack.
GL_STATIC_INL void glScalev (const GLvector *v)
 multiply the current matrix by a translation matrix
GBATEK http://nocash.emubase.de/gbatek.htm#ds3dmatrixloadmultiply
GL_STATIC_INL void glTranslatev (const GLvector *v)
 multiply the current matrix by a translation matrix
GBATEK http://nocash.emubase.de/gbatek.htm#ds3dmatrixloadmultiply
GL_STATIC_INL void glTranslate3f32 (int32 x, int32 y, int32 z)
 multiply the current matrix by a translation matrix
GBATEK http://nocash.emubase.de/gbatek.htm#ds3dmatrixloadmultiply
GL_STATIC_INL void glScalef32 (int32 factor)
 multiply the current matrix by a scale matrix
GBATEK http://nocash.emubase.de/gbatek.htm#ds3dmatrixloadmultiply
GL_STATIC_INL void glLight (int id, rgb color, v10 x, v10 y, v10 z)
 set a light up. Only parallel light sources are supported on the DS
GBATEK http://nocash.emubase.de/gbatek.htm#ds3dpolygonlightparameters
GL_STATIC_INL void glNormal (uint32 normal)
 the normal to use for following vertices
GBATEK http://nocash.emubase.de/gbatek.htm#ds3dpolygonlightparameters
GL_STATIC_INL void glLoadIdentity (void)
 loads an identity matrix to the current matrix, same as glIdentity(void)
GL_STATIC_INL void glMatrixMode (GL_MATRIX_MODE_ENUM mode)
 change the current matrix mode
GBATEK http://nocash.emubase.de/gbatek.htm#ds3dmatrixloadmultiply

GL_STATIC_INL void glViewport (uint8 x1, uint8 y1, uint8 x2, uint8 y2)
 specify the viewport for following drawing, can be set several times per frame.
GBATEK http://nocash.emubase.de/gbatek.htm#ds3ddisplaycontrol
GL_STATIC_INL void glFlush (uint32 mode)
 Waits for a Vblank and swaps the buffers(like swiWaitForVBlank), but lets you specify some 3D options
GBATEK http://nocash.emubase.de/gbatek.htm#ds3ddisplaycontrol.
GL_STATIC_INL void glMaterialShinyness (void)
 The DS uses a table for shinyness..this generates a half-ass one.
GL_STATIC_INL void glCallList (const u32 *list)
 throws a packed list of commands into the graphics FIFO via asyncronous DMA
The first 32bits is the length of the packed command list, followed by a the packed list.
If you want to do this really fast then write your own code that that does this synchronously and only flushes the cache when the list is changed
There is sometimes a problem when you pack the GFX_END command into a list, so don't. GFX_END is a dummy command and never needs called
GBATEK http://nocash.emubase.de/gbatek.htm#ds3dgeometrycommands
GL_STATIC_INL void glPolyFmt (uint32 params)
 Set the parameters for polygons rendered on the current frame
GBATEK http://nocash.emubase.de/gbatek.htm#ds3dpolygonattributes.
GL_STATIC_INL void glEnable (int bits)
 Enables various gl states (blend, alpha test, etc..).
GL_STATIC_INL void glDisable (int bits)
 Disables various gl states (blend, alpha test, etc..).
GL_STATIC_INL void glLoadMatrix4x4 (const m4x4 *m)
 Loads a 4x4 matrix into the current matrix.
GL_STATIC_INL void glLoadMatrix4x3 (const m4x3 *m)
 Loads a 4x3 matrix into the current matrix.
GL_STATIC_INL void glMultMatrix4x4 (const m4x4 *m)
 Multiplies the current matrix by m.
GL_STATIC_INL void glMultMatrix4x3 (const m4x3 *m)
 multiplies the current matrix by
GL_STATIC_INL void glMultMatrix3x3 (const m3x3 *m)
 multiplies the current matrix by m
GL_STATIC_INL void glRotateXi (int angle)
 Rotates the current modelview matrix by angle about the x axis.
GL_STATIC_INL void glRotateYi (int angle)
 Rotates the current modelview matrix by angle about the y axis.
GL_STATIC_INL void glRotateZi (int angle)
 Rotates the current modelview matrix by angle about the z axis.
GL_STATIC_INL void glOrthof32 (int32 left, int32 right, int32 bottom, int32 top, int32 zNear, int32 zFar)
 Multiplies the current matrix into ortho graphic mode.
GL_STATIC_INL void gluLookAtf32 (int32 eyex, int32 eyey, int32 eyez, int32 lookAtx, int32 lookAty, int32 lookAtz, int32 upx, int32 upy, int32 upz)
 Places the camera at the specified location and orientation (fixed point version).
GL_STATIC_INL void glFrustumf32 (int32 left, int32 right, int32 bottom, int32 top, int32 near, int32 far)
 Specifies the viewing frustum for the projection matrix (fixed point version).
GL_STATIC_INL void gluPerspectivef32 (int fovy, int32 aspect, int32 zNear, int32 zFar)
 Utility function which sets up the projection matrix (fixed point version).
GL_STATIC_INL void gluPickMatrix (int x, int y, int width, int height, const int viewport[4])
 Utility function which generates a picking matrix for selection.
GL_STATIC_INL void glResetMatrixStack (void)
 Resets matrix stack to top level.
GL_STATIC_INL void glSetOutlineColor (int id, rgb color)
 Specifies an edge color for polygons.
GL_STATIC_INL void glSetToonTable (const uint16 *table)
 Loads a toon table.
GL_STATIC_INL void glSetToonTableRange (int start, int end, rgb color)
 Sets a range of colors on the toon table.
GL_STATIC_INL void glGetFixed (const GL_GET_ENUM param, int32 *f)
 Grabs fixed format of state variables
OpenGL's modelview matrix is handled on the DS with two matrices. The combination of the DS's position matrix and directional vector matrix hold the data that is in OpenGL's one modelview matrix. (a.k.a. modelview = postion and vector)
http://nocash.emubase.de/gbatek.htm#ds3diomap.
GL_STATIC_INL void glAlphaFunc (int alphaThreshold)
 set the minimum alpha value that will be used
GBATEK http://nocash.emubase.de/gbatek.htm#ds3ddisplaycontrol
GL_STATIC_INL void glCutoffDepth (fixed12d3 wVal)
 Stop the drawing of polygons that are a certain distance from the camera.
GBATEK http://nocash.emubase.de/gbatek.htm#ds3ddisplaycontrol.
GL_STATIC_INL void glInit ()
 Initializes the gl state machine (must be called once before using gl calls).
GL_STATIC_INL void glClearColor (uint8 red, uint8 green, uint8 blue, uint8 alpha)
 sets the color of the rear-plane(a.k.a Clear Color/Plane)
GL_STATIC_INL void glClearPolyID (uint8 ID)
 sets the polygon ID of the rear-plane(a.k.a. Clear/Color Plane), useful for antialiasing and edge coloring
GL_STATIC_INL void glGetInt (GL_GET_ENUM param, int *i)
 Grabs integer state variables from openGL.
GL_STATIC_INL void glVertex3f (float x, float y, float z)
 specifies a vertex location
GL_STATIC_INL void glRotatef32 (float angle, int32 x, int32 y, int32 z)
 Rotate on an arbitrary axis.
GL_STATIC_INL void glRotatef (float angle, float x, float y, float z)
 Rotate about an arbitrary axis.
GL_STATIC_INL void glColor3f (float r, float g, float b)
 specify a color for following vertices
GL_STATIC_INL void glScalef (float x, float y, float z)
 multiply the current matrix by a scale matrix
GBATEK http://nocash.emubase.de/gbatek.htm#ds3dmatrixloadmultiply
GL_STATIC_INL void glTranslatef (float x, float y, float z)
 multiply the current matrix by a translation matrix
GBATEK http://nocash.emubase.de/gbatek.htm#ds3dmatrixloadmultiply
GL_STATIC_INL void glNormal3f (float x, float y, float z)
 the normal to use for following vertices
GBATEK http://nocash.emubase.de/gbatek.htm#ds3dpolygonlightparameters
GL_STATIC_INL void glRotateX (float angle)
 Rotates the current modelview matrix by angle degrees about the x axis.
GL_STATIC_INL void glRotateY (float angle)
 Rotates the current modelview matrix by angle degrees about the y axis.
GL_STATIC_INL void glRotateZ (float angle)
 Rotates the current modelview matrix by angle degrees about the z axis.
GL_STATIC_INL void glOrtho (float left, float right, float bottom, float top, float zNear, float zFar)
 Multiplies the current matrix into ortho graphic mode.
GL_STATIC_INL void gluLookAt (float eyex, float eyey, float eyez, float lookAtx, float lookAty, float lookAtz, float upx, float upy, float upz)
 Places the camera at the specified location and orientation (floating point version).
GL_STATIC_INL void glFrustum (float left, float right, float bottom, float top, float near, float far)
 Specifies the viewing frustum for the projection matrix (floating point version).
GL_STATIC_INL void gluPerspective (float fovy, float aspect, float zNear, float zFar)
 Utility function which sets up the projection matrix (floating point version).
GL_STATIC_INL void glTexCoord2f (float s, float t)
 Sets texture coordinates for following vertices
GBATEK http://nocash.emubase.de/gbatek.htm#ds3dtextureattributes.

Variables

static gl_hidden_globalsglGlob = 0


Detailed Description

openGL (ish) interface to DS 3D hardware.


Define Documentation

#define f32tofloat (  )     (((float)(n)) / (float)(1<<12))

convert f32 to float

#define f32toint (  )     ((n) >> 12)

convert f32 to int

#define f32tot16 (  )     ((t16)(n >> 8))

convert f32 to t16

#define f32tov10 (  )     ((v10)(n >> 3))

convert f32 to v10

#define f32tov16 (  )     (n)

f32 to v16

#define FIFO_BEGIN   REG2ID(GFX_BEGIN)

packed command that starts a polygon vertex list
GBATEK http://nocash.emubase.de/gbatek.htm#ds3dpolygondefinitionsbyvertices

#define FIFO_CLEAR_COLOR   REG2ID(GFX_CLEAR_COLOR)

packed command for clear color of the rear plane
GBATEK http://nocash.emubase.de/gbatek.htm#ds3drearplane

#define FIFO_CLEAR_DEPTH   REG2ID(GFX_CLEAR_DEPTH)

sets depth of the rear plane
GBATEK http://nocash.emubase.de/gbatek.htm#ds3drearplane

#define FIFO_COLOR   REG2ID(GFX_COLOR)

packed command for vertex color directly
GBATEK http://nocash.emubase.de/gbatek.htm#ds3dpolygonattributes

#define FIFO_COMMAND_PACK ( c1,
c2,
c3,
c4   )     (((c4) << 24) | ((c3) << 16) | ((c2) << 8) | (c1))

packs four packed commands into a 32bit command for sending to the GFX FIFO

#define FIFO_DIFFUSE_AMBIENT   REG2ID(GFX_DIFFUSE_AMBIENT)

packed command for setting diffuse and ambient material properties for the following vertices
GBATEK http://nocash.emubase.de/gbatek.htm#ds3dpolygonlightparameters

#define FIFO_END   REG2ID(GFX_END)

packed command that has no discernable effect, it's probably best to never use it since it bloats the size of the list.
GBATEK http://nocash.emubase.de/gbatek.htm#ds3dpolygondefinitionsbyvertices

#define FIFO_FLUSH   REG2ID(GFX_FLUSH)

packed command that has the same effect as swiWaitForVBlank()
GBATEK http://nocash.emubase.de/gbatek.htm#ds3ddisplaycontrol

#define FIFO_LIGHT_COLOR   REG2ID(GFX_LIGHT_COLOR)

packed command for color for a light
GBATEK http://nocash.emubase.de/gbatek.htm#ds3dpolygonlightparameters

#define FIFO_LIGHT_VECTOR   REG2ID(GFX_LIGHT_VECTOR)

packed command for direction of a light source
GBATEK http://nocash.emubase.de/gbatek.htm#ds3dpolygonlightparameters

#define FIFO_NOP   REG2ID(GFX_FIFO)

packed command for nothing, just here to pad your command lists

#define FIFO_NORMAL   REG2ID(GFX_NORMAL)

packed command for normal for following vertices
GBATEK http://nocash.emubase.de/gbatek.htm#ds3dpolygonlightparameters

#define FIFO_PAL_FORMAT   REG2ID(GFX_PAL_FORMAT)

packed command for texture palette attributes
GBATEK http://nocash.emubase.de/gbatek.htm#ds3dtextureattributes

#define FIFO_POLY_FORMAT   REG2ID(GFX_POLY_FORMAT)

packed command for setting polygon attributes
GBATEK http://nocash.emubase.de/gbatek.htm#ds3dpolygonattributes

#define FIFO_SHININESS   REG2ID(GFX_SHININESS)

packed command for setting the shininess table to be used for the following vertices
GBATEK http://nocash.emubase.de/gbatek.htm#ds3dpolygonlightparameters

#define FIFO_SPECULAR_EMISSION   REG2ID(GFX_SPECULAR_EMISSION)

packed command for setting specular and emmissive material properties for the following vertices
GBATEK http://nocash.emubase.de/gbatek.htm#ds3dpolygonlightparameters

#define FIFO_STATUS   REG2ID(GFX_STATUS)

packed command for geometry engine status register
GBATEK http://nocash.emubase.de/gbatek.htm#ds3dstatus

#define FIFO_TEX_COORD   REG2ID(GFX_TEX_COORD)

packed command for a texture coordinate
GBATEK http://nocash.emubase.de/gbatek.htm#ds3dtexturecoordinates

#define FIFO_TEX_FORMAT   REG2ID(GFX_TEX_FORMAT)

packed command for texture format
GBATEK http://nocash.emubase.de/gbatek.htm#ds3dtextureformats

#define FIFO_VERTEX16   REG2ID(GFX_VERTEX16)

packed command for a vertex with 3 16bit paramaters(and 16bits of padding)
GBATEK http://nocash.emubase.de/gbatek.htm#ds3dpolygondefinitionsbyvertices

#define FIFO_VIEWPORT   REG2ID(GFX_VIEWPORT)

packed command for setting viewport
GBATEK http://nocash.emubase.de/gbatek.htm#ds3ddisplaycontrol

#define float_to_12d3 (  )     ((fixed12d3)((n) * (1 << 3)))

convert float to fixed12d3

#define floattof32 (  )     ((int32)((n) * (1 << 12)))

convert float to f32

#define floattot16 (  )     ((t16)((n) * (1 << 4)))

convert float to t16

#define floattov10 (  )     ((n>.998) ? 0x1FF : ((v10)((n)*(1<<9))))

convert float to v10

#define floattov16 (  )     ((v16)((n) * (1 << 12)))

convert float to v16

#define GL_FALSE   0

#define GL_MAX_DEPTH   0x7FFF

the maximum value for type fixed12d3

#define GL_STATIC_INL   static inline

#define GL_TRUE   1

#define int_to_12d3 (  )     ((n) << 3)

convert int to fixed12d3

#define inttof32 (  )     ((n) << 12)

convert int to f32

#define inttot16 (  )     ((n) << 4)

convert int to t16

#define inttov10 (  )     ((n) << 9)

convert int to v10

#define inttov16 (  )     ((n) << 12)

convert int to v16

#define LUT_MASK   (0x1FF)

#define LUT_SIZE   (512)

#define MAX_TEXTURES   2048

#define NORMAL_PACK ( x,
y,
 )     (((x) & 0x3FF) | (((y) & 0x3FF) << 10) | ((z) << 20))

Pack 3 v10 normals into a 32bit value.

#define REG2ID (  )     (u8)( ( ((u32)(&(r)))-0x04000400 ) >> 2 )

converts a GFX command for use in a packed command list

#define t16toint (  )     ((n) >> 4)

convert t16 to int

#define TEXTURE_PACK ( u,
 )     ((u & 0xFFFF) | ((v) << 16))

Pack 2 t16 texture coordinate values into a 32bit value.

#define v10toint (  )     ((n) >> 9)

convert v10 to int

#define v16toint (  )     ((n) >> 12)

convert v16 to int

#define VERTEX_PACK ( x,
 )     (((x) & 0xFFFF) | ((y) << 16))

Pack to v16 values into one 32bit value.


Typedef Documentation

typedef uint16 fixed12d3

Used for depth (glClearDepth, glCutoffDepth).

typedef unsigned short rgb

Holds a color value. 1bit alpha, 5bits red, 5bits green, 5bits blue.

typedef short int t16

text coordinate 12.4 fixed point

typedef short int v10

normal .10 fixed point, NOT USED FOR 10bit VERTEXES!!!

typedef short int v16

vertex 4.12 fixed format


Enumeration Type Documentation

enum DISP3DCNT_ENUM

3D Display Control Register Enums
GBATEK http://nocash.emubase.de/gbatek.htm#ds3ddisplaycontrol
related functions: glEnable(), glDisable(), glInit()

Enumerator:
GL_TEXTURE_2D  enable/disable textures on the geometry engine
GL_TOON_HIGHLIGHT  enable = Highlight shading; disable = Toon shading
GL_ALPHA_TEST  whether to use the alpha threshold set in glAlphaFunc()
GL_BLEND  enable/disable alpha blending
GL_ANTIALIAS  nable/disable edge antialiasing; polygons must have different polygon IDs for the effect to work and the rear plane must be clear
GL_OUTLINE  enable/disable edge coloring; the high 3bits of the polygon ID determine the color; glSetOutlineColor() sets the available colors
GL_FOG_ONLY_ALPHA  enable = fade into background?; disable = don't fade?
GL_FOG  enables/disables fog
GL_COLOR_UNDERFLOW  enable = color buffer underflow, setting resets overflow flag; disable = no color buffer overflow
GL_POLY_OVERFLOW  enable = polygon/vertex buffer overflow, setting resets overflow flag; disable = no polygon/vertex buffer overflow
GL_CLEAR_BMP  rear/clear plane is in BMP mode; disable = rear/color plane is in clear mode
00237                     {
00238         GL_TEXTURE_2D      = (1<<0),  
00239         GL_TOON_HIGHLIGHT  = (1<<1),  
00240         GL_ALPHA_TEST      = (1<<2),  
00241         GL_BLEND           = (1<<3),  
00242         GL_ANTIALIAS       = (1<<4),  
00243         GL_OUTLINE         = (1<<5),  
00244         GL_FOG_ONLY_ALPHA  = (1<<6),  
00245         GL_FOG             = (1<<7),  
00246         GL_COLOR_UNDERFLOW = (1<<12), 
00247         GL_POLY_OVERFLOW   = (1<<13), 
00248         GL_CLEAR_BMP       = (1<<14)  
00249 };

enum GL_GET_ENUM

Enums for reading stuff from the geometry engine
http://nocash.emubase.de/gbatek.htm#ds3diomap
related functions: glGetInt(), glGetFixed().

Enumerator:
GL_GET_VERTEX_RAM_COUNT  returns a count of vertexes currently stored in hardware vertex ram. Use glGetInt() to retrieve
GL_GET_POLYGON_RAM_COUNT  returns a count of polygons currently stored in hardware polygon ram. Use glGetInt() to retrieve
GL_GET_MATRIX_VECTOR  returns the current 3x3 directional vector matrix. Use glGetFixed() to retrieve
GL_GET_MATRIX_POSITION  returns the current 4x4 position matrix. Use glGetFixed() to retrieve
GL_GET_MATRIX_PROJECTION  returns the current 4x4 projection matrix. Use glGetFixed() to retrieve
GL_GET_MATRIX_CLIP  returns the current 4x4 clip matrix. Use glGetFixed() to retrieve
GL_GET_TEXTURE_WIDTH  returns the width of the currently bound texture. Use glGetInt() to retrieve
GL_GET_TEXTURE_HEIGHT  returns the height of the currently bound texture. Use glGetInt() to retrieve

enum GL_GLBEGIN_ENUM

Enums selecting polygon draw mode
GBATEK http://nocash.emubase.de/gbatek.htm#ds3dpolygondefinitionsbyvertices
related functions: glBegin().

Enumerator:
GL_TRIANGLES  draw triangles with each 3 vertices defining a triangle
GL_QUADS  draw quads with each 4 vertices defining a quad
GL_TRIANGLE_STRIP  draw triangles with the first triangle defined by 3 vertices, then each additional triangle being defined by one additional vertex
GL_QUAD_STRIP  draw quads with the first quad being defined by 4 vertices, then each additional triangle being defined by 2 vertices.
GL_TRIANGLE  same as GL_TRIANGLES, old non-OpenGL version
GL_QUAD  same as GL_QUADS, old non-OpenGL version
00143              {
00144         GL_TRIANGLES      = 0, 
00145         GL_QUADS          = 1, 
00146         GL_TRIANGLE_STRIP = 2, 
00147         GL_QUAD_STRIP     = 3, 
00148         GL_TRIANGLE       = 0, 
00149         GL_QUAD           = 1  
00150 } GL_GLBEGIN_ENUM;

enum GL_MATERIALS_ENUM

Enums for setting up materials
GBATEK http://nocash.emubase.de/gbatek.htm#ds3dpolygonlightparameters
related functions: glMaterialf().

Enumerator:
GL_AMBIENT  sets the ambient color for the material. The color when the normal is not facing light
GL_DIFFUSE  sets the diffuse color for the material. The color when the normal is facing light
GL_AMBIENT_AND_DIFFUSE  sets the set ambient and diffuse colors for the material; just a two-in-one of the above.
GL_SPECULAR  sets the specular color for the material. The glossy(highlight) color of the polygon
GL_SHININESS  sets the shininess color for the material. The color that shines back to the user. I have shiny pants!
GL_EMISSION  sets the emission color for the material. bright color that is indepentant of normals and lights
00165              {
00166         GL_AMBIENT             = 0x01, 
00167         GL_DIFFUSE             = 0x02, 
00168         GL_AMBIENT_AND_DIFFUSE = 0x03, 
00169         GL_SPECULAR            = 0x04, 
00170         GL_SHININESS           = 0x08, 
00171         GL_EMISSION            = 0x10  
00172 } GL_MATERIALS_ENUM;

enum GL_MATRIX_MODE_ENUM

Enums selecting matrix mode
GBATEK http://nocash.emubase.de/gbatek.htm#ds3dmatrixloadmultiply
related functions: glMatrixMode().

Enumerator:
GL_PROJECTION  used to set the Projection Matrix
GL_POSITION  used to set the Position Matrix
GL_MODELVIEW  used to set the Modelview Matrix
GL_TEXTURE  used to set the Texture Matrix
00155              {
00156         GL_PROJECTION     = 0, 
00157         GL_POSITION       = 1, 
00158         GL_MODELVIEW      = 2, 
00159         GL_TEXTURE        = 3  
00160 } GL_MATRIX_MODE_ENUM;

enum GL_POLY_FORMAT_ENUM

Enums for setting how polygons will be displayed
GBATEK http://nocash.emubase.de/gbatek.htm#ds3dpolygonattributes
related functions: glPolyFmt(), glInit(), POLY_ALPHA(), POLY_ID().

Enumerator:
POLY_FORMAT_LIGHT0  enable light number 0
POLY_FORMAT_LIGHT1  enable light number 1
POLY_FORMAT_LIGHT2  enable light number 2
POLY_FORMAT_LIGHT3  enable light number 3
POLY_MODULATION  enable modulation shading mode; this is the default
POLY_DECAL  enable decal shading
POLY_TOON_HIGHLIGHT  enable toon/highlight shading mode
POLY_SHADOW  enable shadow shading
POLY_CULL_FRONT  cull front polygons
POLY_CULL_BACK  cull rear polygons
POLY_CULL_NONE  don't cull any polygons
POLY_FOG  enable/disable fog for this polygon
00177                          {
00178         POLY_FORMAT_LIGHT0   = (1<<0), 
00179         POLY_FORMAT_LIGHT1   = (1<<1), 
00180         POLY_FORMAT_LIGHT2   = (1<<2), 
00181         POLY_FORMAT_LIGHT3   = (1<<3), 
00182         POLY_MODULATION      = (0<<4), 
00183         POLY_DECAL           = (1<<4), 
00184         POLY_TOON_HIGHLIGHT  = (2<<4), 
00185         POLY_SHADOW          = (3<<4), 
00186         POLY_CULL_FRONT      = (1<<6), 
00187         POLY_CULL_BACK       = (2<<6), 
00188         POLY_CULL_NONE       = (3<<6), 
00189         POLY_FOG             = (1<<15) 
00190 };

enum GL_TEXTURE_PARAM_ENUM

Enums for texture parameters, such as texture wrapping and texture coord stuff
GBATEK http://nocash.emubase.de/gbatek.htm#ds3dtextureattributes
related functions: glTexImage2d(), glTexParameter().

Enumerator:
GL_TEXTURE_WRAP_S  wrap(repeat) texture on S axis
GL_TEXTURE_WRAP_T  wrap(repeat) texture on T axis
GL_TEXTURE_FLIP_S  flip texture on S axis when wrapping
GL_TEXTURE_FLIP_T  flip texture on T axis when wrapping
GL_TEXTURE_COLOR0_TRANSPARENT  interpret color 0 as clear, same as old GL_TEXTURE_ALPHA_MASK
TEXGEN_OFF  use unmodified texcoord
TEXGEN_TEXCOORD  multiply texcoords by the texture-matrix
TEXGEN_NORMAL  set texcoords equal to normal * texture-matrix, used for spherical reflection mapping
TEXGEN_POSITION  set texcoords equal to vertex * texture-matrix
00208                            {
00209         GL_TEXTURE_WRAP_S = (1 << 16), 
00210         GL_TEXTURE_WRAP_T = (1 << 17), 
00211         GL_TEXTURE_FLIP_S = (1 << 18), 
00212         GL_TEXTURE_FLIP_T = (1 << 19), 
00213         GL_TEXTURE_COLOR0_TRANSPARENT = (1<<29), 
00214         TEXGEN_OFF      = (0<<30), 
00215         TEXGEN_TEXCOORD = (1<<30), 
00216         TEXGEN_NORMAL   = (2<<30), 
00217         TEXGEN_POSITION = (3<<30)  
00218 };

enum GL_TEXTURE_SIZE_ENUM

Enums for size of a texture, specify one for horizontal and one for vertical related functions: glTexImage2d(), glTexParameter().

Enumerator:
TEXTURE_SIZE_8  8 texels
TEXTURE_SIZE_16  16 texels
TEXTURE_SIZE_32  32 texels
TEXTURE_SIZE_64  64 texels
TEXTURE_SIZE_128  128 texels
TEXTURE_SIZE_256  256 texels
TEXTURE_SIZE_512  512 texels
TEXTURE_SIZE_1024  1024 texels
00194                           {
00195         TEXTURE_SIZE_8    = 0, 
00196         TEXTURE_SIZE_16   = 1, 
00197         TEXTURE_SIZE_32   = 2, 
00198         TEXTURE_SIZE_64   = 3, 
00199         TEXTURE_SIZE_128  = 4, 
00200         TEXTURE_SIZE_256  = 5, 
00201         TEXTURE_SIZE_512  = 6, 
00202         TEXTURE_SIZE_1024 = 7  
00203 };

enum GL_TEXTURE_TYPE_ENUM

Enums for texture formats
GBATEK http://nocash.emubase.de/gbatek.htm#ds3dtextureformats
related functions: glTexImage2d(), glTexParameter().

Enumerator:
GL_RGB32_A3  32 color palette, 3 bits of alpha
GL_RGB4  4 color palette
GL_RGB16  16 color palette
GL_RGB256  256 color palette
GL_COMPRESSED  compressed texture
GL_RGB8_A5  8 color palette, 5 bits of alpha
GL_RGBA  15 bit direct color, 1 bit of alpha
GL_RGB  15 bit direct color, manually sets alpha bit to 1
00223              {
00224         GL_RGB32_A3   = 1, 
00225         GL_RGB4       = 2, 
00226         GL_RGB16      = 3, 
00227         GL_RGB256     = 4, 
00228         GL_COMPRESSED = 5, 
00229         GL_RGB8_A5    = 6, 
00230         GL_RGBA       = 7, 
00231         GL_RGB        = 8  
00232 } GL_TEXTURE_TYPE_ENUM;

enum GLFLUSH_ENUM

Enums for glFlush()
GBATEK http://nocash.emubase.de/gbatek.htm#ds3ddisplaycontrol
related functions: glEnable(), glDisable(), glInit().

Enumerator:
GL_TRANS_MANUALSORT  enable manual sorting of translucent polygons, otherwise uses Y-sorting
GL_WBUFFERING  enable W depth buffering of vertices, otherwise uses Z depth buffering
00269                   {
00270         GL_TRANS_MANUALSORT = (1<<0), 
00271         GL_WBUFFERING       = (1<<1)  
00272 };


Function Documentation

GL_STATIC_INL void glAlphaFunc ( int  alphaThreshold  ) 

set the minimum alpha value that will be used
GBATEK http://nocash.emubase.de/gbatek.htm#ds3ddisplaycontrol

Parameters:
alphaThreshold minimum alpha value that will be used (0-15)
01080 { GFX_ALPHA_TEST = alphaThreshold; }

GL_STATIC_INL void glBegin ( GL_GLBEGIN_ENUM  mode  ) 

Starts a polygon group.

Parameters:
mode the draw mode for the polygon
00470 { GFX_BEGIN = mode; }

void glBindTexture ( int  target,
int  name 
)

glBindTexure sets the current named texture to the active texture. Target is ignored as all DS textures are 2D

Parameters:
target ignored, only here for OpenGL compatability
name the name(int value) to set to the current texture

GL_STATIC_INL void glCallList ( const u32 list  ) 

throws a packed list of commands into the graphics FIFO via asyncronous DMA
The first 32bits is the length of the packed command list, followed by a the packed list.
If you want to do this really fast then write your own code that that does this synchronously and only flushes the cache when the list is changed
There is sometimes a problem when you pack the GFX_END command into a list, so don't. GFX_END is a dummy command and never needs called
GBATEK http://nocash.emubase.de/gbatek.htm#ds3dgeometrycommands

00622                                                {
00623         u32 count = *list++;
00624         
00625         // flush the area that we are going to DMA
00626         DC_FlushRange(list, count*4);
00627         
00628         // don't start DMAing while anything else is being DMAed because FIFO DMA is touchy as hell
00629         //    If anyone can explain this better that would be great. -- gabebear
00630         while((DMA_CR(0) & DMA_BUSY)||(DMA_CR(1) & DMA_BUSY)||(DMA_CR(2) & DMA_BUSY)||(DMA_CR(3) & DMA_BUSY));
00631         
00632         // send the packed list asynchronously via DMA to the FIFO
00633         DMA_SRC(0) = (uint32)list;
00634         DMA_DEST(0) = 0x4000400;
00635         DMA_CR(0) = DMA_FIFO | count;
00636         while(DMA_CR(0) & DMA_BUSY);
00637 }

GL_STATIC_INL void glClearColor ( uint8  red,
uint8  green,
uint8  blue,
uint8  alpha 
)

sets the color of the rear-plane(a.k.a Clear Color/Plane)

Parameters:
red component (0-31)
green component (0-31)
blue component (0-31)
alpha from 0(clear) to 31(opaque)
01098                                                                                  {
01099         GFX_CLEAR_COLOR = glGlob->clearColor = ( glGlob->clearColor & 0xFFE08000) | (0x7FFF & RGB15(red, green, blue)) | ((alpha & 0x1F) << 16);
01100 }

GL_STATIC_INL void glClearDepth ( fixed12d3  depth  ) 

reset the depth buffer to this value; generally set this to GL_MAX_DEPTH.
GBATEK http://nocash.emubase.de/gbatek.htm#ds3drearplane

Parameters:
depth Something to do with the depth buffer, generally set to GL_MAX_DEPTH
00478 { GFX_CLEAR_DEPTH = depth; }

GL_STATIC_INL void glClearPolyID ( uint8  ID  ) 

sets the polygon ID of the rear-plane(a.k.a. Clear/Color Plane), useful for antialiasing and edge coloring

Parameters:
ID the polygon ID to give the rear-plane
01104                                            {
01105         GFX_CLEAR_COLOR = glGlob->clearColor = ( glGlob->clearColor & 0xC0FFFFFF) | (( ID & 0x3F ) << 24 );
01106 }

GL_STATIC_INL void glColor ( rgb  color  ) 

Set the color for following vertices.

Parameters:
color the 15bit color value
00489 { GFX_COLOR = (vuint32)color; }

GL_STATIC_INL void glColor3b ( uint8  red,
uint8  green,
uint8  blue 
)

Set the color for following vertices.

Parameters:
red the red component (0-31)
green the green component (0-31)
blue the blue component (0-31)
00485 { GFX_COLOR = (vuint32)RGB15(red>>3, green>>3, blue>>3); }

GL_STATIC_INL void glColor3f ( float  r,
float  g,
float  b 
)

specify a color for following vertices

Warning:
FLOAT VERSION!!!! please use glColor3b()
Parameters:
r the red component of the color
g the green component of the color
b the blue component of the color
01171                                                         {
01172         glColor3b((uint8)(r*255), (uint8)(g*255), (uint8)(b*255));
01173 }

void glColorTable ( uint8  format,
uint32  addr 
)

glColorTable establishes the location of the current palette. Roughly follows glColorTableEXT. Association of palettes with named textures is left to the application.

GL_STATIC_INL void glCutoffDepth ( fixed12d3  wVal  ) 

Stop the drawing of polygons that are a certain distance from the camera.
GBATEK http://nocash.emubase.de/gbatek.htm#ds3ddisplaycontrol.

Parameters:
polygons that are beyond this W-value(distance from camera) will not be drawn; 15bit value.
01085 { GFX_CUTOFF_DEPTH = wVal; }

GL_STATIC_INL void glDisable ( int  bits  ) 

Disables various gl states (blend, alpha test, etc..).

Parameters:
bits bit mask of desired attributes, attributes are enumerated in DISP3DCNT_ENUM
00650 { GFX_CONTROL &= ~bits; }

GL_STATIC_INL void glEnable ( int  bits  ) 

Enables various gl states (blend, alpha test, etc..).

Parameters:
bits bit mask of desired attributes, attributes are enumerated in DISP3DCNT_ENUM
00646 { GFX_CONTROL |= bits; }

GL_STATIC_INL void glEnd ( void   ) 

Ends a polygon group, this seems to be a dummy function that does absolutely nothing, feel free to never use it.

00473 { GFX_END = 0; }

GL_STATIC_INL void glFlush ( uint32  mode  ) 

Waits for a Vblank and swaps the buffers(like swiWaitForVBlank), but lets you specify some 3D options
GBATEK http://nocash.emubase.de/gbatek.htm#ds3ddisplaycontrol.

Parameters:
mode flags from GLFLUSH_ENUM for enabling Y-sorting of translucent polygons and W-Buffering of all vertices
00601 { GFX_FLUSH = mode; }

GL_STATIC_INL void glFrustum ( float  left,
float  right,
float  bottom,
float  top,
float  near,
float  far 
)

Specifies the viewing frustum for the projection matrix (floating point version).

Warning:
FLOAT VERSION!!!! please use glFrustumf32()
Parameters:
left left right top and bottom describe a rectangle located at the near clipping plane
right left right top and bottom describe a rectangle located at the near clipping plane
top left right top and bottom describe a rectangle located at the near clipping plane
bottom left right top and bottom describe a rectangle located at the near clipping plane
near Location of a the near clipping plane (parallel to viewing window)
far Location of a the far clipping plane (parallel to viewing window)
01269                                                                                                       {
01270         glFrustumf32(floattof32(left), floattof32(right), floattof32(bottom), floattof32(top), floattof32(near), floattof32(far));
01271 }

GL_STATIC_INL void glFrustumf32 ( int32  left,
int32  right,
int32  bottom,
int32  top,
int32  near,
int32  far 
)

Specifies the viewing frustum for the projection matrix (fixed point version).

Parameters:
left left right top and bottom describe a rectangle located at the near clipping plane
right left right top and bottom describe a rectangle located at the near clipping plane
top left right top and bottom describe a rectangle located at the near clipping plane
bottom left right top and bottom describe a rectangle located at the near clipping plane
near Location of a the near clipping plane (parallel to viewing window)
far Location of a the far clipping plane (parallel to viewing window)
00905                                                                                                          {
00906 /*      MATRIX_MULT4x4 = divf32(2*near, right - left);
00907         MATRIX_MULT4x4 = 0;
00908         MATRIX_MULT4x4 = divf32(right + left, right - left);
00909         MATRIX_MULT4x4 = 0;
00910         
00911         MATRIX_MULT4x4 = 0;
00912         MATRIX_MULT4x4 = divf32(2*near, top - bottom);
00913         MATRIX_MULT4x4 = divf32(top + bottom, top - bottom);
00914         MATRIX_MULT4x4 = 0;
00915         
00916         MATRIX_MULT4x4 = 0;
00917         MATRIX_MULT4x4 = 0;
00918         MATRIX_MULT4x4 = -divf32(far + near, far - near);
00919         MATRIX_MULT4x4 = floattof32(-1.0F);
00920         MATRIX_MULT4x4 = 0;
00921         
00922         MATRIX_MULT4x4 = 0;
00923         MATRIX_MULT4x4 = -divf32(2 * mulf32(far, near), far - near);
00924         MATRIX_MULT4x4 = 0;
00925 */
00926 
00927 
00928         MATRIX_MULT4x4 = divf32(2*near, right - left);
00929         MATRIX_MULT4x4 = 0;
00930         MATRIX_MULT4x4 = 0;
00931         MATRIX_MULT4x4 = 0;
00932  
00933         MATRIX_MULT4x4 = 0;
00934         MATRIX_MULT4x4 = divf32(2*near, top - bottom);
00935         MATRIX_MULT4x4 = 0;
00936         MATRIX_MULT4x4 = 0;
00937  
00938         MATRIX_MULT4x4 = divf32(right + left, right - left);
00939         MATRIX_MULT4x4 = divf32(top + bottom, top - bottom);
00940         MATRIX_MULT4x4 = -divf32(far + near, far - near);
00941         MATRIX_MULT4x4 = floattof32(-1.0F);
00942  
00943         MATRIX_MULT4x4 = 0;
00944         MATRIX_MULT4x4 = 0;
00945         MATRIX_MULT4x4 = -divf32(2 * mulf32(far, near), far - near);
00946         MATRIX_MULT4x4 = 0;
00947 
00948 }

int glGenTextures ( int  n,
int *  names 
)

Creates room for the specified number of textures.

Parameters:
n the number of textures to generate
names pointer to the names array to fill

GL_STATIC_INL void glGetFixed ( const GL_GET_ENUM  param,
int32 f 
)

Grabs fixed format of state variables
OpenGL's modelview matrix is handled on the DS with two matrices. The combination of the DS's position matrix and directional vector matrix hold the data that is in OpenGL's one modelview matrix. (a.k.a. modelview = postion and vector)
http://nocash.emubase.de/gbatek.htm#ds3diomap.

Parameters:
param The state variable to retrieve
f pointer with room to hold the requested data
01045                                                                  {
01046         int i;
01047         switch (param) {
01048                 case GL_GET_MATRIX_VECTOR:
01049                         while(GFX_BUSY); // wait until the graphics engine has stopped to read matrixes
01050                         for(i = 0; i < 9; i++) f[i] = MATRIX_READ_VECTOR[i];
01051                         break;
01052                 case GL_GET_MATRIX_CLIP:
01053                         while(GFX_BUSY); // wait until the graphics engine has stopped to read matrixes
01054                         for(i = 0; i < 16; i++) f[i] = MATRIX_READ_CLIP[i];
01055                         break;
01056                 case GL_GET_MATRIX_PROJECTION:
01057                         glMatrixMode(GL_POSITION);
01058                         glPushMatrix(); // save the current state of the position matrix
01059                         glLoadIdentity(); // load an identity matrix into the position matrix so that the clip matrix = projection matrix
01060                         while(GFX_BUSY); // wait until the graphics engine has stopped to read matrixes
01061                                 for(i = 0; i < 16; i++) f[i] = MATRIX_READ_CLIP[i]; // read out the projection matrix
01062                         glPopMatrix(1); // restore the position matrix
01063                         break;
01064                 case GL_GET_MATRIX_POSITION:
01065                         glMatrixMode(GL_PROJECTION);
01066                         glPushMatrix(); // save the current state of the projection matrix
01067                         glLoadIdentity(); // load a identity matrix into the projection matrix so that the clip matrix = position matrix
01068                         while(GFX_BUSY); // wait until the graphics engine has stopped to read matrixes
01069                                 for(i = 0; i < 16; i++) f[i] = MATRIX_READ_CLIP[i]; // read out the position matrix
01070                         glPopMatrix(1); // restore the projection matrix
01071                         break;
01072                 default: 
01073                         break;
01074         }
01075 }

gl_hidden_globals* glGetGlobals (  ) 

GL_STATIC_INL void glGetInt ( GL_GET_ENUM  param,
int *  i 
)

Grabs integer state variables from openGL.

Parameters:
param The state variable to retrieve
i pointer with room to hold the requested data
01111                                                        {
01112         switch (param) {
01113                 case GL_GET_POLYGON_RAM_COUNT:
01114                         *i = GFX_POLYGON_RAM_USAGE;
01115                         break;
01116                 case GL_GET_VERTEX_RAM_COUNT:
01117                         *i = GFX_VERTEX_RAM_USAGE;
01118                         break;
01119                 case GL_GET_TEXTURE_WIDTH:
01120                         *i = 8 << (((glGlob->textures[glGlob->activeTexture]) >> 20) & 7);
01121                         break;
01122                 case GL_GET_TEXTURE_HEIGHT:
01123                         *i = 8 << (((glGlob->textures[glGlob->activeTexture]) >> 23) & 7);
01124                         break;
01125                 default:
01126                         break;
01127         }
01128 }

u32 glGetTexParameter (  ) 

Returns the active texture parameter (constructed from internal call to glTexParameter).

void* glGetTexturePointer ( int  name  ) 

returns the address alocated to the texure named by name

Parameters:
name the name of the texture to get a pointer to

GL_STATIC_INL void glInit (  ) 

Initializes the gl state machine (must be called once before using gl calls).

01088                             {
01089         glGlob = glGetGlobals(); // make sure globals are synced between compilation units
01090         glInit_C(); // actually does the initialization
01091 }

void glInit_C ( void   ) 

GL_STATIC_INL void glLight ( int  id,
rgb  color,
v10  x,
v10  y,
v10  z 
)

set a light up. Only parallel light sources are supported on the DS
GBATEK http://nocash.emubase.de/gbatek.htm#ds3dpolygonlightparameters

Parameters:
id the number of the light to setup
color the color of the light
x the x component of the lights directional vector. Direction must be normalized
y the y component of the lights directional vector. Direction must be normalized
z the z component of the lights directional vector. Direction must be normalized
00570                                                                    {
00571         id = (id & 3) << 30;
00572         GFX_LIGHT_VECTOR = id | ((z & 0x3FF) << 20) | ((y & 0x3FF) << 10) | (x & 0x3FF);
00573         GFX_LIGHT_COLOR = id | color;
00574 }

GL_STATIC_INL void glLoadIdentity ( void   ) 

loads an identity matrix to the current matrix, same as glIdentity(void)

00583 { MATRIX_IDENTITY = 0; }

GL_STATIC_INL void glLoadMatrix4x3 ( const m4x3 m  ) 

Loads a 4x3 matrix into the current matrix.

Parameters:
m pointer to a 4x4 matrix
00678                                                    {
00679         MATRIX_LOAD4x3 = m->m[0];
00680         MATRIX_LOAD4x3 = m->m[1];
00681         MATRIX_LOAD4x3 = m->m[2];
00682         MATRIX_LOAD4x3 = m->m[3];
00683         
00684         MATRIX_LOAD4x3 = m->m[4];
00685         MATRIX_LOAD4x3 = m->m[5];
00686         MATRIX_LOAD4x3 = m->m[6];
00687         MATRIX_LOAD4x3 = m->m[7];
00688         
00689         MATRIX_LOAD4x3 = m->m[8];
00690         MATRIX_LOAD4x3 = m->m[9];
00691         MATRIX_LOAD4x3 = m->m[10];
00692         MATRIX_LOAD4x3 = m->m[11];
00693 }

GL_STATIC_INL void glLoadMatrix4x4 ( const m4x4 m  ) 

Loads a 4x4 matrix into the current matrix.

Parameters:
m pointer to a 4x4 matrix
00654                                                   {
00655         MATRIX_LOAD4x4 = m->m[0];
00656         MATRIX_LOAD4x4 = m->m[1];
00657         MATRIX_LOAD4x4 = m->m[2];
00658         MATRIX_LOAD4x4 = m->m[3];
00659         
00660         MATRIX_LOAD4x4 = m->m[4];
00661         MATRIX_LOAD4x4 = m->m[5];
00662         MATRIX_LOAD4x4 = m->m[6];
00663         MATRIX_LOAD4x4 = m->m[7];
00664         
00665         MATRIX_LOAD4x4 = m->m[8];
00666         MATRIX_LOAD4x4 = m->m[9];
00667         MATRIX_LOAD4x4 = m->m[10];
00668         MATRIX_LOAD4x4 = m->m[11];
00669         
00670         MATRIX_LOAD4x4 = m->m[12];
00671         MATRIX_LOAD4x4 = m->m[13];
00672         MATRIX_LOAD4x4 = m->m[14];
00673         MATRIX_LOAD4x4 = m->m[15];
00674 }

void glMaterialf ( GL_MATERIALS_ENUM  mode,
rgb  color 
)

specify the material properties to be used in rendering lit polygons

Parameters:
mode which material property to change
color the color to set for that material property

GL_STATIC_INL void glMaterialShinyness ( void   ) 

The DS uses a table for shinyness..this generates a half-ass one.

00604                                              {
00605         uint32 shiny32[128/4];
00606         uint8  *shiny8 = (uint8*)shiny32;
00607         
00608         int i;
00609         
00610         for (i = 0; i < 128 * 2; i += 2)
00611                 shiny8[i>>1] = i;
00612         
00613         for (i = 0; i < 128 / 4; i++)
00614                 GFX_SHININESS = shiny32[i];
00615 }

GL_STATIC_INL void glMatrixMode ( GL_MATRIX_MODE_ENUM  mode  ) 

change the current matrix mode
GBATEK http://nocash.emubase.de/gbatek.htm#ds3dmatrixloadmultiply

Parameters:
mode the mode for the matrix
00588 { MATRIX_CONTROL = mode; }

GL_STATIC_INL void glMultMatrix3x3 ( const m3x3 m  ) 

multiplies the current matrix by m

Parameters:
m pointer to a 3x3 matrix
00741                                                    {
00742         MATRIX_MULT3x3 = m->m[0];
00743         MATRIX_MULT3x3 = m->m[1];
00744         MATRIX_MULT3x3 = m->m[2];
00745         
00746         MATRIX_MULT3x3 = m->m[3];
00747         MATRIX_MULT3x3 = m->m[4];
00748         MATRIX_MULT3x3 = m->m[5];
00749         
00750         MATRIX_MULT3x3 = m->m[6];
00751         MATRIX_MULT3x3 = m->m[7];
00752         MATRIX_MULT3x3 = m->m[8];
00753 }

GL_STATIC_INL void glMultMatrix4x3 ( const m4x3 m  ) 

multiplies the current matrix by

Parameters:
m pointer to a 4x3 matrix
00721                                                    {
00722         MATRIX_MULT4x3 = m->m[0];
00723         MATRIX_MULT4x3 = m->m[1];
00724         MATRIX_MULT4x3 = m->m[2];
00725         MATRIX_MULT4x3 = m->m[3];
00726         
00727         MATRIX_MULT4x3 = m->m[4];
00728         MATRIX_MULT4x3 = m->m[5];
00729         MATRIX_MULT4x3 = m->m[6];
00730         MATRIX_MULT4x3 = m->m[7];
00731         
00732         MATRIX_MULT4x3 = m->m[8];
00733         MATRIX_MULT4x3 = m->m[9];
00734         MATRIX_MULT4x3 = m->m[10];
00735         MATRIX_MULT4x3 = m->m[11];
00736         
00737 }

GL_STATIC_INL void glMultMatrix4x4 ( const m4x4 m  ) 

Multiplies the current matrix by m.

Parameters:
m pointer to a 4x4 matrix
00697                                                    {
00698         MATRIX_MULT4x4 = m->m[0];
00699         MATRIX_MULT4x4 = m->m[1];
00700         MATRIX_MULT4x4 = m->m[2];
00701         MATRIX_MULT4x4 = m->m[3];
00702         
00703         MATRIX_MULT4x4 = m->m[4];
00704         MATRIX_MULT4x4 = m->m[5];
00705         MATRIX_MULT4x4 = m->m[6];
00706         MATRIX_MULT4x4 = m->m[7];
00707         
00708         MATRIX_MULT4x4 = m->m[8];
00709         MATRIX_MULT4x4 = m->m[9];
00710         MATRIX_MULT4x4 = m->m[10];
00711         MATRIX_MULT4x4 = m->m[11];
00712         
00713         MATRIX_MULT4x4 = m->m[12];
00714         MATRIX_MULT4x4 = m->m[13];
00715         MATRIX_MULT4x4 = m->m[14];
00716         MATRIX_MULT4x4 = m->m[15];
00717 }

GL_STATIC_INL void glNormal ( uint32  normal  ) 

the normal to use for following vertices
GBATEK http://nocash.emubase.de/gbatek.htm#ds3dpolygonlightparameters

Warning:
The nature of the format means that you can't represent the following normals exactly (0,0,1), (0,1,0), or (1,0,0)
Parameters:
normal the packed normal(3 * 10bit x, y, z)
00580 { GFX_NORMAL = normal; }

GL_STATIC_INL void glNormal3f ( float  x,
float  y,
float  z 
)

the normal to use for following vertices
GBATEK http://nocash.emubase.de/gbatek.htm#ds3dpolygonlightparameters

Warning:
FLOAT VERSION!!!! please use glNormal()
Parameters:
x x component of the normal, vector must be normalized
y y component of the normal, vector must be normalized
z z component of the normal, vector must be normalized
01205                                                          {
01206         glNormal(NORMAL_PACK(floattov10(x), floattov10(y), floattov10(z)));
01207 }

GL_STATIC_INL void glOrtho ( float  left,
float  right,
float  bottom,
float  top,
float  zNear,
float  zFar 
)

Multiplies the current matrix into ortho graphic mode.

Warning:
FLOAT VERSION!!!! please use glOrthof32()
Parameters:
left left vertical clipping plane
right right vertical clipping plane
bottom bottom vertical clipping plane
top top vertical clipping plane
zNear near clipping plane
zFar far clipping plane
01238                                                                                                       {
01239         glOrthof32(floattof32(left), floattof32(right), floattof32(bottom), floattof32(top), floattof32(zNear), floattof32(zFar));
01240 }

GL_STATIC_INL void glOrthof32 ( int32  left,
int32  right,
int32  bottom,
int32  top,
int32  zNear,
int32  zFar 
)

Multiplies the current matrix into ortho graphic mode.

Parameters:
left left vertical clipping plane
right right vertical clipping plane
bottom bottom vertical clipping plane
top top vertical clipping plane
zNear near clipping plane
zFar far clipping plane
00820                                                                                                          {
00821         MATRIX_MULT4x4 = divf32(inttof32(2), right - left);     
00822         MATRIX_MULT4x4 = 0;  
00823         MATRIX_MULT4x4 = 0;      
00824         MATRIX_MULT4x4 = 0;
00825 
00826         MATRIX_MULT4x4 = 0;  
00827         MATRIX_MULT4x4 = divf32(inttof32(2), top - bottom);     
00828         MATRIX_MULT4x4 = 0;    
00829         MATRIX_MULT4x4 = 0;
00830 
00831         MATRIX_MULT4x4 = 0;  
00832         MATRIX_MULT4x4 = 0;  
00833         MATRIX_MULT4x4 = divf32(inttof32(-2), zFar - zNear);     
00834         MATRIX_MULT4x4 = 0;
00835 
00836         MATRIX_MULT4x4 = -divf32(right + left, right - left);//0;  
00837         MATRIX_MULT4x4 = -divf32(top + bottom, top - bottom); //0;  
00838         MATRIX_MULT4x4 = -divf32(zFar + zNear, zFar - zNear);//0;  
00839         MATRIX_MULT4x4 = floattof32(1.0F);
00840 }

GL_STATIC_INL void glPolyFmt ( uint32  params  ) 

Set the parameters for polygons rendered on the current frame
GBATEK http://nocash.emubase.de/gbatek.htm#ds3dpolygonattributes.

Parameters:
params the paramters to set for the polygons for the current frame. valid paramters are enumerated in GL_POLY_FORMAT_ENUM and in the functions POLY_ALPHA() and POLY_ID()
00642 { GFX_POLY_FORMAT = params; }

GL_STATIC_INL void glPopMatrix ( int32  num  ) 

Pops num matrices off the stack
GBATEK http://nocash.emubase.de/gbatek.htm#ds3dmatrixstack.

Parameters:
num the number to pop down the stack
00513 { MATRIX_POP = num; }

GL_STATIC_INL void glPushMatrix ( void   ) 

Pushs the current matrix onto the stack
GBATEK http://nocash.emubase.de/gbatek.htm#ds3dmatrixstack.

00508 { MATRIX_PUSH = 0; }

GL_STATIC_INL void glResetMatrixStack ( void   ) 

Resets matrix stack to top level.

00992                                             {
00993         // make sure there are no push/pops that haven't executed yet
00994         while(GFX_STATUS & BIT(14)){
00995                 GFX_STATUS |= 1 << 15; // clear push/pop errors or push/pop busy bit never clears
00996         }
00997         
00998         // pop the projection stack to the top; poping 0 off an empty stack causes an error... weird?
00999         if((GFX_STATUS&(1<<13))!=0) {
01000                 glMatrixMode(GL_PROJECTION);
01001                 glPopMatrix(1);
01002         }
01003         
01004         // 31 deep modelview matrix; 32nd entry works but sets error flag
01005         glMatrixMode(GL_MODELVIEW);
01006         glPopMatrix((GFX_STATUS >> 8) & 0x1F);
01007         
01008         // load identity to all the matrices
01009         glMatrixMode(GL_MODELVIEW);
01010         glLoadIdentity();
01011         glMatrixMode(GL_PROJECTION);
01012         glLoadIdentity();
01013         glMatrixMode(GL_TEXTURE);
01014         glLoadIdentity();
01015 }

void glResetTextures ( void   ) 

Resets the gl texture state freeing all texture memory.

GL_STATIC_INL void glRestoreMatrix ( int32  index  ) 

Restores the current matrix from a location in the stack
GBATEK http://nocash.emubase.de/gbatek.htm#ds3dmatrixstack.

Parameters:
index the place in the stack to restore to
00518 { MATRIX_RESTORE = index; }

GL_STATIC_INL void glRotatef ( float  angle,
float  x,
float  y,
float  z 
)

Rotate about an arbitrary axis.

Warning:
FLOAT VERSION!!!! please use glRotatef32i()
Parameters:
angle the angle to rotate by
x the x component of the axis to rotate on
y the y component of the axis to rotate on
z the z component of the axis to rotate on
01162                                                                      {
01163         glRotatef32(angle, floattof32(x), floattof32(y), floattof32(z));
01164 }

GL_STATIC_INL void glRotatef32 ( float  angle,
int32  x,
int32  y,
int32  z 
)

Rotate on an arbitrary axis.

Warning:
FLOAT VERSION!!!! please use glRotatef32i()
Parameters:
angle the angle to rotate by
x the x component of the axis to rotate on
y the y component of the axis to rotate on
z the z component of the axis to rotate on
01152                                                                        {
01153     glRotatef32i((int)(angle * LUT_SIZE / 360.0), x, y, z);
01154 }

void glRotatef32i ( int  angle,
int32  x,
int32  y,
int32  z 
)

Rotates the model view matrix by angle about the specified unit vector.

Parameters:
angle The angle to rotate by
x X component of the unit vector axis.
y Y component of the unit vector axis.
z Z component of the unit vector axis.

GL_STATIC_INL void glRotateX ( float  angle  ) 

Rotates the current modelview matrix by angle degrees about the x axis.

Warning:
FLOAT VERSION!!!! please use glRotateXi()
Parameters:
angle The angle to rotate by
01212                                           {
01213         glRotateXi((int)(angle * LUT_SIZE / 360.0));
01214 }

GL_STATIC_INL void glRotateXi ( int  angle  ) 

Rotates the current modelview matrix by angle about the x axis.

Parameters:
angle The angle to rotate by (angle is 0-511)
00757                                          {
00758         int32 sine = SIN[angle &  LUT_MASK];
00759         int32 cosine = COS[angle & LUT_MASK];
00760         
00761         MATRIX_MULT3x3 = inttof32(1);
00762         MATRIX_MULT3x3 = 0;
00763         MATRIX_MULT3x3 = 0;
00764         
00765         MATRIX_MULT3x3 = 0;
00766         MATRIX_MULT3x3 = cosine;
00767         MATRIX_MULT3x3 = sine;
00768         
00769         MATRIX_MULT3x3 = 0;
00770         MATRIX_MULT3x3 = -sine;
00771         MATRIX_MULT3x3 = cosine;
00772 }

GL_STATIC_INL void glRotateY ( float  angle  ) 

Rotates the current modelview matrix by angle degrees about the y axis.

Warning:
FLOAT VERSION!!!! please use glRotateYi()
Parameters:
angle The angle to rotate by
01219                                           {
01220         glRotateYi((int)(angle * LUT_SIZE / 360.0));
01221 }

GL_STATIC_INL void glRotateYi ( int  angle  ) 

Rotates the current modelview matrix by angle about the y axis.

Parameters:
angle The angle to rotate by (angle is 0-511)
00776                                          {
00777         int32 sine = SIN[angle &  LUT_MASK];
00778         int32 cosine = COS[angle & LUT_MASK];
00779         
00780         MATRIX_MULT3x3 = cosine;
00781         MATRIX_MULT3x3 = 0;
00782         MATRIX_MULT3x3 = -sine;
00783         
00784         MATRIX_MULT3x3 = 0;
00785         MATRIX_MULT3x3 = inttof32(1);
00786         MATRIX_MULT3x3 = 0;
00787         
00788         MATRIX_MULT3x3 = sine;
00789         MATRIX_MULT3x3 = 0;
00790         MATRIX_MULT3x3 = cosine;
00791 }

GL_STATIC_INL void glRotateZ ( float  angle  ) 

Rotates the current modelview matrix by angle degrees about the z axis.

Warning:
FLOAT VERSION!!!! please use glRotateZi()
Parameters:
angle The angle to rotate by
01226                                           {
01227         glRotateZi((int)(angle * LUT_SIZE / 360.0));
01228 }

GL_STATIC_INL void glRotateZi ( int  angle  ) 

Rotates the current modelview matrix by angle about the z axis.

Parameters:
angle The angle to rotate by (angle is 0-511)
00795                                          {
00796         int32 sine = SIN[angle &  LUT_MASK];
00797         int32 cosine = COS[angle & LUT_MASK];
00798         
00799         MATRIX_MULT3x3 = cosine;
00800         MATRIX_MULT3x3 = sine;
00801         MATRIX_MULT3x3 = 0;
00802         
00803         MATRIX_MULT3x3 = - sine;
00804         MATRIX_MULT3x3 = cosine;
00805         MATRIX_MULT3x3 = 0;
00806         
00807         MATRIX_MULT3x3 = 0;
00808         MATRIX_MULT3x3 = 0;
00809         MATRIX_MULT3x3 = inttof32(1);
00810 }

GL_STATIC_INL void glScalef ( float  x,
float  y,
float  z 
)

multiply the current matrix by a scale matrix
GBATEK http://nocash.emubase.de/gbatek.htm#ds3dmatrixloadmultiply

Warning:
FLOAT VERSION!!!! please use glScalev() or glScalef32()
Parameters:
x scaling on the x axis
y scaling on the y axis
z scaling on the z axis
01181                                                        {
01182         MATRIX_SCALE = floattof32(x);
01183         MATRIX_SCALE = floattof32(y);
01184         MATRIX_SCALE = floattof32(z);
01185 }

GL_STATIC_INL void glScalef32 ( int32  factor  ) 

multiply the current matrix by a scale matrix
GBATEK http://nocash.emubase.de/gbatek.htm#ds3dmatrixloadmultiply

Parameters:
factor the factor to scale by
00557                                             {
00558         MATRIX_SCALE = factor;
00559         MATRIX_SCALE = factor;
00560         MATRIX_SCALE = factor;
00561 }

GL_STATIC_INL void glScalev ( const GLvector v  ) 

multiply the current matrix by a translation matrix
GBATEK http://nocash.emubase.de/gbatek.htm#ds3dmatrixloadmultiply

Parameters:
v the vector to translate by
00528                                                { 
00529         MATRIX_SCALE = v->x;
00530         MATRIX_SCALE = v->y;
00531         MATRIX_SCALE = v->z;
00532 }

GL_STATIC_INL void glSetOutlineColor ( int  id,
rgb  color 
)

Specifies an edge color for polygons.

Parameters:
id which outline color to set (0-7)
color the 15bit color to set
01020 { GFX_EDGE_TABLE[id] = color; }

GL_STATIC_INL void glSetToonTable ( const uint16 table  ) 

Loads a toon table.

Parameters:
pointer to the 32 color palette to load into the toon table
01024                                                        {
01025         int i;
01026         for(i = 0; i < 32; i++ )
01027                 GFX_TOON_TABLE[i] = table[i];
01028 }

GL_STATIC_INL void glSetToonTableRange ( int  start,
int  end,
rgb  color 
)

Sets a range of colors on the toon table.

Parameters:
start the start of the range
end the end of the range
color the color to set for that range
01034                                                                       {
01035         int i;
01036         for(i = start; i <= end; i++ )
01037                 GFX_TOON_TABLE[i] = color;
01038 }

GL_STATIC_INL void glStoreMatrix ( int32  index  ) 

Place the current matrix into the stack at a location
GBATEK http://nocash.emubase.de/gbatek.htm#ds3dmatrixstack.

Parameters:
index the place in the stack to put the current matrix
00523 { MATRIX_STORE = index; }

GL_STATIC_INL void glTexCoord2f ( float  s,
float  t 
)

Sets texture coordinates for following vertices
GBATEK http://nocash.emubase.de/gbatek.htm#ds3dtextureattributes.

Warning:
FLOAT VERSION!!!! please use glTexCoord2t16()
Parameters:
s S(a.k.a. U) texture coordinate (0.0 - 1.0)
t T(a.k.a. V) texture coordinate (0.0 - 1.0)
01288                                                   {
01289         int x = ((glGlob->textures[glGlob->activeTexture]) >> 20) & 7; 
01290         int y = ((glGlob->textures[glGlob->activeTexture]) >> 23) & 7; 
01291         
01292         glTexCoord2t16(floattot16(s*(8 << x)), floattot16(t*(8<<y)));
01293 }

void glTexCoord2f32 ( int32  u,
int32  v 
)

Sets texture coordinates for following vertices
GBATEK http://nocash.emubase.de/gbatek.htm#ds3dtextureattributes.

Parameters:
u U(a.k.a. S) texture coordinate (0.0 - 1.0)
v V(a.k.a. T) texture coordinate (0.0 - 1.0)

GL_STATIC_INL void glTexCoord2t16 ( t16  u,
t16  v 
)

Sets texture coordinates for following vertices
GBATEK http://nocash.emubase.de/gbatek.htm#ds3dtextureattributes.

Parameters:
u U(a.k.a. S) texture coordinate in texels
v V(a.k.a. T) texture coordinate in texels
00504 { GFX_TEX_COORD = TEXTURE_PACK(u,v); }

int glTexImage2D ( int  target,
int  empty1,
GL_TEXTURE_TYPE_ENUM  type,
int  sizeX,
int  sizeY,
int  empty2,
int  param,
const uint8 texture 
)

Loads a 2D texture into texture memory and sets the currently bound texture ID to the attributes specified.

Parameters:
target not used, just here for OpenGL compatibility
empty1 not used, just here for OpenGL compatibility
type The format of the texture
sizeX the horizontal size of the texture; valid sizes are enumerated in GL_TEXTURE_TYPE_ENUM
sizeY the vertical size of the texture; valid sizes are enumerated in GL_TEXTURE_TYPE_ENUM
empty2 not used, just here for OpenGL compatibility
param parameters for the texture
texture pointer to the texture data to load

void glTexLoadPal ( const u16 pal,
u16  count,
u32  addr 
)

Loads a palette into the specified texture addr.

Parameters:
pal pointer to the palette to load
count the size of the palette
addr the offset in VRAM to load the palette

void glTexParameter ( uint8  sizeX,
uint8  sizeY,
const uint32 addr,
GL_TEXTURE_TYPE_ENUM  mode,
uint32  param 
)

Set parameters for the current texture. Although named the same as its gl counterpart, it is not compatible. Effort may be made in the future to make it so.

Parameters:
sizeX the horizontal size of the texture; valid sizes are enumerated in GL_TEXTURE_TYPE_ENUM
sizeY the vertical size of the texture; valid sizes are enumerated in GL_TEXTURE_TYPE_ENUM
addr offset into VRAM where you put the texture
mode the type of texture
param paramaters for the texture

GL_STATIC_INL void glTranslate3f32 ( int32  x,
int32  y,
int32  z 
)

multiply the current matrix by a translation matrix
GBATEK http://nocash.emubase.de/gbatek.htm#ds3dmatrixloadmultiply

Parameters:
x translation on the x axis
y translation on the y axis
z translation on the z axis
00548                                                               {
00549         MATRIX_TRANSLATE = x;
00550         MATRIX_TRANSLATE = y;
00551         MATRIX_TRANSLATE = z;
00552 }

GL_STATIC_INL void glTranslatef ( float  x,
float  y,
float  z 
)

multiply the current matrix by a translation matrix
GBATEK http://nocash.emubase.de/gbatek.htm#ds3dmatrixloadmultiply

Warning:
FLOAT VERSION!!!! please use glTranslate3f32()
Parameters:
x translation on the x axis
y translation on the y axis
z translation on the z axis
01193                                                            {
01194         MATRIX_TRANSLATE = floattof32(x);
01195         MATRIX_TRANSLATE = floattof32(y);
01196         MATRIX_TRANSLATE = floattof32(z);
01197 }

GL_STATIC_INL void glTranslatev ( const GLvector v  ) 

multiply the current matrix by a translation matrix
GBATEK http://nocash.emubase.de/gbatek.htm#ds3dmatrixloadmultiply

Parameters:
v the vector to translate by
00537                                                    {
00538         MATRIX_TRANSLATE = v->x;
00539         MATRIX_TRANSLATE = v->y;
00540         MATRIX_TRANSLATE = v->z;
00541 }

GL_STATIC_INL void gluLookAt ( float  eyex,
float  eyey,
float  eyez,
float  lookAtx,
float  lookAty,
float  lookAtz,
float  upx,
float  upy,
float  upz 
)

Places the camera at the specified location and orientation (floating point version).

Warning:
FLOAT VERSION!!!! please use gluLookAtf32()
Parameters:
eyex (eyex, eyey, eyez) Location of the camera.
eyey (eyex, eyey, eyez) Location of the camera.
eyez (eyex, eyey, eyez) Location of the camera.
lookAtx (lookAtx, lookAty, lookAtz) Where the camera is looking.
lookAty (lookAtx, lookAty, lookAtz) Where the camera is looking.
lookAtz (lookAtx, lookAty, lookAtz) Where the camera is looking.
upx <upx, upy, upz> Unit vector describing which direction is up for the camera.
upy <upx, upy, upz> Unit vector describing which direction is up for the camera.
upz <upx, upy, upz> Unit vector describing which direction is up for the camera.
01255                                                                                                  {
01256         gluLookAtf32(floattof32(eyex), floattof32(eyey), floattof32(eyez),
01257                                  floattof32(lookAtx), floattof32(lookAty), floattof32(lookAtz),
01258                                  floattof32(upx), floattof32(upy), floattof32(upz));
01259 }

GL_STATIC_INL void gluLookAtf32 ( int32  eyex,
int32  eyey,
int32  eyez,
int32  lookAtx,
int32  lookAty,
int32  lookAtz,
int32  upx,
int32  upy,
int32  upz 
)

Places the camera at the specified location and orientation (fixed point version).

Parameters:
eyex (eyex, eyey, eyez) Location of the camera.
eyey (eyex, eyey, eyez) Location of the camera.
eyez (eyex, eyey, eyez) Location of the camera.
lookAtx (lookAtx, lookAty, lookAtz) Where the camera is looking.
lookAty (lookAtx, lookAty, lookAtz) Where the camera is looking.
lookAtz (lookAtx, lookAty, lookAtz) Where the camera is looking.
upx <upx, upy, upz> Unit vector describing which direction is up for the camera.
upy <upx, upy, upz> Unit vector describing which direction is up for the camera.
upz <upx, upy, upz> Unit vector describing which direction is up for the camera.
00852                                                                                                                                                   {
00853         int32 side[3], forward[3], up[3], eye[3];
00854         
00855         forward[0] = eyex - lookAtx; 
00856         forward[1] = eyey - lookAty; 
00857         forward[2] = eyez - lookAtz; 
00858         
00859         normalizef32(forward); 
00860         
00861         up[0] = upx; 
00862         up[1] = upy; 
00863         up[2] = upz; 
00864         eye[0] = eyex; 
00865         eye[1] = eyey; 
00866         eye[2] = eyez; 
00867         
00868         crossf32(up, forward, side); 
00869         
00870         normalizef32(side); 
00871         
00872         // Recompute local up
00873         crossf32(forward, side, up);
00874         
00875         glMatrixMode(GL_MODELVIEW); 
00876         
00877         
00878         // should we use MATRIX_MULT4x3? 
00879         MATRIX_MULT4x3 = side[0]; 
00880         MATRIX_MULT4x3 = up[0]; 
00881         MATRIX_MULT4x3 = forward[0]; 
00882         
00883         MATRIX_MULT4x3 = side[1]; 
00884         MATRIX_MULT4x3 = up[1]; 
00885         MATRIX_MULT4x3 = forward[1]; 
00886         
00887         MATRIX_MULT4x3 = side[2]; 
00888         MATRIX_MULT4x3 = up[2]; 
00889         MATRIX_MULT4x3 = forward[2]; 
00890         
00891         MATRIX_MULT4x3 = -dotf32(eye,side); 
00892         MATRIX_MULT4x3 = -dotf32(eye,up); 
00893         MATRIX_MULT4x3 = -dotf32(eye,forward); 
00894         
00895 }

GL_STATIC_INL void gluPerspective ( float  fovy,
float  aspect,
float  zNear,
float  zFar 
)

Utility function which sets up the projection matrix (floating point version).

Warning:
FLOAT VERSION!!!! please use gluPerspectivef32()
Parameters:
fovy Specifies the field of view in degrees
aspect Specifies the aspect ratio of the screen (normally screen width/screen height)
zNear Specifies the near clipping plane
zFar Specifies the far clipping plane
01279                                                                                      {
01280         gluPerspectivef32((int)(fovy * LUT_SIZE / 360.0), floattof32(aspect), floattof32(zNear), floattof32(zFar));    
01281 }

GL_STATIC_INL void gluPerspectivef32 ( int  fovy,
int32  aspect,
int32  zNear,
int32  zFar 
)

Utility function which sets up the projection matrix (fixed point version).

Parameters:
fovy Specifies the field of view in degrees (0 -511)
aspect Specifies the aspect ratio of the screen (normally screen width/screen height)
zNear Specifies the near clipping plane
zFar Specifies the far clipping plane
00955                                                                                       {
00956         int32 xmin, xmax, ymin, ymax;
00957         
00958         ymax = mulf32(zNear, TAN[(fovy>>1) & LUT_MASK]);
00959         ymin = -ymax;
00960         xmin = mulf32(ymin, aspect);
00961         xmax = mulf32(ymax, aspect);
00962         
00963         glFrustumf32(xmin, xmax, ymin, ymax, zNear, zFar);
00964 }

GL_STATIC_INL void gluPickMatrix ( int  x,
int  y,
int  width,
int  height,
const int  viewport[4] 
)

Utility function which generates a picking matrix for selection.

Parameters:
x 2D x of center (touch x normally)
y 2D y of center (touch y normally)
width width in pixels of the window (3 or 4 is a good number)
height height in pixels of the window (3 or 4 is a good number)
viewport the current viewport (normaly {0, 0, 255, 191})
00972                                                                                              {
00973         MATRIX_MULT4x4 = inttof32(viewport[2]) / width;
00974         MATRIX_MULT4x4 = 0;
00975         MATRIX_MULT4x4 = 0;
00976         MATRIX_MULT4x4 = 0;
00977         MATRIX_MULT4x4 = 0;
00978         MATRIX_MULT4x4 = inttof32(viewport[3]) / height;
00979         MATRIX_MULT4x4 = 0;
00980         MATRIX_MULT4x4 = 0;
00981         MATRIX_MULT4x4 = 0;
00982         MATRIX_MULT4x4 = 0;
00983         MATRIX_MULT4x4 = inttof32(1);
00984         MATRIX_MULT4x4 = 0;
00985         MATRIX_MULT4x4 = inttof32(viewport[2] + ((viewport[0] - x)<<1)) / width;
00986         MATRIX_MULT4x4 = inttof32(viewport[3] + ((viewport[1] - y)<<1)) / height;
00987         MATRIX_MULT4x4 = 0;
00988         MATRIX_MULT4x4 = inttof32(1);
00989 }

int gluTexLoadPal ( const u16 pal,
u16  count,
uint8  format 
)

Loads a palette into the next available palette slot, returns the addr on success or -1.

Parameters:
pal pointer to the palette to load
count the size of the palette
format the format of the texture

GL_STATIC_INL void glVertex3f ( float  x,
float  y,
float  z 
)

specifies a vertex location

Warning:
FLOAT VERSION!!!! please use glVertex3v16()
Parameters:
x the x component of the vertex
y the y component of the vertex
z the z component of the vertex
01142                                                          {
01143         glVertex3v16(floattov16(x), floattov16(y), floattov16(z));
01144 }

GL_STATIC_INL void glVertex3v16 ( v16  x,
v16  y,
v16  z 
)

specifies a vertex

Parameters:
x the x component for the vertex
y the y component for the vertex
z the z component for the vertex
00495                                                      {
00496         GFX_VERTEX16 = (y << 16) | (x & 0xFFFF);
00497         GFX_VERTEX16 = ((uint32)(uint16)z);
00498 }

GL_STATIC_INL void glViewport ( uint8  x1,
uint8  y1,
uint8  x2,
uint8  y2 
)

specify the viewport for following drawing, can be set several times per frame.
GBATEK http://nocash.emubase.de/gbatek.htm#ds3ddisplaycontrol

Parameters:
x1 the left of the viewport
y1 the bottom of the viewport
x2 the right of the viewport
y2 the top of the viewport
00596 { GFX_VIEWPORT = (x1) + (y1 << 8) + (x2 << 16) + (y2 << 24); }

GL_STATIC_INL uint32 POLY_ALPHA ( int  n  ) 

used in glPolyFmt() to set the alpha level for the following polygons, set to 0 for wireframe mode

Parameters:
n the level of alpha (0-31)
00462 { return (uint32)((n) << 16); };

GL_STATIC_INL uint32 POLY_ID ( int  n  ) 

used in glPolyFmt() to set the Polygon ID for the following polygons

Parameters:
n the ID to set for following polygons (0-63)
00466 { return (uint32)((n)<<24); };


Variable Documentation

gl_hidden_globals* glGlob = 0 [static]


Generated on Tue Jan 22 15:48:56 2008 for libnds(ARM9) by  doxygen 1.5.4