sf2dlib
Simple and Fast 2D library for the Nintendo 3DS
Data Structures | Macros | Enumerations | Functions
sf2d.h File Reference

sf2dlib header More...

#include <3ds.h>

Go to the source code of this file.

Data Structures

struct  sf2d_vector_2f
 Represents a two dimensional float vector. More...
 
struct  sf2d_vector_3f
 Represents a three dimensional float vector. More...
 
struct  sf2d_vector_4uc
 Represents a four dimensional unsigned char vector. More...
 
struct  sf2d_vertex_pos_col
 Represents a vertex containing position (float) and color (unsigned char) More...
 
struct  sf2d_vertex_pos_tex
 Represents a vertex containing position and texture coordinates. More...
 
struct  sf2d_texture
 Represents a texture. More...
 

Macros

#define RGBA8(r, g, b, a)   ((((a)&0xFF)<<24) | (((b)&0xFF)<<16) | (((g)&0xFF)<<8) | (((r)&0xFF)<<0))
 Creates a new RGBA8 color. More...
 
#define RGBA8_GET_R(c)   (((c) >> 0) & 0xFF)
 
#define RGBA8_GET_G(c)   (((c) >> 8) & 0xFF)
 
#define RGBA8_GET_B(c)   (((c) >> 16) & 0xFF)
 
#define RGBA8_GET_A(c)   (((c) >> 24) & 0xFF)
 
#define SF2D_GPUCMD_DEFAULT_SIZE   0x80000
 Default size of the GPU commands FIFO buffer.
 
#define SF2D_TEMPPOOL_DEFAULT_SIZE   0x80000
 Default size of the temporary memory pool.
 
#define SF2D_DEFAULT_DEPTH   0.5f
 Default depth (Z coordinate) to draw the textures to.
 

Enumerations

enum  sf2d_texfmt {
  TEXFMT_RGBA8 = 0, TEXFMT_RGB8 = 1, TEXFMT_RGB5A1 = 2, TEXFMT_RGB565 = 3,
  TEXFMT_RGBA4 = 4, TEXFMT_IA8 = 5, TEXFMT_I8 = 7, TEXFMT_A8 = 8,
  TEXFMT_IA4 = 9, TEXFMT_I4 = 10, TEXFMT_A4 = 11, TEXFMT_ETC1 = 12,
  TEXFMT_ETC1A4 = 13
}
 Represents a texture format.
 
enum  sf2d_place { SF2D_PLACE_RAM, SF2D_PLACE_VRAM, SF2D_PLACE_TEMP }
 Data allocated on the RAM or VRAM. More...
 

Functions

int sf2d_init ()
 Initializates the library. More...
 
int sf2d_init_advanced (int gpucmd_size, int temppool_size)
 Initializates the library (with advanced settings) More...
 
int sf2d_fini ()
 Finishes the library. More...
 
void sf2d_set_3D (int enable)
 Enables or disables the 3D. More...
 
void sf2d_start_frame (gfxScreen_t screen, gfx3dSide_t side)
 Starts a frame. More...
 
void sf2d_end_frame ()
 Ends a frame, should be called on pair with sf2d_start_frame.
 
void sf2d_swapbuffers ()
 Swaps the framebuffers, should be called once after all the frames have been finished.
 
void sf2d_set_vblank_wait (int enable)
 Enables or disables the VBlank waiting. More...
 
float sf2d_get_fps ()
 Returns the FPS (frames per second) More...
 
void * sf2d_pool_malloc (u32 size)
 Allocates memory from a temporary pool. The pool will be emptied after a sf2d_swapbuffers call. More...
 
void * sf2d_pool_memalign (u32 size, u32 alignment)
 Allocates aligned memory from a temporary pool. Works as sf2d_pool_malloc. More...
 
void * sf2d_pool_calloc (u32 nmemb, u32 size)
 Allocates aligned memory for an array from a temporary pool. Works as sf2d_pool_malloc. More...
 
unsigned int sf2d_pool_space_free ()
 Returns the temporary pool's free space. More...
 
