]> git.sesse.net Git - kdenlive/blobdiff - src/videoglwidget.cpp
Fix issues with OpenGL aspect ration / corruption and DVD wizard monitor
[kdenlive] / src / videoglwidget.cpp
index 219a96a87f6580ffdfb0be892db8193d585d4ee1..eff90f6ea97f53e1397fb9ab1fa443752ead13ac 100644 (file)
@@ -1,6 +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
@@ -14,7 +19,7 @@ VideoGLWidget::VideoGLWidget(QWidget *parent)
     , m_texture(0)
     , m_display_ratio(4.0 / 3.0)
     , m_backgroundColor(Qt::gray)
-{
+{  
     setAttribute(Qt::WA_PaintOnScreen);
     setAttribute(Qt::WA_OpaquePaintEvent);
 }
@@ -54,7 +59,6 @@ void VideoGLWidget::resizeEvent(QResizeEvent* event)
 }
 void VideoGLWidget::resizeGL(int width, int height)
 {
-
     double this_aspect = (double) width / height;
 
     // Special case optimisation to negate odd effect of sample aspect ratio
@@ -79,12 +83,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);
@@ -104,7 +122,6 @@ void VideoGLWidget::showImage(QImage image)
 {
     m_image_width = image.width();
     m_image_height = image.height();
-
     makeCurrent();
     if (m_texture)
         glDeleteTextures(1, &m_texture);