From 0a990b7530a0490b6a1296663b9844ee90bcae11 Mon Sep 17 00:00:00 2001 From: Lucas Fryzek Date: Fri, 26 Jul 2024 15:04:11 +0100 Subject: apps: Add surfaceless test app --- apps/.gitignore | 1 + apps/surfaceless.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+) create mode 100644 apps/.gitignore create mode 100644 apps/surfaceless.c 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 +#include +#include +#include +#include +#include +#include + +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; +} -- cgit