gl : fix qglwtextureshare demo
authorWang Xin-yu (王昕宇) <comicfans44@gmail.com>
Tue, 1 Jul 2014 00:36:53 +0000 (08:36 +0800)
committerTim-Philipp Müller <tim@centricular.com>
Sat, 9 Dec 2017 19:31:44 +0000 (19:31 +0000)
tests/examples/gl/qt/qglwtextureshare/glcontextid.h
tests/examples/gl/qt/qglwtextureshare/qglrenderer.cpp

index a6c8460..7c59546 100644 (file)
 
 #include <gst/gl/gstglconfig.h>
 
-#if defined(GST_GL_HAVE_PLATFORM_WGL)
+#if GST_GL_HAVE_PLATFORM_WGL
     #define WIN32_LEAN_AND_MEAN
     #include <windows.h>
     #include <Wingdi.h>
     #include <GL/gl.h>
-#elif defined (GST_GL_HAVE_PLATFORM_CGL)
+#elif GST_GL_HAVE_PLATFORM_CGL
     #include <OpenGL/OpenGL.h>
     class NSOpenGLContext;
 #else
 #endif
 
 
-#if defined(GST_GL_HAVE_PLATFORM_WGL)
+#if GST_GL_HAVE_PLATFORM_WGL
     typedef struct _tagGLContextID
     {
         HGLRC contextId;
         HDC dc;
     } GLContextID;
-#elif  defined(GST_GL_HAVE_PLATFORM_CGL)
+#elif  GST_GL_HAVE_PLATFORM_CGL
     typedef struct _tagGLContextID
     {
         NSOpenGLContext* contextId;
     } GLContextID;
-#elif defined(GST_GL_HAVE_PLATFORM_GLX)
+#elif GST_GL_HAVE_PLATFORM_GLX
     typedef struct _tagGLContextID
     {
         GLXContext contextId;
index c590ac7..218b8e4 100644 (file)
@@ -22,6 +22,7 @@
 
 #include <QGLWidget>
 #include <QApplication>
+#include <QDebug>
 #include <QCloseEvent>
 
 #include <gst/video/video.h>
@@ -60,11 +61,11 @@ QGLRenderer::initializeGL()
     display = gst_gl_display_new ();
 
     /* FIXME: Allow the choice at runtime */
-#if defined(GST_GL_HAVE_PLATFORM_WGL)
+#if GST_GL_HAVE_PLATFORM_WGL
     context = gst_gl_context_new_wrapped (display, (guintptr) wglGetCurrentContext (), GST_GL_PLATFORM_WGL, GST_GL_API_OPENGL);
-#elif defined (GST_GL_HAVE_PLATFORM_CGL)
+#elif GST_GL_HAVE_PLATFORM_CGL
     context = gst_gl_context_new_wrapped (display, (guintptr) qt_current_nsopengl_context(), GST_GL_PLATFORM_CGL, GST_GL_API_OPENGL);
-#elif defined(GST_GL_HAVE_PLATFORM_GLX)
+#elif GST_GL_HAVE_PLATFORM_GLX
     context = gst_gl_context_new_wrapped (display, (guintptr) glXGetCurrentContext (), GST_GL_PLATFORM_GLX, GST_GL_API_OPENGL);
 #endif
     gst_object_unref (display);
@@ -139,15 +140,15 @@ QGLRenderer::paintGL()
         mem = gst_buffer_peek_memory (this->frame, 0);
         v_meta = gst_buffer_get_video_meta (this->frame);
 
-        if (gst_is_gl_memory (mem)) {
-            gst_video_info_set_format (&v_info, v_meta->format, v_meta->width,
+        Q_ASSERT(gst_is_gl_memory (mem));
+
+        gst_video_info_set_format (&v_info, v_meta->format, v_meta->width,
                 v_meta->height);
 
-            gst_video_frame_map (&v_frame, &v_info, this->frame,
+        gst_video_frame_map (&v_frame, &v_info, this->frame,
                 (GstMapFlags) (GST_MAP_READ | GST_MAP_GL));
 
-            tex_id = *(guint *) v_frame.data[0];
-        }
+        tex_id = *(guint *) v_frame.data[0];
 
         glEnable(GL_DEPTH_TEST);
 
@@ -216,6 +217,8 @@ QGLRenderer::paintGL()
         zrot+=0.4f;
 
         glBindTexture(GL_TEXTURE_2D, 0);
+
+        gst_video_frame_unmap(&v_frame);
     }
 }