void sf2d_pool_reset ()
 Empties the temporary pool.
 
void sf2d_set_clear_color (u32 color)
 Sets the screen clear color. More...
 
void sf2d_draw_line (int x0, int y0, int x1, int y1, u32 color)
 Draws a line. More...
 
void sf2d_draw_rectangle (int x, int y, int w, int h, u32 color)
 Draws a rectangle. More...
 
void sf2d_draw_rectangle_rotate (int x, int y, int w, int h, u32 color, float rad)
 Draws a rotated rectangle. More...
 
void sf2d_draw_fill_circle (int x, int y, int radius, u32 color)
 Draws a filled circle. More...
 
sf2d_texturesf2d_create_texture (int width, int height, sf2d_texfmt pixel_format, sf2d_place place)
 Creates an empty texture. The returned texture has the data allocated, this means that the raw pixel data can be filled just after the return. More...
 
void sf2d_free_texture (sf2d_texture *texture)
 Frees a texture. More...
 
void sf2d_fill_texture_from_RGBA8 (sf2d_texture *dst, const void *rgba8, int source_w, int source_h)
 Fills an already allocated texture from a RGBA8 source. More...
 
sf2d_texturesf2d_create_texture_mem_RGBA8 (const void *src_buffer, int src_w, int src_h, sf2d_texfmt pixel_format, sf2d_place place)
 Creates a texture and fills it from a RGBA8 memory source. The returned texture is already tiled. More...
 
void sf2d_bind_texture (const sf2d_texture *texture, GPU_TEXUNIT unit)
 Binds a texture to a GPU texture unit. More...
 
void sf2d_bind_texture_color (const sf2d_texture *texture, GPU_TEXUNIT unit, u32 color)
 Binds a texture to a GPU texture unit with a constant color. More...
 
void sf2d_bind_texture_parameters (const sf2d_texture *texture, GPU_TEXUNIT unit, unsigned int params)
 Binds a texture to a GPU texture unit with custom parameters. More...
 
void sf2d_texture_set_params (sf2d_texture *texture, u32 params)
 Changes the texture params (filters and wrapping) More...
 
int sf2d_texture_get_params (const sf2d_texture *texture)
 Returns the texture params. More...
 
void sf2d_draw_texture (const sf2d_texture *texture, int x, int y)
 Draws a texture. More...
 
void sf2d_draw_texture_blend (const sf2d_texture *texture, int x, int y, u32 color)
 Draws a texture blended with a color. More...
 
void sf2d_draw_texture_rotate_hotspot (const sf2d_texture *texture, int x, int y, float rad, float center_x, float center_y)
 Draws a texture with rotation around a hotspot. More...
 
void sf2d_draw_texture_rotate_hotspot_blend (const sf2d_texture *texture, int x, int y, float rad, float center_x, float center_y, u32 color)
 Draws a texture with rotation around a hotspot with a color. More...
 
void sf2d_draw_texture_rotate (const sf2d_texture *texture, int x, int y, float rad)
 Draws a texture with rotation around its center. More...
 
void sf2d_draw_texture_rotate_blend (const sf2d_texture *texture, int x, int y, float rad, u32 color)
 Draws a texture with rotation around its center with color. More...
 
void sf2d_draw_texture_part (const sf2d_texture *texture, int x, int y, int tex_x, int tex_y, int tex_w, int tex_h)
 Draws a part of a texture. More...
 
void sf2d_draw_texture_part_blend (const sf2d_texture *texture, int x, int y, int tex_x, int tex_y, int tex_w, int tex_h, u32 color)
 Draws a part of a texture with color. More...
 
void sf2d_draw_texture_scale (const sf2d_texture *texture, int x, int y, float x_scale, float y_scale)
 Draws a texture with scaling. More...
 
void sf2d_draw_texture_scale_blend (const sf2d_texture *texture, int x, int y, float x_scale, float y_scale, u32 color)
 Draws a texture with scaling with color. More...
 
