This commit is contained in:
Rakarake 2025-12-18 01:31:14 +01:00
parent 575e4ee54a
commit 5f08179427

View file

@ -28,6 +28,11 @@ struct client_state {
struct xdg_toplevel *xdg_toplevel; struct xdg_toplevel *xdg_toplevel;
struct wl_egl_window *egl_window; struct wl_egl_window *egl_window;
EGLDisplay egl_display;
EGLConfig egl_config;
EGLSurface egl_surface;
EGLContext egl_context;
}; };
static void static void
@ -144,61 +149,62 @@ wl_registry_listener = {
.global_remove = registry_handle_global_remove, .global_remove = registry_handle_global_remove,
}; };
//static void egl_init(struct client_state *state) { static void egl_init(struct client_state *state) {
// EGLint major; EGLint major;
// EGLint minor; EGLint minor;
// EGLint num_configs; EGLint num_configs;
// EGLint attribs[] = { EGLint attribs[] = {
// EGL_RENDERABLE_TYPE, EGL_OPENGL_BIT, EGL_RENDERABLE_TYPE, EGL_OPENGL_BIT,
// EGL_NONE EGL_NONE
// }; };
//
// state->egl_window = wl_egl_window_create(state->wl_surface, state->width, state->egl_window = wl_egl_window_create(state->wl_surface, state->width,
// state->height); state->height);
//
// state->egl_display = eglGetDisplay((EGLNativeDisplayType) state->display); state->egl_display = eglGetDisplay((EGLNativeDisplayType) state->wl_display);
// if(state->display == EGL_NO_DISPLAY) { if(state->wl_display == EGL_NO_DISPLAY) {
// fprintf(stderr, "Couldn't get EGL display\n"); fprintf(stderr, "Couldn't get EGL display\n");
// exit(EXIT_FAILURE); exit(EXIT_FAILURE);
// } }
//
// if(eglInitialize(state->egl_display, &major, &minor) != EGL_TRUE) { if(eglInitialize(state->egl_display, &major, &minor) != EGL_TRUE) {
// fprintf(stderr, "Couldnt initialize EGL\n"); fprintf(stderr, "Couldnt initialize EGL\n");
// exit(EXIT_FAILURE); exit(EXIT_FAILURE);
// } }
//
// if(eglChooseConfig(state->egl_display, attribs, &state->egl_config, 1, if(eglChooseConfig(state->egl_display, attribs, &state->egl_config, 1,
// &num_configs) != EGL_TRUE) { &num_configs) != EGL_TRUE) {
// fprintf(stderr, "CouldnÄt find matching EGL config\n"); fprintf(stderr, "Couldn't find matching EGL config\n");
// exit(EXIT_FAILURE); exit(EXIT_FAILURE);
// } }
//
// state->egl_surface = eglCreateWindowSurface(state->egl_display, state->egl_surface = eglCreateWindowSurface(state->egl_display,
// state->egl_config, state->egl_config,
// (EGLNativeWindowType) state->egl_window, NULL); (EGLNativeWindowType) state->egl_window, NULL);
// if(state->egl_surface == EGL_NO_SURFACE) { if(state->egl_surface == EGL_NO_SURFACE) {
// fprintf(stderr, "Couldn't create EGL surface\n"); fprintf(stderr, "Couldn't create EGL surface\n");
// exit(EXIT_FAILURE); exit(EXIT_FAILURE);
// } }
//
// state->egl_context = eglCreateContext(state->egl_display, state->egl_config, state->egl_context = eglCreateContext(state->egl_display, state->egl_config,
// EGL_NO_CONTEXT, NULL); EGL_NO_CONTEXT, NULL);
// if(state->egl_context == EGL_NO_CONTEXT) { if(state->egl_context == EGL_NO_CONTEXT) {
// fprintf(stderr, "Couldn't create EGL context\n"); fprintf(stderr, "Couldn't create EGL context\n");
// exit(EXIT_FAILURE); exit(EXIT_FAILURE);
// } }
//
// if(!eglMakeCurrent(state->egl_display, state->egl_surface, if(!eglMakeCurrent(state->egl_display, state->egl_surface,
// state->egl_surface, state->egl_context)) { state->egl_surface, state->egl_context)) {
// fprintf(stderr, "Couldn't make EGL context current\n"); fprintf(stderr, "Couldn't make EGL context current\n");
// exit(EXIT_FAILURE); exit(EXIT_FAILURE);
// } }
//} }
int int
main(int argc, char *argv[]) main(int argc, char *argv[])
{ {
struct client_state state = { 700, 450, 0 }; int width = 700, height = 450;
struct client_state state = { width, height, 0 };
state.wl_display = wl_display_connect(NULL); state.wl_display = wl_display_connect(NULL);
state.wl_registry = wl_display_get_registry(state.wl_display); state.wl_registry = wl_display_get_registry(state.wl_display);
wl_registry_add_listener(state.wl_registry, &wl_registry_listener, &state); wl_registry_add_listener(state.wl_registry, &wl_registry_listener, &state);