mirror of
https://github.com/brunoherbelin/vimix.git
synced 2025-12-12 02:40:00 +01:00
Correct implementation of DeviceSource resize
previous commit was bad...
This commit is contained in:
@@ -384,13 +384,14 @@ void DeviceSource::setDevice(const std::string &devicename)
|
|||||||
|
|
||||||
pipeline << " ! videoconvert";
|
pipeline << " ! videoconvert";
|
||||||
|
|
||||||
dettach();
|
// resize render buffer
|
||||||
|
if (renderbuffer_)
|
||||||
|
renderbuffer_->resize(best.width, best.height);
|
||||||
|
|
||||||
// open gstreamer
|
// open gstreamer
|
||||||
stream_->open( pipeline.str(), best.width, best.height);
|
stream_->open( pipeline.str(), best.width, best.height);
|
||||||
stream_->play(true);
|
stream_->play(true);
|
||||||
|
|
||||||
|
|
||||||
// will be ready after init and one frame rendered
|
// will be ready after init and one frame rendered
|
||||||
ready_ = false;
|
ready_ = false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -171,6 +171,31 @@ glm::vec3 FrameBuffer::resolution() const
|
|||||||
return glm::vec3(attrib_.viewport.x, attrib_.viewport.y, 0.f);
|
return glm::vec3(attrib_.viewport.x, attrib_.viewport.y, 0.f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FrameBuffer::resize(int width, int height)
|
||||||
|
{
|
||||||
|
if (framebufferid_) {
|
||||||
|
if (attrib_.viewport.x != width || attrib_.viewport.y != height)
|
||||||
|
{
|
||||||
|
// de-init
|
||||||
|
glDeleteFramebuffers(1, &framebufferid_);
|
||||||
|
framebufferid_ = 0;
|
||||||
|
|
||||||
|
if (intermediate_framebufferid_)
|
||||||
|
glDeleteFramebuffers(1, &intermediate_framebufferid_);
|
||||||
|
intermediate_framebufferid_ = 0;
|
||||||
|
if (textureid_)
|
||||||
|
glDeleteTextures(1, &textureid_);
|
||||||
|
textureid_ = 0;
|
||||||
|
if (intermediate_textureid_)
|
||||||
|
glDeleteTextures(1, &intermediate_textureid_);
|
||||||
|
intermediate_textureid_ = 0;
|
||||||
|
|
||||||
|
// change resolution
|
||||||
|
attrib_.viewport = glm::ivec2(width, height);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void FrameBuffer::begin(bool clear)
|
void FrameBuffer::begin(bool clear)
|
||||||
{
|
{
|
||||||
if (!framebufferid_)
|
if (!framebufferid_)
|
||||||
|
|||||||
@@ -69,6 +69,7 @@ public:
|
|||||||
inline uint width() const { return attrib_.viewport.x; }
|
inline uint width() const { return attrib_.viewport.x; }
|
||||||
inline uint height() const { return attrib_.viewport.y; }
|
inline uint height() const { return attrib_.viewport.y; }
|
||||||
glm::vec3 resolution() const;
|
glm::vec3 resolution() const;
|
||||||
|
void resize(int width, int height);
|
||||||
float aspectRatio() const;
|
float aspectRatio() const;
|
||||||
std::string info() const;
|
std::string info() const;
|
||||||
|
|
||||||
|
|||||||
@@ -425,14 +425,6 @@ void Source::render()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Source::dettach()
|
|
||||||
{
|
|
||||||
// replace renderbuffer_
|
|
||||||
if (renderbuffer_)
|
|
||||||
delete renderbuffer_;
|
|
||||||
renderbuffer_ = nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Source::attach(FrameBuffer *renderbuffer)
|
void Source::attach(FrameBuffer *renderbuffer)
|
||||||
{
|
{
|
||||||
// invalid argument
|
// invalid argument
|
||||||
|
|||||||
1
Source.h
1
Source.h
@@ -246,7 +246,6 @@ protected:
|
|||||||
// NB: rendershader_ is applied at render()
|
// NB: rendershader_ is applied at render()
|
||||||
FrameBuffer *renderbuffer_;
|
FrameBuffer *renderbuffer_;
|
||||||
void attach(FrameBuffer *renderbuffer);
|
void attach(FrameBuffer *renderbuffer);
|
||||||
void dettach() ;
|
|
||||||
|
|
||||||
// the rendersurface draws the renderbuffer in the scene
|
// the rendersurface draws the renderbuffer in the scene
|
||||||
// It is associated to the rendershader for mixing effects
|
// It is associated to the rendershader for mixing effects
|
||||||
|
|||||||
Reference in New Issue
Block a user