mirror of
https://github.com/glfw/glfw.git
synced 2024-11-22 04:54:35 +00:00
Updated glad.
This commit is contained in:
parent
d79beb9539
commit
4596663232
39
deps/glad.c
vendored
39
deps/glad.c
vendored
@ -1,3 +1,4 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <glad/glad.h>
|
||||
|
||||
@ -687,9 +688,33 @@ static void find_extensionsGL(void) {
|
||||
}
|
||||
|
||||
static void find_coreGL(void) {
|
||||
const char *v = (const char *)glGetString(GL_VERSION);
|
||||
int major = v[0] - '0';
|
||||
int minor = v[2] - '0';
|
||||
|
||||
/* Thank you @elmindreda
|
||||
* https://github.com/elmindreda/greg/blob/master/templates/greg.c.in#L176
|
||||
* https://github.com/glfw/glfw/blob/master/src/context.c#L36
|
||||
*/
|
||||
int i, major, minor;
|
||||
|
||||
const char* version;
|
||||
const char* prefixes[] = {
|
||||
"OpenGL ES-CM ",
|
||||
"OpenGL ES-CL ",
|
||||
"OpenGL ES ",
|
||||
NULL
|
||||
};
|
||||
|
||||
version = (const char*) glGetString(GL_VERSION);
|
||||
if (!version) return;
|
||||
|
||||
for (i = 0; prefixes[i]; i++) {
|
||||
const size_t length = strlen(prefixes[i]);
|
||||
if (strncmp(version, prefixes[i], length) == 0) {
|
||||
version += length;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
sscanf(version, "%d.%d", &major, &minor);
|
||||
GLVersion.major = major; GLVersion.minor = minor;
|
||||
GLAD_GL_VERSION_1_0 = (major == 1 && minor >= 0) || major > 1;
|
||||
GLAD_GL_VERSION_1_1 = (major == 1 && minor >= 1) || major > 1;
|
||||
@ -704,10 +729,11 @@ static void find_coreGL(void) {
|
||||
GLAD_GL_VERSION_3_2 = (major == 3 && minor >= 2) || major > 3;
|
||||
}
|
||||
|
||||
void gladLoadGLLoader(GLADloadproc load) {
|
||||
int gladLoadGLLoader(GLADloadproc load) {
|
||||
GLVersion.major = 0; GLVersion.minor = 0;
|
||||
glGetString = (PFNGLGETSTRINGPROC)load("glGetString");
|
||||
if(glGetString == NULL) return;
|
||||
if(glGetString == NULL) return 0;
|
||||
if(glGetString(GL_VERSION) == NULL) return 0;
|
||||
find_coreGL();
|
||||
load_GL_VERSION_1_0(load);
|
||||
load_GL_VERSION_1_1(load);
|
||||
@ -722,7 +748,6 @@ void gladLoadGLLoader(GLADloadproc load) {
|
||||
load_GL_VERSION_3_2(load);
|
||||
|
||||
find_extensionsGL();
|
||||
|
||||
return;
|
||||
return GLVersion.major != 0 || GLVersion.minor != 0;
|
||||
}
|
||||
|
||||
|
17
deps/glad/glad.h
vendored
17
deps/glad/glad.h
vendored
@ -22,15 +22,17 @@
|
||||
#define APIENTRYP APIENTRY *
|
||||
#endif
|
||||
|
||||
extern struct gladGLversionStruct {
|
||||
int major;
|
||||
int minor;
|
||||
} GLVersion;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct gladGLversionStruct {
|
||||
int major;
|
||||
int minor;
|
||||
};
|
||||
|
||||
extern struct gladGLversionStruct GLVersion;
|
||||
|
||||
typedef void* (* GLADloadproc)(const char *name);
|
||||
|
||||
#ifndef GLAPI
|
||||
@ -58,7 +60,7 @@ typedef void* (* GLADloadproc)(const char *name);
|
||||
# define GLAPI extern
|
||||
# endif
|
||||
#endif
|
||||
GLAPI void gladLoadGLLoader(GLADloadproc);
|
||||
GLAPI int gladLoadGLLoader(GLADloadproc);
|
||||
|
||||
#include <stddef.h>
|
||||
#include <KHR/khrplatform.h>
|
||||
@ -836,11 +838,13 @@ typedef GLintptr GLvdpauSurfaceNV;
|
||||
#define GL_UNIFORM_BUFFER_START 0x8A29
|
||||
#define GL_UNIFORM_BUFFER_SIZE 0x8A2A
|
||||
#define GL_MAX_VERTEX_UNIFORM_BLOCKS 0x8A2B
|
||||
#define GL_MAX_GEOMETRY_UNIFORM_BLOCKS 0x8A2C
|
||||
#define GL_MAX_FRAGMENT_UNIFORM_BLOCKS 0x8A2D
|
||||
#define GL_MAX_COMBINED_UNIFORM_BLOCKS 0x8A2E
|
||||
#define GL_MAX_UNIFORM_BUFFER_BINDINGS 0x8A2F
|
||||
#define GL_MAX_UNIFORM_BLOCK_SIZE 0x8A30
|
||||
#define GL_MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS 0x8A31
|
||||
#define GL_MAX_COMBINED_GEOMETRY_UNIFORM_COMPONENTS 0x8A32
|
||||
#define GL_MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS 0x8A33
|
||||
#define GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT 0x8A34
|
||||
#define GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH 0x8A35
|
||||
@ -859,6 +863,7 @@ typedef GLintptr GLvdpauSurfaceNV;
|
||||
#define GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS 0x8A42
|
||||
#define GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES 0x8A43
|
||||
#define GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER 0x8A44
|
||||
#define GL_UNIFORM_BLOCK_REFERENCED_BY_GEOMETRY_SHADER 0x8A45
|
||||
#define GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER 0x8A46
|
||||
#define GL_INVALID_INDEX 0xFFFFFFFF
|
||||
#define GL_CONTEXT_CORE_PROFILE_BIT 0x00000001
|
||||
|
Loading…
Reference in New Issue
Block a user