diff options
Diffstat (limited to 'apps')
-rw-r--r-- | apps/.gitignore | 1 | ||||
-rw-r--r-- | apps/surfaceless.c | 50 |
2 files changed, 51 insertions, 0 deletions
diff --git a/apps/.gitignore b/apps/.gitignore new file mode 100644 index 0000000..d66f8c4 --- /dev/null +++ b/apps/.gitignore @@ -0,0 +1 @@ +surfaceless diff --git a/apps/surfaceless.c b/apps/surfaceless.c new file mode 100644 index 0000000..7eb2567 --- /dev/null +++ b/apps/surfaceless.c @@ -0,0 +1,50 @@ +#include <EGL/egl.h> +#include <EGL/eglext.h> +#include <GLES2/gl2.h> +#include <assert.h> +#include <stdbool.h> +#include <stdio.h> +#include <string.h> + +int main (int32_t argc, char* argv[]) { + bool res; + EGLDisplay egl_dpy = eglGetDisplay(EGL_DEFAULT_DISPLAY); + + res = eglInitialize(egl_dpy, NULL, NULL); + assert(res); + + const char *egl_extension_st = eglQueryString(egl_dpy, EGL_EXTENSIONS); + assert(strstr(egl_extension_st, "EGL_KHR_create_context") != NULL); + assert(strstr(egl_extension_st, "EGL_KHR_surfaceless_context") != NULL); + + static const EGLint config_attribs[] = { + EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, + EGL_NONE + }; + EGLConfig cfg; + EGLint count; + + res = eglChooseConfig(egl_dpy, config_attribs, &cfg, 1, &count); + assert(res); + + res = eglBindAPI(EGL_OPENGL_ES_API); + assert(res); + + static const EGLint attribs[] = { + EGL_CONTEXT_CLIENT_VERSION, 3, + EGL_NONE + }; + EGLContext ctx = eglCreateContext(egl_dpy, + cfg, + EGL_NO_CONTEXT, + attribs); + assert(ctx != EGL_NO_CONTEXT); + + res = eglMakeCurrent(egl_dpy, EGL_NO_SURFACE, EGL_NO_SURFACE, ctx); + assert(res); + + eglDestroyContext(egl_dpy, ctx); + eglTerminate(egl_dpy); + + return 0; +} |