citro2d
Data Structures | Macros | Enumerations | Functions
base.h File Reference

Basic citro2d initialization and drawing API. More...

#include <citro3d.h>
#include <tex3ds.h>

Go to the source code of this file.

Data Structures

struct  C2D_DrawParams
 
struct  C2D_Tint
 
struct  C2D_Image
 
struct  C2D_ImageTint
 

Macros

#define C2D_DEFAULT_MAX_OBJECTS   4096
 
#define C2D_CONSTEXPR   static inline
 
#define C2D_OPTIONAL(_x)
 

Enumerations

enum  C2D_Corner {
  C2D_TopLeft,
  C2D_TopRight,
  C2D_BotLeft,
  C2D_BotRight
}
 

Functions

C2D_CONSTEXPR float C2D_Clamp (float x, float min, float max)
 Clamps a value between bounds. More...
 
C2D_CONSTEXPR u8 C2D_FloatToU8 (float x)
 Converts a float to u8. More...
 
C2D_CONSTEXPR u32 C2D_Color32 (u8 r, u8 g, u8 b, u8 a)
 Builds a 32-bit RGBA color value. More...
 
C2D_CONSTEXPR u32 C2D_Color32f (float r, float g, float b, float a)
 Builds a 32-bit RGBA color value from float values. More...
 
static void C2D_SetImageTint (C2D_ImageTint *tint, C2D_Corner corner, u32 color, float blend)
 Configures one corner of an image tint structure. More...
 
static void C2D_PlainImageTint (C2D_ImageTint *tint, u32 color, float blend)
 Configures an image tint structure with the specified tint parameters applied to all corners. More...
 
static void C2D_AlphaImageTint (C2D_ImageTint *tint, float alpha)
 Configures an image tint structure to just apply transparency to the image. More...
 
static void C2D_TopImageTint (C2D_ImageTint *tint, u32 color, float blend)
 Configures an image tint structure with the specified tint parameters applied to the top side (e.g. More...
 
static void C2D_BottomImageTint (C2D_ImageTint *tint, u32 color, float blend)
 Configures an image tint structure with the specified tint parameters applied to the bottom side (e.g. More...
 
static void C2D_LeftImageTint (C2D_ImageTint *tint, u32 color, float blend)
 Configures an image tint structure with the specified tint parameters applied to the left side (e.g. More...
 
static void C2D_RightImageTint (C2D_ImageTint *tint, u32 color, float blend)
 Configures an image tint structure with the specified tint parameters applied to the right side (e.g. More...
 
bool C2D_Init (size_t maxObjects)
 Initialize citro2d. More...
 
void C2D_Fini (void)
 Deinitialize citro2d.
 
void C2D_Prepare (void)
 Prepares the GPU for rendering 2D content. More...
 
void C2D_Flush (void)
 Ensures all 2D objects so far have been drawn.
 
void C2D_SceneSize (u32 width, u32 height, bool tilt)
 Configures the size of the 2D scene. More...
 
static void C2D_SceneTarget (C3D_RenderTarget *target)
 Configures the size of the 2D scene to match that of the specified render target. More...
 
C3D_RenderTarget * C2D_CreateScreenTarget (gfxScreen_t screen, gfx3dSide_t side)
 Helper function to create a render target for a screen. More...
 
void C2D_TargetClear (C3D_RenderTarget *target, u32 color)
 Helper function to clear a rendertarget using the specified color. More...
 
static void C2D_SceneBegin (C3D_RenderTarget *target)
 Helper function to begin drawing a 2D scene on a render target. More...
 
void C2D_Fade (u32 color)
 Configures the fading color. More...
 
bool C2D_DrawImage (C2D_Image img, const C2D_DrawParams *params, const C2D_ImageTint *tint C2D_OPTIONAL(nullptr))
 Draws an image using the GPU (variant accepting C2D_DrawParams) More...
 
static bool C2D_DrawImageAt (C2D_Image img, float x, float y, float depth, const C2D_ImageTint *tint C2D_OPTIONAL(nullptr), float scaleX C2D_OPTIONAL(1.0f), float scaleY C2D_OPTIONAL(1.0f))
 Draws an image using the GPU (variant accepting position/scaling) More...
 
static bool C2D_DrawImageAtRotated (C2D_Image img, float x, float y, float depth, float angle, const C2D_ImageTint *tint C2D_OPTIONAL(nullptr), float scaleX C2D_OPTIONAL(1.0f), float scaleY C2D_OPTIONAL(1.0f))
 Draws an image using the GPU (variant accepting position/scaling/rotation) More...
 
bool C2D_DrawTriangle (float x0, float y0, u32 clr0, float x1, float y1, u32 clr1, float x2, float y2, u32 clr2, float depth)
 Draws a plain triangle using the GPU. More...
 
bool C2D_DrawRectangle (float x, float y, float z, float w, float h, u32 clr0, u32 clr1, u32 clr2, u32 clr3)
 Draws a plain rectangle using the GPU. More...
 
static bool C2D_DrawRectSolid (float x, float y, float z, float w, float h, u32 clr)
 Draws a plain rectangle using the GPU (with a solid color) More...
 
bool C2D_DrawEllipse (float x, float y, float z, float w, float h, u32 clr0, u32 clr1, u32 clr2, u32 clr3)
 Draws an ellipse using the GPU. More...
 
static bool C2D_DrawEllipseSolid (float x, float y, float z, float w, float h, u32 clr)
 Draws a ellipse using the GPU (with a solid color) More...
 
static bool C2D_DrawCircle (float x, float y, float z, float radius, u32 clr0, u32 clr1, u32 clr2, u32 clr3)
 Draws a circle (an ellipse with identical width and height) using the GPU. More...
 
static bool C2D_DrawCircleSolid (float x, float y, float z, float radius, u32 clr)
 Draws a circle (an ellipse with identical width and height) using the GPU (with a solid color) More...
 

Detailed Description

Basic citro2d initialization and drawing API.

Enumeration Type Documentation

enum C2D_Corner
Enumerator
C2D_TopLeft 

Top left corner.

C2D_TopRight 

Top right corner.

C2D_BotLeft 

Bottom left corner.

C2D_BotRight 

Bottom right corner.