void sf2d_draw_texture_part_scale (const sf2d_texture *texture, float x, float y, float tex_x, float tex_y, float tex_w, float tex_h, float x_scale, float y_scale)
 Draws a part of a texture, with scaling. More...
 
void sf2d_draw_texture_part_scale_blend (const sf2d_texture *texture, float x, float y, float tex_x, float tex_y, float tex_w, float tex_h, float x_scale, float y_scale, u32 color)
 Draws a part of a texture, with scaling, with color. More...
 
void sf2d_draw_texture_part_rotate_scale (const sf2d_texture *texture, int x, int y, float rad, int tex_x, int tex_y, int tex_w, int tex_h, float x_scale, float y_scale)
 Draws a part of a texture, with rotation and scaling. More...
 
void sf2d_draw_texture_part_rotate_scale_blend (const sf2d_texture *texture, int x, int y, float rad, int tex_x, int tex_y, int tex_w, int tex_h, float x_scale, float y_scale, u32 color)
 Draws a part of a texture, with rotation, scaling and color. More...
 
void sf2d_draw_texture_depth (const sf2d_texture *texture, int x, int y, signed short z)
 Draws a texture blended in a certain depth. More...
 
void sf2d_draw_texture_depth_blend (const sf2d_texture *texture, int x, int y, signed short z, u32 color)
 Draws a texture blended in a certain depth. More...
 
void sf2d_draw_quad_uv (const sf2d_texture *texture, float left, float top, float right, float bottom, float u0, float v0, float u1, float v1, unsigned int params)
 Draws a texture using custom texture coordinates and parameters. More...
 
void sf2d_set_pixel (sf2d_texture *texture, int x, int y, u32 new_color)
 Changes a pixel of the texture. More...
 
u32 sf2d_get_pixel (sf2d_texture *texture, int x, int y)
 Gets a pixel of the texture. More...
 
void sf2d_texture_tile32 (sf2d_texture *texture)
 Tiles a texture. More...
 
void sf2d_set_scissor_test (GPU_SCISSORMODE mode, u32 x, u32 y, u32 w, u32 h)
 Sets the scissor test. More...
 
gfxScreen_t sf2d_get_current_screen ()
 Returns the current screen (latest call to sf2d_start_frame) More...
 
gfx3dSide_t sf2d_get_current_side ()
 Returns the current screen side (latest call to sf2d_start_frame) More...
 

Detailed Description

sf2dlib header

Author
Sergi Granell (xerpi)
Date
22 March 2015

Macro Definition Documentation

#define RGBA8 (   r,
  g,
  b,
 
)    ((((a)&0xFF)<<24) | (((b)&0xFF)<<16) | (((g)&0xFF)<<8) | (((r)&0xFF)<<0))

Creates a new RGBA8 color.

Parameters
rthe red component of the color to create
gthe green component of the color to create
bthe blue component of the color to create
athe alpha component of the color to create

Enumeration Type Documentation

enum sf2d_place

Data allocated on the RAM or VRAM.

Enumerator
SF2D_PLACE_RAM 

RAM allocated

SF2D_PLACE_VRAM 

VRAM allocated

SF2D_PLACE_TEMP 

Temporary memory pool allocated

Function Documentation

void sf2d_bind_texture ( const sf2d_texture texture,
GPU_TEXUNIT  unit 
)

Binds a texture to a GPU texture unit.

Parameters
texturethe texture to bind
unitGPU texture unit to bind to
void sf2d_bind_texture_color ( const sf2d_texture texture,
GPU_TEXUNIT  unit,
u32  color 
)

Binds a texture to a GPU texture unit with a constant color.

Parameters
texturethe texture to bind
unitGPU texture unit to bind to
colorthe color the bind with the texture
void sf2d_bind_texture_parameters ( const sf2d_texture texture,
GPU_TEXUNIT  unit,
unsigned int  params 
)

Binds a texture to a GPU texture unit with custom parameters.

