X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Fvideoglwidget.cpp;h=af6527ad2191af451b93f1395b8d73af7d5c899d;hb=65fb2361980ff6a927a8218ecb1d99618bfcc85c;hp=cbe08e3838c19826384e6d1870fedbef15787535;hpb=1ca75f8e1d52cc86df11c66eb6092d41c5b3bd50;p=kdenlive diff --git a/src/videoglwidget.cpp b/src/videoglwidget.cpp index cbe08e38..af6527ad 100644 --- a/src/videoglwidget.cpp +++ b/src/videoglwidget.cpp @@ -1,6 +1,11 @@ #include #include +#ifdef Q_WS_MAC +#include +#else +#include +#endif #include "videoglwidget.h" #ifndef GL_TEXTURE_RECTANGLE_EXT @@ -9,12 +14,16 @@ VideoGLWidget::VideoGLWidget(QWidget *parent) : QGLWidget(parent) + , x(0) + , y(0) + , w(width()) + , h(height()) , m_image_width(0) , m_image_height(0) , m_texture(0) , m_display_ratio(4.0 / 3.0) , m_backgroundColor(Qt::gray) -{ +{ setAttribute(Qt::WA_PaintOnScreen); setAttribute(Qt::WA_OpaquePaintEvent); } @@ -36,6 +45,12 @@ QSize VideoGLWidget::sizeHint() const return QSize(400, 300); } +void VideoGLWidget::setImageAspectRatio(double ratio) +{ + m_display_ratio = ratio; + resizeGL(width(), height()); +} + void VideoGLWidget::initializeGL() { qglClearColor(m_backgroundColor); @@ -48,6 +63,11 @@ void VideoGLWidget::initializeGL() glPixelStorei(GL_UNPACK_ALIGNMENT, 1); } +void VideoGLWidget::resizeEvent(QResizeEvent* event) +{ + resizeGL(event->size().width(),event->size().height()); +} + void VideoGLWidget::resizeGL(int width, int height) { double this_aspect = (double) width / height; @@ -74,12 +94,26 @@ void VideoGLWidget::resizeGL(int width, int height) glLoadIdentity(); gluOrtho2D(0, width, height, 0); glMatrixMode(GL_MODELVIEW); - glClear(GL_COLOR_BUFFER_BIT); // | GL_DEPTH_BUFFER_BIT // Depth is disabled, so shouldn'b be necessary to clear DEPTH_BUFFER + glClear(GL_COLOR_BUFFER_BIT); +} + +void VideoGLWidget::activateMonitor() +{ + makeCurrent(); + glViewport(0, 0, width(), height()); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + gluOrtho2D(0, width(), height(), 0); + glMatrixMode(GL_MODELVIEW); + glClear(GL_COLOR_BUFFER_BIT); } void VideoGLWidget::paintGL() { if (m_texture) { +#ifdef Q_WS_MAC + glClear(GL_COLOR_BUFFER_BIT); +#endif glEnable(GL_TEXTURE_RECTANGLE_EXT); glBegin(GL_QUADS); glTexCoord2i(0, 0); @@ -99,7 +133,6 @@ void VideoGLWidget::showImage(QImage image) { m_image_width = image.width(); m_image_height = image.height(); - makeCurrent(); if (m_texture) glDeleteTextures(1, &m_texture);