BugFix Stream: ensure replacement of texture on re-open

This commit is contained in:
Bruno Herbelin
2023-03-04 13:25:12 +01:00
parent 207aa88daf
commit c25d4b7dad

View File

@@ -105,7 +105,7 @@ std::string Stream::decoderName()
guint Stream::texture() const guint Stream::texture() const
{ {
if (textureindex_ == 0) if (!textureindex_)
return Resource::getTextureBlack(); return Resource::getTextureBlack();
return textureindex_; return textureindex_;
@@ -518,8 +518,9 @@ GstClockTime Stream::position()
void Stream::init_texture(guint index) void Stream::init_texture(guint index)
{ {
glActiveTexture(GL_TEXTURE0); glActiveTexture(GL_TEXTURE0);
if (textureindex_ < 1) if (textureindex_)
glGenTextures(1, &textureindex_); glDeleteTextures(1, &textureindex_);
glGenTextures(1, &textureindex_);
glBindTexture(GL_TEXTURE_2D, textureindex_); glBindTexture(GL_TEXTURE_2D, textureindex_);
glTexStorage2D(GL_TEXTURE_2D, 1, GL_RGBA8, width_, height_); glTexStorage2D(GL_TEXTURE_2D, 1, GL_RGBA8, width_, height_);
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, width_, height_, glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, width_, height_,
@@ -582,7 +583,7 @@ void Stream::init_texture(guint index)
void Stream::fill_texture(guint index) void Stream::fill_texture(guint index)
{ {
// is this the first frame ? // is this the first frame ?
if ( !textureinitialized_ || textureindex_ < 1) if ( !textureinitialized_ || !textureindex_)
{ {
// initialize texture // initialize texture
init_texture(index); init_texture(index);