This commit is contained in:
parent
09f7be21eb
commit
e693b523f4
|
@ -144,7 +144,7 @@ void ProjectMVisualization::Init() {
|
|||
projectm_set_preset_duration(projectm_instance_, duration_);
|
||||
projectm_set_mesh_size(projectm_instance_, 32, 24);
|
||||
projectm_set_fps(projectm_instance_, 35);
|
||||
projectm_set_window_size(projectm_instance_, 512, 512);
|
||||
//projectm_set_window_size(projectm_instance_, 512, 512);
|
||||
projectm_playlist_instance_ = projectm_playlist_create(projectm_instance_);
|
||||
#else
|
||||
projectM::Settings s;
|
||||
|
@ -204,12 +204,26 @@ void ProjectMVisualization::RenderFrame(const int width, const int height) {
|
|||
Q_ASSERT(projectm_);
|
||||
#endif
|
||||
|
||||
//Resize(width, height);
|
||||
|
||||
#ifdef HAVE_PROJECTM4
|
||||
projectm_set_window_size(projectm_instance_, static_cast<size_t>(width * pixel_ratio_), static_cast<size_t>(height * pixel_ratio_));
|
||||
projectm_opengl_render_frame(projectm_instance_);
|
||||
#else
|
||||
projectm_->projectM_resetGL(static_cast<int>(width * pixel_ratio_), static_cast<int>(height * pixel_ratio_));
|
||||
projectm_->renderFrame();
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
void ProjectMVisualization::Resize(const int width, const int height) {
|
||||
|
||||
#ifdef HAVE_PROJECTM4
|
||||
if (projectm_instance_) {
|
||||
projectm_set_window_size(projectm_instance_, static_cast<size_t>(width * pixel_ratio_), static_cast<size_t>(height * pixel_ratio_));
|
||||
}
|
||||
#else
|
||||
if (projectm_) {
|
||||
projectm_->projectM_resetGL(static_cast<int>(width * pixel_ratio_), static_cast<int>(height * pixel_ratio_));
|
||||
}
|
||||
#endif // HAVE_PROJECTM4
|
||||
|
||||
}
|
||||
|
@ -220,15 +234,7 @@ void ProjectMVisualization::SceneRectChanged(const QRectF &rect) {
|
|||
// Accessing the QScreen becomes a lot easier in Qt 5.14 with QWidget::screen().
|
||||
pixel_ratio_ = container_->devicePixelRatio();
|
||||
|
||||
#ifdef HAVE_PROJECTM4
|
||||
if (projectm_instance_) {
|
||||
projectm_set_window_size(projectm_instance_, static_cast<size_t>(rect.width() * pixel_ratio_), static_cast<size_t>(rect.height() * pixel_ratio_));
|
||||
}
|
||||
#else
|
||||
if (projectm_) {
|
||||
projectm_->projectM_resetGL(static_cast<int>(rect.width() * pixel_ratio_), static_cast<int>(rect.height() * pixel_ratio_));
|
||||
}
|
||||
#endif // HAVE_PROJECTM4
|
||||
//Resize(rect.width(), rect.height());
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -66,6 +66,7 @@ class ProjectMVisualization : public QObject, public GstBufferConsumer {
|
|||
|
||||
void Init();
|
||||
void RenderFrame(const int width, const int height);
|
||||
void Resize(const int width, const int height);
|
||||
|
||||
// BufferConsumer
|
||||
void ConsumeBuffer(GstBuffer *buffer, const int pipeline_id, const QString &format) override;
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
|
||||
#include <QPainter>
|
||||
|
||||
#include "core/logging.h"
|
||||
#include "visualizationopenglwidget.h"
|
||||
#include "projectmvisualization.h"
|
||||
|
||||
|
@ -44,4 +45,36 @@ void VisualizationOpenGLWidget::paintGL() {
|
|||
p.endNativePainting();
|
||||
update();
|
||||
|
||||
qLog(Debug) << __PRETTY_FUNCTION__ << glGetError();
|
||||
|
||||
}
|
||||
|
||||
void VisualizationOpenGLWidget::resizeGL(const int width, const int height) {
|
||||
|
||||
Setup(width, height);
|
||||
projectm_visualization_->Resize(width, height);
|
||||
|
||||
}
|
||||
|
||||
void VisualizationOpenGLWidget::Setup(const int width, const int height) {
|
||||
|
||||
glShadeModel(GL_SMOOTH);
|
||||
glClearColor(0, 0, 0, 0);
|
||||
glViewport(0, 0, width, height);
|
||||
glMatrixMode(GL_TEXTURE);
|
||||
glLoadIdentity();
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glLoadIdentity();
|
||||
glDrawBuffer(GL_BACK);
|
||||
glReadBuffer(GL_BACK);
|
||||
glEnable(GL_BLEND);
|
||||
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
glEnable(GL_LINE_SMOOTH);
|
||||
glEnable(GL_POINT_SMOOTH);
|
||||
glClearColor(0.0F, 0.0F, 0.0F, 0.0F);
|
||||
glLineStipple(2, 0xAAAA);
|
||||
|
||||
}
|
||||
|
|
|
@ -35,6 +35,10 @@ class VisualizationOpenGLWidget : public QOpenGLWidget {
|
|||
protected:
|
||||
void initializeGL() override;
|
||||
void paintGL() override;
|
||||
void resizeGL(const int width, const int height) override;
|
||||
|
||||
private:
|
||||
void Setup(const int width, const int height);
|
||||
|
||||
private:
|
||||
ProjectMVisualization *projectm_visualization_;
|
||||
|
|
Loading…
Reference in New Issue