all: $(BINARIES)
+# choices (not all combinations are valid)
+# windowing system WIN_{GLX,EGL}
+# the kind of context CON_{GL1,GLES2}
+
glxtest: $(COMMON_SRC) $(COMMON_HDR) glutil_gl1.cpp glxbackend.cpp glxbackend.h
- g++ $(FLAGS) -DUSE_GLX $(COMMON_SRC) glutil_gl1.cpp glxbackend.cpp -lGL -lX11 -lboost_program_options -o glxtest
+ g++ $(FLAGS) -DWIN_GLX -DCON_GL1 $(COMMON_SRC) glutil_gl1.cpp glxbackend.cpp -lGL -lX11 -lboost_program_options -o glxtest
egltest: $(COMMON_SRC) $(COMMON_HDR) glutil_gl1.cpp eglbackend.cpp eglbackend.h
- g++ $(FLAGS) -DUSE_EGL $(COMMON_SRC) glutil_gl1.cpp eglbackend.cpp -lEGL -lGL -lX11 -lboost_program_options -o egltest
+ g++ $(FLAGS) -DWIN_EGL -DCON_GL1 $(COMMON_SRC) glutil_gl1.cpp eglbackend.cpp -lEGL -lGL -lX11 -lboost_program_options -o egltest
glestest: $(COMMON_SRC) $(COMMON_HDR) glutil_gl2.cpp eglbackend.cpp eglbackend.h
- g++ $(FLAGS) -DUSE_EGL -DUSE_GLES $(COMMON_SRC) glutil_gl2.cpp eglbackend.cpp -lEGL -lGLESv2 -lX11 -lboost_program_options -o glestest
+ g++ $(FLAGS) -DWIN_EGL -DCON_GLES2 $(COMMON_SRC) glutil_gl2.cpp eglbackend.cpp -lEGL -lGLESv2 -lX11 -lboost_program_options -o glestest
eglinfo: eglinfo.c
gcc $(FLAGS) eglinfo.c -lEGL -lGL -lX11 -o eglinfo
#include <EGL/eglext.h>
+#if !defined(CON_GL1) && !defined(CON_GLES2)
+#error "Valid GL contexts for EGL are: GL1, GLES2"
+#endif
+
static const char *eglErrorToString(EGLint e)
{
#define CASE(name) case name: return #name
}
static const EGLint context_attribs[] = {
-#ifdef USE_GLES
+#ifdef CON_GLES2
EGL_CONTEXT_CLIENT_VERSION, 2,
#endif
EGL_NONE
EGL_RED_SIZE, 4,
EGL_GREEN_SIZE, 4,
EGL_BLUE_SIZE, 4,
-#ifdef USE_GLES
+#ifdef CON_GLES2
EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
#else
EGL_RENDERABLE_TYPE, EGL_OPENGL_BIT,
fprintf(stderr, "Need at least EGL 1.3 to function properly\n");
exit(1);
}
-#ifdef USE_GLES
+#ifdef CON_GLES2
if (eglBindAPI(EGL_OPENGL_ES_API) == EGL_FALSE)
#else
if (eglBindAPI(EGL_OPENGL_API) == EGL_FALSE)
// my GL utility functions and the GL window class
#include "glutil.h"
#include "glwindow.h"
-// include proper GL backend
-#if defined(USE_GLX)
+// include proper GL backend (windowing system)
+#if defined(WIN_GLX)
#include "glxbackend.h"
static GLBackend *createGLBackend()
{
return new GLXBackend();
}
-#elif defined(USE_EGL)
+#elif defined(WIN_EGL)
#include "eglbackend.h"
static GLBackend *createGLBackend()
{
*/
-#ifdef USE_GLES
+#ifdef CON_GLES2
#include <GLES2/gl2.h>
#else
#include <GL/gl.h>
#include "glutil.h"
+#if defined(CON_GLES2)
+#error "GLES2 contexts do not support GL1 functionality"
+#endif
+
// initialisation
void initialise2dProjection()
{
glVertex2f(x2, y2);
glVertex2f(x1, y2);
glEnd();
-}
\ No newline at end of file
+}
#include "glutil.h"
+#if defined(CON_GL1)
+#error "GL1 contexts do not support GL2 functionality"
+#endif
+
// shaders
static const char *vertex_shader_source =
"#version 100 \n\
#include <GL/glxext.h>
#include <string>
+#if !defined(CON_GL1)
+#error "Valid GL contexts for GLX are: GL1"
+#endif
+
// attributes for a double buffered visual in RGBA format with at least 4 bits per color
static int attrList[] =
{