|
Packit |
971217 |
/*
|
|
Packit |
971217 |
* GStreamer
|
|
Packit |
971217 |
* Copyright (C) 2008 Julien Isorce <julien.isorce@gmail.com>
|
|
Packit |
971217 |
* Copyright (C) 2012 Matthew Waters <ystreet00@gmail.com>
|
|
Packit |
971217 |
*
|
|
Packit |
971217 |
* This library is free software; you can redistribute it and/or
|
|
Packit |
971217 |
* modify it under the terms of the GNU Library General Public
|
|
Packit |
971217 |
* License as published by the Free Software Foundation; either
|
|
Packit |
971217 |
* version 2 of the License, or (at your option) any later version.
|
|
Packit |
971217 |
*
|
|
Packit |
971217 |
* This library is distributed in the hope that it will be useful,
|
|
Packit |
971217 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit |
971217 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Packit |
971217 |
* Library General Public License for more details.
|
|
Packit |
971217 |
*
|
|
Packit |
971217 |
* You should have received a copy of the GNU Library General Public
|
|
Packit |
971217 |
* License along with this library; if not, write to the
|
|
Packit |
971217 |
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
Packit |
971217 |
* Boston, MA 02110-1301, USA.
|
|
Packit |
971217 |
*/
|
|
Packit |
971217 |
|
|
Packit |
971217 |
#ifdef HAVE_CONFIG_H
|
|
Packit |
971217 |
#include "config.h"
|
|
Packit |
971217 |
#endif
|
|
Packit |
971217 |
|
|
Packit |
971217 |
#include <gst/gst.h>
|
|
Packit |
971217 |
|
|
Packit |
971217 |
#include <gst/gl/gl.h>
|
|
Packit |
971217 |
#include <gst/gl/gstglfuncs.h>
|
|
Packit |
971217 |
|
|
Packit |
971217 |
#include "gstglcontext_wgl.h"
|
|
Packit |
971217 |
#include <GL/wglext.h>
|
|
Packit |
971217 |
|
|
Packit |
971217 |
#include "../utils/opengl_versions.h"
|
|
Packit |
971217 |
#include "../gstglcontext_private.h"
|
|
Packit |
971217 |
|
|
Packit |
971217 |
struct _GstGLContextWGLPrivate
|
|
Packit |
971217 |
{
|
|
Packit |
971217 |
PFNWGLCREATECONTEXTATTRIBSARBPROC wglCreateContextAttribsARB;
|
|
Packit |
971217 |
|
|
Packit |
971217 |
GstGLAPI context_api;
|
|
Packit |
971217 |
};
|
|
Packit |
971217 |
|
|
Packit |
971217 |
#define GST_CAT_DEFAULT gst_gl_context_debug
|
|
Packit |
971217 |
|
|
Packit |
971217 |
#define gst_gl_context_wgl_parent_class parent_class
|
|
Packit |
971217 |
G_DEFINE_TYPE (GstGLContextWGL, gst_gl_context_wgl, GST_TYPE_GL_CONTEXT);
|
|
Packit |
971217 |
#define GST_GL_CONTEXT_WGL_GET_PRIVATE(o) \
|
|
Packit |
971217 |
(G_TYPE_INSTANCE_GET_PRIVATE((o), GST_TYPE_GL_CONTEXT_WGL, GstGLContextWGLPrivate))
|
|
Packit |
971217 |
|
|
Packit |
971217 |
static guintptr gst_gl_context_wgl_get_gl_context (GstGLContext * context);
|
|
Packit |
971217 |
static void gst_gl_context_wgl_swap_buffers (GstGLContext * context);
|
|
Packit |
971217 |
static gboolean gst_gl_context_wgl_choose_format (GstGLContext * context,
|
|
Packit |
971217 |
GError ** error);
|
|
Packit |
971217 |
static gboolean gst_gl_context_wgl_activate (GstGLContext * context,
|
|
Packit |
971217 |
gboolean activate);
|
|
Packit |
971217 |
static gboolean gst_gl_context_wgl_create_context (GstGLContext * context,
|
|
Packit |
971217 |
GstGLAPI gl_api, GstGLContext * other_context, GError ** error);
|
|
Packit |
971217 |
static void gst_gl_context_wgl_destroy_context (GstGLContext * context);
|
|
Packit |
971217 |
GstGLAPI gst_gl_context_wgl_get_gl_api (GstGLContext * context);
|
|
Packit |
971217 |
static GstGLPlatform gst_gl_context_wgl_get_gl_platform (GstGLContext *
|
|
Packit |
971217 |
context);
|
|
Packit |
971217 |
|
|
Packit |
971217 |
static void
|
|
Packit |
971217 |
gst_gl_context_wgl_class_init (GstGLContextWGLClass * klass)
|
|
Packit |
971217 |
{
|
|
Packit |
971217 |
GstGLContextClass *context_class = (GstGLContextClass *) klass;
|
|
Packit |
971217 |
|
|
Packit |
971217 |
g_type_class_add_private (klass, sizeof (GstGLContextWGLPrivate));
|
|
Packit |
971217 |
|
|
Packit |
971217 |
context_class->get_gl_context =
|
|
Packit |
971217 |
GST_DEBUG_FUNCPTR (gst_gl_context_wgl_get_gl_context);
|
|
Packit |
971217 |
context_class->choose_format =
|
|
Packit |
971217 |
GST_DEBUG_FUNCPTR (gst_gl_context_wgl_choose_format);
|
|
Packit |
971217 |
context_class->activate = GST_DEBUG_FUNCPTR (gst_gl_context_wgl_activate);
|
|
Packit |
971217 |
context_class->create_context =
|
|
Packit |
971217 |
GST_DEBUG_FUNCPTR (gst_gl_context_wgl_create_context);
|
|
Packit |
971217 |
context_class->destroy_context =
|
|
Packit |
971217 |
GST_DEBUG_FUNCPTR (gst_gl_context_wgl_destroy_context);
|
|
Packit |
971217 |
context_class->swap_buffers =
|
|
Packit |
971217 |
GST_DEBUG_FUNCPTR (gst_gl_context_wgl_swap_buffers);
|
|
Packit |
971217 |
|
|
Packit |
971217 |
context_class->get_proc_address =
|
|
Packit |
971217 |
GST_DEBUG_FUNCPTR (gst_gl_context_wgl_get_proc_address);
|
|
Packit |
971217 |
context_class->get_gl_api = GST_DEBUG_FUNCPTR (gst_gl_context_wgl_get_gl_api);
|
|
Packit |
971217 |
context_class->get_gl_platform =
|
|
Packit |
971217 |
GST_DEBUG_FUNCPTR (gst_gl_context_wgl_get_gl_platform);
|
|
Packit |
971217 |
}
|
|
Packit |
971217 |
|
|
Packit |
971217 |
static void
|
|
Packit |
971217 |
gst_gl_context_wgl_init (GstGLContextWGL * context_wgl)
|
|
Packit |
971217 |
{
|
|
Packit |
971217 |
context_wgl->priv = GST_GL_CONTEXT_WGL_GET_PRIVATE (context_wgl);
|
|
Packit |
971217 |
|
|
Packit |
971217 |
context_wgl->priv->context_api = GST_GL_API_OPENGL | GST_GL_API_OPENGL3;
|
|
Packit |
971217 |
}
|
|
Packit |
971217 |
|
|
Packit |
971217 |
/* Must be called in the gl thread */
|
|
Packit |
971217 |
GstGLContextWGL *
|
|
Packit |
971217 |
gst_gl_context_wgl_new (GstGLDisplay * display)
|
|
Packit |
971217 |
{
|
|
Packit |
971217 |
GstGLContextWGL *context;
|
|
Packit |
971217 |
|
|
Packit |
971217 |
if ((gst_gl_display_get_handle_type (display) & GST_GL_DISPLAY_TYPE_WIN32) ==
|
|
Packit |
971217 |
0)
|
|
Packit |
971217 |
/* we require an win32 display handle to create WGL contexts */
|
|
Packit |
971217 |
return NULL;
|
|
Packit |
971217 |
|
|
Packit |
971217 |
context = g_object_new (GST_TYPE_GL_CONTEXT_WGL, NULL);
|
|
Packit |
971217 |
gst_object_ref_sink (context);
|
|
Packit |
971217 |
|
|
Packit |
971217 |
return context;
|
|
Packit |
971217 |
}
|
|
Packit |
971217 |
|
|
Packit |
971217 |
static HGLRC
|
|
Packit |
971217 |
_create_context_with_flags (GstGLContextWGL * context_wgl, HDC dpy,
|
|
Packit |
971217 |
HGLRC share_context, gint major, gint minor, gint contextFlags,
|
|
Packit |
971217 |
gint profileMask)
|
|
Packit |
971217 |
{
|
|
Packit |
971217 |
HGLRC ret;
|
|
Packit |
971217 |
#define N_ATTRIBS 20
|
|
Packit |
971217 |
gint attribs[N_ATTRIBS];
|
|
Packit |
971217 |
gint n = 0;
|
|
Packit |
971217 |
|
|
Packit |
971217 |
if (major) {
|
|
Packit |
971217 |
attribs[n++] = WGL_CONTEXT_MAJOR_VERSION_ARB;
|
|
Packit |
971217 |
attribs[n++] = major;
|
|
Packit |
971217 |
}
|
|
Packit |
971217 |
if (minor) {
|
|
Packit |
971217 |
attribs[n++] = WGL_CONTEXT_MINOR_VERSION_ARB;
|
|
Packit |
971217 |
attribs[n++] = minor;
|
|
Packit |
971217 |
}
|
|
Packit |
971217 |
if (contextFlags) {
|
|
Packit |
971217 |
attribs[n++] = WGL_CONTEXT_FLAGS_ARB;
|
|
Packit |
971217 |
attribs[n++] = contextFlags;
|
|
Packit |
971217 |
}
|
|
Packit |
971217 |
if (profileMask) {
|
|
Packit |
971217 |
attribs[n++] = WGL_CONTEXT_PROFILE_MASK_ARB;
|
|
Packit |
971217 |
attribs[n++] = profileMask;
|
|
Packit |
971217 |
}
|
|
Packit |
971217 |
attribs[n++] = 0;
|
|
Packit |
971217 |
|
|
Packit |
971217 |
g_assert (n < N_ATTRIBS);
|
|
Packit |
971217 |
#undef N_ATTRIBS
|
|
Packit |
971217 |
|
|
Packit |
971217 |
ret =
|
|
Packit |
971217 |
context_wgl->priv->wglCreateContextAttribsARB (dpy, share_context,
|
|
Packit |
971217 |
attribs);
|
|
Packit |
971217 |
|
|
Packit |
971217 |
return ret;
|
|
Packit |
971217 |
}
|
|
Packit |
971217 |
|
|
Packit |
971217 |
static gboolean
|
|
Packit |
971217 |
gst_gl_context_wgl_create_context (GstGLContext * context,
|
|
Packit |
971217 |
GstGLAPI gl_api, GstGLContext * other_context, GError ** error)
|
|
Packit |
971217 |
{
|
|
Packit |
971217 |
GstGLWindow *window;
|
|
Packit |
971217 |
GstGLContextWGL *context_wgl;
|
|
Packit |
971217 |
HGLRC external_gl_context = NULL;
|
|
Packit |
971217 |
HGLRC trampoline;
|
|
Packit |
971217 |
HDC device;
|
|
Packit |
971217 |
|
|
Packit |
971217 |
context_wgl = GST_GL_CONTEXT_WGL (context);
|
|
Packit |
971217 |
window = gst_gl_context_get_window (context);
|
|
Packit |
971217 |
device = (HDC) gst_gl_window_get_display (window);
|
|
Packit |
971217 |
|
|
Packit |
971217 |
if (other_context) {
|
|
Packit |
971217 |
if (gst_gl_context_get_gl_platform (other_context) != GST_GL_PLATFORM_WGL) {
|
|
Packit |
971217 |
g_set_error (error, GST_GL_CONTEXT_ERROR,
|
|
Packit |
971217 |
GST_GL_CONTEXT_ERROR_WRONG_CONFIG,
|
|
Packit |
971217 |
"Cannot share context with a non-WGL context");
|
|
Packit |
971217 |
goto failure;
|
|
Packit |
971217 |
}
|
|
Packit |
971217 |
external_gl_context = (HGLRC) gst_gl_context_get_gl_context (other_context);
|
|
Packit |
971217 |
}
|
|
Packit |
971217 |
|
|
Packit |
971217 |
trampoline = wglCreateContext (device);
|
|
Packit |
971217 |
if (trampoline)
|
|
Packit |
971217 |
GST_DEBUG ("gl context created: %" G_GUINTPTR_FORMAT,
|
|
Packit |
971217 |
(guintptr) trampoline);
|
|
Packit |
971217 |
else {
|
|
Packit |
971217 |
g_set_error (error, GST_GL_CONTEXT_ERROR,
|
|
Packit |
971217 |
GST_GL_CONTEXT_ERROR_CREATE_CONTEXT, "failed to create glcontext:0x%x",
|
|
Packit |
971217 |
(unsigned int) GetLastError ());
|
|
Packit |
971217 |
goto failure;
|
|
Packit |
971217 |
}
|
|
Packit |
971217 |
g_assert (trampoline);
|
|
Packit |
971217 |
|
|
Packit |
971217 |
/* get extension functions */
|
|
Packit |
971217 |
wglMakeCurrent (device, trampoline);
|
|
Packit |
971217 |
|
|
Packit |
971217 |
context_wgl->priv->wglCreateContextAttribsARB =
|
|
Packit |
971217 |
(PFNWGLCREATECONTEXTATTRIBSARBPROC)
|
|
Packit |
971217 |
wglGetProcAddress ("wglCreateContextAttribsARB");
|
|
Packit |
971217 |
|
|
Packit |
971217 |
wglMakeCurrent (device, 0);
|
|
Packit |
971217 |
wglDeleteContext (trampoline);
|
|
Packit |
971217 |
trampoline = NULL;
|
|
Packit |
971217 |
|
|
Packit |
971217 |
if (context_wgl->priv->wglCreateContextAttribsARB != NULL
|
|
Packit |
971217 |
&& gl_api & GST_GL_API_OPENGL3) {
|
|
Packit |
971217 |
gint i;
|
|
Packit |
971217 |
|
|
Packit |
971217 |
for (i = 0; i < G_N_ELEMENTS (opengl_versions); i++) {
|
|
Packit |
971217 |
gint profileMask = 0;
|
|
Packit |
971217 |
gint contextFlags = 0;
|
|
Packit |
971217 |
|
|
Packit |
971217 |
if ((opengl_versions[i].major > 3
|
|
Packit |
971217 |
|| (opengl_versions[i].major == 3
|
|
Packit |
971217 |
&& opengl_versions[i].minor >= 2))) {
|
|
Packit |
971217 |
profileMask |= WGL_CONTEXT_CORE_PROFILE_BIT_ARB;
|
|
Packit |
971217 |
contextFlags |= WGL_CONTEXT_DEBUG_BIT_ARB;
|
|
Packit |
971217 |
} else {
|
|
Packit |
971217 |
break;
|
|
Packit |
971217 |
}
|
|
Packit |
971217 |
|
|
Packit |
971217 |
GST_DEBUG_OBJECT (context, "trying to create a GL %d.%d context",
|
|
Packit |
971217 |
opengl_versions[i].major, opengl_versions[i].minor);
|
|
Packit |
971217 |
|
|
Packit |
971217 |
context_wgl->wgl_context = _create_context_with_flags (context_wgl,
|
|
Packit |
971217 |
device, external_gl_context, opengl_versions[i].major,
|
|
Packit |
971217 |
opengl_versions[i].minor, contextFlags, profileMask);
|
|
Packit |
971217 |
|
|
Packit |
971217 |
if (context_wgl->wgl_context) {
|
|
Packit |
971217 |
context_wgl->priv->context_api = GST_GL_API_OPENGL3;
|
|
Packit |
971217 |
break;
|
|
Packit |
971217 |
}
|
|
Packit |
971217 |
}
|
|
Packit |
971217 |
}
|
|
Packit |
971217 |
|
|
Packit |
971217 |
if (!context_wgl->wgl_context) {
|
|
Packit |
971217 |
|
|
Packit |
971217 |
if (context_wgl->priv->wglCreateContextAttribsARB && external_gl_context) {
|
|
Packit |
971217 |
context_wgl->wgl_context =
|
|
Packit |
971217 |
context_wgl->priv->wglCreateContextAttribsARB (device,
|
|
Packit |
971217 |
external_gl_context, 0);
|
|
Packit |
971217 |
}
|
|
Packit |
971217 |
|
|
Packit |
971217 |
|
|
Packit |
971217 |
if (!context_wgl->wgl_context) {
|
|
Packit |
971217 |
|
|
Packit |
971217 |
context_wgl->wgl_context = wglCreateContext (device);
|
|
Packit |
971217 |
|
|
Packit |
971217 |
if (!context_wgl->wgl_context) {
|
|
Packit |
971217 |
g_set_error (error, GST_GL_CONTEXT_ERROR,
|
|
Packit |
971217 |
GST_GL_CONTEXT_ERROR_CREATE_CONTEXT,
|
|
Packit |
971217 |
"Failed to create WGL context 0x%x",
|
|
Packit |
971217 |
(unsigned int) GetLastError ());
|
|
Packit |
971217 |
goto failure;
|
|
Packit |
971217 |
}
|
|
Packit |
971217 |
|
|
Packit |
971217 |
if (external_gl_context) {
|
|
Packit |
971217 |
if (!wglShareLists (external_gl_context, context_wgl->wgl_context)) {
|
|
Packit |
971217 |
g_set_error (error, GST_GL_CONTEXT_ERROR,
|
|
Packit |
971217 |
GST_GL_CONTEXT_ERROR_CREATE_CONTEXT,
|
|
Packit |
971217 |
"failed to share contexts through wglShareLists 0x%x",
|
|
Packit |
971217 |
(unsigned int) GetLastError ());
|
|
Packit |
971217 |
goto failure;
|
|
Packit |
971217 |
}
|
|
Packit |
971217 |
}
|
|
Packit |
971217 |
}
|
|
Packit |
971217 |
|
|
Packit |
971217 |
context_wgl->priv->context_api = GST_GL_API_OPENGL;
|
|
Packit |
971217 |
}
|
|
Packit |
971217 |
|
|
Packit |
971217 |
GST_LOG ("gl context id: %" G_GUINTPTR_FORMAT,
|
|
Packit |
971217 |
(guintptr) context_wgl->wgl_context);
|
|
Packit |
971217 |
|
|
Packit |
971217 |
gst_object_unref (window);
|
|
Packit |
971217 |
|
|
Packit |
971217 |
return TRUE;
|
|
Packit |
971217 |
|
|
Packit |
971217 |
failure:
|
|
Packit |
971217 |
gst_object_unref (window);
|
|
Packit |
971217 |
|
|
Packit |
971217 |
return FALSE;
|
|
Packit |
971217 |
}
|
|
Packit |
971217 |
|
|
Packit |
971217 |
static void
|
|
Packit |
971217 |
gst_gl_context_wgl_destroy_context (GstGLContext * context)
|
|
Packit |
971217 |
{
|
|
Packit |
971217 |
GstGLContextWGL *context_wgl;
|
|
Packit |
971217 |
|
|
Packit |
971217 |
context_wgl = GST_GL_CONTEXT_WGL (context);
|
|
Packit |
971217 |
|
|
Packit |
971217 |
if (context_wgl->wgl_context)
|
|
Packit |
971217 |
wglDeleteContext (context_wgl->wgl_context);
|
|
Packit |
971217 |
context_wgl->wgl_context = NULL;
|
|
Packit |
971217 |
}
|
|
Packit |
971217 |
|
|
Packit |
971217 |
static gboolean
|
|
Packit |
971217 |
gst_gl_context_wgl_choose_format (GstGLContext * context, GError ** error)
|
|
Packit |
971217 |
{
|
|
Packit |
971217 |
GstGLWindow *window;
|
|
Packit |
971217 |
PIXELFORMATDESCRIPTOR pfd;
|
|
Packit |
971217 |
gint pixelformat = 0;
|
|
Packit |
971217 |
gboolean res = FALSE;
|
|
Packit |
971217 |
HDC device;
|
|
Packit |
971217 |
|
|
Packit |
971217 |
window = gst_gl_context_get_window (context);
|
|
Packit |
971217 |
gst_gl_window_win32_create_window (GST_GL_WINDOW_WIN32 (window), error);
|
|
Packit |
971217 |
device = (HDC) gst_gl_window_get_display (window);
|
|
Packit |
971217 |
gst_object_unref (window);
|
|
Packit |
971217 |
|
|
Packit |
971217 |
pfd.nSize = sizeof (PIXELFORMATDESCRIPTOR);
|
|
Packit |
971217 |
pfd.nVersion = 1;
|
|
Packit |
971217 |
pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER;
|
|
Packit |
971217 |
pfd.iPixelType = PFD_TYPE_RGBA;
|
|
Packit |
971217 |
pfd.cColorBits = 24;
|
|
Packit |
971217 |
pfd.cRedBits = 8;
|
|
Packit |
971217 |
pfd.cRedShift = 0;
|
|
Packit |
971217 |
pfd.cGreenBits = 8;
|
|
Packit |
971217 |
pfd.cGreenShift = 0;
|
|
Packit |
971217 |
pfd.cBlueBits = 8;
|
|
Packit |
971217 |
pfd.cBlueShift = 0;
|
|
Packit |
971217 |
pfd.cAlphaBits = 0;
|
|
Packit |
971217 |
pfd.cAlphaShift = 0;
|
|
Packit |
971217 |
pfd.cAccumBits = 0;
|
|
Packit |
971217 |
pfd.cAccumRedBits = 0;
|
|
Packit |
971217 |
pfd.cAccumGreenBits = 0;
|
|
Packit |
971217 |
pfd.cAccumBlueBits = 0;
|
|
Packit |
971217 |
pfd.cAccumAlphaBits = 0;
|
|
Packit |
971217 |
pfd.cDepthBits = 24;
|
|
Packit |
971217 |
pfd.cStencilBits = 8;
|
|
Packit |
971217 |
pfd.cAuxBuffers = 0;
|
|
Packit |
971217 |
pfd.iLayerType = PFD_MAIN_PLANE;
|
|
Packit |
971217 |
pfd.bReserved = 0;
|
|
Packit |
971217 |
pfd.dwLayerMask = 0;
|
|
Packit |
971217 |
pfd.dwVisibleMask = 0;
|
|
Packit |
971217 |
pfd.dwDamageMask = 0;
|
|
Packit |
971217 |
|
|
Packit |
971217 |
pfd.cColorBits = (BYTE) GetDeviceCaps (device, BITSPIXEL);
|
|
Packit |
971217 |
|
|
Packit |
971217 |
pixelformat = ChoosePixelFormat (device, &pfd;;
|
|
Packit |
971217 |
|
|
Packit |
971217 |
if (!pixelformat) {
|
|
Packit |
971217 |
g_set_error (error, GST_GL_CONTEXT_ERROR, GST_GL_CONTEXT_ERROR_FAILED,
|
|
Packit |
971217 |
"Failed to choose a pixel format");
|
|
Packit |
971217 |
return FALSE;
|
|
Packit |
971217 |
}
|
|
Packit |
971217 |
|
|
Packit |
971217 |
res = SetPixelFormat (device, pixelformat, &pfd;;
|
|
Packit |
971217 |
|
|
Packit |
971217 |
return res;
|
|
Packit |
971217 |
}
|
|
Packit |
971217 |
|
|
Packit |
971217 |
static void
|
|
Packit |
971217 |
gst_gl_context_wgl_swap_buffers (GstGLContext * context)
|
|
Packit |
971217 |
{
|
|
Packit |
971217 |
GstGLWindow *window = gst_gl_context_get_window (context);
|
|
Packit |
971217 |
HDC device = (HDC) gst_gl_window_get_display (window);
|
|
Packit |
971217 |
|
|
Packit |
971217 |
SwapBuffers (device);
|
|
Packit |
971217 |
|
|
Packit |
971217 |
gst_object_unref (window);
|
|
Packit |
971217 |
}
|
|
Packit |
971217 |
|
|
Packit |
971217 |
static guintptr
|
|
Packit |
971217 |
gst_gl_context_wgl_get_gl_context (GstGLContext * context)
|
|
Packit |
971217 |
{
|
|
Packit |
971217 |
return (guintptr) GST_GL_CONTEXT_WGL (context)->wgl_context;
|
|
Packit |
971217 |
}
|
|
Packit |
971217 |
|
|
Packit |
971217 |
static gboolean
|
|
Packit |
971217 |
gst_gl_context_wgl_activate (GstGLContext * context, gboolean activate)
|
|
Packit |
971217 |
{
|
|
Packit |
971217 |
GstGLWindow *window;
|
|
Packit |
971217 |
GstGLContextWGL *context_wgl;
|
|
Packit |
971217 |
HDC device;
|
|
Packit |
971217 |
gboolean result;
|
|
Packit |
971217 |
|
|
Packit |
971217 |
window = gst_gl_context_get_window (context);
|
|
Packit |
971217 |
context_wgl = GST_GL_CONTEXT_WGL (context);
|
|
Packit |
971217 |
device = (HDC) gst_gl_window_get_display (window);
|
|
Packit |
971217 |
|
|
Packit |
971217 |
if (activate) {
|
|
Packit |
971217 |
result = wglMakeCurrent (device, context_wgl->wgl_context);
|
|
Packit |
971217 |
} else {
|
|
Packit |
971217 |
result = wglMakeCurrent (NULL, NULL);
|
|
Packit |
971217 |
}
|
|
Packit |
971217 |
|
|
Packit |
971217 |
gst_object_unref (window);
|
|
Packit |
971217 |
|
|
Packit |
971217 |
return result;
|
|
Packit |
971217 |
}
|
|
Packit |
971217 |
|
|
Packit |
971217 |
GstGLAPI
|
|
Packit |
971217 |
gst_gl_context_wgl_get_gl_api (GstGLContext * context)
|
|
Packit |
971217 |
{
|
|
Packit |
971217 |
GstGLContextWGL *context_wgl = GST_GL_CONTEXT_WGL (context);
|
|
Packit |
971217 |
|
|
Packit |
971217 |
return context_wgl->priv->context_api;
|
|
Packit |
971217 |
}
|
|
Packit |
971217 |
|
|
Packit |
971217 |
static GstGLPlatform
|
|
Packit |
971217 |
gst_gl_context_wgl_get_gl_platform (GstGLContext * context)
|
|
Packit |
971217 |
{
|
|
Packit |
971217 |
return GST_GL_PLATFORM_WGL;
|
|
Packit |
971217 |
}
|
|
Packit |
971217 |
|
|
Packit |
971217 |
gpointer
|
|
Packit |
971217 |
gst_gl_context_wgl_get_proc_address (GstGLAPI gl_api, const gchar * name)
|
|
Packit |
971217 |
{
|
|
Packit |
971217 |
gpointer result;
|
|
Packit |
971217 |
|
|
Packit |
971217 |
if (!(result = gst_gl_context_default_get_proc_address (gl_api, name))) {
|
|
Packit |
971217 |
result = wglGetProcAddress ((LPCSTR) name);
|
|
Packit |
971217 |
}
|
|
Packit |
971217 |
|
|
Packit |
971217 |
return result;
|
|
Packit |
971217 |
}
|
|
Packit |
971217 |
|
|
Packit |
971217 |
guintptr
|
|
Packit |
971217 |
gst_gl_context_wgl_get_current_context (void)
|
|
Packit |
971217 |
{
|
|
Packit |
971217 |
return (guintptr) wglGetCurrentContext ();
|
|
Packit |
971217 |
}
|