From 76073fe5fad8799e5850805f2f090af2cb62c741 Mon Sep 17 00:00:00 2001 From: Berke Güzel Date: Tue, 13 Oct 2026 23:41:31 +0300 Subject: Simplify the public event and CPU API Applications now need far less ceremony: hello.c is a 20-line loop that handles REFRESH, CLOSE and QUIT and draws into the surface's own pixels. - Fold GEOMETRY, STATE and FOCUS into one WINDOW event carrying size, scale and state; unchanged values send nothing. - Guarantee REFRESH once a window has a size and after every resize, never at size zero. - Merge DROP_HOVER into DROP with over/leave/data actions and give drag and drop actions enums. - Keep event strings valid until the next wait and drop yasl_event_release; empty or failed waits report NONE. - Replace copy-in presentation with a lent pixel buffer: yasl_cpu_pixels and yasl_cpu_present. - Remove yasl_poll_event, yasl_cpu_read_pixels, unused event fields and comments that restated names. - Wayland: resize floating windows in request_size instead of reporting it unsupported, and stop marking new GPU surfaces as Vulkan so yasl_vulkan_create_surface no longer fails with NATIVE_WINDOW_IN_USE. Also includes the in-progress public API refactor that was uncommitted in the tree (removal of the app/loop layer, new surface, GL and Vulkan entry points). Co-Authored-By: Claude Opus 5.5 --- src/common/gl_options.c | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 src/common/gl_options.c (limited to 'src/common/gl_options.c') diff --git a/src/common/gl_options.c b/src/common/gl_options.c new file mode 100644 index 0000000..ec8f98a --- /dev/null +++ b/src/common/gl_options.c @@ -0,0 +1,38 @@ +#include "gl_options.h" +#include +#include +bool yasl_private_gl_parse_options(const int *attrs, struct yasl_private_gl_options *out) +{ + if (!out) { errno = EINVAL; return false; } + struct yasl_private_gl_options o = {.major=3, .minor=2, .profile=YASL_PRIVATE_GL_CORE, + .red_bits=8, .green_bits=8, .blue_bits=8, .alpha_bits=8, .depth_bits=24, .stencil_bits=8}; + if (attrs) for (size_t i=0;;i+=2) { + if (i >= 128) { errno=EINVAL; return false; } + int key=attrs[i]; + if (key==YASL_PRIVATE_GL_END) break; + int v=attrs[i+1]; + switch(key) { + case YASL_PRIVATE_GL_MAJOR: o.major=v; break; + case YASL_PRIVATE_GL_MINOR: o.minor=v; break; + case YASL_PRIVATE_GL_PROFILE: o.profile=v; break; + case YASL_PRIVATE_GL_DEBUG: o.debug=v; break; + case YASL_PRIVATE_GL_FORWARD_COMPAT: o.forward_compat=v; break; + case YASL_PRIVATE_GL_RED_BITS: o.red_bits=v; break; + case YASL_PRIVATE_GL_GREEN_BITS: o.green_bits=v; break; + case YASL_PRIVATE_GL_BLUE_BITS: o.blue_bits=v; break; + case YASL_PRIVATE_GL_ALPHA_BITS: o.alpha_bits=v; break; + case YASL_PRIVATE_GL_DEPTH_BITS: o.depth_bits=v; break; + case YASL_PRIVATE_GL_STENCIL_BITS: o.stencil_bits=v; break; + case YASL_PRIVATE_GL_SAMPLES: o.samples=v; break; + case YASL_PRIVATE_GL_SRGB: o.srgb=v; break; + case YASL_PRIVATE_GL_API: o.api=v; break; + default: errno=EINVAL; return false; + } + } + if (o.major<1 || o.major>4 || o.minor<0 || o.minor>9 || o.profile<0 || o.profile>2 || + o.api<0 || o.api>1 || (unsigned)o.debug>1 || (unsigned)o.forward_compat>1 || + (unsigned)o.srgb>1 || (unsigned)o.red_bits>64 || (unsigned)o.green_bits>64 || + (unsigned)o.blue_bits>64 || (unsigned)o.alpha_bits>64 || (unsigned)o.depth_bits>64 || + (unsigned)o.stencil_bits>64 || (unsigned)o.samples>64) { errno=EINVAL; return false; } + *out=o; return true; +} -- cgit v1.2.3