cccp.h

Includes:
"paul_color.h"
"paul_bitmap.h"
"paul_math.h"
"paul_threads.h"
"paul_os.h"
"raudio.h"

Introduction

CCCP - The C Create Coding Project

Discussion

This header defines the core data structures and function prototypes for the CCCP project.

Updated:
Saturday, July 19, 2025


Functions

CCCP_ApplyShader

Applies a shader to a surface.

CCCP_BlitSurface

Blits one surface onto another at the specified position.

CCCP_BlitSurfaceRect

Blits a rectangular region from one surface to another.

CCCP_ClearSurface

Clears the surface with the specified color.

CCCP_ClipSurface

Clips a surface to a rectangular region.

CCCP_CopySurface

Creates a copy of an existing surface.

CCCP_DebugPrintASCII

Prints ASCII text to a surface for debugging.

CCCP_DebugPrintUnicode

Prints Unicode text to a surface for debugging.

CCCP_DestroyFont

Destroys a font.

CCCP_DestroyHashTable

Destroys a hash table.

CCCP_DestroyMusic

Destroys music.

CCCP_DestroyShader

Destroys a shader.

CCCP_DestroySound

Destroys a sound.

CCCP_DestroySurface

Destroys a surface and frees its memory.

CCCP_DestroyTimer

Destroys a timer.

CCCP_DestroyWave

Destroys a wave.

CCCP_DrawCircle

Draws a circle.

CCCP_DrawLine

Draws a line between two points.

CCCP_DrawRect

Draws a rectangle.

CCCP_DrawText

Draws text to a surface using a font.

CCCP_DrawTriangle

Draws a triangle.

CCCP_FlipSurface

Flips a surface horizontally and/or vertically.

CCCP_GetElapsedTime

Gets the elapsed time of a timer.

CCCP_GetMasterVolume

Gets the current master volume.

CCCP_GetMusicTimeLength

Gets the total length of the music.

CCCP_GetMusicTimePlayed

Gets the current playback position of the music.

CCCP_GetMusicVolume

Gets the volume of music.

CCCP_GetPixel

Gets the color of a pixel at the specified coordinates.

CCCP_GetSoundVolume

Gets the volume of a sound.

CCCP_HashTableClear

Clears all entries from the hash table.

CCCP_HashTableGet

Gets a value from the hash table.

CCCP_HashTableInsert

Inserts a key-value pair into the hash table.

CCCP_HashTableRemove

Removes a key-value pair from the hash table.

CCCP_HashTableSize

Gets the number of entries in the hash table.

CCCP_IsMusicLooping

Checks if music is set to loop.

CCCP_IsMusicPlaying

Checks if music is currently playing.

CCCP_IsMusicReady

Checks if music is ready to use.

CCCP_IsSoundPlaying

Checks if a sound is currently playing.

CCCP_IsSoundReady

Checks if a sound is ready to use.

CCCP_IsWaveReady

Checks if a wave is ready to use.

CCCP_LoadFont

Loads a font from a file.

CCCP_NewHashTable

Creates a new hash table.

CCCP_NewMusicFromFile

Creates new music from a file.

CCCP_NewMusicFromMemory

Creates new music from data in memory.

CCCP_NewShader

Creates a new shader.

CCCP_NewSoundFromFile

Creates a new sound from a file.

CCCP_NewSoundFromWave

Creates a new sound from an existing wave.

CCCP_NewSurface

Creates a new surface with the specified dimensions and clear color.

CCCP_NewTimer

Creates a new timer.

CCCP_NewWaveFromFile

Creates a new wave from a file.

CCCP_NewWaveFromMemory

Creates a new wave from data in memory.

CCCP_PauseMusic

Pauses music.

CCCP_PauseSound

Pauses a sound.

CCCP_PauseTimer

Pauses a timer.

CCCP_PlayMusic

Plays music.

CCCP_PlaySound

Plays a sound.

CCCP_ResizeSurface

Resizes a surface to new dimensions.

CCCP_ResumeMusic

Resumes paused music.

CCCP_ResumeSound

Resumes a paused sound.

CCCP_ResumeTimer

Resumes a paused timer.

CCCP_RotateSurface

Rotates a surface by the specified angle.

CCCP_SeekMusic

Seeks to a position in the music.

CCCP_SetMasterVolume

Sets the master volume for all audio.

CCCP_SetMusicLooping

Sets whether music should loop.

CCCP_SetMusicVolume

Sets the volume of music.

CCCP_SetPixel

Sets the color of a pixel at the specified coordinates.

CCCP_SetSoundVolume

Sets the volume of a sound.

CCCP_Sleep

Sleeps for the specified number of seconds.

CCCP_StartTimer

Starts a timer.

CCCP_StopMusic

Stops music.

CCCP_StopSound

Stops a sound.

CCCP_StopTimer

Stops a timer.

CCCP_SurfaceFromCheckerboard

Creates a surface with a checkerboard pattern.

CCCP_SurfaceFromConcentricCircles

Creates a surface with concentric circles.

CCCP_SurfaceFromDiagonalGradient

Creates a surface with a diagonal gradient.

CCCP_SurfaceFromFBMNoise

Creates a surface filled with Fractional Brownian Motion noise.

CCCP_SurfaceFromFile

Loads a surface from an image file.

CCCP_SurfaceFromHorizontalGradient

Creates a surface with a horizontal gradient.

CCCP_SurfaceFromHorizontalStripes

Creates a surface with horizontal stripes.

CCCP_SurfaceFromMemory

Creates a surface from raw pixel data in memory.

CCCP_SurfaceFromPerlinNoise

Creates a surface filled with Perlin noise.

CCCP_SurfaceFromRadialGradient

Creates a surface with a radial gradient.

CCCP_SurfaceFromSimplexNoise

Creates a surface filled with Simplex noise.

CCCP_SurfaceFromValueNoise

Creates a surface filled with value noise.

CCCP_SurfaceFromVerticalGradient

Creates a surface with a vertical gradient.

CCCP_SurfaceFromVerticalStripes

Creates a surface with vertical stripes.

CCCP_SurfaceFromWhiteNoise

Creates a surface filled with white noise.

