gl : fix qglwtextureshare demo

This commit is contained in:
Wang Xin-yu (王昕宇) 2014-07-01 08:36:53 +08:00 committed by Matthew Waters
parent e050541f11
commit 6e4ea66ede
2 changed files with 16 additions and 13 deletions

View file

@ -25,12 +25,12 @@
#include <gst/gl/gstglconfig.h> #include <gst/gl/gstglconfig.h>
#if defined(GST_GL_HAVE_PLATFORM_WGL) #if GST_GL_HAVE_PLATFORM_WGL
#define WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN
#include <windows.h> #include <windows.h>
#include <Wingdi.h> #include <Wingdi.h>
#include <GL/gl.h> #include <GL/gl.h>
#elif defined (GST_GL_HAVE_PLATFORM_CGL) #elif GST_GL_HAVE_PLATFORM_CGL
#include <OpenGL/OpenGL.h> #include <OpenGL/OpenGL.h>
class NSOpenGLContext; class NSOpenGLContext;
#else #else
@ -41,18 +41,18 @@
#endif #endif
#if defined(GST_GL_HAVE_PLATFORM_WGL) #if GST_GL_HAVE_PLATFORM_WGL
typedef struct _tagGLContextID typedef struct _tagGLContextID
{ {
HGLRC contextId; HGLRC contextId;
HDC dc; HDC dc;
} GLContextID; } GLContextID;
#elif defined(GST_GL_HAVE_PLATFORM_CGL) #elif GST_GL_HAVE_PLATFORM_CGL
typedef struct _tagGLContextID typedef struct _tagGLContextID
{ {
NSOpenGLContext* contextId; NSOpenGLContext* contextId;
} GLContextID; } GLContextID;
#elif defined(GST_GL_HAVE_PLATFORM_GLX) #elif GST_GL_HAVE_PLATFORM_GLX
typedef struct _tagGLContextID typedef struct _tagGLContextID
{ {
GLXContext contextId; GLXContext contextId;

View file

@ -22,6 +22,7 @@
#include <QGLWidget> #include <QGLWidget>
#include <QApplication> #include <QApplication>
#include <QDebug>
#include <QCloseEvent> #include <QCloseEvent>
#include <gst/video/video.h> #include <gst/video/video.h>
@ -60,11 +61,11 @@ QGLRenderer::initializeGL()
display = gst_gl_display_new (); display = gst_gl_display_new ();
/* FIXME: Allow the choice at runtime */ /* 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); 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); 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); context = gst_gl_context_new_wrapped (display, (guintptr) glXGetCurrentContext (), GST_GL_PLATFORM_GLX, GST_GL_API_OPENGL);
#endif #endif
gst_object_unref (display); gst_object_unref (display);
@ -139,7 +140,8 @@ QGLRenderer::paintGL()
mem = gst_buffer_peek_memory (this->frame, 0); mem = gst_buffer_peek_memory (this->frame, 0);
v_meta = gst_buffer_get_video_meta (this->frame); v_meta = gst_buffer_get_video_meta (this->frame);
if (gst_is_gl_memory (mem)) { Q_ASSERT(gst_is_gl_memory (mem));
gst_video_info_set_format (&v_info, v_meta->format, v_meta->width, gst_video_info_set_format (&v_info, v_meta->format, v_meta->width,
v_meta->height); v_meta->height);
@ -147,7 +149,6 @@ QGLRenderer::paintGL()
(GstMapFlags) (GST_MAP_READ | GST_MAP_GL)); (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); glEnable(GL_DEPTH_TEST);
@ -216,6 +217,8 @@ QGLRenderer::paintGL()
zrot+=0.4f; zrot+=0.4f;
glBindTexture(GL_TEXTURE_2D, 0); glBindTexture(GL_TEXTURE_2D, 0);
gst_video_frame_unmap(&v_frame);
} }
} }