Drawing


Modules

 Drawing base
 Clipping / Windowing
 Broken. Please see detailed description!
 Screen view
 Untextured geometry
 Untextured geometry (rectangles, lines, etc.).
 Images
 Image support in µLibrary.
 Advanced vertex commands
 Advanced vertex commands and depth management.

Data Structures

struct  UL_IMAGE

Defines

#define UL_SCREEN_WIDTH   256
#define UL_SCREEN_HEIGHT   192
#define ulGetColorRed(color)   ((color) & 31)
#define ulGetColorGreen(color)   (((color) >> 5) & 31)
#define ulGetColorBlue(color)   (((color) >> 10) & 31)
#define ulEnableEdgeAntialiasing()   (GFX_CONTROL |= GL_ANTIALIAS)
#define ulDisableEdgeAntialiasing()   (GFX_CONTROL &= ~GL_ANTIALIAS)
#define ulSetTransparentColor(color)   (ul_colorKeyEnabled = 1, ul_colorKeyValue = color)
#define ulDisableTransparentColor()   (ul_colorKeyEnabled = 0)

Typedefs

typedef unsigned short UL_COLOR

Enumerations

enum  UL_SPECIAL_EFFECT { UL_FX_DEFAULT = 0, UL_FX_ALPHA = 1 }

Functions

void ulSetAlpha (UL_SPECIAL_EFFECT effect, int coeff, int polygroup)
void ulSetMainLcd (int position)
int ulGetMainLcd ()
void ulSetRegCapture (bool enable, uint8 srcBlend, uint8 destBlend, uint8 bank, uint8 offset, uint8 size, uint8 source, uint8 srcOffset)

Detailed Description

All about drawing!

Define Documentation

#define UL_SCREEN_WIDTH   256

Defines the screen width of the Nintendo DS. Example of use:

//Fade the whole screen with a semi transparent (16) black rectangle
ulSetAlpha(UL_FX_ALPHA, 16, 1);
ulDrawFillRect(0, 0, UL_SCREEN_WIDTH, UL_SCREEN_HEIGHT, RGB15(0, 0, 0));
//Restore default alpha
ulSetAlpha(UL_FX_DEFAULT, 0, 0);

#define UL_SCREEN_HEIGHT   192

Defines the screen height. See UL_SCREEN_WIDTH for more information.

#define ulGetColorRed ( color   )     ((color) & 31)

Retrieves the red component value of the specified color. Example:

//Brightens a color (approach each component from the maximum, 31)
void colorBrighten(UL_COLOR c)
{
        u8 r, g, b;
        
        r = (31 + ulGetColorRed(c)) / 2;
        g = (31 + ulGetColorGreen(c)) / 2;
        b = (31 + ulGetColorBlue(c)) / 2;
        
        return RGB15(r, g, b);
} 

#define ulGetColorGreen ( color   )     (((color) >> 5) & 31)

Retrieves the green component value of the specified color.

#define ulGetColorBlue ( color   )     (((color) >> 10) & 31)

Retrieves the blue component value of the specified color.

 
#define ulEnableEdgeAntialiasing (  )     (GFX_CONTROL |= GL_ANTIALIAS)

Enables edge antialiasing.

 
#define ulDisableEdgeAntialiasing (  )     (GFX_CONTROL &= ~GL_ANTIALIAS)

Disables edge antialiasing.

#define ulSetTransparentColor ( color   )     (ul_colorKeyEnabled = 1, ul_colorKeyValue = color)

Sets the transparent color for loading images. Any pixel matching this color will be set as transparent upon loading. This does not have any effect ouside of loading images, and doesn't work for JPG format. Also, this will not affect GIF files which do have a transparent color. The said transparent color will be used instead.

 
#define ulDisableTransparentColor (  )     (ul_colorKeyEnabled = 0)

Disables the transparent color setting (as it is by default). Useful if your image already has an alpha channel and you don't need to have a color key.


Typedef Documentation

typedef unsigned short UL_COLOR

Color type. It's cleaner to use this when manipulating colors as your code will become more easily portable (e.g. on PSP where colors are 32 bits).


Enumeration Type Documentation

enum UL_SPECIAL_EFFECT

Special effects

Enumerator:
UL_FX_DEFAULT  Opaque.
UL_FX_ALPHA  Alpha blending.


Function Documentation

void ulSetAlpha ( UL_SPECIAL_EFFECT  effect,
int  coeff,
int  polygroup 
)

Defines the transparency and grouping of objects. Everything drawn next to this command will use those alpha parameters. You can then restore the original state (opaque) by writing ulSetAlpha(UL_FX_DEFAULT, 0, 0).

Parameters:
effect can be UL_FX_DEFAULT for opaque or UL_FX_ALPHA for semi-transparency (alpha blending).
coeff blending coefficient: 0 = wireframe, 1 = nearly transparent, ..., 31 = nearly opaque. Has no effect with UL_FX_DEFAULT.
polygroup defines the polygon group of next objects. Objects with different polygroups will be blended together, while objects with the same polygroup will be merged and drawn as a single layer. In each group, the first object drawn will have the highest priority.
Example:
//Default (opaque) objects always have 0 as an ID. Any other value may cause garbage on real DS.
ulSetAlpha(UL_FX_DEFAULT, 0, 0);
//Draw a blue sky background
ulDrawFillRect(0, 0, 256, 192, RGB15(0, 16, 31));
//Set alpha to 1/2, set ID to 1 so that actual objects will be blended with the background (ID = 0)
ulSetAlpha(UL_FX_ALPHA, 16, 1);
//Draw a semi transparent image
ulDrawImage(anImage);
//Restore to default (opaque)
ulSetAlpha(UL_FX_DEFAULT, 0, 0);

void ulSetMainLcd ( int  position  )  [inline]

Set the main LCD, the one which is currently controlled by µLibrary.

Parameters:
position 
  • 0 = touchpad
  • 1 = top screen
You can also use the libnds macro lcdSwap if you simply want to swap the LCDs.

Note: By default, µLibrary controls the top screen.

int ulGetMainLcd (  )  [inline]

Returns 1 if µLibrary is currently drawing to the top screen, 0 if it is on the touchpad.

void ulSetRegCapture ( bool  enable,
uint8  srcBlend,
uint8  destBlend,
uint8  bank,
uint8  offset,
uint8  size,
uint8  source,
uint8  srcOffset 
)

Does a capture.


Generated on Thu Dec 27 13:00:58 2007 by  doxygen 1.5.2