AnimaEngine  1.0.0
Nintendo DS Pokemon Black, White, Black 2, and White 2 sprite extraction and preview toolchain
Data Structures | Typedefs | Functions
gui_platform.h File Reference

Platform-independent renderer and OS abstraction layer. More...

Go to the source code of this file.

Data Structures

struct  GrColor
 Abstract color representation using 8-bit red, green, blue, and alpha values. More...
 
struct  GrRect
 Abstract rectangle bounding box in 2D coordinate space. More...
 
struct  GrTexture
 Abstract texture representation mapped to graphics card registers. More...
 
struct  GrFilePathList
 Abstracted directory list container. More...
 

Typedefs

typedef struct GrColor GrColor
 Abstract color representation using 8-bit red, green, blue, and alpha values. More...
 
typedef struct GrRect GrRect
 Abstract rectangle bounding box in 2D coordinate space. More...
 
typedef struct GrTexture GrTexture
 Abstract texture representation mapped to graphics card registers. More...
 
typedef struct GrFilePathList GrFilePathList
 Abstracted directory list container. More...
 

Functions

void Gr_InitWindow (int w, int h, const char *title)
 Initialises the application window and renderer context. More...
 
void Gr_CloseWindow (void)
 Terminates the windowing subsystem and cleans up remaining hardware resources. More...
 
int Gr_WindowShouldClose (void)
 Checks if the OS window closing event (close button, Alt+F4) has been triggered. More...
 
int Gr_GetScreenW (void)
 Gets the current window canvas width in pixels. More...
 
int Gr_GetScreenH (void)
 Gets the current window canvas height in pixels. More...
 
void Gr_SetMinSize (int w, int h)
 resticts the minimum allowable window sizing for resizable targets. More...
 
void Gr_SetTargetFPS (int fps)
 resticts the rendering execution speed to the target frames per second. More...
 
void Gr_BeginFrame (void)
 Signals the rendering backend that a new frame has started (flushes draw calls). More...
 
void Gr_EndFrame (void)
 Signals the rendering backend that a frame has finished (swaps framebuffers). More...
 
void Gr_Clear (GrColor c)
 Clears the entire active framebuffer with a solid background color. More...
 
float Gr_GetTime (void)
 Returns total time elapsed in seconds since the window context started. More...
 
float Gr_GetFrameDelta (void)
 Returns the duration time step in seconds between the previous frame and this frame. More...
 
int Gr_FileExists (const char *path)
 Checks if a file path exists and is accessible. More...
 
GrFilePathList Gr_LoadDirectoryFiles (const char *dirPath)
 Loads all filenames/directories inside a specified folder. More...
 
void Gr_UnloadDirectoryFiles (GrFilePathList list)
 Deallocates directory list memory allocations. More...
 
int Gr_IsPathFile (const char *path)
 Checks whether the given path represents a file or a directory. More...
 
const char * Gr_GetFileName (const char *filePath)
 Extracts the file name pointer (excluding folders) from a path string. More...
 
const char * Gr_GetWorkingDirectory (void)
 Gets current process working directory (CWD) path. More...
 
const char * Gr_GetPrevDirectoryPath (const char *dirPath)
 Resolves parent directory path. More...
 
int Gr_MouseX (void)
 Gets active cursor horizontal pixel index. More...
 
int Gr_MouseY (void)
 Gets active cursor vertical pixel index. More...
 
int Gr_MousePressed (int btn)
 Checks if a mouse button was clicked. More...
 
int Gr_MouseDown (int btn)
 Checks if a mouse button is currently held down. More...
 
int Gr_GetWheel (void)
 Gets mouse wheel offset delta. More...
 
int Gr_KeyPressed (int key)
 Checks if keyboard key was clicked. More...
 
int Gr_KeyDown (int key)
 Checks if keyboard key is being held. More...
 
int Gr_GetChar (void)
 Pops latest character pressed from keyboard queue. More...
 
const char * Gr_Clipboard (void)
 Gets active system clipboard contents. More...
 
