libnds
|
A very small and simple DS rendering lib using the 3d core to render 2D stuff. More...
#include <nds/arm9/videoGL.h>
Data Structures | |
struct | glImage |
Struct for our GL-Based Images. More... | |
Enumerations | |
enum | GL_FLIP_MODE { GL_FLIP_NONE = (1 << 0) , GL_FLIP_V = (1 << 1) , GL_FLIP_H = (1 << 2) } |
Enums selecting flipping mode. More... | |
Functions | |
void | glBegin2D (void) |
Sets up OpenGL for 2d rendering. | |
void | glBox (int x1, int y1, int x2, int y2, int color) |
Draws a box. | |
void | glBoxFilled (int x1, int y1, int x2, int y2, int color) |
Draws a filled box. | |
void | glBoxFilledGradient (int x1, int y1, int x2, int y2, int color1, int color2, int color3, int color4) |
Draws a filled box in gradient colors. | |
void | glEnd2D (void) |
Issue this after drawing 2d so that we don't mess the matrix stack. | |
static int | glGetActiveTexture (void) |
Returns the active texture. Use with care. | |
void | glLine (int x1, int y1, int x2, int y2, int color) |
Draws a line. | |
int | glLoadSpriteSet (glImage *sprite, const unsigned int numframes, const uint16_t *texcoords, GL_TEXTURE_TYPE_ENUM type, int sizeX, int sizeY, int param, int palette_width, const void *palette, const void *texture) |
Initializes our spriteset with Texture Packer generated UV coordinates. | |
int | glLoadTileSet (glImage *sprite, int tile_wid, int tile_hei, int bmp_wid, int bmp_hei, GL_TEXTURE_TYPE_ENUM type, int sizeX, int sizeY, int param, int palette_width, const void *palette, const void *texture) |
Initializes our tileset (like glInitSpriteset()) but without the use of Texture Packer auto-generated files. | |
void | glPutPixel (int x, int y, int color) |
Draws a pixel. | |
void | glScreen2D (void) |
Initializes GL in 2D mode. | |
static void | glSetActiveTexture (int TextureID) |
Set the active texture. Use with care. | |
void | glSprite (int x, int y, int flipmode, const glImage *spr) |
Draws a sprite. | |
void | glSpriteOnQuad (int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4, int uoff, int voff, int flipmode, const glImage *spr) |
Draws a horizontaly stretched sprite (clean stretching). | |
void | glSpriteRotate (int x, int y, s32 angle, int flipmode, const glImage *spr) |
Draws a center rotated sprite. | |
void | glSpriteRotateScale (int x, int y, s32 angle, s32 scale, int flipmode, const glImage *spr) |
Draws a center rotated scaled sprite. | |
void | glSpriteRotateScaleXY (int x, int y, s32 angle, s32 scaleX, s32 scaleY, int flipmode, const glImage *spr) |
Draws a center rotated axis-exclusive scaled sprite. | |
void | glSpriteScale (int x, int y, s32 scale, int flipmode, const glImage *spr) |
Draws a scaled sprite. | |
void | glSpriteScaleXY (int x, int y, s32 scaleX, s32 scaleY, int flipmode, const glImage *spr) |
Draws an axis exclusive scaled sprite. | |
void | glSpriteStretchHorizontal (int x, int y, int length_x, const glImage *spr) |
Draws a horizontaly stretched sprite (clean stretching). | |
void | glTriangle (int x1, int y1, int x2, int y2, int x3, int y3, int color) |
Draws a triangle. | |
void | glTriangleFilled (int x1, int y1, int x2, int y2, int x3, int y3, int color) |
Draws a filled triangle. | |
void | glTriangleFilledGradient (int x1, int y1, int x2, int y2, int x3, int y3, int color1, int color2, int color3) |
Draws a triangle in gradient colors. | |
enum GL_FLIP_MODE |
void glBegin2D | ( | void | ) |
Sets up OpenGL for 2d rendering.
Call this before drawing any of GL2D's drawing or sprite functions.
void glBox | ( | int | x1, |
int | y1, | ||
int | x2, | ||
int | y2, | ||
int | color | ||
) |
Draws a box.
x1,y1 | Top-Left coordinate of the box. |
x2,y2 | Bottom-Right coordinate of the box. |
color | RGB15/ARGB16 color. |
void glBoxFilled | ( | int | x1, |
int | y1, | ||
int | x2, | ||
int | y2, | ||
int | color | ||
) |
Draws a filled box.
x1,y1 | Top-Left coordinate of the box. |
x2,y2 | Bottom-Right coordinate of the box. |
color | RGB15/ARGB16 color. |
void glBoxFilledGradient | ( | int | x1, |
int | y1, | ||
int | x2, | ||
int | y2, | ||
int | color1, | ||
int | color2, | ||
int | color3, | ||
int | color4 | ||
) |
Draws a filled box in gradient colors.
x1,y1 | Top-Left coordinate of the box. |
x2,y2 | Bottom-Right coordinate of the box. |
color1 | RGB15/ARGB16 color of the Top-Left corner. |
color2 | RGB15/ARGB16 color of the Bottom-Left corner. |
color3 | RGB15/ARGB16 color of the Bottom-Right corner. |
color4 | RGB15/ARGB16 color of the Top-Right corner. |
void glEnd2D | ( | void | ) |
Issue this after drawing 2d so that we don't mess the matrix stack.
The compliment of glBegin2D().
|
inlinestatic |
Returns the active texture. Use with care.
Needed to achieve some effects since libnds 1.5.0.
void glLine | ( | int | x1, |
int | y1, | ||
int | x2, | ||
int | y2, | ||
int | color | ||
) |
Draws a line.
x1,y1 | Top-Left coordinate of the line. |
x2,y2 | Bottom-Right coordinate of the line. |
color | RGB15/ARGB16 color. |
int glLoadSpriteSet | ( | glImage * | sprite, |
const unsigned int | numframes, | ||
const uint16_t * | texcoords, | ||
GL_TEXTURE_TYPE_ENUM | type, | ||
int | sizeX, | ||
int | sizeY, | ||
int | param, | ||
int | palette_width, | ||
const void * | palette, | ||
const void * | texture | ||
) |
Initializes our spriteset with Texture Packer generated UV coordinates.
Very safe and easy to use.
sprite | Pointer to an array of glImage. |
numframes | Number of frames in a spriteset (auto-generated by Texture Packer). |
texcoords | Texture Packer auto-generated array of UV coords. |
type | The format of the texture (see glTexImage2D()). |
sizeX | The horizontal size of the texture; valid sizes are enumerated in GL_TEXTURE_TYPE_ENUM (see glTexImage2D()). |
sizeY | The vertical size of the texture; valid sizes are enumerated in GL_TEXTURE_TYPE_ENUM (see glTexImage2D()). |
param | Parameters for the texture (see glTexImage2D()). |
palette_width | Length of the palette. Valid values are 4, 16, 32, 256 (if 0, the palette is removed from the currently bound texture). |
palette | Pointer to the palette data to load (if NULL, then palette is emoved from currently bound texture). |
texture | Pointer to the texture data to load. |
int glLoadTileSet | ( | glImage * | sprite, |
int | tile_wid, | ||
int | tile_hei, | ||
int | bmp_wid, | ||
int | bmp_hei, | ||
GL_TEXTURE_TYPE_ENUM | type, | ||
int | sizeX, | ||
int | sizeY, | ||
int | param, | ||
int | palette_width, | ||
const void * | palette, | ||
const void * | texture | ||
) |
Initializes our tileset (like glInitSpriteset()) but without the use of Texture Packer auto-generated files.
Can only be used when tiles in a tilset are of the same dimensions.
sprite | Pointer to an array of glImage. |
tile_wid | Width of each tile in the texture. |
tile_hei | Height of each tile in the texture. |
bmp_wid | Width of of the texture or tileset. |
bmp_hei | height of of the texture or tileset. |
type | The format of the texture (see glTexImage2D()). |
sizeX | The horizontal size of the texture; valid sizes are enumerated in GL_TEXTURE_TYPE_ENUM (see glTexImage2D()). |
sizeY | The vertical size of the texture; valid sizes are enumerated in GL_TEXTURE_TYPE_ENUM (see glTexImage2D()). |
param | Parameters for the texture (see glTexImage2D()). |
palette_width | Length of the palette. Valid values are 4, 16, 32, 256 (if 0, the palette is removed from the currently bound texture). |
palette | Pointer to the palette data to load (if NULL, then palette is removed from currently bound texture). |
texture | Pointer to the texture data to load. |
void glPutPixel | ( | int | x, |
int | y, | ||
int | color | ||
) |
Draws a pixel.
x | X position of the pixel. |
y | Y position of the pixel. |
color | RGB15/ARGB16 color. |
void glScreen2D | ( | void | ) |
Initializes GL in 2D mode.
Also initializes GL in 3d mode so that we could combine 2D and 3D later. Almost a direct copy from the DS example files.
|
inlinestatic |
Set the active texture. Use with care.
Needed to achieve some effects since libnds 1.5.0.
TextureID | Texture to set as active. |
void glSprite | ( | int | x, |
int | y, | ||
int | flipmode, | ||
const glImage * | spr | ||
) |
Draws a sprite.
x | X position of the sprite. |
y | Y position of the sprite. |
flipmode | Mode for flipping (see GL_FLIP_MODE enum). |
spr | Pointer to a glImage. |
void glSpriteOnQuad | ( | int | x1, |
int | y1, | ||
int | x2, | ||
int | y2, | ||
int | x3, | ||
int | y3, | ||
int | x4, | ||
int | y4, | ||
int | uoff, | ||
int | voff, | ||
int | flipmode, | ||
const glImage * | spr | ||
) |
Draws a horizontaly stretched sprite (clean stretching).
Useful for "shrearing effects".
x1,y1 | First corner of the sprite. |
x2,y2 | Second corner of the sprite. |
x3,y3 | Third corner of the sprite. |
x4,y4 | Fourth corner of the sprite. |
uoff,voff | Texture offsets. |
flipmode | Mode for flipping (see GL_FLIP_MODE enum). |
spr | Pointer to a glImage. |
Draws a center rotated sprite.
x | X position of the sprite center. |
y | Y position of the sprite center. |
angle | Binary Radian Angle(-32768 to 32767) to rotate the sprite. |
flipmode | Mode for flipping (see GL_FLIP_MODE enum). |
spr | Pointer to a glImage. |
Draws a center rotated scaled sprite.
x | X position of the sprite center. |
y | Y position of the sprite center. |
angle | Binary Radian Angle(-32768 to 32767) to rotate the sprite. |
scale | 20.12 fixed-point scale value (1 << 12 is normal). |
flipmode | Mode for flipping (see GL_FLIP_MODE enum). |
spr | Pointer to a glImage. |
void glSpriteRotateScaleXY | ( | int | x, |
int | y, | ||
s32 | angle, | ||
s32 | scaleX, | ||
s32 | scaleY, | ||
int | flipmode, | ||
const glImage * | spr | ||
) |
Draws a center rotated axis-exclusive scaled sprite.
x | X position of the sprite center. |
y | Y position of the sprite center. |
angle | Binary Radian Angle(-32768 to 32767) to rotate the sprite. |
scaleX | 20.12 fixed-point X-Axis scale value (1 << 12 is normal). |
scaleY | 20.12 fixed-point Y-Axis scale value (1 << 12 is normal). |
flipmode | Mode for flipping (see GL_FLIP_MODE enum). |
spr | Pointer to a glImage. |
Draws a scaled sprite.
x | X position of the sprite. |
y | Y position of the sprite. |
scale | 20.12 fixed-point scale value (1 << 12 is normal). |
flipmode | Mode for flipping (see GL_FLIP_MODE enum). |
spr | Pointer to a glImage. |
Draws an axis exclusive scaled sprite.
x | X position of the sprite. |
y | Y position of the sprite. |
scaleX | 20.12 fixed-point X-Axis scale value (1 << 12 is normal). |
scaleY | 20.12 fixed-point Y-Axis scale value (1 << 12 is normal). |
flipmode | Mode for flipping (see GL_FLIP_MODE enum). |
spr | Pointer to a glImage. |
void glSpriteStretchHorizontal | ( | int | x, |
int | y, | ||
int | length_x, | ||
const glImage * | spr | ||
) |
Draws a horizontaly stretched sprite (clean stretching).
Useful for "laser effects".
x | X position of the sprite center. |
y | Y position of the sprite center. |
length_x | The length(in pixels) to stretch the sprite. |
spr | Pointer to a glImage. |
void glTriangle | ( | int | x1, |
int | y1, | ||
int | x2, | ||
int | y2, | ||
int | x3, | ||
int | y3, | ||
int | color | ||
) |
Draws a triangle.
x1,y1 | Vertex 1 of the triangle. |
x2,y2 | Vertex 2 of the triangle. |
x3,y3 | Vertex 3 of the triangle. |
color | RGB15/ARGB16 color of the triangle. |
void glTriangleFilled | ( | int | x1, |
int | y1, | ||
int | x2, | ||
int | y2, | ||
int | x3, | ||
int | y3, | ||
int | color | ||
) |
Draws a filled triangle.
x1,y1 | Vertex 1 of the triangle. |
x2,y2 | Vertex 2 of the triangle. |
x3,y3 | Vertex 3 of the triangle. |
color | RGB15/ARGB16 color of the triangle. |
void glTriangleFilledGradient | ( | int | x1, |
int | y1, | ||
int | x2, | ||
int | y2, | ||
int | x3, | ||
int | y3, | ||
int | color1, | ||
int | color2, | ||
int | color3 | ||
) |
Draws a triangle in gradient colors.
x1,y1 | Vertex 1 of the triangle. |
x2,y2 | Vertex 2 of the triangle. |
x3,y3 | Vertex 3 of the triangle. |
color1 | RGB15/ARGB16 color of the vertex 1. |
color2 | RGB15/ARGB16 color of the vertex 2. |
color3 | RGB15/ARGB16 color of the vertex 3. |