* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
+#include "glutil.h"
+
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <sstream>
-#include "glutil.h"
-
// extension functions we use
typedef GLuint (*GLCREATESHADERPROC) (GLenum type);
typedef void (*GLGETSHADERIVPROC) (GLuint shader, GLenum pname, GLint *params);
{
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;
}
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
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 "<unknown>";
- }
-#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\
}";
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\