project for a (works on my devices) demo
This commit is contained in:
76
SOURCES/graphics/library/application_context.c
Normal file
76
SOURCES/graphics/library/application_context.c
Normal file
@@ -0,0 +1,76 @@
|
||||
#include "application_context.h"
|
||||
|
||||
#include "../os/WAYLAND/wl_context.h"
|
||||
#include "../os/EGL/egl_context.h"
|
||||
#include "../os/EGL/GLES_3_1_compatibility.h"
|
||||
#include <wayland-egl.h>
|
||||
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
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;
|
||||
window *win;
|
||||
application_context *app;
|
||||
|
||||
app = application_context_malloc();
|
||||
/* get the builders and the display connection */
|
||||
wl = wl_context_new();
|
||||
app->w_context = wl;
|
||||
|
||||
|
||||
/* 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)
|
||||
),
|
||||
wl,
|
||||
app
|
||||
);
|
||||
|
||||
/* ??? allocates the required struct for binding a buffer to the wl_surface of the window's toplevel */
|
||||
app->win = win;
|
||||
app->running = 1;
|
||||
win->egl_window = wl_egl_window_create( win->surface, win->dimensions->w, win->dimensions->h);
|
||||
|
||||
/* EGL_NO_SURFACE */
|
||||
if (NULL == win->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->egl_surface = eglCreateWindowSurface(
|
||||
egl->display,
|
||||
egl->config,
|
||||
(EGLNativeWindowType) win->egl_window,
|
||||
NULL
|
||||
);
|
||||
if( EGL_NO_SURFACE == win->egl_surface) {
|
||||
fprintf(stderr, "Couldn't create EGL surface\n");
|
||||
printEGLError();
|
||||
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
if( ! eglMakeCurrent(egl->display, win->egl_surface, win->egl_surface, egl->context)) {
|
||||
fprintf(stderr, "Couldn't make EGL context current\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
GLES_3_1_compatibility_init();
|
||||
|
||||
return app;
|
||||
}
|
||||
Reference in New Issue
Block a user