int Gr_FileDropped (void)
 Checks if any files have been dropped onto the window area in this frame. More...
 
int Gr_DropCount (void)
 Gets count of dropped files. More...
 
const char * Gr_DropPath (int i)
 Gets path of dropped file by index. More...
 
void Gr_DropFinish (void)
 Cleans up drag-and-drop platform handles. More...
 
GrRect Gr_MeasureText (const char *text, int size)
 Computes width bounds for a text string under a target font height size. More...
 
void Gr_DrawText (const char *text, float x, float y, int size, GrColor c)
 Draws direct raster text on active canvas. More...
 
void Gr_DrawRect (GrRect r, GrColor c)
 Draws solid rectangle. More...
 
void Gr_DrawRectRounded (GrRect r, float rad, GrColor c)
 Draws rounded corners solid rectangle. More...
 
void Gr_DrawRectRoundedLines (GrRect r, float rad, GrColor c)
 Draws lines of a rounded corners rectangle. More...
 
void Gr_DrawCircle (int cx, int cy, float r, GrColor c)
 Draws solid circle. More...
 
void Gr_ScissorBegin (int x, int y, int w, int h)
 Sets a rectangular scissor clipping box on drawing calls. More...
 
void Gr_ScissorEnd (void)
 Disables scissor clipping bounding boxes. More...
 
int Gr_CheckPointInRect (GrRect r, float px, float py)
 Verifies collision point bounds inside a rectangle. More...
 
int Gr_CheckPointInCircle (float px, float py, float cx, float cy, float r)
 Verifies collision bounds inside a circle. More...
 
int Gr_MakeTextureRGBA (GrTexture *t, const unsigned char *rgba, int w, int h)
 Allocates dynamic texture mapping using raw RGBA pixel arrays. More...
 
void Gr_UpdateTexture (GrTexture *t, const unsigned char *rgba)
 Copies new raw RGBA pixel bytes directly into an active texture VRAM address. More...
 
void Gr_DrawTexture (GrTexture *t, GrRect src, GrRect dst, GrColor tint)
 Draws a textured quad inside target coordinates. More...
 
void Gr_UnloadTexture (GrTexture *t)
 Deallocates hardware graphics memory registers used by a texture. More...
 
const char * Gr_FormatText (const char *fmt,...)
 Formats text string using printf-style layout arguments. More...
 

Detailed Description

Platform-independent renderer and OS abstraction layer.

This module defines the color, rectangle, texture, and windowing abstractions used by the GUI browser application. Implementing this interface allows swapping backends (e.g. Raylib, SDL, OpenGL).

Typedef Documentation

◆ GrColor

typedef struct GrColor GrColor

Abstract color representation using 8-bit red, green, blue, and alpha values.

◆ GrFilePathList

Abstracted directory list container.

◆ GrRect

typedef struct GrRect GrRect

Abstract rectangle bounding box in 2D coordinate space.

◆ GrTexture

typedef struct GrTexture GrTexture

Abstract texture representation mapped to graphics card registers.

Function Documentation

◆ Gr_BeginFrame()

void Gr_BeginFrame ( void  )

Signals the rendering backend that a new frame has started (flushes draw calls).

◆ Gr_CheckPointInCircle()

int Gr_CheckPointInCircle ( float  px,
float  py,
float  cx,
float  cy,
float  r 
)

Verifies collision bounds inside a circle.

◆ Gr_CheckPointInRect()

int Gr_CheckPointInRect ( GrRect  r,
float  px,
float  py 
)

Verifies collision point bounds inside a rectangle.

◆ Gr_Clear()

void Gr_Clear ( GrColor  c)

Clears the entire active framebuffer with a solid background color.

Parameters
cTarget background color.

◆ Gr_Clipboard()

const char* Gr_Clipboard ( void  )

Gets active system clipboard contents.

◆ Gr_CloseWindow()

void Gr_CloseWindow ( void  )

Terminates the windowing subsystem and cleans up remaining hardware resources.

◆ Gr_DrawCircle()

