struct opengl_function { char *Name; char *Type; char *Arguments; }; struct opengl_function OpenGLFunctionEntries[] = { {"BindTexture", "void", "GLenum target, GLuint texture"}, {"BlendFunc", "void", "GLenum sfactor, GLenum dfactor"}, {"Clear", "void", "GLbitfield mask"}, {"ClearAccum", "void", "GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha"}, {"ClearColor", "void", "GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha"}, {"ClearDepth", "void", "GLclampd depth"}, {"ClearIndex", "void", "GLfloat c"}, {"ClearStencil", "void", "GLint s"}, {"ClipPlane", "void", "GLenum plane, const GLdouble *equation"}, {"CullFace", "void", "GLenum mode"}, {"DeleteTextures", "void", "GLsizei n, const GLuint *textures"}, {"Disable", "void", "GLenum cap"}, {"DrawArrays", "void", "GLenum mode, GLint first, GLsizei count"}, {"DrawBuffer", "void", "GLenum mode"}, {"DrawElements", "void", "GLenum mode, GLsizei count, GLenum type, const GLvoid *indices"}, {"DrawArraysInstanced", "void", "GLenum mode, GLint first, GLsizei count, GLsizei instancecount"}, {"Enable", "void", "GLenum cap"}, {"GenTextures", "void", "GLsizei n, GLuint *textures"}, {"GetClipPlane", "void", "GLenum plane, GLdouble *equation"}, {"GetDoublev", "void", "GLenum pname, GLdouble *params"}, {"GetError", "GLenum", "void"}, {"GetFloatv", "void", "GLenum pname, GLfloat *params"}, {"GetIntegerv", "void", "GLenum pname, GLint *params"}, {"GetPointerv", "void", "GLenum pname, GLvoid* *params"}, {"GetString", "const GLubyte *", "GLenum name"}, {"GetTexEnvfv", "void", "GLenum target, GLenum pname, GLfloat *params"}, {"GetTexEnviv", "void", "GLenum target, GLenum pname, GLint *params"}, {"GetTexGendv", "void", "GLenum coord, GLenum pname, GLdouble *params"}, {"GetTexGenfv", "void", "GLenum coord, GLenum pname, GLfloat *params"}, {"GetTexGeniv", "void", "GLenum coord, GLenum pname, GLint *params"}, {"GetTexImage", "void", "GLenum target, GLint level, GLenum format, GLenum type, GLvoid *pixels"}, {"GetTexLevelParameterfv", "void", "GLenum target, GLint level, GLenum pname, GLfloat *params"}, {"GetTexLevelParameteriv", "void", "GLenum target, GLint level, GLenum pname, GLint *params"}, {"GetTexParameterfv", "void", "GLenum target, GLenum pname, GLfloat *params"}, {"GetTexParameteriv", "void", "GLenum target, GLenum pname, GLint *params"}, {"Hint", "void", "GLenum target, GLenum mode"}, {"IsTexture", "GLboolean", "GLuint texture"}, {"LineWidth", "void", "GLfloat width"}, {"ListBase", "void", "GLuint base"}, {"LoadName", "void", "GLuint name"}, {"LogicOp", "void", "GLenum opcode"}, {"PointSize", "void", "GLfloat size"}, {"PolygonMode", "void", "GLenum face, GLenum mode"}, {"Scissor", "void", "GLint x, GLint y, GLsizei width, GLsizei height"}, {"TexImage1D", "void", "GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const GLvoid *pixels"}, {"TexImage2D", "void", "GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels"}, {"TexParameterf", "void", "GLenum target, GLenum pname, GLfloat param"}, {"TexParameterfv", "void", "GLenum target, GLenum pname, const GLfloat *params"}, {"TexParameteri", "void", "GLenum target, GLenum pname, GLint param"}, {"TexParameteriv", "void", "GLenum target, GLenum pname, const GLint *params"}, {"TexSubImage1D", "void", "GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels"}, {"TexSubImage2D", "void", "GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels"}, {"CompressedTexImage2D", "void", "GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *pixels"}, {"ActiveTexture", "void", "GLenum texture"}, {"Viewport", "void", "GLint x, GLint y, GLsizei width, GLsizei height"}, {"GenBuffers", "void", "GLsizei n, GLuint *buffers"}, {"BindBuffer", "void", "GLenum target, GLuint buffer"}, {"BufferData", "void", "GLenum target, GLsizeiptr size, const void *data, GLenum usage"}, {"BufferSubData", "void", "GLenum target, GLintptr offset, GLsizeiptr size, const void *data"}, {"GenVertexArrays", "void", "GLsizei n, GLuint *arrays"}, {"BindVertexArray", "void", "GLenum array"}, {"GetAttribLocation", "GLint", "GLuint program, const GLchar *name"}, {"EnableVertexAttribArray", "void", "GLuint index"}, {"DisableVertexAttribArray", "void", "GLuint index"}, {"VertexAttribPointer", "void", "GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void *pointer"}, {"VertexAttribIPointer", "void", "GLuint index, GLint size, GLenum type, GLsizei stride, const void * pointer"}, {"VertexAttribLPointer", "void", "GLuint index, GLint size, GLenum type, GLsizei stride, const void * pointer"}, {"VertexAttribDivisor", "void", "GLuint index, GLuint divisor"}, {"CreateShader", "GLuint", "GLenum type"}, {"ShaderSource", "void", "GLuint shader, GLsizei count, const GLchar *const*string, const GLint *length"}, {"CompileShader", "void", "GLuint shader"}, {"DeleteShader", "void", "GLuint shader"}, {"GetShaderiv", "void", "GLuint shader, GLenum pname, GLint *params"}, {"GetShaderInfoLog", "void", "GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog"}, {"CreateProgram", "GLuint", "void"}, {"UseProgram", "void", "GLuint program"}, {"AttachShader", "void", "GLuint program, GLuint shader"}, {"DeleteProgram", "void", "GLuint program"}, {"LinkProgram", "void", "GLuint program"}, {"GetProgramiv", "void", "GLuint program, GLenum pname, GLint *params"}, {"GetProgramInfoLog", "void", "GLuint program, GLsizei bufSize, GLsizei *length, GLchar *infoLog"}, {"GetUniformLocation", "GLint", "GLuint program, const GLchar *name"}, {"Uniform1i", "void", "GLint location, GLint v0"}, {"Uniform2f", "void", "GLint location, GLfloat v0, GLfloat v1"}, {"Uniform3f", "void", "GLint location, GLfloat v0, GLfloat v1, GLfloat v2"}, {"UniformMatrix4fv", "void", "GLint location, GLsizei count, GLboolean transpose, const GLfloat *value"}, {"DebugMessageCallback", "void", "void (*)(GLenum, GLenum, GLuint, GLenum, GLsizei, const GLchar *, const void *), const void *userParam"}, }; static void GenOpenGL(void) { FILE *Out = fopen("../code/generated/vn_opengl_functions.h", "wb"); if(Out) { for(s32 Index = 0; Index < ArrayCount(OpenGLFunctionEntries); ++Index) { struct opengl_function *Function = OpenGLFunctionEntries + Index; fprintf(Out, "typedef %s opengl_%s(%s);\n", Function->Type, Function->Name, Function->Arguments); } fprintf(Out, "\n"); for(s32 Index = 0; Index < ArrayCount(OpenGLFunctionEntries); ++Index) { struct opengl_function *Function = OpenGLFunctionEntries + Index; fprintf(Out, "global opengl_%s *gl%s = 0;\n", Function->Name, Function->Name); } fprintf(Out, "\n"); fprintf(Out, "extern void *OpenGL_LoadFunction(char *);\n"); fprintf(Out, "\n"); fprintf(Out, "static void OpenGL_LoadAllFunctions(void)\n"); fprintf(Out, "{\n"); for(s32 Index = 0; Index < ArrayCount(OpenGLFunctionEntries); ++Index) { struct opengl_function *Function = OpenGLFunctionEntries + Index; fprintf(Out, "\tgl%s = (opengl_%s *)OpenGL_LoadFunction(\"gl%s\");\n", Function->Name, Function->Name, Function->Name); } fprintf(Out, "}\n"); fclose(Out); } }