mirror of
https://github.com/brunoherbelin/vimix.git
synced 2025-12-11 18:34:58 +01:00
Cleanup of surface management in Sources (centralize texturesurface_ in
Source class, avoid mistakes in subclasses). Integration of sources in AppearanceView (not functionnal yet).
This commit is contained in:
@@ -15,19 +15,11 @@ MediaSource::MediaSource() : Source(), path_("")
|
||||
{
|
||||
// create media player
|
||||
mediaplayer_ = new MediaPlayer;
|
||||
|
||||
// create media surface:
|
||||
// - textured with original texture from media player
|
||||
// - crop & repeat UV can be managed here
|
||||
// - additional custom shader can be associated
|
||||
surface_ = new Surface(renderingshader_);
|
||||
|
||||
}
|
||||
|
||||
MediaSource::~MediaSource()
|
||||
{
|
||||
// delete media surface & player
|
||||
delete surface_;
|
||||
// delete media player
|
||||
delete mediaplayer_;
|
||||
}
|
||||
|
||||
@@ -68,11 +60,6 @@ uint MediaSource::texture() const
|
||||
return mediaplayer_->texture();
|
||||
}
|
||||
|
||||
void MediaSource::replaceRenderingShader()
|
||||
{
|
||||
surface_->replaceShader(renderingshader_);
|
||||
}
|
||||
|
||||
void MediaSource::init()
|
||||
{
|
||||
if ( mediaplayer_->isOpen() ) {
|
||||
@@ -84,7 +71,7 @@ void MediaSource::init()
|
||||
if (mediaplayer_->texture() != Resource::getTextureBlack()) {
|
||||
|
||||
// get the texture index from media player, apply it to the media surface
|
||||
surface_->setTextureIndex( mediaplayer_->texture() );
|
||||
texturesurface_->setTextureIndex( mediaplayer_->texture() );
|
||||
|
||||
// create Frame buffer matching size of media player
|
||||
float height = float(mediaplayer_->width()) / mediaplayer_->aspectRatio();
|
||||
@@ -97,10 +84,12 @@ void MediaSource::init()
|
||||
if (mediaplayer_->isImage()) {
|
||||
overlays_[View::MIXING]->attach( new Symbol(Symbol::IMAGE, glm::vec3(0.8f, 0.8f, 0.01f)) );
|
||||
overlays_[View::LAYER]->attach( new Symbol(Symbol::IMAGE, glm::vec3(0.8f, 0.8f, 0.01f)) );
|
||||
overlays_[View::APPEARANCE]->attach( new Symbol(Symbol::IMAGE, glm::vec3(1.1f, 0.9f, 0.01f)) );
|
||||
}
|
||||
else {
|
||||
overlays_[View::MIXING]->attach( new Symbol(Symbol::VIDEO, glm::vec3(0.8f, 0.8f, 0.01f)) );
|
||||
overlays_[View::LAYER]->attach( new Symbol(Symbol::VIDEO, glm::vec3(0.8f, 0.8f, 0.01f)) );
|
||||
overlays_[View::APPEARANCE]->attach( new Symbol(Symbol::VIDEO, glm::vec3(1.1f, 0.9f, 0.01f)) );
|
||||
}
|
||||
|
||||
// done init
|
||||
@@ -143,8 +132,8 @@ void MediaSource::render()
|
||||
// render the media player into frame buffer
|
||||
static glm::mat4 projection = glm::ortho(-1.f, 1.f, 1.f, -1.f, -1.f, 1.f);
|
||||
renderbuffer_->begin();
|
||||
surface_->shader()->color.a = mediaplayer_->currentTimelineFading();
|
||||
surface_->draw(glm::identity<glm::mat4>(), projection);
|
||||
texturesurface_->shader()->color.a = mediaplayer_->currentTimelineFading();
|
||||
texturesurface_->draw(glm::identity<glm::mat4>(), projection);
|
||||
renderbuffer_->end();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user