void Gr_DrawCircle ( int  cx,
int  cy,
float  r,
GrColor  c 
)

Draws solid circle.

Parameters
cxCenter X index.
cyCenter Y index.
rCircle radius in pixels.
cSolid color.

◆ Gr_DrawRect()

void Gr_DrawRect ( GrRect  r,
GrColor  c 
)

Draws solid rectangle.

Parameters
rLayout bounds.
cSolid color.

◆ Gr_DrawRectRounded()

void Gr_DrawRectRounded ( GrRect  r,
float  rad,
GrColor  c 
)

Draws rounded corners solid rectangle.

Parameters
rLayout bounds.
radCorner rounding radius factor (0.0 to 1.0).
cSolid color.

◆ Gr_DrawRectRoundedLines()

void Gr_DrawRectRoundedLines ( GrRect  r,
float  rad,
GrColor  c 
)

Draws lines of a rounded corners rectangle.

Parameters
rLayout bounds.
radRounding factor.
cLine color.

◆ Gr_DrawText()

void Gr_DrawText ( const char *  text,
float  x,
float  y,
int  size,
GrColor  c 
)

Draws direct raster text on active canvas.

Parameters
textTarget string.
xHorizontal pixel position.
yVertical pixel position.
sizeFont height in pixels.
cFont color.

◆ Gr_DrawTexture()

void Gr_DrawTexture ( GrTexture t,
GrRect  src,
GrRect  dst,
GrColor  tint 
)

Draws a textured quad inside target coordinates.

Parameters
tTexture register pointer.
srcSource cropped boundaries within the texture.
dstDestination target placement boundaries.
tintColor multiplier overlay.

◆ Gr_DropCount()

int Gr_DropCount ( void  )

Gets count of dropped files.

◆ Gr_DropFinish()

void Gr_DropFinish ( void  )

Cleans up drag-and-drop platform handles.

◆ Gr_DropPath()

const char* Gr_DropPath ( int  i)

Gets path of dropped file by index.

◆ Gr_EndFrame()

void Gr_EndFrame ( void  )

Signals the rendering backend that a frame has finished (swaps framebuffers).

◆ Gr_FileDropped()

int Gr_FileDropped ( void  )

Checks if any files have been dropped onto the window area in this frame.

◆ Gr_FileExists()

int Gr_FileExists ( const char *  path)

Checks if a file path exists and is accessible.

Parameters
pathSystem path string.
Returns
1 if file is accessible; 0 otherwise.

◆ Gr_FormatText()

const char* Gr_FormatText ( const char *  fmt,
  ... 
)

Formats text string using printf-style layout arguments.

Parameters
fmtprintf-style format string.
Returns
Pointer to internal static buffer populated with the result.

◆ Gr_GetChar()

int Gr_GetChar ( void  )

Pops latest character pressed from keyboard queue.

◆ Gr_GetFileName()

const char* Gr_GetFileName ( const char *  filePath)

Extracts the file name pointer (excluding folders) from a path string.

Parameters
filePathComplete path string.
Returns
Pointer within filePath starting at the base file name.

◆ Gr_GetFrameDelta()

float Gr_GetFrameDelta ( void  )

Returns the duration time step in seconds between the previous frame and this frame.

Returns
Frame time step in seconds.

◆ Gr_GetPrevDirectoryPath()

const char* Gr_GetPrevDirectoryPath ( const char *  dirPath)

Resolves parent directory path.

Parameters
dirPathComplete directory path.
Returns
Pointer to parent path string.

◆ Gr_GetScreenH()

int Gr_GetScreenH ( void  )

Gets the current window canvas height in pixels.

Returns
Height in pixels.

◆ Gr_GetScreenW()

int Gr_GetScreenW ( void  )

Gets the current window canvas width in pixels.

Returns
Width in pixels.

◆ Gr_GetTime()

float Gr_GetTime ( void  )

Returns total time elapsed in seconds since the window context started.

Returns
Time in seconds.

◆ Gr_GetWheel()

int Gr_GetWheel ( void  )

Gets mouse wheel offset delta.

