enforce trilinear and mipmap generation

This commit is contained in:
itsmattkc
2019-03-28 18:21:35 +11:00
parent c468d023b0
commit 4e0188fd3a
7 changed files with 32 additions and 18 deletions
+12 -10
View File
@@ -26,37 +26,39 @@ void FramebufferObject::Create(QOpenGLContext *ctx, int width, int height)
// set context to new context provided
ctx_ = ctx;
QOpenGLFunctions* f = ctx->functions();
// create framebuffer object
ctx->functions()->glGenFramebuffers(1, &buffer_);
f->glGenFramebuffers(1, &buffer_);
// create texture
ctx->functions()->glGenTextures(1, &texture_);
f->glGenTextures(1, &texture_);
// bind framebuffer for attaching
ctx->functions()->glBindFramebuffer(GL_DRAW_FRAMEBUFFER, buffer_);
f->glBindFramebuffer(GL_DRAW_FRAMEBUFFER, buffer_);
// bind texture
ctx->functions()->glBindTexture(GL_TEXTURE_2D, texture_);
f->glBindTexture(GL_TEXTURE_2D, texture_);
// allocate storage for texture
ctx->functions()->glTexImage2D(
f->glTexImage2D(
GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr
);
// set texture filtering to bilinear
ctx->functions()->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
ctx->functions()->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
f->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
f->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
// attach texture to framebuffer
ctx->functions()->glFramebufferTexture2D(
f->glFramebufferTexture2D(
GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture_, 0
);
// release texture
ctx->functions()->glBindTexture(GL_TEXTURE_2D, 0);
f->glBindTexture(GL_TEXTURE_2D, 0);
// release framebuffer
ctx->functions()->glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
f->glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
}
void FramebufferObject::Destroy()