OpenGLRenderer: Implement texture blit/copy if glCopyImageSubData is not supported

This commit is contained in:
Jérôme Leclercq
2021-09-21 17:39:24 +02:00
parent 4933a389a2
commit 7ab4d91900
4 changed files with 124 additions and 26 deletions

View File

@@ -64,25 +64,7 @@ namespace Nz
const OpenGLTexture& glTexture = static_cast<const OpenGLTexture&>(source);
const GL::Context& context = m_texture.EnsureDeviceContext();
// Use glCopyImageSubData if available
if (context.glCopyImageSubData)
{
GLuint srcImage = glTexture.GetTexture().GetObjectId();
GLenum srcTarget = ToOpenGL(ToTextureTarget(glTexture.GetType()));
GLuint dstImage = m_texture.GetObjectId();
GLenum dstTarget = ToOpenGL(ToTextureTarget(m_params.type));
context.glCopyImageSubData(srcImage, srcTarget, 0, GLint(srcBox.x), GLint(srcBox.y), GLint(srcBox.z), dstImage, dstTarget, 0, GLint(dstPos.x), GLint(dstPos.y), GLint(dstPos.z), GLsizei(srcBox.width), GLsizei(srcBox.height), GLsizei(srcBox.depth));
return true;
}
else
{
//TODO: Blit using framebuffers
}
return false;
return context.CopyTexture(glTexture.GetTexture(), m_texture, srcBox, dstPos);
}
PixelFormat OpenGLTexture::GetFormat() const