added files
This commit is contained in:
@@ -0,0 +1,146 @@
|
||||
#pragma once
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
// GLFunctions
|
||||
//
|
||||
// Linux distributions only ship GL/gl.h with legacy (<=1.1/1.2) function
|
||||
// declarations; everything from OpenGL 1.5 onward (VAOs/VBOs, GLSL
|
||||
// shaders, etc.) must be resolved at runtime as function pointers. This
|
||||
// is a small, self-contained loader for exactly the subset of OpenGL 3.3
|
||||
// core functions this project's renderer uses. It is intentionally
|
||||
// separate from Dear ImGui's own bundled loader (imgui_impl_opengl3_loader.h)
|
||||
// to avoid the multiple-definition problems that occur when two GL
|
||||
// loaders are mixed in the same program - see the comment at the top of
|
||||
// that file for details.
|
||||
//
|
||||
// Usage: call planetarium::gl::loadGLFunctions() exactly once, right
|
||||
// after the GLFW OpenGL context has been made current and before any
|
||||
// other GL call in the project's own rendering code.
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
#include <GL/gl.h>
|
||||
#include <cstddef>
|
||||
|
||||
#ifndef GL_ARRAY_BUFFER
|
||||
#define GL_ARRAY_BUFFER 0x8892
|
||||
#endif
|
||||
#ifndef GL_ELEMENT_ARRAY_BUFFER
|
||||
#define GL_ELEMENT_ARRAY_BUFFER 0x8893
|
||||
#endif
|
||||
#ifndef GL_STATIC_DRAW
|
||||
#define GL_STATIC_DRAW 0x88E4
|
||||
#endif
|
||||
#ifndef GL_DYNAMIC_DRAW
|
||||
#define GL_DYNAMIC_DRAW 0x88E8
|
||||
#endif
|
||||
#ifndef GL_FRAGMENT_SHADER
|
||||
#define GL_FRAGMENT_SHADER 0x8B30
|
||||
#endif
|
||||
#ifndef GL_VERTEX_SHADER
|
||||
#define GL_VERTEX_SHADER 0x8B31
|
||||
#endif
|
||||
#ifndef GL_COMPILE_STATUS
|
||||
#define GL_COMPILE_STATUS 0x8B81
|
||||
#endif
|
||||
#ifndef GL_LINK_STATUS
|
||||
#define GL_LINK_STATUS 0x8B82
|
||||
#endif
|
||||
#ifndef GL_TEXTURE0
|
||||
#define GL_TEXTURE0 0x84C0
|
||||
#endif
|
||||
#ifndef GL_PROGRAM_POINT_SIZE
|
||||
#define GL_PROGRAM_POINT_SIZE 0x8642
|
||||
#endif
|
||||
#ifndef GL_CLAMP_TO_EDGE
|
||||
#define GL_CLAMP_TO_EDGE 0x812F
|
||||
#endif
|
||||
#ifndef GL_MULTISAMPLE
|
||||
#define GL_MULTISAMPLE 0x809D
|
||||
#endif
|
||||
#ifndef GL_MAJOR_VERSION
|
||||
#define GL_MAJOR_VERSION 0x821B
|
||||
#endif
|
||||
#ifndef GL_MINOR_VERSION
|
||||
#define GL_MINOR_VERSION 0x821C
|
||||
#endif
|
||||
|
||||
typedef char GLchar;
|
||||
typedef ptrdiff_t GLsizeiptr;
|
||||
typedef ptrdiff_t GLintptr;
|
||||
|
||||
namespace planetarium::gl {
|
||||
|
||||
using PFNGLGENVERTEXARRAYS = void (*)(GLsizei, GLuint*);
|
||||
using PFNGLBINDVERTEXARRAY = void (*)(GLuint);
|
||||
using PFNGLDELETEVERTEXARRAYS = void (*)(GLsizei, const GLuint*);
|
||||
using PFNGLGENBUFFERS = void (*)(GLsizei, GLuint*);
|
||||
using PFNGLBINDBUFFER = void (*)(GLenum, GLuint);
|
||||
using PFNGLBUFFERDATA = void (*)(GLenum, GLsizeiptr, const void*, GLenum);
|
||||
using PFNGLDELETEBUFFERS = void (*)(GLsizei, const GLuint*);
|
||||
using PFNGLVERTEXATTRIBPOINTER = void (*)(GLuint, GLint, GLenum, GLboolean, GLsizei, const void*);
|
||||
using PFNGLENABLEVERTEXATTRIBARRAY = void (*)(GLuint);
|
||||
using PFNGLDISABLEVERTEXATTRIBARRAY = void (*)(GLuint);
|
||||
|
||||
using PFNGLCREATESHADER = GLuint (*)(GLenum);
|
||||
using PFNGLSHADERSOURCE = void (*)(GLuint, GLsizei, const GLchar* const*, const GLint*);
|
||||
using PFNGLCOMPILESHADER = void (*)(GLuint);
|
||||
using PFNGLGETSHADERIV = void (*)(GLuint, GLenum, GLint*);
|
||||
using PFNGLGETSHADERINFOLOG = void (*)(GLuint, GLsizei, GLsizei*, GLchar*);
|
||||
using PFNGLDELETESHADER = void (*)(GLuint);
|
||||
using PFNGLCREATEPROGRAM = GLuint (*)();
|
||||
using PFNGLATTACHSHADER = void (*)(GLuint, GLuint);
|
||||
using PFNGLLINKPROGRAM = void (*)(GLuint);
|
||||
using PFNGLGETPROGRAMIV = void (*)(GLuint, GLenum, GLint*);
|
||||
using PFNGLGETPROGRAMINFOLOG = void (*)(GLuint, GLsizei, GLsizei*, GLchar*);
|
||||
using PFNGLUSEPROGRAM = void (*)(GLuint);
|
||||
using PFNGLDELETEPROGRAM = void (*)(GLuint);
|
||||
|
||||
using PFNGLGETUNIFORMLOCATION = GLint (*)(GLuint, const GLchar*);
|
||||
using PFNGLUNIFORMMATRIX4FV = void (*)(GLint, GLsizei, GLboolean, const GLfloat*);
|
||||
using PFNGLUNIFORM3FV = void (*)(GLint, GLsizei, const GLfloat*);
|
||||
using PFNGLUNIFORM4FV = void (*)(GLint, GLsizei, const GLfloat*);
|
||||
using PFNGLUNIFORM1F = void (*)(GLint, GLfloat);
|
||||
using PFNGLUNIFORM1I = void (*)(GLint, GLint);
|
||||
using PFNGLACTIVETEXTURE = void (*)(GLenum);
|
||||
using PFNGLGENERATEMIPMAP = void (*)(GLenum);
|
||||
|
||||
extern PFNGLGENVERTEXARRAYS glGenVertexArrays;
|
||||
extern PFNGLBINDVERTEXARRAY glBindVertexArray;
|
||||
extern PFNGLDELETEVERTEXARRAYS glDeleteVertexArrays;
|
||||
extern PFNGLGENBUFFERS glGenBuffers;
|
||||
extern PFNGLBINDBUFFER glBindBuffer;
|
||||
extern PFNGLBUFFERDATA glBufferData;
|
||||
extern PFNGLDELETEBUFFERS glDeleteBuffers;
|
||||
extern PFNGLVERTEXATTRIBPOINTER glVertexAttribPointer;
|
||||
extern PFNGLENABLEVERTEXATTRIBARRAY glEnableVertexAttribArray;
|
||||
extern PFNGLDISABLEVERTEXATTRIBARRAY glDisableVertexAttribArray;
|
||||
|
||||
extern PFNGLCREATESHADER glCreateShader;
|
||||
extern PFNGLSHADERSOURCE glShaderSource;
|
||||
extern PFNGLCOMPILESHADER glCompileShader;
|
||||
extern PFNGLGETSHADERIV glGetShaderiv;
|
||||
extern PFNGLGETSHADERINFOLOG glGetShaderInfoLog;
|
||||
extern PFNGLDELETESHADER glDeleteShader;
|
||||
extern PFNGLCREATEPROGRAM glCreateProgram;
|
||||
extern PFNGLATTACHSHADER glAttachShader;
|
||||
extern PFNGLLINKPROGRAM glLinkProgram;
|
||||
extern PFNGLGETPROGRAMIV glGetProgramiv;
|
||||
extern PFNGLGETPROGRAMINFOLOG glGetProgramInfoLog;
|
||||
extern PFNGLUSEPROGRAM glUseProgram;
|
||||
extern PFNGLDELETEPROGRAM glDeleteProgram;
|
||||
|
||||
extern PFNGLGETUNIFORMLOCATION glGetUniformLocation;
|
||||
extern PFNGLUNIFORMMATRIX4FV glUniformMatrix4fv;
|
||||
extern PFNGLUNIFORM3FV glUniform3fv;
|
||||
extern PFNGLUNIFORM4FV glUniform4fv;
|
||||
extern PFNGLUNIFORM1F glUniform1f;
|
||||
extern PFNGLUNIFORM1I glUniform1i;
|
||||
extern PFNGLACTIVETEXTURE glActiveTexture;
|
||||
extern PFNGLGENERATEMIPMAP glGenerateMipmap;
|
||||
|
||||
// Resolves every function pointer above via glfwGetProcAddress. Must be
|
||||
// called once, after glfwMakeContextCurrent(). Returns false if any
|
||||
// required entry point could not be resolved.
|
||||
bool loadGLFunctions();
|
||||
|
||||
} // namespace planetarium::gl
|
||||
Reference in New Issue
Block a user