WAFFLE_API int32_t waffle_attrib_list_length(const int32_t attrib_list[]) { wcore_error_reset(); return wcore_attrib_list_length(attrib_list); }
struct wcore_window* sl_window_create(struct wcore_platform *wc_plat, struct wcore_config *wc_config, int32_t width, int32_t height, const intptr_t attrib_list[]) { struct sl_window *self; bool ok = true; if (width == -1 && height == -1) { wcore_errorf(WAFFLE_ERROR_UNSUPPORTED_ON_PLATFORM, "fullscreen window not supported"); return NULL; } if (wcore_attrib_list_length(attrib_list) > 0) { wcore_error_bad_attribute(attrib_list[0]); return NULL; } self = wcore_calloc(sizeof(*self)); if (self == NULL) return NULL; ok = wegl_pbuffer_init(&self->wegl, wc_config, width, height); if (!ok) goto error; return &self->wegl.wcore; error: sl_window_destroy(&self->wegl.wcore); return NULL; }
struct wcore_window* wgbm_window_create(struct wcore_platform *wc_plat, struct wcore_config *wc_config, int32_t width, int32_t height, const intptr_t attrib_list[]) { struct wgbm_display *dpy = wgbm_display(wc_config->display); struct wgbm_platform *plat = wgbm_platform(wegl_platform(wc_plat)); struct wgbm_window *self; uint32_t gbm_format; bool ok = true; if (width == -1 && height == -1) { wcore_errorf(WAFFLE_ERROR_UNSUPPORTED_ON_PLATFORM, "fullscreen window not supported"); return NULL; } if (wcore_attrib_list_length(attrib_list) > 0) { wcore_error_bad_attribute(attrib_list[0]); return NULL; } self = wcore_calloc(sizeof(*self)); if (self == NULL) return NULL; gbm_format = wgbm_config_get_gbm_format(wc_plat, wc_config->display, wc_config); assert(gbm_format != 0); self->gbm_surface = plat->gbm_surface_create(dpy->gbm_device, width, height, gbm_format, GBM_BO_USE_RENDERING); if (!self->gbm_surface) { wcore_errorf(WAFFLE_ERROR_UNKNOWN, "gbm_surface_create failed"); goto error; } ok = wegl_window_init(&self->wegl, wc_config, (intptr_t) self->gbm_surface); if (!ok) goto error; return &self->wegl.wcore; error: wgbm_window_destroy(&self->wegl.wcore); return NULL; }
struct wcore_window* glx_window_create(struct wcore_platform *wc_plat, struct wcore_config *wc_config, int32_t width, int32_t height, const intptr_t attrib_list[]) { struct glx_window *self; struct glx_display *dpy = glx_display(wc_config->display); struct glx_config *config = glx_config(wc_config); bool ok = true; if (width == -1 && height == -1) { width = DisplayWidth(dpy->x11.xlib, dpy->x11.screen); height = DisplayHeight(dpy->x11.xlib, dpy->x11.screen); } if (wcore_attrib_list_length(attrib_list) > 0) { wcore_error_bad_attribute(attrib_list[0]); return NULL; } self = wcore_calloc(sizeof(*self)); if (self == NULL) return NULL; ok = wcore_window_init(&self->wcore, wc_config); if (!ok) goto error; ok = x11_window_init(&self->x11, &dpy->x11, config->xcb_visual_id, width, height); if (!ok) goto error; return &self->wcore; error: glx_window_destroy(&self->wcore); return NULL; }