WineD3D on Windows

Compiling WineD3D for use on Windows

WineD3D is the core of Wine's Direct3D implementation. In WineD3D we translate Direct3D functions to Windows OpenGL. The use of Windows OpenGL allows WineD3D and several Direct3D dlls to function on Windows.

At the moment Direct3D8 (d3d8.dll) , Direct3D9 (d3d9.dll), Direct3D 10 (d3d10.dll and d3d10core.dll), and Direct3D 11 (d3d11.dll and dxgi.dll) can be used on Windows. DirectDraw and Direct3D<7 can be tricky to use because when ddraw.dll will load opengl32.dll which loads ddraw.dll again causing a loop and crashing the program. A workaround is to rename ddraw.dll to something equally long, like ddfuk.dll and then use an hex editor to change all references in the program's exe and dll files from ddraw.dll to ddfuk.dll.

The Wine 3D dlls can be cross-compiled like any other Wine dll or test. Care should be taken that '-DUSE_WIN32_OPENGL' is used when compiling WineD3D. This flag is needed because on Windows we load gl functions from opengl32.dll but on Linux we have a hack around to use

The script below can be used to cross-compile d3d8/d3d9/wined3d from a Linux machine. The script has been tested on Debian and Ubuntu. On Debian/Ubuntu the mingw binaries are all prefixed with 'i586-mingw32msvc' hence '--host=i586-mingw32msvc' on Gentoo for instance a different prefix is used and there you need '--host=i686-mingw32'. The script assumes mingw is around, that git is installed and that wine's build deps are installed.

set -ex
unset CC
rm -rf wine-tools wine-win32 wine-git
mkdir wine-tools wine-win32
git clone git:// ./wine-git
cd wine-tools
../wine-git/configure --without-x
make __tooldeps__
cd ..
cd wine-win32
../wine-git/configure --without-x --without-freetype --host=i586-mingw32msvc CFLAGS="-O2 -DWINE_NOWINSOCK -DUSE_WIN32_OPENGL" --with-wine-tools=../wine-tools/ LDFLAGS=" -static-libgcc"
make dlls/wined3d dlls/ddraw dlls/d3d8 dlls/d3d9 dlls/d3d10 dlls/d3d10core dlls/d3d11 dlls/dxgi
cp libs/wine/libwine.dll dlls/wined3d/wined3d.dll dlls/ddraw/ddraw.dll dlls/d3d8/d3d8.dll dlls/d3d9/d3d9.dll dlls/d3d10/d3d10.dll dlls/d3d10core/d3d10core.dll dlls/d3d11/d3d11.dll dlls/dxgi/dxgi.dll ../
cd ..
rm -rf wine-tools wine-win32 wine-git


Note: precompiled versions of WineD3D from official Wine releases are available at or (old releases)

After compilation you need to copy all the dlls you've built. You can place the dlls in the directory of the program you want to run.

Alternatively, you can install them system-wide by copying them to c:\windows\system32\ (overwriting Microsoft versions) and removing d3d8.dll and d3d9.dll in c:\windows\system32\dllcache\. Note that if you do that, Windows will detect this, and will prompt you to insert the installation CD to revert to MS versions of the DLLs.

You might also be interested in wiki page Parallels to follow code changes being made.

Software emulation and pseudo-dedicated server

Sometimes it's useful to run an emulated D3D backend with null 3D display, allowing for running games as dedicated servers, which weren't designed to in the first place!

Please clone my wined3d-null branch if interested.

If one needs a headless server, it's recommended to run tightvnc (Debian sid binary will suffice if libgl1-mesa-swx11 is installed) due to its GLX support.

It's even possible to cross-compile Wine and Mesa for i686-w64-mingw32 for Windows support of aforementioned functionality.

For Mesa:

scons build=release machine=generic platform=windows toolchain=crossmingw llvm=no debug=yes verbose=yes texture_float=no libgl-gdi

For Wine:

$HOME/dev/wine/configure --without-x --without-freetype --host=i686-w64-mingw32 --target=i686-w64-mingw32 CFLAGS='-O2 -g -DWINE_NOWINSOCK -DUSE_WIN32_OPENGL' --with-wine-tools=$HOME/dev/wine-build-mingw/win32/.. ac_cv_prog_DLLWRAP='i686-w64-mingw32-gcc -shared -shared-libgcc'

You may need to force-enable -shared-libgcc and -lstdc++ for Mesa. There were nasty libgcc crashes seen with static linking.

WineD3DOnWindows (last edited 2015-08-22 06:43:16 by dosse91)