From: Ralf Jung Date: Sun, 8 Sep 2013 19:29:26 +0000 (+0200) Subject: rename window system and context choice variables X-Git-Url: https://git.ralfj.de/gltest.git/commitdiff_plain/b4dc0596570275aa9def5ff63af951beb8473d58?ds=inline rename window system and context choice variables --- diff --git a/Makefile b/Makefile index 52a6495..c848639 100644 --- a/Makefile +++ b/Makefile @@ -7,14 +7,18 @@ BINARIES := glxtest egltest glestest eglinfo 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 diff --git a/eglbackend.cpp b/eglbackend.cpp index c5d5bcb..0d5e5e6 100644 --- a/eglbackend.cpp +++ b/eglbackend.cpp @@ -24,6 +24,10 @@ #include +#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 @@ -50,7 +54,7 @@ static void exitEglError(const char *what) } static const EGLint context_attribs[] = { -#ifdef USE_GLES +#ifdef CON_GLES2 EGL_CONTEXT_CLIENT_VERSION, 2, #endif EGL_NONE @@ -59,7 +63,7 @@ static const EGLint config_attribs[] = { 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, @@ -82,7 +86,7 @@ VisualID EGLBackend::initialize(Display *xDisplay) 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) diff --git a/gltest.cpp b/gltest.cpp index 440e8f5..edc17f8 100644 --- a/gltest.cpp +++ b/gltest.cpp @@ -31,14 +31,14 @@ namespace po = boost::program_options; // 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() { diff --git a/glutil.h b/glutil.h index 704d2cb..e7a39ad 100644 --- a/glutil.h +++ b/glutil.h @@ -17,7 +17,7 @@ */ -#ifdef USE_GLES +#ifdef CON_GLES2 #include #else #include diff --git a/glutil_gl1.cpp b/glutil_gl1.cpp index 8e31114..596704e 100644 --- a/glutil_gl1.cpp +++ b/glutil_gl1.cpp @@ -18,6 +18,10 @@ #include "glutil.h" +#if defined(CON_GLES2) +#error "GLES2 contexts do not support GL1 functionality" +#endif + // initialisation void initialise2dProjection() { @@ -37,4 +41,4 @@ void drawQuad(GLfloat red, GLfloat green, GLfloat blue, GLfloat x1, GLfloat y1, glVertex2f(x2, y2); glVertex2f(x1, y2); glEnd(); -} \ No newline at end of file +} diff --git a/glutil_gl2.cpp b/glutil_gl2.cpp index ebcb5b0..ad89138 100644 --- a/glutil_gl2.cpp +++ b/glutil_gl2.cpp @@ -21,6 +21,10 @@ #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\ diff --git a/glxbackend.cpp b/glxbackend.cpp index a957e5b..97e6937 100644 --- a/glxbackend.cpp +++ b/glxbackend.cpp @@ -24,6 +24,10 @@ #include #include +#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[] = {