libnds
Data Structures | Enumerations | Functions
gl2d.h File Reference

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
This is our struct to hold our image attributes. You don't need to worry about this if you use the texture packer. More...
 

Enumerations

Functions

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. More...
 
void glBoxFilled (int x1, int y1, int x2, int y2, int color)
 Draws a Filled Box. More...
 
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. More...
 
void glEnd2D (void)
 Issue this after drawing 2d so that we don't mess the matrix stack.
The compliment of glBegin2D().
 
static int glGetActiveTexture ()
 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. More...
 
int glLoadSpriteSet (glImage *sprite, const unsigned int numframes, const unsigned int *texcoords, GL_TEXTURE_TYPE_ENUM type, int sizeX, int sizeY, int param, int pallette_width, const u16 *palette, const uint8 *texture)
 Initializes our spriteset with Texture Packer generated UV coordinates
Very safe and easy to use.. More...
 
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 pallette_width, const u16 *palette, const uint8 *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. More...
 
void glPutPixel (int x, int y, int color)
 Draws a Pixel. More...
 
void glScreen2D (void)
 Initializes GL in 2D mode.
 
static void glSetActiveTexture (int TextureID)
 Set the active texture. Use with care.
Needed to achieve some effects since libnds 1.5.0.
 
void glSprite (int x, int y, int flipmode, const glImage *spr)
 Draws a Sprite. More...
 
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". More...
 
void glSpriteRotate (int x, int y, s32 angle, int flipmode, const glImage *spr)
 Draws a Center Rotated Sprite. More...
 
void glSpriteRotateScale (int x, int y, s32 angle, s32 scale, int flipmode, const glImage *spr)
 Draws a Center Rotated Scaled Sprite. More...
 
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. More...
 
void glSpriteScale (int x, int y, s32 scale, int flipmode, const glImage *spr)
 Draws a Scaled Sprite. More...
 
void glSpriteScaleXY (int x, int y, s32 scaleX, s32 scaleY, int flipmode, const glImage *spr)
 Draws an Axis Exclusive Scaled Sprite. More...
 
void glSpriteStretchHorizontal (int x, int y, int length_x, const glImage *spr)
 Draws a Horizontaly Stretched Sprite (Clean Stretching)
Useful for "Laser Effects". More...
 
void glTriangle (int x1, int y1, int x2, int y2, int x3, int y3, int color)
 Draws a Triangle. More...
 
void glTriangleFilled (int x1, int y1, int x2, int y2, int x3, int y3, int color)
 Draws a Filled Triangle. More...
 
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. More...
 

Detailed Description

A very small and simple DS rendering lib using the 3d core to render 2D stuff.

API

Enumeration Type Documentation

Enums selecting flipping mode.

These enums are bits for flipping the sprites.
You can "|" (or) GL_FLIP_V and GL_FLIP_H to flip both ways.

Enumerator
GL_FLIP_NONE 

No flipping

GL_FLIP_V 

Sprite is rendered vertically flipped

GL_FLIP_H 

Sprite is rendered horizontally flipped

Function Documentation

void glBox ( int  x1,
int  y1,
int  x2,
int  y2,
int  color 
)

Draws a Box.

Parameters
x1,y1Top-Left coordinate of the box.
x2,y2Bottom-Right coordinate of the box.
colorRGB15/ARGB16 color.
void glBoxFilled ( int  x1,
int  y1,
int  x2,
int  y2,
int  color 
)

Draws a Filled Box.

Parameters
x1,y1Top-Left coordinate of the box.
x2,y2Bottom-Right coordinate of the box.
colorRGB15/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.

Parameters
x1,y1Top-Left coordinate of the box.
x2,y2Bottom-Right coordinate of the box.
color1RGB15/ARGB16 color of the Top-Left corner.
color2RGB15/ARGB16 color of the Bottom-Left corner.
color3RGB15/ARGB16 color of the Bottom-Right corner.
color4RGB15/ARGB16 color of the Top-Right corner.
void glLine ( int  x1,
int  y1,
int  x2,
int  y2,
int  color 
)

Draws a Line.

Parameters
x1,y1Top-Left coordinate of the line.
x2,y2Bottom-Right coordinate of the line.
colorRGB15/ARGB16 color.
int glLoadSpriteSet ( glImage sprite,
const unsigned int  numframes,
const unsigned int *  texcoords,
GL_TEXTURE_TYPE_ENUM  type,
int  sizeX,
int  sizeY,
int  param,
int  pallette_width,
const u16 palette,
const uint8 texture 
)

Initializes our spriteset with Texture Packer generated UV coordinates
Very safe and easy to use..

Parameters
*spritePointer to an array of glImage.
numframesnumber of frames in a spriteset (auto-generated by Texture Packer).
*texcoordsTexture Packer auto-generated array of UV coords.
typeThe format of the texture ( see glTexImage2d() ).
sizeXThe horizontal size of the texture; valid sizes are enumerated in GL_TEXTURE_TYPE_ENUM ( see glTexImage2d() ).
sizeYThe vertical size of the texture; valid sizes are enumerated in GL_TEXTURE_TYPE_ENUM ( see glTexImage2d() ).
paramparameters for the texture ( see glTexImage2d() ).
pallette_widthLength of the palette. Valid values are 4, 16, 32, 256 (if 0, then palette is removed from currently bound texture).
*palettePointer to the palette data to load (if NULL, then palette is removed from currently bound texture).
*texturePointer 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  pallette_width,
const u16 palette,
const uint8 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.

