WIP
This commit is contained in:
parent
575e4ee54a
commit
5f08179427
1 changed files with 57 additions and 51 deletions
108
glonkers.c
108
glonkers.c
|
|
@ -28,6 +28,11 @@ struct client_state {
|
|||
struct xdg_toplevel *xdg_toplevel;
|
||||
|
||||
struct wl_egl_window *egl_window;
|
||||
|
||||
EGLDisplay egl_display;
|
||||
EGLConfig egl_config;
|
||||
EGLSurface egl_surface;
|
||||
EGLContext egl_context;
|
||||
};
|
||||
|
||||
static void
|
||||
|
|
@ -144,61 +149,62 @@ wl_registry_listener = {
|
|||
.global_remove = registry_handle_global_remove,
|
||||
};
|
||||
|
||||
//static void egl_init(struct client_state *state) {
|
||||
// EGLint major;
|
||||
// EGLint minor;
|
||||
// EGLint num_configs;
|
||||
// EGLint attribs[] = {
|
||||
// EGL_RENDERABLE_TYPE, EGL_OPENGL_BIT,
|
||||
// EGL_NONE
|
||||
// };
|
||||
//
|
||||
// state->egl_window = wl_egl_window_create(state->wl_surface, state->width,
|
||||
// state->height);
|
||||
//
|
||||
// state->egl_display = eglGetDisplay((EGLNativeDisplayType) state->display);
|
||||
// if(state->display == EGL_NO_DISPLAY) {
|
||||
// fprintf(stderr, "Couldn't get EGL display\n");
|
||||
// exit(EXIT_FAILURE);
|
||||
// }
|
||||
//
|
||||
// if(eglInitialize(state->egl_display, &major, &minor) != EGL_TRUE) {
|
||||
// fprintf(stderr, "Couldnt initialize EGL\n");
|
||||
// exit(EXIT_FAILURE);
|
||||
// }
|
||||
//
|
||||
// if(eglChooseConfig(state->egl_display, attribs, &state->egl_config, 1,
|
||||
// &num_configs) != EGL_TRUE) {
|
||||
// fprintf(stderr, "CouldnÄt find matching EGL config\n");
|
||||
// exit(EXIT_FAILURE);
|
||||
// }
|
||||
//
|
||||
// state->egl_surface = eglCreateWindowSurface(state->egl_display,
|
||||
// state->egl_config,
|
||||
// (EGLNativeWindowType) state->egl_window, NULL);
|
||||
// if(state->egl_surface == EGL_NO_SURFACE) {
|
||||
// fprintf(stderr, "Couldn't create EGL surface\n");
|
||||
// exit(EXIT_FAILURE);
|
||||
// }
|
||||
//
|
||||
// state->egl_context = eglCreateContext(state->egl_display, state->egl_config,
|
||||
// EGL_NO_CONTEXT, NULL);
|
||||
// if(state->egl_context == EGL_NO_CONTEXT) {
|
||||
// fprintf(stderr, "Couldn't create EGL context\n");
|
||||
// exit(EXIT_FAILURE);
|
||||
// }
|
||||
//
|
||||
// if(!eglMakeCurrent(state->egl_display, state->egl_surface,
|
||||
// state->egl_surface, state->egl_context)) {
|
||||
// fprintf(stderr, "Couldn't make EGL context current\n");
|
||||
// exit(EXIT_FAILURE);
|
||||
// }
|
||||
//}
|
||||
static void egl_init(struct client_state *state) {
|
||||
EGLint major;
|
||||
EGLint minor;
|
||||
EGLint num_configs;
|
||||
EGLint attribs[] = {
|
||||
EGL_RENDERABLE_TYPE, EGL_OPENGL_BIT,
|
||||
EGL_NONE
|
||||
};
|
||||
|
||||
state->egl_window = wl_egl_window_create(state->wl_surface, state->width,
|
||||
state->height);
|
||||
|
||||
state->egl_display = eglGetDisplay((EGLNativeDisplayType) state->wl_display);
|
||||
if(state->wl_display == EGL_NO_DISPLAY) {
|
||||
fprintf(stderr, "Couldn't get EGL display\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
if(eglInitialize(state->egl_display, &major, &minor) != EGL_TRUE) {
|
||||
fprintf(stderr, "Couldnt initialize EGL\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
if(eglChooseConfig(state->egl_display, attribs, &state->egl_config, 1,
|
||||
&num_configs) != EGL_TRUE) {
|
||||
fprintf(stderr, "Couldn't find matching EGL config\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
state->egl_surface = eglCreateWindowSurface(state->egl_display,
|
||||
state->egl_config,
|
||||
(EGLNativeWindowType) state->egl_window, NULL);
|
||||
if(state->egl_surface == EGL_NO_SURFACE) {
|
||||
fprintf(stderr, "Couldn't create EGL surface\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
state->egl_context = eglCreateContext(state->egl_display, state->egl_config,
|
||||
EGL_NO_CONTEXT, NULL);
|
||||
if(state->egl_context == EGL_NO_CONTEXT) {
|
||||
fprintf(stderr, "Couldn't create EGL context\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
if(!eglMakeCurrent(state->egl_display, state->egl_surface,
|
||||
state->egl_surface, state->egl_context)) {
|
||||
fprintf(stderr, "Couldn't make EGL context current\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
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_registry = wl_display_get_registry(state.wl_display);
|
||||
wl_registry_add_listener(state.wl_registry, &wl_registry_listener, &state);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue