Defines | |
#define | ulSetDepth(z) (ul_currentDepth = z) |
#define | ulGetDepth() ul_currentDepth |
#define | ulSetAutoDepth(enable) (ul_autoDepth = enable) |
#define | ulVertexBegin(vtype) ( GFX_BEGIN = vtype ) |
#define | ulVertexEnd() ( GFX_END = 0 ) |
#define | ulVertexHandleDepth() ( ul_currentDepth += ul_autoDepth ) |
#define | ulVertexUVXY(u, v, x, y) |
#define | ulVertexXY(x, y) |
#define | ulVertexColor(color) ( GFX_COLOR = color ) |
#define | ulDisableTexture() (GFX_TEX_FORMAT = 0) |
Functions | |
void | ulSetTexture (UL_IMAGE *img) |
#define ulSetDepth | ( | z | ) | (ul_currentDepth = z) |
Defines the depth of the next object to draw.
#define ulGetDepth | ( | ) | ul_currentDepth |
Retreives the current depth. Useful when the AutoDepth mode is enabled.
#define ulSetAutoDepth | ( | enable | ) | (ul_autoDepth = enable) |
Set whether you want to increment the depth of objects automatically. Enabled by default.
enable | 0 = disable, 1 = enable. Do not set to any other value, else priority problems can and will appear. |
#define ulVertexBegin | ( | vtype | ) | ( GFX_BEGIN = vtype ) |
Begins to draw a new 2D/3D object.
vtype | Defines the type of object you want to draw.
|
ulVertexBegin(GL_TRIANGLES); ulVertexXY(x0, y0); ulVertexXY(x1, y1); ulVertexXY(x1, y1); ulVertexEnd();
Separate Tri. Triangle Strips Line Segment v0 v2___v4____v6 |\ v3 /|\ |\ /\ v0 v1 | \ /\ v0( | \ | \ / \ ------ |__\ /__\ \|__\|__\/____\ v2 v1 v2 v4 v5 v1 v3 v5 v7 Separate Quads Quadliteral Strips Prohibited Quads v0__v3 v0__v2____v4 v10__ v0__v3 v4 / \ v4____v7 / \ |\ _____ / /v11 \/ |\ / \ | \ / \ | |v6 v8| / /\ v5| \ /______\ |_____\ /______\___|_|_____|/ /__\ /___\ v1 v2 v5 v6 v1 v3 v5 v7 v9 v2 v1 v6 v7
#define ulVertexEnd | ( | ) | ( GFX_END = 0 ) |
Call this after you've finished to draw your object. Look at the examples above for more informations.
#define ulVertexHandleDepth | ( | ) | ( ul_currentDepth += ul_autoDepth ) |
You MUST call this after you've terminated to draw any object on the screen. It is necessary to get the auto-depth feature working.
#define ulVertexUVXY | ( | u, | |||
v, | |||||
x, | |||||
y | ) |
Value:
({ GFX_TEX_COORD = ((u16)(v)) << 20 | ((u16)(u)) << 4; \ GFX_VERTEX16 = (((u16)(y)) << 16) | ((u16)(x)); \ GFX_VERTEX16 = ul_currentDepth; })
u,v | Texture coordinates | |
x,y | Vertex coordinates |
void drawAnImage(UL_IMAGE *img) { ulSetTexture(img); //Begins drawing quadliterals ulVertexBegin(GL_QUADS); //Drawing order for a quad is: top-left, bottom-left, bottom-right, top-right. ulVertexUVXY(img->offsetX0, img->offsetY0, img->x, img->y); ulVertexUVXY(img->offsetX0, img->offsetY1, img->x, img->y + img->stretchY); ulVertexUVXY(img->offsetX1, img->offsetY1, img->x + img->stretchX, img->y + img->stretchY); ulVertexUVXY(img->offsetX1, img->offsetY0, img->x + img->stretchX, img->y); //End there. You could also continue and draw other quads (issue 4 new vertex commands) ulVertexEnd(); //Auto-increment depth ulVertexHandleDepth(); return; }
#define ulVertexXY | ( | x, | |||
y | ) |
Value:
({ GFX_VERTEX16 = (((u16)(y)) << 16) | ((u16)(x)); \ GFX_VERTEX16 = ul_currentDepth; })
x,y | Vertex coordinates |
void drawTriangle(int x0, int y0, int x1, int y1, int x2, int y2, UL_COLOR color) { //We're drawing a simple colored triangle (untextured) ulDisableTexture(); //Begins drawing quadliterals ulVertexBegin(GL_TRIANGLES); //You can define the color of each vertex before issuing the vertex command, or once for all, like here. If the vertices have different colors, a gradient will appear between each corner. ulVertexColor(color); //Draw our triangle (3 vertices) ulVertexXY(x0, y0); ulVertexXY(x1, y1); ulVertexXY(x2, y2); //End our drawing. ulVertexEnd(); //Don't forget to auto-increment depth ulVertexHandleDepth(); return; }
#define ulVertexColor | ( | color | ) | ( GFX_COLOR = color ) |
Set the next vertex color. In a 2D or 3D object, each vertex can have its own color, just call this before issuing the vertex command to set its color.
#define ulDisableTexture | ( | ) | (GFX_TEX_FORMAT = 0) |
Disables texturing. Use it if you want to draw a coloured or gradient-filled object.
void ulSetTexture | ( | UL_IMAGE * | img | ) |
Sets the current image as a texture so you can draw on the screen by issuing vertex commands. This function will realize the image if it's not already done.