Parameters
*spritePointer to an array of glImage.
tile_widWidth of each tile in the texture.
tile_heiHeight of each tile in the texture.
bmp_widWidth of of the texture or tileset.
bmp_heiheight of of the texture or tileset.
typeThe format of the texture ( see glTexImage2d() ).
sizeXThe horizontal size of the texture; valid sizes are enumerated in GL_TEXTURE_TYPE_ENUM ( see glTexImage2d() ).
sizeYThe vertical size of the texture; valid sizes are enumerated in GL_TEXTURE_TYPE_ENUM ( see glTexImage2d() ).
paramparameters for the texture ( see glTexImage2d() ).
pallette_widthLength of the palette. Valid values are 4, 16, 32, 256 (if 0, then palette is removed from currently bound texture).
*palettePointer to the palette data to load (if NULL, then palette is removed from currently bound texture).
*texturePointer to the texture data to load.
void glPutPixel ( int  x,
int  y,
int  color 
)

Draws a Pixel.

Parameters
xX position of the pixel.
yY position of the pixel.
colorRGB15/ARGB16 color.
void glSprite ( int  x,
int  y,
int  flipmode,
const glImage spr 
)

Draws a Sprite.

Parameters
xX position of the sprite.
yY position of the sprite.
flipmodemode for flipping (see GL_FLIP_MODE enum).
*sprpointer 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".

Parameters
x1,y1First corner of the sprite.
x2,y2Second corner of the sprite.
x3,y3Third corner of the sprite.
x4,y4Fourth corner of the sprite.
uoff,vofftexture offsets.
flipmodemode for flipping (see GL_FLIP_MODE enum).
*sprpointer to a glImage.
void glSpriteRotate ( int  x,
int  y,
s32  angle,
int  flipmode,
const glImage spr 
)

Draws a Center Rotated Sprite.

Parameters
xX position of the sprite center.
yY position of the sprite center.
angleBinary Radian Angle(-32768 to 32767) to rotate the sprite.
flipmodemode for flipping (see GL_FLIP_MODE enum).
*sprpointer to a glImage.
void glSpriteRotateScale ( int  x,
int  y,
s32  angle,
s32  scale,
int  flipmode,
const glImage spr 
)

Draws a Center Rotated Scaled Sprite.

Parameters
xX position of the sprite center.
yY position of the sprite center.
angleBinary Radian Angle(-32768 to 32767) to rotate the sprite.
scale20.12 fixed-point scale value (1 << 12 is normal).
flipmodemode for flipping (see GL_FLIP_MODE enum).
*sprpointer 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.

Parameters
xX position of the sprite center.
yY position of the sprite center.
angleBinary Radian Angle(-32768 to 32767) to rotate the sprite.
scaleX20.12 fixed-point X-Axis scale value (1 << 12 is normal).
scaleY20.12 fixed-point Y-Axis scale value (1 << 12 is normal).
flipmodemode for flipping (see GL_FLIP_MODE enum).
*sprpointer to a glImage.
void glSpriteScale ( int  x,
int  y,
s32  scale,
int  flipmode,
const glImage spr 
)

Draws a Scaled Sprite.

Parameters
xX position of the sprite.
yY position of the sprite.
scale20.12 fixed-point scale value (1 << 12 is normal).
flipmodemode for flipping (see GL_FLIP_MODE enum).
*sprpointer to a glImage.
void glSpriteScaleXY ( int  x,
int  y,
s32  scaleX,
s32  scaleY,
int  flipmode,
const glImage spr 
)

Draws an Axis Exclusive Scaled Sprite.

Parameters
xX position of the sprite.
yY position of the sprite.
scaleX20.12 fixed-point X-Axis scale value (1 << 12 is normal).
scaleY20.12 fixed-point Y-Axis scale value (1 << 12 is normal).
flipmodemode for flipping (see GL_FLIP_MODE enum).
*sprpointer 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".

Parameters
xX position of the sprite center.
yY position of the sprite center.
length_xThe length(in pixels) to stretch the sprite.
*sprpointer to a glImage.
void glTriangle ( int  x1,
int  y1,
int  x2,
int  y2,
int  x3,
int  y3,
int  color 
)

Draws a Triangle.

Parameters
x1,y1Vertex 1 of the triangle.
x2,y2Vertex 2 of the triangle.
x3,y3Vertex 3 of the triangle.
colorRGB15/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.

Parameters
x1,y1Vertex 1 of the triangle.
x2,y2Vertex 2 of the triangle.
x3,y3Vertex 3 of the triangle.
colorRGB15/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.

Parameters
x1,y1Vertex 1 of the triangle.
x2,y2Vertex 2 of the triangle.
x3,y3Vertex 3 of the triangle.
color1RGB15/ARGB16 color of the vertex 1.
color2RGB15/ARGB16 color of the vertex 2.
color3RGB15/ARGB16 color of the vertex 3.