Now About Social Code
summaryrefslogtreecommitdiff
path: root/apps/surfaceless.c
diff options
context:
space:
mode:
authorLucas Fryzek <lucas.fryzek@fryzekconcepts.com>2024-07-26 15:04:11 +0100
committerLucas Fryzek <lucas.fryzek@fryzekconcepts.com>2024-07-26 15:04:11 +0100
commit0a990b7530a0490b6a1296663b9844ee90bcae11 (patch)
tree12bea147404ea8cba94bb0c2976711fb6a14165a /apps/surfaceless.c
parent6a1e5989c35d0721819f480f1040091b878ba351 (diff)
apps: Add surfaceless test app
Diffstat (limited to 'apps/surfaceless.c')
-rw-r--r--apps/surfaceless.c50
1 files changed, 50 insertions, 0 deletions
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;
+}