mirror of
https://github.com/RetroDECK/Duckstation.git
synced 2024-11-26 23:55:40 +00:00
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)
|
if (samples > 1)
|
||||||
{
|
{
|
||||||
|
Assert(!data);
|
||||||
if (GLAD_GL_ARB_texture_storage || GLAD_GL_ES_VERSION_3_1)
|
if (GLAD_GL_ARB_texture_storage || GLAD_GL_ES_VERSION_3_1)
|
||||||
glTexStorage2DMultisample(target, samples, internal_format, width, height, GL_FALSE);
|
glTexStorage2DMultisample(target, samples, internal_format, width, height, GL_FALSE);
|
||||||
else
|
else
|
||||||
|
@ -43,7 +44,7 @@ bool Texture::Create(u32 width, u32 height, u32 samples, GLenum internal_format,
|
||||||
}
|
}
|
||||||
else
|
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);
|
glTexStorage2D(target, 1, internal_format, width, height);
|
||||||
else
|
else
|
||||||
glTexImage2D(target, 0, internal_format, width, height, 0, format, type, data);
|
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;
|
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)
|
void Texture::SetLinearFilter(bool enabled)
|
||||||
{
|
{
|
||||||
Assert(!IsMultisampled());
|
Assert(!IsMultisampled());
|
||||||
|
|
|
@ -12,6 +12,7 @@ public:
|
||||||
|
|
||||||
bool Create(u32 width, u32 height, u32 samples, GLenum internal_format, GLenum format, GLenum type,
|
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);
|
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();
|
bool CreateFramebuffer();
|
||||||
|
|
||||||
void Destroy();
|
void Destroy();
|
||||||
|
|
Loading…
Reference in a new issue