summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--wimmel.frag2
-rw-r--r--wimmel_gl.c24
2 files changed, 21 insertions, 5 deletions
diff --git a/wimmel.frag b/wimmel.frag
index 22adcf9..58d633e 100644
--- a/wimmel.frag
+++ b/wimmel.frag
@@ -22,7 +22,7 @@ main()
}
}
- gl_FragColor = vec4(float(diff < barrier), 0.0, 0.0, 1.0);
+ gl_FragColor = vec4(0.0, 0.0, float(diff < barrier), 1.0);
}
// vim:ft=c:
diff --git a/wimmel_gl.c b/wimmel_gl.c
index 0f271af..64fdda3 100644
--- a/wimmel_gl.c
+++ b/wimmel_gl.c
@@ -1,4 +1,6 @@
+#include <stdio.h>
#include <stdlib.h>
+#include <string.h>
#include <glib.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
@@ -8,6 +10,7 @@
#include <EGL/egl.h>
#include <GLES2/gl2.h>
+#include <GLES2/gl2ext.h>
#else
@@ -355,16 +358,29 @@ main(int argc, char **argv)
draw();
glPixelStorei(GL_PACK_ALIGNMENT, 1);
- stride = width * 4;
+ stride = width * sizeof(GLushort);
buffer = malloc(stride * height);
+
+#ifndef GLUT
+ if (!strstr((char *) glGetString(GL_EXTENSIONS),
+ "GL_EXT_read_format_bgra")) {
+ fprintf(stderr, "GL_EXT_read_format_bgra not available\n");
+ exit(EXIT_FAILURE);
+ }
+#endif
glReadPixels(0, 0, width, height,
- GL_RGBA, GL_UNSIGNED_BYTE,
+ GL_BGRA_EXT,
+#ifdef GL_EXT_read_format_bgra
+ GL_UNSIGNED_SHORT_4_4_4_4_REV_EXT,
+#else
+ GL_UNSIGNED_SHORT_4_4_4_4_REV,
+#endif
buffer);
for (int j = 0; j < height; ++j) {
- guchar *row = buffer + (height - 1 - j) * stride;
+ GLushort *row = (GLushort *) (buffer + (height - 1 - j) * stride);
for (int i = 0; i < width; ++i) {
- if (*(row + i*4)) {
+ if (row[i] & 0x0f) {
color_t color = COLOR(255, 0, 0, 0);
for (int k = i; k < i+mwidth; k++) {
put_pixel(pixbuf, POINT(k, j), color);