CCCP_SurfaceFromWorleyNoise

Creates a surface filled with Worley noise.

CCCP_SurfaceHeight

Gets the height of a surface.

CCCP_SurfaceWidth

Gets the width of a surface.

CCCP_UnloadAllMusic

Unloads all music from the audio context.

CCCP_UnloadAllSounds

Unloads all sounds from the audio context.

CCCP_UnloadAllWaves

Unloads all waves from the audio context.

CCCP_UpdateMusic

Updates music data.

CCCP_UpdateSound

Updates sound data.


CCCP_ApplyShader


Applies a shader to a surface.

bool CCCP_ApplyShader(
    CCCP_Surface surface,
    CCCP_Shader *shader,
    void *userdata);  
Parameters
surface

The surface to apply the shader to.

shader

Pointer to the shader.

userdata

User-defined data to pass to the shader function.

Return Value

true if the shader was applied successfully, false otherwise.


CCCP_BlitSurface


Blits one surface onto another at the specified position.

void CCCP_BlitSurface(
    CCCP_Surface dest,
    CCCP_Surface src,
    int x,
    int y);  
Parameters
dest

The destination surface.

src

The source surface.

x

X coordinate on the destination surface.

y

Y coordinate on the destination surface.


CCCP_BlitSurfaceRect


Blits a rectangular region from one surface to another.

void CCCP_BlitSurfaceRect(
    CCCP_Surface dest,
    CCCP_Surface src,
    int srcX,
    int srcY,
    int srcW,
    int srcH,
    int destX,
    int destY);  
Parameters
dest

The destination surface.

src

The source surface.

srcX

X coordinate of the source rectangle.

srcY

Y coordinate of the source rectangle.

srcW

Width of the source rectangle.

srcH

Height of the source rectangle.

destX

X coordinate on the destination surface.

destY

Y coordinate on the destination surface.


CCCP_ClearSurface


Clears the surface with the specified color.

void CCCP_ClearSurface(
    CCCP_Surface surface,
    color_t clearColor);  
Parameters
surface

The surface to clear.

clearColor

The color to clear with.


CCCP_ClipSurface


Clips a surface to a rectangular region.

CCCP_Surface CCCP_ClipSurface(
    CCCP_Surface surface,
    int x,
    int y,
    int w,
    int h);  
Parameters
surface

The surface to clip.

x

X coordinate of the clip rectangle.

y

Y coordinate of the clip rectangle.

w

Width of the clip rectangle.

h

Height of the clip rectangle.

Return Value

A new clipped surface.


CCCP_CopySurface


Creates a copy of an existing surface.

CCCP_Surface CCCP_CopySurface(
    CCCP_Surface surface);  
Parameters
surface

The surface to copy.

Return Value

A new CCCP_Surface that is a copy of the input.


CCCP_DebugPrintASCII


Prints ASCII text to a surface for debugging.

void CCCP_DebugPrintASCII(
    CCCP_Surface surface,
    int x,
    int y,
    const char *text,
    color_t color);  
Parameters
surface

The surface to print on.

x

X coordinate to start printing.

y

Y coordinate to start printing.

text

The ASCII text to print.

color

The color of the text.


CCCP_DebugPrintUnicode


Prints Unicode text to a surface for debugging.

void CCCP_DebugPrintUnicode(
    CCCP_Surface surface,
    int x,
    int y,
    const wchar_t *text,
    color_t color);  
Parameters
surface

The surface to print on.

x

X coordinate to start printing.

y

Y coordinate to start printing.

text

The Unicode text to print.

color

The color of the text.


CCCP_DestroyFont


Destroys a font.

void CCCP_DestroyFont(
    CCCP_Font *font);  
Parameters
font

The font to destroy.


CCCP_DestroyHashTable


Destroys a hash table.

void CCCP_DestroyHashTable(
    CCCP_HashTable *table);  
Parameters
table

The hash table to destroy.


CCCP_DestroyMusic


Destroys music.

bool CCCP_DestroyMusic(
    CCCP_AudioContext *ctx,
    const char *key);  
Parameters
ctx

The audio context.

key

The key of the music to destroy.

Return Value

true if the music was destroyed successfully, false otherwise.


CCCP_DestroyShader


Destroys a shader.

void CCCP_DestroyShader(
    CCCP_Shader *shader);  
Parameters
shader

Pointer to the shader to destroy.


CCCP_DestroySound


Destroys a sound.

bool CCCP_DestroySound(
    CCCP_AudioContext *ctx,
    const char *key);  
Parameters
ctx

The audio context.

key

The key of the sound to destroy.

Return Value

true if the sound was destroyed successfully, false otherwise.


CCCP_DestroySurface


Destroys a surface and frees its memory.

void CCCP_DestroySurface(
    CCCP_Surface surface);  
Parameters
surface

The surface to destroy.


CCCP_DestroyTimer


Destroys a timer.

void CCCP_DestroyTimer(
    CCCP_Timer *timer);  
Parameters
timer

The timer to destroy.


CCCP_DestroyWave


Destroys a wave.

bool CCCP_DestroyWave(
    CCCP_AudioContext *ctx,
    const char *key);  
Parameters
ctx

The audio context.

key

The key of the wave to destroy.

Return Value

true if the wave was destroyed successfully, false otherwise.


CCCP_DrawCircle


Draws a circle.

void CCCP_DrawCircle(
    CCCP_Surface surface,
    int x,
    int y,
    int radius,
    color_t color,
    bool filled);  
Parameters
surface

The surface to draw on.

x

X coordinate of the circle center.

y

Y coordinate of the circle center.

radius

Radius of the circle.

color

The color of the circle.

filled

Whether the circle should be filled.


CCCP_DrawLine


Draws a line between two points.

void CCCP_DrawLine(
    CCCP_Surface surface,
    int x1,
    int y1,
    int x2,
    int y2,
    color_t color);  
Parameters
surface

The surface to draw on.

x1

X coordinate of the start point.

y1

Y coordinate of the start point.

x2

X coordinate of the end point.

y2

Y coordinate of the end point.

color

The color of the line.


CCCP_DrawRect


Draws a rectangle.

