diff options
| author | Berke Güzel <wenekar1@gmail.com> | 2026-10-14 13:13:52 +0300 |
|---|---|---|
| committer | Berke Güzel <wenekar1@gmail.com> | 2026-10-14 13:13:52 +0300 |
| commit | 1ab3e5a123109704789c2768e11a4f9af515821d (patch) | |
| tree | 31ee03e58093a58100c6eb58681d5d29648a5ddd /include/yasl/gl.h | |
| parent | d86fa6215d40caa7852dbbd6a8cf4aa8e89dd879 (diff) | |
Redefine public and rendering APIs with explicit contracts
Diffstat (limited to 'include/yasl/gl.h')
| -rw-r--r-- | include/yasl/gl.h | 37 |
1 files changed, 23 insertions, 14 deletions
diff --git a/include/yasl/gl.h b/include/yasl/gl.h index 39d2c63..d5603e3 100644 --- a/include/yasl/gl.h +++ b/include/yasl/gl.h @@ -1,27 +1,36 @@ -/** @file Optional EGL/OpenGL/OpenGL ES contexts on Linux. Attribute lists are per-call. */ +/** @file Optional EGL/OpenGL/OpenGL ES contexts on Linux. */ #ifndef YASL_GL_H #define YASL_GL_H #include "yasl/yasl.h" #ifdef __cplusplus extern "C" { #endif -enum yasl_gl_attribute { YASL_GL_END, YASL_GL_MAJOR, YASL_GL_MINOR, YASL_GL_PROFILE, YASL_GL_DEBUG, - YASL_GL_FORWARD_COMPAT, YASL_GL_RED_BITS, YASL_GL_GREEN_BITS, YASL_GL_BLUE_BITS, YASL_GL_ALPHA_BITS, - YASL_GL_DEPTH_BITS, YASL_GL_STENCIL_BITS, YASL_GL_SAMPLES, YASL_GL_SRGB, YASL_GL_API }; enum yasl_gl_profile { YASL_GL_ANY, YASL_GL_CORE, YASL_GL_COMPATIBILITY }; enum yasl_gl_api { YASL_GL_OPENGL, YASL_GL_OPENGL_ES }; typedef void (*yasl_gl_proc)(void); -/** key/value pairs terminated by END, NULL defaults to GL3.2 core RGBA8 D24 S8. - * share is a live GL surface or NULL. CPU flag is invalid. Context is owned by - * the returned surface. Detach it from all rendering threads before destruction. - * Cocoa returns NULL with YASL_ERROR_UNSUPPORTED; use Metal or MoltenVK. */ -YASL_API yasl_surface *yasl_gl_surface_create(const char *title, int width, int height, - unsigned flags, const int *attributes, yasl_surface *share); -/** May run on a rendering thread. NULL detaches this thread's current context. */ -YASL_API bool yasl_gl_make_current(yasl_surface *surface); +struct yasl_gl_options { + int major, minor; + enum yasl_gl_profile profile; + enum yasl_gl_api api; + int red_bits, green_bits, blue_bits, alpha_bits; + int depth_bits, stencil_bits, samples; + bool debug, forward_compat, srgb; + yasl_surface *share; +}; +/** C and C++ initializer: GL 3.2 core, RGBA8, D24, S8. */ +#define YASL_GL_OPTIONS_INIT \ + {3, 2, YASL_GL_CORE, YASL_GL_OPENGL, 8, 8, 8, 8, 24, 8, 0, false, false, false, NULL} +/** NULL gl selects defaults. options->type must be NATIVE. share, when set, + * must be a live GL surface. Detach the owned context from every rendering + * thread before destruction. Cocoa fails with errno=ENOTSUP. */ +YASL_API yasl_surface *yasl_gl_surface_create(const struct yasl_surface_options *options, + const struct yasl_gl_options *gl); +/** These four operations may run on a rendering thread. The application must + * synchronize surface/display destruction. NULL make_current detaches. */ +YASL_API int yasl_gl_make_current(yasl_surface *surface); YASL_API yasl_gl_proc yasl_gl_get_proc_address(const char *name); -YASL_API bool yasl_gl_swap_interval(yasl_surface *surface, int interval); -YASL_API bool yasl_gl_swap_buffers(yasl_surface *surface); +YASL_API int yasl_gl_set_swap_interval(yasl_surface *surface, int interval); +YASL_API int yasl_gl_present(yasl_surface *surface); #ifdef __cplusplus } #endif |
