Skip to content

Commit

Permalink
style: update based on new style guide changes
Browse files Browse the repository at this point in the history
  • Loading branch information
hoffstadt committed Oct 22, 2024
1 parent 2df8e2d commit db87039
Show file tree
Hide file tree
Showing 8 changed files with 84 additions and 84 deletions.
4 changes: 2 additions & 2 deletions extensions/pl_gpu_allocators_ext.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ typedef struct _plGPUAllocatorsI
void (*cleanup)(plDevice*);

// for debug viewing
plDeviceMemoryAllocation* (*get_blocks)(const plDeviceMemoryAllocatorI*, uint32_t* puSizeOut);
plDeviceAllocationRange* (*get_ranges)(const plDeviceMemoryAllocatorI*, uint32_t* puSizeOut);
plDeviceMemoryAllocation* (*get_blocks)(const plDeviceMemoryAllocatorI*, uint32_t* sizeOut);
plDeviceAllocationRange* (*get_ranges)(const plDeviceMemoryAllocatorI*, uint32_t* sizeOut);

} plGPUAllocatorsI;

Expand Down
20 changes: 10 additions & 10 deletions extensions/pl_image_ext.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,28 +51,28 @@ typedef struct _plImageWriteInfo plImageWriteInfo;
typedef struct _plImageI
{
// query image info
bool (*get_info) (char const* pcFilename, plImageInfo* ptInfoOut);
bool (*get_info_from_memory)(const unsigned char* pcBuffer, int iLength, plImageInfo* ptInfoOut);
bool (*get_info) (char const* filename, plImageInfo* infoOut);
bool (*get_info_from_memory)(const unsigned char* buffer, int length, plImageInfo* infoOut);

// reading LDR (HDR will be remapped through this interface)
unsigned char* (*load_from_memory) (const unsigned char* pcBuffer, int iLength, int* piX, int* piY, int* piChannels, int iDesiredChannels);
unsigned char* (*load) (char const* pcFilename, int* piX, int* piY, int* piChannels, int iDesiredChannels);
unsigned short* (*load_16bit_from_memory)(const unsigned char* pcBuffer, int iLength, int* piX, int* piY, int* piChannels, int iDesiredChannels);
unsigned short* (*load_16bit) (char const* pcFilename, int* piX, int* piY, int* piChannels, int iDesiredChannels);
unsigned char* (*load_from_memory) (const unsigned char* buffer, int length, int* x, int* y, int* channels, int desiredChannels);
unsigned char* (*load) (char const* filename, int* x, int* y, int* channels, int desiredChannels);
unsigned short* (*load_16bit_from_memory)(const unsigned char* buffer, int length, int* x, int* y, int* channels, int desiredChannels);
unsigned short* (*load_16bit) (char const* filename, int* y, int* x, int* channels, int desiredChannels);
void (*set_hdr_to_ldr_gamma) (float); // default 2.2f
void (*set_hdr_to_ldr_scale) (float); // default 1.0f

// reading HDR (LDR will be promoted to floating point values)
float* (*load_hdr_from_memory)(const unsigned char* pcBuffer, int iLength, int* piX, int* piY, int* piChannels, int iDesiredChannels);
float* (*load_hdr) (char const* pcFilename, int* piX, int* piY, int* piChannels, int iDesiredChannels);
float* (*load_hdr_from_memory)(const unsigned char* buffer, int length, int* x, int* y, int* channels, int desiredChannels);
float* (*load_hdr) (char const* filename, int* x, int* y, int* channels, int desiredChannels);
void (*set_ldr_to_hdr_gamma)(float); // default 2.2f
void (*set_ldr_to_hdr_scale)(float); // default 1.0f

// call when finished with memory
void (*free)(void* pRetValueFromLoad);
void (*free)(void* returnValueFromLoad);

// writing to disk (currently supports png, jpg, bmp, hdr, tga)
bool (*write)(char const *pcFileName, const void *pData, const plImageWriteInfo*);
bool (*write)(char const* filename, const void* data, const plImageWriteInfo*);
} plImageI;