void CCCP_DrawRect(
    CCCP_Surface surface,
    int x,
    int y,
    int w,
    int h,
    color_t color,
    bool filled);  
Parameters
surface

The surface to draw on.

x

X coordinate of the rectangle.

y

Y coordinate of the rectangle.

w

Width of the rectangle.

h

Height of the rectangle.

color

The color of the rectangle.

filled

Whether the rectangle should be filled.


CCCP_DrawText


Draws text to a surface using a font.

void CCCP_DrawText(
    CCCP_Surface surface,
    CCCP_Font *font,
    int x,
    int y,
    const char *text,
    color_t color,
    float size);  
Parameters
surface

The surface to draw on.

font

The font to use.

x

X coordinate to start drawing.

y

Y coordinate to start drawing.

text

The text to draw.

color

The color of the text.

size

The size of the text.


CCCP_DrawTriangle


Draws a triangle.

void CCCP_DrawTriangle(
    CCCP_Surface surface,
    int x1,
    int y1,
    int x2,
    int y2,
    int x3,
    int y3,
    color_t color,
    bool filled);  
Parameters
surface

The surface to draw on.

x1

X coordinate of the first vertex.

y1

Y coordinate of the first vertex.

x2

X coordinate of the second vertex.

y2

Y coordinate of the second vertex.

x3

X coordinate of the third vertex.

y3

Y coordinate of the third vertex.

color

The color of the triangle.

filled

Whether the triangle should be filled.


CCCP_FlipSurface


Flips a surface horizontally and/or vertically.

CCCP_Surface CCCP_FlipSurface(
    CCCP_Surface surface,
    bool horizontal,
    bool vertical);  
Parameters
surface

The surface to flip.

horizontal

Whether to flip horizontally.

vertical

Whether to flip vertically.

Return Value

A new flipped surface.


CCCP_GetElapsedTime


Gets the elapsed time of a timer.

double CCCP_GetElapsedTime(
    CCCP_Timer *timer);  
Parameters
timer

The timer.

Return Value

The elapsed time in seconds.


CCCP_GetMasterVolume


Gets the current master volume.

float CCCP_GetMasterVolume(
    CCCP_AudioContext *ctx);  
Parameters
ctx

The audio context.

Return Value

The current master volume (0.0 to 1.0).


CCCP_GetMusicTimeLength


Gets the total length of the music.

float CCCP_GetMusicTimeLength(
    CCCP_AudioContext *ctx,
    const char *key);  
Parameters
ctx

The audio context.

key

The key of the music.

Return Value

The total length in seconds.


CCCP_GetMusicTimePlayed


Gets the current playback position of the music.

float CCCP_GetMusicTimePlayed(
    CCCP_AudioContext *ctx,
    const char *key);  
Parameters
ctx

The audio context.

key

The key of the music.

Return Value

The current position in seconds.


CCCP_GetMusicVolume


Gets the volume of music.

float CCCP_GetMusicVolume(
    CCCP_AudioContext *ctx,
    const char *key);  
Parameters
ctx

The audio context.

key

The key of the music.

Return Value

The current volume level (0.0 to 1.0).


CCCP_GetPixel


Gets the color of a pixel at the specified coordinates.

color_t CCCP_GetPixel(
    CCCP_Surface surface,
    int x,
    int y);  
Parameters
surface

The surface.

x

X coordinate of the pixel.

y

Y coordinate of the pixel.

Return Value

The color of the pixel.


CCCP_GetSoundVolume


Gets the volume of a sound.

float CCCP_GetSoundVolume(
    CCCP_AudioContext *ctx,
    const char *key);  
Parameters
ctx

The audio context.

key

The key of the sound.

Return Value

The current volume level (0.0 to 1.0).


CCCP_HashTableClear


Clears all entries from the hash table.

void CCCP_HashTableClear(
    CCCP_HashTable *table);  
Parameters
table

The hash table.


CCCP_HashTableGet


Gets a value from the hash table.

void* CCCP_HashTableGet(
    CCCP_HashTable *table,
    const char *key);  
Parameters
table

The hash table.

key

The key string.

Return Value

The value pointer, or NULL if not found.


CCCP_HashTableInsert


Inserts a key-value pair into the hash table.

int CCCP_HashTableInsert(
    CCCP_HashTable *table,
    const char *key,
    void *value);  
Parameters
table

The hash table.

key

The key string.

value

The value pointer.

Return Value

0 on success, non-zero on failure.


CCCP_HashTableRemove


Removes a key-value pair from the hash table.

int CCCP_HashTableRemove(
    CCCP_HashTable *table,
    const char *key);  
Parameters
table

The hash table.

key

The key string.

Return Value

0 on success, non-zero on failure.


CCCP_HashTableSize


Gets the number of entries in the hash table.

size_t CCCP_HashTableSize(
    CCCP_HashTable *table);  
Parameters
table

The hash table.

Return Value

The number of entries.


CCCP_IsMusicLooping


Checks if music is set to loop.

bool CCCP_IsMusicLooping(
    CCCP_AudioContext *ctx,
    const char *key);  
Parameters
ctx

The audio context.

key

The key of the music.

Return Value

true if looping is enabled, false otherwise.


CCCP_IsMusicPlaying


Checks if music is currently playing.

bool CCCP_IsMusicPlaying(
    CCCP_AudioContext *ctx,
    const char *key);  
Parameters
ctx

The audio context.

key

The key of the music.

Return Value

true if the music is playing, false otherwise.


CCCP_IsMusicReady


Checks if music is ready to use.

bool CCCP_IsMusicReady(
    CCCP_AudioContext *ctx,
    const char *key);  
Parameters
ctx

The audio context.

key

The key of the music.

Return Value

true if the music is ready, false otherwise.


CCCP_IsSoundPlaying


Checks if a sound is currently playing.

bool CCCP_IsSoundPlaying(
    CCCP_AudioContext *ctx,
    const char *key);  
Parameters
ctx

The audio context.

key

The key of the sound.

Return Value

true if the sound is playing, false otherwise.


CCCP_IsSoundReady


Checks if a sound is ready to use.

bool CCCP_IsSoundReady(
    CCCP_AudioContext *ctx,
    const char *key);  