Parameters
texturethe texture to bind
unitGPU texture unit to bind to
paramsthe parameters the bind with the texture
sf2d_texture* sf2d_create_texture ( int  width,
int  height,
sf2d_texfmt  pixel_format,
sf2d_place  place 
)

Creates an empty texture. The returned texture has the data allocated, this means that the raw pixel data can be filled just after the return.

Parameters
widththe width of the texture
heightthe height of the texture
pixel_formatthe pixel_format of the texture
placewhere to allocate the texture
Returns
a pointer to the newly created texture
Note
Before drawing the texture, it needs to be tiled by calling sf2d_texture_tile32. The default texture params are both min and mag filters GPU_NEAREST, and both S and T wrappings GPU_CLAMP_TO_BORDER.
sf2d_texture* sf2d_create_texture_mem_RGBA8 ( const void *  src_buffer,
int  src_w,
int  src_h,
sf2d_texfmt  pixel_format,
sf2d_place  place 
)

Creates a texture and fills it from a RGBA8 memory source. The returned texture is already tiled.

Parameters
src_bufferpointer to the RGBA8 data to fill from
src_wwidth (in pixels) of the RGAB8 source
src_hheight (in pixels) of the RGAB8 source
pixel_formatthe pixel_format of the texture to create
placewhere to allocate the texture
Returns
a pointer to the newly created, filled, and tiled texture
void sf2d_draw_fill_circle ( int  x,
int  y,
int  radius,
u32  color 
)

Draws a filled circle.

Parameters
xx coordinate of the center of the circle
yy coordinate of the center of the circle
radiusthe radius of the circle
colorthe color to draw the circle
void sf2d_draw_line ( int  x0,
int  y0,
int  x1,
int  y1,
u32  color 
)

Draws a line.

Parameters
x0x coordinate of the first dot
y0y coordinate of the first dot
x1x coordinate of the second dot
y1y coordinate of the sceond dot
colorthe color to draw the line
void sf2d_draw_quad_uv ( const sf2d_texture texture,
float  left,
float  top,
float  right,
float  bottom,
float  u0,
float  v0,
float  u1,
float  v1,
unsigned int  params 
)

Draws a texture using custom texture coordinates and parameters.

Parameters
texturethe texture to draw
leftthe left coordinate of the texture to start drawing
topthe top coordinate of the texture to start drawing
widththe width to draw from the starting left coordinate
heightthe height to draw from the starting top coordinate
u0the U texture coordinate of the left vertices
v0the V texture coordinate of the top vertices
u1the U texture coordinate of the right vertices
v1the V texture coordinate of the bottom vertices
paramsthe parameters to draw the texture with
void sf2d_draw_rectangle ( int  x,
int  y,
int  w,
int  h,
u32  color 
)

Draws a rectangle.

Parameters
xx coordinate of the top left corner of the rectangle
yy coordinate of the top left corner of the rectangle
wrectangle width
hrectangle height
colorthe color to draw the rectangle
void sf2d_draw_rectangle_rotate ( int  x,
int  y,
int  w,
int  h,
u32  color,
float  rad 
)

Draws a rotated rectangle.

Parameters
xx coordinate of the top left corner of the rectangle
yy coordinate of the top left corner of the rectangle
wrectangle width
hrectangle height
colorthe color to draw the rectangle
radrotation (in radians) to draw the rectangle
void sf2d_draw_texture ( const sf2d_texture texture,
int  x,
int  y 
)

Draws a texture.

Parameters
texturethe texture to draw
xthe x coordinate to draw the texture to
ythe y coordinate to draw the texture to
void sf2d_draw_texture_blend ( const sf2d_texture texture,
int  x,
int  y,
u32  color 
)

Draws a texture blended with a color.

Parameters
texturethe texture to draw
xthe x coordinate to draw the texture to
ythe y coordinate to draw the texture to
colorthe color to blend with the texture
void sf2d_draw_texture_depth ( const sf2d_texture texture,
int  x,
int  y,
signed short  z 
)

Draws a texture blended in a certain depth.

