mirror of
https://github.com/outbackdingo/UltraGrid.git
synced 2026-03-22 08:40:28 +00:00
gl_utils: Make it harder to use uinitialized texture
This commit is contained in:
@@ -367,6 +367,11 @@ void Texture::init(){
|
||||
glGenBuffers(1, &pbo);
|
||||
}
|
||||
|
||||
void Texture::bind() {
|
||||
init();
|
||||
glBindTexture(GL_TEXTURE_2D, tex_id);
|
||||
}
|
||||
|
||||
|
||||
void Framebuffer::attach_texture(GLuint tex){
|
||||
glBindTexture(GL_TEXTURE_2D, tex);
|
||||
@@ -383,7 +388,7 @@ void Framebuffer::attach_texture(GLuint tex){
|
||||
|
||||
void FrameUploader::put_frame(video_frame *f, bool pbo_frame){
|
||||
assert(tex);
|
||||
glBindTexture(GL_TEXTURE_2D, tex->get());
|
||||
tex->bind();
|
||||
tex->allocate(f->tiles[0].width, f->tiles[0].height, GL_RGB);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
|
||||
@@ -57,6 +57,7 @@
|
||||
//#include <SDL2/SDL_opengl.h>
|
||||
#include <mutex>
|
||||
#include <memory>
|
||||
#include <cassert>
|
||||
|
||||
#include "types.h"
|
||||
|
||||
@@ -149,9 +150,9 @@ public:
|
||||
~Texture();
|
||||
|
||||
/**
|
||||
* Returns the underlying OpenGL texture id
|
||||
* Returns the underlying OpenGL texture id.
|
||||
*/
|
||||
GLuint get() const { return tex_id; }
|
||||
GLuint get() const { assert(tex_id); return tex_id; }
|
||||
|
||||
/**
|
||||
* Allocates the the storage for the texture according to requested
|
||||
@@ -163,6 +164,13 @@ public:
|
||||
*/
|
||||
void allocate(int w, int h, GLint internal_fmt);
|
||||
|
||||
/**
|
||||
* Creates the actual OpenGL texture objects if not yet created
|
||||
*/
|
||||
void init();
|
||||
|
||||
void bind();
|
||||
|
||||
/**
|
||||
* Uploads video frame to the texture
|
||||
*
|
||||
@@ -189,7 +197,6 @@ public:
|
||||
std::swap(pbo, o.pbo);
|
||||
}
|
||||
private:
|
||||
void init();
|
||||
|
||||
/**
|
||||
* Uploads image data to the texture
|
||||
|
||||
Reference in New Issue
Block a user