]> git.sesse.net Git - kdenlive/blobdiff - src/videoglwidget.cpp
Fix Coverity #980683
[kdenlive] / src / videoglwidget.cpp
index dffa495b6dab2829012ed0021f527a80816b2674..af6527ad2191af451b93f1395b8d73af7d5c899d 100644 (file)
@@ -1,7 +1,11 @@
 
 #include <QtGui>
 #include <QtOpenGL>
+#ifdef Q_WS_MAC
+#include <OpenGL/glu.h>
+#else
 #include <GL/glu.h>
+#endif
 #include "videoglwidget.h"
 
 #ifndef GL_TEXTURE_RECTANGLE_EXT
 
 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);
 }
@@ -37,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);
@@ -53,9 +67,9 @@ 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;
 
     // Special case optimisation to negate odd effect of sample aspect ratio
@@ -83,6 +97,17 @@ void VideoGLWidget::resizeGL(int width, int height)
     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) {
@@ -108,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);