gl: Track image destruction and remove handles from state tracker

- Handles are reused for different resources which can cause problems
This commit is contained in:
kd-11 2022-06-04 01:56:01 +03:00 committed by kd-11
parent d577cebd89
commit 8185bfe893
4 changed files with 39 additions and 11 deletions

View file

@ -123,6 +123,13 @@ namespace gl
m_format_class = format_class;
}
texture::~texture()
{
gl::get_command_context()->unbind_texture(static_cast<GLenum>(m_target), m_id);
glDeleteTextures(1, &m_id);
m_id = GL_NONE;
}
void texture::copy_from(const void* src, texture::format format, texture::type type, int level, const coord3u region, const pixel_unpack_settings& pixel_settings)
{
pixel_settings.apply();
@ -260,6 +267,13 @@ namespace gl
}
}
texture_view::~texture_view()
{
gl::get_command_context()->unbind_texture(static_cast<GLenum>(m_target), m_id);
glDeleteTextures(1, &m_id);
m_id = GL_NONE;
}
void texture_view::bind(gl::command_context& cmd, GLuint layer) const
{
cmd->bind_texture(layer, m_target, m_id);