Parameters
ctx

The audio context.

key

The key of the sound.

Return Value

true if the sound is ready, false otherwise.


CCCP_IsWaveReady


Checks if a wave is ready to use.

bool CCCP_IsWaveReady(
    CCCP_AudioContext *ctx,
    const char *key);  
Parameters
ctx

The audio context.

key

The key of the wave.

Return Value

true if the wave is ready, false otherwise.


CCCP_LoadFont


Loads a font from a file.

CCCP_Font* CCCP_LoadFont(
    const char *filename);  
Parameters
filename

Path to the font file.

Return Value

A new CCCP_Font, or NULL on failure.


CCCP_NewHashTable


Creates a new hash table.

CCCP_HashTable* CCCP_NewHashTable(
    size_t capacity);  
Parameters
capacity

Initial capacity of the hash table.

Return Value

A new CCCP_HashTable.


CCCP_NewMusicFromFile


Creates new music from a file.

bool CCCP_NewMusicFromFile(
    CCCP_AudioContext *ctx,
    const char *key,
    const char *filename);  
Parameters
ctx

The audio context.

key

The key to associate with the music.

filename

Path to the music file.

Return Value

true if the music was created successfully, false otherwise.


CCCP_NewMusicFromMemory


Creates new music from data in memory.

bool CCCP_NewMusicFromMemory(
    CCCP_AudioContext *ctx,
    const char *key,
    const void *data,
    int dataSize);  
Parameters
ctx

The audio context.

key

The key to associate with the music.

data

The music data.

dataSize

Size of the data in bytes.

Return Value

true if the music was created successfully, false otherwise.


CCCP_NewShader


Creates a new shader.

CCCP_Shader CCCP_NewShader(
    CCCP_ShaderFunc func,
    int numThreads);  
Parameters
func

The shader function.

numThreads

Number of threads to use (0 = hardware concurrency).

Return Value

A new CCCP_Shader.


CCCP_NewSoundFromFile


Creates a new sound from a file.

bool CCCP_NewSoundFromFile(
    CCCP_AudioContext *ctx,
    const char *key,
    const char *filename);  
Parameters
ctx

The audio context.

key

The key to associate with the sound.

filename

Path to the sound file.

Return Value

true if the sound was created successfully, false otherwise.


CCCP_NewSoundFromWave


Creates a new sound from an existing wave.

bool CCCP_NewSoundFromWave(
    CCCP_AudioContext *ctx,
    const char *key,
    const char *waveKey);  
Parameters
ctx

The audio context.

key

The key to associate with the sound.

waveKey

The key of the wave to use.

Return Value

true if the sound was created successfully, false otherwise.


CCCP_NewSurface


Creates a new surface with the specified dimensions and clear color.

CCCP_Surface CCCP_NewSurface(
    unsigned int w,
    unsigned int h,
    color_t clearColor);  
Parameters
w

Width of the surface.

h

Height of the surface.

clearColor

Initial clear color for the surface.

Return Value

A new CCCP_Surface.


CCCP_NewTimer


Creates a new timer.

CCCP_Timer* CCCP_NewTimer(
    void);  
Return Value

A new CCCP_Timer.


CCCP_NewWaveFromFile


Creates a new wave from a file.

bool CCCP_NewWaveFromFile(
    CCCP_AudioContext *ctx,
    const char *key,
    const char *filename);  
Parameters
ctx

The audio context.

key

The key to associate with the wave.

filename

Path to the wave file.

Return Value

true if the wave was created successfully, false otherwise.


CCCP_NewWaveFromMemory


Creates a new wave from data in memory.

bool CCCP_NewWaveFromMemory(
    CCCP_AudioContext *ctx,
    const char *key,
    const void *data,
    int dataSize);  
Parameters
ctx

The audio context.

key

The key to associate with the wave.

data

The wave data.

dataSize

Size of the data in bytes.

Return Value

true if the wave was created successfully, false otherwise.


CCCP_PauseMusic


Pauses music.

void CCCP_PauseMusic(
    CCCP_AudioContext *ctx,
    const char *key);  
Parameters
ctx

The audio context.

key

The key of the music to pause.


CCCP_PauseSound


Pauses a sound.

void CCCP_PauseSound(
    CCCP_AudioContext *ctx,
    const char *key);  
Parameters
ctx

The audio context.

key

The key of the sound to pause.


CCCP_PauseTimer


Pauses a timer.

void CCCP_PauseTimer(
    CCCP_Timer *timer);  
Parameters
timer

The timer to pause.


CCCP_PlayMusic


Plays music.

void CCCP_PlayMusic(
    CCCP_AudioContext *ctx,
    const char *key);  
Parameters
ctx

The audio context.

key

The key of the music to play.


CCCP_PlaySound


Plays a sound.

void CCCP_PlaySound(
    CCCP_AudioContext *ctx,
    const char *key);  
Parameters
ctx

The audio context.

key

The key of the sound to play.


CCCP_ResizeSurface


Resizes a surface to new dimensions.

CCCP_Surface CCCP_ResizeSurface(
    CCCP_Surface surface,
    unsigned int w,
    unsigned int h);  
Parameters
surface

The surface to resize.

w

New width.

h

New height.

Return Value

A new resized surface.


CCCP_ResumeMusic


Resumes paused music.

void CCCP_ResumeMusic(
    CCCP_AudioContext *ctx,
    const char *key);  
Parameters
ctx

The audio context.

key

The key of the music to resume.


CCCP_ResumeSound


Resumes a paused sound.

void CCCP_ResumeSound(
    CCCP_AudioContext *ctx,
    const char *key);  
Parameters
ctx

The audio context.

key

The key of the sound to resume.


CCCP_ResumeTimer


Resumes a paused timer.

void CCCP_ResumeTimer(
    CCCP_Timer *timer);  
Parameters
timer

The timer to resume.


CCCP_RotateSurface


Rotates a surface by the specified angle.

CCCP_Surface CCCP_RotateSurface(
    CCCP_Surface surface,
    float angle);  
Parameters
surface

The surface to rotate.

angle

Rotation angle in radians.

Return Value

