reimplemented tsa and gizmos
This commit is contained in:
+34
-5
@@ -41,7 +41,6 @@ extern "C" {
|
||||
#include <QScreen>
|
||||
#include <QMessageBox>
|
||||
#include <QOpenGLBuffer>
|
||||
#include <QOpenGLVertexArrayObject>
|
||||
|
||||
#include "panels/panels.h"
|
||||
#include "project/projectelements.h"
|
||||
@@ -62,6 +61,8 @@ extern "C" {
|
||||
#include "ui/menu.h"
|
||||
#include "mainwindow.h"
|
||||
|
||||
const int kTitleActionSafeVertexSize = 84;
|
||||
|
||||
ViewerWidget::ViewerWidget(QWidget *parent) :
|
||||
QOpenGLWidget(parent),
|
||||
waveform(false),
|
||||
@@ -221,6 +222,13 @@ void ViewerWidget::initializeGL() {
|
||||
connect(context(), SIGNAL(aboutToBeDestroyed()), this, SLOT(context_destroy()), Qt::DirectConnection);
|
||||
|
||||
pipeline_ = olive::rendering::GetPipeline();
|
||||
|
||||
vao_.create();
|
||||
|
||||
title_safe_area_buffer_.create();
|
||||
title_safe_area_buffer_.bind();
|
||||
title_safe_area_buffer_.allocate(nullptr, kTitleActionSafeVertexSize * sizeof(GLfloat));
|
||||
title_safe_area_buffer_.release();
|
||||
}
|
||||
|
||||
void ViewerWidget::frame_update() {
|
||||
@@ -277,6 +285,10 @@ void ViewerWidget::context_destroy() {
|
||||
|
||||
renderer.delete_ctx();
|
||||
|
||||
title_safe_area_buffer_.destroy();
|
||||
|
||||
vao_.destroy();
|
||||
|
||||
pipeline_ = nullptr;
|
||||
|
||||
doneCurrent();
|
||||
@@ -509,14 +521,23 @@ void ViewerWidget::draw_title_safe_area() {
|
||||
0.5f, 0.55f, 0.0f
|
||||
};
|
||||
|
||||
vao_.bind();
|
||||
|
||||
title_safe_area_buffer_.bind();
|
||||
title_safe_area_buffer_.write(0, vertices, kTitleActionSafeVertexSize * sizeof(GLfloat));
|
||||
|
||||
GLuint vertex_location = pipeline_->attributeLocation("a_position");
|
||||
func->glEnableVertexAttribArray(vertex_location);
|
||||
func->glVertexAttribPointer(vertex_location, 3, GL_FLOAT, GL_FALSE, 0, vertices);
|
||||
func->glVertexAttribPointer(vertex_location, 3, GL_FLOAT, GL_FALSE, 0, 0);
|
||||
|
||||
func->glDrawArrays(GL_LINES, 0, 28);
|
||||
|
||||
pipeline_->setUniformValue("color_only", false);
|
||||
|
||||
title_safe_area_buffer_.release();
|
||||
|
||||
vao_.release();
|
||||
|
||||
pipeline_->release();
|
||||
|
||||
}
|
||||
@@ -647,14 +668,23 @@ void ViewerWidget::draw_gizmos() {
|
||||
}
|
||||
}
|
||||
|
||||
vao_.bind();
|
||||
|
||||
QOpenGLBuffer vertex_buffer;
|
||||
vertex_buffer.create();
|
||||
vertex_buffer.bind();
|
||||
vertex_buffer.allocate(vertices.constData(), vertices.size() * sizeof(GLfloat));
|
||||
|
||||
GLuint vertex_location = pipeline_->attributeLocation("a_position");
|
||||
func->glEnableVertexAttribArray(vertex_location);
|
||||
func->glVertexAttribPointer(vertex_location, 3, GL_FLOAT, GL_FALSE, 0, vertices.constData());
|
||||
func->glVertexAttribPointer(vertex_location, 3, GL_FLOAT, GL_FALSE, 0, 0);
|
||||
|
||||
func->glDrawArrays(GL_LINES, 0, vertices.size() / 3);
|
||||
|
||||
pipeline_->setUniformValue("color_only", false);
|
||||
|
||||
vao_.release();
|
||||
|
||||
pipeline_->release();
|
||||
|
||||
}
|
||||
@@ -669,10 +699,10 @@ void ViewerWidget::paintGL() {
|
||||
tex_lock->lock();
|
||||
|
||||
QOpenGLFunctions* f = context()->functions();
|
||||
//QOpenGLExtraFunctions* xf = context()->extraFunctions();
|
||||
|
||||
makeCurrent();
|
||||
|
||||
|
||||
// clear to solid black
|
||||
f->glClearColor(0.0, 0.0, 0.0, 0.0);
|
||||
f->glClear(GL_COLOR_BUFFER_BIT);
|
||||
@@ -680,7 +710,6 @@ void ViewerWidget::paintGL() {
|
||||
|
||||
// draw texture from render thread
|
||||
|
||||
|
||||
f->glViewport(0, 0, width(), height());
|
||||
|
||||
f->glBindTexture(GL_TEXTURE_2D, tex);
|
||||
|
||||
@@ -29,6 +29,8 @@
|
||||
#include <QMutex>
|
||||
#include <QWaitCondition>
|
||||
#include <QOpenGLFunctions>
|
||||
#include <QOpenGLVertexArrayObject>
|
||||
#include <QOpenGLBuffer>
|
||||
|
||||
#include "timeline/clip.h"
|
||||
#include "project/footage.h"
|
||||
@@ -94,6 +96,8 @@ private:
|
||||
double y_scroll;
|
||||
|
||||
QOpenGLShaderProgramPtr pipeline_;
|
||||
QOpenGLVertexArrayObject vao_;
|
||||
QOpenGLBuffer title_safe_area_buffer_;
|
||||
|
||||
private slots:
|
||||
void context_destroy();
|
||||
|
||||
Reference in New Issue
Block a user