Common/GL: Add replace method to texture
This commit is contained in:
parent
ecbfff3c60
commit
ebaad0f35a
|
@ -36,6 +36,7 @@ bool Texture::Create(u32 width, u32 height, u32 samples, GLenum internal_format,
|
|||
|
||||
if (samples > 1)
|
||||
{
|
||||
Assert(!data);
|
||||
if (GLAD_GL_ARB_texture_storage || GLAD_GL_ES_VERSION_3_1)
|
||||
glTexStorage2DMultisample(target, samples, internal_format, width, height, GL_FALSE);
|
||||
else
|
||||
|
@ -43,7 +44,7 @@ bool Texture::Create(u32 width, u32 height, u32 samples, GLenum internal_format,
|
|||
}
|
||||
else
|
||||
{
|
||||
if (GLAD_GL_ARB_texture_storage || GLAD_GL_ES_VERSION_3_0)
|
||||
if ((GLAD_GL_ARB_texture_storage || GLAD_GL_ES_VERSION_3_0) && !data)
|
||||
glTexStorage2D(target, 1, internal_format, width, height);
|
||||
else
|
||||
glTexImage2D(target, 0, internal_format, width, height, 0, format, type, data);
|
||||
|
@ -74,6 +75,17 @@ bool Texture::Create(u32 width, u32 height, u32 samples, GLenum internal_format,
|
|||
return true;
|
||||
}
|
||||
|
||||
void Texture::Replace(u32 width, u32 height, GLenum internal_format, GLenum format, GLenum type, const void* data)
|
||||
{
|
||||
Assert(IsValid() && m_samples == 1);
|
||||
|
||||
m_width = width;
|
||||
m_height = height;
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, m_id);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, internal_format, width, height, 0, format, type, data);
|
||||
}
|
||||
|
||||
void Texture::SetLinearFilter(bool enabled)
|
||||
{
|
||||
Assert(!IsMultisampled());
|
||||
|
|
|
@ -12,6 +12,7 @@ public:
|
|||
|
||||
bool Create(u32 width, u32 height, u32 samples, GLenum internal_format, GLenum format, GLenum type,
|
||||
const void* data = nullptr, bool linear_filter = false, bool wrap = false);
|
||||
void Replace(u32 width, u32 height, GLenum internal_format, GLenum format, GLenum type, const void* data);
|
||||
bool CreateFramebuffer();
|
||||
|
||||
void Destroy();
|
||||
|
|
Loading…
Reference in New Issue