A new rotated surface.


CCCP_SeekMusic


Seeks to a position in the music.

void CCCP_SeekMusic(
    CCCP_AudioContext *ctx,
    const char *key,
    float position);  
Parameters
ctx

The audio context.

key

The key of the music.

position

The position to seek to (in seconds).


CCCP_SetMasterVolume


Sets the master volume for all audio.

void CCCP_SetMasterVolume(
    CCCP_AudioContext *ctx,
    float volume);  
Parameters
ctx

The audio context.

volume

The volume level (0.0 to 1.0).


CCCP_SetMusicLooping


Sets whether music should loop.

void CCCP_SetMusicLooping(
    CCCP_AudioContext *ctx,
    const char *key,
    bool looping);  
Parameters
ctx

The audio context.

key

The key of the music.

looping

Whether to enable looping.


CCCP_SetMusicVolume


Sets the volume of music.

void CCCP_SetMusicVolume(
    CCCP_AudioContext *ctx,
    const char *key,
    float volume);  
Parameters
ctx

The audio context.

key

The key of the music.

volume

The volume level (0.0 to 1.0).


CCCP_SetPixel


Sets the color of a pixel at the specified coordinates.

bool CCCP_SetPixel(
    CCCP_Surface surface,
    int x,
    int y,
    color_t color);  
Parameters
surface

The surface.

x

X coordinate of the pixel.

y

Y coordinate of the pixel.

color

The color to set.

Return Value

true if the pixel was set successfully, false otherwise.


CCCP_SetSoundVolume


Sets the volume of a sound.

void CCCP_SetSoundVolume(
    CCCP_AudioContext *ctx,
    const char *key,
    float volume);  
Parameters
ctx

The audio context.

key

The key of the sound.

volume

The volume level (0.0 to 1.0).


CCCP_Sleep


Sleeps for the specified number of seconds.

void CCCP_Sleep(
    double seconds);  
Parameters
seconds

The number of seconds to sleep.


CCCP_StartTimer


Starts a timer.

void CCCP_StartTimer(
    CCCP_Timer *timer);  
Parameters
timer

The timer to start.


CCCP_StopMusic


Stops music.

void CCCP_StopMusic(
    CCCP_AudioContext *ctx,
    const char *key);  
Parameters
ctx

The audio context.

key

The key of the music to stop.


CCCP_StopSound


Stops a sound.

void CCCP_StopSound(
    CCCP_AudioContext *ctx,
    const char *key);  
Parameters
ctx

The audio context.

key

The key of the sound to stop.


CCCP_StopTimer


Stops a timer.

void CCCP_StopTimer(
    CCCP_Timer *timer);  
Parameters
timer

The timer to stop.


CCCP_SurfaceFromCheckerboard


Creates a surface with a checkerboard pattern.

CCCP_Surface CCCP_SurfaceFromCheckerboard(
    unsigned int width,
    unsigned int height,
    color_t color1,
    color_t color2,
    unsigned int squareSize);  
Parameters
width

Width of the surface.

height

Height of the surface.

color1

First color of the checkerboard.

color2

Second color of the checkerboard.

squareSize

Size of each square in the checkerboard.

Return Value

A new surface with checkerboard pattern.


CCCP_SurfaceFromConcentricCircles


Creates a surface with concentric circles.

CCCP_Surface CCCP_SurfaceFromConcentricCircles(
    unsigned int width,
    unsigned int height,
    color_t centerColor,
    color_t edgeColor,
    unsigned int numRings);  
Parameters
width

Width of the surface.

height

Height of the surface.

centerColor

Color at the center.

edgeColor

Color at the edges.

numRings

Number of concentric rings.

Return Value

A new surface with concentric circles.


CCCP_SurfaceFromDiagonalGradient


Creates a surface with a diagonal gradient.

CCCP_Surface CCCP_SurfaceFromDiagonalGradient(
    unsigned int width,
    unsigned int height,
    color_t startColor,
    color_t endColor);  
Parameters
width

Width of the surface.

height

Height of the surface.

startColor

Starting color of the gradient.

endColor

Ending color of the gradient.

Return Value

A new surface with diagonal gradient.


CCCP_SurfaceFromFBMNoise


Creates a surface filled with Fractional Brownian Motion noise.

CCCP_Surface CCCP_SurfaceFromFBMNoise(
    unsigned int width,
    unsigned int height,
    float scale,
    float offsetX,
    float offsetY,
    float lacunarity,
    float gain,
    int octaves);  
Parameters
width

Width of the surface.

height

Height of the surface.

scale

Scale of the noise.

offsetX

X offset for the noise.

offsetY

Y offset for the noise.

lacunarity

Lacunarity parameter for FBM.

gain

Gain parameter for FBM.

octaves

Number of octaves for FBM.

Return Value

A new surface with FBM noise.


CCCP_SurfaceFromFile


Loads a surface from an image file.

CCCP_Surface CCCP_SurfaceFromFile(
    const char *filename);  
Parameters
filename

Path to the image file.

Return Value

A new CCCP_Surface, or NULL on failure.


CCCP_SurfaceFromHorizontalGradient


Creates a surface with a horizontal gradient.

CCCP_Surface CCCP_SurfaceFromHorizontalGradient(
    unsigned int width,
    unsigned int height,
    color_t startColor,
    color_t endColor);  
Parameters
width

Width of the surface.

height

Height of the surface.

startColor

Starting color of the gradient.

endColor

Ending color of the gradient.

Return Value

A new surface with horizontal gradient.


CCCP_SurfaceFromHorizontalStripes


Creates a surface with horizontal stripes.

CCCP_Surface CCCP_SurfaceFromHorizontalStripes(
    unsigned int width,
    unsigned int height,
    color_t color1,
    color_t color2,
    unsigned int stripeWidth);  
Parameters
width

Width of the surface.

height

Height of the surface.

color1

First color of the stripes.

color2

Second color of the stripes.

stripeWidth

Width of each stripe.

Return Value

A new surface with horizontal stripes.


CCCP_SurfaceFromMemory


Creates a surface from raw pixel data in memory.

