mirror of
https://github.com/gwm17/glfw.git
synced 2024-11-22 18:28:52 -05:00
Make all client API functions dynamically loaded
This commit is contained in:
parent
84b512c62c
commit
6b8d490249
|
@ -64,6 +64,7 @@ GLFW bundles a number of dependencies in the `deps/` directory.
|
|||
|
||||
## Changelog
|
||||
|
||||
- Made all client API functions dynamically loaded
|
||||
- Changed minimum required CMake version to 2.8.12
|
||||
- Replaced GLU with [linmath.h](https://github.com/datenwolf/linmath.h) in
|
||||
example programs
|
||||
|
|
|
@ -38,6 +38,7 @@
|
|||
static GLboolean parseVersionString(int* api, int* major, int* minor, int* rev)
|
||||
{
|
||||
int i;
|
||||
_GLFWwindow* window;
|
||||
const char* version;
|
||||
const char* prefixes[] =
|
||||
{
|
||||
|
@ -49,7 +50,9 @@ static GLboolean parseVersionString(int* api, int* major, int* minor, int* rev)
|
|||
|
||||
*api = GLFW_OPENGL_API;
|
||||
|
||||
version = (const char*) glGetString(GL_VERSION);
|
||||
window = _glfwPlatformGetCurrentContext();
|
||||
|
||||
version = (const char*) window->GetString(GL_VERSION);
|
||||
if (!version)
|
||||
{
|
||||
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||
|
@ -352,6 +355,10 @@ GLboolean _glfwRefreshContextAttribs(const _GLFWctxconfig* ctxconfig)
|
|||
{
|
||||
_GLFWwindow* window = _glfwPlatformGetCurrentContext();
|
||||
|
||||
window->GetIntegerv = (PFNGLGETINTEGERVPROC) glfwGetProcAddress("glGetIntegerv");
|
||||
window->GetString = (PFNGLGETSTRINGPROC) glfwGetProcAddress("glGetString");
|
||||
window->Clear = (PFNGLCLEARPROC) glfwGetProcAddress("glClear");
|
||||
|
||||
if (!parseVersionString(&window->context.api,
|
||||
&window->context.major,
|
||||
&window->context.minor,
|
||||
|
@ -382,7 +389,7 @@ GLboolean _glfwRefreshContextAttribs(const _GLFWctxconfig* ctxconfig)
|
|||
if (window->context.major >= 3)
|
||||
{
|
||||
GLint flags;
|
||||
glGetIntegerv(GL_CONTEXT_FLAGS, &flags);
|
||||
window->GetIntegerv(GL_CONTEXT_FLAGS, &flags);
|
||||
|
||||
if (flags & GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT)
|
||||
window->context.forward = GL_TRUE;
|
||||
|
@ -404,7 +411,7 @@ GLboolean _glfwRefreshContextAttribs(const _GLFWctxconfig* ctxconfig)
|
|||
(window->context.major == 3 && window->context.minor >= 2))
|
||||
{
|
||||
GLint mask;
|
||||
glGetIntegerv(GL_CONTEXT_PROFILE_MASK, &mask);
|
||||
window->GetIntegerv(GL_CONTEXT_PROFILE_MASK, &mask);
|
||||
|
||||
if (mask & GL_CONTEXT_COMPATIBILITY_PROFILE_BIT)
|
||||
window->context.profile = GLFW_OPENGL_COMPAT_PROFILE;
|
||||
|
@ -427,7 +434,7 @@ GLboolean _glfwRefreshContextAttribs(const _GLFWctxconfig* ctxconfig)
|
|||
// only present from 3.0 while the extension applies from 1.1
|
||||
|
||||
GLint strategy;
|
||||
glGetIntegerv(GL_RESET_NOTIFICATION_STRATEGY_ARB, &strategy);
|
||||
window->GetIntegerv(GL_RESET_NOTIFICATION_STRATEGY_ARB, &strategy);
|
||||
|
||||
if (strategy == GL_LOSE_CONTEXT_ON_RESET_ARB)
|
||||
window->context.robustness = GLFW_LOSE_CONTEXT_ON_RESET;
|
||||
|
@ -444,7 +451,7 @@ GLboolean _glfwRefreshContextAttribs(const _GLFWctxconfig* ctxconfig)
|
|||
// one, so we can reuse them here
|
||||
|
||||
GLint strategy;
|
||||
glGetIntegerv(GL_RESET_NOTIFICATION_STRATEGY_ARB, &strategy);
|
||||
window->GetIntegerv(GL_RESET_NOTIFICATION_STRATEGY_ARB, &strategy);
|
||||
|
||||
if (strategy == GL_LOSE_CONTEXT_ON_RESET_ARB)
|
||||
window->context.robustness = GLFW_LOSE_CONTEXT_ON_RESET;
|
||||
|
@ -456,7 +463,7 @@ GLboolean _glfwRefreshContextAttribs(const _GLFWctxconfig* ctxconfig)
|
|||
if (glfwExtensionSupported("GL_KHR_context_flush_control"))
|
||||
{
|
||||
GLint behavior;
|
||||
glGetIntegerv(GL_CONTEXT_RELEASE_BEHAVIOR, &behavior);
|
||||
window->GetIntegerv(GL_CONTEXT_RELEASE_BEHAVIOR, &behavior);
|
||||
|
||||
if (behavior == GL_NONE)
|
||||
window->context.release = GLFW_RELEASE_BEHAVIOR_NONE;
|
||||
|
@ -581,7 +588,7 @@ GLFWAPI int glfwExtensionSupported(const char* extension)
|
|||
|
||||
// Check if extension is in the modern OpenGL extensions string list
|
||||
|
||||
glGetIntegerv(GL_NUM_EXTENSIONS, &count);
|
||||
window->GetIntegerv(GL_NUM_EXTENSIONS, &count);
|
||||
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
|
@ -602,7 +609,7 @@ GLFWAPI int glfwExtensionSupported(const char* extension)
|
|||
{
|
||||
// Check if extension is in the old style OpenGL extensions string
|
||||
|
||||
const char* extensions = (const char*) glGetString(GL_EXTENSIONS);
|
||||
const char* extensions = (const char*) window->GetString(GL_EXTENSIONS);
|
||||
if (!extensions)
|
||||
{
|
||||
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||
|
|
|
@ -69,6 +69,10 @@
|
|||
#include "../deps/GL/glext.h"
|
||||
#endif
|
||||
|
||||
typedef void (APIENTRY * PFNGLCLEARPROC)(GLbitfield);
|
||||
typedef const GLubyte* (APIENTRY * PFNGLGETSTRINGPROC)(GLenum);
|
||||
typedef void (APIENTRY * PFNGLGETINTEGERVPROC)(GLenum,GLint*);
|
||||
|
||||
typedef struct _GLFWwndconfig _GLFWwndconfig;
|
||||
typedef struct _GLFWctxconfig _GLFWctxconfig;
|
||||
typedef struct _GLFWfbconfig _GLFWfbconfig;
|
||||
|
@ -261,6 +265,9 @@ struct _GLFWwindow
|
|||
#if defined(_GLFW_USE_OPENGL)
|
||||
PFNGLGETSTRINGIPROC GetStringi;
|
||||
#endif
|
||||
PFNGLGETINTEGERVPROC GetIntegerv;
|
||||
PFNGLGETSTRINGPROC GetString;
|
||||
PFNGLCLEARPROC Clear;
|
||||
|
||||
struct {
|
||||
GLFWwindowposfun pos;
|
||||
|
|
|
@ -202,7 +202,7 @@ GLFWAPI GLFWwindow* glfwCreateWindow(int width, int height,
|
|||
|
||||
// Clearing the front buffer to black to avoid garbage pixels left over
|
||||
// from previous uses of our bit of VRAM
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
window->Clear(GL_COLOR_BUFFER_BIT);
|
||||
_glfwPlatformSwapBuffers(window);
|
||||
|
||||
// Restore the previously current context (or NULL)
|
||||
|
|
Loading…
Reference in New Issue
Block a user