aboutsummaryrefslogtreecommitdiffstats
path: root/egltest.c
diff options
context:
space:
mode:
authorGerd Hoffmann <kraxel@redhat.com>2019-04-05 13:17:34 +0200
committerGerd Hoffmann <kraxel@redhat.com>2019-04-05 13:17:34 +0200
commitdc88d0b43d0159ebf1dd70b40b286989b812d4eb (patch)
treeaaab6bbe1c68a6e6860ea191db81c6793d05fd5b /egltest.c
parent33601a7bae426afca8bcb40e7157befd7b57adf6 (diff)
downloaddrminfo-dc88d0b43d0159ebf1dd70b40b286989b812d4eb.tar.gz
add egltest
Diffstat (limited to 'egltest.c')
-rw-r--r--egltest.c117
1 files changed, 117 insertions, 0 deletions
diff --git a/egltest.c b/egltest.c
new file mode 100644
index 0000000..fdafa14
--- /dev/null
+++ b/egltest.c
@@ -0,0 +1,117 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdbool.h>
+#include <unistd.h>
+#include <errno.h>
+#include <string.h>
+#include <inttypes.h>
+#include <getopt.h>
+#include <assert.h>
+
+#include <gbm.h>
+#include <epoxy/gl.h>
+#include <epoxy/egl.h>
+
+#include <xf86drm.h>
+#include <xf86drmMode.h>
+
+#include <cairo.h>
+#include <pixman.h>
+
+#include "drmtools.h"
+#include "ttytools.h"
+
+/* ------------------------------------------------------------------ */
+
+static void egl_print_info(void)
+{
+ printf("version: %s\n", glGetString(GL_VERSION));
+ printf("vendor: %s\n", glGetString(GL_VENDOR));
+ printf("renderer: %s\n", glGetString(GL_RENDERER));
+}
+
+static void egl_draw(void)
+{
+ /* green background */
+ glClearColor(0.0, 0.6, 0.0, 1.0);
+ glClear(GL_COLOR_BUFFER_BIT);
+ glFlush();
+}
+
+/* ------------------------------------------------------------------ */
+
+static void usage(FILE *fp)
+{
+ fprintf(fp,
+ "\n"
+ "usage: egltest [ options ]\n"
+ "\n"
+ "options:\n"
+ " -h print this\n"
+ " -a autotest mode\n"
+ " -c <nr> pick card\n"
+ " -s <secs> set sleep time (default: 60)\n"
+ " -i print device info\n"
+ "\n");
+}
+
+int main(int argc, char **argv)
+{
+ int card = 0;
+ int secs = 60;
+ char *output = NULL;
+ char *modename = NULL;
+ bool printinfo = false;
+ bool autotest = false;
+ char buf[32];
+ int c;
+
+ for (;;) {
+ c = getopt(argc, argv, "haic:s:");
+ if (c == -1)
+ break;
+ switch (c) {
+ case 'c':
+ card = atoi(optarg);
+ break;
+ case 's':
+ secs = atoi(optarg);
+ break;
+ case 'i':
+ printinfo = true;
+ break;
+ case 'a':
+ autotest = true;
+ break;
+ case 'h':
+ usage(stdout);
+ exit(0);
+ default:
+ usage(stderr);
+ exit(1);
+ }
+ }
+
+ drm_init_dev(card, output, modename, false);
+ drm_setup_egl();
+
+ if (printinfo) {
+ egl_print_info();
+ goto done;
+ }
+
+ egl_draw();
+ drm_egl_flush_display();
+
+ if (autotest)
+ fprintf(stdout, "---ok---\n");
+
+ tty_raw();
+ kbd_wait(secs);
+ read(0, buf, sizeof(buf));
+ tty_restore();
+
+done:
+ drm_fini_dev();
+ return 0;
+}