mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-29 19:42:53 +02:00
Mipmap generation, trilinear,anisotropic filtering for OffscreenQmlSurface
This commit is contained in:
parent
af2c31f29b
commit
df17913801
3 changed files with 27 additions and 11 deletions
|
@ -166,7 +166,7 @@ private:
|
||||||
QMyQuickRenderControl* _renderControl{ nullptr };
|
QMyQuickRenderControl* _renderControl{ nullptr };
|
||||||
FramebufferPtr _fbo;
|
FramebufferPtr _fbo;
|
||||||
RenderbufferPtr _depthStencil;
|
RenderbufferPtr _depthStencil;
|
||||||
TextureRecycler _textures;
|
TextureRecycler _textures { true };
|
||||||
GLTextureEscrow _escrow;
|
GLTextureEscrow _escrow;
|
||||||
|
|
||||||
uint64_t _lastRenderTime{ 0 };
|
uint64_t _lastRenderTime{ 0 };
|
||||||
|
@ -399,6 +399,8 @@ void OffscreenQmlRenderThread::render() {
|
||||||
glGetError();
|
glGetError();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Context::Bound(oglplus::Texture::Target::_2D, *texture).GenerateMipmap();
|
||||||
|
|
||||||
// FIXME probably unecessary
|
// FIXME probably unecessary
|
||||||
DefaultFramebuffer().Bind(Framebuffer::Target::Draw);
|
DefaultFramebuffer().Bind(Framebuffer::Target::Draw);
|
||||||
_quickWindow->resetOpenGLState();
|
_quickWindow->resetOpenGLState();
|
||||||
|
|
|
@ -509,16 +509,28 @@ TexturePtr TextureRecycler::getNextTexture() {
|
||||||
using namespace oglplus;
|
using namespace oglplus;
|
||||||
if (_readyTextures.empty()) {
|
if (_readyTextures.empty()) {
|
||||||
TexturePtr newTexture(new Texture());
|
TexturePtr newTexture(new Texture());
|
||||||
Context::Bound(oglplus::Texture::Target::_2D, *newTexture)
|
|
||||||
.MinFilter(TextureMinFilter::Linear)
|
if (_useMipmaps) {
|
||||||
.MagFilter(TextureMagFilter::Linear)
|
Context::Bound(oglplus::Texture::Target::_2D, *newTexture)
|
||||||
.WrapS(TextureWrap::ClampToEdge)
|
.MinFilter(TextureMinFilter::LinearMipmapLinear)
|
||||||
.WrapT(TextureWrap::ClampToEdge)
|
.MagFilter(TextureMagFilter::Linear)
|
||||||
.Image2D(
|
.WrapS(TextureWrap::ClampToEdge)
|
||||||
0, PixelDataInternalFormat::RGBA8,
|
.WrapT(TextureWrap::ClampToEdge)
|
||||||
_size.x, _size.y,
|
.Anisotropy(8.0f)
|
||||||
0, PixelDataFormat::RGB, PixelDataType::UnsignedByte, nullptr
|
.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);
|
GLuint texId = GetName(*newTexture);
|
||||||
_allTextures[texId] = TexInfo{ newTexture, _size };
|
_allTextures[texId] = TexInfo{ newTexture, _size };
|
||||||
_readyTextures.push(newTexture);
|
_readyTextures.push(newTexture);
|
||||||
|
|
|
@ -190,6 +190,7 @@ using BasicFramebufferWrapperPtr = std::shared_ptr<BasicFramebufferWrapper>;
|
||||||
|
|
||||||
class TextureRecycler {
|
class TextureRecycler {
|
||||||
public:
|
public:
|
||||||
|
TextureRecycler(bool useMipmaps) : _useMipmaps(useMipmaps) {}
|
||||||
void setSize(const uvec2& size);
|
void setSize(const uvec2& size);
|
||||||
void clear();
|
void clear();
|
||||||
TexturePtr getNextTexture();
|
TexturePtr getNextTexture();
|
||||||
|
@ -212,4 +213,5 @@ private:
|
||||||
Map _allTextures;
|
Map _allTextures;
|
||||||
Queue _readyTextures;
|
Queue _readyTextures;
|
||||||
uvec2 _size{ 1920, 1080 };
|
uvec2 _size{ 1920, 1080 };
|
||||||
|
bool _useMipmaps;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue