summaryrefslogtreecommitdiffstats
path: root/libvo/vo_direct3d.c
diff options
context:
space:
mode:
authorUoti Urpala <uau@glyph.nonexistent.invalid>2010-01-08 02:06:42 +0200
committerUoti Urpala <uau@glyph.nonexistent.invalid>2010-01-08 02:06:42 +0200
commit17eb7f2c4bb070d9477792fcbd4a5120ee1a789c (patch)
tree702cfe702169effb14fbabb3f50d289c1683147d /libvo/vo_direct3d.c
parentff3ef4e7827424db7444cdb7973faa499e054ac5 (diff)
parenteb6fc7e99e07712b74c17c917aa33704ef6e410a (diff)
downloadmpv-17eb7f2c4bb070d9477792fcbd4a5120ee1a789c.tar.bz2
mpv-17eb7f2c4bb070d9477792fcbd4a5120ee1a789c.tar.xz
Merge svn changes up to r30195
Diffstat (limited to 'libvo/vo_direct3d.c')
-rw-r--r--libvo/vo_direct3d.c37
1 files changed, 30 insertions, 7 deletions
diff --git a/libvo/vo_direct3d.c b/libvo/vo_direct3d.c
index 7094af8823..384dcb477b 100644
--- a/libvo/vo_direct3d.c
+++ b/libvo/vo_direct3d.c
@@ -70,6 +70,10 @@ static struct global_priv {
the movie's codec) */
D3DFORMAT desktop_fmt; /**< Desktop (screen) colorspace format.
Usually XRGB */
+
+ HANDLE d3d9_dll; /**< d3d9 Library HANDLE */
+ IDirect3D9 * (WINAPI *pDirect3DCreate9)(UINT); /**< pointer to Direct3DCreate9 function */
+
LPDIRECT3D9 d3d_handle; /**< Direct3D Handle */
LPDIRECT3DDEVICE9 d3d_device; /**< The Direct3D Adapter */
IDirect3DSurface9 *d3d_surface; /**< Offscreen Direct3D Surface. MPlayer
@@ -441,7 +445,7 @@ static int reconfigure_d3d(void)
IDirect3D9_Release(priv->d3d_handle);
/* Initialize Direct3D from the beginning */
- priv->d3d_handle = Direct3DCreate9(D3D_SDK_VERSION);
+ priv->d3d_handle = priv->pDirect3DCreate9(D3D_SDK_VERSION);
if (!priv->d3d_handle) {
mp_msg(MSGT_VO, MSGL_ERR, "<vo_direct3d>Initializing Direct3D failed.\n");
return 0;
@@ -670,7 +674,7 @@ static int preinit(const char *arg)
priv = calloc(1, sizeof(struct global_priv));
if (!priv) {
mp_msg(MSGT_VO, MSGL_ERR, "<vo_direct3d>Allocating private memory failed.\n");
- return -1;
+ goto err_out;
}
/* FIXME
@@ -678,17 +682,29 @@ static int preinit(const char *arg)
> an example of how to use it.
*/
- priv->d3d_handle = Direct3DCreate9(D3D_SDK_VERSION);
+ priv->d3d9_dll = LoadLibraryA("d3d9.dll");
+ if (!priv->d3d9_dll) {
+ mp_msg(MSGT_VO, MSGL_ERR, "<vo_direct3d>Unable to dynamically load d3d9.dll\n");
+ goto err_out;
+ }
+
+ priv->pDirect3DCreate9 = (void *)GetProcAddress(priv->d3d9_dll, "Direct3DCreate9");
+ if (!priv->pDirect3DCreate9) {
+ mp_msg(MSGT_VO, MSGL_ERR, "<vo_direct3d>Unable to find entry point of Direct3DCreate9\n");
+ goto err_out;
+ }
+
+ priv->d3d_handle = priv->pDirect3DCreate9(D3D_SDK_VERSION);
if (!priv->d3d_handle) {
mp_msg(MSGT_VO, MSGL_ERR, "<vo_direct3d>Initializing Direct3D failed.\n");
- return -1;
+ goto err_out;
}
if (FAILED(IDirect3D9_GetAdapterDisplayMode(priv->d3d_handle,
D3DADAPTER_DEFAULT,
&disp_mode))) {
mp_msg(MSGT_VO, MSGL_ERR, "<vo_direct3d>Reading display mode failed.\n");
- return -1;
+ goto err_out;
}
/* Store in priv->desktop_fmt the user desktop's colorspace. Usually XRGB. */
@@ -704,7 +720,7 @@ static int preinit(const char *arg)
D3DDEVTYPE_HAL,
&disp_caps))) {
mp_msg(MSGT_VO, MSGL_ERR, "<vo_direct3d>Reading display capabilities failed.\n");
- return -1;
+ goto err_out;
}
/* Store relevant information reguarding caps of device */
@@ -729,10 +745,14 @@ static int preinit(const char *arg)
*/
if (!vo_w32_init()) {
mp_msg(MSGT_VO, MSGL_V, "<vo_direct3d>Configuring onscreen window failed.\n");
- return -1;
+ goto err_out;
}
return 0;
+
+err_out:
+ uninit();
+ return -1;
}
@@ -859,6 +879,9 @@ static void uninit(void)
uninit_d3d();
vo_w32_uninit(); /* w32_common framework call */
+ if (priv->d3d9_dll)
+ FreeLibrary(priv->d3d9_dll);
+ priv->d3d9_dll = NULL;
free(priv);
priv = NULL;
}