summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile2
-rw-r--r--wimmel_gl.c99
2 files changed, 79 insertions, 22 deletions
diff --git a/Makefile b/Makefile
index 0156d6c..2f72437 100644
--- a/Makefile
+++ b/Makefile
@@ -23,7 +23,7 @@ wimmel_gl: wimmel_gl.o util.o
wimmel_gl:
- $(CC) $(LDFLAGS) `pkg-config --cflags --libs egl gl` -o $@ $+
+ $(CC) $(LDFLAGS) `pkg-config --cflags --libs egl glesv2` -o $@ $+
clean:
rm -f $(PROGS) $(OBJS)
diff --git a/wimmel_gl.c b/wimmel_gl.c
index 6610a5b..5fbf942 100644
--- a/wimmel_gl.c
+++ b/wimmel_gl.c
@@ -5,14 +5,18 @@
#define GL_GLEXT_PROTOTYPES
#ifndef GLUT
+
#include <EGL/egl.h>
+#include <GLES2/gl2.h>
+
#else
-#include <GL/glut.h>
-#endif
+#include <GL/glut.h>
#include <GL/gl.h>
#include <GL/glext.h>
+#endif
+
#include "util.h"
#ifndef GLUT
@@ -218,19 +222,71 @@ init_gl(int argc, char **argv)
{
GLuint fb, rb;
#ifndef GLUT
+ EGLint ctx_attribs[] = {
+ EGL_CONTEXT_CLIENT_VERSION, 2,
+ EGL_NONE
+ };
+#if 0
+ EGLint attribs[] = {
+ EGL_SURFACE_TYPE, EGL_PBUFFER_BIT,
+ EGL_RED_SIZE, 1,
+ EGL_GREEN_SIZE, 1,
+ EGL_BLUE_SIZE, 1,
+ EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
+ EGL_NONE
+ };
+ EGLint pbuf_attribs[] = {
+ EGL_WIDTH, width,
+ EGL_HEIGHT, height,
+#if 0
+ EGL_TEXTURE_FORMAT, EGL_TEXTURE_RGB,
+ EGL_TEXTURE_TARGET, EGL_TEXTURE_2D,
+#endif
+ EGL_NONE
+ };
+ EGLSurface surf;
+ EGLConfig conf;
+ EGLint num_conf;
+#endif
+ EGLContext ctx;
+
dpy = eglGetDisplay(EGL_DEFAULT_DISPLAY);
+
eglInitialize(dpy, NULL, NULL);
- eglBindAPI(EGL_OPENGL_API);
- EGLContext ctx = eglCreateContext(dpy, NULL, EGL_NO_CONTEXT, NULL);
+ eglBindAPI(EGL_OPENGL_ES_API);
+#if 0
+ if (!eglChooseConfig(dpy, attribs, &conf, 1, &num_conf) || !num_conf) {
+ printf("eglChooseConfig() failed\n");
+ exit(EXIT_FAILURE);
+ }
+#endif
+ ctx = eglCreateContext(dpy, NULL, EGL_NO_CONTEXT, ctx_attribs);
if (ctx == NULL) {
fprintf(stderr, "failed to create context\n");
exit(EXIT_FAILURE);
}
-
if (!eglMakeCurrent(dpy, EGL_NO_SURFACE, EGL_NO_SURFACE, ctx)) {
fprintf(stderr, "failed to make context current\n");
exit(EXIT_FAILURE);
}
+#if 0
+ ctx = eglCreateContext(dpy, conf, EGL_NO_CONTEXT, ctx_attribs);
+ if (ctx == NULL) {
+ fprintf(stderr, "failed to create context\n");
+ exit(EXIT_FAILURE);
+ }
+ surf = eglCreatePbufferSurface(dpy, conf, pbuf_attribs);
+ if (!surf) {
+ fprintf(stderr, "failed to create pbuffer surface\n");
+ exit(EXIT_FAILURE);
+ }
+
+ if (!eglMakeCurrent(dpy, surf, surf, ctx)) {
+ fprintf(stderr, "failed to make context current\n");
+ exit(EXIT_FAILURE);
+ }
+#endif
+
#else
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_RGBA /*| GLUT_DEPTH */ | GLUT_DOUBLE);
@@ -238,22 +294,23 @@ init_gl(int argc, char **argv)
int window = glutCreateWindow("wimmel");
glutDestroyWindow(window);
#endif
- glGenFramebuffersEXT(1, &fb);
- glGenRenderbuffersEXT(1, &rb);
-
- glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fb);
- glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, rb);
-
- glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT,
- GL_COLOR_ATTACHMENT0_EXT,
- GL_RENDERBUFFER_EXT,
- rb);
- glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT,
- GL_RGBA,
- width, height);
-
- if (glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT) !=
- GL_FRAMEBUFFER_COMPLETE_EXT) {
+
+ glGenFramebuffers(1, &fb);
+ glGenRenderbuffers(1, &rb);
+
+ glBindFramebuffer(GL_FRAMEBUFFER, fb);
+ glBindRenderbuffer(GL_RENDERBUFFER, rb);
+
+ glFramebufferRenderbuffer(GL_FRAMEBUFFER,
+ GL_COLOR_ATTACHMENT0,
+ GL_RENDERBUFFER,
+ rb);
+ glRenderbufferStorage(GL_RENDERBUFFER,
+ GL_RGBA4,
+ width, height);
+
+ if (glCheckFramebufferStatus(GL_FRAMEBUFFER) !=
+ GL_FRAMEBUFFER_COMPLETE) {
fprintf(stderr, "Framebuffer not complete\n");
exit(EXIT_FAILURE);
}