From cc78b74098e02311cc646fe5b82c13641ff705fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20K=C3=A4fer?= Date: Thu, 29 Sep 2016 15:32:48 +0200 Subject: [core] remove dependence on gl.h types --- src/mbgl/gl/context.hpp | 58 ++++++++++++------------------------------------- 1 file changed, 14 insertions(+), 44 deletions(-) (limited to 'src/mbgl/gl/context.hpp') diff --git a/src/mbgl/gl/context.hpp b/src/mbgl/gl/context.hpp index 133a56b6f8..04089c2000 100644 --- a/src/mbgl/gl/context.hpp +++ b/src/mbgl/gl/context.hpp @@ -7,56 +7,26 @@ #include #include +#include namespace mbgl { namespace gl { -constexpr GLsizei TextureMax = 64; +constexpr size_t TextureMax = 64; class Context : private util::noncopyable { public: ~Context(); - UniqueProgram createProgram() { - return UniqueProgram { MBGL_CHECK_ERROR(glCreateProgram()), { this } }; - } - - UniqueShader createVertexShader() { - return UniqueShader { MBGL_CHECK_ERROR(glCreateShader(GL_VERTEX_SHADER)), { this } }; - } - - UniqueShader createFragmentShader() { - return UniqueShader { MBGL_CHECK_ERROR(glCreateShader(GL_FRAGMENT_SHADER)), { this } }; - } - - UniqueBuffer createBuffer() { - BufferID id = 0; - MBGL_CHECK_ERROR(glGenBuffers(1, &id)); - return UniqueBuffer { std::move(id), { this } }; - } + UniqueProgram createProgram(); + UniqueShader createVertexShader(); + UniqueShader createFragmentShader(); + UniqueBuffer createBuffer(); + UniqueTexture createTexture(); + UniqueVertexArray createVertexArray(); + UniqueFramebuffer createFramebuffer(); - UniqueTexture createTexture() { - if (pooledTextures.empty()) { - pooledTextures.resize(TextureMax); - MBGL_CHECK_ERROR(glGenTextures(TextureMax, pooledTextures.data())); - } - - TextureID id = pooledTextures.back(); - pooledTextures.pop_back(); - return UniqueTexture { std::move(id), { this } }; - } - - UniqueVertexArray createVertexArray() { - VertexArrayID id = 0; - MBGL_CHECK_ERROR(gl::GenVertexArrays(1, &id)); - return UniqueVertexArray { std::move(id), { this } }; - } - - UniqueFramebuffer createFramebuffer() { - FramebufferID id = 0; - MBGL_CHECK_ERROR(glGenFramebuffers(1, &id)); - return UniqueFramebuffer { std::move(id), { this } }; - } + void uploadBuffer(BufferType, size_t, void*); // Actually remove the objects we marked as abandoned with the above methods. // Only call this while the OpenGL context is exclusive to this thread. @@ -100,13 +70,13 @@ public: State activeTexture; State bindFramebuffer; State viewport; -#ifndef GL_ES_VERSION_2_0 +#if not MBGL_USE_GLES2 State pixelZoom; State rasterPos; -#endif // GL_ES_VERSION_2_0 +#endif // MBGL_USE_GLES2 std::array, 2> texture; - State> vertexBuffer; - State> elementBuffer; + State vertexBuffer; + State elementBuffer; State vertexArrayObject; private: -- cgit v1.2.1