6 #define LOADPROC(type, func) \
8 if(!(func = (type)glXGetProcAddress((unsigned char*)#func))) { \
9 fputs("failed to load entry point: " #func, stderr); \
16 const char *glext, *glver;
18 if(!(glver = (const char*)glGetString(GL_VERSION))) {
19 fprintf(stderr, "failed to retrieve OpenGL version string\n");
24 sscanf(glver, "%d.%d", &glcaps.ver_major, &glcaps.ver_minor);
26 if(!(glext = (const char*)glGetString(GL_EXTENSIONS))) {
27 fprintf(stderr, "failed to retrieve OpenGL extensions string\n");
31 if(glcaps.ver_major >= 2 || glcaps.ver_minor >= 5 || (strstr(glext, "GL_ARB_vertex_buffer_object"))) {
35 if(glcaps.ver_major >= 2 || (strstr(glext, "GL_ARB_vertex_shader") && strstr(glext, "GL_ARB_fragment_shader"))) {
40 LOADPROC(PFNGLGENBUFFERSPROC, glGenBuffers);
41 LOADPROC(PFNGLDELETEBUFFERSPROC, glDeleteBuffers);
42 LOADPROC(PFNGLBINDBUFFERPROC, glBindBuffer);
43 LOADPROC(PFNGLBUFFERDATAPROC, glBufferData);
47 LOADPROC(PFNGLCREATEPROGRAMPROC, glCreateProgram);
48 LOADPROC(PFNGLDELETEPROGRAMPROC, glDeleteProgram);
49 LOADPROC(PFNGLATTACHSHADERPROC, glAttachShader);
50 LOADPROC(PFNGLLINKPROGRAMPROC, glLinkProgram);
51 LOADPROC(PFNGLGETPROGRAMIVPROC, glGetProgramiv);
52 LOADPROC(PFNGLGETPROGRAMINFOLOGPROC, glGetProgramInfoLog);
53 LOADPROC(PFNGLUSEPROGRAMPROC, glUseProgram);
54 LOADPROC(PFNGLGETUNIFORMLOCATIONPROC, glGetUniformLocation);
55 LOADPROC(PFNGLUNIFORM1IPROC, glUniform1i);
56 LOADPROC(PFNGLUNIFORM1FPROC, glUniform1f);
57 LOADPROC(PFNGLUNIFORM2FPROC, glUniform2f);
58 LOADPROC(PFNGLUNIFORM3FPROC, glUniform3f);
59 LOADPROC(PFNGLUNIFORM4FPROC, glUniform4f);
60 LOADPROC(PFNGLUNIFORMMATRIX4FVPROC, glUniformMatrix4fv);
61 LOADPROC(PFNGLGETATTRIBLOCATIONPROC, glGetAttribLocation);
62 LOADPROC(PFNGLVERTEXATTRIB3FPROC, glVertexAttrib3f);
63 LOADPROC(PFNGLCREATESHADERPROC, glCreateShader);
64 LOADPROC(PFNGLDELETESHADERPROC, glDeleteShader);
65 LOADPROC(PFNGLSHADERSOURCEPROC, glShaderSource);
66 LOADPROC(PFNGLCOMPILESHADERPROC, glCompileShader);
67 LOADPROC(PFNGLGETSHADERIVPROC, glGetShaderiv);
68 LOADPROC(PFNGLGETSHADERINFOLOGPROC, glGetShaderInfoLog);
69 LOADPROC(PFNGLBINDATTRIBLOCATIONPROC, glBindAttribLocation);
70 LOADPROC(PFNGLENABLEVERTEXATTRIBARRAYPROC, glEnableVertexAttribArray);
71 LOADPROC(PFNGLDISABLEVERTEXATTRIBARRAYPROC, glDisableVertexAttribArray);
72 LOADPROC(PFNGLVERTEXATTRIBPOINTERPROC, glVertexAttribPointer);