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 || (strstr(glext, "GL_ARB_vertex_shader") && strstr(glext, "GL_ARB_fragment_shader"))) {
37 LOADPROC(PFNGLCREATEPROGRAMPROC, glCreateProgram);
38 LOADPROC(PFNGLDELETEPROGRAMPROC, glDeleteProgram);
39 LOADPROC(PFNGLATTACHSHADERPROC, glAttachShader);
40 LOADPROC(PFNGLLINKPROGRAMPROC, glLinkProgram);
41 LOADPROC(PFNGLGETPROGRAMIVPROC, glGetProgramiv);
42 LOADPROC(PFNGLGETPROGRAMINFOLOGPROC, glGetProgramInfoLog);
43 LOADPROC(PFNGLUSEPROGRAMPROC, glUseProgram);
44 LOADPROC(PFNGLGETUNIFORMLOCATIONPROC, glGetUniformLocation);
45 LOADPROC(PFNGLUNIFORM1IPROC, glUniform1i);
46 LOADPROC(PFNGLUNIFORM1FPROC, glUniform1f);
47 LOADPROC(PFNGLUNIFORM2FPROC, glUniform2f);
48 LOADPROC(PFNGLUNIFORM3FPROC, glUniform3f);
49 LOADPROC(PFNGLUNIFORM4FPROC, glUniform4f);
50 LOADPROC(PFNGLUNIFORMMATRIX4FVPROC, glUniformMatrix4fv);
51 LOADPROC(PFNGLGETATTRIBLOCATIONPROC, glGetAttribLocation);
52 LOADPROC(PFNGLVERTEXATTRIB3FPROC, glVertexAttrib3f);
53 LOADPROC(PFNGLCREATESHADERPROC, glCreateShader);
54 LOADPROC(PFNGLDELETESHADERPROC, glDeleteShader);
55 LOADPROC(PFNGLSHADERSOURCEPROC, glShaderSource);
56 LOADPROC(PFNGLCOMPILESHADERPROC, glCompileShader);
57 LOADPROC(PFNGLGETSHADERIVPROC, glGetShaderiv);
58 LOADPROC(PFNGLGETSHADERINFOLOGPROC, glGetShaderInfoLog);