/*****************************************************************************
* glwin32.c: Windows OpenGL provider
*****************************************************************************
- * Copyright (C) 2001-2009 the VideoLAN team
+ * Copyright (C) 2001-2009 VLC authors and VideoLAN
* $Id$
*
* Authors: Gildas Bazin <gbazin@videolan.org>
*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
*
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#ifdef HAVE_CONFIG_H
# include "config.h"
#include <ddraw.h>
#include <commctrl.h>
-#include <multimon.h>
#undef GetSystemMetrics
#ifndef MONITOR_DEFAULTTONEAREST
#endif
#include "../opengl.h"
+#include <GL/wglew.h>
#include "common.h"
/*****************************************************************************
set_subcategory(SUBCAT_VIDEO_VOUT)
set_shortname("OpenGL")
set_description(N_("OpenGL video output"))
- set_capability("vout display", 20)
- add_shortcut("glwin32")
+ set_capability("vout display", 160)
+ add_shortcut("glwin32", "opengl")
set_callbacks(Open, Close)
-
- /* FIXME: Hack to avoid unregistering our window class */
- linked_with_a_crap_library_which_uses_atexit ()
vlc_module_end()
-#if 0 /* FIXME */
- /* check if we registered a window class because we need to
- * unregister it */
- WNDCLASS wndclass;
- if(GetClassInfo(GetModuleHandle(NULL), "VLC DirectX", &wndclass))
- UnregisterClass("VLC DirectX", GetModuleHandle(NULL));
-#endif
-
-
/*****************************************************************************
* Local prototypes.
*****************************************************************************/
-static picture_t *Get (vout_display_t *);
-static void Prepare(vout_display_t *, picture_t *);
-static void Display(vout_display_t *, picture_t *);
-static int Control(vout_display_t *, int, va_list);
-static void Manage (vout_display_t *);
+static picture_pool_t *Pool (vout_display_t *, unsigned);
+static void Prepare(vout_display_t *, picture_t *, subpicture_t *);
+static void Display(vout_display_t *, picture_t *, subpicture_t *);
+static int Control(vout_display_t *, int, va_list);
+static void Manage (vout_display_t *);
-static void Swap (vout_opengl_t *);
+static void Swap (vlc_gl_t *);
+static void *OurGetProcAddress(vlc_gl_t *, const char *);
/**
* It creates an OpenGL vout display.
sys->hGLRC = wglCreateContext(sys->hGLDC);
wglMakeCurrent(sys->hGLDC, sys->hGLRC);
+ const char *extensions = (const char*)glGetString(GL_EXTENSIONS);
+#ifdef WGL_EXT_swap_control
+ if (HasExtension(extensions, "WGL_EXT_swap_control")) {
+ PFNWGLSWAPINTERVALEXTPROC SwapIntervalEXT = (PFNWGLSWAPINTERVALEXTPROC)wglGetProcAddress("wglSwapIntervalEXT");
+ if (SwapIntervalEXT)
+ SwapIntervalEXT(1);
+ }
+#endif
+
/* */
sys->gl.lock = NULL;
sys->gl.unlock = NULL;
sys->gl.swap = Swap;
+ sys->gl.getProcAddress = OurGetProcAddress;
sys->gl.sys = vd;
video_format_t fmt = vd->fmt;
- if (vout_display_opengl_Init(&sys->vgl, &fmt, &sys->gl))
+ const vlc_fourcc_t *subpicture_chromas;
+ sys->vgl = vout_display_opengl_New(&fmt, &subpicture_chromas, &sys->gl);
+ if (!sys->vgl)
goto error;
vout_display_info_t info = vd->info;
info.has_double_click = true;
- info.has_hide_mouse = true;
- info.has_pictures_invalid = true;
+ info.has_hide_mouse = false;
+ info.has_event_thread = true;
+ info.subpicture_chromas = subpicture_chromas;
/* Setup vout_display now that everything is fine */
vd->fmt = fmt;
vd->info = info;
- vd->get = Get;
+ vd->pool = Pool;
vd->prepare = Prepare;
vd->display = Display;
vd->control = Control;
vout_display_t *vd = (vout_display_t *)object;
vout_display_sys_t *sys = vd->sys;
- if (sys->vgl.gl)
- vout_display_opengl_Clean(&sys->vgl);
+ if (sys->vgl)
+ vout_display_opengl_Delete(sys->vgl);
if (sys->hGLDC && sys->hGLRC)
wglMakeCurrent(NULL, NULL);
}
/* */
-static picture_t *Get(vout_display_t *vd)
+static picture_pool_t *Pool(vout_display_t *vd, unsigned count)
{
vout_display_sys_t *sys = vd->sys;
- if (!sys->pool) {
- sys->pool = vout_display_opengl_GetPool(&sys->vgl);
- if (!sys->pool)
- return NULL;
- }
- return picture_pool_Get(sys->pool);
+ if (!sys->pool)
+ sys->pool = vout_display_opengl_GetPool(sys->vgl, count);
+ return sys->pool;
}
-static void Prepare(vout_display_t *vd, picture_t *picture)
+static void Prepare(vout_display_t *vd, picture_t *picture, subpicture_t *subpicture)
{
vout_display_sys_t *sys = vd->sys;
- vout_display_opengl_Prepare(&sys->vgl, picture);
+ vout_display_opengl_Prepare(sys->vgl, picture, subpicture);
}
-static void Display(vout_display_t *vd, picture_t *picture)
+static void Display(vout_display_t *vd, picture_t *picture, subpicture_t *subpicture)
{
vout_display_sys_t *sys = vd->sys;
- vout_display_opengl_Display(&sys->vgl, &vd->source);
+ vout_display_opengl_Display(sys->vgl, &vd->source);
picture_Release(picture);
+ if (subpicture)
+ subpicture_Delete(subpicture);
CommonDisplay(vd);
}
static int Control(vout_display_t *vd, int query, va_list args)
{
- return CommonControl(vd, query, args);
+ switch (query) {
+ case VOUT_DISPLAY_GET_OPENGL: {
+ vlc_gl_t **gl = va_arg(args, vlc_gl_t **);
+ *gl = &vd->sys->gl;
+
+ CommonDisplay(vd);
+ return VLC_SUCCESS;
+ }
+ default:
+ return CommonControl(vd, query, args);
+ }
}
static void Manage (vout_display_t *vd)
glViewport(0, 0, width, height);
}
-static void Swap(vout_opengl_t *gl)
+static void Swap(vlc_gl_t *gl)
{
vout_display_t *vd = gl->sys;
SwapBuffers(vd->sys->hGLDC);
}
+static void *OurGetProcAddress(vlc_gl_t *gl, const char *name)
+{
+ VLC_UNUSED(gl);
+ return wglGetProcAddress(name);
+}
+