◆ Gr_GetWorkingDirectory()

const char* Gr_GetWorkingDirectory ( void  )

Gets current process working directory (CWD) path.

Returns
Pointer to internal static path string.

◆ Gr_InitWindow()

void Gr_InitWindow ( int  w,
int  h,
const char *  title 
)

Initialises the application window and renderer context.

Parameters
wWindow width.
hWindow height.
titleUTF-8 window title.

◆ Gr_IsPathFile()

int Gr_IsPathFile ( const char *  path)

Checks whether the given path represents a file or a directory.

Parameters
pathTarget path string.
Returns
1 if it is a file; 0 if directory.

◆ Gr_KeyDown()

int Gr_KeyDown ( int  key)

Checks if keyboard key is being held.

◆ Gr_KeyPressed()

int Gr_KeyPressed ( int  key)

Checks if keyboard key was clicked.

◆ Gr_LoadDirectoryFiles()

GrFilePathList Gr_LoadDirectoryFiles ( const char *  dirPath)

Loads all filenames/directories inside a specified folder.

Parameters
dirPathFolder path string.
Returns
Struct containing paths and count.

◆ Gr_MakeTextureRGBA()

int Gr_MakeTextureRGBA ( GrTexture t,
const unsigned char *  rgba,
int  w,
int  h 
)

Allocates dynamic texture mapping using raw RGBA pixel arrays.

Parameters
tAbstract texture destination container.
rgbaPixel bytes.
wTexture width.
hTexture height.
Returns
0 on success; negative on failure.

◆ Gr_MeasureText()

GrRect Gr_MeasureText ( const char *  text,
int  size 
)

Computes width bounds for a text string under a target font height size.

Parameters
textUTF-8 string.
sizeFont height in pixels.
Returns
Layout bounds rectangle.

◆ Gr_MouseDown()

int Gr_MouseDown ( int  btn)

Checks if a mouse button is currently held down.

◆ Gr_MousePressed()

int Gr_MousePressed ( int  btn)

Checks if a mouse button was clicked.

◆ Gr_MouseX()

int Gr_MouseX ( void  )

Gets active cursor horizontal pixel index.

◆ Gr_MouseY()

int Gr_MouseY ( void  )

Gets active cursor vertical pixel index.

◆ Gr_ScissorBegin()

void Gr_ScissorBegin ( int  x,
int  y,
int  w,
int  h 
)

Sets a rectangular scissor clipping box on drawing calls.

Parameters
xOrigin X coordinate.
yOrigin Y coordinate.
wClipping area width.
hClipping area height.

◆ Gr_ScissorEnd()

void Gr_ScissorEnd ( void  )

Disables scissor clipping bounding boxes.

◆ Gr_SetMinSize()

void Gr_SetMinSize ( int  w,
int  h 
)

resticts the minimum allowable window sizing for resizable targets.

Parameters
wMinimum width limit.
hMinimum height limit.

◆ Gr_SetTargetFPS()

void Gr_SetTargetFPS ( int  fps)

resticts the rendering execution speed to the target frames per second.

Parameters
fpsTarget FPS (e.g. 60).

◆ Gr_UnloadDirectoryFiles()

void Gr_UnloadDirectoryFiles ( GrFilePathList  list)

Deallocates directory list memory allocations.

Parameters
listDirect container to clean.

◆ Gr_UnloadTexture()

void Gr_UnloadTexture ( GrTexture t)

Deallocates hardware graphics memory registers used by a texture.

Parameters
tTexture pointer to clean.

◆ Gr_UpdateTexture()

void Gr_UpdateTexture ( GrTexture t,
const unsigned char *  rgba 
)

Copies new raw RGBA pixel bytes directly into an active texture VRAM address.

Parameters
tActive texture container.
rgbaNew pixel bytes (must match width * height * 4).

◆ Gr_WindowShouldClose()

int Gr_WindowShouldClose ( void  )

Checks if the OS window closing event (close button, Alt+F4) has been triggered.

Returns
1 if window should terminate; 0 otherwise.