From 869f9da13f544953727f3380da14279eef7d4f12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wang=20Xin-yu=20=28=E7=8E=8B=E6=98=95=E5=AE=87=29?= Date: Tue, 1 Jul 2014 08:36:53 +0800 Subject: [PATCH] gl : fix qglwtextureshare demo --- .../gl/qt/qglwtextureshare/glcontextid.h | 10 +++++----- .../gl/qt/qglwtextureshare/qglrenderer.cpp | 19 +++++++++++-------- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/tests/examples/gl/qt/qglwtextureshare/glcontextid.h b/tests/examples/gl/qt/qglwtextureshare/glcontextid.h index a6c846013b..7c59546f4f 100644 --- a/tests/examples/gl/qt/qglwtextureshare/glcontextid.h +++ b/tests/examples/gl/qt/qglwtextureshare/glcontextid.h @@ -25,12 +25,12 @@ #include -#if defined(GST_GL_HAVE_PLATFORM_WGL) +#if GST_GL_HAVE_PLATFORM_WGL #define WIN32_LEAN_AND_MEAN #include #include #include -#elif defined (GST_GL_HAVE_PLATFORM_CGL) +#elif GST_GL_HAVE_PLATFORM_CGL #include class NSOpenGLContext; #else @@ -41,18 +41,18 @@ #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; diff --git a/tests/examples/gl/qt/qglwtextureshare/qglrenderer.cpp b/tests/examples/gl/qt/qglwtextureshare/qglrenderer.cpp index c590ac7a3a..218b8e4a49 100644 --- a/tests/examples/gl/qt/qglwtextureshare/qglrenderer.cpp +++ b/tests/examples/gl/qt/qglwtextureshare/qglrenderer.cpp @@ -22,6 +22,7 @@ #include #include +#include #include #include @@ -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); } }