mirror of
https://github.com/brunoherbelin/vimix.git
synced 2025-12-13 11:19:58 +01:00
opengl good practice: unbind texture after set
This commit is contained in:
@@ -146,6 +146,7 @@ void FrameGrabbing::grabFrame(FrameBuffer *frame_buffer, float dt)
|
||||
#else
|
||||
glBindTexture(GL_TEXTURE_2D, frame_buffer->texture());
|
||||
glGetTexImage(GL_TEXTURE_2D, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
|
||||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
#endif
|
||||
|
||||
// update case ; alternating indices
|
||||
|
||||
@@ -225,8 +225,9 @@ void MediaPlayer::open(string path)
|
||||
// set uri to open
|
||||
uri_ = GstToolkit::filename_to_uri(path);
|
||||
|
||||
// reset
|
||||
ready_ = false;
|
||||
// close before re-openning
|
||||
if (isOpen())
|
||||
close();
|
||||
|
||||
// start URI discovering thread:
|
||||
discoverer_ = std::async( UriDiscoverer_, uri_);
|
||||
@@ -507,7 +508,7 @@ GstClockTime MediaPlayer::position()
|
||||
|
||||
void MediaPlayer::enable(bool on)
|
||||
{
|
||||
if ( !ready_ )
|
||||
if ( !ready_ || pipeline_ == nullptr)
|
||||
return;
|
||||
|
||||
if ( enabled_ != on ) {
|
||||
@@ -772,6 +773,7 @@ void MediaPlayer::init_texture(guint index)
|
||||
// for possible hadrware decoding plugins used. Empty string means none.
|
||||
hardware_decoder_ = GstToolkit::used_gpu_decoding_plugins(pipeline_);
|
||||
}
|
||||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
}
|
||||
|
||||
|
||||
@@ -819,6 +821,7 @@ void MediaPlayer::fill_texture(guint index)
|
||||
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, media_.width, media_.height,
|
||||
GL_RGBA, GL_UNSIGNED_BYTE, frame_[index].vframe.data[0]);
|
||||
}
|
||||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -679,7 +679,7 @@ uint textureMixingQuadratic()
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
}
|
||||
return texid;
|
||||
}
|
||||
|
||||
@@ -38,6 +38,7 @@ uint Resource::getTextureBlack()
|
||||
// texture with one black pixel
|
||||
glTexStorage2D(GL_TEXTURE_2D, 1, GL_RGBA8, 1, 1);
|
||||
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, clearColor);
|
||||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
}
|
||||
|
||||
return tex_index_black;
|
||||
@@ -59,6 +60,7 @@ uint Resource::getTextureWhite()
|
||||
// texture with one black pixel
|
||||
glTexStorage2D(GL_TEXTURE_2D, 1, GL_RGBA8, 1, 1);
|
||||
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, clearColor);
|
||||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
}
|
||||
|
||||
return tex_index_white;
|
||||
@@ -80,6 +82,7 @@ uint Resource::getTextureTransparent()
|
||||
// texture with one black pixel
|
||||
glTexStorage2D(GL_TEXTURE_2D, 1, GL_RGBA8, 1, 1);
|
||||
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, clearColor);
|
||||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
}
|
||||
|
||||
return tex_index_transparent;
|
||||
@@ -219,6 +222,7 @@ uint Resource::getTextureDDS(const std::string& path, float *aspect_ratio)
|
||||
if(height < 1) height = 1;
|
||||
|
||||
}
|
||||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
|
||||
// remember to avoid openning the same resource twice
|
||||
textureIndex[path] = textureID;
|
||||
@@ -276,6 +280,7 @@ uint Resource::getTextureImage(const std::string& path, float *aspect_ratio)
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
|
||||
// free memory
|
||||
stbi_image_free(img);
|
||||
|
||||
Reference in New Issue
Block a user