CCCP_Surface CCCP_SurfaceFromMemory(
    const void *data,
    int width,
    int height,
    bitmap_format_t format);  
Parameters
data

Pointer to the pixel data.

width

Width of the image.

height

Height of the image.

format

Format of the pixel data.

Return Value

A new CCCP_Surface.


CCCP_SurfaceFromPerlinNoise


Creates a surface filled with Perlin noise.

CCCP_Surface CCCP_SurfaceFromPerlinNoise(
    unsigned int width,
    unsigned int height,
    float scale,
    float offsetX,
    float offsetY);  
Parameters
width

Width of the surface.

height

Height of the surface.

scale

Scale of the noise.

offsetX

X offset for the noise.

offsetY

Y offset for the noise.

Return Value

A new surface with Perlin noise.


CCCP_SurfaceFromRadialGradient


Creates a surface with a radial gradient.

CCCP_Surface CCCP_SurfaceFromRadialGradient(
    unsigned int width,
    unsigned int height,
    color_t centerColor,
    color_t edgeColor);  
Parameters
width

Width of the surface.

height

Height of the surface.

centerColor

Color at the center.

edgeColor

Color at the edges.

Return Value

A new surface with radial gradient.


CCCP_SurfaceFromSimplexNoise


Creates a surface filled with Simplex noise.

CCCP_Surface CCCP_SurfaceFromSimplexNoise(
    unsigned int width,
    unsigned int height,
    float scale,
    float offsetX,
    float offsetY);  
Parameters
width

Width of the surface.

height

Height of the surface.

scale

Scale of the noise.

offsetX

X offset for the noise.

offsetY

Y offset for the noise.

Return Value

A new surface with Simplex noise.


CCCP_SurfaceFromValueNoise


Creates a surface filled with value noise.

CCCP_Surface CCCP_SurfaceFromValueNoise(
    unsigned int width,
    unsigned int height,
    float scale,
    float offsetX,
    float offsetY);  
Parameters
width

Width of the surface.

height

Height of the surface.

scale

Scale of the noise.

offsetX

X offset for the noise.

offsetY

Y offset for the noise.

Return Value

A new surface with value noise.


CCCP_SurfaceFromVerticalGradient


Creates a surface with a vertical gradient.

CCCP_Surface CCCP_SurfaceFromVerticalGradient(
    unsigned int width,
    unsigned int height,
    color_t startColor,
    color_t endColor);  
Parameters
width

Width of the surface.

height

Height of the surface.

startColor

Starting color of the gradient.

endColor

Ending color of the gradient.

Return Value

A new surface with vertical gradient.


CCCP_SurfaceFromVerticalStripes


Creates a surface with vertical stripes.

CCCP_Surface CCCP_SurfaceFromVerticalStripes(
    unsigned int width,
    unsigned int height,
    color_t color1,
    color_t color2,
    unsigned int stripeWidth);  
Parameters
width

Width of the surface.

height

Height of the surface.

color1

First color of the stripes.

color2

Second color of the stripes.

stripeWidth

Width of each stripe.

Return Value

A new surface with vertical stripes.


CCCP_SurfaceFromWhiteNoise


Creates a surface filled with white noise.

CCCP_Surface CCCP_SurfaceFromWhiteNoise(
    unsigned int width,
    unsigned int height,
    float scale,
    float offsetX,
    float offsetY);  
Parameters
width

Width of the surface.

height

Height of the surface.

scale

Scale of the noise.

offsetX

X offset for the noise.

offsetY

Y offset for the noise.

Return Value

A new surface with white noise.


CCCP_SurfaceFromWorleyNoise


Creates a surface filled with Worley noise.

CCCP_Surface CCCP_SurfaceFromWorleyNoise(
    unsigned int width,
    unsigned int height,
    float scale,
    float offsetX,
    float offsetY);  
Parameters
width

Width of the surface.

height

Height of the surface.

scale

Scale of the noise.

offsetX

X offset for the noise.

offsetY

Y offset for the noise.

Return Value

A new surface with Worley noise.


CCCP_SurfaceHeight


Gets the height of a surface.

int CCCP_SurfaceHeight(
    CCCP_Surface surface);  
Parameters
surface

The surface.

Return Value

The height of the surface.


CCCP_SurfaceWidth


Gets the width of a surface.

int CCCP_SurfaceWidth(
    CCCP_Surface surface);  
Parameters
surface

The surface.

Return Value

The width of the surface.


CCCP_UnloadAllMusic


Unloads all music from the audio context.

void CCCP_UnloadAllMusic(
    CCCP_AudioContext *ctx);  
Parameters
ctx

The audio context.


CCCP_UnloadAllSounds


Unloads all sounds from the audio context.

void CCCP_UnloadAllSounds(
    CCCP_AudioContext *ctx);  
Parameters
ctx

The audio context.


CCCP_UnloadAllWaves


Unloads all waves from the audio context.

void CCCP_UnloadAllWaves(
    CCCP_AudioContext *ctx);  
Parameters
ctx

The audio context.


CCCP_UpdateMusic


Updates music data.

void CCCP_UpdateMusic(
    CCCP_AudioContext *ctx,
    const char *key,
    const void *data,
    int sampleCount);  
Parameters
ctx

The audio context.

key

The key of the music.

data

The new music data.

sampleCount

Number of samples in the data.


CCCP_UpdateSound


Updates sound data.

void CCCP_UpdateSound(
    CCCP_AudioContext *ctx,
    const char *key,
    const void *data,
    int frameCount);  
Parameters
ctx

The audio context.

key

The key of the sound.

data

The new sound data.

frameCount

Number of frames in the data.


Typedefs

CCCP_AudioContext

Context for managing audio resources.

CCCP_Event

Represents an input event in the application.

CCCP_EventType

Types of events that can occur in the application.

CCCP_Font

Opaque type representing a font.

CCCP_HashEntry

Represents an entry in a hash table.

CCCP_HashTable

Represents a hash table data structure.

CCCP_Key

Key codes for keyboard input.

CCCP_ModifierKey

Modifier key flags for keyboard input.

CCCP_Scene

Configuration structure for a scene in the application.

CCCP_Shader

Represents a shader for surface processing.

CCCP_ShaderFunc

