diff --git a/framework/opengl_primitives/src/mm/opengl/fbo_builder.cpp b/framework/opengl_primitives/src/mm/opengl/fbo_builder.cpp index 91ac4f8..c52c4d3 100644 --- a/framework/opengl_primitives/src/mm/opengl/fbo_builder.cpp +++ b/framework/opengl_primitives/src/mm/opengl/fbo_builder.cpp @@ -47,7 +47,11 @@ FBOBuilder& FBOBuilder::attachTexture(std::shared_ptr tex, GLuint attac } //glFramebufferTexture2D(target, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, tex->getHandle(), 0); - glFramebufferTexture2D(target, attachment_type, GL_TEXTURE_2D, tex->getHandle(), 0); + if (tex->samples == 0u) { + glFramebufferTexture2D(target, attachment_type, GL_TEXTURE_2D, tex->getHandle(), 0); + } else { + glFramebufferTexture2D(target, attachment_type, GL_TEXTURE_2D_MULTISAMPLE, tex->getHandle(), 0); + } _fbo->_texAttachments.push_back(tex); // keep a ref at the fbo return *this; diff --git a/framework/opengl_primitives/src/mm/opengl/texture.cpp b/framework/opengl_primitives/src/mm/opengl/texture.cpp index 7e99e1d..be9f766 100644 --- a/framework/opengl_primitives/src/mm/opengl/texture.cpp +++ b/framework/opengl_primitives/src/mm/opengl/texture.cpp @@ -17,10 +17,10 @@ Texture::Texture( uint32_t handle, int32_t width_, int32_t height_, int32_t internalFormat, int32_t format, int32_t type, - uint32_t samples + uint32_t samples_ ) : _handle(handle), width(width_), height(height_), - _internalFormat(internalFormat), _format(format), _type(type), - _samples(samples) { + samples(samples_), + _internalFormat(internalFormat), _format(format), _type(type) { } Texture::~Texture(void) { @@ -34,7 +34,7 @@ void Texture::unbind(void) const { void Texture::bind(uint32_t slot) const { glActiveTexture(GL_TEXTURE0 + slot); - if (_samples == 0) { + if (samples == 0) { glBindTexture(GL_TEXTURE_2D, _handle); } else { glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, _handle); @@ -44,12 +44,12 @@ void Texture::bind(uint32_t slot) const { void Texture::resize(int32_t new_width, int32_t new_height) { // if (glTexImage2D == true) - if (_samples == 0) { + if (samples == 0) { glBindTexture(GL_TEXTURE_2D, _handle); glTexImage2D(GL_TEXTURE_2D, 0, _internalFormat, new_width, new_height, 0, _format, _type, NULL); } else { glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, _handle); - glTexImage2DMultisample(GL_TEXTURE_2D_MULTISAMPLE, _samples, _internalFormat, new_width, new_height, 0); + glTexImage2DMultisample(GL_TEXTURE_2D_MULTISAMPLE, samples, _internalFormat, new_width, new_height, 0); } // HACK: super dirty diff --git a/framework/opengl_primitives/src/mm/opengl/texture.hpp b/framework/opengl_primitives/src/mm/opengl/texture.hpp index 8f9603b..fd5771c 100644 --- a/framework/opengl_primitives/src/mm/opengl/texture.hpp +++ b/framework/opengl_primitives/src/mm/opengl/texture.hpp @@ -30,11 +30,12 @@ namespace MM::OpenGL { int32_t const width; int32_t const height; //int32_t const bpp; // bits per pixel + uint32_t const samples{0u}; // sample count, 0 == off + private: int32_t const _internalFormat; int32_t const _format; int32_t const _type; - uint32_t const _samples{0u}; // sample count, 0 == off public: ~Texture(); diff --git a/framework/opengl_primitives/src/mm/opengl/texture_loader.hpp b/framework/opengl_primitives/src/mm/opengl/texture_loader.hpp index 94215b1..025ef7d 100644 --- a/framework/opengl_primitives/src/mm/opengl/texture_loader.hpp +++ b/framework/opengl_primitives/src/mm/opengl/texture_loader.hpp @@ -31,5 +31,12 @@ namespace MM::OpenGL { } }; + struct TextureLoaderEmptyMultiSampled final { + template + std::shared_ptr load(Args&& ... args) const { + return Texture::createEmptyMultiSampled(std::forward(args)...); + } + }; + } // MM::OpenGL