//-----------------------------------------------------------------------------
Expand Down
6 changes: 3 additions & 3 deletions extensions/pl_job_ext.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,22 +54,22 @@ typedef struct _plAtomicCounter plAtomicCounter; // pl_os.h
typedef struct _plJobI
{
// setup/shutdown
void (*initialize)(uint32_t uThreadCount); // set thread count to 0 to get optimal thread count
void (*initialize)(uint32_t threadCount); // set thread count to 0 to get optimal thread count
void (*cleanup)(void);

// typical usage
// - submit an array of job descriptions and receive an atomic counter pointer
// - pass NULL for the atomic counter pointer if you don't need to wait (fire & forget)
// - use "wait_for_counter" to wait on jobs to complete and return counter for reuse
void (*dispatch_jobs)(uint32_t uJobCount, plJobDesc*, plAtomicCounter**);
void (*dispatch_jobs)(uint32_t jobCount, plJobDesc*, plAtomicCounter**);

// batch usage
// Follows more of a compute shader design. All jobs use the same data which can be indexed
// using the job index. If the jobs are small, consider increasing the group size.
// - uJobCount : how many jobs to generate
// - uGroupSize : how many jobs to execute per thread serially (set 0 for optimal group size)
// - pass NULL for the atomic counter pointer if you don't need to wait (fire & forget)
void (*dispatch_batch)(uint32_t uJobCount, uint32_t uGroupSize, plJobDesc, plAtomicCounter**);
void (*dispatch_batch)(uint32_t jobCount, uint32_t groupSize, plJobDesc, plAtomicCounter**);

// waits for counter to reach 0 and returns the counter for reuse but subsequent dispatches
void (*wait_for_counter)(plAtomicCounter*);
Expand Down
2 changes: 1 addition & 1 deletion extensions/pl_rect_pack_ext.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ typedef struct _plPackRect plPackRect;

typedef struct _plRectPackI
{
void (*pack_rects)(int iWidth, int iHeight, plPackRect*, uint32_t uRectCount);
void (*pack_rects)(int width, int height, plPackRect*, uint32_t rectCount);
} plRectPackI;

//-----------------------------------------------------------------------------
Expand Down
8 changes: 4 additions & 4 deletions extensions/pl_shader_ext.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,14 @@ typedef struct _plShaderI
bool (*initialize)(const plShaderOptions*);

// load shader (compile if not already compiled)
plShaderModule (*load_glsl)(const char* pcShader, const char* pcEntryFunc, const char* pcFile, plShaderOptions*);
plShaderModule (*load_glsl)(const char* shader, const char* entryFunc, const char* file, plShaderOptions*);

// compilation (pass null shader options to use default)
plShaderModule (*compile_glsl) (const char* pcShader, const char* pcEntryFunc, plShaderOptions*);
plShaderModule (*compile_glsl) (const char* shader, const char* entryFunc, plShaderOptions*);

// write/read on disk
void (*write_to_disk) (const char* pcShader, const plShaderModule*);
plShaderModule (*read_from_disk)(const char* pcShader, const char* pcEntryFunc);
void (*write_to_disk) (const char* shader, const plShaderModule*);
plShaderModule (*read_from_disk)(const char* shader, const char* entryFunc);
} plShaderI;

//-----------------------------------------------------------------------------
Expand Down
6 changes: 3 additions & 3 deletions extensions/pl_stats_ext.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ typedef struct _plStatsI

// provides a pointer to a value for the counter
// (user should store this pointer to prevent lookups every frame)
double* (*get_counter)(char const* pcName);
double* (*get_counter)(char const* name);

// provides stat data back to user for analysis/display/etc.
double** (*get_counter_data)(char const* pcName); // set point to valid memory
const char** (*get_names) (uint32_t* puCount);
double** (*get_counter_data)(char const* name); // set point to valid memory
const char** (*get_names) (uint32_t* countOut);

// settings
void (*set_max_frames)(uint32_t); // default: 120
Expand Down
48 changes: 24 additions & 24 deletions src/pl.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,31 +84,31 @@ typedef uint16_t plUiWChar;
typedef struct _plApiRegistryI
{

const void* (*add) (const char* pcName, const void* pInterface);
void (*remove)(const void* pInterface);
const void* (*first) (const char* pcName);
const void* (*next) (const void* pPrevInterface);
const void* (*add) (const char* name, const void* interface);
void (*remove)(const void* interface);
const void* (*first) (const char* name);
const void* (*next) (const void* prevInterface);

} plApiRegistryI;

typedef struct _plExtensionRegistryI
{

bool (*load) (const char* pcName, const char* pcLoadFunc, const char* pcUnloadFunc, bool bReloadable);
bool (*unload)(const char* pcName);
bool (*load) (const char* name, const char* loadFunc, const char* unloadFunc, bool reloadable);
bool (*unload)(const char* name);

} plExtensionRegistryI;

