started porting renderer to new portable form
This commit is contained in:
@@ -20,10 +20,6 @@
|
||||
|
||||
#include "opacity.h"
|
||||
|
||||
#include "render/gl/functions.h"
|
||||
#include "render/rendertexture.h"
|
||||
#include "render/video/videorenderer.h"
|
||||
|
||||
OpacityNode::OpacityNode()
|
||||
{
|
||||
opacity_input_ = new NodeInput("opacity_in");
|
||||
@@ -61,65 +57,29 @@ QString OpacityNode::id()
|
||||
return "org.olivevideoeditor.Olive.opacity";
|
||||
}
|
||||
|
||||
QVariant OpacityNode::Value(NodeOutput *output, const rational &in, const rational &out)
|
||||
{
|
||||
Q_UNUSED(out)
|
||||
|
||||
// Find the current Renderer instance
|
||||
RenderInstance* renderer = VideoRendererProcessor::CurrentInstance();
|
||||
|
||||
// If nothing is available, don't return a texture
|
||||
if (renderer == nullptr) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (output == texture_output_) {
|
||||
RenderTexturePtr input_tex = texture_input_->get_value(in).value<RenderTexturePtr>();
|
||||
|
||||
if (input_tex == nullptr) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Attach texture's back buffer as frame buffer
|
||||
renderer->buffer()->AttachBackBuffer(input_tex);
|
||||
renderer->buffer()->Bind();
|
||||
|
||||
// Bind texture's front buffer to draw with
|
||||
input_tex->Bind();
|
||||
|
||||
// Set opacity to value
|
||||
ShaderPtr pipeline = renderer->default_pipeline();
|
||||
pipeline->bind();
|
||||
pipeline->setUniformValue("opacity", opacity_input_->get_value(in).toFloat()*0.01f);
|
||||
pipeline->release();
|
||||
|
||||
renderer->context()->functions()->glBlendFunc(GL_ONE, GL_ZERO);
|
||||
|
||||
// Blit
|
||||
olive::gl::Blit(pipeline);
|
||||
|
||||
// Reset to full opacity
|
||||
pipeline->bind();
|
||||
pipeline->setUniformValue("opacity", 1.0f);
|
||||
pipeline->release();
|
||||
|
||||
input_tex->Release();
|
||||
renderer->buffer()->Release();
|
||||
renderer->buffer()->Detach();
|
||||
|
||||
input_tex->SwapFrontAndBack();
|
||||
|
||||
return QVariant::fromValue(input_tex);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void OpacityNode::Retranslate()
|
||||
{
|
||||
opacity_input_->set_name(tr("Opacity"));
|
||||
}
|
||||
|
||||
QString OpacityNode::Code(NodeOutput *output)
|
||||
{
|
||||
if (output == texture_output()) {
|
||||
return "#version 110"
|
||||
"\n"
|
||||
"varying vec2 olive_tex_coord;\n"
|
||||
"\n"
|
||||
"uniform sampler2D tex_in;\n"
|
||||
"uniform float opacity_in;\n"
|
||||
"\n"
|
||||
"void main(void) {\n"
|
||||
" gl_FragColor = tex_in * (opacity_in * 0.01);\n"
|
||||
"}\n";
|
||||
}
|
||||
|
||||
return Node::Code(output);
|
||||
}
|
||||
|
||||
NodeInput *OpacityNode::texture_input()
|
||||
{
|
||||
return texture_input_;
|
||||
|
||||
@@ -22,7 +22,6 @@
|
||||
#define OPACITYNODE_H
|
||||
|
||||
#include "node/node.h"
|
||||
#include "render/gl/shaderptr.h"
|
||||
|
||||
class OpacityNode : public Node
|
||||
{
|
||||
@@ -36,10 +35,10 @@ public:
|
||||
|
||||
virtual QString id() override;
|
||||
|
||||
virtual QVariant Value(NodeOutput *output, const rational &in, const rational &out) override;
|
||||
|
||||
virtual void Retranslate() override;
|
||||
|
||||
virtual QString Code(NodeOutput* output) override;
|
||||
|
||||
NodeInput* texture_input();
|
||||
|
||||
NodeOutput* texture_output();
|
||||
|
||||
Reference in New Issue
Block a user