Function pointer type for shader functions.

CCCP_State

Opaque type representing the application state.

CCCP_Timer

Opaque type representing a timer.

CCCP_WindowFlags

Flags for configuring window properties.


CCCP_AudioContext


Context for managing audio resources.

typedef struct CCCP_AudioContext { 
    float volume; 
    CCCP_HashTable *waves; 
    CCCP_HashTable *sounds; 
    CCCP_HashTable *music; 
} CCCP_AudioContext;  
Fields
volume

Master volume level.

waves

Hash table of wave resources.

sounds

Hash table of sound resources.

music

Hash table of music resources.


CCCP_Event


Represents an input event in the application.

typedef struct { 
    struct { 
        int button; 
        int down; 
        struct { 
            unsigned int x, y; 
            float dx, dy; 
                } position; 
        struct { 
            float dx, dy; 
                } wheel; 
        } mouse; 
    struct { 
        CCCP_Key key; 
        int down; 
        } keyboard; 
    CCCP_ModifierKey modifier; 
    struct { 
        int focused, closed; 
        struct { 
            unsigned int width, height; 
                } size; 
        } window; 
    CCCP_EventType type; 
} CCCP_Event;  
Fields
mouse

Mouse-related event data.

mouse.button

Mouse button number.

mouse.down

Whether the mouse button is pressed (1) or released (0).

mouse.position

Mouse position coordinates.

mouse.position.x

Mouse X coordinate.

mouse.position.y

Mouse Y coordinate.

mouse.position.dx

Mouse delta X.

mouse.position.dy

Mouse delta Y.

mouse.wheel

Mouse wheel scroll data.

mouse.wheel.dx

Horizontal scroll delta.

mouse.wheel.dy

Vertical scroll delta.

keyboard

Keyboard-related event data.

keyboard.key

The key that was pressed or released.

keyboard.down

Whether the key is pressed (1) or released (0).

modifier

Modifier keys that are currently pressed.

window

Window-related event data.

window.focused

Whether the window is focused (1) or not (0).

window.closed

Whether the window is closed (1) or not (0).

window.size

Window dimensions.

window.size.width

Window width.

window.size.height

Window height.

type

The type of event.


CCCP_EventType


Types of events that can occur in the application.

typedef enum { 
    #define X(NAME,
            ARGS) NAME##Event, 
    CCCP_CALLBACKS  #undef X 
} CCCP_EventType;  
Constants
KeyboardEvent

Keyboard input event.

MouseButtonEvent

Mouse button event.

MouseMoveEvent

Mouse movement event.

MouseScrollEvent

Mouse scroll event.

ResizedEvent

Window resize event.

FocusEvent

Window focus event.


CCCP_Font


Opaque type representing a font.

typedef struct CCCP_Font CCCP_Font;  

CCCP_HashEntry


Represents an entry in a hash table.

typedef struct CCCP_HashEntry { 
    const char *key; 
    void *value; 
    struct CCCP_HashEntry *next; 
} CCCP_HashEntry;  
Fields
key

The key string.

value

The value pointer.

next

Pointer to the next entry in the chain.


CCCP_HashTable


Represents a hash table data structure.

typedef struct { 
    CCCP_HashEntry **buckets; 
    size_t capacity; 
    size_t size; 
    void(*free_callback)(
        void*); 
} CCCP_HashTable;  
Fields
buckets

Array of bucket pointers.

capacity

Maximum number of buckets.

size

Current number of entries.

free_callback

Function to free values when destroying the table.


CCCP_Key


Key codes for keyboard input.

typedef enum { 
    KEY_PAD0=128,
    KEY_PAD1,
    KEY_PAD2,
    KEY_PAD3,
    KEY_PAD4,
    KEY_PAD5,
    KEY_PAD6,
    KEY_PAD7, 
    KEY_PAD8,
    KEY_PAD9,
    KEY_PADMUL,
    KEY_PADADD,
    KEY_PADENTER,
    KEY_PADSUB,
    KEY_PADDOT, 
    KEY_PADDIV,
    KEY_F1,
    KEY_F2,
    KEY_F3,
    KEY_F4,
    KEY_F5,
    KEY_F6,
    KEY_F7,
    KEY_F8,
    KEY_F9, 
    KEY_F10,
    KEY_F11,
    KEY_F12,
    KEY_BACKSPACE,
    KEY_TAB,
    KEY_RETURN,
    KEY_SHIFT, 
    KEY_CONTROL,
    KEY_ALT,
    KEY_PAUSE,
    KEY_CAPSLOCK,
    KEY_ESCAPE,
    KEY_SPACE,
    KEY_PAGEUP, 
    KEY_PAGEDN,
    KEY_END,
    KEY_HOME,
    KEY_LEFT,
    KEY_UP,
    KEY_RIGHT,
    KEY_DOWN,
    KEY_INSERT, 
    KEY_DELETE,
    KEY_LWIN,
    KEY_RWIN,
    KEY_NUMLOCK,
    KEY_SCROLL,
    KEY_LSHIFT,
    KEY_RSHIFT, 
    KEY_LCONTROL,
    KEY_RCONTROL,
    KEY_LALT,
    KEY_RALT,
    KEY_SEMICOLON,
    KEY_EQUALS, 
    KEY_COMMA,
    KEY_MINUS,
    KEY_DOT,
    KEY_SLASH,
    KEY_BACKTICK,
    KEY_LSQUARE, 
    KEY_BACKSLASH,
    KEY_RSQUARE,
    KEY_TICK 
} CCCP_Key;  
Constants
KEY_PAD0

Numpad 0 key.

KEY_PAD1

Numpad 1 key.

KEY_PAD2

Numpad 2 key.

KEY_PAD3

Numpad 3 key.

KEY_PAD4

Numpad 4 key.

KEY_PAD5

Numpad 5 key.

KEY_PAD6

Numpad 6 key.

KEY_PAD7

Numpad 7 key.

KEY_PAD8

Numpad 8 key.

KEY_PAD9

Numpad 9 key.

KEY_PADMUL

Numpad multiply key.

KEY_PADADD

Numpad add key.

KEY_PADENTER

