Added initial texture read back support.

This commit is contained in:
Branimir Karadžić
2015-10-20 16:32:08 -07:00
parent 1be1714780
commit 6aa6efda12
14 changed files with 232 additions and 10 deletions

View File

@@ -1204,6 +1204,7 @@ namespace bgfx { namespace gl
, m_maxMsaa(0)
, m_vao(0)
, m_blitSupported(false)
, m_readBackSupported(false)
, m_vaoSupport(false)
, m_samplerObjectSupport(false)
, m_shadowSamplersSupport(false)
@@ -1713,7 +1714,7 @@ namespace bgfx { namespace gl
{
m_blitSupported = NULL != glCopyImageSubData;
g_caps.supported |= m_blitSupported
? BGFX_CAPS_BLIT
? BGFX_CAPS_TEXTURE_BLIT
: 0
;
}
@@ -2093,6 +2094,36 @@ namespace bgfx { namespace gl
{
}
void readTexture(TextureHandle _handle, void* _data) BX_OVERRIDE
{
if (m_readBackSupported)
{
const TextureGL& texture = m_textures[_handle.idx];
const bool compressed = isCompressed(TextureFormat::Enum(texture.m_textureFormat) );
GL_CHECK(glBindTexture(texture.m_target, texture.m_id) );
if (compressed)
{
GL_CHECK(glGetCompressedTexImage(texture.m_target
, 0
, _data
) );
}
else
{
GL_CHECK(glGetTexImage(texture.m_target
, 0
, texture.m_fmt
, texture.m_type
, _data
) );
}
GL_CHECK(glBindTexture(texture.m_target, 0) );
}
}
void resizeTexture(TextureHandle _handle, uint16_t _width, uint16_t _height) BX_OVERRIDE
{
TextureGL& texture = m_textures[_handle.idx];
@@ -3106,6 +3137,7 @@ namespace bgfx { namespace gl
int32_t m_maxMsaa;
GLuint m_vao;
bool m_blitSupported;
bool m_readBackSupported;
bool m_vaoSupport;
bool m_samplerObjectSupport;
bool m_shadowSamplersSupport;