mirror of
https://github.com/brunoherbelin/vimix.git
synced 2025-12-11 18:34:58 +01:00
Fixed Session Render Source (self-referenced session, not global).
This commit is contained in:
@@ -256,7 +256,7 @@ Source * Mixer::createSourceFile(std::string path)
|
|||||||
Source * Mixer::createSourceRender()
|
Source * Mixer::createSourceRender()
|
||||||
{
|
{
|
||||||
// ready to create a source
|
// ready to create a source
|
||||||
RenderSource *s = new RenderSource;
|
RenderSource *s = new RenderSource(session_);
|
||||||
|
|
||||||
// propose a new name based on session name
|
// propose a new name based on session name
|
||||||
renameSource(s, SystemToolkit::base_filename(session_->filename()));
|
renameSource(s, SystemToolkit::base_filename(session_->filename()));
|
||||||
|
|||||||
@@ -81,7 +81,7 @@ void SessionCreator::loadSession(XMLElement *sessionNode)
|
|||||||
session_->addSource(new_session_source);
|
session_->addSource(new_session_source);
|
||||||
}
|
}
|
||||||
else if ( std::string(pType) == "RenderSource") {
|
else if ( std::string(pType) == "RenderSource") {
|
||||||
RenderSource *new_render_source = new RenderSource();
|
RenderSource *new_render_source = new RenderSource(session_);
|
||||||
new_render_source->accept(*this);
|
new_render_source->accept(*this);
|
||||||
session_->addSource(new_render_source);
|
session_->addSource(new_render_source);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -95,12 +95,14 @@ bool SessionSource::failed() const
|
|||||||
|
|
||||||
uint SessionSource::texture() const
|
uint SessionSource::texture() const
|
||||||
{
|
{
|
||||||
|
if (session_ == nullptr)
|
||||||
|
return Resource::getTextureBlack();
|
||||||
return session_->frame()->texture();
|
return session_->frame()->texture();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SessionSource::init()
|
void SessionSource::init()
|
||||||
{
|
{
|
||||||
if ( loadFinished_ && !loadFailed_ ) {
|
if ( loadFinished_ && !loadFailed_ && session_ != nullptr) {
|
||||||
loadFinished_ = false;
|
loadFinished_ = false;
|
||||||
|
|
||||||
// set resolution
|
// set resolution
|
||||||
@@ -156,7 +158,7 @@ void SessionSource::accept(Visitor& v)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
RenderSource::RenderSource() : Source()
|
RenderSource::RenderSource(Session *session) : Source(), session_(session)
|
||||||
{
|
{
|
||||||
// create surface:
|
// create surface:
|
||||||
sessionsurface_ = new Surface(rendershader_);
|
sessionsurface_ = new Surface(rendershader_);
|
||||||
@@ -170,24 +172,30 @@ RenderSource::~RenderSource()
|
|||||||
|
|
||||||
bool RenderSource::failed() const
|
bool RenderSource::failed() const
|
||||||
{
|
{
|
||||||
return Mixer::manager().session() == nullptr;
|
return session_ == nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint RenderSource::texture() const
|
uint RenderSource::texture() const
|
||||||
{
|
{
|
||||||
return Mixer::manager().session()->frame()->texture();
|
if (session_ == nullptr)
|
||||||
|
return Resource::getTextureBlack();
|
||||||
|
return session_->frame()->texture();
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderSource::init()
|
void RenderSource::init()
|
||||||
{
|
{
|
||||||
Session *session = Mixer::manager().session();
|
if (session_ == nullptr)
|
||||||
if (session && session->frame()->texture() != Resource::getTextureBlack()) {
|
session_ = Mixer::manager().session();
|
||||||
|
|
||||||
|
if (session_ && session_->frame()->texture() != Resource::getTextureBlack()) {
|
||||||
|
|
||||||
|
FrameBuffer *fb = session_->frame();
|
||||||
|
|
||||||
// get the texture index from framebuffer of view, apply it to the surface
|
// get the texture index from framebuffer of view, apply it to the surface
|
||||||
sessionsurface_->setTextureIndex( session->frame()->texture() );
|
sessionsurface_->setTextureIndex( fb->texture() );
|
||||||
|
|
||||||
// create Frame buffer matching size of output session
|
// create Frame buffer matching size of output session
|
||||||
FrameBuffer *renderbuffer = new FrameBuffer( session->frame()->resolution());
|
FrameBuffer *renderbuffer = new FrameBuffer( fb->resolution());
|
||||||
|
|
||||||
// set the renderbuffer of the source and attach rendering nodes
|
// set the renderbuffer of the source and attach rendering nodes
|
||||||
attach(renderbuffer);
|
attach(renderbuffer);
|
||||||
@@ -199,7 +207,7 @@ void RenderSource::init()
|
|||||||
// done init
|
// done init
|
||||||
initialized_ = true;
|
initialized_ = true;
|
||||||
|
|
||||||
Log::Info("Source Render linked to session (%d x %d).", int(session->frame()->resolution().x), int(session->frame()->resolution().y) );
|
Log::Info("Source Render linked to session (%d x %d).", int(fb->resolution().x), int(fb->resolution().y) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ protected:
|
|||||||
class RenderSource : public Source
|
class RenderSource : public Source
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
RenderSource();
|
RenderSource(Session *session);
|
||||||
~RenderSource();
|
~RenderSource();
|
||||||
|
|
||||||
// implementation of source API
|
// implementation of source API
|
||||||
@@ -53,6 +53,7 @@ protected:
|
|||||||
|
|
||||||
void init() override;
|
void init() override;
|
||||||
Surface *sessionsurface_;
|
Surface *sessionsurface_;
|
||||||
|
Session *session_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user