Numpad enter key.

KEY_PADSUB

Numpad subtract key.

KEY_PADDOT

Numpad decimal point key.

KEY_PADDIV

Numpad divide key.

KEY_F1

F1 function key.

KEY_F2

F2 function key.

KEY_F3

F3 function key.

KEY_F4

F4 function key.

KEY_F5

F5 function key.

KEY_F6

F6 function key.

KEY_F7

F7 function key.

KEY_F8

F8 function key.

KEY_F9

F9 function key.

KEY_F10

F10 function key.

KEY_F11

F11 function key.

KEY_F12

F12 function key.

KEY_BACKSPACE

Backspace key.

KEY_TAB

Tab key.

KEY_RETURN

Return/Enter key.

KEY_SHIFT

Shift key.

KEY_CONTROL

Control key.

KEY_ALT

Alt key.

KEY_PAUSE

Pause key.

KEY_CAPSLOCK

Caps Lock key.

KEY_ESCAPE

Escape key.

KEY_SPACE

Spacebar key.

KEY_PAGEUP

Page Up key.

KEY_PAGEDN

Page Down key.

KEY_END

End key.

KEY_HOME

Home key.

KEY_LEFT

Left arrow key.

KEY_UP

Up arrow key.

KEY_RIGHT

Right arrow key.

KEY_DOWN

Down arrow key.

KEY_INSERT

Insert key.

KEY_DELETE

Delete key.

KEY_LWIN

Left Windows key.

KEY_RWIN

Right Windows key.

KEY_NUMLOCK

Num Lock key.

KEY_SCROLL

Scroll Lock key.

KEY_LSHIFT

Left Shift key.

KEY_RSHIFT

Right Shift key.

KEY_LCONTROL

Left Control key.

KEY_RCONTROL

Right Control key.

KEY_LALT

Left Alt key.

KEY_RALT

Right Alt key.

KEY_SEMICOLON

Semicolon key.

KEY_EQUALS

Equals key.

KEY_COMMA

Comma key.

KEY_MINUS

Minus key.

KEY_DOT

Period key.

KEY_SLASH

Slash key.

KEY_BACKTICK

Backtick key.

KEY_LSQUARE

Left square bracket key.

KEY_BACKSLASH

Backslash key.

KEY_RSQUARE

Right square bracket key.

KEY_TICK

Tick/Quote key.


CCCP_ModifierKey


Modifier key flags for keyboard input.

typedef enum { 
    KEY_MOD_SHIFT = 1 << 0, 
    KEY_MOD_CONTROL = 1 << 1, 
    KEY_MOD_ALT = 1 << 2, 
    KEY_MOD_SUPER = 1 << 3, 
    KEY_MOD_CAPS_LOCK = 1 << 4, 
    KEY_MOD_NUM_LOCK = 1 << 5 
} CCCP_ModifierKey;  
Constants
KEY_MOD_SHIFT

Shift modifier key.

KEY_MOD_CONTROL

Control modifier key.

KEY_MOD_ALT

Alt modifier key.

KEY_MOD_SUPER

Super/Windows modifier key.

KEY_MOD_CAPS_LOCK

Caps Lock modifier.

KEY_MOD_NUM_LOCK

Num Lock modifier.


CCCP_Scene


Configuration structure for a scene in the application.

typedef struct { 
    int windowWidth; 
    int windowHeight; 
    const char *windowTitle; 
    color_t clearColor; 
    int targetFPS; 
    CCCP_State *(*init)(
        CCCP_Surface,
        CCCP_AudioContext*); 
    void(*deinit)(
        CCCP_State*,
        CCCP_AudioContext*); 
    void(*reload)(
        CCCP_State*,
        CCCP_AudioContext*); 
    void(*unload)(
        CCCP_State*,
        CCCP_AudioContext*); 
    int(*event)(
        CCCP_State*,
        CCCP_Event*,
        CCCP_AudioContext*); 
    int(*tick)(
        CCCP_State*,
        CCCP_Surface,
        CCCP_AudioContext*,
        double); 
} CCCP_Scene;  
Fields
windowWidth

Initial window width.

windowHeight

Initial window height.

windowTitle

Window title string.

clearColor

Background clear color.

targetFPS

Target frames per second.

init

Function called to initialize the scene state.

deinit

Function called to deinitialize the scene state.

reload

Function called when the scene is reloaded.

unload

Function called when the scene is unloaded.

event

Function called to handle events.

tick

Function called each frame to update the scene.


CCCP_Shader


Represents a shader for surface processing.

typedef struct { 
    CCCP_ShaderFunc func; 
    int thread_count; // 0 = use hardware concurrency 
} CCCP_Shader;  
Fields
func

Pointer to the shader function.

thread_count

Number of threads to use (0 = use hardware concurrency).


CCCP_ShaderFunc


Function pointer type for shader functions.

typedef vec4( *CCCP_ShaderFunc)(
    vec2,
    vec2,
    float,
    void *);  
Parameters
fragcoord

Fragment coordinates (vec2).

resolution

Surface resolution (vec2).

time

Current time (float).

userdata

User-defined data pointer.

Return Value

Color value (vec4).


CCCP_State


Opaque type representing the application state.

typedef struct CCCP_State CCCP_State;  

CCCP_Timer


Opaque type representing a timer.

typedef struct CCCP_Timer CCCP_Timer;  

CCCP_WindowFlags


Flags for configuring window properties.

typedef enum { 
    WINDOW_RESIZABLE = 1 << 0, 
    WINDOW_FULLSCREEN = 1 << 1, 
    WINDOW_FULLSCREEN_DESKTOP = 1 << 2, 
    WINDOW_BORDERLESS = 1 << 3, 
    WINDOW_ALWAYS_ON_TOP = 1 << 4 
} CCCP_WindowFlags;  
Constants
WINDOW_RESIZABLE

Window can be resized by the user.

WINDOW_FULLSCREEN

Window is in fullscreen mode.

WINDOW_FULLSCREEN_DESKTOP

Window is in fullscreen desktop mode.

WINDOW_BORDERLESS

Window has no border.

WINDOW_ALWAYS_ON_TOP

Window stays on top of other windows.