typedef struct _plMemoryI
{

void* (*realloc)(void*, size_t, const char* pcFile, int iLine);
void* (*realloc)(void*, size_t, const char* file, int line);

// stats
size_t (*get_memory_usage)(void);
size_t (*get_allocation_count)(void);
size_t (*get_free_count)(void);
plAllocationEntry* (*get_allocations)(size_t* pszCount);
plAllocationEntry* (*get_allocations)(size_t* countOut);

} plMemoryI;

Expand All @@ -120,32 +120,32 @@ typedef struct _plIOI

// keyboard
bool (*is_key_down) (plKey);
bool (*is_key_pressed) (plKey, bool bRepeat);
bool (*is_key_pressed) (plKey, bool repeat);
bool (*is_key_released) (plKey);
int (*get_key_pressed_amount)(plKey, float fRepeatDelay, float fRate);
int (*get_key_pressed_amount)(plKey, float repeatDelay, float rate);

// mouse
bool (*is_mouse_down) (plMouseButton);
bool (*is_mouse_clicked) (plMouseButton, bool bRepeat);
bool (*is_mouse_clicked) (plMouseButton, bool repeat);
bool (*is_mouse_released) (plMouseButton);
bool (*is_mouse_double_clicked)(plMouseButton);
bool (*is_mouse_dragging) (plMouseButton, float fThreshold);
bool (*is_mouse_dragging) (plMouseButton, float threshold);
bool (*is_mouse_hovering_rect) (plVec2 minVec, plVec2 maxVec);
void (*reset_mouse_drag_delta) (plMouseButton);
plVec2 (*get_mouse_drag_delta) (plMouseButton, float fThreshold);
plVec2 (*get_mouse_drag_delta) (plMouseButton, float threshold);
plVec2 (*get_mouse_pos) (void);
float (*get_mouse_wheel) (void);
bool (*is_mouse_pos_valid) (plVec2);
void (*set_mouse_cursor) (plMouseCursor);

// input functions (used by backends)
void (*add_key_event) (plKey, bool bDown);
void (*add_key_event) (plKey, bool down);
void (*add_text_event) (uint32_t uChar);
void (*add_text_event_utf16) (uint16_t uChar);
void (*add_text_events_utf8) (const char* pcText);
void (*add_text_events_utf8) (const char* text);
void (*add_mouse_pos_event) (float x, float y);
void (*add_mouse_button_event)(int iButton, bool bDown);
void (*add_mouse_wheel_event) (float fHorizontalDelta, float fVerticalDelta);
void (*add_mouse_button_event)(int button, bool down);
void (*add_mouse_wheel_event) (float horizontalDelta, float verticalDelta);
void (*clear_input_characters)(void);

// misc.
Expand All @@ -158,8 +158,8 @@ typedef struct _plDataRegistryI
{

// for convience, only use for infrequent operations (i.e. global extension data)
void (*set_data)(const char* pcName, void* pData);
void* (*get_data)(const char* pcName);
void (*set_data)(const char* name, void* data);
void* (*get_data)(const char* name);

//~~~~~~~~~~~~~~~~~~~~~~~~~do not use below here yet~~~~~~~~~~~~~~~~~~~~~~~~~~~

Expand All @@ -168,18 +168,18 @@ typedef struct _plDataRegistryI

// object creation & retrieval
plDataID (*create_object) (void);
plDataID (*get_object_by_name)(const char* pcName); // assumes property 0 is name
plDataID (*get_object_by_name)(const char* name); // assumes property 0 is name

// reading (no locking or waiting)
const plDataObject* (*read) (plDataID);
const char* (*get_string)(const plDataObject*, uint32_t uProperty);
void* (*get_buffer)(const plDataObject*, uint32_t uProperty);
const char* (*get_string)(const plDataObject*, uint32_t property);
void* (*get_buffer)(const plDataObject*, uint32_t property);
void (*end_read) (const plDataObject*);

// writing (global lock)
plDataObject* (*write) (plDataID);
void (*set_string)(plDataObject*, uint32_t uProperty, const char*);
void (*set_buffer)(plDataObject*, uint32_t uProperty, void*);
void (*set_string)(plDataObject*, uint32_t property, const char*);
void (*set_buffer)(plDataObject*, uint32_t property, void*);
void (*commit) (plDataObject*);

} plDataRegistryI;
Expand Down
Loading

0 comments on commit db87039

Please sign in to comment.