diff --git a/libraries/gl/src/gl/OffscreenQmlSurface.cpp b/libraries/gl/src/gl/OffscreenQmlSurface.cpp index 366bc96ca3..c47312f9f6 100644 --- a/libraries/gl/src/gl/OffscreenQmlSurface.cpp +++ b/libraries/gl/src/gl/OffscreenQmlSurface.cpp @@ -166,7 +166,7 @@ private: QMyQuickRenderControl* _renderControl{ nullptr }; FramebufferPtr _fbo; RenderbufferPtr _depthStencil; - TextureRecycler _textures; + TextureRecycler _textures { true }; GLTextureEscrow _escrow; uint64_t _lastRenderTime{ 0 }; @@ -399,6 +399,8 @@ void OffscreenQmlRenderThread::render() { glGetError(); } + Context::Bound(oglplus::Texture::Target::_2D, *texture).GenerateMipmap(); + // FIXME probably unecessary DefaultFramebuffer().Bind(Framebuffer::Target::Draw); _quickWindow->resetOpenGLState(); diff --git a/libraries/gl/src/gl/OglplusHelpers.cpp b/libraries/gl/src/gl/OglplusHelpers.cpp index 1154042b4a..d31800dc4c 100644 --- a/libraries/gl/src/gl/OglplusHelpers.cpp +++ b/libraries/gl/src/gl/OglplusHelpers.cpp @@ -509,16 +509,28 @@ TexturePtr TextureRecycler::getNextTexture() { using namespace oglplus; if (_readyTextures.empty()) { TexturePtr newTexture(new Texture()); - Context::Bound(oglplus::Texture::Target::_2D, *newTexture) - .MinFilter(TextureMinFilter::Linear) - .MagFilter(TextureMagFilter::Linear) - .WrapS(TextureWrap::ClampToEdge) - .WrapT(TextureWrap::ClampToEdge) - .Image2D( - 0, PixelDataInternalFormat::RGBA8, - _size.x, _size.y, - 0, PixelDataFormat::RGB, PixelDataType::UnsignedByte, nullptr - ); + + if (_useMipmaps) { + Context::Bound(oglplus::Texture::Target::_2D, *newTexture) + .MinFilter(TextureMinFilter::LinearMipmapLinear) + .MagFilter(TextureMagFilter::Linear) + .WrapS(TextureWrap::ClampToEdge) + .WrapT(TextureWrap::ClampToEdge) + .Anisotropy(8.0f) + .LODBias(-0.2f) + .Image2D(0, PixelDataInternalFormat::RGBA8, + _size.x, _size.y, + 0, PixelDataFormat::RGB, PixelDataType::UnsignedByte, nullptr); + } else { + Context::Bound(oglplus::Texture::Target::_2D, *newTexture) + .MinFilter(TextureMinFilter::Linear) + .MagFilter(TextureMagFilter::Linear) + .WrapS(TextureWrap::ClampToEdge) + .WrapT(TextureWrap::ClampToEdge) + .Image2D(0, PixelDataInternalFormat::RGBA8, + _size.x, _size.y, + 0, PixelDataFormat::RGB, PixelDataType::UnsignedByte, nullptr); + } GLuint texId = GetName(*newTexture); _allTextures[texId] = TexInfo{ newTexture, _size }; _readyTextures.push(newTexture); diff --git a/libraries/gl/src/gl/OglplusHelpers.h b/libraries/gl/src/gl/OglplusHelpers.h index fe5822c4be..ab47689312 100644 --- a/libraries/gl/src/gl/OglplusHelpers.h +++ b/libraries/gl/src/gl/OglplusHelpers.h @@ -190,6 +190,7 @@ using BasicFramebufferWrapperPtr = std::shared_ptr; class TextureRecycler { public: + TextureRecycler(bool useMipmaps) : _useMipmaps(useMipmaps) {} void setSize(const uvec2& size); void clear(); TexturePtr getNextTexture(); @@ -212,4 +213,5 @@ private: Map _allTextures; Queue _readyTextures; uvec2 _size{ 1920, 1080 }; + bool _useMipmaps; };