test_output: use new drawing pipeline
authorDavid Herrmann <dh.herrmann@googlemail.com>
Wed, 18 Jan 2012 14:54:59 +0000 (15:54 +0100)
committerDavid Herrmann <dh.herrmann@googlemail.com>
Wed, 18 Jan 2012 15:26:57 +0000 (16:26 +0100)
This converts the output test function to use the new kmscon_context for
drawing operations so we no longer depend directly on GL.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
Makefile.am
tests/test_output.c

index 4efc05f..ef94165 100644 (file)
@@ -93,12 +93,7 @@ test_console_CPPFLAGS = \
        $(OPENGL_CFLAGS)
 
 test_output_SOURCES = tests/test_output.c
-test_output_LDADD = \
-       libkmscon-core.la \
-       $(OPENGL_LIBS)
-test_output_CPPFLAGS = \
-       $(AM_CPPFLAGS) \
-       $(OPENGL_CFLAGS)
+test_output_LDADD = libkmscon-core.la
 
 test_vt_SOURCES = tests/test_vt.c
 test_vt_LDADD = libkmscon-core.la
index c1320f6..5157fb8 100644 (file)
  *
  * This would show a test screen on output 0 and 4:
  * $ ./test_output 0 4
- * The test screen is a white background with two gray triangles in the top-left
- * and lower-right corner.
+ * The test screen is a colored quad with 4 different colors in each corner.
  */
 
-#define GL_GLEXT_PROTOTYPES
-
+#include <errno.h>
 #include <inttypes.h>
 #include <signal.h>
 #include <stdio.h>
 #include <string.h>
 #include <unistd.h>
 
-#include <GL/gl.h>
-#include <GL/glext.h>
 #include "log.h"
 #include "output.h"
 
+/* a colored quad */
+float d_vert[] = { 1, 1, -1, 1, -1, -1, 1, -1 };
+float d_col[] = { 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 0, 1, 1 };
+
 static void sig_term(int sig)
 {
 }
@@ -65,6 +65,11 @@ static int set_outputs(struct kmscon_compositor *comp, int num, char **list)
 {
        struct kmscon_output *iter;
        int i, j, val, ret;
+       struct kmscon_context *ctx;
+
+       ctx = kmscon_compositor_get_context(comp);
+       if (!ctx)
+               return -EINVAL;
 
        j = 0;
        iter = kmscon_compositor_get_outputs(comp);
@@ -102,18 +107,8 @@ static int set_outputs(struct kmscon_compositor *comp, int num, char **list)
                        continue;
                }
 
-               glClearColor(1.0, 1.0, 1.0, 1.0);
-               glClear(GL_COLOR_BUFFER_BIT);
-
-               glBegin(GL_TRIANGLES);
-               glColor4f(0.5, 0.5, 0.5, 1.0);
-               glVertex3f(1.0, 1.0, 0.0f);
-               glVertex3f(0, 0, 0.0f);
-               glVertex3f(1.0, 0, 0.0f);
-               glVertex3f(-1.0, -1.0, 0.0f);
-               glVertex3f(0, 0, 0.0f);
-               glVertex3f(-1.0, 0, 0.0f);
-               glEnd();
+               kmscon_context_clear(ctx);
+               kmscon_context_draw_def(ctx, d_vert, d_col, 4);
 
                ret = kmscon_output_swap(iter);
                if (ret) {