Parameters
texturethe texture to draw
xthe x coordinate to draw the texture to
ythe y coordinate to draw the texture to
zthe depth to draw the texture to
Note
The z parameter is a value in the [-32768, +32767] range, where -32768 is the deepest and +32767 the toppest. By default, the textures are drawn at z = 0. Keep in mind that this function won't do Order-independent transparency (OIT), so you should use fully opaque textures to get good results.
void sf2d_draw_texture_depth_blend ( const sf2d_texture texture,
int  x,
int  y,
signed short  z,
u32  color 
)

Draws a texture blended in a certain depth.

Parameters
texturethe texture to draw
xthe x coordinate to draw the texture to
ythe y coordinate to draw the texture to
zthe depth to draw the texture to
colorthe color to blend with the texture
Note
The z parameter is a value in the [-32768, +32767] range, where -32768 is the deepest and +32767 the toppest. By default, the textures are drawn at z = 0. Keep in mind that this function won't do Order-independent transparency (OIT), so you should use fully opaque textures to get good results.
void sf2d_draw_texture_part ( const sf2d_texture texture,
int  x,
int  y,
int  tex_x,
int  tex_y,
int  tex_w,
int  tex_h 
)

Draws a part of a texture.

Parameters
texturethe texture to draw
xthe x coordinate to draw the texture to
ythe y coordinate to draw the texture to
tex_xthe starting point (x coordinate) where to start drawing
tex_ythe starting point (y coordinate) where to start drawing
tex_wthe width to draw from the starting point
tex_hthe height to draw from the starting point
void sf2d_draw_texture_part_blend ( const sf2d_texture texture,
int  x,
int  y,
int  tex_x,
int  tex_y,
int  tex_w,
int  tex_h,
u32  color 
)

Draws a part of a texture with color.

Parameters
texturethe texture to draw
xthe x coordinate to draw the texture to
ythe y coordinate to draw the texture to
tex_xthe starting point (x coordinate) where to start drawing
tex_ythe starting point (y coordinate) where to start drawing
tex_wthe width to draw from the starting point
tex_hthe height to draw from the starting point
colorthe color to blend with the texture
void sf2d_draw_texture_part_rotate_scale ( const sf2d_texture texture,
int  x,
int  y,
float  rad,
int  tex_x,
int  tex_y,
int  tex_w,
int  tex_h,
float  x_scale,
float  y_scale 
)

Draws a part of a texture, with rotation and scaling.

Parameters
texturethe texture to draw
xthe x coordinate to draw the texture to
ythe y coordinate to draw the texture to
radrotation (in radians) to draw the texture
tex_xthe starting point (x coordinate) where to start drawing
tex_ythe starting point (y coordinate) where to start drawing
tex_wthe width to draw from the starting point
tex_hthe height to draw from the starting point
x_scalethe x scale
y_scalethe y scale
void sf2d_draw_texture_part_rotate_scale_blend ( const sf2d_texture texture,
int  x,
int  y,
float  rad,
int  tex_x,
int  tex_y,
int  tex_w,
int  tex_h,
float  x_scale,
float  y_scale,
u32  color 
)

Draws a part of a texture, with rotation, scaling and color.

Parameters
texturethe texture to draw
xthe x coordinate to draw the texture to
ythe y coordinate to draw the texture to
radrotation (in radians) to draw the texture
tex_xthe starting point (x coordinate) where to start drawing
tex_ythe starting point (y coordinate) where to start drawing
tex_wthe width to draw from the starting point
tex_hthe height to draw from the starting point
x_scalethe x scale
y_scalethe y scale
colorthe color to blend with the texture
void sf2d_draw_texture_part_scale ( const sf2d_texture texture,
float  x,
float  y,
float  tex_x,
float  tex_y,
float  tex_w,
float  tex_h,
float  x_scale,
float  y_scale 
)

Draws a part of a texture, with scaling.

