Simple Graphics Library 1.0.0.0
Runtime-independent image processing primitives
Loading...
Searching...
No Matches
Getting Started

Configure and Build

Select build options through the curses menu, then build and install:

make menu
make build
make install INSTALL_PREFIX=/opt/sgl

The package installs public headers, the sgl-core library, pkg-config metadata, and a CMake package. A direct CMake consumer can use:

find_package(sgl-core-package CONFIG REQUIRED)
target_link_libraries(application PRIVATE sgl-core::sgl-core)

Include and Link

Application code normally needs only:

#include <sgl-core.h>
Public API for memory, image processing, queues, and worker threads.

sgl-fixed_point.h and sgl-compiler.h are low-level support headers for code that intentionally shares SGL's arithmetic or compiler abstractions.

Runtime Lifecycle

SGL allocations come from one caller-owned process-wide pool. The pool's backing array must remain alive and unchanged until deinitialization succeeds. Objects must be destroyed in reverse order before detaching the pool.

#include <sgl-core.h>
#define APP_SGL_POOL_BYTES (8U * 1024U * 1024U)
static sgl_uint8_t app_sgl_pool[APP_SGL_POOL_BYTES];
static sgl_result_t app_run(void)
{
sgl_threadpool_t *workers;
sgl_result_t result;
workers = SGL_NULL;
app_sgl_pool,
(sgl_size_t)sizeof(app_sgl_pool));
#if defined(SGL_CFG_HAS_THREAD)
if (result == SGL_SUCCESS) {
4U,
"sgl-app");
if (workers == SGL_NULL) {
}
}
#endif
/* Invoke image operations here. A NULL workers value is also valid. */
#if defined(SGL_CFG_HAS_THREAD)
if (workers != SGL_NULL) {
result = sgl_threadpool_destroy(workers);
}
#endif
result = SGL_FAILURE;
}
return result;
}
sgl_result_t sgl_memory_pool_initialize(void *memory, sgl_size_t size)
Registers the process-wide SGL memory pool.
sgl_result_t sgl_memory_pool_deinitialize(void)
Detaches the caller-owned memory pool.
#define SGL_NULL
Null pointer constant for public SGL interfaces.
Definition sgl-type.h:138
unsigned long sgl_size_t
Unsigned type used for object sizes and byte counts.
Definition sgl-type.h:44
unsigned char sgl_uint8_t
Unsigned integer with exactly 8 value bits.
Definition sgl-type.h:26
sgl_result_t sgl_threadpool_destroy(sgl_threadpool_t *pool)
Stops workers and destroys a thread pool.
sgl_threadpool_t * sgl_threadpool_create(sgl_size_t num_threads, sgl_size_t max_routine_lists, const char *base_name)
Creates a worker-thread pool.
struct sgl_threadpool sgl_threadpool_t
Opaque synchronous worker-thread pool.
Definition sgl-core.h:91
sgl_result_t
Result codes returned by SGL operations.
Definition sgl-core.h:67
@ SGL_FAILURE
Operation failed without a more specific code.
Definition sgl-core.h:69
@ SGL_SUCCESS
Operation completed successfully.
Definition sgl-core.h:68
@ SGL_ERROR_MEMORY_ALLOCATION
The configured SGL memory pool could not satisfy an allocation.
Definition sgl-core.h:71
#define SGL_THREADPOOL_DEFAULT_MAX_ROUTINE_LISTS
Default maximum routine-list count accepted by sgl_threadpool_create().
Definition sgl-core.h:46

Error Handling

Image functions return sgl_result_t. Treat every value other than SGL_SUCCESS as a failed operation. Pointer-returning creation functions report invalid input and allocation failure as SGL_NULL. Size-query functions return zero for invalid or overflowing geometry.