#include "application_context.h" #include "window/window.h" #include "../os/WAYLAND/wl_context.h" #include "../os/EGL/egl_context.h" #include "../os/EGL/GLES_3_1_compatibility.h" #include #include #include application_context* application_context_malloc(){ application_context *app = malloc( sizeof( application_context)); return app; } application_context* application_context_new( const char *title){ wl_context *wl; egl_context *egl; gui_component *win; application_context *app; app = application_context_malloc(); /* get the builders and the display connection */ wl = wl_context_new(); app->w_context = wl; fprintf(stderr, "created WL_CONTEXT\n"); /* builds the minimal for a running */ win = window_new( title, ui_dimensions_new( wl_context_get(GLUT_SCREEN_WIDTH), wl_context_get(GLUT_SCREEN_HEIGHT) ), app ); fprintf(stderr, "CREATED WINDOW\n"); /* ??? allocates the required struct for binding a buffer to the wl_surface of the window's toplevel */ app->win = win; app->running = 1; window_gui_enrichment *win_x = ( window_gui_enrichment* ) win->specialization; win_x->egl_window = wl_egl_window_create( win->graphics->surface, win->graphics->dimensions->w, win->graphics->dimensions->h); /* EGL_NO_SURFACE */ if (NULL == win_x->egl_window) { fprintf(stderr, "Couldn't create EGL window\n"); exit(1); } /* gets the context for GLES2 graphics API */ egl = egl_context_new( wl->display); app->e_context = egl; win_x->egl_surface = eglCreateWindowSurface( egl->display, egl->config, (EGLNativeWindowType) win_x->egl_window, NULL ); if( EGL_NO_SURFACE == win_x->egl_surface) { fprintf(stderr, "Couldn't create EGL surface\n"); printEGLError(); exit(EXIT_FAILURE); } if( ! eglMakeCurrent(egl->display, win_x->egl_surface, win_x->egl_surface, egl->context)) { fprintf(stderr, "Couldn't make EGL context current\n"); exit(EXIT_FAILURE); } GLES_3_1_compatibility_init(); return app; }