Parameters
texturethe texture to draw
xthe x coordinate to draw the texture to
ythe y coordinate to draw the texture to
tex_xthe starting point (x coordinate) where to start drawing
tex_ythe starting point (y coordinate) where to start drawing
tex_wthe width to draw from the starting point
tex_hthe height to draw from the starting point
x_scalethe x scale
y_scalethe y scale
void sf2d_draw_texture_part_scale_blend ( const sf2d_texture texture,
float  x,
float  y,
float  tex_x,
float  tex_y,
float  tex_w,
float  tex_h,
float  x_scale,
float  y_scale,
u32  color 
)

Draws a part of a texture, with scaling, with color.

Parameters
texturethe texture to draw
xthe x coordinate to draw the texture to
ythe y coordinate to draw the texture to
tex_xthe starting point (x coordinate) where to start drawing
tex_ythe starting point (y coordinate) where to start drawing
tex_wthe width to draw from the starting point
tex_hthe height to draw from the starting point
x_scalethe x scale
y_scalethe y scale
colorthe color to blend with the texture
void sf2d_draw_texture_rotate ( const sf2d_texture texture,
int  x,
int  y,
float  rad 
)

Draws a texture with rotation around its center.

Parameters
texturethe texture to draw
xthe x coordinate to draw the texture to
ythe y coordinate to draw the texture to
radrotation (in radians) to draw the texture
void sf2d_draw_texture_rotate_blend ( const sf2d_texture texture,
int  x,
int  y,
float  rad,
u32  color 
)

Draws a texture with rotation around its center with color.

Parameters
texturethe texture to draw
xthe x coordinate to draw the texture to
ythe y coordinate to draw the texture to
radrotation (in radians) to draw the texture
colorthe color to blend with the texture
void sf2d_draw_texture_rotate_hotspot ( const sf2d_texture texture,
int  x,
int  y,
float  rad,
float  center_x,
float  center_y 
)

Draws a texture with rotation around a hotspot.

Parameters
texturethe texture to draw
xthe x coordinate to draw the texture to
ythe y coordinate to draw the texture to
radrotation (in radians) to draw the texture
center_xthe x position of the hotspot
center_ythe y position of the hotspot
void sf2d_draw_texture_rotate_hotspot_blend ( const sf2d_texture texture,
int  x,
int  y,
float  rad,
float  center_x,
float  center_y,
u32  color 
)

Draws a texture with rotation around a hotspot with a color.

Parameters
texturethe texture to draw
xthe x coordinate to draw the texture to
ythe y coordinate to draw the texture to
radrotation (in radians) to draw the texture
center_xthe x position of the hotspot
center_ythe y position of the hotspot
colorthe color to blend with the texture
void sf2d_draw_texture_scale ( const sf2d_texture texture,
int  x,
int  y,
float  x_scale,
float  y_scale 
)

Draws a texture with scaling.

Parameters
texturethe texture to draw
xthe x coordinate to draw the texture to
ythe y coordinate to draw the texture to
x_scalethe x scale
y_scalethe y scale
void sf2d_draw_texture_scale_blend ( const sf2d_texture texture,
int  x,
int  y,
float  x_scale,
float  y_scale,
u32  color 
)

Draws a texture with scaling with color.

Parameters
texturethe texture to draw
xthe x coordinate to draw the texture to
ythe y coordinate to draw the texture to
x_scalethe x scale
y_scalethe y scale
colorthe color to blend with the texture
void sf2d_fill_texture_from_RGBA8 ( sf2d_texture dst,
const void *  rgba8,
int  source_w,
int  source_h 
)

Fills an already allocated texture from a RGBA8 source.

Parameters
dstpointer to the destination texture to fill
rgba8pointer to the RGBA8 data to fill from
source_wwidth (in pixels) of the RGAB8 source
source_hheight (in pixels) of the RGAB8 source
int sf2d_fini ( )

Finishes the library.

Returns
Whether the finalization has been successful or not
void sf2d_free_texture ( sf2d_texture texture)

Frees a texture.

Parameters
texturepointer to the texture to freeze
gfxScreen_t sf2d_get_current_screen ( )

Returns the current screen (latest call to sf2d_start_frame)

