X-Git-Url: https://git.ralfj.de/gltest.git/blobdiff_plain/ce1b46da645fdcac80fc9c71082bb5cb40166576..3e648337c136c8a8715d642857faa9e00a6db180:/glutil_gl2.cpp diff --git a/glutil_gl2.cpp b/glutil_gl2.cpp index 666ede9..87d8e0c 100644 --- a/glutil_gl2.cpp +++ b/glutil_gl2.cpp @@ -16,13 +16,13 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +#include "glutil.h" + #include #include #include #include -#include "glutil.h" - // extension functions we use typedef GLuint (*GLCREATESHADERPROC) (GLenum type); typedef void (*GLGETSHADERIVPROC) (GLuint shader, GLenum pname, GLint *params); @@ -78,8 +78,7 @@ static T_proc resolveFunctionPointer(T_glGetProcAddress p_glGetProcAddress, cons { T_proc proc = p_glGetProcAddress(name); if (proc == NULL) { - fprintf(stderr, "Error resolvung function %s\n", name); - exit(1); + die("Error resolvung function %s\n", name); } return proc; } @@ -96,8 +95,7 @@ void resolveFunctionPointers(T_glGetProcAddress p_glGetProcAddress) int majorVersion; ssm >> majorVersion; if (majorVersion < 2) { - fprintf(stderr, "Need at least GL 2.0 to function properly, but detected version %d\n", majorVersion); - exit(1); + die("Need at least GL 2.0 to function properly, but detected version %d\n", majorVersion); } #endif @@ -127,35 +125,11 @@ void resolveFunctionPointers(T_glGetProcAddress p_glGetProcAddress) p_glDeleteBuffers = (GLDELETEBUFFERSPROC)resolveFunctionPointer(p_glGetProcAddress, "glDeleteBuffers"); } -static const char *glErrorToString(GLenum e) -{ -#define CASE(name) case name: return #name - switch (e) { - CASE(GL_NO_ERROR); - CASE(GL_INVALID_ENUM); - CASE(GL_INVALID_VALUE); - CASE(GL_INVALID_OPERATION); -#ifndef CON_GLES2 - CASE(GL_STACK_OVERFLOW); - CASE(GL_STACK_UNDERFLOW); -#endif - CASE(GL_OUT_OF_MEMORY); - default: return ""; - } -#undef CASE -} - -static void checkGlError(const char *what) -{ - GLenum e = glGetError(); - if (e == GL_NO_ERROR) return; - fprintf(stderr, "GL error %d (%s): %s\n", e, glErrorToString(e), what); - exit(1); -} - // shaders static const char *vertex_shader_source = "#version 100 \n\ +precision mediump float;\n\ +precision mediump int;\n\ attribute vec2 position; \n\ attribute vec3 color; \n\ varying vec3 frag_color; \n\ @@ -166,6 +140,8 @@ void main() \n\ }"; static const char *fragment_shader_source = "#version 100 \n\ +precision mediump float;\n\ +precision mediump int;\n\ varying vec3 frag_color; \n\ void main(void) \n\ { \n\