[core] Refactor OpenGL extension loading mechanism
Previously, we initialized global variables that held pointers to the extension functions. While this seemed to work, the spec doesn't guarantee that the function pointers are identical for different OpenGL contexts. Therefore, we are now making them a member variable of the Context object.
This commit is contained in:
committed by
John Firebaugh
parent
234384ece9
commit
e67abfbe67
44
src/mbgl/gl/program_binary_extension.hpp
Normal file
44
src/mbgl/gl/program_binary_extension.hpp
Normal file
@@ -0,0 +1,44 @@
|
||||
#pragma once
|
||||
|
||||
#include <mbgl/gl/features.hpp>
|
||||
#include <mbgl/gl/extension.hpp>
|
||||
#include <mbgl/gl/gl.hpp>
|
||||
|
||||
#if MBGL_HAS_BINARY_PROGRAMS
|
||||
|
||||
#define GL_PROGRAM_BINARY_LENGTH 0x8741
|
||||
#define GL_NUM_PROGRAM_BINARY_FORMATS 0x87FE
|
||||
#define GL_PROGRAM_BINARY_FORMATS 0x87FF
|
||||
|
||||
namespace mbgl {
|
||||
namespace gl {
|
||||
namespace extension {
|
||||
|
||||
class ProgramBinary {
|
||||
public:
|
||||
template <typename Fn>
|
||||
ProgramBinary(const Fn& loadExtension)
|
||||
: getProgramBinary(loadExtension({
|
||||
{ "GL_OES_get_program_binary", "glGetProgramBinaryOES" },
|
||||
{ "GL_ARB_get_program_binary", "glGetProgramBinary" },
|
||||
})),
|
||||
programBinary(loadExtension({
|
||||
{ "GL_OES_get_program_binary", "glProgramBinaryOES" },
|
||||
{ "GL_ARB_get_program_binary", "glProgramBinary" },
|
||||
})) {
|
||||
}
|
||||
|
||||
const ExtensionFunction<void(
|
||||
GLuint program, GLsizei bufSize, GLsizei* length, GLenum* binaryFormat, GLvoid* binary)>
|
||||
getProgramBinary;
|
||||
|
||||
const ExtensionFunction<void(
|
||||
GLuint program, GLenum binaryFormat, const GLvoid* binary, GLint length)>
|
||||
programBinary;
|
||||
};
|
||||
|
||||
} // namespace extension
|
||||
} // namespace gl
|
||||
} // namespace mbgl
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user