Note
The returned value can be GFX_TOP or GFX_BOTTOM.
gfx3dSide_t sf2d_get_current_side ( )

Returns the current screen side (latest call to sf2d_start_frame)

Note
The returned value can be GFX_LEFT or GFX_RIGHT.
float sf2d_get_fps ( )

Returns the FPS (frames per second)

Returns
the current FPS
u32 sf2d_get_pixel ( sf2d_texture texture,
int  x,
int  y 
)

Gets a pixel of the texture.

Parameters
texturethe texture to get the pixel
xthe x coordinate to get the pixel
ythe y coordinate to get the pixel
Returns
the pixel at (x, y)
int sf2d_init ( )

Initializates the library.

Returns
Whether the initialization has been successful or not
int sf2d_init_advanced ( int  gpucmd_size,
int  temppool_size 
)

Initializates the library (with advanced settings)

Parameters
gpucmd_sizethe size of the GPU FIFO
temppool_sizethe size of the temporary pool
Returns
Whether the initialization has been successful or not
void* sf2d_pool_calloc ( u32  nmemb,
u32  size 
)

Allocates aligned memory for an array from a temporary pool. Works as sf2d_pool_malloc.

Parameters
nmembthe number of elements to allocate
sizethe size (and alignment) of each element to allocate
Note
Unlike libc's calloc, this function does not initialize to 0, and returns a pointer aligned to size.
void* sf2d_pool_malloc ( u32  size)

Allocates memory from a temporary pool. The pool will be emptied after a sf2d_swapbuffers call.

Parameters
sizethe number of bytes to allocate
void* sf2d_pool_memalign ( u32  size,
u32  alignment 
)

Allocates aligned memory from a temporary pool. Works as sf2d_pool_malloc.

Parameters
sizethe number of bytes to allocate
alignmentthe alignment to where allocate the memory
unsigned int sf2d_pool_space_free ( )

Returns the temporary pool's free space.

Returns
the temporary pool's free space
void sf2d_set_3D ( int  enable)

Enables or disables the 3D.

Parameters
enablewhether to enable or disable the 3D
void sf2d_set_clear_color ( u32  color)

Sets the screen clear color.

Parameters
colorthe color
void sf2d_set_pixel ( sf2d_texture texture,
int  x,
int  y,
u32  new_color 
)

Changes a pixel of the texture.

Parameters
texturethe texture to change the pixel
xthe x coordinate to change the pixel
ythe y coordinate to change the pixel
new_colorthe new color to set to the pixel at (x, y)
void sf2d_set_scissor_test ( GPU_SCISSORMODE  mode,
u32  x,
u32  y,
u32  w,
u32  h 
)

Sets the scissor test.

Parameters
modethe test mode (disable, invert or normal)
xthe starting x coordinate of the scissor
ythe starting y coordinate of the scissor
wthe width of the scissor rectangle
hthe height of the scissor rectangle
Note
This function should be called after sf2d_start_frame. The scissor will remain active until the sf2d_end_frame call.
void sf2d_set_vblank_wait ( int  enable)

Enables or disables the VBlank waiting.

Parameters
enablewhether to enable or disable the VBlank waiting
void sf2d_start_frame ( gfxScreen_t  screen,
gfx3dSide_t  side 
)

Starts a frame.

Parameters
screentarget screen
sidetarget eye (only for top screen)
int sf2d_texture_get_params ( const sf2d_texture texture)

Returns the texture params.

Parameters
texturethe texture to get the params
Returns
the current texture params of texture
void sf2d_texture_set_params ( sf2d_texture texture,
u32  params 
)

Changes the texture params (filters and wrapping)

Parameters
texturethe texture to change the params
paramsthe new texture params to use. You can use the GPU_TEXTURE_[MIN,MAG]_FILTER and GPU_TEXTURE_WRAP_[S,T] macros as helpers.
void sf2d_texture_tile32 ( sf2d_texture texture)

Tiles a texture.

Parameters
texturethe texture to tile