diff --git a/source/globjects/CMakeLists.txt b/source/globjects/CMakeLists.txt index be97ca95..c0a6f9d9 100644 --- a/source/globjects/CMakeLists.txt +++ b/source/globjects/CMakeLists.txt @@ -161,6 +161,16 @@ set(sources ${source_path}/implementations/FramebufferImplementation_Legacy.cpp ${source_path}/implementations/FramebufferImplementation_Legacy.h + ${source_path}/implementations/AbstractProgramImplementation.cpp + ${source_path}/implementations/AbstractProgramImplementation.h + ${source_path}/implementations/ProgramImplementation_Legacy.cpp + ${source_path}/implementations/ProgramImplementation_Legacy.h + + ${source_path}/implementations/AbstractProgramPipelineImplementation.cpp + ${source_path}/implementations/AbstractProgramPipelineImplementation.h + ${source_path}/implementations/ProgramPipelineImplementation_Legacy.cpp + ${source_path}/implementations/ProgramPipelineImplementation_Legacy.h + ${source_path}/implementations/AbstractProgramBinaryImplementation.cpp ${source_path}/implementations/AbstractProgramBinaryImplementation.h ${source_path}/implementations/ProgramBinaryImplementation_GetProgramBinaryARB.cpp @@ -168,6 +178,26 @@ set(sources ${source_path}/implementations/ProgramBinaryImplementation_None.cpp ${source_path}/implementations/ProgramBinaryImplementation_None.h + ${source_path}/implementations/AbstractQueryImplementation.cpp + ${source_path}/implementations/AbstractQueryImplementation.h + ${source_path}/implementations/QueryImplementation_Legacy.cpp + ${source_path}/implementations/QueryImplementation_Legacy.h + + ${source_path}/implementations/AbstractRenderbufferImplementation.cpp + ${source_path}/implementations/AbstractRenderbufferImplementation.h + ${source_path}/implementations/RenderbufferImplementation_Legacy.cpp + ${source_path}/implementations/RenderbufferImplementation_Legacy.h + + ${source_path}/implementations/AbstractSamplerImplementation.cpp + ${source_path}/implementations/AbstractSamplerImplementation.h + ${source_path}/implementations/SamplerImplementation_Legacy.cpp + ${source_path}/implementations/SamplerImplementation_Legacy.h + + ${source_path}/implementations/AbstractShaderImplementation.cpp + ${source_path}/implementations/AbstractShaderImplementation.h + ${source_path}/implementations/ShaderImplementation_Legacy.cpp + ${source_path}/implementations/ShaderImplementation_Legacy.h + ${source_path}/implementations/AbstractShadingLanguageIncludeImplementation.cpp ${source_path}/implementations/AbstractShadingLanguageIncludeImplementation.h ${source_path}/implementations/ShadingLanguageIncludeImplementation_ShadingLanguageIncludeARB.cpp @@ -206,6 +236,11 @@ set(sources ${source_path}/implementations/TextureStorageMultisampleImplementation_Fallback.cpp ${source_path}/implementations/TextureStorageMultisampleImplementation_Fallback.h + ${source_path}/implementations/AbstractTransformFeedbackImplementation.cpp + ${source_path}/implementations/AbstractTransformFeedbackImplementation.h + ${source_path}/implementations/TransformFeedbackImplementation_Legacy.cpp + ${source_path}/implementations/TransformFeedbackImplementation_Legacy.h + ${source_path}/implementations/AbstractUniformImplementation.cpp ${source_path}/implementations/AbstractUniformImplementation.h ${source_path}/implementations/UniformImplementation_Legacy.cpp diff --git a/source/globjects/include/globjects/Framebuffer.h b/source/globjects/include/globjects/Framebuffer.h index ea30257c..f5b5d092 100644 --- a/source/globjects/include/globjects/Framebuffer.h +++ b/source/globjects/include/globjects/Framebuffer.h @@ -104,14 +104,6 @@ class GLOBJECTS_API Framebuffer : public Object, public Instantiator & rect, gl::GLenum format, gl::GLenum type, gl::GLvoid * data = nullptr) const; void readPixels(gl::GLenum readBuffer, const std::array & rect, gl::GLenum format, gl::GLenum type, gl::GLvoid * data = nullptr) const; diff --git a/source/globjects/include/globjects/Program.h b/source/globjects/include/globjects/Program.h index 57a2cc29..71cdab21 100644 --- a/source/globjects/include/globjects/Program.h +++ b/source/globjects/include/globjects/Program.h @@ -86,12 +86,18 @@ class GLOBJECTS_API Program : public Object, public Instantiator public: + enum class Implementation + { + Legacy + }; + enum class BinaryImplementation { None, GetProgramBinaryARB }; + static void hintImplementation(Implementation impl); static void hintBinaryImplementation(BinaryImplementation impl); @@ -128,6 +134,8 @@ class GLOBJECTS_API Program : public Object, public Instantiator template std::array get(gl::GLenum pname) const; + void get(gl::GLenum pname, std::size_t count, gl::GLint * values) const; + bool isValid() const; void validate(); diff --git a/source/globjects/include/globjects/Program.inl b/source/globjects/include/globjects/Program.inl index 61f21ade..af94ab4f 100644 --- a/source/globjects/include/globjects/Program.inl +++ b/source/globjects/include/globjects/Program.inl @@ -120,7 +120,7 @@ std::array Program::get(gl::GLenum pname) const { std::array values; - glGetProgramiv(id(), pname, values.data()); + get(pname, Count, values.data()); return values; } diff --git a/source/globjects/include/globjects/ProgramPipeline.h b/source/globjects/include/globjects/ProgramPipeline.h index 5ab0a27c..6c9ed9c6 100644 --- a/source/globjects/include/globjects/ProgramPipeline.h +++ b/source/globjects/include/globjects/ProgramPipeline.h @@ -21,6 +21,13 @@ class Program; class GLOBJECTS_API ProgramPipeline : public Object, public Instantiator { +public: + enum class Implementation + { + Legacy + }; + + public: ProgramPipeline(); virtual ~ProgramPipeline(); diff --git a/source/globjects/include/globjects/Query.h b/source/globjects/include/globjects/Query.h index d4f6d6c9..f11b4485 100644 --- a/source/globjects/include/globjects/Query.h +++ b/source/globjects/include/globjects/Query.h @@ -66,6 +66,13 @@ namespace globjects */ class GLOBJECTS_API Query : public Object, public Instantiator { +public: + enum class Implementation + { + Legacy + }; + + public: Query(); @@ -113,8 +120,6 @@ class GLOBJECTS_API Query : public Object, public Instantiator protected: Query(std::unique_ptr && resource); - static gl::GLuint genQuery(); - void counter(gl::GLenum target) const; }; diff --git a/source/globjects/include/globjects/Renderbuffer.h b/source/globjects/include/globjects/Renderbuffer.h index d4b4d62c..a65dd828 100644 --- a/source/globjects/include/globjects/Renderbuffer.h +++ b/source/globjects/include/globjects/Renderbuffer.h @@ -19,6 +19,13 @@ namespace globjects */ class GLOBJECTS_API Renderbuffer : public Object, public Instantiator { +public: + enum class Implementation + { + Legacy + }; + + public: Renderbuffer(); diff --git a/source/globjects/include/globjects/Sampler.h b/source/globjects/include/globjects/Sampler.h index e72df6c6..9b2a946a 100644 --- a/source/globjects/include/globjects/Sampler.h +++ b/source/globjects/include/globjects/Sampler.h @@ -21,6 +21,13 @@ namespace globjects */ class GLOBJECTS_API Sampler : public Object, public Instantiator { +public: + enum class Implementation + { + Legacy + }; + + public: Sampler(); diff --git a/source/globjects/include/globjects/Shader.h b/source/globjects/include/globjects/Shader.h index 5b709808..18bc5659 100644 --- a/source/globjects/include/globjects/Shader.h +++ b/source/globjects/include/globjects/Shader.h @@ -50,6 +50,11 @@ class GLOBJECTS_API Shader : public Object, public Instantiator public: + enum class Implementation + { + Legacy + }; + enum class IncludeImplementation { Fallback, diff --git a/source/globjects/include/globjects/TransformFeedback.h b/source/globjects/include/globjects/TransformFeedback.h index 8b03f491..be5b30dc 100644 --- a/source/globjects/include/globjects/TransformFeedback.h +++ b/source/globjects/include/globjects/TransformFeedback.h @@ -60,6 +60,13 @@ class Program; */ class GLOBJECTS_API TransformFeedback : public Object, public Instantiator { +public: + enum class Implementation + { + Legacy + }; + + public: TransformFeedback(); diff --git a/source/globjects/source/Buffer.cpp b/source/globjects/source/Buffer.cpp index dafd0e0f..50c64f1e 100644 --- a/source/globjects/source/Buffer.cpp +++ b/source/globjects/source/Buffer.cpp @@ -78,17 +78,17 @@ Buffer::~Buffer() void Buffer::bind(const GLenum target) const { - glBindBuffer(target, id()); + return implementation().bind(this, target); } void Buffer::unbind(const GLenum target) { - glBindBuffer(target, 0); + return implementation().unbind(target); } void Buffer::unbind(const GLenum target, const GLuint index) { - glBindBufferBase(target, index, 0); + return implementation().unbindBase(target, index); } const void * Buffer::map() const @@ -143,12 +143,12 @@ GLint64 Buffer::getParameter64(const GLenum pname) const void Buffer::bindBase(const GLenum target, const GLuint index) const { - glBindBufferBase(target, index, id()); + return implementation().bindBase(this, target, index); } void Buffer::bindRange(const GLenum target, const GLuint index, const GLintptr offset, const GLsizeiptr size) const { - glBindBufferRange(target, index, id(), offset, size); + return implementation().bindRange(this, target, index, offset, size); } void Buffer::copySubData(Buffer * buffer, const GLintptr readOffset, const GLintptr writeOffset, const GLsizeiptr size) const diff --git a/source/globjects/source/Framebuffer.cpp b/source/globjects/source/Framebuffer.cpp index 84467574..cda047dd 100644 --- a/source/globjects/source/Framebuffer.cpp +++ b/source/globjects/source/Framebuffer.cpp @@ -86,22 +86,22 @@ Framebuffer::~Framebuffer() void Framebuffer::bind() const { - glBindFramebuffer(GL_FRAMEBUFFER, id()); + implementation().bind(this); } void Framebuffer::bind(const GLenum target) const { - glBindFramebuffer(target, id()); + implementation().bind(this, target); } void Framebuffer::unbind() { - glBindFramebuffer(GL_FRAMEBUFFER, 0); + implementation().unbind(); } void Framebuffer::unbind(const GLenum target) { - glBindFramebuffer(target, 0); + implementation().unbind(target); } void Framebuffer::setParameter(const GLenum pname, const GLint param) @@ -239,41 +239,6 @@ void Framebuffer::clearBuffer(gl::GLenum buffer, gl::GLint drawBuffer, float val clearBuffer(buffer, drawBuffer, &value); } -void Framebuffer::colorMask(const GLboolean red, const GLboolean green, const GLboolean blue, const GLboolean alpha) -{ - glColorMask(red, green, blue, alpha); -} - -void Framebuffer::colorMask(const glm::bvec4 & mask) -{ - colorMask(static_cast(mask[0]), static_cast(mask[1]), static_cast(mask[2]), static_cast(mask[3])); -} - -void Framebuffer::colorMaski(const GLuint buffer, const GLboolean red, const GLboolean green, const GLboolean blue, const GLboolean alpha) -{ - glColorMaski(buffer, red, green, blue, alpha); -} - -void Framebuffer::colorMaski(const GLuint buffer, const glm::bvec4 & mask) -{ - colorMaski(buffer, static_cast(mask[0]), static_cast(mask[1]), static_cast(mask[2]), static_cast(mask[3])); -} - -void Framebuffer::clearColor(const GLfloat red, const GLfloat green, const GLfloat blue, const GLfloat alpha) -{ - glClearColor(red, green, blue, alpha); -} - -void Framebuffer::clearColor(const glm::vec4 & color) -{ - clearColor(color.r, color.g, color.b, color.a); -} - -void Framebuffer::clearDepth(const GLdouble depth) -{ - glClearDepth(depth); -} - void Framebuffer::readPixels(const GLint x, const GLint y, const GLsizei width, const GLsizei height, const GLenum format, const GLenum type, GLvoid * data) const { implementation().readPixels(this, x, y, width, height, format, type, data); diff --git a/source/globjects/source/IncludeProcessor.cpp b/source/globjects/source/IncludeProcessor.cpp index 1d194886..202a259c 100644 --- a/source/globjects/source/IncludeProcessor.cpp +++ b/source/globjects/source/IncludeProcessor.cpp @@ -21,9 +21,9 @@ namespace // From http://stackoverflow.com/questions/216823/whats-the-best-way-to-trim-stdstring inline std::string trim(const std::string &s) { - auto wsfront=std::find_if_not(s.begin(),s.end(),[](int c){return std::isspace(c);}); - auto wsback=std::find_if_not(s.rbegin(),s.rend(),[](int c){return std::isspace(c);}).base(); - return (wsback<=wsfront ? std::string() : std::string(wsfront,wsback)); + auto wsfront=std::find_if_not(s.begin(),s.end(),[](int c){return std::isspace(c);}); + auto wsback=std::find_if_not(s.rbegin(),s.rend(),[](int c){return std::isspace(c);}).base(); + return (wsback<=wsfront ? std::string() : std::string(wsfront,wsback)); } inline bool contains(const std::string& string, const std::string& search) diff --git a/source/globjects/source/Program.cpp b/source/globjects/source/Program.cpp index 703982d7..25e62a1c 100644 --- a/source/globjects/source/Program.cpp +++ b/source/globjects/source/Program.cpp @@ -31,6 +31,11 @@ namespace { +const globjects::AbstractProgramImplementation & implementation() +{ + return globjects::ImplementationRegistry::current().programImplementation(); +} + const globjects::AbstractProgramBinaryImplementation & binaryImplementation() { return globjects::ImplementationRegistry::current().programBinaryImplementation(); @@ -44,6 +49,11 @@ namespace globjects { +void Program::hintImplementation(const Implementation impl) +{ + ImplementationRegistry::current().initialize(impl); +} + void Program::hintBinaryImplementation(const BinaryImplementation impl) { ImplementationRegistry::current().initialize(impl); @@ -593,6 +603,11 @@ GLint Program::get(const GLenum pname) const return value; } +void Program::get(gl::GLenum pname, std::size_t /*count*/, gl::GLint * values) const +{ + glGetProgramiv(id(), pname, values); +} + void Program::getActiveAttrib(gl::GLuint index, gl::GLsizei bufSize, gl::GLsizei * length, gl::GLint * size, gl::GLenum * type, gl::GLchar * name) const { checkDirty(); diff --git a/source/globjects/source/ProgramPipeline.cpp b/source/globjects/source/ProgramPipeline.cpp index 9b0c53ce..2d371a43 100644 --- a/source/globjects/source/ProgramPipeline.cpp +++ b/source/globjects/source/ProgramPipeline.cpp @@ -11,6 +11,22 @@ #include #include +#include "registry/ImplementationRegistry.h" +#include "implementations/AbstractProgramPipelineImplementation.h" + + +namespace +{ + + +globjects::AbstractProgramPipelineImplementation & implementation() +{ + return globjects::ImplementationRegistry::current().programPipelineImplementation(); +} + + +} // namespace + namespace globjects { @@ -96,13 +112,13 @@ void ProgramPipeline::use() const checkUseStatus(); } - gl::glUseProgram(0); - gl::glBindProgramPipeline(id()); + Program::release(); + implementation().use(this); } void ProgramPipeline::release() { - gl::glBindProgramPipeline(0); + implementation().release(); } void ProgramPipeline::useStages(Program * program, gl::UseProgramStageMask stages) @@ -114,14 +130,14 @@ void ProgramPipeline::useStages(Program * program, gl::UseProgramStageMask stage program->link(); - gl::glUseProgramStages(id(), stages, program->id()); + implementation().useStages(this, program, stages); invalidate(); } void ProgramPipeline::releaseStages(gl::UseProgramStageMask stages) { - gl::glUseProgramStages(id(), stages, 0); + implementation().releaseStages(this, stages); invalidate(); } @@ -141,7 +157,7 @@ bool ProgramPipeline::isValid() const void ProgramPipeline::validate() const { - gl::glValidateProgramPipeline(id()); + implementation().validate(this); } void ProgramPipeline::invalidate() @@ -165,26 +181,12 @@ bool ProgramPipeline::checkUseStatus() const gl::GLint ProgramPipeline::get(const gl::GLenum pname) const { - gl::GLint value = 0; - gl::glGetProgramPipelineiv(id(), pname, &value); - - return value; + return implementation().getInt(this, pname); } std::string ProgramPipeline::infoLog() const { - gl::GLint length = get(gl::GL_INFO_LOG_LENGTH); - - if (length == 0) - { - return std::string(); - } - - std::vector log(length); - - gl::glGetProgramPipelineInfoLog(id(), length, &length, log.data()); - - return std::string(log.data(), length); + return implementation().getInfoLog(this); } gl::GLenum ProgramPipeline::objectType() const diff --git a/source/globjects/source/Query.cpp b/source/globjects/source/Query.cpp index 8f2aa28e..e8d14731 100644 --- a/source/globjects/source/Query.cpp +++ b/source/globjects/source/Query.cpp @@ -73,15 +73,6 @@ int Query::getCounterBits(const GLenum target) return get(target, GL_QUERY_COUNTER_BITS); } -GLuint Query::genQuery() -{ - GLuint id; - - glGenQueries(1, &id); - - return id; -} - GLint Query::get(const GLenum target, const GLenum pname) { GLint value = 0; @@ -209,7 +200,7 @@ void Query::counter(const GLenum target) const bool Query::isQuery(const GLuint id) { - return glIsQuery(id) == GL_TRUE; + return glIsQuery(id) == gl::GL_TRUE; } GLenum Query::objectType() const diff --git a/source/globjects/source/Renderbuffer.cpp b/source/globjects/source/Renderbuffer.cpp index fa98c88d..5ff3a606 100644 --- a/source/globjects/source/Renderbuffer.cpp +++ b/source/globjects/source/Renderbuffer.cpp @@ -7,10 +7,26 @@ #include #include +#include "registry/ImplementationRegistry.h" +#include "implementations/AbstractRenderbufferImplementation.h" + using namespace gl; +namespace +{ + + +globjects::AbstractRenderbufferImplementation & implementation() +{ + return globjects::ImplementationRegistry::current().renderbufferImplementation(); +} + + +} // namespace + + namespace globjects { @@ -48,37 +64,27 @@ void Renderbuffer::unbind() void Renderbuffer::bind(const GLenum target) const { - glBindRenderbuffer(target, id()); + implementation().bind(this, target); } void Renderbuffer::unbind(const GLenum target) { - glBindRenderbuffer(target, 0); + implementation().unbind(target); } void Renderbuffer::storage(const GLenum internalformat, const GLsizei width, const GLsizei height) { - bind(GL_RENDERBUFFER); - - glRenderbufferStorage(GL_RENDERBUFFER, internalformat, width, height); + implementation().storage(this, internalformat, width, height); } void Renderbuffer::storageMultisample(const GLsizei samples, const GLenum internalformat, const GLsizei width, const GLsizei height) { - bind(GL_RENDERBUFFER); - - glRenderbufferStorageMultisample(GL_RENDERBUFFER, samples, internalformat, width, height); + implementation().storageMultisample(this, samples, internalformat, width, height); } GLint Renderbuffer::getParameter(const GLenum pname) const { - GLint value = 0; - - bind(GL_RENDERBUFFER); - - glGetRenderbufferParameteriv(GL_RENDERBUFFER, pname, &value); - - return value; + return implementation().getParameterInt(this, pname); } GLenum Renderbuffer::objectType() const diff --git a/source/globjects/source/Resource.cpp b/source/globjects/source/Resource.cpp index 94483352..1c60e604 100644 --- a/source/globjects/source/Resource.cpp +++ b/source/globjects/source/Resource.cpp @@ -6,38 +6,21 @@ #include "registry/ImplementationRegistry.h" #include "implementations/AbstractBufferImplementation.h" +#include "implementations/AbstractProgramImplementation.h" +#include "implementations/AbstractProgramPipelineImplementation.h" #include "implementations/AbstractFramebufferImplementation.h" #include "implementations/AbstractTextureImplementation.h" +#include "implementations/AbstractQueryImplementation.h" +#include "implementations/AbstractRenderbufferImplementation.h" +#include "implementations/AbstractSamplerImplementation.h" +#include "implementations/AbstractShaderImplementation.h" +#include "implementations/AbstractTransformFeedbackImplementation.h" +#include "implementations/AbstractVertexAttributeBindingImplementation.h" using namespace gl; -namespace -{ - - -template -GLuint createObject(CreateObjectsFunction function) -{ - GLuint id; - function(1, &id); - return id; -} - -template -void deleteObject(DeleteObjectsFunction function, const GLuint id, const bool hasOwnership) -{ - if (!hasOwnership) - { - return; - } - - function(1, &id); -} - -} - namespace globjects { @@ -118,7 +101,9 @@ BufferResource::BufferResource() BufferResource::~BufferResource() { if (hasOwnership()) + { ImplementationRegistry::current().bufferImplementation().destroy(id()); + } } @@ -130,12 +115,14 @@ FrameBufferObjectResource::FrameBufferObjectResource() FrameBufferObjectResource::~FrameBufferObjectResource() { if (hasOwnership()) + { ImplementationRegistry::current().framebufferImplementation().destroy(id()); + } } ProgramResource::ProgramResource() -: IDResource(glCreateProgram()) + : IDResource(ImplementationRegistry::current().programImplementation().create()) { } @@ -143,56 +130,69 @@ ProgramResource::~ProgramResource() { if (hasOwnership()) { - glDeleteProgram(id()); + ImplementationRegistry::current().programImplementation().destroy(id()); } } ProgramPipelineResource::ProgramPipelineResource() -: IDResource(createObject(glGenProgramPipelines)) +: IDResource(ImplementationRegistry::current().programPipelineImplementation().create()) { } ProgramPipelineResource::~ProgramPipelineResource() { - deleteObject(glDeleteProgramPipelines, id(), hasOwnership()); + if (hasOwnership()) + { + ImplementationRegistry::current().programPipelineImplementation().destroy(id()); + } } QueryResource::QueryResource() -: IDResource(createObject(glGenQueries)) +: IDResource(ImplementationRegistry::current().queryImplementation().create()) { } QueryResource::~QueryResource() { - deleteObject(glDeleteQueries, id(), hasOwnership()); + if (hasOwnership()) + { + ImplementationRegistry::current().queryImplementation().destroy(id()); + } } RenderBufferObjectResource::RenderBufferObjectResource() -: IDResource(createObject(glGenRenderbuffers)) +: IDResource(ImplementationRegistry::current().renderbufferImplementation().create()) { } RenderBufferObjectResource::~RenderBufferObjectResource() { - deleteObject(glDeleteRenderbuffers, id(), hasOwnership()); + if (hasOwnership()) + { + ImplementationRegistry::current().renderbufferImplementation().destroy(id()); + } } SamplerResource::SamplerResource() -: IDResource(createObject(glGenSamplers)) +: IDResource(ImplementationRegistry::current().samplerImplementation().create()) { } SamplerResource::~SamplerResource() { - deleteObject(glDeleteSamplers, id(), hasOwnership()); + if (hasOwnership()) + { + ImplementationRegistry::current().samplerImplementation().destroy(id()); + } } + ShaderResource::ShaderResource(GLenum type) -: IDResource(glCreateShader(type)) +: IDResource(ImplementationRegistry::current().shaderImplementation().create(type)) { } @@ -200,7 +200,7 @@ ShaderResource::~ShaderResource() { if (hasOwnership()) { - glDeleteShader(id()); + ImplementationRegistry::current().shaderImplementation().destroy(id()); } } @@ -220,24 +220,30 @@ TextureResource::~TextureResource() TransformFeedbackResource::TransformFeedbackResource() -: IDResource(createObject(glGenTransformFeedbacks)) +: IDResource(ImplementationRegistry::current().transformfeedbackImplementation().create()) { } TransformFeedbackResource::~TransformFeedbackResource() { - deleteObject(glDeleteTransformFeedbacks, id(), hasOwnership()); + if (hasOwnership()) + { + ImplementationRegistry::current().transformfeedbackImplementation().destroy(id()); + } } VertexArrayObjectResource::VertexArrayObjectResource() -: IDResource(createObject(glGenVertexArrays)) +: IDResource(ImplementationRegistry::current().attributeImplementation().create()) { } VertexArrayObjectResource::~VertexArrayObjectResource() { - deleteObject(glDeleteVertexArrays, id(), hasOwnership()); + if (hasOwnership()) + { + ImplementationRegistry::current().attributeImplementation().destroy(id()); + } } diff --git a/source/globjects/source/VertexArray.cpp b/source/globjects/source/VertexArray.cpp index e3c32319..a4a55043 100644 --- a/source/globjects/source/VertexArray.cpp +++ b/source/globjects/source/VertexArray.cpp @@ -80,12 +80,12 @@ VertexArray::~VertexArray() void VertexArray::bind() const { - glBindVertexArray(id()); + implementation().bind(this); } void VertexArray::unbind() { - glBindVertexArray(0); + implementation().unbind(); } VertexAttributeBinding * VertexArray::binding(const GLuint bindingIndex) @@ -155,106 +155,88 @@ std::vector VertexArray::bindings() const void VertexArray::drawArrays(const GLenum mode, const GLint first, const GLsizei count) const { - bind(); - glDrawArrays(mode, first, count); + implementation().drawArrays(this, mode, first, count); } void VertexArray::drawArraysInstanced(const GLenum mode, const GLint first, const GLsizei count, const GLsizei instanceCount) const { - bind(); - glDrawArraysInstanced(mode, first, count, instanceCount); + implementation().drawArraysInstanced(this, mode, first, count, instanceCount); } void VertexArray::drawArraysInstancedBaseInstance(const GLenum mode, const GLint first, const GLsizei count, const GLsizei instanceCount, const GLuint baseInstance) const { - bind(); - glDrawArraysInstancedBaseInstance(mode, first, count, instanceCount, baseInstance); + implementation().drawArraysInstancedBaseInstance(this, mode, first, count, instanceCount, baseInstance); } void VertexArray::drawArraysIndirect(const GLenum mode, const void* indirect) const { // Don't assert a non-null indirect pointer as it may be a zero offset into the indirection buffer in GPU memory - - bind(); - glDrawArraysIndirect(mode, indirect); + implementation().drawArraysIndirect(this, mode, indirect); } void VertexArray::multiDrawArrays(const GLenum mode, GLint* first, const GLsizei* count, const GLsizei drawCount) const { - bind(); - glMultiDrawArrays(mode, first, count, drawCount); + implementation().multiDrawArrays(this, mode, first, count, drawCount); } void VertexArray::multiDrawArraysIndirect(const GLenum mode, const void* indirect, const GLsizei drawCount, const GLsizei stride) const { - bind(); - glMultiDrawArraysIndirect(mode, indirect, drawCount, stride); + implementation().multiDrawArraysIndirect(this, mode, indirect, drawCount, stride); } void VertexArray::drawElements(const GLenum mode, const GLsizei count, const GLenum type, const void * indices) const { - bind(); - glDrawElements(mode, count, type, indices); + implementation().drawElements(this, mode, count, type, indices); } void VertexArray::drawElementsBaseVertex(const GLenum mode, const GLsizei count, const GLenum type, const void* indices, const GLint baseVertex) const { - bind(); - glDrawElementsBaseVertex(mode, count, type, const_cast(indices), baseVertex); + implementation().drawElementsBaseVertex(this, mode, count, type, indices, baseVertex); } void VertexArray::drawElementsInstanced(const GLenum mode, const GLsizei count, const GLenum type, const void* indices, const GLsizei primitiveCount) const { - bind(); - glDrawElementsInstanced(mode, count, type, indices, primitiveCount); + implementation().drawElementsInstanced(this, mode, count, type, indices, primitiveCount); } void VertexArray::drawElementsInstancedBaseInstance(const GLenum mode, const GLsizei count, const GLenum type, const void* indices, const GLsizei instanceCount, const GLuint baseInstance) const { - bind(); - glDrawElementsInstancedBaseInstance(mode, count, type, indices, instanceCount, baseInstance); + implementation().drawElementsInstancedBaseInstance(this, mode, count, type, indices, instanceCount, baseInstance); } void VertexArray::drawElementsInstancedBaseVertex(const GLenum mode, const GLsizei count, const GLenum type, const void* indices, const GLsizei instanceCount, const GLint baseVertex) const { - bind(); - glDrawElementsInstancedBaseVertex(mode, count, type, indices, instanceCount, baseVertex); + implementation().drawElementsInstancedBaseVertex(this, mode, count, type, indices, instanceCount, baseVertex); } void VertexArray::drawElementsInstancedBaseVertexBaseInstance(const GLenum mode, const GLsizei count, const GLenum type, const void* indices, const GLsizei instanceCount, const GLint baseVertex, const GLuint baseInstance) const { - bind(); - glDrawElementsInstancedBaseVertexBaseInstance(mode, count, type, indices, instanceCount, baseVertex, baseInstance); + implementation().drawElementsInstancedBaseVertexBaseInstance(this, mode, count, type, indices, instanceCount, baseVertex, baseInstance); } void VertexArray::multiDrawElements(const GLenum mode, const GLsizei* count, const GLenum type, const void** indices, const GLsizei drawCount) const { - bind(); - glMultiDrawElements(mode, count, type, indices, drawCount); + implementation().multiDrawElements(this, mode, count, type, indices, drawCount); } void VertexArray::multiDrawElementsBaseVertex(const GLenum mode, const GLsizei* count, const GLenum type, const void** indices, const GLsizei drawCount, GLint* baseVertex) const { - bind(); - glMultiDrawElementsBaseVertex(mode, const_cast(count), type, const_cast(indices), drawCount, baseVertex); + implementation().multiDrawElementsBaseVertex(this, mode, count, type, indices, drawCount, baseVertex); } void VertexArray::multiDrawElementsIndirect(const GLenum mode, const GLenum type, const void* indirect, const GLsizei drawCount, const GLsizei stride) const { - bind(); - glMultiDrawElementsIndirect(mode, type, indirect, drawCount, stride); + implementation().multiDrawElementsIndirect(this, mode, type, indirect, drawCount, stride); } void VertexArray::drawRangeElements(const GLenum mode, const GLuint start, const GLuint end, const GLsizei count, const GLenum type, const void* indices) const { - bind(); - glDrawRangeElements(mode, start, end, count, type, indices); + implementation().drawRangeElements(this, mode, start, end, count, type, indices); } void VertexArray::drawRangeElementsBaseVertex(const GLenum mode, const GLuint start, const GLuint end, const GLsizei count, const GLenum type, const void* indices, const GLint baseVertex) const { - bind(); - glDrawRangeElementsBaseVertex(mode, start, end, count, type, const_cast(indices), baseVertex); + implementation().drawRangeElementsBaseVertex(this, mode, start, end, count, type, indices, baseVertex); } void VertexArray::multiDrawArrays(const GLenum mode, const std::vector & ranges) const diff --git a/source/globjects/source/implementations/AbstractBufferImplementation.h b/source/globjects/source/implementations/AbstractBufferImplementation.h index cb7a6efb..e90466cd 100644 --- a/source/globjects/source/implementations/AbstractBufferImplementation.h +++ b/source/globjects/source/implementations/AbstractBufferImplementation.h @@ -26,6 +26,13 @@ class AbstractBufferImplementation virtual gl::GLuint create() const = 0; virtual void destroy(gl::GLuint id) const = 0; + virtual void bind(const Buffer * buffer, gl::GLenum target) const = 0; + virtual void unbind(gl::GLenum target) const = 0; + virtual void bindBase(const Buffer * buffer, gl::GLenum target, const gl::GLuint index) const = 0; + virtual void unbindBase(gl::GLenum target, const gl::GLuint index) const = 0; + + virtual void bindRange(const Buffer * buffer, gl::GLenum target, gl::GLuint index, gl::GLintptr offset, gl::GLsizeiptr size) const = 0; + virtual void * map(const Buffer * buffer, gl::GLenum access) const = 0; virtual void * mapRange(const Buffer * buffer, gl::GLintptr offset, gl::GLsizeiptr length, gl::MapBufferAccessMask access) const = 0; virtual bool unmap(const Buffer * buffer) const = 0; diff --git a/source/globjects/source/implementations/AbstractFramebufferImplementation.h b/source/globjects/source/implementations/AbstractFramebufferImplementation.h index f04375ab..049f2fc4 100644 --- a/source/globjects/source/implementations/AbstractFramebufferImplementation.h +++ b/source/globjects/source/implementations/AbstractFramebufferImplementation.h @@ -29,6 +29,11 @@ class AbstractFramebufferImplementation virtual gl::GLuint create() const = 0; virtual void destroy(gl::GLuint id) const = 0; + virtual void bind(const Framebuffer * fbo) const = 0; + virtual void bind(const Framebuffer * fbo, gl::GLenum target) const = 0; + virtual void unbind() const = 0; + virtual void unbind(gl::GLenum target) const = 0; + virtual gl::GLenum checkStatus(const Framebuffer * fbo) const = 0; virtual void setParameter(const Framebuffer * fbo, gl::GLenum pname, gl::GLint param) const = 0; virtual gl::GLint getAttachmentParameter(const Framebuffer * fbo, gl::GLenum attachment, gl::GLenum pname) const = 0; diff --git a/source/globjects/source/implementations/AbstractProgramImplementation.cpp b/source/globjects/source/implementations/AbstractProgramImplementation.cpp new file mode 100644 index 00000000..906e1260 --- /dev/null +++ b/source/globjects/source/implementations/AbstractProgramImplementation.cpp @@ -0,0 +1,31 @@ + +#include "AbstractProgramImplementation.h" + +#include +#include + +#include "ProgramImplementation_Legacy.h" + + +using namespace gl; + + +namespace globjects +{ + + +AbstractProgramImplementation::AbstractProgramImplementation() +{ +} + +AbstractProgramImplementation::~AbstractProgramImplementation() +{ +} + +AbstractProgramImplementation * AbstractProgramImplementation::get(const Program::Implementation /*impl*/) +{ + return ProgramImplementation_Legacy::instance(); +} + + +} // namespace globjects diff --git a/source/globjects/source/implementations/AbstractProgramImplementation.h b/source/globjects/source/implementations/AbstractProgramImplementation.h new file mode 100644 index 00000000..d557eda7 --- /dev/null +++ b/source/globjects/source/implementations/AbstractProgramImplementation.h @@ -0,0 +1,30 @@ + +#pragma once + + +#include + +#include + +#include + + +namespace globjects +{ + + +class AbstractProgramImplementation +{ +public: + AbstractProgramImplementation(); + virtual ~AbstractProgramImplementation(); + + static AbstractProgramImplementation * get(Program::Implementation impl = + Program::Implementation::Legacy); + + virtual gl::GLuint create() const = 0; + virtual void destroy(gl::GLuint id) const = 0; +}; + + +} // namespace globjects diff --git a/source/globjects/source/implementations/AbstractProgramPipelineImplementation.cpp b/source/globjects/source/implementations/AbstractProgramPipelineImplementation.cpp new file mode 100644 index 00000000..fd99372f --- /dev/null +++ b/source/globjects/source/implementations/AbstractProgramPipelineImplementation.cpp @@ -0,0 +1,31 @@ + +#include "AbstractProgramPipelineImplementation.h" + +#include +#include + +#include "ProgramPipelineImplementation_Legacy.h" + + +using namespace gl; + + +namespace globjects +{ + + +AbstractProgramPipelineImplementation::AbstractProgramPipelineImplementation() +{ +} + +AbstractProgramPipelineImplementation::~AbstractProgramPipelineImplementation() +{ +} + +AbstractProgramPipelineImplementation * AbstractProgramPipelineImplementation::get(const ProgramPipeline::Implementation /*impl*/) +{ + return ProgramPipelineImplementation_Legacy::instance(); +} + + +} // namespace globjects diff --git a/source/globjects/source/implementations/AbstractProgramPipelineImplementation.h b/source/globjects/source/implementations/AbstractProgramPipelineImplementation.h new file mode 100644 index 00000000..0af9aad1 --- /dev/null +++ b/source/globjects/source/implementations/AbstractProgramPipelineImplementation.h @@ -0,0 +1,38 @@ + +#pragma once + + +#include + +#include + +#include + + +namespace globjects +{ + + +class AbstractProgramPipelineImplementation +{ +public: + AbstractProgramPipelineImplementation(); + virtual ~AbstractProgramPipelineImplementation(); + + static AbstractProgramPipelineImplementation * get(ProgramPipeline::Implementation impl = + ProgramPipeline::Implementation::Legacy); + + virtual gl::GLuint create() const = 0; + virtual void destroy(gl::GLuint id) const = 0; + + virtual void use(const ProgramPipeline * pipeline) const = 0; + virtual void release() const = 0; + virtual void useStages(const ProgramPipeline * pipeline, const Program * program, gl::UseProgramStageMask stages) const = 0; + virtual void releaseStages(const ProgramPipeline * pipeline, gl::UseProgramStageMask stages) const = 0; + virtual void validate(const ProgramPipeline * pipeline) const = 0; + virtual gl::GLint getInt(const ProgramPipeline * pipeline, gl::GLenum pname) const = 0; + virtual std::string getInfoLog(const ProgramPipeline * pipeline) const = 0; +}; + + +} // namespace globjects diff --git a/source/globjects/source/implementations/AbstractQueryImplementation.cpp b/source/globjects/source/implementations/AbstractQueryImplementation.cpp new file mode 100644 index 00000000..e1c4eee5 --- /dev/null +++ b/source/globjects/source/implementations/AbstractQueryImplementation.cpp @@ -0,0 +1,31 @@ + +#include "AbstractQueryImplementation.h" + +#include +#include + +#include "QueryImplementation_Legacy.h" + + +using namespace gl; + + +namespace globjects +{ + + +AbstractQueryImplementation::AbstractQueryImplementation() +{ +} + +AbstractQueryImplementation::~AbstractQueryImplementation() +{ +} + +AbstractQueryImplementation * AbstractQueryImplementation::get(const Query::Implementation /*impl*/) +{ + return QueryImplementation_Legacy::instance(); +} + + +} // namespace globjects diff --git a/source/globjects/source/implementations/AbstractQueryImplementation.h b/source/globjects/source/implementations/AbstractQueryImplementation.h new file mode 100644 index 00000000..f6123dc3 --- /dev/null +++ b/source/globjects/source/implementations/AbstractQueryImplementation.h @@ -0,0 +1,30 @@ + +#pragma once + + +#include + +#include + +#include + + +namespace globjects +{ + + +class AbstractQueryImplementation +{ +public: + AbstractQueryImplementation(); + virtual ~AbstractQueryImplementation(); + + static AbstractQueryImplementation * get(Query::Implementation impl = + Query::Implementation::Legacy); + + virtual gl::GLuint create() const = 0; + virtual void destroy(gl::GLuint id) const = 0; +}; + + +} // namespace globjects diff --git a/source/globjects/source/implementations/AbstractRenderbufferImplementation.cpp b/source/globjects/source/implementations/AbstractRenderbufferImplementation.cpp new file mode 100644 index 00000000..5cdc49b1 --- /dev/null +++ b/source/globjects/source/implementations/AbstractRenderbufferImplementation.cpp @@ -0,0 +1,31 @@ + +#include "AbstractRenderbufferImplementation.h" + +#include +#include + +#include "RenderbufferImplementation_Legacy.h" + + +using namespace gl; + + +namespace globjects +{ + + +AbstractRenderbufferImplementation::AbstractRenderbufferImplementation() +{ +} + +AbstractRenderbufferImplementation::~AbstractRenderbufferImplementation() +{ +} + +AbstractRenderbufferImplementation * AbstractRenderbufferImplementation::get(const Renderbuffer::Implementation /*impl*/) +{ + return RenderbufferImplementation_Legacy::instance(); +} + + +} // namespace globjects diff --git a/source/globjects/source/implementations/AbstractRenderbufferImplementation.h b/source/globjects/source/implementations/AbstractRenderbufferImplementation.h new file mode 100644 index 00000000..7cca100d --- /dev/null +++ b/source/globjects/source/implementations/AbstractRenderbufferImplementation.h @@ -0,0 +1,36 @@ + +#pragma once + + +#include + +#include + +#include + + +namespace globjects +{ + + +class AbstractRenderbufferImplementation +{ +public: + AbstractRenderbufferImplementation(); + virtual ~AbstractRenderbufferImplementation(); + + static AbstractRenderbufferImplementation * get(Renderbuffer::Implementation impl = + Renderbuffer::Implementation::Legacy); + + virtual gl::GLuint create() const = 0; + virtual void destroy(gl::GLuint id) const = 0; + + virtual void bind(const Renderbuffer * renderbuffer, gl::GLenum target) const = 0; + virtual void unbind(gl::GLenum target) const = 0; + virtual void storage(const Renderbuffer * renderbuffer, gl::GLenum internalformat, gl::GLsizei width, gl::GLsizei height) const = 0; + virtual void storageMultisample(const Renderbuffer * renderbuffer, gl::GLsizei samples, gl::GLenum internalformat, gl::GLsizei width, const gl::GLsizei height) const = 0; + virtual gl::GLint getParameterInt(const Renderbuffer * renderbuffer, gl::GLenum pname) const = 0; +}; + + +} // namespace globjects diff --git a/source/globjects/source/implementations/AbstractSamplerImplementation.cpp b/source/globjects/source/implementations/AbstractSamplerImplementation.cpp new file mode 100644 index 00000000..f3d6847e --- /dev/null +++ b/source/globjects/source/implementations/AbstractSamplerImplementation.cpp @@ -0,0 +1,31 @@ + +#include "AbstractSamplerImplementation.h" + +#include +#include + +#include "SamplerImplementation_Legacy.h" + + +using namespace gl; + + +namespace globjects +{ + + +AbstractSamplerImplementation::AbstractSamplerImplementation() +{ +} + +AbstractSamplerImplementation::~AbstractSamplerImplementation() +{ +} + +AbstractSamplerImplementation * AbstractSamplerImplementation::get(const Sampler::Implementation /*impl*/) +{ + return SamplerImplementation_Legacy::instance(); +} + + +} // namespace globjects diff --git a/source/globjects/source/implementations/AbstractSamplerImplementation.h b/source/globjects/source/implementations/AbstractSamplerImplementation.h new file mode 100644 index 00000000..8fe43bb3 --- /dev/null +++ b/source/globjects/source/implementations/AbstractSamplerImplementation.h @@ -0,0 +1,30 @@ + +#pragma once + + +#include + +#include + +#include + + +namespace globjects +{ + + +class AbstractSamplerImplementation +{ +public: + AbstractSamplerImplementation(); + virtual ~AbstractSamplerImplementation(); + + static AbstractSamplerImplementation * get(Sampler::Implementation impl = + Sampler::Implementation::Legacy); + + virtual gl::GLuint create() const = 0; + virtual void destroy(gl::GLuint id) const = 0; +}; + + +} // namespace globjects diff --git a/source/globjects/source/implementations/AbstractShaderImplementation.cpp b/source/globjects/source/implementations/AbstractShaderImplementation.cpp new file mode 100644 index 00000000..1fcf3fae --- /dev/null +++ b/source/globjects/source/implementations/AbstractShaderImplementation.cpp @@ -0,0 +1,31 @@ + +#include "AbstractShaderImplementation.h" + +#include +#include + +#include "ShaderImplementation_Legacy.h" + + +using namespace gl; + + +namespace globjects +{ + + +AbstractShaderImplementation::AbstractShaderImplementation() +{ +} + +AbstractShaderImplementation::~AbstractShaderImplementation() +{ +} + +AbstractShaderImplementation * AbstractShaderImplementation::get(const Shader::Implementation /*impl*/) +{ + return ShaderImplementation_Legacy::instance(); +} + + +} // namespace globjects diff --git a/source/globjects/source/implementations/AbstractShaderImplementation.h b/source/globjects/source/implementations/AbstractShaderImplementation.h new file mode 100644 index 00000000..96b07380 --- /dev/null +++ b/source/globjects/source/implementations/AbstractShaderImplementation.h @@ -0,0 +1,30 @@ + +#pragma once + + +#include + +#include + +#include + + +namespace globjects +{ + + +class AbstractShaderImplementation +{ +public: + AbstractShaderImplementation(); + virtual ~AbstractShaderImplementation(); + + static AbstractShaderImplementation * get(Shader::Implementation impl = + Shader::Implementation::Legacy); + + virtual gl::GLuint create(gl::GLenum type) const = 0; + virtual void destroy(gl::GLuint id) const = 0; +}; + + +} // namespace globjects diff --git a/source/globjects/source/implementations/AbstractTransformFeedbackImplementation.cpp b/source/globjects/source/implementations/AbstractTransformFeedbackImplementation.cpp new file mode 100644 index 00000000..619de359 --- /dev/null +++ b/source/globjects/source/implementations/AbstractTransformFeedbackImplementation.cpp @@ -0,0 +1,31 @@ + +#include "AbstractTransformFeedbackImplementation.h" + +#include +#include + +#include "TransformFeedbackImplementation_Legacy.h" + + +using namespace gl; + + +namespace globjects +{ + + +AbstractTransformFeedbackImplementation::AbstractTransformFeedbackImplementation() +{ +} + +AbstractTransformFeedbackImplementation::~AbstractTransformFeedbackImplementation() +{ +} + +AbstractTransformFeedbackImplementation * AbstractTransformFeedbackImplementation::get(const TransformFeedback::Implementation /*impl*/) +{ + return TransformFeedbackImplementation_Legacy::instance(); +} + + +} // namespace globjects diff --git a/source/globjects/source/implementations/AbstractTransformFeedbackImplementation.h b/source/globjects/source/implementations/AbstractTransformFeedbackImplementation.h new file mode 100644 index 00000000..704ec4c3 --- /dev/null +++ b/source/globjects/source/implementations/AbstractTransformFeedbackImplementation.h @@ -0,0 +1,30 @@ + +#pragma once + + +#include + +#include + +#include + + +namespace globjects +{ + + +class AbstractTransformFeedbackImplementation +{ +public: + AbstractTransformFeedbackImplementation(); + virtual ~AbstractTransformFeedbackImplementation(); + + static AbstractTransformFeedbackImplementation * get(TransformFeedback::Implementation impl = + TransformFeedback::Implementation::Legacy); + + virtual gl::GLuint create() const = 0; + virtual void destroy(gl::GLuint id) const = 0; +}; + + +} // namespace globjects diff --git a/source/globjects/source/implementations/AbstractVertexAttributeBindingImplementation.cpp b/source/globjects/source/implementations/AbstractVertexAttributeBindingImplementation.cpp index e103c7b7..ccb2448b 100644 --- a/source/globjects/source/implementations/AbstractVertexAttributeBindingImplementation.cpp +++ b/source/globjects/source/implementations/AbstractVertexAttributeBindingImplementation.cpp @@ -71,5 +71,117 @@ void * & AbstractVertexAttributeBindingImplementation::bindingData(const VertexA return binding->m_bindingData; } +void AbstractVertexAttributeBindingImplementation::bind(const VertexArray * vertexArray) const +{ + glBindVertexArray(vertexArray->id()); +} + +void AbstractVertexAttributeBindingImplementation::unbind() const +{ + glBindVertexArray(0); +} + +void AbstractVertexAttributeBindingImplementation::drawArrays(const VertexArray * vertexArray, gl::GLenum mode, gl::GLint first, gl::GLsizei count) const +{ + bind(vertexArray); + glDrawArrays(mode, first, count); +} + +void AbstractVertexAttributeBindingImplementation::drawArraysInstanced(const VertexArray * vertexArray, gl::GLenum mode, gl::GLint first, gl::GLsizei count, gl::GLsizei instanceCount) const +{ + bind(vertexArray); + glDrawArraysInstanced(mode, first, count, instanceCount); +} + +void AbstractVertexAttributeBindingImplementation::drawArraysInstancedBaseInstance(const VertexArray * vertexArray, gl::GLenum mode, gl::GLint first, gl::GLsizei count, gl::GLsizei instanceCount, gl::GLuint baseInstance) const +{ + bind(vertexArray); + glDrawArraysInstancedBaseInstance(mode, first, count, instanceCount, baseInstance); +} + +void AbstractVertexAttributeBindingImplementation::drawArraysIndirect(const VertexArray * vertexArray, gl::GLenum mode, const void * indirect) const +{ + bind(vertexArray); + glDrawArraysIndirect(mode, indirect); +} + +void AbstractVertexAttributeBindingImplementation::multiDrawArrays(const VertexArray * vertexArray, gl::GLenum mode, gl::GLint * first, const gl::GLsizei * count, gl::GLsizei drawCount) const +{ + bind(vertexArray); + glMultiDrawArrays(mode, first, count, drawCount); +} + +void AbstractVertexAttributeBindingImplementation::multiDrawArraysIndirect(const VertexArray * vertexArray, gl::GLenum mode, const void * indirect, gl::GLsizei drawCount, gl::GLsizei stride) const +{ + bind(vertexArray); + glMultiDrawArraysIndirect(mode, indirect, drawCount, stride); +} + +void AbstractVertexAttributeBindingImplementation::drawElements(const VertexArray * vertexArray, gl::GLenum mode, gl::GLsizei count, gl::GLenum type, const void * indices) const +{ + bind(vertexArray); + glDrawElements(mode, count, type, indices); +} + +void AbstractVertexAttributeBindingImplementation::drawElementsBaseVertex(const VertexArray * vertexArray, gl::GLenum mode, gl::GLsizei count, gl::GLenum type, const void * indices, gl::GLint baseVertex) const +{ + bind(vertexArray); + glDrawElementsBaseVertex(mode, count, type, const_cast(indices), baseVertex); +} + +void AbstractVertexAttributeBindingImplementation::drawElementsInstanced(const VertexArray * vertexArray, gl::GLenum mode, gl::GLsizei count, gl::GLenum type, const void * indices, gl::GLsizei primitiveCount) const +{ + bind(vertexArray); + glDrawElementsInstanced(mode, count, type, indices, primitiveCount); +} + +void AbstractVertexAttributeBindingImplementation::drawElementsInstancedBaseInstance(const VertexArray * vertexArray, gl::GLenum mode, gl::GLsizei count, gl::GLenum type, const void * indices, gl::GLsizei instanceCount, gl::GLuint baseInstance) const +{ + bind(vertexArray); + glDrawElementsInstancedBaseInstance(mode, count, type, indices, instanceCount, baseInstance); +} + +void AbstractVertexAttributeBindingImplementation::drawElementsInstancedBaseVertex(const VertexArray * vertexArray, gl::GLenum mode, gl::GLsizei count, gl::GLenum type, const void * indices, gl::GLsizei instanceCount, gl::GLint baseVertex) const +{ + bind(vertexArray); + glDrawElementsInstancedBaseVertex(mode, count, type, indices, instanceCount, baseVertex); +} + +void AbstractVertexAttributeBindingImplementation::drawElementsInstancedBaseVertexBaseInstance(const VertexArray * vertexArray, gl::GLenum mode, gl::GLsizei count, gl::GLenum type, const void * indices, gl::GLsizei instanceCount, gl::GLint baseVertex, gl::GLuint baseInstance) const +{ + bind(vertexArray); + glDrawElementsInstancedBaseVertexBaseInstance(mode, count, type, indices, instanceCount, baseVertex, baseInstance); +} + +void AbstractVertexAttributeBindingImplementation::multiDrawElements(const VertexArray * vertexArray, gl::GLenum mode, const gl::GLsizei * count, gl::GLenum type, const void ** indices, gl::GLsizei drawCount) const +{ + bind(vertexArray); + glMultiDrawElements(mode, count, type, indices, drawCount); +} + +void AbstractVertexAttributeBindingImplementation::multiDrawElementsBaseVertex(const VertexArray * vertexArray, gl::GLenum mode, const gl::GLsizei * count, gl::GLenum type, const void ** indices, gl::GLsizei drawCount, gl::GLint * baseVertex) const +{ + bind(vertexArray); + glMultiDrawElementsBaseVertex(mode, const_cast(count), type, const_cast(indices), drawCount, baseVertex); +} + +void AbstractVertexAttributeBindingImplementation::multiDrawElementsIndirect(const VertexArray * vertexArray, gl::GLenum mode, gl::GLenum type, const void * indirect, gl::GLsizei drawCount, gl::GLsizei stride) const +{ + bind(vertexArray); + glMultiDrawElementsIndirect(mode, type, indirect, drawCount, stride); +} + +void AbstractVertexAttributeBindingImplementation::drawRangeElements(const VertexArray * vertexArray, gl::GLenum mode, gl::GLuint start, gl::GLuint end, gl::GLsizei count, gl::GLenum type, const void * indices) const +{ + bind(vertexArray); + glDrawRangeElements(mode, start, end, count, type, indices); +} + +void AbstractVertexAttributeBindingImplementation::drawRangeElementsBaseVertex(const VertexArray * vertexArray, gl::GLenum mode, gl::GLuint start, gl::GLuint end, gl::GLsizei count, gl::GLenum type, const void * indices, gl::GLint baseVertex) const +{ + bind(vertexArray); + glDrawRangeElementsBaseVertex(mode, start, end, count, type, const_cast(indices), baseVertex); +} + } // namespace globjects diff --git a/source/globjects/source/implementations/AbstractVertexAttributeBindingImplementation.h b/source/globjects/source/implementations/AbstractVertexAttributeBindingImplementation.h index 51c3ce37..c7a1bb92 100644 --- a/source/globjects/source/implementations/AbstractVertexAttributeBindingImplementation.h +++ b/source/globjects/source/implementations/AbstractVertexAttributeBindingImplementation.h @@ -27,6 +27,34 @@ class AbstractVertexAttributeBindingImplementation static AbstractVertexAttributeBindingImplementation * get(VertexArray::AttributeImplementation impl = VertexArray::AttributeImplementation::VertexAttribBindingARB); + virtual gl::GLuint create() const = 0; + virtual void destroy(gl::GLuint id) const = 0; + + virtual void bind(const VertexArray * vertexArray) const; + virtual void unbind() const; + + virtual void drawArrays(const VertexArray * vertexArray, gl::GLenum mode, gl::GLint first, gl::GLsizei count) const; + virtual void drawArraysInstanced(const VertexArray * vertexArray, gl::GLenum mode, gl::GLint first, gl::GLsizei count, gl::GLsizei instanceCount) const; + virtual void drawArraysInstancedBaseInstance(const VertexArray * vertexArray, gl::GLenum mode, gl::GLint first, gl::GLsizei count, gl::GLsizei instanceCount, gl::GLuint baseInstance) const; + virtual void drawArraysIndirect(const VertexArray * vertexArray, gl::GLenum mode, const void * indirect = nullptr) const; + + virtual void multiDrawArrays(const VertexArray * vertexArray, gl::GLenum mode, gl::GLint * first, const gl::GLsizei * count, gl::GLsizei drawCount) const; + virtual void multiDrawArraysIndirect(const VertexArray * vertexArray, gl::GLenum mode, const void * indirect, gl::GLsizei drawCount, gl::GLsizei stride) const; + + virtual void drawElements(const VertexArray * vertexArray, gl::GLenum mode, gl::GLsizei count, gl::GLenum type, const void * indices = nullptr) const; + virtual void drawElementsBaseVertex(const VertexArray * vertexArray, gl::GLenum mode, gl::GLsizei count, gl::GLenum type, const void * indices, gl::GLint baseVertex) const; + virtual void drawElementsInstanced(const VertexArray * vertexArray, gl::GLenum mode, gl::GLsizei count, gl::GLenum type, const void * indices, gl::GLsizei primitiveCount) const; + virtual void drawElementsInstancedBaseInstance(const VertexArray * vertexArray, gl::GLenum mode, gl::GLsizei count, gl::GLenum type, const void * indices, gl::GLsizei instanceCount, gl::GLuint baseInstance) const; + virtual void drawElementsInstancedBaseVertex(const VertexArray * vertexArray, gl::GLenum mode, gl::GLsizei count, gl::GLenum type, const void * indices, gl::GLsizei instanceCount, gl::GLint baseVertex) const; + virtual void drawElementsInstancedBaseVertexBaseInstance(const VertexArray * vertexArray, gl::GLenum mode, gl::GLsizei count, gl::GLenum type, const void * indices, gl::GLsizei instanceCount, gl::GLint baseVertex, gl::GLuint baseInstance) const; + + virtual void multiDrawElements(const VertexArray * vertexArray, gl::GLenum mode, const gl::GLsizei * count, gl::GLenum type, const void ** indices, gl::GLsizei drawCount) const; + virtual void multiDrawElementsBaseVertex(const VertexArray * vertexArray, gl::GLenum mode, const gl::GLsizei * count, gl::GLenum type, const void ** indices, gl::GLsizei drawCount, gl::GLint * baseVertex) const; + virtual void multiDrawElementsIndirect(const VertexArray * vertexArray, gl::GLenum mode, gl::GLenum type, const void * indirect, gl::GLsizei drawCount, gl::GLsizei stride) const; + + virtual void drawRangeElements(const VertexArray * vertexArray, gl::GLenum mode, gl::GLuint start, gl::GLuint end, gl::GLsizei count, gl::GLenum type, const void * indices = nullptr) const; + virtual void drawRangeElementsBaseVertex(const VertexArray * vertexArray, gl::GLenum mode, gl::GLuint start, gl::GLuint end, gl::GLsizei count, gl::GLenum type, const void * indices, gl::GLint baseVertex) const; + virtual void enable(const VertexArray * vertexArray, gl::GLint attributeIndex) const = 0; virtual void disable(const VertexArray * vertexArray, gl::GLint attributeIndex) const = 0; diff --git a/source/globjects/source/implementations/BufferImplementation_DirectStateAccessARB.cpp b/source/globjects/source/implementations/BufferImplementation_DirectStateAccessARB.cpp index a164ef9f..c78dbdff 100644 --- a/source/globjects/source/implementations/BufferImplementation_DirectStateAccessARB.cpp +++ b/source/globjects/source/implementations/BufferImplementation_DirectStateAccessARB.cpp @@ -29,6 +29,26 @@ void BufferImplementation_DirectStateAccessARB::destroy(const GLuint id) const BufferImplementation_Legacy::instance()->destroy(id); } +void BufferImplementation_DirectStateAccessARB::bind(const Buffer * buffer, gl::GLenum target) const +{ + glBindBuffer(target, buffer->id()); +} + +void BufferImplementation_DirectStateAccessARB::unbind(gl::GLenum target) const +{ + glBindBuffer(target, 0); +} + +void BufferImplementation_DirectStateAccessARB::bindBase(const Buffer * buffer, gl::GLenum target, const gl::GLuint index) const +{ + glBindBufferBase(target, index, buffer->id()); +} + +void BufferImplementation_DirectStateAccessARB::unbindBase(gl::GLenum target, const gl::GLuint index) const +{ + glBindBufferBase(target, index, 0); +} + void * BufferImplementation_DirectStateAccessARB::map(const Buffer * buffer, GLenum access) const { return glMapNamedBuffer(buffer->id(), access); @@ -39,6 +59,11 @@ void * BufferImplementation_DirectStateAccessARB::mapRange(const Buffer * buffer return glMapNamedBufferRange(buffer->id(), offset, static_cast(length), static_cast(access)); } +void BufferImplementation_DirectStateAccessARB::bindRange(const Buffer * buffer, gl::GLenum target, gl::GLuint index, gl::GLintptr offset, gl::GLsizeiptr size) const +{ + glBindBufferRange(target, index, buffer->id(), offset, size); +} + bool BufferImplementation_DirectStateAccessARB::unmap(const Buffer * buffer) const { return GL_TRUE == glUnmapNamedBuffer(buffer->id()); diff --git a/source/globjects/source/implementations/BufferImplementation_DirectStateAccessARB.h b/source/globjects/source/implementations/BufferImplementation_DirectStateAccessARB.h index 6b52bd76..c9ebf45b 100644 --- a/source/globjects/source/implementations/BufferImplementation_DirectStateAccessARB.h +++ b/source/globjects/source/implementations/BufferImplementation_DirectStateAccessARB.h @@ -21,6 +21,13 @@ class BufferImplementation_DirectStateAccessARB : public AbstractBufferImplement virtual gl::GLuint create() const override; virtual void destroy(gl::GLuint id) const override; + virtual void bind(const Buffer * buffer, gl::GLenum target) const override; + virtual void unbind(gl::GLenum target) const override; + virtual void bindBase(const Buffer * buffer, gl::GLenum target, const gl::GLuint index) const override; + virtual void unbindBase(gl::GLenum target, const gl::GLuint index) const override; + + virtual void bindRange(const Buffer * buffer, gl::GLenum target, gl::GLuint index, gl::GLintptr offset, gl::GLsizeiptr size) const override; + virtual void * map(const Buffer * buffer, gl::GLenum access) const override; virtual void * mapRange(const Buffer * buffer, gl::GLintptr offset, gl::GLsizeiptr length, gl::MapBufferAccessMask access) const override; virtual bool unmap(const Buffer * buffer) const override; diff --git a/source/globjects/source/implementations/BufferImplementation_DirectStateAccessEXT.cpp b/source/globjects/source/implementations/BufferImplementation_DirectStateAccessEXT.cpp index edcf4979..db43a36c 100644 --- a/source/globjects/source/implementations/BufferImplementation_DirectStateAccessEXT.cpp +++ b/source/globjects/source/implementations/BufferImplementation_DirectStateAccessEXT.cpp @@ -26,6 +26,31 @@ void BufferImplementation_DirectStateAccessEXT::destroy(const GLuint id) const BufferImplementation_Legacy::instance()->destroy(id); } +void BufferImplementation_DirectStateAccessEXT::bind(const Buffer * buffer, gl::GLenum target) const +{ + glBindBuffer(target, buffer->id()); +} + +void BufferImplementation_DirectStateAccessEXT::unbind(gl::GLenum target) const +{ + glBindBuffer(target, 0); +} + +void BufferImplementation_DirectStateAccessEXT::bindBase(const Buffer * buffer, gl::GLenum target, const gl::GLuint index) const +{ + glBindBufferBase(target, index, buffer->id()); +} + +void BufferImplementation_DirectStateAccessEXT::unbindBase(gl::GLenum target, const gl::GLuint index) const +{ + glBindBufferBase(target, index, 0); +} + +void BufferImplementation_DirectStateAccessEXT::bindRange(const Buffer * buffer, gl::GLenum target, gl::GLuint index, gl::GLintptr offset, gl::GLsizeiptr size) const +{ + glBindBufferRange(target, index, buffer->id(), offset, size); +} + void * BufferImplementation_DirectStateAccessEXT::map(const Buffer * buffer, GLenum access) const { return glMapNamedBufferEXT(buffer->id(), access); diff --git a/source/globjects/source/implementations/BufferImplementation_DirectStateAccessEXT.h b/source/globjects/source/implementations/BufferImplementation_DirectStateAccessEXT.h index 59115c3d..da9a9db3 100644 --- a/source/globjects/source/implementations/BufferImplementation_DirectStateAccessEXT.h +++ b/source/globjects/source/implementations/BufferImplementation_DirectStateAccessEXT.h @@ -20,6 +20,13 @@ class BufferImplementation_DirectStateAccessEXT : public AbstractBufferImplement virtual gl::GLuint create() const override; virtual void destroy(gl::GLuint id) const override; + virtual void bind(const Buffer * buffer, gl::GLenum target) const override; + virtual void unbind(gl::GLenum target) const override; + virtual void bindBase(const Buffer * buffer, gl::GLenum target, const gl::GLuint index) const override; + virtual void unbindBase(gl::GLenum target, const gl::GLuint index) const override; + + virtual void bindRange(const Buffer * buffer, gl::GLenum target, gl::GLuint index, gl::GLintptr offset, gl::GLsizeiptr size) const override; + virtual void * map(const Buffer * buffer, gl::GLenum access) const override; virtual void * mapRange(const Buffer * buffer, gl::GLintptr offset, gl::GLsizeiptr length, gl::MapBufferAccessMask access) const override; virtual bool unmap(const Buffer * buffer) const override; diff --git a/source/globjects/source/implementations/BufferImplementation_Legacy.cpp b/source/globjects/source/implementations/BufferImplementation_Legacy.cpp index 1312cbbc..f32713d1 100644 --- a/source/globjects/source/implementations/BufferImplementation_Legacy.cpp +++ b/source/globjects/source/implementations/BufferImplementation_Legacy.cpp @@ -32,6 +32,31 @@ void BufferImplementation_Legacy::destroy(const GLuint id) const glDeleteBuffers(1, &id); } +void BufferImplementation_Legacy::bind(const Buffer * buffer, gl::GLenum target) const +{ + glBindBuffer(target, buffer->id()); +} + +void BufferImplementation_Legacy::unbind(gl::GLenum target) const +{ + glBindBuffer(target, 0); +} + +void BufferImplementation_Legacy::bindBase(const Buffer * buffer, gl::GLenum target, const gl::GLuint index) const +{ + glBindBufferBase(target, index, buffer->id()); +} + +void BufferImplementation_Legacy::unbindBase(gl::GLenum target, const gl::GLuint index) const +{ + glBindBufferBase(target, index, 0); +} + +void BufferImplementation_Legacy::bindRange(const Buffer * buffer, gl::GLenum target, gl::GLuint index, gl::GLintptr offset, gl::GLsizeiptr size) const +{ + glBindBufferRange(target, index, buffer->id(), offset, size); +} + void * BufferImplementation_Legacy::map(const Buffer * buffer, GLenum access) const { buffer->bind(s_workingTarget); diff --git a/source/globjects/source/implementations/BufferImplementation_Legacy.h b/source/globjects/source/implementations/BufferImplementation_Legacy.h index 1cbcf583..121ee2b8 100644 --- a/source/globjects/source/implementations/BufferImplementation_Legacy.h +++ b/source/globjects/source/implementations/BufferImplementation_Legacy.h @@ -18,6 +18,13 @@ class BufferImplementation_Legacy : public AbstractBufferImplementation virtual gl::GLuint create() const override; virtual void destroy(gl::GLuint id) const override; + virtual void bind(const Buffer * buffer, gl::GLenum target) const override; + virtual void unbind(gl::GLenum target) const override; + virtual void bindBase(const Buffer * buffer, gl::GLenum target, const gl::GLuint index) const override; + virtual void unbindBase(gl::GLenum target, const gl::GLuint index) const override; + + virtual void bindRange(const Buffer * buffer, gl::GLenum target, gl::GLuint index, gl::GLintptr offset, gl::GLsizeiptr size) const override; + virtual void * map(const Buffer * buffer, gl::GLenum access) const override; virtual void * mapRange(const Buffer * buffer, gl::GLintptr offset, gl::GLsizeiptr length, gl::MapBufferAccessMask access) const override; virtual bool unmap(const Buffer * buffer) const override; diff --git a/source/globjects/source/implementations/FramebufferImplementation_DirectStateAccessARB.cpp b/source/globjects/source/implementations/FramebufferImplementation_DirectStateAccessARB.cpp index abe0feac..0569d629 100644 --- a/source/globjects/source/implementations/FramebufferImplementation_DirectStateAccessARB.cpp +++ b/source/globjects/source/implementations/FramebufferImplementation_DirectStateAccessARB.cpp @@ -31,6 +31,26 @@ void FramebufferImplementation_DirectStateAccessARB::destroy(const GLuint id) co FramebufferImplementation_Legacy::instance()->destroy(id); } +void FramebufferImplementation_DirectStateAccessARB::bind(const Framebuffer * fbo) const +{ + glBindFramebuffer(GL_FRAMEBUFFER, fbo->id()); +} + +void FramebufferImplementation_DirectStateAccessARB::bind(const Framebuffer * fbo, gl::GLenum target) const +{ + glBindFramebuffer(target, fbo->id()); +} + +void FramebufferImplementation_DirectStateAccessARB::unbind() const +{ + glBindFramebuffer(GL_FRAMEBUFFER, 0); +} + +void FramebufferImplementation_DirectStateAccessARB::unbind(gl::GLenum target) const +{ + glBindFramebuffer(target, 0); +} + GLenum FramebufferImplementation_DirectStateAccessARB::checkStatus(const Framebuffer * fbo) const { // glCheckNamedFramebufferStatus seems to fail when checking the default framebuffer diff --git a/source/globjects/source/implementations/FramebufferImplementation_DirectStateAccessARB.h b/source/globjects/source/implementations/FramebufferImplementation_DirectStateAccessARB.h index 41f8b885..2456be19 100644 --- a/source/globjects/source/implementations/FramebufferImplementation_DirectStateAccessARB.h +++ b/source/globjects/source/implementations/FramebufferImplementation_DirectStateAccessARB.h @@ -18,6 +18,11 @@ class FramebufferImplementation_DirectStateAccessARB : public AbstractFramebuffe virtual gl::GLuint create() const override; virtual void destroy(gl::GLuint id) const override; + virtual void bind(const Framebuffer * fbo) const override; + virtual void bind(const Framebuffer * fbo, gl::GLenum target) const override; + virtual void unbind() const override; + virtual void unbind(gl::GLenum target) const override; + virtual gl::GLenum checkStatus(const Framebuffer * fbo) const override; virtual void setParameter(const Framebuffer * fbo, gl::GLenum pname, gl::GLint param) const override; virtual gl::GLint getAttachmentParameter(const Framebuffer * fbo, gl::GLenum attachment, gl::GLenum pname) const override; diff --git a/source/globjects/source/implementations/FramebufferImplementation_DirectStateAccessEXT.cpp b/source/globjects/source/implementations/FramebufferImplementation_DirectStateAccessEXT.cpp index a9073cc6..bf4e0581 100644 --- a/source/globjects/source/implementations/FramebufferImplementation_DirectStateAccessEXT.cpp +++ b/source/globjects/source/implementations/FramebufferImplementation_DirectStateAccessEXT.cpp @@ -28,6 +28,26 @@ void FramebufferImplementation_DirectStateAccessEXT::destroy(GLuint id) const FramebufferImplementation_Legacy::instance()->destroy(id); } +void FramebufferImplementation_DirectStateAccessEXT::bind(const Framebuffer * fbo) const +{ + glBindFramebuffer(GL_FRAMEBUFFER, fbo->id()); +} + +void FramebufferImplementation_DirectStateAccessEXT::bind(const Framebuffer * fbo, gl::GLenum target) const +{ + glBindFramebuffer(target, fbo->id()); +} + +void FramebufferImplementation_DirectStateAccessEXT::unbind() const +{ + glBindFramebuffer(GL_FRAMEBUFFER, 0); +} + +void FramebufferImplementation_DirectStateAccessEXT::unbind(gl::GLenum target) const +{ + glBindFramebuffer(target, 0); +} + GLenum FramebufferImplementation_DirectStateAccessEXT::checkStatus(const Framebuffer * fbo) const { // glCheckNamedFramebufferStatus seems to fail when checking the default framebuffer diff --git a/source/globjects/source/implementations/FramebufferImplementation_DirectStateAccessEXT.h b/source/globjects/source/implementations/FramebufferImplementation_DirectStateAccessEXT.h index 2a87ef4d..6e2cc136 100644 --- a/source/globjects/source/implementations/FramebufferImplementation_DirectStateAccessEXT.h +++ b/source/globjects/source/implementations/FramebufferImplementation_DirectStateAccessEXT.h @@ -18,6 +18,11 @@ class FramebufferImplementation_DirectStateAccessEXT : public AbstractFramebuffe virtual gl::GLuint create() const override; virtual void destroy(gl::GLuint id) const override; + virtual void bind(const Framebuffer * fbo) const override; + virtual void bind(const Framebuffer * fbo, gl::GLenum target) const override; + virtual void unbind() const override; + virtual void unbind(gl::GLenum target) const override; + virtual gl::GLenum checkStatus(const Framebuffer * fbo) const override; virtual void setParameter(const Framebuffer * fbo, gl::GLenum pname, gl::GLint param) const override; virtual gl::GLint getAttachmentParameter(const Framebuffer * fbo, gl::GLenum attachment, gl::GLenum pname) const override; diff --git a/source/globjects/source/implementations/FramebufferImplementation_Legacy.cpp b/source/globjects/source/implementations/FramebufferImplementation_Legacy.cpp index a1f2d9ba..7ab18e7c 100644 --- a/source/globjects/source/implementations/FramebufferImplementation_Legacy.cpp +++ b/source/globjects/source/implementations/FramebufferImplementation_Legacy.cpp @@ -30,6 +30,26 @@ void FramebufferImplementation_Legacy::destroy(GLuint id) const glDeleteFramebuffers(1, &id); } +void FramebufferImplementation_Legacy::bind(const Framebuffer * fbo) const +{ + glBindFramebuffer(GL_FRAMEBUFFER, fbo->id()); +} + +void FramebufferImplementation_Legacy::bind(const Framebuffer * fbo, gl::GLenum target) const +{ + glBindFramebuffer(target, fbo->id()); +} + +void FramebufferImplementation_Legacy::unbind() const +{ + glBindFramebuffer(GL_FRAMEBUFFER, 0); +} + +void FramebufferImplementation_Legacy::unbind(gl::GLenum target) const +{ + glBindFramebuffer(target, 0); +} + GLenum FramebufferImplementation_Legacy::checkStatus(const Framebuffer * fbo) const { fbo->bind(GL_DRAW_FRAMEBUFFER); diff --git a/source/globjects/source/implementations/FramebufferImplementation_Legacy.h b/source/globjects/source/implementations/FramebufferImplementation_Legacy.h index 9c77294b..e199a01d 100644 --- a/source/globjects/source/implementations/FramebufferImplementation_Legacy.h +++ b/source/globjects/source/implementations/FramebufferImplementation_Legacy.h @@ -18,6 +18,11 @@ class FramebufferImplementation_Legacy : public AbstractFramebufferImplementatio virtual gl::GLuint create() const override; virtual void destroy(gl::GLuint id) const override; + virtual void bind(const Framebuffer * fbo) const override; + virtual void bind(const Framebuffer * fbo, gl::GLenum target) const override; + virtual void unbind() const override; + virtual void unbind(gl::GLenum target) const override; + virtual gl::GLenum checkStatus(const Framebuffer * fbo) const override; virtual void setParameter(const Framebuffer * fbo, gl::GLenum pname, gl::GLint param) const override; virtual gl::GLint getAttachmentParameter(const Framebuffer * fbo, gl::GLenum attachment, gl::GLenum pname) const override; diff --git a/source/globjects/source/implementations/ProgramImplementation_Legacy.cpp b/source/globjects/source/implementations/ProgramImplementation_Legacy.cpp new file mode 100644 index 00000000..f4d03540 --- /dev/null +++ b/source/globjects/source/implementations/ProgramImplementation_Legacy.cpp @@ -0,0 +1,28 @@ + +#include "ProgramImplementation_Legacy.h" + +#include +#include +#include + +#include + + +using namespace gl; + + +namespace globjects +{ + +GLuint ProgramImplementation_Legacy::create() const +{ + return glCreateProgram(); +} + +void ProgramImplementation_Legacy::destroy(const GLuint id) const +{ + glDeleteProgram(id); +} + + +} // namespace globjects diff --git a/source/globjects/source/implementations/ProgramImplementation_Legacy.h b/source/globjects/source/implementations/ProgramImplementation_Legacy.h new file mode 100644 index 00000000..8b69aefd --- /dev/null +++ b/source/globjects/source/implementations/ProgramImplementation_Legacy.h @@ -0,0 +1,28 @@ + +#pragma once + + +#include + +#include "../base/Singleton.h" + +#include "AbstractProgramImplementation.h" + + +namespace globjects +{ + + +class AbstractStringSource; + + +class ProgramImplementation_Legacy : public AbstractProgramImplementation + , public Singleton +{ +public: + virtual gl::GLuint create() const override; + virtual void destroy(gl::GLuint id) const override; +}; + + +} // namespace globjects diff --git a/source/globjects/source/implementations/ProgramPipelineImplementation_Legacy.cpp b/source/globjects/source/implementations/ProgramPipelineImplementation_Legacy.cpp new file mode 100644 index 00000000..0b953e7a --- /dev/null +++ b/source/globjects/source/implementations/ProgramPipelineImplementation_Legacy.cpp @@ -0,0 +1,81 @@ + +#include "ProgramPipelineImplementation_Legacy.h" + +#include +#include +#include + +#include +#include + + +using namespace gl; + + +namespace globjects +{ + +GLuint ProgramPipelineImplementation_Legacy::create() const +{ + gl::GLuint id; + glGenProgramPipelines(1, &id); + + return id; +} + +void ProgramPipelineImplementation_Legacy::destroy(const GLuint id) const +{ + glDeleteProgramPipelines(1, &id); +} + +void ProgramPipelineImplementation_Legacy::use(const ProgramPipeline * pipeline) const +{ + gl::glBindProgramPipeline(pipeline->id()); +} + +void ProgramPipelineImplementation_Legacy::release() const +{ + gl::glBindProgramPipeline(0); +} + +void ProgramPipelineImplementation_Legacy::useStages(const ProgramPipeline * pipeline, const Program * program, gl::UseProgramStageMask stages) const +{ + gl::glUseProgramStages(pipeline->id(), stages, program->id()); +} + +void ProgramPipelineImplementation_Legacy::releaseStages(const ProgramPipeline * pipeline, gl::UseProgramStageMask stages) const +{ + gl::glUseProgramStages(pipeline->id(), stages, 0); +} + +void ProgramPipelineImplementation_Legacy::validate(const ProgramPipeline * pipeline) const +{ + gl::glValidateProgramPipeline(pipeline->id()); +} + +gl::GLint ProgramPipelineImplementation_Legacy::getInt(const ProgramPipeline * pipeline, gl::GLenum pname) const +{ + gl::GLint value = 0; + gl::glGetProgramPipelineiv(pipeline->id(), pname, &value); + + return value; +} + +std::string ProgramPipelineImplementation_Legacy::getInfoLog(const ProgramPipeline * pipeline) const +{ + gl::GLint length = getInt(pipeline, gl::GL_INFO_LOG_LENGTH); + + if (length == 0) + { + return std::string(); + } + + std::vector log(length); + + gl::glGetProgramPipelineInfoLog(pipeline->id(), length, &length, log.data()); + + return std::string(log.data(), length); +} + + +} // namespace globjects diff --git a/source/globjects/source/implementations/ProgramPipelineImplementation_Legacy.h b/source/globjects/source/implementations/ProgramPipelineImplementation_Legacy.h new file mode 100644 index 00000000..99cbc44c --- /dev/null +++ b/source/globjects/source/implementations/ProgramPipelineImplementation_Legacy.h @@ -0,0 +1,33 @@ + +#pragma once + + +#include + +#include "../base/Singleton.h" + +#include "AbstractProgramPipelineImplementation.h" + + +namespace globjects +{ + + +class ProgramPipelineImplementation_Legacy : public AbstractProgramPipelineImplementation + , public Singleton +{ +public: + virtual gl::GLuint create() const override; + virtual void destroy(gl::GLuint id) const override; + + virtual void use(const ProgramPipeline * pipeline) const override; + virtual void release() const override; + virtual void useStages(const ProgramPipeline * pipeline, const Program * program, gl::UseProgramStageMask stages) const override; + virtual void releaseStages(const ProgramPipeline * pipeline, gl::UseProgramStageMask stages) const override; + virtual void validate(const ProgramPipeline * pipeline) const override; + virtual gl::GLint getInt(const ProgramPipeline * pipeline, gl::GLenum pname) const override; + virtual std::string getInfoLog(const ProgramPipeline * pipeline) const override; +}; + + +} // namespace globjects diff --git a/source/globjects/source/implementations/QueryImplementation_Legacy.cpp b/source/globjects/source/implementations/QueryImplementation_Legacy.cpp new file mode 100644 index 00000000..d0f60705 --- /dev/null +++ b/source/globjects/source/implementations/QueryImplementation_Legacy.cpp @@ -0,0 +1,31 @@ + +#include "QueryImplementation_Legacy.h" + +#include +#include +#include + +#include + + +using namespace gl; + + +namespace globjects +{ + +GLuint QueryImplementation_Legacy::create() const +{ + gl::GLuint id; + glGenQueries(1, &id); + + return id; +} + +void QueryImplementation_Legacy::destroy(const GLuint id) const +{ + glDeleteQueries(1, &id); +} + + +} // namespace globjects diff --git a/source/globjects/source/implementations/QueryImplementation_Legacy.h b/source/globjects/source/implementations/QueryImplementation_Legacy.h new file mode 100644 index 00000000..bd4a3ab3 --- /dev/null +++ b/source/globjects/source/implementations/QueryImplementation_Legacy.h @@ -0,0 +1,25 @@ + +#pragma once + + +#include + +#include "../base/Singleton.h" + +#include "AbstractQueryImplementation.h" + + +namespace globjects +{ + + +class QueryImplementation_Legacy : public AbstractQueryImplementation + , public Singleton +{ +public: + virtual gl::GLuint create() const override; + virtual void destroy(gl::GLuint id) const override; +}; + + +} // namespace globjects diff --git a/source/globjects/source/implementations/RenderbufferImplementation_Legacy.cpp b/source/globjects/source/implementations/RenderbufferImplementation_Legacy.cpp new file mode 100644 index 00000000..61b2bbef --- /dev/null +++ b/source/globjects/source/implementations/RenderbufferImplementation_Legacy.cpp @@ -0,0 +1,67 @@ + +#include "RenderbufferImplementation_Legacy.h" + +#include +#include +#include + +#include + + +using namespace gl; + + +namespace globjects +{ + +GLuint RenderbufferImplementation_Legacy::create() const +{ + gl::GLuint id; + glGenRenderbuffers(1, &id); + + return id; +} + +void RenderbufferImplementation_Legacy::destroy(const GLuint id) const +{ + glDeleteRenderbuffers(1, &id); +} + + +void RenderbufferImplementation_Legacy::bind(const Renderbuffer * renderbuffer, const GLenum target) const +{ + glBindRenderbuffer(target, renderbuffer->id()); +} + +void RenderbufferImplementation_Legacy::unbind(const GLenum target) const +{ + glBindRenderbuffer(target, 0); +} + +void RenderbufferImplementation_Legacy::storage(const Renderbuffer * renderbuffer, gl::GLenum internalformat, gl::GLsizei width, gl::GLsizei height) const +{ + bind(renderbuffer, GL_RENDERBUFFER); + + glRenderbufferStorage(GL_RENDERBUFFER, internalformat, width, height); +} + +void RenderbufferImplementation_Legacy::storageMultisample(const Renderbuffer * renderbuffer, gl::GLsizei samples, gl::GLenum internalformat, gl::GLsizei width, const gl::GLsizei height) const +{ + bind(renderbuffer, GL_RENDERBUFFER); + + glRenderbufferStorageMultisample(GL_RENDERBUFFER, samples, internalformat, width, height); +} + +gl::GLint RenderbufferImplementation_Legacy::getParameterInt(const Renderbuffer * renderbuffer, gl::GLenum pname) const +{ + GLint value = 0; + + bind(renderbuffer, GL_RENDERBUFFER); + + glGetRenderbufferParameteriv(GL_RENDERBUFFER, pname, &value); + + return value; +} + + +} // namespace globjects diff --git a/source/globjects/source/implementations/RenderbufferImplementation_Legacy.h b/source/globjects/source/implementations/RenderbufferImplementation_Legacy.h new file mode 100644 index 00000000..768d341f --- /dev/null +++ b/source/globjects/source/implementations/RenderbufferImplementation_Legacy.h @@ -0,0 +1,31 @@ + +#pragma once + + +#include + +#include "../base/Singleton.h" + +#include "AbstractRenderbufferImplementation.h" + + +namespace globjects +{ + + +class RenderbufferImplementation_Legacy : public AbstractRenderbufferImplementation + , public Singleton +{ +public: + virtual gl::GLuint create() const override; + virtual void destroy(gl::GLuint id) const override; + + virtual void bind(const Renderbuffer * renderbuffer, gl::GLenum target) const override; + virtual void unbind(gl::GLenum target) const override; + virtual void storage(const Renderbuffer * renderbuffer, gl::GLenum internalformat, gl::GLsizei width, gl::GLsizei height) const override; + virtual void storageMultisample(const Renderbuffer * renderbuffer, gl::GLsizei samples, gl::GLenum internalformat, gl::GLsizei width, const gl::GLsizei height) const override; + virtual gl::GLint getParameterInt(const Renderbuffer * renderbuffer, gl::GLenum pname) const override; +}; + + +} // namespace globjects diff --git a/source/globjects/source/implementations/SamplerImplementation_Legacy.cpp b/source/globjects/source/implementations/SamplerImplementation_Legacy.cpp new file mode 100644 index 00000000..a9448cd0 --- /dev/null +++ b/source/globjects/source/implementations/SamplerImplementation_Legacy.cpp @@ -0,0 +1,31 @@ + +#include "SamplerImplementation_Legacy.h" + +#include +#include +#include + +#include + + +using namespace gl; + + +namespace globjects +{ + +GLuint SamplerImplementation_Legacy::create() const +{ + gl::GLuint id; + glGenSamplers(1, &id); + + return id; +} + +void SamplerImplementation_Legacy::destroy(const GLuint id) const +{ + glDeleteSamplers(1, &id); +} + + +} // namespace globjects diff --git a/source/globjects/source/implementations/SamplerImplementation_Legacy.h b/source/globjects/source/implementations/SamplerImplementation_Legacy.h new file mode 100644 index 00000000..c4813a7a --- /dev/null +++ b/source/globjects/source/implementations/SamplerImplementation_Legacy.h @@ -0,0 +1,25 @@ + +#pragma once + + +#include + +#include "../base/Singleton.h" + +#include "AbstractSamplerImplementation.h" + + +namespace globjects +{ + + +class SamplerImplementation_Legacy : public AbstractSamplerImplementation + , public Singleton +{ +public: + virtual gl::GLuint create() const override; + virtual void destroy(gl::GLuint id) const override; +}; + + +} // namespace globjects diff --git a/source/globjects/source/implementations/ShaderImplementation_Legacy.cpp b/source/globjects/source/implementations/ShaderImplementation_Legacy.cpp new file mode 100644 index 00000000..cf32d2e1 --- /dev/null +++ b/source/globjects/source/implementations/ShaderImplementation_Legacy.cpp @@ -0,0 +1,28 @@ + +#include "ShaderImplementation_Legacy.h" + +#include +#include +#include + +#include + + +using namespace gl; + + +namespace globjects +{ + +GLuint ShaderImplementation_Legacy::create(gl::GLenum type) const +{ + return glCreateShader(type); +} + +void ShaderImplementation_Legacy::destroy(const GLuint id) const +{ + glDeleteShader(id); +} + + +} // namespace globjects diff --git a/source/globjects/source/implementations/ShaderImplementation_Legacy.h b/source/globjects/source/implementations/ShaderImplementation_Legacy.h new file mode 100644 index 00000000..7b51fbdb --- /dev/null +++ b/source/globjects/source/implementations/ShaderImplementation_Legacy.h @@ -0,0 +1,25 @@ + +#pragma once + + +#include + +#include "../base/Singleton.h" + +#include "AbstractShaderImplementation.h" + + +namespace globjects +{ + + +class ShaderImplementation_Legacy : public AbstractShaderImplementation + , public Singleton +{ +public: + virtual gl::GLuint create(gl::GLenum type) const override; + virtual void destroy(gl::GLuint id) const override; +}; + + +} // namespace globjects diff --git a/source/globjects/source/implementations/TransformFeedbackImplementation_Legacy.cpp b/source/globjects/source/implementations/TransformFeedbackImplementation_Legacy.cpp new file mode 100644 index 00000000..7ab45b29 --- /dev/null +++ b/source/globjects/source/implementations/TransformFeedbackImplementation_Legacy.cpp @@ -0,0 +1,31 @@ + +#include "TransformFeedbackImplementation_Legacy.h" + +#include +#include +#include + +#include + + +using namespace gl; + + +namespace globjects +{ + +GLuint TransformFeedbackImplementation_Legacy::create() const +{ + gl::GLuint id; + glGenTransformFeedbacks(1, &id); + + return id; +} + +void TransformFeedbackImplementation_Legacy::destroy(const GLuint id) const +{ + glDeleteTransformFeedbacks(1, &id); +} + + +} // namespace globjects diff --git a/source/globjects/source/implementations/TransformFeedbackImplementation_Legacy.h b/source/globjects/source/implementations/TransformFeedbackImplementation_Legacy.h new file mode 100644 index 00000000..2d158123 --- /dev/null +++ b/source/globjects/source/implementations/TransformFeedbackImplementation_Legacy.h @@ -0,0 +1,25 @@ + +#pragma once + + +#include + +#include "../base/Singleton.h" + +#include "AbstractTransformFeedbackImplementation.h" + + +namespace globjects +{ + + +class TransformFeedbackImplementation_Legacy : public AbstractTransformFeedbackImplementation + , public Singleton +{ +public: + virtual gl::GLuint create() const override; + virtual void destroy(gl::GLuint id) const override; +}; + + +} // namespace globjects diff --git a/source/globjects/source/implementations/VertexAttributeBindingImplementation_DirectStateAccessARB.cpp b/source/globjects/source/implementations/VertexAttributeBindingImplementation_DirectStateAccessARB.cpp index e135e631..6d6386ca 100644 --- a/source/globjects/source/implementations/VertexAttributeBindingImplementation_DirectStateAccessARB.cpp +++ b/source/globjects/source/implementations/VertexAttributeBindingImplementation_DirectStateAccessARB.cpp @@ -25,6 +25,20 @@ VertexAttributeBindingImplementation_DirectStateAccessARB::~VertexAttributeBindi } +gl::GLuint VertexAttributeBindingImplementation_DirectStateAccessARB::create() const +{ + gl::GLuint result = 0; + + gl::glCreateVertexArrays(1, &result); + + return result; +} + +void VertexAttributeBindingImplementation_DirectStateAccessARB::destroy(gl::GLuint id) const +{ + gl::glDeleteVertexArrays(1, &id); +} + void VertexAttributeBindingImplementation_DirectStateAccessARB::enable(const VertexArray * vertexArray, GLint attributeIndex) const { glEnableVertexArrayAttrib(vertexArray->id(), attributeIndex); diff --git a/source/globjects/source/implementations/VertexAttributeBindingImplementation_DirectStateAccessARB.h b/source/globjects/source/implementations/VertexAttributeBindingImplementation_DirectStateAccessARB.h index 9fa0c0e9..f76b10a4 100644 --- a/source/globjects/source/implementations/VertexAttributeBindingImplementation_DirectStateAccessARB.h +++ b/source/globjects/source/implementations/VertexAttributeBindingImplementation_DirectStateAccessARB.h @@ -22,6 +22,9 @@ class VertexAttributeBindingImplementation_DirectStateAccessARB : public Abstrac VertexAttributeBindingImplementation_DirectStateAccessARB(); virtual ~VertexAttributeBindingImplementation_DirectStateAccessARB(); + virtual gl::GLuint create() const override; + virtual void destroy(gl::GLuint id) const override; + virtual void enable(const VertexArray * vertexArray, gl::GLint attributeIndex) const override; virtual void disable(const VertexArray * vertexArray, gl::GLint attributeIndex) const override; diff --git a/source/globjects/source/implementations/VertexAttributeBindingImplementation_Legacy.cpp b/source/globjects/source/implementations/VertexAttributeBindingImplementation_Legacy.cpp index 82587cbd..4987fcb0 100644 --- a/source/globjects/source/implementations/VertexAttributeBindingImplementation_Legacy.cpp +++ b/source/globjects/source/implementations/VertexAttributeBindingImplementation_Legacy.cpp @@ -46,6 +46,20 @@ VertexAttributeBindingImplementation_Legacy::BindingData::BindingData() { } +gl::GLuint VertexAttributeBindingImplementation_Legacy::create() const +{ + gl::GLuint result = 0; + + gl::glGenVertexArrays(1, &result); + + return result; +} + +void VertexAttributeBindingImplementation_Legacy::destroy(gl::GLuint id) const +{ + gl::glDeleteVertexArrays(1, &id); +} + VertexAttributeBindingImplementation_Legacy::VertexAttributeBindingImplementation_Legacy() { } diff --git a/source/globjects/source/implementations/VertexAttributeBindingImplementation_Legacy.h b/source/globjects/source/implementations/VertexAttributeBindingImplementation_Legacy.h index 15e32081..2f3a9405 100644 --- a/source/globjects/source/implementations/VertexAttributeBindingImplementation_Legacy.h +++ b/source/globjects/source/implementations/VertexAttributeBindingImplementation_Legacy.h @@ -22,6 +22,9 @@ class VertexAttributeBindingImplementation_Legacy : public AbstractVertexAttribu VertexAttributeBindingImplementation_Legacy(); virtual ~VertexAttributeBindingImplementation_Legacy(); + virtual gl::GLuint create() const override; + virtual void destroy(gl::GLuint id) const override; + virtual void enable(const VertexArray * vertexArray, gl::GLint attributeIndex) const override; virtual void disable(const VertexArray * vertexArray, gl::GLint attributeIndex) const override; diff --git a/source/globjects/source/implementations/VertexAttributeBindingImplementation_VertexAttribBindingARB.cpp b/source/globjects/source/implementations/VertexAttributeBindingImplementation_VertexAttribBindingARB.cpp index 0273ea21..39381ec1 100644 --- a/source/globjects/source/implementations/VertexAttributeBindingImplementation_VertexAttribBindingARB.cpp +++ b/source/globjects/source/implementations/VertexAttributeBindingImplementation_VertexAttribBindingARB.cpp @@ -27,6 +27,20 @@ VertexAttributeBindingImplementation_VertexAttribBindingARB::~VertexAttributeBin { } +gl::GLuint VertexAttributeBindingImplementation_VertexAttribBindingARB::create() const +{ + gl::GLuint result = 0; + + gl::glGenVertexArrays(1, &result); + + return result; +} + +void VertexAttributeBindingImplementation_VertexAttribBindingARB::destroy(gl::GLuint id) const +{ + gl::glDeleteVertexArrays(1, &id); +} + void VertexAttributeBindingImplementation_VertexAttribBindingARB::enable(const VertexArray * vertexArray, GLint attributeIndex) const { VertexAttributeBindingImplementation_Legacy::instance()->enable(vertexArray, attributeIndex); diff --git a/source/globjects/source/implementations/VertexAttributeBindingImplementation_VertexAttribBindingARB.h b/source/globjects/source/implementations/VertexAttributeBindingImplementation_VertexAttribBindingARB.h index 53fbc53d..1975defb 100644 --- a/source/globjects/source/implementations/VertexAttributeBindingImplementation_VertexAttribBindingARB.h +++ b/source/globjects/source/implementations/VertexAttributeBindingImplementation_VertexAttribBindingARB.h @@ -22,6 +22,9 @@ class VertexAttributeBindingImplementation_VertexAttribBindingARB : public Abstr VertexAttributeBindingImplementation_VertexAttribBindingARB(); virtual ~VertexAttributeBindingImplementation_VertexAttribBindingARB(); + virtual gl::GLuint create() const override; + virtual void destroy(gl::GLuint id) const override; + virtual void enable(const VertexArray * vertexArray, gl::GLint attributeIndex) const override; virtual void disable(const VertexArray * vertexArray, gl::GLint attributeIndex) const override; diff --git a/source/globjects/source/registry/ImplementationRegistry.cpp b/source/globjects/source/registry/ImplementationRegistry.cpp index 829dc1cd..dd2ee850 100644 --- a/source/globjects/source/registry/ImplementationRegistry.cpp +++ b/source/globjects/source/registry/ImplementationRegistry.cpp @@ -7,12 +7,19 @@ #include "../implementations/AbstractBufferImplementation.h" #include "../implementations/AbstractFramebufferImplementation.h" #include "../implementations/AbstractDebugImplementation.h" +#include "../implementations/AbstractProgramImplementation.h" #include "../implementations/AbstractProgramBinaryImplementation.h" +#include "../implementations/AbstractProgramPipelineImplementation.h" +#include "../implementations/AbstractQueryImplementation.h" +#include "../implementations/AbstractRenderbufferImplementation.h" +#include "../implementations/AbstractSamplerImplementation.h" +#include "../implementations/AbstractShaderImplementation.h" #include "../implementations/AbstractShadingLanguageIncludeImplementation.h" #include "../implementations/AbstractObjectNameImplementation.h" #include "../implementations/AbstractTextureImplementation.h" #include "../implementations/AbstractTextureStorageImplementation.h" #include "../implementations/AbstractTextureStorageMultisampleImplementation.h" +#include "../implementations/AbstractTransformFeedbackImplementation.h" #include "../implementations/AbstractVertexAttributeBindingImplementation.h" @@ -25,13 +32,20 @@ ImplementationRegistry::ImplementationRegistry() , m_bufferImplementation(nullptr) , m_framebufferImplementation(nullptr) , m_debugImplementation(nullptr) +, m_programImplementation(nullptr) , m_programBinaryImplementation(nullptr) +, m_programPipelineImplementation(nullptr) +, m_queryImplementation(nullptr) +, m_renderbufferImplementation(nullptr) +, m_samplerImplementation(nullptr) +, m_shaderImplementation(nullptr) , m_shadingLanguageIncludeImplementation(nullptr) , m_objectNameImplementation(nullptr) , m_textureBindlessImplementation(nullptr) , m_textureStorageImplementation(nullptr) , m_textureStorageMultisampleImplementation(nullptr) , m_attributeImplementation(nullptr) +, m_transformfeedbackImplementation(nullptr) { } @@ -41,13 +55,20 @@ ImplementationRegistry::~ImplementationRegistry() delete m_bufferImplementation; delete m_framebufferImplementation; delete m_debugImplementation; + delete m_programImplementation; delete m_programBinaryImplementation; + delete m_programPipelineImplementation; + delete m_queryImplementation; + delete m_renderbufferImplementation; + delete m_samplerImplementation; + delete m_shaderImplementation; delete m_shadingLanguageIncludeImplementation; delete m_objectNameImplementation; delete m_attributeImplementation; delete m_textureBindlessImplementation; delete m_textureStorageImplementation; delete m_textureStorageMultisampleImplementation; + delete m_transformfeedbackImplementation; } ImplementationRegistry & ImplementationRegistry::current() @@ -61,13 +82,20 @@ void ImplementationRegistry::initialize() m_bufferImplementation = AbstractBufferImplementation::get(); m_framebufferImplementation = AbstractFramebufferImplementation::get(); m_debugImplementation = AbstractDebugImplementation::get(); + m_programImplementation = AbstractProgramImplementation::get(); m_programBinaryImplementation = AbstractProgramBinaryImplementation::get(); + m_programPipelineImplementation = AbstractProgramPipelineImplementation::get(); + m_queryImplementation = AbstractQueryImplementation::get(); + m_renderbufferImplementation = AbstractRenderbufferImplementation::get(); + m_samplerImplementation = AbstractSamplerImplementation::get(); + m_shaderImplementation = AbstractShaderImplementation::get(); m_shadingLanguageIncludeImplementation = AbstractShadingLanguageIncludeImplementation::get(); m_objectNameImplementation = AbstractObjectNameImplementation::get(); m_attributeImplementation = AbstractVertexAttributeBindingImplementation::get(); m_textureBindlessImplementation = AbstractTextureImplementation::get(); m_textureStorageImplementation = AbstractTextureStorageImplementation::get(); m_textureStorageMultisampleImplementation = AbstractTextureStorageMultisampleImplementation::get(); + m_transformfeedbackImplementation = AbstractTransformFeedbackImplementation::get(); } void ImplementationRegistry::initialize(const AbstractUniform::BindlessImplementation impl) @@ -90,11 +118,41 @@ void ImplementationRegistry::initialize(const DebugMessage::Implementation impl) m_debugImplementation = AbstractDebugImplementation::get(impl); } +void ImplementationRegistry::initialize(const Program::Implementation impl) +{ + m_programImplementation = AbstractProgramImplementation::get(impl); +} + void ImplementationRegistry::initialize(const Program::BinaryImplementation impl) { m_programBinaryImplementation = AbstractProgramBinaryImplementation::get(impl); } +void ImplementationRegistry::initialize(const ProgramPipeline::Implementation impl) +{ + m_programPipelineImplementation = AbstractProgramPipelineImplementation::get(impl); +} + +void ImplementationRegistry::initialize(const Query::Implementation impl) +{ + m_queryImplementation = AbstractQueryImplementation::get(impl); +} + +void ImplementationRegistry::initialize(const Renderbuffer::Implementation impl) +{ + m_renderbufferImplementation = AbstractRenderbufferImplementation::get(impl); +} + +void ImplementationRegistry::initialize(const Sampler::Implementation impl) +{ + m_samplerImplementation = AbstractSamplerImplementation::get(impl); +} + +void ImplementationRegistry::initialize(const Shader::Implementation impl) +{ + m_shaderImplementation = AbstractShaderImplementation::get(impl); +} + void ImplementationRegistry::initialize(const Shader::IncludeImplementation impl) { m_shadingLanguageIncludeImplementation = AbstractShadingLanguageIncludeImplementation::get(impl); @@ -125,6 +183,11 @@ void ImplementationRegistry::initialize(Texture::StorageMultisampleImplementatio m_textureStorageMultisampleImplementation = AbstractTextureStorageMultisampleImplementation::get(impl); } +void ImplementationRegistry::initialize(const TransformFeedback::Implementation impl) +{ + m_transformfeedbackImplementation = AbstractTransformFeedbackImplementation::get(impl); +} + AbstractUniformImplementation & ImplementationRegistry::uniformImplementation() { if (!m_uniformImplementation) @@ -157,6 +220,14 @@ AbstractDebugImplementation & ImplementationRegistry::debugImplementation() return *m_debugImplementation; } +AbstractProgramImplementation & ImplementationRegistry::programImplementation() +{ + if (!m_programImplementation) + m_programImplementation = AbstractProgramImplementation::get(); + + return *m_programImplementation; +} + AbstractProgramBinaryImplementation & ImplementationRegistry::programBinaryImplementation() { if (!m_programBinaryImplementation) @@ -165,6 +236,46 @@ AbstractProgramBinaryImplementation & ImplementationRegistry::programBinaryImple return *m_programBinaryImplementation; } +AbstractProgramPipelineImplementation & ImplementationRegistry::programPipelineImplementation() +{ + if (!m_programPipelineImplementation) + m_programPipelineImplementation = AbstractProgramPipelineImplementation::get(); + + return *m_programPipelineImplementation; +} + +AbstractQueryImplementation & ImplementationRegistry::queryImplementation() +{ + if (!m_queryImplementation) + m_queryImplementation = AbstractQueryImplementation::get(); + + return *m_queryImplementation; +} + +AbstractRenderbufferImplementation & ImplementationRegistry::renderbufferImplementation() +{ + if (!m_renderbufferImplementation) + m_renderbufferImplementation = AbstractRenderbufferImplementation::get(); + + return *m_renderbufferImplementation; +} + +AbstractSamplerImplementation & ImplementationRegistry::samplerImplementation() +{ + if (!m_samplerImplementation) + m_samplerImplementation = AbstractSamplerImplementation::get(); + + return *m_samplerImplementation; +} + +AbstractShaderImplementation & ImplementationRegistry::shaderImplementation() +{ + if (!m_shaderImplementation) + m_shaderImplementation = AbstractShaderImplementation::get(); + + return *m_shaderImplementation; +} + AbstractShadingLanguageIncludeImplementation & ImplementationRegistry::shadingLanguageIncludeImplementation() { if (!m_shadingLanguageIncludeImplementation) @@ -213,5 +324,13 @@ AbstractTextureStorageMultisampleImplementation & ImplementationRegistry::textur return *m_textureStorageMultisampleImplementation; } +AbstractTransformFeedbackImplementation & ImplementationRegistry::transformfeedbackImplementation() +{ + if (!m_transformfeedbackImplementation) + m_transformfeedbackImplementation = AbstractTransformFeedbackImplementation::get(); + + return *m_transformfeedbackImplementation; +} + } // namespace globjects diff --git a/source/globjects/source/registry/ImplementationRegistry.h b/source/globjects/source/registry/ImplementationRegistry.h index 0a538473..45100de1 100644 --- a/source/globjects/source/registry/ImplementationRegistry.h +++ b/source/globjects/source/registry/ImplementationRegistry.h @@ -1,14 +1,19 @@ #pragma once -#include #include +#include #include #include #include #include #include #include +#include +#include +#include +#include +#include #include @@ -20,13 +25,20 @@ class AbstractUniformImplementation; class AbstractBufferImplementation; class AbstractFramebufferImplementation; class AbstractDebugImplementation; +class AbstractProgramImplementation; class AbstractProgramBinaryImplementation; +class AbstractProgramPipelineImplementation; +class AbstractQueryImplementation; +class AbstractRenderbufferImplementation; +class AbstractSamplerImplementation; +class AbstractShaderImplementation; class AbstractShadingLanguageIncludeImplementation; class AbstractObjectNameImplementation; class AbstractVertexAttributeBindingImplementation; class AbstractTextureImplementation; class AbstractTextureStorageImplementation; class AbstractTextureStorageMultisampleImplementation; +class AbstractTransformFeedbackImplementation; class ImplementationRegistry @@ -41,13 +53,20 @@ class ImplementationRegistry void initialize(Buffer::BindlessImplementation impl); void initialize(Framebuffer::BindlessImplementation impl); void initialize(DebugMessage::Implementation impl); + void initialize(Program::Implementation impl); void initialize(Program::BinaryImplementation impl); + void initialize(ProgramPipeline::Implementation impl); + void initialize(Query::Implementation impl); + void initialize(Renderbuffer::Implementation impl); + void initialize(Sampler::Implementation impl); + void initialize(Shader::Implementation impl); void initialize(Shader::IncludeImplementation impl); void initialize(Object::NameImplementation impl); void initialize(VertexArray::AttributeImplementation impl); void initialize(Texture::BindlessImplementation impl); void initialize(Texture::StorageImplementation impl); void initialize(Texture::StorageMultisampleImplementation impl); + void initialize(TransformFeedback::Implementation impl); static ImplementationRegistry & current(); @@ -55,13 +74,20 @@ class ImplementationRegistry AbstractBufferImplementation & bufferImplementation(); AbstractFramebufferImplementation & framebufferImplementation(); AbstractDebugImplementation & debugImplementation(); + AbstractProgramImplementation & programImplementation(); AbstractProgramBinaryImplementation & programBinaryImplementation(); + AbstractProgramPipelineImplementation & programPipelineImplementation(); + AbstractQueryImplementation & queryImplementation(); + AbstractRenderbufferImplementation & renderbufferImplementation(); + AbstractSamplerImplementation & samplerImplementation(); + AbstractShaderImplementation & shaderImplementation(); AbstractShadingLanguageIncludeImplementation & shadingLanguageIncludeImplementation(); AbstractObjectNameImplementation & objectNameImplementation(); AbstractVertexAttributeBindingImplementation & attributeImplementation(); AbstractTextureImplementation & textureBindlessImplementation(); AbstractTextureStorageImplementation & textureStorageImplementation(); AbstractTextureStorageMultisampleImplementation & textureStorageMultisampleImplementation(); + AbstractTransformFeedbackImplementation & transformfeedbackImplementation(); protected: @@ -69,13 +95,20 @@ class ImplementationRegistry AbstractBufferImplementation * m_bufferImplementation; AbstractFramebufferImplementation * m_framebufferImplementation; AbstractDebugImplementation * m_debugImplementation; + AbstractProgramImplementation * m_programImplementation; AbstractProgramBinaryImplementation * m_programBinaryImplementation; + AbstractProgramPipelineImplementation * m_programPipelineImplementation; + AbstractQueryImplementation * m_queryImplementation; + AbstractRenderbufferImplementation * m_renderbufferImplementation; + AbstractSamplerImplementation * m_samplerImplementation; + AbstractShaderImplementation * m_shaderImplementation; AbstractShadingLanguageIncludeImplementation * m_shadingLanguageIncludeImplementation; AbstractObjectNameImplementation * m_objectNameImplementation; AbstractTextureImplementation * m_textureBindlessImplementation; AbstractTextureStorageImplementation * m_textureStorageImplementation; AbstractTextureStorageMultisampleImplementation * m_textureStorageMultisampleImplementation; AbstractVertexAttributeBindingImplementation * m_attributeImplementation; + AbstractTransformFeedbackImplementation * m_transformfeedbackImplementation; };