]> git.pld-linux.org Git - packages/wine.git/blame - wine-d3d9patch.patch
- 20050628
[packages/wine.git] / wine-d3d9patch.patch
CommitLineData
87d5d4d9 1diff -urN wine.20050419/configure wine.20050419.dx9/configure
2--- wine.20050419/configure 2005-04-19 06:54:44.000000000 -0600
3+++ wine.20050419.dx9/configure 2005-04-20 03:02:02.000000000 -0600
4@@ -20054,7 +20054,7 @@
5 MAKE_PROG_RULES=programs/Makeprog.rules
6
7
8- ac_config_files="$ac_config_files Make.rules dlls/Makedll.rules dlls/Maketest.rules libs/Makelib.rules programs/Makeprog.rules Makefile dlls/Makefile dlls/advapi32/Makefile dlls/advapi32/tests/Makefile dlls/advpack/Makefile dlls/advpack/tests/Makefile dlls/amstream/Makefile dlls/atl/Makefile dlls/avicap32/Makefile dlls/avifil32/Makefile dlls/cabinet/Makefile dlls/capi2032/Makefile dlls/cards/Makefile dlls/cfgmgr32/Makefile dlls/comcat/Makefile dlls/comctl32/Makefile dlls/comctl32/tests/Makefile dlls/commdlg/Makefile dlls/crtdll/Makefile dlls/crypt32/Makefile dlls/cryptdll/Makefile dlls/ctl3d/Makefile dlls/d3d8/Makefile dlls/d3d9/Makefile dlls/d3dim/Makefile dlls/d3drm/Makefile dlls/d3dx8/Makefile dlls/d3dxof/Makefile dlls/dbghelp/Makefile dlls/dciman32/Makefile dlls/ddraw/Makefile dlls/ddraw/tests/Makefile dlls/devenum/Makefile dlls/dinput/Makefile dlls/dinput8/Makefile dlls/dmband/Makefile dlls/dmcompos/Makefile dlls/dmime/Makefile dlls/dmloader/Makefile dlls/dmscript/Makefile dlls/dmstyle/Makefile dlls/dmsynth/Makefile dlls/dmusic/Makefile dlls/dmusic32/Makefile dlls/dplay/Makefile dlls/dplayx/Makefile dlls/dpnet/Makefile dlls/dpnhpast/Makefile dlls/dsound/Makefile dlls/dsound/tests/Makefile dlls/dswave/Makefile dlls/dxdiagn/Makefile dlls/dxerr8/Makefile dlls/dxerr9/Makefile dlls/dxguid/Makefile dlls/gdi/Makefile dlls/gdi/tests/Makefile dlls/glu32/Makefile dlls/glut32/Makefile dlls/hhctrl.ocx/Makefile dlls/iccvid/Makefile dlls/icmp/Makefile dlls/ifsmgr.vxd/Makefile dlls/imagehlp/Makefile dlls/imm32/Makefile dlls/iphlpapi/Makefile dlls/iphlpapi/tests/Makefile dlls/itss/Makefile dlls/kernel/Makefile dlls/kernel/tests/Makefile dlls/lzexpand/Makefile dlls/lzexpand/tests/Makefile dlls/mapi32/Makefile dlls/mapi32/tests/Makefile dlls/mlang/Makefile dlls/mlang/tests/Makefile dlls/mmdevldr.vxd/Makefile dlls/monodebg.vxd/Makefile dlls/mpr/Makefile dlls/msacm/Makefile dlls/msacm/imaadp32/Makefile dlls/msacm/msadp32/Makefile dlls/msacm/msg711/Makefile dlls/msacm/winemp3/Makefile dlls/msacm/tests/Makefile dlls/mscms/Makefile dlls/mscms/tests/Makefile dlls/msdmo/Makefile dlls/mshtml/Makefile dlls/msi/Makefile dlls/msi/tests/Makefile dlls/msimg32/Makefile dlls/msisys/Makefile dlls/msnet32/Makefile dlls/msrle32/Makefile dlls/msvcrt/Makefile dlls/msvcrt/tests/Makefile dlls/msvcrt20/Makefile dlls/msvcrt40/Makefile dlls/msvcrtd/Makefile dlls/msvcrtd/tests/Makefile dlls/msvidc32/Makefile dlls/msvideo/Makefile dlls/mswsock/Makefile dlls/netapi32/Makefile dlls/netapi32/tests/Makefile dlls/newdev/Makefile dlls/ntdll/Makefile dlls/ntdll/tests/Makefile dlls/odbc32/Makefile dlls/ole32/Makefile dlls/ole32/tests/Makefile dlls/oleacc/Makefile dlls/oleaut32/Makefile dlls/oleaut32/tests/Makefile dlls/olecli/Makefile dlls/oledlg/Makefile dlls/olepro32/Makefile dlls/olesvr/Makefile dlls/opengl32/Makefile dlls/psapi/Makefile dlls/psapi/tests/Makefile dlls/qcap/Makefile dlls/quartz/Makefile dlls/quartz/tests/Makefile dlls/rasapi32/Makefile dlls/riched20/Makefile dlls/richedit/Makefile dlls/rpcrt4/Makefile dlls/rpcrt4/tests/Makefile dlls/rsabase/Makefile dlls/rsabase/tests/Makefile dlls/rsaenh/Makefile dlls/rsaenh/tests/Makefile dlls/secur32/Makefile dlls/sensapi/Makefile dlls/serialui/Makefile dlls/setupapi/Makefile dlls/shdocvw/Makefile dlls/shell32/Makefile dlls/shell32/tests/Makefile dlls/shfolder/Makefile dlls/shlwapi/Makefile dlls/shlwapi/tests/Makefile dlls/snmpapi/Makefile dlls/stdole32.tlb/Makefile dlls/sti/Makefile dlls/strmiids/Makefile dlls/tapi32/Makefile dlls/ttydrv/Makefile dlls/twain/Makefile dlls/unicows/Makefile dlls/url/Makefile dlls/urlmon/Makefile dlls/urlmon/tests/Makefile dlls/user/Makefile dlls/user/tests/Makefile dlls/uuid/Makefile dlls/uxtheme/Makefile dlls/vdhcp.vxd/Makefile dlls/vdmdbg/Makefile dlls/version/Makefile dlls/version/tests/Makefile dlls/vmm.vxd/Makefile dlls/vnbt.vxd/Makefile dlls/vnetbios.vxd/Makefile dlls/vtdapi.vxd/Makefile dlls/vwin32.vxd/Makefile dlls/win32s/Makefile dlls/winaspi/Makefile dlls/wined3d/Makefile dlls/winedos/Makefile dlls/wineps/Makefile dlls/wininet/Makefile dlls/wininet/tests/Makefile dlls/winmm/Makefile dlls/winmm/joystick/Makefile dlls/winmm/mcianim/Makefile dlls/winmm/mciavi/Makefile dlls/winmm/mcicda/Makefile dlls/winmm/mciseq/Makefile dlls/winmm/mciwave/Makefile dlls/winmm/midimap/Makefile dlls/winmm/tests/Makefile dlls/winmm/wavemap/Makefile dlls/winmm/winealsa/Makefile dlls/winmm/winearts/Makefile dlls/winmm/wineaudioio/Makefile dlls/winmm/winejack/Makefile dlls/winmm/winenas/Makefile dlls/winmm/wineoss/Makefile dlls/winnls/Makefile dlls/winsock/Makefile dlls/winsock/tests/Makefile dlls/winspool/Makefile dlls/winspool/tests/Makefile dlls/wintab32/Makefile dlls/wintrust/Makefile dlls/wow32/Makefile dlls/wsock32/Makefile dlls/wtsapi32/Makefile dlls/x11drv/Makefile documentation/Makefile fonts/Makefile include/Makefile libs/Makefile libs/port/Makefile libs/unicode/Makefile libs/wine/Makefile libs/wpp/Makefile loader/Makefile programs/Makefile programs/avitools/Makefile programs/clock/Makefile programs/cmdlgtst/Makefile programs/control/Makefile programs/expand/Makefile programs/msiexec/Makefile programs/notepad/Makefile programs/progman/Makefile programs/regedit/Makefile programs/regsvr32/Makefile programs/rpcss/Makefile programs/rundll32/Makefile programs/start/Makefile programs/taskmgr/Makefile programs/uninstaller/Makefile programs/view/Makefile programs/wcmd/Makefile programs/wineboot/Makefile programs/winebrowser/Makefile programs/winecfg/Makefile programs/wineconsole/Makefile programs/winedbg/Makefile programs/winefile/Makefile programs/winemenubuilder/Makefile programs/winemine/Makefile programs/winepath/Makefile programs/winetest/Makefile programs/winevdm/Makefile programs/winhelp/Makefile programs/winver/Makefile server/Makefile tools/Makefile tools/widl/Makefile tools/winapi/Makefile tools/winebuild/Makefile tools/winedump/Makefile tools/winegcc/Makefile tools/wmc/Makefile tools/wrc/Makefile"
9+ ac_config_files="$ac_config_files Make.rules dlls/Makedll.rules dlls/Maketest.rules libs/Makelib.rules programs/Makeprog.rules Makefile dlls/Makefile dlls/advapi32/Makefile dlls/advapi32/tests/Makefile dlls/advpack/Makefile dlls/advpack/tests/Makefile dlls/amstream/Makefile dlls/atl/Makefile dlls/avicap32/Makefile dlls/avifil32/Makefile dlls/cabinet/Makefile dlls/capi2032/Makefile dlls/cards/Makefile dlls/cfgmgr32/Makefile dlls/comcat/Makefile dlls/comctl32/Makefile dlls/comctl32/tests/Makefile dlls/commdlg/Makefile dlls/crtdll/Makefile dlls/crypt32/Makefile dlls/cryptdll/Makefile dlls/ctl3d/Makefile dlls/d3d8/Makefile dlls/d3d9/Makefile dlls/d3dim/Makefile dlls/d3drm/Makefile dlls/d3dx8/Makefile dlls/d3dx9/Makefile dlls/d3dxof/Makefile dlls/dbghelp/Makefile dlls/dciman32/Makefile dlls/ddraw/Makefile dlls/ddraw/tests/Makefile dlls/devenum/Makefile dlls/dinput/Makefile dlls/dinput8/Makefile dlls/dmband/Makefile dlls/dmcompos/Makefile dlls/dmime/Makefile dlls/dmloader/Makefile dlls/dmscript/Makefile dlls/dmstyle/Makefile dlls/dmsynth/Makefile dlls/dmusic/Makefile dlls/dmusic32/Makefile dlls/dplay/Makefile dlls/dplayx/Makefile dlls/dpnet/Makefile dlls/dpnhpast/Makefile dlls/dsound/Makefile dlls/dsound/tests/Makefile dlls/dswave/Makefile dlls/dxdiagn/Makefile dlls/dxerr8/Makefile dlls/dxerr9/Makefile dlls/dxguid/Makefile dlls/gdi/Makefile dlls/gdi/tests/Makefile dlls/glu32/Makefile dlls/glut32/Makefile dlls/hhctrl.ocx/Makefile dlls/iccvid/Makefile dlls/icmp/Makefile dlls/ifsmgr.vxd/Makefile dlls/imagehlp/Makefile dlls/imm32/Makefile dlls/iphlpapi/Makefile dlls/iphlpapi/tests/Makefile dlls/itss/Makefile dlls/kernel/Makefile dlls/kernel/tests/Makefile dlls/lzexpand/Makefile dlls/lzexpand/tests/Makefile dlls/mapi32/Makefile dlls/mapi32/tests/Makefile dlls/mlang/Makefile dlls/mlang/tests/Makefile dlls/mmdevldr.vxd/Makefile dlls/monodebg.vxd/Makefile dlls/mpr/Makefile dlls/msacm/Makefile dlls/msacm/imaadp32/Makefile dlls/msacm/msadp32/Makefile dlls/msacm/msg711/Makefile dlls/msacm/winemp3/Makefile dlls/msacm/tests/Makefile dlls/mscms/Makefile dlls/mscms/tests/Makefile dlls/msdmo/Makefile dlls/mshtml/Makefile dlls/msi/Makefile dlls/msi/tests/Makefile dlls/msimg32/Makefile dlls/msisys/Makefile dlls/msnet32/Makefile dlls/msrle32/Makefile dlls/msvcrt/Makefile dlls/msvcrt/tests/Makefile dlls/msvcrt20/Makefile dlls/msvcrt40/Makefile dlls/msvcrtd/Makefile dlls/msvcrtd/tests/Makefile dlls/msvidc32/Makefile dlls/msvideo/Makefile dlls/mswsock/Makefile dlls/netapi32/Makefile dlls/netapi32/tests/Makefile dlls/newdev/Makefile dlls/ntdll/Makefile dlls/ntdll/tests/Makefile dlls/odbc32/Makefile dlls/ole32/Makefile dlls/ole32/tests/Makefile dlls/oleacc/Makefile dlls/oleaut32/Makefile dlls/oleaut32/tests/Makefile dlls/olecli/Makefile dlls/oledlg/Makefile dlls/olepro32/Makefile dlls/olesvr/Makefile dlls/opengl32/Makefile dlls/psapi/Makefile dlls/psapi/tests/Makefile dlls/qcap/Makefile dlls/quartz/Makefile dlls/quartz/tests/Makefile dlls/rasapi32/Makefile dlls/riched20/Makefile dlls/richedit/Makefile dlls/rpcrt4/Makefile dlls/rpcrt4/tests/Makefile dlls/rsabase/Makefile dlls/rsabase/tests/Makefile dlls/rsaenh/Makefile dlls/rsaenh/tests/Makefile dlls/secur32/Makefile dlls/sensapi/Makefile dlls/serialui/Makefile dlls/setupapi/Makefile dlls/shdocvw/Makefile dlls/shell32/Makefile dlls/shell32/tests/Makefile dlls/shfolder/Makefile dlls/shlwapi/Makefile dlls/shlwapi/tests/Makefile dlls/snmpapi/Makefile dlls/stdole32.tlb/Makefile dlls/sti/Makefile dlls/strmiids/Makefile dlls/tapi32/Makefile dlls/ttydrv/Makefile dlls/twain/Makefile dlls/unicows/Makefile dlls/url/Makefile dlls/urlmon/Makefile dlls/urlmon/tests/Makefile dlls/user/Makefile dlls/user/tests/Makefile dlls/uuid/Makefile dlls/uxtheme/Makefile dlls/vdhcp.vxd/Makefile dlls/vdmdbg/Makefile dlls/version/Makefile dlls/version/tests/Makefile dlls/vmm.vxd/Makefile dlls/vnbt.vxd/Makefile dlls/vnetbios.vxd/Makefile dlls/vtdapi.vxd/Makefile dlls/vwin32.vxd/Makefile dlls/win32s/Makefile dlls/winaspi/Makefile dlls/wined3d/Makefile dlls/winedos/Makefile dlls/wineps/Makefile dlls/wininet/Makefile dlls/wininet/tests/Makefile dlls/winmm/Makefile dlls/winmm/joystick/Makefile dlls/winmm/mcianim/Makefile dlls/winmm/mciavi/Makefile dlls/winmm/mcicda/Makefile dlls/winmm/mciseq/Makefile dlls/winmm/mciwave/Makefile dlls/winmm/midimap/Makefile dlls/winmm/tests/Makefile dlls/winmm/wavemap/Makefile dlls/winmm/winealsa/Makefile dlls/winmm/winearts/Makefile dlls/winmm/wineaudioio/Makefile dlls/winmm/winejack/Makefile dlls/winmm/winenas/Makefile dlls/winmm/wineoss/Makefile dlls/winnls/Makefile dlls/winsock/Makefile dlls/winsock/tests/Makefile dlls/winspool/Makefile dlls/winspool/tests/Makefile dlls/wintab32/Makefile dlls/wintrust/Makefile dlls/wow32/Makefile dlls/wsock32/Makefile dlls/wtsapi32/Makefile dlls/x11drv/Makefile documentation/Makefile fonts/Makefile include/Makefile libs/Makefile libs/port/Makefile libs/unicode/Makefile libs/wine/Makefile libs/wpp/Makefile loader/Makefile programs/Makefile programs/avitools/Makefile programs/clock/Makefile programs/cmdlgtst/Makefile programs/control/Makefile programs/expand/Makefile programs/msiexec/Makefile programs/notepad/Makefile programs/progman/Makefile programs/regedit/Makefile programs/regsvr32/Makefile programs/rpcss/Makefile programs/rundll32/Makefile programs/start/Makefile programs/taskmgr/Makefile programs/uninstaller/Makefile programs/view/Makefile programs/wcmd/Makefile programs/wineboot/Makefile programs/winebrowser/Makefile programs/winecfg/Makefile programs/wineconsole/Makefile programs/winedbg/Makefile programs/winefile/Makefile programs/winemenubuilder/Makefile programs/winemine/Makefile programs/winepath/Makefile programs/winetest/Makefile programs/winevdm/Makefile programs/winhelp/Makefile programs/winver/Makefile server/Makefile tools/Makefile tools/widl/Makefile tools/winapi/Makefile tools/winebuild/Makefile tools/winedump/Makefile tools/winegcc/Makefile tools/wmc/Makefile tools/wrc/Makefile"
10
11
12 cat >confcache <<\_ACEOF
13@@ -20617,6 +20617,7 @@
14 "dlls/d3dim/Makefile" ) CONFIG_FILES="$CONFIG_FILES dlls/d3dim/Makefile" ;;
15 "dlls/d3drm/Makefile" ) CONFIG_FILES="$CONFIG_FILES dlls/d3drm/Makefile" ;;
16 "dlls/d3dx8/Makefile" ) CONFIG_FILES="$CONFIG_FILES dlls/d3dx8/Makefile" ;;
17+ "dlls/d3dx9/Makefile" ) CONFIG_FILES="$CONFIG_FILES dlls/d3dx9/Makefile" ;;
18 "dlls/d3dxof/Makefile" ) CONFIG_FILES="$CONFIG_FILES dlls/d3dxof/Makefile" ;;
19 "dlls/dbghelp/Makefile" ) CONFIG_FILES="$CONFIG_FILES dlls/dbghelp/Makefile" ;;
20 "dlls/dciman32/Makefile" ) CONFIG_FILES="$CONFIG_FILES dlls/dciman32/Makefile" ;;
21diff -urN wine.20050419/configure.ac wine.20050419.dx9/configure.ac
22--- wine.20050419/configure.ac 2005-03-28 02:58:45.000000000 -0700
23+++ wine.20050419.dx9/configure.ac 2005-04-20 01:52:56.000000000 -0600
24@@ -1536,6 +1536,7 @@
25 dlls/d3dim/Makefile
26 dlls/d3drm/Makefile
27 dlls/d3dx8/Makefile
28+dlls/d3dx9/Makefile
29 dlls/d3dxof/Makefile
30 dlls/dbghelp/Makefile
31 dlls/dciman32/Makefile
32diff -urN wine.20050419/dlls/Makefile.in wine.20050419.dx9/dlls/Makefile.in
33--- wine.20050419/dlls/Makefile.in 2005-03-05 04:19:14.000000000 -0700
34+++ wine.20050419.dx9/dlls/Makefile.in 2005-04-20 01:52:56.000000000 -0600
35@@ -9,7 +9,7 @@
36
37 GLU32FILES = glu32
38 GLUT32FILES = glut32
39-OPENGLFILES = d3d8 d3d9 d3dx8 opengl32 wined3d
40+OPENGLFILES = d3d8 d3d9 d3dx8 d3dx9 opengl32 wined3d
41 XFILES = ddraw x11drv
42 EXTRADIRS = @GLU32FILES@ @GLUT32FILES@ @OPENGLFILES@ @XFILES@
43
44@@ -174,6 +174,7 @@
45 d3d8 \
46 d3d9 \
47 d3dx8 \
48+ d3dx9 \
49 ddraw \
50 dxerr8 \
51 dxerr9 \
52@@ -494,6 +495,9 @@
53 d3dx8.dll.so: d3dx8/d3dx8.dll.so
54 $(RM) $@ && $(LN_S) d3dx8/d3dx8.dll.so $@
55
56+d3dx9.dll.so: d3dx9/d3dx9.dll.so
57+ $(RM) $@ && $(LN_S) d3dx9/d3dx9.dll.so $@
58+
59 d3dxof.dll.so: d3dxof/d3dxof.dll.so
60 $(RM) $@ && $(LN_S) d3dxof/d3dxof.dll.so $@
61
62@@ -1003,7 +1007,6 @@
63 libuuid.a: uuid/libuuid.a
64 $(RM) $@ && $(LN_S) uuid/libuuid.a $@
65
66-
67 # Import libraries
68
69 IMPORT_LIBS = \
70@@ -1029,6 +1032,7 @@
71 libd3dim.$(IMPLIBEXT) \
72 libd3drm.$(IMPLIBEXT) \
73 libd3dx8.$(IMPLIBEXT) \
74+ libd3dx9.$(IMPLIBEXT) \
75 libd3dxof.$(IMPLIBEXT) \
76 libdbghelp.$(IMPLIBEXT) \
77 libdciman32.$(IMPLIBEXT) \
78@@ -1256,6 +1260,11 @@
79 libd3dx8.a: d3dx8/d3dx8.spec.def
80 $(DLLTOOL) -k -l $@ -d d3dx8/d3dx8.spec.def
81
82+libd3dx9.def: d3dx9/d3dx9.spec.def
83+ $(RM) $@ && $(LN_S) d3dx9/d3dx9.spec.def $@
84+libd3dx9.a: d3dx9/d3dx9.spec.def
85+ $(DLLTOOL) -k -l $@ -d d3dx9/d3dx9.spec.def
86+
87 libd3dxof.def: d3dxof/d3dxof.spec.def
88 $(RM) $@ && $(LN_S) d3dxof/d3dxof.spec.def $@
89 libd3dxof.a: d3dxof/d3dxof.spec.def
90@@ -1823,6 +1832,7 @@
91 d3dim/d3dim.spec.def: $(WINEBUILD)
92 d3drm/d3drm.spec.def: $(WINEBUILD)
93 d3dx8/d3dx8.spec.def: $(WINEBUILD)
94+d3dx9/d3dx9.spec.def: $(WINEBUILD)
95 d3dxof/d3dxof.spec.def: $(WINEBUILD)
96 dbghelp/dbghelp.spec.def: $(WINEBUILD)
97 dciman32/dciman32.spec.def: $(WINEBUILD)
98@@ -1960,6 +1970,7 @@
99 d3dim/d3dim.dll.so: d3dim
100 d3drm/d3drm.dll.so: d3drm
101 d3dx8/d3dx8.dll.so: d3dx8
102+d3dx9/d3dx9.dll.so: d3dx9
103 d3dxof/d3dxof.dll.so: d3dxof
104 dbghelp/dbghelp.dll.so: dbghelp
105 dciman32/dciman32.dll.so: dciman32
106diff -urN wine.20050419/dlls/d3d8/d3d8_private.h wine.20050419.dx9/dlls/d3d8/d3d8_private.h
107--- wine.20050419/dlls/d3d8/d3d8_private.h 2005-03-23 06:15:20.000000000 -0700
108+++ wine.20050419.dx9/dlls/d3d8/d3d8_private.h 2005-04-20 01:52:56.000000000 -0600
109@@ -596,6 +596,9 @@
110 /* OpenGL/GLX related */
111 GLXContext swap_ctx;
112 Drawable swap_drawable;
113+
114+ /* ready for when we move over to wined3d */
115+ IWineD3DSwapChain *wineD3DSwapChain;
116 };
117
118 /* IUnknown: */
119diff -urN wine.20050419/dlls/d3d8/device.c wine.20050419.dx9/dlls/d3d8/device.c
120--- wine.20050419/dlls/d3d8/device.c 2005-03-23 06:15:20.000000000 -0700
121+++ wine.20050419.dx9/dlls/d3d8/device.c 2005-04-20 01:52:56.000000000 -0600
122@@ -70,6 +70,12 @@
123 memcpy(gl_mat, (mat), 16 * sizeof(float)); \
124 } while (0)
125
126+
127+/*internal function, (static) */
128+
129+HRESULT WINAPI IDirect3DDevice8Impl_CreateSurface(LPDIRECT3DDEVICE8 , UINT , UINT , D3DFORMAT , BOOL Lockable,
130+ IDirect3DSurface8** ppSurface, D3DRESOURCETYPE , UINT ,D3DPOOL , D3DMULTISAMPLE_TYPE );
131+
132 /* Apply the current values to the specified texture stage */
133 void setupTextureStates(LPDIRECT3DDEVICE8 iface, DWORD Stage, DWORD Flags) {
134 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
135@@ -352,9 +358,90 @@
136 }
137 HRESULT WINAPI IDirect3DDevice8Impl_GetDeviceCaps(LPDIRECT3DDEVICE8 iface, D3DCAPS8* pCaps) {
138 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
139- FIXME("(%p) : stub, calling idirect3d for now\n", This);
140- IDirect3D8Impl_GetDeviceCaps((LPDIRECT3D8) This->direct3d8, This->adapterNo, This->devType, pCaps);
141- return D3D_OK;
142+ HRESULT hrc = D3D_OK;
143+ WINED3DCAPS *pWineCaps = NULL;
144+
145+ if(NULL == pCaps){
146+ return D3DERR_INVALIDCALL;
147+ }
148+
149+ pWineCaps = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(WINED3DCAPS));
150+ if(pWineCaps == NULL){
151+ return D3DERR_INVALIDCALL; /*well this is what MSDN says to return*/
152+ }
153+ pWineCaps->DeviceType = &pCaps->DeviceType;
154+ pWineCaps->AdapterOrdinal = &pCaps->AdapterOrdinal;
155+ pWineCaps->Caps = &pCaps->Caps;
156+ pWineCaps->Caps2 = &pCaps->Caps2;
157+ pWineCaps->Caps3 = &pCaps->Caps3;
158+ pWineCaps->PresentationIntervals = &pCaps->PresentationIntervals;
159+ pWineCaps->CursorCaps = &pCaps->CursorCaps;
160+ pWineCaps->DevCaps = &pCaps->DevCaps;
161+ pWineCaps->PrimitiveMiscCaps = &pCaps->PrimitiveMiscCaps;
162+ pWineCaps->RasterCaps = &pCaps->RasterCaps;
163+ pWineCaps->ZCmpCaps = &pCaps->ZCmpCaps;
164+ pWineCaps->SrcBlendCaps = &pCaps->SrcBlendCaps;
165+ pWineCaps->DestBlendCaps = &pCaps->DestBlendCaps;
166+ pWineCaps->AlphaCmpCaps = &pCaps->AlphaCmpCaps;
167+ pWineCaps->ShadeCaps = &pCaps->ShadeCaps;
168+ pWineCaps->TextureCaps = &pCaps->TextureCaps;
169+ pWineCaps->TextureFilterCaps = &pCaps->TextureFilterCaps;
170+ pWineCaps->CubeTextureFilterCaps = &pCaps->CubeTextureFilterCaps;
171+ pWineCaps->VolumeTextureFilterCaps = &pCaps->VolumeTextureFilterCaps;
172+ pWineCaps->TextureAddressCaps = &pCaps->TextureAddressCaps;
173+ pWineCaps->VolumeTextureAddressCaps = &pCaps->VolumeTextureAddressCaps;
174+ pWineCaps->LineCaps = &pCaps->LineCaps;
175+ pWineCaps->MaxTextureWidth = &pCaps->MaxTextureWidth;
176+ pWineCaps->MaxTextureHeight = &pCaps->MaxTextureHeight;
177+ pWineCaps->MaxVolumeExtent = &pCaps->MaxVolumeExtent;
178+ pWineCaps->MaxTextureRepeat = &pCaps->MaxTextureRepeat;
179+ pWineCaps->MaxTextureAspectRatio = &pCaps->MaxTextureAspectRatio;
180+ pWineCaps->MaxAnisotropy = &pCaps->MaxAnisotropy;
181+ pWineCaps->MaxVertexW = &pCaps->MaxVertexW;
182+ pWineCaps->GuardBandLeft = &pCaps->GuardBandLeft;
183+ pWineCaps->GuardBandTop = &pCaps->GuardBandTop;
184+ pWineCaps->GuardBandRight = &pCaps->GuardBandRight;
185+ pWineCaps->GuardBandBottom = &pCaps->GuardBandBottom;
186+ pWineCaps->ExtentsAdjust = &pCaps->ExtentsAdjust;
187+ pWineCaps->StencilCaps = &pCaps->StencilCaps;
188+ pWineCaps->FVFCaps = &pCaps->FVFCaps;
189+ pWineCaps->TextureOpCaps = &pCaps->TextureOpCaps;
190+ pWineCaps->MaxTextureBlendStages = &pCaps->MaxTextureBlendStages;
191+ pWineCaps->MaxSimultaneousTextures = &pCaps->MaxSimultaneousTextures;
192+ pWineCaps->VertexProcessingCaps = &pCaps->VertexProcessingCaps;
193+ pWineCaps->MaxActiveLights = &pCaps->MaxActiveLights;
194+ pWineCaps->MaxUserClipPlanes = &pCaps->MaxUserClipPlanes;
195+ pWineCaps->MaxVertexBlendMatrices = &pCaps->MaxVertexBlendMatrices;
196+ pWineCaps->MaxVertexBlendMatrixIndex = &pCaps->MaxVertexBlendMatrixIndex;
197+ pWineCaps->MaxPointSize = &pCaps->MaxPointSize;
198+ pWineCaps->MaxPrimitiveCount = &pCaps->MaxPrimitiveCount;
199+ pWineCaps->MaxVertexIndex = &pCaps->MaxVertexIndex;
200+ pWineCaps->MaxStreams = &pCaps->MaxStreams;
201+ pWineCaps->MaxStreamStride = &pCaps->MaxStreamStride;
202+ pWineCaps->VertexShaderVersion = &pCaps->VertexShaderVersion;
203+ pWineCaps->MaxVertexShaderConst = &pCaps->MaxVertexShaderConst;
204+ pWineCaps->PixelShaderVersion = &pCaps->PixelShaderVersion;
205+ /* d3d9 only
206+ pWineCaps->PixelShader1xMaxValue = &pCaps->PixelShader1xMaxValue;
207+ pWineCaps->DevCaps2 = &pCaps->DevCaps2;
208+ pWineCaps->MaxNpatchTessellationLevel = &pCaps->MaxNpatchTessellationLevel;
209+ pWineCaps->MasterAdapterOrdinal = &pCaps->MasterAdapterOrdinal;
210+ pWineCaps->AdapterOrdinalInGroup = &pCaps->AdapterOrdinalInGroup;
211+ pWineCaps->NumberOfAdaptersInGroup = &pCaps->NumberOfAdaptersInGroup;
212+ pWineCaps->DeclTypes = &pCaps->DeclTypes;
213+ pWineCaps->NumSimultaneousRTs = &pCaps->NumSimultaneousRTs;
214+ pWineCaps->StretchRectFilterCaps = &pCaps->StretchRectFilterCaps;
215+ pWineCaps->VS20Caps = &pCaps->VS20Caps;
216+ pWineCaps->PS20Caps = &pCaps->PS20Caps;
217+ pWineCaps->VertexTextureFilterCaps = &pCaps->VertexTextureFilterCaps;
218+ pWineCaps->MaxVShaderInstructionsExecuted = &pCaps->MaxVShaderInstructionsExecuted;
219+ pWineCaps->MaxPShaderInstructionsExecuted = &pCaps->MaxPShaderInstructionsExecuted;
220+ pWineCaps->MaxVertexShader30InstructionSlots = &pCaps->MaxVertexShader30InstructionSlots;
221+ pWineCaps->MaxPixelShader30InstructionSlots = &pCaps->MaxPixelShader30InstructionSlots;
222+ */
223+ hrc = IWineD3DDevice_GetDeviceCaps(This->WineD3DDevice, pWineCaps);
224+ HeapFree(GetProcessHeap(), 0, pWineCaps);
225+ return hrc;
226 }
227 HRESULT WINAPI IDirect3DDevice8Impl_GetDisplayMode(LPDIRECT3DDEVICE8 iface, D3DDISPLAYMODE* pMode) {
228
229@@ -387,6 +474,10 @@
230 HRESULT WINAPI IDirect3DDevice8Impl_GetCreationParameters(LPDIRECT3DDEVICE8 iface, D3DDEVICE_CREATION_PARAMETERS *pParameters) {
231 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
232 TRACE("(%p) copying to %p\n", This, pParameters);
233+ if(pParameters == NULL || (int)pParameters < 1000) {
234+ FIXME("GetCrationParameters called with no buffer or corrupt buffer!\n");
235+ return D3DERR_INVALIDCALL; /*should we allocate?*/
236+ }
237 memcpy(pParameters, &This->CreateParms, sizeof(D3DDEVICE_CREATION_PARAMETERS));
238 return D3D_OK;
239 }
240@@ -854,7 +945,6 @@
241 object->Device = This;
242 object->ref = 1;
243 object->ResourceType = D3DRTYPE_INDEXBUFFER;
244-
245 object->currentDesc.Type = D3DRTYPE_INDEXBUFFER;
246 object->currentDesc.Usage = Usage;
247 object->currentDesc.Pool = Pool;
248@@ -869,47 +959,11 @@
249
250 return D3D_OK;
251 }
252-HRESULT WINAPI IDirect3DDevice8Impl_CreateRenderTarget(LPDIRECT3DDEVICE8 iface, UINT Width, UINT Height, D3DFORMAT Format, D3DMULTISAMPLE_TYPE MultiSample, BOOL Lockable, IDirect3DSurface8** ppSurface) {
253- IDirect3DSurface8Impl *object;
254- IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
255
256- object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3DSurface8Impl));
257- if (NULL == object) {
258- *ppSurface = NULL;
259- return D3DERR_OUTOFVIDEOMEMORY;
260- }
261- *ppSurface = (LPDIRECT3DSURFACE8) object;
262- object->lpVtbl = &Direct3DSurface8_Vtbl;
263- object->Device = This;
264- object->ResourceType = D3DRTYPE_SURFACE;
265- object->Container = (IUnknown*) This;
266
267- object->ref = 1;
268- object->myDesc.Width = Width;
269- object->myDesc.Height = Height;
270- object->myDesc.Format = Format;
271- object->myDesc.Type = D3DRTYPE_SURFACE;
272- object->myDesc.Usage = D3DUSAGE_RENDERTARGET;
273- object->myDesc.Pool = D3DPOOL_DEFAULT;
274- object->myDesc.MultiSampleType = MultiSample;
275- object->bytesPerPixel = D3DFmtGetBpp(This, Format);
276- if (Format == D3DFMT_DXT1) {
277- object->myDesc.Size = (Width * object->bytesPerPixel)/2 * Height; /* DXT1 is half byte per pixel */
278- } else {
279- object->myDesc.Size = (Width * object->bytesPerPixel) * Height;
280- }
281- object->allocatedMemory = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, object->myDesc.Size);
282- object->lockable = Lockable;
283- object->locked = FALSE;
284- memset(&object->lockedRect, 0, sizeof(RECT));
285- IDirect3DSurface8Impl_CleanDirtyRect((LPDIRECT3DSURFACE8) object);
286+HRESULT WINAPI IDirect3DDevice8Impl_CreateSurface(LPDIRECT3DDEVICE8 iface, UINT Width, UINT Height, D3DFORMAT Format, BOOL Lockable, IDirect3DSurface8** ppSurface,D3DRESOURCETYPE Type, UINT Usage,D3DPOOL Pool, D3DMULTISAMPLE_TYPE MultiSample ) {
287
288- TRACE("(%p) : w(%d) h(%d) fmt(%d,%s) lockable(%d) surf@%p, surfmem@%p, %d bytes\n", This, Width, Height, Format, debug_d3dformat(Format), Lockable, *ppSurface, object->allocatedMemory, object->myDesc.Size);
289- return D3D_OK;
290-}
291-HRESULT WINAPI IDirect3DDevice8Impl_CreateDepthStencilSurface(LPDIRECT3DDEVICE8 iface, UINT Width, UINT Height, D3DFORMAT Format, D3DMULTISAMPLE_TYPE MultiSample, IDirect3DSurface8** ppSurface) {
292 IDirect3DSurface8Impl *object;
293-
294 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
295
296 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3DSurface8Impl));
297@@ -917,6 +971,7 @@
298 *ppSurface = NULL;
299 return D3DERR_OUTOFVIDEOMEMORY;
300 }
301+
302 *ppSurface = (LPDIRECT3DSURFACE8) object;
303 object->lpVtbl = &Direct3DSurface8_Vtbl;
304 object->Device = This;
305@@ -927,45 +982,12 @@
306 object->myDesc.Width = Width;
307 object->myDesc.Height = Height;
308 object->myDesc.Format = Format;
309- object->myDesc.Type = D3DRTYPE_SURFACE;
310- object->myDesc.Usage = D3DUSAGE_DEPTHSTENCIL;
311- object->myDesc.Pool = D3DPOOL_DEFAULT;
312+ object->myDesc.Type = Type;
313+ object->myDesc.Usage = Usage;
314+ object->myDesc.Pool = Pool;
315 object->myDesc.MultiSampleType = MultiSample;
316 object->bytesPerPixel = D3DFmtGetBpp(This, Format);
317- if (Format == D3DFMT_DXT1) {
318- object->myDesc.Size = (Width * object->bytesPerPixel)/2 * Height; /* DXT1 is half byte per pixel */
319- } else {
320- object->myDesc.Size = (Width * object->bytesPerPixel) * Height;
321- }
322- object->allocatedMemory = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, object->myDesc.Size);
323- object->lockable = (D3DFMT_D16_LOCKABLE == Format) ? TRUE : FALSE;
324- object->locked = FALSE;
325- memset(&object->lockedRect, 0, sizeof(RECT));
326- IDirect3DSurface8Impl_CleanDirtyRect((LPDIRECT3DSURFACE8) object);
327-
328- TRACE("(%p) : w(%d) h(%d) fmt(%d,%s) surf@%p, surfmem@%p, %d bytes\n", This, Width, Height, Format, debug_d3dformat(Format), *ppSurface, object->allocatedMemory, object->myDesc.Size);
329- return D3D_OK;
330-}
331-HRESULT WINAPI IDirect3DDevice8Impl_CreateImageSurface(LPDIRECT3DDEVICE8 iface, UINT Width, UINT Height, D3DFORMAT Format, IDirect3DSurface8** ppSurface) {
332- IDirect3DSurface8Impl *object;
333-
334- IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
335-
336- object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3DSurface8Impl));
337- *ppSurface = (LPDIRECT3DSURFACE8) object;
338- object->lpVtbl = &Direct3DSurface8_Vtbl;
339- object->Device = This;
340- object->ResourceType = D3DRTYPE_SURFACE;
341- object->Container = (IUnknown*) This;
342
343- object->ref = 1;
344- object->myDesc.Width = Width;
345- object->myDesc.Height = Height;
346- object->myDesc.Format = Format;
347- object->myDesc.Type = D3DRTYPE_SURFACE;
348- object->myDesc.Usage = 0;
349- object->myDesc.Pool = D3DPOOL_SYSTEMMEM;
350- object->bytesPerPixel = D3DFmtGetBpp(This, Format);
351 /* DXTn mipmaps use the same number of 'levels' down to eg. 8x1, but since
352 it is based around 4x4 pixel blocks it requires padding, so allocate enough
353 space! */
354@@ -977,15 +999,43 @@
355 } else {
356 object->myDesc.Size = (Width * object->bytesPerPixel) * Height;
357 }
358+
359 object->allocatedMemory = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, object->myDesc.Size);
360- object->lockable = TRUE;
361+ object->lockable = (D3DFMT_D16_LOCKABLE == Format) ? TRUE : Lockable;
362 object->locked = FALSE;
363 memset(&object->lockedRect, 0, sizeof(RECT));
364 IDirect3DSurface8Impl_CleanDirtyRect((LPDIRECT3DSURFACE8) object);
365
366 TRACE("(%p) : w(%d) h(%d) fmt(%d,%s) surf@%p, surfmem@%p, %d bytes\n", This, Width, Height, Format, debug_d3dformat(Format), *ppSurface, object->allocatedMemory, object->myDesc.Size);
367 return D3D_OK;
368+
369+
370+
371+}
372+
373+
374+HRESULT WINAPI IDirect3DDevice8Impl_CreateRenderTarget(LPDIRECT3DDEVICE8 iface, UINT Width, UINT Height, D3DFORMAT Format, D3DMULTISAMPLE_TYPE MultiSample, BOOL Lockable, IDirect3DSurface8** ppSurface) {
375+
376+ Format |= Lockable?D3DFMT_D16_LOCKABLE:0;
377+ return IDirect3DDevice8Impl_CreateSurface(iface,Width,Height,Format,TRUE /*Lockable*/,ppSurface,D3DRTYPE_SURFACE,D3DUSAGE_DEPTHSTENCIL,D3DPOOL_SYSTEMMEM,MultiSample);
378+
379 }
380+
381+
382+HRESULT WINAPI IDirect3DDevice8Impl_CreateDepthStencilSurface(LPDIRECT3DDEVICE8 iface, UINT Width, UINT Height, D3DFORMAT Format, D3DMULTISAMPLE_TYPE MultiSample, IDirect3DSurface8** ppSurface) {
383+
384+ return IDirect3DDevice8Impl_CreateSurface(iface,Width,Height,Format,FALSE/*Lockable*/,ppSurface,D3DRTYPE_SURFACE,D3DUSAGE_DEPTHSTENCIL,D3DPOOL_DEFAULT,MultiSample);
385+}
386+
387+
388+
389+HRESULT WINAPI IDirect3DDevice8Impl_CreateImageSurface(LPDIRECT3DDEVICE8 iface, UINT Width, UINT Height, D3DFORMAT Format, IDirect3DSurface8** ppSurface) {
390+
391+ return IDirect3DDevice8Impl_CreateSurface(iface,Width,Height,Format,TRUE/*Lockable*/,ppSurface,D3DRTYPE_SURFACE,0,D3DPOOL_SCRATCH,D3DMULTISAMPLE_NONE);
392+
393+}
394+
395+
396 HRESULT WINAPI IDirect3DDevice8Impl_CopyRects(LPDIRECT3DDEVICE8 iface,
397 IDirect3DSurface8* pSourceSurface, CONST RECT* pSourceRectsArray, UINT cRects,
398 IDirect3DSurface8* pDestinationSurface, CONST POINT* pDestPointsArray) {
399@@ -3111,7 +3161,7 @@
400 IDirect3DStateBlockImpl* pSB = (IDirect3DStateBlockImpl*) Token;
401 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
402
403- TRACE("(%p)\n", This);
404+ FIXME("(%p)\n", This);
405
406 return IDirect3DDeviceImpl_CaptureStateBlock(This, pSB);
407 }
408diff -urN wine.20050419/dlls/d3d8/directx.c wine.20050419.dx9/dlls/d3d8/directx.c
409--- wine.20050419/dlls/d3d8/directx.c 2005-03-29 12:01:00.000000000 -0700
410+++ wine.20050419.dx9/dlls/d3d8/directx.c 2005-04-20 01:52:56.000000000 -0600
411@@ -192,7 +192,88 @@
412
413 HRESULT WINAPI IDirect3D8Impl_GetDeviceCaps(LPDIRECT3D8 iface, UINT Adapter, D3DDEVTYPE DeviceType, D3DCAPS8* pCaps) {
414 IDirect3D8Impl *This = (IDirect3D8Impl *)iface;
415- return IWineD3D_GetDeviceCaps(This->WineD3D, Adapter, DeviceType, (void *)pCaps);
416+ HRESULT hrc = D3D_OK;
417+ WINED3DCAPS *pWineCaps = NULL;
418+ if(NULL == pCaps){
419+ return D3DERR_INVALIDCALL;
420+ }
421+ pWineCaps = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(WINED3DCAPS));
422+ if(pWineCaps == NULL){
423+ return D3DERR_INVALIDCALL; /*well this is what MSDN says to return*/
424+ }
425+ pWineCaps->DeviceType = &pCaps->DeviceType;
426+ pWineCaps->AdapterOrdinal = &pCaps->AdapterOrdinal;
427+ pWineCaps->Caps = &pCaps->Caps;
428+ pWineCaps->Caps2 = &pCaps->Caps2;
429+ pWineCaps->Caps3 = &pCaps->Caps3;
430+ pWineCaps->PresentationIntervals = &pCaps->PresentationIntervals;
431+ pWineCaps->CursorCaps = &pCaps->CursorCaps;
432+ pWineCaps->DevCaps = &pCaps->DevCaps;
433+ pWineCaps->PrimitiveMiscCaps = &pCaps->PrimitiveMiscCaps;
434+ pWineCaps->RasterCaps = &pCaps->RasterCaps;
435+ pWineCaps->ZCmpCaps = &pCaps->ZCmpCaps;
436+ pWineCaps->SrcBlendCaps = &pCaps->SrcBlendCaps;
437+ pWineCaps->DestBlendCaps = &pCaps->DestBlendCaps;
438+ pWineCaps->AlphaCmpCaps = &pCaps->AlphaCmpCaps;
439+ pWineCaps->ShadeCaps = &pCaps->ShadeCaps;
440+ pWineCaps->TextureCaps = &pCaps->TextureCaps;
441+ pWineCaps->TextureFilterCaps = &pCaps->TextureFilterCaps;
442+ pWineCaps->CubeTextureFilterCaps = &pCaps->CubeTextureFilterCaps;
443+ pWineCaps->VolumeTextureFilterCaps = &pCaps->VolumeTextureFilterCaps;
444+ pWineCaps->TextureAddressCaps = &pCaps->TextureAddressCaps;
445+ pWineCaps->VolumeTextureAddressCaps = &pCaps->VolumeTextureAddressCaps;
446+ pWineCaps->LineCaps = &pCaps->LineCaps;
447+ pWineCaps->MaxTextureWidth = &pCaps->MaxTextureWidth;
448+ pWineCaps->MaxTextureHeight = &pCaps->MaxTextureHeight;
449+ pWineCaps->MaxVolumeExtent = &pCaps->MaxVolumeExtent;
450+ pWineCaps->MaxTextureRepeat = &pCaps->MaxTextureRepeat;
451+ pWineCaps->MaxTextureAspectRatio = &pCaps->MaxTextureAspectRatio;
452+ pWineCaps->MaxAnisotropy = &pCaps->MaxAnisotropy;
453+ pWineCaps->MaxVertexW = &pCaps->MaxVertexW;
454+ pWineCaps->GuardBandLeft = &pCaps->GuardBandLeft;
455+ pWineCaps->GuardBandTop = &pCaps->GuardBandTop;
456+ pWineCaps->GuardBandRight = &pCaps->GuardBandRight;
457+ pWineCaps->GuardBandBottom = &pCaps->GuardBandBottom;
458+ pWineCaps->ExtentsAdjust = &pCaps->ExtentsAdjust;
459+ pWineCaps->StencilCaps = &pCaps->StencilCaps;
460+ pWineCaps->FVFCaps = &pCaps->FVFCaps;
461+ pWineCaps->TextureOpCaps = &pCaps->TextureOpCaps;
462+ pWineCaps->MaxTextureBlendStages = &pCaps->MaxTextureBlendStages;
463+ pWineCaps->MaxSimultaneousTextures = &pCaps->MaxSimultaneousTextures;
464+ pWineCaps->VertexProcessingCaps = &pCaps->VertexProcessingCaps;
465+ pWineCaps->MaxActiveLights = &pCaps->MaxActiveLights;
466+ pWineCaps->MaxUserClipPlanes = &pCaps->MaxUserClipPlanes;
467+ pWineCaps->MaxVertexBlendMatrices = &pCaps->MaxVertexBlendMatrices;
468+ pWineCaps->MaxVertexBlendMatrixIndex = &pCaps->MaxVertexBlendMatrixIndex;
469+ pWineCaps->MaxPointSize = &pCaps->MaxPointSize;
470+ pWineCaps->MaxPrimitiveCount = &pCaps->MaxPrimitiveCount;
471+ pWineCaps->MaxVertexIndex = &pCaps->MaxVertexIndex;
472+ pWineCaps->MaxStreams = &pCaps->MaxStreams;
473+ pWineCaps->MaxStreamStride = &pCaps->MaxStreamStride;
474+ pWineCaps->VertexShaderVersion = &pCaps->VertexShaderVersion;
475+ pWineCaps->MaxVertexShaderConst = &pCaps->MaxVertexShaderConst;
476+ pWineCaps->PixelShaderVersion = &pCaps->PixelShaderVersion;
477+ /* d3d9 only
478+ pWineCaps->PixelShader1xMaxValue = &pCaps->PixelShader1xMaxValue;
479+ pWineCaps->DevCaps2 = &pCaps->DevCaps2;
480+ pWineCaps->MaxNpatchTessellationLevel = &pCaps->MaxNpatchTessellationLevel;
481+ pWineCaps->MasterAdapterOrdinal = &pCaps->MasterAdapterOrdinal;
482+ pWineCaps->AdapterOrdinalInGroup = &pCaps->AdapterOrdinalInGroup;
483+ pWineCaps->NumberOfAdaptersInGroup = &pCaps->NumberOfAdaptersInGroup;
484+ pWineCaps->DeclTypes = &pCaps->DeclTypes;
485+ pWineCaps->NumSimultaneousRTs = &pCaps->NumSimultaneousRTs;
486+ pWineCaps->StretchRectFilterCaps = &pCaps->StretchRectFilterCaps;
487+ pWineCaps->VS20Caps = &pCaps->VS20Caps;
488+ pWineCaps->PS20Caps = &pCaps->PS20Caps;
489+ pWineCaps->VertexTextureFilterCaps = &pCaps->VertexTextureFilterCaps;
490+ pWineCaps->MaxVShaderInstructionsExecuted = &pCaps->MaxVShaderInstructionsExecuted;
491+ pWineCaps->MaxPShaderInstructionsExecuted = &pCaps->MaxPShaderInstructionsExecuted;
492+ pWineCaps->MaxVertexShader30InstructionSlots = &pCaps->MaxVertexShader30InstructionSlots;
493+ pWineCaps->MaxPixelShader30InstructionSlots = &pCaps->MaxPixelShader30InstructionSlots;
494+ */
495+ hrc = IWineD3D_GetDeviceCaps(This->WineD3D, Adapter, DeviceType, pWineCaps);
496+ HeapFree(GetProcessHeap(), 0, pWineCaps);
497+ return hrc;
498 }
499
500 HMONITOR WINAPI IDirect3D8Impl_GetAdapterMonitor(LPDIRECT3D8 iface, UINT Adapter) {
501@@ -563,6 +644,86 @@
502 return res;
503 }
504
505+
506+/* Internal function called back during the CreateDevice to create a render target */
507+HRESULT WINAPI D3D8CB_CreateDepthStencilSurface(IUnknown *device, UINT Width, UINT Height,
508+ D3DFORMAT Format, D3DMULTISAMPLE_TYPE MultiSample,
509+ DWORD MultisampleQuality, BOOL Discard,
510+ IWineD3DSurface** ppSurface, HANDLE* pSharedHandle) {
511+ HRESULT res = D3D_OK;
512+ IDirect3DSurface8Impl *d3dSurface = NULL;
513+
514+ res = IDirect3DDevice8_CreateDepthStencilSurface((IDirect3DDevice8 *)device, Width, Height,
515+ Format, MultiSample, (IDirect3DSurface8 **)&d3dSurface);
516+ if (res == D3D_OK) {
517+ *ppSurface = d3dSurface->wineD3DSurface;
518+ }else{
519+ FIXME("Error create depth stencil surface\n");
520+ *ppSurface = NULL;
521+ }
522+ return res;
523+}
524+
525+
526+/* Callback for creating the inplicite swapchain when the device is created */
527+
528+HRESULT WINAPI D3D8CB_CreateAdditionalSwapChain(IUnknown *device,
529+ WINED3DPRESENT_PARAMETERS* pPresentationParameters,
530+ IWineD3DSwapChain ** ppSwapChain){
531+ HRESULT res = D3D_OK;
532+ IDirect3DSwapChain8Impl *d3dSwapChain = NULL;
533+ /* We have to pass the presentation parameters back and forth */
534+ D3DPRESENT_PARAMETERS localParameters;
535+ localParameters.BackBufferWidth = *(pPresentationParameters->BackBufferWidth);
536+ localParameters.BackBufferHeight = *(pPresentationParameters->BackBufferHeight);
537+ localParameters.BackBufferFormat = *(pPresentationParameters->BackBufferFormat);
538+ localParameters.BackBufferCount = *(pPresentationParameters->BackBufferCount);
539+ localParameters.MultiSampleType = *(pPresentationParameters->MultiSampleType);
540+/* d3d9 only */
541+/* localParameters.MultiSampleQuality = *(pPresentationParameters->MultiSampleQuality); */
542+ localParameters.SwapEffect = *(pPresentationParameters->SwapEffect);
543+ localParameters.hDeviceWindow = *(pPresentationParameters->hDeviceWindow);
544+ localParameters.Windowed = *(pPresentationParameters->Windowed);
545+ localParameters.EnableAutoDepthStencil = *(pPresentationParameters->EnableAutoDepthStencil);
546+ localParameters.AutoDepthStencilFormat = *(pPresentationParameters->AutoDepthStencilFormat);
547+ localParameters.Flags = *(pPresentationParameters->Flags);
548+ localParameters.FullScreen_RefreshRateInHz = *(pPresentationParameters->FullScreen_RefreshRateInHz);
549+/* not in d3d8 */
550+/* localParameters.PresentationInterval = *(pPresentationParameters->PresentationInterval); */
551+
552+ TRACE("(%p) rellaying\n", device);
553+ /*copy the presentation parameters*/
554+ res = IDirect3DDevice8_CreateAdditionalSwapChain((IDirect3DDevice8 *)device, &localParameters, (IDirect3DSwapChain8 **)&d3dSwapChain);
555+
556+ if (res == D3D_OK){
557+ *ppSwapChain = d3dSwapChain->wineD3DSwapChain;
558+ } else {
559+ FIXME("failed to create additional swap chain\n");
560+ *ppSwapChain = NULL;
561+ }
562+ /* Copy back the presentation parameters */
563+ TRACE("(%p) setting up return parameters\n", device);
564+ *pPresentationParameters->BackBufferWidth = localParameters.BackBufferWidth;
565+ *pPresentationParameters->BackBufferHeight = localParameters.BackBufferHeight;
566+ *pPresentationParameters->BackBufferFormat = localParameters.BackBufferFormat;
567+ *pPresentationParameters->BackBufferCount = localParameters.BackBufferCount;
568+ *pPresentationParameters->MultiSampleType = localParameters.MultiSampleType;
569+/* *pPresentationParameters->MultiSampleQuality leave alone incase wineD3D set something internally */
570+ *pPresentationParameters->SwapEffect = localParameters.SwapEffect;
571+ *pPresentationParameters->hDeviceWindow = localParameters.hDeviceWindow;
572+ *pPresentationParameters->Windowed = localParameters.Windowed;
573+ *pPresentationParameters->EnableAutoDepthStencil = localParameters.EnableAutoDepthStencil;
574+ *pPresentationParameters->AutoDepthStencilFormat = localParameters.AutoDepthStencilFormat;
575+ *pPresentationParameters->Flags = localParameters.Flags;
576+ *pPresentationParameters->FullScreen_RefreshRateInHz = localParameters.FullScreen_RefreshRateInHz;
577+/* *pPresentationParameters->PresentationInterval leave alone incase wineD3D set something internally */
578+
579+ return res;
580+
581+}
582+
583+
584+
585 HRESULT WINAPI IDirect3D8Impl_CreateDevice (LPDIRECT3D8 iface,
586 UINT Adapter, D3DDEVTYPE DeviceType, HWND hFocusWindow,
587 DWORD BehaviourFlags, D3DPRESENT_PARAMETERS* pPresentationParameters,
588@@ -608,7 +769,8 @@
589 localParameters.Flags = &pPresentationParameters->Flags;
590 localParameters.FullScreen_RefreshRateInHz = &pPresentationParameters->FullScreen_RefreshRateInHz;
591 localParameters.PresentationInterval = &pPresentationParameters->FullScreen_PresentationInterval; /* Renamed in dx9 */
592- IWineD3D_CreateDevice(This->WineD3D, Adapter, DeviceType, hFocusWindow, BehaviourFlags, &localParameters, &object->WineD3DDevice, (IUnknown *)object, D3D8CB_CreateRenderTarget);
593+ /*TODO: remove createRenderTarget and CreateDepthSurfae call backs*/
594+ IWineD3D_CreateDevice(This->WineD3D, Adapter, DeviceType, hFocusWindow, BehaviourFlags, &localParameters, &object->WineD3DDevice, (IUnknown *)object, D3D8CB_CreateRenderTarget, D3D8CB_CreateDepthStencilSurface, D3D8CB_CreateAdditionalSwapChain);
595
596 /** use StateBlock Factory here, for creating the startup stateBlock */
597 object->StateBlock = NULL;
598diff -urN wine.20050419/dlls/d3d8/stateblock.c wine.20050419.dx9/dlls/d3d8/stateblock.c
599--- wine.20050419/dlls/d3d8/stateblock.c 2004-12-23 11:33:45.000000000 -0700
600+++ wine.20050419.dx9/dlls/d3d8/stateblock.c 2005-04-20 01:52:56.000000000 -0600
601@@ -286,7 +286,9 @@
602 TRACE("(%p) : Type(%d)\n", This, Type);
603
604 /* Allocate Storage */
605+
606 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3DStateBlockImpl));
607+ FIXME("Allocated %p stateblock\n",object);
608 if (object) {
609 if (NULL == This->StateBlock) { /** if it the main stateblock only do init and returns */
610 /*object->lpVtbl = &Direct3DStateBlock9_Vtbl;*/
611@@ -354,6 +356,7 @@
612
613 while (src) {
614 newEl = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(PLIGHTINFOEL));
615+ FIXME("Allocated %p sblights\n",newEl);
616 if (newEl == NULL) return D3DERR_OUTOFVIDEOMEMORY;
617 memcpy(newEl, src, sizeof(PLIGHTINFOEL));
618 newEl->prev = dst;
619@@ -386,10 +389,13 @@
620 tmp = pSB->lights;
621 if (tmp) tmp = tmp->next;
622 while (tmp != NULL) {
623+ FIXME("(%p) Freeing sblight %p\n",This,tmp->prev);
624 HeapFree(GetProcessHeap(), 0, (void *)(tmp->prev));
625 tmp = tmp->next;
626 }
627+ FIXME("(%p) Freeing sblight %p\n",This,tmp);
628 HeapFree(GetProcessHeap(), 0, (void *)tmp);
629+ FIXME("(%p) Freeing stateblock %p\n",This,pSB);
630 HeapFree(GetProcessHeap(), 0, (void *)pSB);
631 return D3D_OK;
632 }
633@@ -407,6 +413,7 @@
634 /* Allocate Storage */
635 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3DStateBlockImpl));
636 if (object) {
637+ FIXME("Allocated %p IDirect3DStateBlockImpl\n",object);
638 } else {
639 return E_OUTOFMEMORY;
640 }
641diff -urN wine.20050419/dlls/d3d9/cubetexture.c wine.20050419.dx9/dlls/d3d9/cubetexture.c
642--- wine.20050419/dlls/d3d9/cubetexture.c 2005-03-29 12:01:00.000000000 -0700
643+++ wine.20050419.dx9/dlls/d3d9/cubetexture.c 2005-04-20 01:52:56.000000000 -0600
644@@ -236,6 +236,8 @@
645
646
647
648+
649+
650 /* IDirect3DDevice9 IDirect3DCubeTexture9 Methods follow: */
651 HRESULT WINAPI IDirect3DDevice9Impl_CreateCubeTexture(LPDIRECT3DDEVICE9 iface,
652 UINT EdgeLength, UINT Levels, DWORD Usage,
653diff -urN wine.20050419/dlls/d3d9/d3d9_main.c wine.20050419.dx9/dlls/d3d9/d3d9_main.c
654--- wine.20050419/dlls/d3d9/d3d9_main.c 2005-03-02 06:44:59.000000000 -0700
655+++ wine.20050419.dx9/dlls/d3d9/d3d9_main.c 2005-04-20 01:52:56.000000000 -0600
656@@ -44,6 +44,7 @@
657
658 object->lpVtbl = &Direct3D9_Vtbl;
659 object->ref = 1;
660+ FIXME("calling WineDirect3DCreate with %d %d %p\n", SDKVersion, 9, (IUnknown *)object);
661 object->WineD3D = WineDirect3DCreate(SDKVersion, 9, (IUnknown *)object);
662
663 TRACE("SDKVersion = %x, Created Direct3D object @ %p, WineObj @ %p\n", SDKVersion, object, object->WineD3D);
664diff -urN wine.20050419/dlls/d3d9/d3d9_private.h wine.20050419.dx9/dlls/d3d9/d3d9_private.h
665--- wine.20050419/dlls/d3d9/d3d9_private.h 2005-03-29 12:01:00.000000000 -0700
666+++ wine.20050419.dx9/dlls/d3d9/d3d9_private.h 2005-04-20 01:52:56.000000000 -0600
667@@ -27,7 +27,6 @@
668 # error You must include config.h to use this header
669 #endif
670
671-/* THIS FILE MUST NOT CONTAIN X11 or MESA DEFINES */
672 #include <stdarg.h>
673
674 #define NONAMELESSUNION
675@@ -35,19 +34,10 @@
676 #define COBJMACROS
677 #include "windef.h"
678 #include "winbase.h"
679-#include "wingdi.h"
680 #include "winuser.h"
681 #include "wine/debug.h"
682 #include "wine/unicode.h"
683
684-#define XMD_H
685-#include <GL/gl.h>
686-#include <GL/glx.h>
687-#ifdef HAVE_GL_GLEXT_H
688-# include <GL/glext.h>
689-#endif
690-#undef XMD_H
691-
692 #undef APIENTRY
693 #undef CALLBACK
694 #undef WINAPI
695@@ -61,116 +51,14 @@
696 #include "d3d9_private.h"
697 #include "wine/wined3d_interface.h"
698
699-/* X11 locking */
700-
701-extern void (*wine_tsx11_lock_ptr)(void);
702-extern void (*wine_tsx11_unlock_ptr)(void);
703-
704-/* As GLX relies on X, this is needed */
705-#define ENTER_GL() wine_tsx11_lock_ptr()
706-#define LEAVE_GL() wine_tsx11_unlock_ptr()
707
708 #include <stdarg.h>
709
710+
711 #include "windef.h"
712 #include "winbase.h"
713-#include "d3d9.h"
714+#include "d3d9.h" /*why is this included twice?*/
715
716-/* Device caps */
717-#define MAX_PALETTES 256
718-#define MAX_STREAMS 16
719-#define MAX_ACTIVE_LIGHTS 8
720-#define MAX_CLIPPLANES D3DMAXUSERCLIPPLANES
721-#define MAX_LEVELS 256
722-
723-/* Other useful values */
724-#define HIGHEST_RENDER_STATE D3DRS_BLENDOPALPHA
725-#define HIGHEST_TEXTURE_STATE 29
726-#define HIGHEST_TRANSFORMSTATE 512
727-#define D3DSBT_RECORDED 0xfffffffe
728-
729-#define D3D_VSHADER_MAX_CONSTANTS 96
730-#define D3D_PSHADER_MAX_CONSTANTS 32
731-
732-/* Direct3D9 Interfaces: */
733-typedef struct IDirect3D9Impl IDirect3D9Impl;
734-typedef struct IDirect3DDevice9Impl IDirect3DDevice9Impl;
735-typedef struct IDirect3DBaseTexture9Impl IDirect3DBaseTexture9Impl;
736-typedef struct IDirect3DTexture9Impl IDirect3DTexture9Impl;
737-typedef struct IDirect3DVolumeTexture9Impl IDirect3DVolumeTexture9Impl;
738-typedef struct IDirect3DCubeTexture9Impl IDirect3DCubeTexture9Impl;
739-typedef struct IDirect3DVertexBuffer9Impl IDirect3DVertexBuffer9Impl;
740-typedef struct IDirect3DIndexBuffer9Impl IDirect3DIndexBuffer9Impl;
741-typedef struct IDirect3DSurface9Impl IDirect3DSurface9Impl;
742-typedef struct IDirect3DSwapChain9Impl IDirect3DSwapChain9Impl;
743-typedef struct IDirect3DResource9Impl IDirect3DResource9Impl;
744-typedef struct IDirect3DVolume9Impl IDirect3DVolume9Impl;
745-typedef struct IDirect3DStateBlock9Impl IDirect3DStateBlock9Impl;
746-typedef struct IDirect3DVertexShader9Impl IDirect3DVertexShader9Impl;
747-typedef struct IDirect3DPixelShader9Impl IDirect3DPixelShader9Impl;
748-typedef struct IDirect3DVertexDeclaration9Impl IDirect3DVertexDeclaration9Impl;
749-
750-
751-#define D3DCOLOR_R(dw) (((float) (((dw) >> 16) & 0xFF)) / 255.0f)
752-#define D3DCOLOR_G(dw) (((float) (((dw) >> 8) & 0xFF)) / 255.0f)
753-#define D3DCOLOR_B(dw) (((float) (((dw) >> 0) & 0xFF)) / 255.0f)
754-#define D3DCOLOR_A(dw) (((float) (((dw) >> 24) & 0xFF)) / 255.0f)
755-
756-#define D3DCOLORTOCOLORVALUE(dw, col) \
757- (col).r = D3DCOLOR_R(dw); \
758- (col).g = D3DCOLOR_G(dw); \
759- (col).b = D3DCOLOR_B(dw); \
760- (col).a = D3DCOLOR_A(dw);
761-
762-#define D3DCOLORTOVECTOR4(dw, vec) \
763- (vec).x = D3DCOLOR_R(dw); \
764- (vec).y = D3DCOLOR_G(dw); \
765- (vec).z = D3DCOLOR_B(dw); \
766- (vec).w = D3DCOLOR_A(dw);
767-
768-#define D3DCOLORTOGLFLOAT4(dw, vec) \
769- (vec)[0] = D3DCOLOR_R(dw); \
770- (vec)[1] = D3DCOLOR_G(dw); \
771- (vec)[2] = D3DCOLOR_B(dw); \
772- (vec)[3] = D3DCOLOR_A(dw);
773-
774-/**
775- * State Block for Begin/End/Capture/Create/Apply State Block
776- * Note: Very long winded but I do not believe gl Lists will
777- * resolve everything we need, so doing it manually for now
778- */
779-typedef struct SAVEDSTATES {
780- BOOL lightEnable[MAX_ACTIVE_LIGHTS];
781- BOOL Indices;
782- BOOL lights[MAX_ACTIVE_LIGHTS];
783- BOOL material;
784- BOOL stream_source[MAX_STREAMS];
785- BOOL textures[8];
786- BOOL transform[HIGHEST_TRANSFORMSTATE];
787- BOOL viewport;
788- BOOL vertexShader;
789- BOOL vertexShaderConstant;
790- BOOL vertexShaderDecl;
791- BOOL pixelShader;
792- BOOL pixelShaderConstant;
793- BOOL renderstate[HIGHEST_RENDER_STATE];
794- BOOL texture_state[8][HIGHEST_TEXTURE_STATE];
795- BOOL clipplane[MAX_CLIPPLANES];
796-} SAVEDSTATES;
797-
798-typedef struct D3DSHADERVECTORF {
799- float x;
800- float y;
801- float z;
802- float w;
803-} D3DSHADERVECTORF;
804-
805-typedef struct D3DSHADERVECTORI {
806- int x;
807- int y;
808- int z;
809- int w;
810-} D3DSHADERVECTORI;
811
812 /* ===========================================================================
813 The interfactes themselves
814@@ -188,7 +76,7 @@
815 /*****************************************************************************
816 * IDirect3D implementation structure
817 */
818-struct IDirect3D9Impl
819+typedef struct IDirect3D9Impl
820 {
821 /* IUnknown fields */
822 IDirect3D9Vtbl *lpVtbl;
823@@ -197,33 +85,11 @@
824 /* The WineD3D device */
825 IWineD3D *WineD3D;
826
827- /* IDirect3D9 fields */
828-};
829+} IDirect3D9Impl;
830
831-/* IUnknown: */
832-extern HRESULT WINAPI IDirect3D9Impl_QueryInterface(LPDIRECT3D9 iface,REFIID refiid,LPVOID *obj);
833-extern ULONG WINAPI IDirect3D9Impl_AddRef(LPDIRECT3D9 iface);
834-extern ULONG WINAPI IDirect3D9Impl_Release(LPDIRECT3D9 iface);
835-
836-/* IDirect3d9: */
837-extern HRESULT WINAPI IDirect3D9Impl_RegisterSoftwareDevice(LPDIRECT3D9 iface, void* pInitializeFunction);
838-extern UINT WINAPI IDirect3D9Impl_GetAdapterCount(LPDIRECT3D9 iface);
839-extern HRESULT WINAPI IDirect3D9Impl_GetAdapterIdentifier(LPDIRECT3D9 iface, UINT Adapter, DWORD Flags, D3DADAPTER_IDENTIFIER9* pIdentifier);
840-extern UINT WINAPI IDirect3D9Impl_GetAdapterModeCount(LPDIRECT3D9 iface, UINT Adapter, D3DFORMAT Format);
841-extern HRESULT WINAPI IDirect3D9Impl_EnumAdapterModes(LPDIRECT3D9 iface, UINT Adapter, D3DFORMAT Format, UINT Mode, D3DDISPLAYMODE* pMode);
842-extern HRESULT WINAPI IDirect3D9Impl_GetAdapterDisplayMode(LPDIRECT3D9 iface, UINT Adapter, D3DDISPLAYMODE* pMode);
843-extern HRESULT WINAPI IDirect3D9Impl_CheckDeviceType(LPDIRECT3D9 iface, UINT Adapter, D3DDEVTYPE CheckType, D3DFORMAT DisplayFormat, D3DFORMAT BackBufferFormat, BOOL Windowed);
844-extern HRESULT WINAPI IDirect3D9Impl_CheckDeviceFormat(LPDIRECT3D9 iface, UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT AdapterFormat, DWORD Usage, D3DRESOURCETYPE RType, D3DFORMAT CheckFormat);
845-extern HRESULT WINAPI IDirect3D9Impl_CheckDeviceMultiSampleType(LPDIRECT3D9 iface, UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT SurfaceFormat, BOOL Windowed, D3DMULTISAMPLE_TYPE MultiSampleType, DWORD* pQualityLevels);
846-extern HRESULT WINAPI IDirect3D9Impl_CheckDepthStencilMatch(LPDIRECT3D9 iface, UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT AdapterFormat, D3DFORMAT RenderTargetFormat, D3DFORMAT DepthStencilFormat);
847-extern HRESULT WINAPI IDirect3D9Impl_CheckDeviceFormatConversion(LPDIRECT3D9 iface, UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT SourceFormat, D3DFORMAT TargetFormat);
848-extern HRESULT WINAPI IDirect3D9Impl_GetDeviceCaps(LPDIRECT3D9 iface, UINT Adapter, D3DDEVTYPE DeviceType, D3DCAPS9* pCaps);
849-extern HMONITOR WINAPI IDirect3D9Impl_GetAdapterMonitor(LPDIRECT3D9 iface, UINT Adapter);
850-extern HRESULT WINAPI IDirect3D9Impl_CreateDevice(LPDIRECT3D9 iface, UINT Adapter, D3DDEVTYPE DeviceType, HWND hFocusWindow, DWORD BehaviorFlags, D3DPRESENT_PARAMETERS* pPresentationParameters, IDirect3DDevice9** ppReturnedDeviceInterface);
851-
852-/* ---------------- */
853-/* IDirect3DDevice9 */
854-/* ---------------- */
855+/* ---------- */
856+/* IDirect3D9 */
857+/* ---------- */
858
859 /*****************************************************************************
860 * Predeclare the interface implementation structures
861@@ -231,168 +97,33 @@
862 extern IDirect3DDevice9Vtbl Direct3DDevice9_Vtbl;
863
864 /*****************************************************************************
865- * IDirect3DDevice9 implementation structure
866+ * IDirect3D implementation structure
867 */
868-struct IDirect3DDevice9Impl
869+typedef struct IDirect3DDevice9Impl
870 {
871 /* IUnknown fields */
872 IDirect3DDevice9Vtbl *lpVtbl;
873 DWORD ref;
874
875- /* IDirect3DDevice9 fields */
876- IDirect3D9Impl *direct3d;
877+ /* The IDirect3DDevice9 fields */
878 IWineD3DDevice *WineD3DDevice;
879
880- /* FIXME: To be sorted out during move */
881- IDirect3DSurface9Impl *frontBuffer;
882- IDirect3DSurface9Impl *backBuffer;
883- IDirect3DSurface9Impl *depthStencilBuffer;
884-
885- IDirect3DSurface9Impl *renderTarget;
886- IDirect3DSurface9Impl *stencilBufferTarget;
887-
888- D3DPRESENT_PARAMETERS PresentParms;
889- D3DDEVICE_CREATION_PARAMETERS CreateParms;
890-
891- UINT adapterNo;
892- D3DDEVTYPE devType;
893-
894- UINT srcBlend;
895- UINT dstBlend;
896- UINT alphafunc;
897- UINT stencilfunc;
898-
899- /* State block related */
900- BOOL isRecordingState;
901- IDirect3DStateBlock9Impl *StateBlock;
902- IDirect3DStateBlock9Impl *UpdateStateBlock;
903-
904- /* Other required values */
905- float lightPosn[MAX_ACTIVE_LIGHTS][4];
906- float lightDirn[MAX_ACTIVE_LIGHTS][4];
907-
908- /* palettes texture management */
909- PALETTEENTRY palettes[MAX_PALETTES][256];
910- UINT currentPalette;
911-
912- /* Optimization */
913- D3DMATRIX lastProj;
914- D3DMATRIX lastView;
915- D3DMATRIX lastWorld0;
916- D3DMATRIX lastTexTrans[8];
917-
918- /* OpenGL related */
919- /*
920- GLXContext glCtx;
921- XVisualInfo *visInfo;
922- Display *display;
923- GLXContext render_ctx;
924- Drawable drawable;
925- Window win;
926- */
927- HWND win_handle;
928-
929- /* OpenGL Extension related */
930-
931- /* Cursor management */
932- BOOL bCursorVisible;
933- UINT xHotSpot;
934- UINT yHotSpot;
935- UINT xScreenSpace;
936- UINT yScreenSpace;
937+} IDirect3DDevice9Impl;
938
939- UINT dummyTextureName[8];
940-};
941-
942-/* IUnknown: */
943-extern HRESULT WINAPI IDirect3DDevice9Impl_QueryInterface(LPDIRECT3DDEVICE9 iface, REFIID refiid, LPVOID *obj);
944-extern ULONG WINAPI IDirect3DDevice9Impl_AddRef(LPDIRECT3DDEVICE9 iface);
945-extern ULONG WINAPI IDirect3DDevice9Impl_Release(LPDIRECT3DDEVICE9 iface);
946
947 /* IDirect3DDevice9: */
948-extern HRESULT WINAPI IDirect3DDevice9Impl_TestCooperativeLevel(LPDIRECT3DDEVICE9 iface);
949-extern UINT WINAPI IDirect3DDevice9Impl_GetAvailableTextureMem(LPDIRECT3DDEVICE9 iface);
950-extern HRESULT WINAPI IDirect3DDevice9Impl_EvictManagedRessources(LPDIRECT3DDEVICE9 iface);
951 extern HRESULT WINAPI IDirect3DDevice9Impl_GetDirect3D(LPDIRECT3DDEVICE9 iface, IDirect3D9** ppD3D9);
952-extern HRESULT WINAPI IDirect3DDevice9Impl_GetDeviceCaps(LPDIRECT3DDEVICE9 iface, D3DCAPS9* pCaps);
953-extern HRESULT WINAPI IDirect3DDevice9Impl_GetDisplayMode(LPDIRECT3DDEVICE9 iface, UINT iSwapChain, D3DDISPLAYMODE* pMode);
954-extern HRESULT WINAPI IDirect3DDevice9Impl_GetCreationParameters(LPDIRECT3DDEVICE9 iface, D3DDEVICE_CREATION_PARAMETERS* pParameters);
955-extern HRESULT WINAPI IDirect3DDevice9Impl_SetCursorProperties(LPDIRECT3DDEVICE9 iface, UINT XHotSpot, UINT YHotSpot, IDirect3DSurface9* pCursorBitmap);
956-extern void WINAPI IDirect3DDevice9Impl_SetCursorPosition(LPDIRECT3DDEVICE9 iface, int XScreenSpace, int YScreenSpace, DWORD Flags);
957-extern BOOL WINAPI IDirect3DDevice9Impl_ShowCursor(LPDIRECT3DDEVICE9 iface, BOOL bShow);
958 extern HRESULT WINAPI IDirect3DDevice9Impl_CreateAdditionalSwapChain(LPDIRECT3DDEVICE9 iface, D3DPRESENT_PARAMETERS* pPresentationParameters, IDirect3DSwapChain9** pSwapChain);
959 extern HRESULT WINAPI IDirect3DDevice9Impl_GetSwapChain(LPDIRECT3DDEVICE9 iface, UINT iSwapChain, IDirect3DSwapChain9** pSwapChain);
960 extern UINT WINAPI IDirect3DDevice9Impl_GetNumberOfSwapChains(LPDIRECT3DDEVICE9 iface);
961-extern HRESULT WINAPI IDirect3DDevice9Impl_Reset(LPDIRECT3DDEVICE9 iface, D3DPRESENT_PARAMETERS* pPresentationParameters);
962-extern HRESULT WINAPI IDirect3DDevice9Impl_Present(LPDIRECT3DDEVICE9 iface, CONST RECT* pSourceRect, CONST RECT* pDestRect, HWND hDestWindowOverride, CONST RGNDATA* pDirtyRegion);
963-extern HRESULT WINAPI IDirect3DDevice9Impl_GetBackBuffer(LPDIRECT3DDEVICE9 iface, UINT iSwapChain, UINT BackBuffer, D3DBACKBUFFER_TYPE Type, IDirect3DSurface9** ppBackBuffer);
964-extern HRESULT WINAPI IDirect3DDevice9Impl_GetRasterStatus(LPDIRECT3DDEVICE9 iface, UINT iSwapChain, D3DRASTER_STATUS* pRasterStatus);
965-extern HRESULT WINAPI IDirect3DDevice9Impl_SetDialogBoxMode(LPDIRECT3DDEVICE9 iface, BOOL bEnableDialogs);
966-extern void WINAPI IDirect3DDevice9Impl_SetGammaRamp(LPDIRECT3DDEVICE9 iface, UINT iSwapChain, DWORD Flags, CONST D3DGAMMARAMP* pRamp);
967-extern void WINAPI IDirect3DDevice9Impl_GetGammaRamp(LPDIRECT3DDEVICE9 iface, UINT iSwapChain, D3DGAMMARAMP* pRamp);
968 extern HRESULT WINAPI IDirect3DDevice9Impl_CreateTexture(LPDIRECT3DDEVICE9 iface, UINT Width, UINT Height, UINT Levels, DWORD Usage, D3DFORMAT Format, D3DPOOL Pool, IDirect3DTexture9** ppTexture, HANDLE* pSharedHandle);
969 extern HRESULT WINAPI IDirect3DDevice9Impl_CreateVolumeTexture(LPDIRECT3DDEVICE9 iface, UINT Width, UINT Height, UINT Depth, UINT Levels, DWORD Usage, D3DFORMAT Format, D3DPOOL Pool, IDirect3DVolumeTexture9** ppVolumeTexture, HANDLE* pSharedHandle);
970 extern HRESULT WINAPI IDirect3DDevice9Impl_CreateCubeTexture(LPDIRECT3DDEVICE9 iface, UINT EdgeLength, UINT Levels, DWORD Usage, D3DFORMAT Format, D3DPOOL Pool, IDirect3DCubeTexture9** ppCubeTexture, HANDLE* pSharedHandle);
971 extern HRESULT WINAPI IDirect3DDevice9Impl_CreateVertexBuffer(LPDIRECT3DDEVICE9 iface, UINT Length, DWORD Usage, DWORD FVF, D3DPOOL Pool, IDirect3DVertexBuffer9** ppVertexBuffer, HANDLE* pSharedHandle);
972 extern HRESULT WINAPI IDirect3DDevice9Impl_CreateIndexBuffer(LPDIRECT3DDEVICE9 iface, UINT Length, DWORD Usage, D3DFORMAT Format, D3DPOOL Pool, IDirect3DIndexBuffer9** ppIndexBuffer, HANDLE* pSharedHandle);
973-extern HRESULT WINAPI IDirect3DDevice9Impl_CreateRenderTarget(LPDIRECT3DDEVICE9 iface, UINT Width, UINT Height, D3DFORMAT Format, D3DMULTISAMPLE_TYPE MultiSample, DWORD MultisampleQuality, BOOL Lockable, IDirect3DSurface9** ppSurface, HANDLE* pSharedHandle);
974-extern HRESULT WINAPI IDirect3DDevice9Impl_CreateDepthStencilSurface(LPDIRECT3DDEVICE9 iface, UINT Width, UINT Height, D3DFORMAT Format, D3DMULTISAMPLE_TYPE MultiSample, DWORD MultisampleQuality, BOOL Discard, IDirect3DSurface9** ppSurface, HANDLE* pSharedHandle);
975-extern HRESULT WINAPI IDirect3DDevice9Impl_UpdateSurface(LPDIRECT3DDEVICE9 iface, IDirect3DSurface9* pSourceSurface, CONST RECT* pSourceRect, IDirect3DSurface9* pDestinationSurface, CONST POINT* pDestPoint);
976-extern HRESULT WINAPI IDirect3DDevice9Impl_UpdateTexture(LPDIRECT3DDEVICE9 iface, IDirect3DBaseTexture9* pSourceTexture, IDirect3DBaseTexture9* pDestinationTexture);
977-extern HRESULT WINAPI IDirect3DDevice9Impl_GetRenderTargetData(LPDIRECT3DDEVICE9 iface, IDirect3DSurface9* pRenderTarget, IDirect3DSurface9* pDestSurface);
978-extern HRESULT WINAPI IDirect3DDevice9Impl_GetFrontBufferData(LPDIRECT3DDEVICE9 iface, UINT iSwapChain, IDirect3DSurface9* pDestSurface);
979-extern HRESULT WINAPI IDirect3DDevice9Impl_StretchRects(LPDIRECT3DDEVICE9 iface, IDirect3DSurface9* pSourceSurface, CONST RECT* pSourceRect, IDirect3DSurface9* pDestSurface, CONST RECT* pDestRect, D3DTEXTUREFILTERTYPE Filter);
980-extern HRESULT WINAPI IDirect3DDevice9Impl_ColorFill(LPDIRECT3DDEVICE9 iface, IDirect3DSurface9* pSurface, CONST RECT* pRect, D3DCOLOR color);
981-extern HRESULT WINAPI IDirect3DDevice9Impl_CreateOffscreenPlainSurface(LPDIRECT3DDEVICE9 iface, UINT Width, UINT Height, D3DFORMAT Format, D3DPOOL Pool, IDirect3DSurface9** ppSurface, HANDLE* pSharedHandle);
982-extern HRESULT WINAPI IDirect3DDevice9Impl_SetRenderTarget(LPDIRECT3DDEVICE9 iface, DWORD RenderTargetIndex, IDirect3DSurface9* pRenderTarget);
983-extern HRESULT WINAPI IDirect3DDevice9Impl_GetRenderTarget(LPDIRECT3DDEVICE9 iface, DWORD RenderTargetIndex, IDirect3DSurface9** ppRenderTarget);
984-extern HRESULT WINAPI IDirect3DDevice9Impl_SetDepthStencilSurface(LPDIRECT3DDEVICE9 iface, IDirect3DSurface9* pNewZStencilSurface);
985-extern HRESULT WINAPI IDirect3DDevice9Impl_GetDepthStencilSurface(LPDIRECT3DDEVICE9 iface, IDirect3DSurface9** ppZStencilSurface);
986-extern HRESULT WINAPI IDirect3DDevice9Impl_BeginScene(LPDIRECT3DDEVICE9 iface);
987-extern HRESULT WINAPI IDirect3DDevice9Impl_EndScene(LPDIRECT3DDEVICE9 iface);
988-extern HRESULT WINAPI IDirect3DDevice9Impl_Clear(LPDIRECT3DDEVICE9 iface, DWORD Count, CONST D3DRECT* pRects, DWORD Flags, D3DCOLOR Color, float Z, DWORD Stencil);
989-extern HRESULT WINAPI IDirect3DDevice9Impl_SetTransform(LPDIRECT3DDEVICE9 iface, D3DTRANSFORMSTATETYPE State, CONST D3DMATRIX* pMatrix);
990-extern HRESULT WINAPI IDirect3DDevice9Impl_GetTransform(LPDIRECT3DDEVICE9 iface, D3DTRANSFORMSTATETYPE State, D3DMATRIX* pMatrix);
991-extern HRESULT WINAPI IDirect3DDevice9Impl_MultiplyTransform(LPDIRECT3DDEVICE9 iface, D3DTRANSFORMSTATETYPE State, CONST D3DMATRIX* pMatrix);
992-extern HRESULT WINAPI IDirect3DDevice9Impl_SetViewport(LPDIRECT3DDEVICE9 iface, CONST D3DVIEWPORT9* pViewport);
993-extern HRESULT WINAPI IDirect3DDevice9Impl_GetViewport(LPDIRECT3DDEVICE9 iface, D3DVIEWPORT9* pViewport);
994-extern HRESULT WINAPI IDirect3DDevice9Impl_SetMaterial(LPDIRECT3DDEVICE9 iface, CONST D3DMATERIAL9* pMaterial);
995-extern HRESULT WINAPI IDirect3DDevice9Impl_GetMaterial(LPDIRECT3DDEVICE9 iface, D3DMATERIAL9* pMaterial);
996-extern HRESULT WINAPI IDirect3DDevice9Impl_SetLight(LPDIRECT3DDEVICE9 iface, DWORD Index, CONST D3DLIGHT9* pLight);
997-extern HRESULT WINAPI IDirect3DDevice9Impl_GetLight(LPDIRECT3DDEVICE9 iface, DWORD Index, D3DLIGHT9* pLight);
998-extern HRESULT WINAPI IDirect3DDevice9Impl_LightEnable(LPDIRECT3DDEVICE9 iface, DWORD Index, BOOL Enable);
999-extern HRESULT WINAPI IDirect3DDevice9Impl_GetLightEnable(LPDIRECT3DDEVICE9 iface, DWORD Index, BOOL* pEnable);
1000-extern HRESULT WINAPI IDirect3DDevice9Impl_SetClipPlane(LPDIRECT3DDEVICE9 iface, DWORD Index, CONST float* pPlane);
1001-extern HRESULT WINAPI IDirect3DDevice9Impl_GetClipPlane(LPDIRECT3DDEVICE9 iface, DWORD Index, float* pPlane);
1002-extern HRESULT WINAPI IDirect3DDevice9Impl_SetRenderState(LPDIRECT3DDEVICE9 iface, D3DRENDERSTATETYPE State, DWORD Value);
1003-extern HRESULT WINAPI IDirect3DDevice9Impl_GetRenderState(LPDIRECT3DDEVICE9 iface, D3DRENDERSTATETYPE State, DWORD* pValue);
1004 extern HRESULT WINAPI IDirect3DDevice9Impl_CreateStateBlock(LPDIRECT3DDEVICE9 iface, D3DSTATEBLOCKTYPE Type, IDirect3DStateBlock9** ppSB);
1005 extern HRESULT WINAPI IDirect3DDevice9Impl_BeginStateBlock(LPDIRECT3DDEVICE9 iface);
1006 extern HRESULT WINAPI IDirect3DDevice9Impl_EndStateBlock(LPDIRECT3DDEVICE9 iface, IDirect3DStateBlock9** ppSB);
1007-extern HRESULT WINAPI IDirect3DDevice9Impl_SetClipStatus(LPDIRECT3DDEVICE9 iface, CONST D3DCLIPSTATUS9* pClipStatus);
1008-extern HRESULT WINAPI IDirect3DDevice9Impl_GetClipStatus(LPDIRECT3DDEVICE9 iface, D3DCLIPSTATUS9* pClipStatus);
1009-extern HRESULT WINAPI IDirect3DDevice9Impl_GetTexture(LPDIRECT3DDEVICE9 iface, DWORD Stage, IDirect3DBaseTexture9** ppTexture);
1010-extern HRESULT WINAPI IDirect3DDevice9Impl_SetTexture(LPDIRECT3DDEVICE9 iface, DWORD Stage, IDirect3DBaseTexture9* pTexture);
1011-extern HRESULT WINAPI IDirect3DDevice9Impl_GetTextureStageState(LPDIRECT3DDEVICE9 iface, DWORD Stage, D3DTEXTURESTAGESTATETYPE Type, DWORD* pValue);
1012-extern HRESULT WINAPI IDirect3DDevice9Impl_SetTextureStageState(LPDIRECT3DDEVICE9 iface, DWORD Stage, D3DTEXTURESTAGESTATETYPE Type, DWORD Value);
1013-extern HRESULT WINAPI IDirect3DDevice9Impl_GetSamplerState(LPDIRECT3DDEVICE9 iface, DWORD Sampler, D3DSAMPLERSTATETYPE Type, DWORD* pValue);
1014-extern HRESULT WINAPI IDirect3DDevice9Impl_SetSamplerState(LPDIRECT3DDEVICE9 iface, DWORD Sampler, D3DSAMPLERSTATETYPE Type, DWORD Value);
1015-extern HRESULT WINAPI IDirect3DDevice9Impl_ValidateDevice(LPDIRECT3DDEVICE9 iface, DWORD* pNumPasses);
1016-extern HRESULT WINAPI IDirect3DDevice9Impl_SetPaletteEntries(LPDIRECT3DDEVICE9 iface, UINT PaletteNumber, CONST PALETTEENTRY* pEntries);
1017-extern HRESULT WINAPI IDirect3DDevice9Impl_GetPaletteEntries(LPDIRECT3DDEVICE9 iface, UINT PaletteNumber, PALETTEENTRY* pEntries);
1018-extern HRESULT WINAPI IDirect3DDevice9Impl_SetCurrentTexturePalette(LPDIRECT3DDEVICE9 iface, UINT PaletteNumber);
1019-extern HRESULT WINAPI IDirect3DDevice9Impl_GetCurrentTexturePalette(LPDIRECT3DDEVICE9 iface, UINT *PaletteNumber);
1020-extern HRESULT WINAPI IDirect3DDevice9Impl_SetScissorRect(LPDIRECT3DDEVICE9 iface, CONST RECT* pRect);
1021-extern HRESULT WINAPI IDirect3DDevice9Impl_GetScissorRect(LPDIRECT3DDEVICE9 iface, RECT* pRect);
1022-extern HRESULT WINAPI IDirect3DDevice9Impl_SetSoftwareVertexProcessing(LPDIRECT3DDEVICE9 iface, BOOL bSoftware);
1023-extern BOOL WINAPI IDirect3DDevice9Impl_GetSoftwareVertexProcessing(LPDIRECT3DDEVICE9 iface);
1024-extern HRESULT WINAPI IDirect3DDevice9Impl_SetNPatchMode(LPDIRECT3DDEVICE9 iface, float nSegments);
1025-extern float WINAPI IDirect3DDevice9Impl_GetNPatchMode(LPDIRECT3DDEVICE9 iface);
1026-extern HRESULT WINAPI IDirect3DDevice9Impl_DrawPrimitive(LPDIRECT3DDEVICE9 iface, D3DPRIMITIVETYPE PrimitiveType, UINT StartVertex, UINT PrimitiveCount);
1027-extern HRESULT WINAPI IDirect3DDevice9Impl_DrawIndexedPrimitive(LPDIRECT3DDEVICE9 iface, D3DPRIMITIVETYPE, INT BaseVertexIndex, UINT MinVertexIndex, UINT NumVertices, UINT startIndex, UINT primCount);
1028-extern HRESULT WINAPI IDirect3DDevice9Impl_DrawPrimitiveUP(LPDIRECT3DDEVICE9 iface, D3DPRIMITIVETYPE PrimitiveType, UINT PrimitiveCount, CONST void* pVertexStreamZeroData, UINT VertexStreamZeroStride);
1029-extern HRESULT WINAPI IDirect3DDevice9Impl_DrawIndexedPrimitiveUP(LPDIRECT3DDEVICE9 iface, D3DPRIMITIVETYPE PrimitiveType, UINT MinVertexIndex, UINT NumVertices, UINT PrimitiveCount, CONST void* pIndexData, D3DFORMAT IndexDataFormat, CONST void* pVertexStreamZeroData, UINT VertexStreamZeroStride);
1030-extern HRESULT WINAPI IDirect3DDevice9Impl_ProcessVertices(LPDIRECT3DDEVICE9 iface, UINT SrcStartIndex, UINT DestIndex, UINT VertexCount, IDirect3DVertexBuffer9* pDestBuffer, IDirect3DVertexDeclaration9* pVertexDecl, DWORD Flags);
1031 extern HRESULT WINAPI IDirect3DDevice9Impl_CreateVertexDeclaration(LPDIRECT3DDEVICE9 iface, CONST D3DVERTEXELEMENT9* pVertexElements, IDirect3DVertexDeclaration9** ppDecl);
1032 extern HRESULT WINAPI IDirect3DDevice9Impl_SetVertexDeclaration(LPDIRECT3DDEVICE9 iface, IDirect3DVertexDeclaration9* pDecl);
1033 extern HRESULT WINAPI IDirect3DDevice9Impl_GetVertexDeclaration(LPDIRECT3DDEVICE9 iface, IDirect3DVertexDeclaration9** ppDecl);
1034@@ -409,11 +140,8 @@
1035 extern HRESULT WINAPI IDirect3DDevice9Impl_GetVertexShaderConstantB(LPDIRECT3DDEVICE9 iface, UINT StartRegister, BOOL* pConstantData, UINT BoolCount);
1036 extern HRESULT WINAPI IDirect3DDevice9Impl_SetStreamSource(LPDIRECT3DDEVICE9 iface, UINT StreamNumber, IDirect3DVertexBuffer9* pStreamData, UINT OffsetInBytes, UINT Stride);
1037 extern HRESULT WINAPI IDirect3DDevice9Impl_GetStreamSource(LPDIRECT3DDEVICE9 iface, UINT StreamNumber, IDirect3DVertexBuffer9** ppStreamData, UINT* OffsetInBytes, UINT* pStride);
1038-extern HRESULT WINAPI IDirect3DDevice9Impl_SetStreamSourceFreq(LPDIRECT3DDEVICE9 iface, UINT StreamNumber, UINT Divider);
1039-extern HRESULT WINAPI IDirect3DDevice9Impl_GetStreamSourceFreq(LPDIRECT3DDEVICE9 iface, UINT StreamNumber, UINT* Divider);
1040-extern HRESULT WINAPI IDirect3DDevice9Impl_SetIndices(LPDIRECT3DDEVICE9 iface, IDirect3DIndexBuffer9* pIndexData);
1041-extern HRESULT WINAPI IDirect3DDevice9Impl_GetIndices(LPDIRECT3DDEVICE9 iface, IDirect3DIndexBuffer9** ppIndexData);
1042 extern HRESULT WINAPI IDirect3DDevice9Impl_CreatePixelShader(LPDIRECT3DDEVICE9 iface, CONST DWORD* pFunction, IDirect3DPixelShader9** ppShader);
1043+
1044 extern HRESULT WINAPI IDirect3DDevice9Impl_SetPixelShader(LPDIRECT3DDEVICE9 iface, IDirect3DPixelShader9* pShader);
1045 extern HRESULT WINAPI IDirect3DDevice9Impl_GetPixelShader(LPDIRECT3DDEVICE9 iface, IDirect3DPixelShader9** ppShader);
1046 extern HRESULT WINAPI IDirect3DDevice9Impl_SetPixelShaderConstantF(LPDIRECT3DDEVICE9 iface, UINT StartRegister, CONST float* pConstantData, UINT Vector4fCount);
1047@@ -422,9 +150,6 @@
1048 extern HRESULT WINAPI IDirect3DDevice9Impl_GetPixelShaderConstantI(LPDIRECT3DDEVICE9 iface, UINT StartRegister, int* pConstantData, UINT Vector4iCount);
1049 extern HRESULT WINAPI IDirect3DDevice9Impl_SetPixelShaderConstantB(LPDIRECT3DDEVICE9 iface, UINT StartRegister, CONST BOOL* pConstantData, UINT BoolCount);
1050 extern HRESULT WINAPI IDirect3DDevice9Impl_GetPixelShaderConstantB(LPDIRECT3DDEVICE9 iface, UINT StartRegister, BOOL* pConstantData, UINT BoolCount);
1051-extern HRESULT WINAPI IDirect3DDevice9Impl_DrawRectPatch(LPDIRECT3DDEVICE9 iface, UINT Handle, CONST float* pNumSegs, CONST D3DRECTPATCH_INFO* pRectPatchInfo);
1052-extern HRESULT WINAPI IDirect3DDevice9Impl_DrawTriPatch(LPDIRECT3DDEVICE9 iface, UINT Handle, CONST float* pNumSegs, CONST D3DTRIPATCH_INFO* pTriPatchInfo);
1053-extern HRESULT WINAPI IDirect3DDevice9Impl_DeletePatch(LPDIRECT3DDEVICE9 iface, UINT Handle);
1054 extern HRESULT WINAPI IDirect3DDevice9Impl_CreateQuery(LPDIRECT3DDEVICE9 iface, D3DQUERYTYPE Type, IDirect3DQuery9** ppQuery);
1055
1056
1057@@ -440,7 +165,7 @@
1058 /*****************************************************************************
1059 * IDirect3DVolume9 implementation structure
1060 */
1061-struct IDirect3DVolume9Impl
1062+typedef struct IDirect3DVolume9Impl
1063 {
1064 /* IUnknown fields */
1065 IDirect3DVolume9Vtbl *lpVtbl;
1066@@ -448,23 +173,7 @@
1067
1068 /* IDirect3DVolume9 fields */
1069 IWineD3DVolume *wineD3DVolume;
1070-};
1071-
1072-/* IUnknown: */
1073-extern HRESULT WINAPI IDirect3DVolume9Impl_QueryInterface(LPDIRECT3DVOLUME9 iface, REFIID refiid, LPVOID* obj);
1074-extern ULONG WINAPI IDirect3DVolume9Impl_AddRef(LPDIRECT3DVOLUME9 iface);
1075-extern ULONG WINAPI IDirect3DVolume9Impl_Release(LPDIRECT3DVOLUME9 iface);
1076-
1077-/* IDirect3DVolume9: */
1078-extern HRESULT WINAPI IDirect3DVolume9Impl_GetDevice(LPDIRECT3DVOLUME9 iface, IDirect3DDevice9** ppDevice);
1079-extern HRESULT WINAPI IDirect3DVolume9Impl_SetPrivateData(LPDIRECT3DVOLUME9 iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags);
1080-extern HRESULT WINAPI IDirect3DVolume9Impl_GetPrivateData(LPDIRECT3DVOLUME9 iface, REFGUID refguid, void* pData, DWORD* pSizeOfData);
1081-extern HRESULT WINAPI IDirect3DVolume9Impl_FreePrivateData(LPDIRECT3DVOLUME9 iface, REFGUID refguid);
1082-extern HRESULT WINAPI IDirect3DVolume9Impl_GetContainer(LPDIRECT3DVOLUME9 iface, REFIID riid, void** ppContainer);
1083-extern HRESULT WINAPI IDirect3DVolume9Impl_GetDesc(LPDIRECT3DVOLUME9 iface, D3DVOLUME_DESC* pDesc);
1084-extern HRESULT WINAPI IDirect3DVolume9Impl_LockBox(LPDIRECT3DVOLUME9 iface, D3DLOCKED_BOX* pLockedVolume, CONST D3DBOX* pBox, DWORD Flags);
1085-extern HRESULT WINAPI IDirect3DVolume9Impl_UnlockBox(LPDIRECT3DVOLUME9 iface);
1086-
1087+} IDirect3DVolume9Impl;
1088
1089 /* ------------------- */
1090 /* IDirect3DSwapChain9 */
1091@@ -478,34 +187,15 @@
1092 /*****************************************************************************
1093 * IDirect3DSwapChain9 implementation structure
1094 */
1095-struct IDirect3DSwapChain9Impl
1096+typedef struct IDirect3DSwapChain9Impl
1097 {
1098 /* IUnknown fields */
1099 IDirect3DSwapChain9Vtbl *lpVtbl;
1100 DWORD ref;
1101
1102 /* IDirect3DSwapChain9 fields */
1103- IDirect3DDevice9Impl *Device;
1104- IDirect3DSurface9Impl *frontBuffer;
1105- IDirect3DSurface9Impl *backBuffer;
1106- IDirect3DSurface9Impl *depthStencilBuffer;
1107- D3DPRESENT_PARAMETERS PresentParms;
1108-};
1109-
1110-/* IUnknown: */
1111-extern HRESULT WINAPI IDirect3DSwapChain9Impl_QueryInterface(LPDIRECT3DSWAPCHAIN9 iface, REFIID refiid, LPVOID* obj);
1112-extern ULONG WINAPI IDirect3DSwapChain9Impl_AddRef(LPDIRECT3DSWAPCHAIN9 iface);
1113-extern ULONG WINAPI IDirect3DSwapChain9Impl_Release(LPDIRECT3DSWAPCHAIN9 iface);
1114-
1115-/* IDirect3DSwapChain9: */
1116-extern HRESULT WINAPI IDirect3DSwapChain9Impl_Present(LPDIRECT3DSWAPCHAIN9 iface, CONST RECT* pSourceRect, CONST RECT* pDestRect, HWND hDestWindowOverride, CONST RGNDATA* pDirtyRegion, DWORD dwFlags);
1117-extern HRESULT WINAPI IDirect3DSwapChain9Impl_GetFrontBufferData(LPDIRECT3DSWAPCHAIN9 iface, IDirect3DSurface9* pDestSurface);
1118-extern HRESULT WINAPI IDirect3DSwapChain9Impl_GetBackBuffer(LPDIRECT3DSWAPCHAIN9 iface, UINT iBackBuffer, D3DBACKBUFFER_TYPE Type, IDirect3DSurface9** ppBackBuffer);
1119-extern HRESULT WINAPI IDirect3DSwapChain9Impl_GetRasterStatus(LPDIRECT3DSWAPCHAIN9 iface, D3DRASTER_STATUS* pRasterStatus);
1120-extern HRESULT WINAPI IDirect3DSwapChain9Impl_GetDisplayMode(LPDIRECT3DSWAPCHAIN9 iface, D3DDISPLAYMODE* pMode);
1121-extern HRESULT WINAPI IDirect3DSwapChain9Impl_GetDevice(LPDIRECT3DSWAPCHAIN9 iface, IDirect3DDevice9** ppDevice);
1122-extern HRESULT WINAPI IDirect3DSwapChain9Impl_GetPresentParameters(LPDIRECT3DSWAPCHAIN9 iface, D3DPRESENT_PARAMETERS* pPresentationParameters);
1123-
1124+ IWineD3DSwapChain *wineD3DSwapChain;
1125+} IDirect3DSwapChain9Impl;
1126
1127 /* ------------------ */
1128 /* IDirect3DResource9 */
1129@@ -519,7 +209,7 @@
1130 /*****************************************************************************
1131 * IDirect3DResource9 implementation structure
1132 */
1133-struct IDirect3DResource9Impl
1134+typedef struct IDirect3DResource9Impl
1135 {
1136 /* IUnknown fields */
1137 IDirect3DResource9Vtbl *lpVtbl;
1138@@ -527,7 +217,7 @@
1139
1140 /* IDirect3DResource9 fields */
1141 IWineD3DResource *wineD3DResource;
1142-};
1143+} IDirect3DResource9Impl;
1144
1145 /* IUnknown: */
1146 extern HRESULT WINAPI IDirect3DResource9Impl_QueryInterface(LPDIRECT3DRESOURCE9 iface,REFIID refiid,LPVOID *obj);
1147@@ -544,7 +234,6 @@
1148 extern void WINAPI IDirect3DResource9Impl_PreLoad(LPDIRECT3DRESOURCE9 iface);
1149 extern D3DRESOURCETYPE WINAPI IDirect3DResource9Impl_GetType(LPDIRECT3DRESOURCE9 iface);
1150
1151-
1152 /* ----------------- */
1153 /* IDirect3DSurface9 */
1154 /* ----------------- */
1155@@ -557,7 +246,7 @@
1156 /*****************************************************************************
1157 * IDirect3DSurface9 implementation structure
1158 */
1159-struct IDirect3DSurface9Impl
1160+typedef struct IDirect3DSurface9Impl
1161 {
1162 /* IUnknown fields */
1163 IDirect3DSurface9Vtbl *lpVtbl;
1164@@ -566,31 +255,7 @@
1165 /* IDirect3DResource9 fields */
1166 IWineD3DSurface *wineD3DSurface;
1167
1168-};
1169-
1170-/* IUnknown: */
1171-extern HRESULT WINAPI IDirect3DSurface9Impl_QueryInterface(LPDIRECT3DSURFACE9 iface, REFIID refiid, LPVOID* obj);
1172-extern ULONG WINAPI IDirect3DSurface9Impl_AddRef(LPDIRECT3DSURFACE9 iface);
1173-extern ULONG WINAPI IDirect3DSurface9Impl_Release(LPDIRECT3DSURFACE9 iface);
1174-
1175-/* IDirect3DSurface9: (Inherited from IDirect3DResource9) */
1176-extern HRESULT WINAPI IDirect3DSurface9Impl_GetDevice(LPDIRECT3DSURFACE9 iface, IDirect3DDevice9** ppDevice);
1177-extern HRESULT WINAPI IDirect3DSurface9Impl_SetPrivateData(LPDIRECT3DSURFACE9 iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags);
1178-extern HRESULT WINAPI IDirect3DSurface9Impl_GetPrivateData(LPDIRECT3DSURFACE9 iface, REFGUID refguid, void* pData,DWORD* pSizeOfData);
1179-extern HRESULT WINAPI IDirect3DSurface9Impl_FreePrivateData(LPDIRECT3DSURFACE9 iface, REFGUID refguid);
1180-extern DWORD WINAPI IDirect3DSurface9Impl_SetPriority(LPDIRECT3DSURFACE9 iface, DWORD PriorityNew);
1181-extern DWORD WINAPI IDirect3DSurface9Impl_GetPriority(LPDIRECT3DSURFACE9 iface);
1182-extern void WINAPI IDirect3DSurface9Impl_PreLoad(LPDIRECT3DSURFACE9 iface);
1183-extern D3DRESOURCETYPE WINAPI IDirect3DSurface9Impl_GetType(LPDIRECT3DSURFACE9 iface);
1184-
1185-/* IDirect3DSurface9: */
1186-extern HRESULT WINAPI IDirect3DSurface9Impl_GetContainer(LPDIRECT3DSURFACE9 iface, REFIID riid, void** ppContainer);
1187-extern HRESULT WINAPI IDirect3DSurface9Impl_GetDesc(LPDIRECT3DSURFACE9 iface, D3DSURFACE_DESC *pDesc);
1188-extern HRESULT WINAPI IDirect3DSurface9Impl_LockRect(LPDIRECT3DSURFACE9 iface, D3DLOCKED_RECT* pLockedRect, CONST RECT* pRect, DWORD Flags);
1189-extern HRESULT WINAPI IDirect3DSurface9Impl_UnlockRect(LPDIRECT3DSURFACE9 iface);
1190-extern HRESULT WINAPI IDirect3DSurface9Impl_GetDC(LPDIRECT3DSURFACE9 iface, HDC* phdc);
1191-extern HRESULT WINAPI IDirect3DSurface9Impl_ReleaseDC(LPDIRECT3DSURFACE9 iface, HDC hdc);
1192-
1193+} IDirect3DSurface9Impl;
1194
1195 /* ---------------------- */
1196 /* IDirect3DVertexBuffer9 */
1197@@ -604,7 +269,7 @@
1198 /*****************************************************************************
1199 * IDirect3DVertexBuffer9 implementation structure
1200 */
1201-struct IDirect3DVertexBuffer9Impl
1202+typedef struct IDirect3DVertexBuffer9Impl
1203 {
1204 /* IUnknown fields */
1205 IDirect3DVertexBuffer9Vtbl *lpVtbl;
1206@@ -612,28 +277,8 @@
1207
1208 /* IDirect3DResource9 fields */
1209 IWineD3DVertexBuffer *wineD3DVertexBuffer;
1210-};
1211-
1212-/* IUnknown: */
1213-extern HRESULT WINAPI IDirect3DVertexBuffer9Impl_QueryInterface(LPDIRECT3DVERTEXBUFFER9 iface,REFIID refiid,LPVOID *obj);
1214-extern ULONG WINAPI IDirect3DVertexBuffer9Impl_AddRef(LPDIRECT3DVERTEXBUFFER9 iface);
1215-extern ULONG WINAPI IDirect3DVertexBuffer9Impl_Release(LPDIRECT3DVERTEXBUFFER9 iface);
1216-
1217-/* IDirect3DVertexBuffer9: (Inherited from IDirect3DResource9) */
1218-extern HRESULT WINAPI IDirect3DVertexBuffer9Impl_GetDevice(LPDIRECT3DVERTEXBUFFER9 iface, IDirect3DDevice9** ppDevice);
1219-extern HRESULT WINAPI IDirect3DVertexBuffer9Impl_SetPrivateData(LPDIRECT3DVERTEXBUFFER9 iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags);
1220-extern HRESULT WINAPI IDirect3DVertexBuffer9Impl_GetPrivateData(LPDIRECT3DVERTEXBUFFER9 iface, REFGUID refguid, void* pData, DWORD* pSizeOfData);
1221-extern HRESULT WINAPI IDirect3DVertexBuffer9Impl_FreePrivateData(LPDIRECT3DVERTEXBUFFER9 iface, REFGUID refguid);
1222-extern DWORD WINAPI IDirect3DVertexBuffer9Impl_SetPriority(LPDIRECT3DVERTEXBUFFER9 iface, DWORD PriorityNew);
1223-extern DWORD WINAPI IDirect3DVertexBuffer9Impl_GetPriority(LPDIRECT3DVERTEXBUFFER9 iface);
1224-extern void WINAPI IDirect3DVertexBuffer9Impl_PreLoad(LPDIRECT3DVERTEXBUFFER9 iface);
1225-extern D3DRESOURCETYPE WINAPI IDirect3DVertexBuffer9Impl_GetType(LPDIRECT3DVERTEXBUFFER9 iface);
1226-
1227-/* IDirect3DVertexBuffer9: */
1228-extern HRESULT WINAPI IDirect3DVertexBuffer9Impl_Lock(LPDIRECT3DVERTEXBUFFER9 iface, UINT OffsetToLock, UINT SizeToLock, void** ppbData, DWORD Flags);
1229-extern HRESULT WINAPI IDirect3DVertexBuffer9Impl_Unlock(LPDIRECT3DVERTEXBUFFER9 iface);
1230-extern HRESULT WINAPI IDirect3DVertexBuffer9Impl_GetDesc(LPDIRECT3DVERTEXBUFFER9 iface, D3DVERTEXBUFFER_DESC *pDesc);
1231
1232+} IDirect3DVertexBuffer9Impl;
1233
1234 /* --------------------- */
1235 /* IDirect3DIndexBuffer9 */
1236@@ -647,7 +292,7 @@
1237 /*****************************************************************************
1238 * IDirect3DIndexBuffer9 implementation structure
1239 */
1240-struct IDirect3DIndexBuffer9Impl
1241+typedef struct IDirect3DIndexBuffer9Impl
1242 {
1243 /* IUnknown fields */
1244 IDirect3DIndexBuffer9Vtbl *lpVtbl;
1245@@ -655,28 +300,7 @@
1246
1247 /* IDirect3DResource9 fields */
1248 IWineD3DIndexBuffer *wineD3DIndexBuffer;
1249-};
1250-
1251-/* IUnknown: */
1252-extern HRESULT WINAPI IDirect3DIndexBuffer9Impl_QueryInterface(LPDIRECT3DINDEXBUFFER9 iface,REFIID refiid,LPVOID *obj);
1253-extern ULONG WINAPI IDirect3DIndexBuffer9Impl_AddRef(LPDIRECT3DINDEXBUFFER9 iface);
1254-extern ULONG WINAPI IDirect3DIndexBuffer9Impl_Release(LPDIRECT3DINDEXBUFFER9 iface);
1255-
1256-/* IDirect3DIndexBuffer9: (Inherited from IDirect3DResource9) */
1257-extern HRESULT WINAPI IDirect3DIndexBuffer9Impl_GetDevice(LPDIRECT3DINDEXBUFFER9 iface, IDirect3DDevice9** ppDevice);
1258-extern HRESULT WINAPI IDirect3DIndexBuffer9Impl_SetPrivateData(LPDIRECT3DINDEXBUFFER9 iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags);
1259-extern HRESULT WINAPI IDirect3DIndexBuffer9Impl_GetPrivateData(LPDIRECT3DINDEXBUFFER9 iface, REFGUID refguid, void* pData, DWORD* pSizeOfData);
1260-extern HRESULT WINAPI IDirect3DIndexBuffer9Impl_FreePrivateData(LPDIRECT3DINDEXBUFFER9 iface, REFGUID refguid);
1261-extern DWORD WINAPI IDirect3DIndexBuffer9Impl_SetPriority(LPDIRECT3DINDEXBUFFER9 iface, DWORD PriorityNew);
1262-extern DWORD WINAPI IDirect3DIndexBuffer9Impl_GetPriority(LPDIRECT3DINDEXBUFFER9 iface);
1263-extern void WINAPI IDirect3DIndexBuffer9Impl_PreLoad(LPDIRECT3DINDEXBUFFER9 iface);
1264-extern D3DRESOURCETYPE WINAPI IDirect3DIndexBuffer9Impl_GetType(LPDIRECT3DINDEXBUFFER9 iface);
1265-
1266-/* IDirect3DIndexBuffer9: */
1267-extern HRESULT WINAPI IDirect3DIndexBuffer9Impl_Lock(LPDIRECT3DINDEXBUFFER9 iface, UINT OffsetToLock, UINT SizeToLock, void** ppbData, DWORD Flags);
1268-extern HRESULT WINAPI IDirect3DIndexBuffer9Impl_Unlock(LPDIRECT3DINDEXBUFFER9 iface);
1269-extern HRESULT WINAPI IDirect3DIndexBuffer9Impl_GetDesc(LPDIRECT3DINDEXBUFFER9 iface, D3DINDEXBUFFER_DESC *pDesc);
1270-
1271+} IDirect3DIndexBuffer9Impl;
1272
1273 /* --------------------- */
1274 /* IDirect3DBaseTexture9 */
1275@@ -690,7 +314,7 @@
1276 /*****************************************************************************
1277 * IDirect3DBaseTexture9 implementation structure
1278 */
1279-struct IDirect3DBaseTexture9Impl
1280+typedef struct IDirect3DBaseTexture9Impl
1281 {
1282 /* IUnknown fields */
1283 IDirect3DBaseTexture9Vtbl *lpVtbl;
1284@@ -698,7 +322,8 @@
1285
1286 /* IDirect3DResource9 fields */
1287 IWineD3DBaseTexture *wineD3DBaseTexture;
1288-};
1289+
1290+} IDirect3DBaseTexture9Impl;
1291
1292 /* IUnknown: */
1293 extern HRESULT WINAPI IDirect3DBaseTexture9Impl_QueryInterface(LPDIRECT3DBASETEXTURE9 iface,REFIID refiid,LPVOID *obj);
1294@@ -723,113 +348,45 @@
1295 extern D3DTEXTUREFILTERTYPE WINAPI IDirect3DBaseTexture9Impl_GetAutoGenFilterType(LPDIRECT3DBASETEXTURE9 iface);
1296 extern void WINAPI IDirect3DBaseTexture9Impl_GenerateMipSubLevels(LPDIRECT3DBASETEXTURE9 iface);
1297
1298-
1299-/* --------------------- */
1300-/* IDirect3DCubeTexture9 */
1301-/* --------------------- */
1302+/* ----------------- */
1303+/* IDirect3DTexture9 */
1304+/* ----------------- */
1305
1306 /*****************************************************************************
1307 * Predeclare the interface implementation structures
1308 */
1309-extern IDirect3DCubeTexture9Vtbl Direct3DCubeTexture9_Vtbl;
1310+extern IDirect3DTexture9Vtbl Direct3DTexture9_Vtbl;
1311
1312 /*****************************************************************************
1313- * IDirect3DCubeTexture9 implementation structure
1314+ * IDirect3DTexture9 implementation structure
1315 */
1316-struct IDirect3DCubeTexture9Impl
1317+typedef struct IDirect3DTexture9Impl
1318 {
1319 /* IUnknown fields */
1320- IDirect3DCubeTexture9Vtbl *lpVtbl;
1321+ IDirect3DTexture9Vtbl *lpVtbl;
1322 DWORD ref;
1323-
1324 /* IDirect3DResource9 fields */
1325- IWineD3DCubeTexture *wineD3DCubeTexture;
1326-};
1327-
1328-/* IUnknown: */
1329-extern HRESULT WINAPI IDirect3DCubeTexture9Impl_QueryInterface(LPDIRECT3DCUBETEXTURE9 iface,REFIID refiid,LPVOID *obj);
1330-extern ULONG WINAPI IDirect3DCubeTexture9Impl_AddRef(LPDIRECT3DCUBETEXTURE9 iface);
1331-extern ULONG WINAPI IDirect3DCubeTexture9Impl_Release(LPDIRECT3DCUBETEXTURE9 iface);
1332-
1333-/* IDirect3DCubeTexture9: (Inherited from IDirect3DResource9) */
1334-extern HRESULT WINAPI IDirect3DCubeTexture9Impl_GetDevice(LPDIRECT3DCUBETEXTURE9 iface, IDirect3DDevice9** ppDevice);
1335-extern HRESULT WINAPI IDirect3DCubeTexture9Impl_SetPrivateData(LPDIRECT3DCUBETEXTURE9 iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags);
1336-extern HRESULT WINAPI IDirect3DCubeTexture9Impl_GetPrivateData(LPDIRECT3DCUBETEXTURE9 iface, REFGUID refguid, void* pData, DWORD* pSizeOfData);
1337-extern HRESULT WINAPI IDirect3DCubeTexture9Impl_FreePrivateData(LPDIRECT3DCUBETEXTURE9 iface, REFGUID refguid);
1338-extern DWORD WINAPI IDirect3DCubeTexture9Impl_SetPriority(LPDIRECT3DCUBETEXTURE9 iface, DWORD PriorityNew);
1339-extern DWORD WINAPI IDirect3DCubeTexture9Impl_GetPriority(LPDIRECT3DCUBETEXTURE9 iface);
1340-extern void WINAPI IDirect3DCubeTexture9Impl_PreLoad(LPDIRECT3DCUBETEXTURE9 iface);
1341-extern D3DRESOURCETYPE WINAPI IDirect3DCubeTexture9Impl_GetType(LPDIRECT3DCUBETEXTURE9 iface);
1342-
1343-/* IDirect3DCubeTexture9: (Inherited from IDirect3DBaseTexture9) */
1344-extern DWORD WINAPI IDirect3DCubeTexture9Impl_SetLOD(LPDIRECT3DCUBETEXTURE9 iface, DWORD LODNew);
1345-extern DWORD WINAPI IDirect3DCubeTexture9Impl_GetLOD(LPDIRECT3DCUBETEXTURE9 iface);
1346-extern DWORD WINAPI IDirect3DCubeTexture9Impl_GetLevelCount(LPDIRECT3DCUBETEXTURE9 iface);
1347-extern HRESULT WINAPI IDirect3DCubeTexture9Impl_SetAutoGenFilterType(LPDIRECT3DCUBETEXTURE9 iface, D3DTEXTUREFILTERTYPE FilterType);
1348-extern D3DTEXTUREFILTERTYPE WINAPI IDirect3DCubeTexture9Impl_GetAutoGenFilterType(LPDIRECT3DCUBETEXTURE9 iface);
1349-extern void WINAPI IDirect3DCubeTexture9Impl_GenerateMipSubLevels(LPDIRECT3DCUBETEXTURE9 iface);
1350-
1351-/* IDirect3DCubeTexture9 */
1352-extern HRESULT WINAPI IDirect3DCubeTexture9Impl_GetLevelDesc(LPDIRECT3DCUBETEXTURE9 iface, UINT Level, D3DSURFACE_DESC* pDesc);
1353-extern HRESULT WINAPI IDirect3DCubeTexture9Impl_GetCubeMapSurface(LPDIRECT3DCUBETEXTURE9 iface, D3DCUBEMAP_FACES FaceType, UINT Level, IDirect3DSurface9** ppCubeMapSurface);
1354-extern HRESULT WINAPI IDirect3DCubeTexture9Impl_LockRect(LPDIRECT3DCUBETEXTURE9 iface, D3DCUBEMAP_FACES FaceType, UINT Level, D3DLOCKED_RECT* pLockedRect, CONST RECT* pRect, DWORD Flags);
1355-extern HRESULT WINAPI IDirect3DCubeTexture9Impl_UnlockRect(LPDIRECT3DCUBETEXTURE9 iface, D3DCUBEMAP_FACES FaceType, UINT Level);
1356-extern HRESULT WINAPI IDirect3DCubeTexture9Impl_AddDirtyRect(LPDIRECT3DCUBETEXTURE9 iface, D3DCUBEMAP_FACES FaceType, CONST RECT* pDirtyRect);
1357+ IWineD3DTexture *wineD3DTexture;
1358
1359-
1360-/* ----------------- */
1361-/* IDirect3DTexture9 */
1362-/* ----------------- */
1363+} IDirect3DTexture9Impl;
1364
1365 /*****************************************************************************
1366 * Predeclare the interface implementation structures
1367 */
1368-extern IDirect3DTexture9Vtbl Direct3DTexture9_Vtbl;
1369+extern IDirect3DCubeTexture9Vtbl Direct3DCubeTexture9_Vtbl;
1370
1371 /*****************************************************************************
1372- * IDirect3DTexture9 implementation structure
1373+ * IDirect3DCubeTexture9 implementation structure
1374 */
1375-struct IDirect3DTexture9Impl
1376+typedef struct IDirect3DCubeTexture9Impl
1377 {
1378 /* IUnknown fields */
1379- IDirect3DTexture9Vtbl *lpVtbl;
1380+ IDirect3DCubeTexture9Vtbl *lpVtbl;
1381 DWORD ref;
1382-
1383 /* IDirect3DResource9 fields */
1384- IWineD3DTexture *wineD3DTexture;
1385-
1386-};
1387-
1388-/* IUnknown: */
1389-extern HRESULT WINAPI IDirect3DTexture9Impl_QueryInterface(LPDIRECT3DTEXTURE9 iface,REFIID refiid,LPVOID *obj);
1390-extern ULONG WINAPI IDirect3DTexture9Impl_AddRef(LPDIRECT3DTEXTURE9 iface);
1391-extern ULONG WINAPI IDirect3DTexture9Impl_Release(LPDIRECT3DTEXTURE9 iface);
1392-
1393-/* IDirect3DTexture9: (Inherited from IDirect3DResource9) */
1394-extern HRESULT WINAPI IDirect3DTexture9Impl_GetDevice(LPDIRECT3DTEXTURE9 iface, IDirect3DDevice9** ppDevice);
1395-extern HRESULT WINAPI IDirect3DTexture9Impl_SetPrivateData(LPDIRECT3DTEXTURE9 iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags);
1396-extern HRESULT WINAPI IDirect3DTexture9Impl_GetPrivateData(LPDIRECT3DTEXTURE9 iface, REFGUID refguid, void* pData, DWORD* pSizeOfData);
1397-extern HRESULT WINAPI IDirect3DTexture9Impl_FreePrivateData(LPDIRECT3DTEXTURE9 iface, REFGUID refguid);
1398-extern DWORD WINAPI IDirect3DTexture9Impl_SetPriority(LPDIRECT3DTEXTURE9 iface, DWORD PriorityNew);
1399-extern DWORD WINAPI IDirect3DTexture9Impl_GetPriority(LPDIRECT3DTEXTURE9 iface);
1400-extern void WINAPI IDirect3DTexture9Impl_PreLoad(LPDIRECT3DTEXTURE9 iface);
1401-extern D3DRESOURCETYPE WINAPI IDirect3DTexture9Impl_GetType(LPDIRECT3DTEXTURE9 iface);
1402-
1403-/* IDirect3DTexture9: (Inherited from IDirect3DBaseTexture9) */
1404-extern DWORD WINAPI IDirect3DTexture9Impl_SetLOD(LPDIRECT3DTEXTURE9 iface, DWORD LODNew);
1405-extern DWORD WINAPI IDirect3DTexture9Impl_GetLOD(LPDIRECT3DTEXTURE9 iface);
1406-extern DWORD WINAPI IDirect3DTexture9Impl_GetLevelCount(LPDIRECT3DTEXTURE9 iface);
1407-extern HRESULT WINAPI IDirect3DTexture9Impl_SetAutoGenFilterType(LPDIRECT3DTEXTURE9 iface, D3DTEXTUREFILTERTYPE FilterType);
1408-extern D3DTEXTUREFILTERTYPE WINAPI IDirect3DTexture9Impl_GetAutoGenFilterType(LPDIRECT3DTEXTURE9 iface);
1409-extern void WINAPI IDirect3DTexture9Impl_GenerateMipSubLevels(LPDIRECT3DTEXTURE9 iface);
1410-
1411-/* IDirect3DTexture9: */
1412-extern HRESULT WINAPI IDirect3DTexture9Impl_GetLevelDesc(LPDIRECT3DTEXTURE9 iface, UINT Level, D3DSURFACE_DESC* pDesc);
1413-extern HRESULT WINAPI IDirect3DTexture9Impl_GetSurfaceLevel(LPDIRECT3DTEXTURE9 iface, UINT Level, IDirect3DSurface9** ppSurfaceLevel);
1414-extern HRESULT WINAPI IDirect3DTexture9Impl_LockRect(LPDIRECT3DTEXTURE9 iface, UINT Level, D3DLOCKED_RECT* pLockedRect, CONST RECT* pRect, DWORD Flags);
1415-extern HRESULT WINAPI IDirect3DTexture9Impl_UnlockRect(LPDIRECT3DTEXTURE9 iface, UINT Level);
1416-extern HRESULT WINAPI IDirect3DTexture9Impl_AddDirtyRect(LPDIRECT3DTEXTURE9 iface, CONST RECT* pDirtyRect);
1417+ IWineD3DCubeTexture *wineD3DCubeTexture;
1418
1419+} IDirect3DCubeTexture9Impl;
1420
1421 /* ----------------------- */
1422 /* IDirect3DVolumeTexture9 */
1423@@ -843,7 +400,7 @@
1424 /*****************************************************************************
1425 * IDirect3DVolumeTexture9 implementation structure
1426 */
1427-struct IDirect3DVolumeTexture9Impl
1428+typedef struct IDirect3DVolumeTexture9Impl
1429 {
1430 /* IUnknown fields */
1431 IDirect3DVolumeTexture9Vtbl *lpVtbl;
1432@@ -851,38 +408,7 @@
1433
1434 /* IDirect3DResource9 fields */
1435 IWineD3DVolumeTexture *wineD3DVolumeTexture;
1436-};
1437-
1438-/* IUnknown: */
1439-extern HRESULT WINAPI IDirect3DVolumeTexture9Impl_QueryInterface(LPDIRECT3DVOLUMETEXTURE9 iface,REFIID refiid,LPVOID *obj);
1440-extern ULONG WINAPI IDirect3DVolumeTexture9Impl_AddRef(LPDIRECT3DVOLUMETEXTURE9 iface);
1441-extern ULONG WINAPI IDirect3DVolumeTexture9Impl_Release(LPDIRECT3DVOLUMETEXTURE9 iface);
1442-
1443-/* IDirect3DVolumeTexture9: (Inherited from IDirect3DResource9) */
1444-extern HRESULT WINAPI IDirect3DVolumeTexture9Impl_GetDevice(LPDIRECT3DVOLUMETEXTURE9 iface, IDirect3DDevice9** ppDevice);
1445-extern HRESULT WINAPI IDirect3DVolumeTexture9Impl_SetPrivateData(LPDIRECT3DVOLUMETEXTURE9 iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags);
1446-extern HRESULT WINAPI IDirect3DVolumeTexture9Impl_GetPrivateData(LPDIRECT3DVOLUMETEXTURE9 iface, REFGUID refguid, void* pData, DWORD* pSizeOfData);
1447-extern HRESULT WINAPI IDirect3DVolumeTexture9Impl_FreePrivateData(LPDIRECT3DVOLUMETEXTURE9 iface, REFGUID refguid);
1448-extern DWORD WINAPI IDirect3DVolumeTexture9Impl_SetPriority(LPDIRECT3DVOLUMETEXTURE9 iface, DWORD PriorityNew);
1449-extern DWORD WINAPI IDirect3DVolumeTexture9Impl_GetPriority(LPDIRECT3DVOLUMETEXTURE9 iface);
1450-extern void WINAPI IDirect3DVolumeTexture9Impl_PreLoad(LPDIRECT3DVOLUMETEXTURE9 iface);
1451-extern D3DRESOURCETYPE WINAPI IDirect3DVolumeTexture9Impl_GetType(LPDIRECT3DVOLUMETEXTURE9 iface);
1452-
1453-/* IDirect3DVolumeTexture9: (Inherited from IDirect3DBaseTexture9) */
1454-extern DWORD WINAPI IDirect3DVolumeTexture9Impl_SetLOD(LPDIRECT3DVOLUMETEXTURE9 iface, DWORD LODNew);
1455-extern DWORD WINAPI IDirect3DVolumeTexture9Impl_GetLOD(LPDIRECT3DVOLUMETEXTURE9 iface);
1456-extern DWORD WINAPI IDirect3DVolumeTexture9Impl_GetLevelCount(LPDIRECT3DVOLUMETEXTURE9 iface);
1457-extern HRESULT WINAPI IDirect3DVolumeTexture9Impl_SetAutoGenFilterType(LPDIRECT3DVOLUMETEXTURE9 iface, D3DTEXTUREFILTERTYPE FilterType);
1458-extern D3DTEXTUREFILTERTYPE WINAPI IDirect3DVolumeTexture9Impl_GetAutoGenFilterType(LPDIRECT3DVOLUMETEXTURE9 iface);
1459-extern void WINAPI IDirect3DVolumeTexture9Impl_GenerateMipSubLevels(LPDIRECT3DVOLUMETEXTURE9 iface);
1460-
1461-/* IDirect3DVolumeTexture9: */
1462-extern HRESULT WINAPI IDirect3DVolumeTexture9Impl_GetLevelDesc(LPDIRECT3DVOLUMETEXTURE9 iface, UINT Level, D3DVOLUME_DESC *pDesc);
1463-extern HRESULT WINAPI IDirect3DVolumeTexture9Impl_GetVolumeLevel(LPDIRECT3DVOLUMETEXTURE9 iface, UINT Level, IDirect3DVolume9** ppVolumeLevel);
1464-extern HRESULT WINAPI IDirect3DVolumeTexture9Impl_LockBox(LPDIRECT3DVOLUMETEXTURE9 iface, UINT Level, D3DLOCKED_BOX* pLockedVolume, CONST D3DBOX* pBox, DWORD Flags);
1465-extern HRESULT WINAPI IDirect3DVolumeTexture9Impl_UnlockBox(LPDIRECT3DVOLUMETEXTURE9 iface, UINT Level);
1466-extern HRESULT WINAPI IDirect3DVolumeTexture9Impl_AddDirtyBox(LPDIRECT3DVOLUMETEXTURE9 iface, CONST D3DBOX* pDirtyBox);
1467-
1468+} IDirect3DVolumeTexture9Impl;
1469
1470 /* ----------------------- */
1471 /* IDirect3DStateBlock9 */
1472@@ -896,91 +422,14 @@
1473 /*****************************************************************************
1474 * IDirect3DStateBlock9 implementation structure
1475 */
1476-struct IDirect3DStateBlock9Impl {
1477+typedef struct IDirect3DStateBlock9Impl {
1478 /* IUnknown fields */
1479 IDirect3DStateBlock9Vtbl *lpVtbl;
1480 DWORD ref;
1481
1482 /* IDirect3DStateBlock9 fields */
1483- IDirect3DDevice9Impl* Device;
1484-
1485- D3DSTATEBLOCKTYPE blockType;
1486-
1487- SAVEDSTATES Changed;
1488- SAVEDSTATES Set;
1489-
1490- /* Light Enable */
1491- BOOL lightEnable[MAX_ACTIVE_LIGHTS];
1492-
1493- /* ClipPlane */
1494- double clipplane[MAX_CLIPPLANES][4];
1495-
1496- /* Stream Source */
1497- UINT stream_stride[MAX_STREAMS];
1498- IDirect3DVertexBuffer9* stream_source[MAX_STREAMS];
1499- BOOL streamIsUP;
1500-
1501- /* Indices */
1502- IDirect3DIndexBuffer9* pIndexData;
1503- UINT baseVertexIndex;
1504-
1505- /* Texture */
1506- IDirect3DBaseTexture9* textures[8];
1507- int textureDimensions[8];
1508- /* Texture State Stage */
1509- DWORD texture_state[8][HIGHEST_TEXTURE_STATE];
1510-
1511- /* RenderState */
1512- DWORD renderstate[HIGHEST_RENDER_STATE];
1513-
1514- /* Transform */
1515- D3DMATRIX transforms[HIGHEST_TRANSFORMSTATE];
1516-
1517-
1518- /* ViewPort */
1519- D3DVIEWPORT9 viewport;
1520-
1521- /* Lights */
1522- D3DLIGHT9 lights[MAX_ACTIVE_LIGHTS];
1523-
1524- /* Material */
1525- D3DMATERIAL9 material;
1526-
1527- DWORD FVF;
1528-
1529- /* Vertex Shader */
1530- IDirect3DVertexShader9* VertexShader;
1531-
1532- /* Vertex Shader Declaration */
1533- IDirect3DVertexDeclaration9Impl* vertexDecl;
1534-
1535- /* Pixel Shader */
1536- IDirect3DPixelShader9* PixelShader;
1537-
1538- /* Indexed Vertex Blending */
1539- D3DVERTEXBLENDFLAGS vertex_blend;
1540- FLOAT tween_factor;
1541-
1542- /* Vertex Shader Constant */
1543- D3DSHADERVECTORF vertexShaderConstantF[D3D_VSHADER_MAX_CONSTANTS];
1544- D3DSHADERVECTORI vertexShaderConstantI[D3D_VSHADER_MAX_CONSTANTS];
1545- BOOL vertexShaderConstantB[D3D_VSHADER_MAX_CONSTANTS];
1546- /* Pixel Shader Constant */
1547- D3DSHADERVECTORF pixelShaderConstantF[D3D_PSHADER_MAX_CONSTANTS];
1548- D3DSHADERVECTORI pixelShaderConstantI[D3D_PSHADER_MAX_CONSTANTS];
1549- BOOL pixelShaderConstantB[D3D_PSHADER_MAX_CONSTANTS];
1550-};
1551-
1552-/* IUnknown: */
1553-extern HRESULT WINAPI IDirect3DStateBlock9Impl_QueryInterface(LPDIRECT3DSTATEBLOCK9 iface, REFIID refiid, LPVOID* obj);
1554-extern ULONG WINAPI IDirect3DStateBlock9Impl_AddRef(LPDIRECT3DSTATEBLOCK9 iface);
1555-extern ULONG WINAPI IDirect3DStateBlock9Impl_Release(LPDIRECT3DSTATEBLOCK9 iface);
1556-
1557-/* IDirect3DStateBlock9: */
1558-extern HRESULT WINAPI IDirect3DStateBlock9Impl_GetDevice(LPDIRECT3DSTATEBLOCK9 iface, IDirect3DDevice9** ppDevice);
1559-extern HRESULT WINAPI IDirect3DStateBlock9Impl_Capture(LPDIRECT3DSTATEBLOCK9 iface);
1560-extern HRESULT WINAPI IDirect3DStateBlock9Impl_Apply(LPDIRECT3DSTATEBLOCK9 iface);
1561-
1562+ IWineD3DStateBlock *wineD3DStateBlock;
1563+} IDirect3DStateBlock9Impl;
1564
1565 /* --------------------------- */
1566 /* IDirect3DVertexDeclaration9 */
1567@@ -994,24 +443,14 @@
1568 /*****************************************************************************
1569 * IDirect3DVertexShaderDeclaration implementation structure
1570 */
1571-struct IDirect3DVertexDeclaration9Impl {
1572+typedef struct IDirect3DVertexDeclaration9Impl {
1573 /* IUnknown fields */
1574 IDirect3DVertexDeclaration9Vtbl *lpVtbl;
1575 DWORD ref;
1576
1577 /* IDirect3DVertexDeclaration9 fields */
1578 IWineD3DVertexDeclaration *wineD3DVertexDeclaration;
1579-};
1580-
1581-/* IUnknown: */
1582-extern HRESULT WINAPI IDirect3DVertexDeclaration9Impl_QueryInterface(LPDIRECT3DVERTEXDECLARATION9 iface, REFIID refiid, LPVOID* obj);
1583-extern ULONG WINAPI IDirect3DVertexDeclaration9Impl_AddRef(LPDIRECT3DVERTEXDECLARATION9 iface);
1584-extern ULONG WINAPI IDirect3DVertexDeclaration9Impl_Release(LPDIRECT3DVERTEXDECLARATION9 iface);
1585-
1586-/* IDirect3DVertexDeclaration9: */
1587-extern HRESULT WINAPI IDirect3DVertexDeclaration9Impl_GetDevice(LPDIRECT3DVERTEXDECLARATION9 iface, IDirect3DDevice9** ppDevice);
1588-extern HRESULT WINAPI IDirect3DVertexDeclaration9Impl_GetDeclaration(LPDIRECT3DVERTEXDECLARATION9 iface, D3DVERTEXELEMENT9* pDecl, UINT* pNumElements);
1589-
1590+} IDirect3DVertexDeclaration9Impl;
1591
1592 /* ---------------------- */
1593 /* IDirect3DVertexShader9 */
1594@@ -1025,35 +464,14 @@
1595 /*****************************************************************************
1596 * IDirect3DVertexShader implementation structure
1597 */
1598-struct IDirect3DVertexShader9Impl {
1599+typedef struct IDirect3DVertexShader9Impl {
1600 /* IUnknown fields */
1601 IDirect3DVertexShader9Vtbl *lpVtbl;
1602 DWORD ref;
1603
1604- /* IDirect3DVertexDeclaration9 fields */
1605- IDirect3DDevice9Impl* Device;
1606-
1607- DWORD* function;
1608- UINT functionLength;
1609- DWORD usage; /* 0 || D3DUSAGE_SOFTWAREPROCESSING */
1610- DWORD version;
1611- /* run time datas */
1612- /*
1613- VSHADERDATA* data;
1614- VSHADERINPUTDATA input;
1615- VSHADEROUTPUTDATA output;
1616- */
1617-};
1618-
1619-/* IUnknown: */
1620-extern HRESULT WINAPI IDirect3DVertexShader9Impl_QueryInterface(LPDIRECT3DVERTEXSHADER9 iface, REFIID refiid, LPVOID* obj);
1621-extern ULONG WINAPI IDirect3DVertexShader9Impl_AddRef(LPDIRECT3DVERTEXSHADER9 iface);
1622-extern ULONG WINAPI IDirect3DVertexShader9Impl_Release(LPDIRECT3DVERTEXSHADER9 iface);
1623-
1624-/* IDirect3DVertexShader9: */
1625-extern HRESULT WINAPI IDirect3DVertexShader9Impl_GetDevice(LPDIRECT3DVERTEXSHADER9 iface, IDirect3DDevice9** ppDevice);
1626-extern HRESULT WINAPI IDirect3DVertexShader9Impl_GetFunction(LPDIRECT3DVERTEXSHADER9 iface, VOID* pData, UINT* pSizeOfData);
1627-
1628+ /* IDirect3DVertexShader9 fields */
1629+ IWineD3DVertexShader *wineD3DVertexShader;
1630+} IDirect3DVertexShader9Impl;
1631
1632 /* --------------------- */
1633 /* IDirect3DPixelShader9 */
1634@@ -1067,34 +485,14 @@
1635 /*****************************************************************************
1636 * IDirect3DPixelShader implementation structure
1637 */
1638-struct IDirect3DPixelShader9Impl {
1639+typedef struct IDirect3DPixelShader9Impl {
1640 /* IUnknown fields */
1641 IDirect3DPixelShader9Vtbl *lpVtbl;
1642 DWORD ref;
1643
1644 /* IDirect3DPixelShader9 fields */
1645- IDirect3DDevice9Impl* Device;
1646-
1647- DWORD* function;
1648- UINT functionLength;
1649- DWORD version;
1650- /* run time datas */
1651- /*
1652- PSHADERDATA* data;
1653- PSHADERINPUTDATA input;
1654- PSHADEROUTPUTDATA output;
1655- */
1656-};
1657-
1658-/* IUnknown: */
1659-extern HRESULT WINAPI IDirect3DPixelShader9Impl_QueryInterface(LPDIRECT3DPIXELSHADER9 iface, REFIID refiid, LPVOID* obj);
1660-extern ULONG WINAPI IDirect3DPixelShader9Impl_AddRef(LPDIRECT3DPIXELSHADER9 iface);
1661-extern ULONG WINAPI IDirect3DPixelShader9Impl_Release(LPDIRECT3DPIXELSHADER9 iface);
1662-
1663-/* IDirect3DPixelShader9: */
1664-extern HRESULT WINAPI IDirect3DPixelShader9Impl_GetDevice(LPDIRECT3DPIXELSHADER9 iface, IDirect3DDevice9** ppDevice);
1665-extern HRESULT WINAPI IDirect3DPixelShader9Impl_GetFunction(LPDIRECT3DPIXELSHADER9 iface, VOID* pData, UINT* pSizeOfData);
1666-
1667+ IWineD3DPixelShader *wineD3DPixelShader;
1668+} IDirect3DPixelShader9Impl;
1669
1670 /* --------------- */
1671 /* IDirect3DQuery9 */
1672@@ -1128,4 +526,15 @@
1673 IWineD3DVolume **ppVolume,
1674 HANDLE * pSharedHandle);
1675
1676+extern HRESULT WINAPI D3D9CB_CreateDepthStencilSurface(IUnknown *device, UINT Width, UINT Height,
1677+ D3DFORMAT Format, D3DMULTISAMPLE_TYPE MultiSample,
1678+ DWORD MultisampleQuality, BOOL Discard,
1679+ IWineD3DSurface** ppSurface, HANDLE* pSharedHandle);
1680+
1681+extern HRESULT WINAPI D3D9CB_CreateRenderTarget(IUnknown *device, UINT Width, UINT Height,
1682+ D3DFORMAT Format, D3DMULTISAMPLE_TYPE MultiSample,
1683+ DWORD MultisampleQuality, BOOL Lockable,
1684+ IWineD3DSurface** ppSurface, HANDLE* pSharedHandle);
1685+
1686+
1687 #endif /* __WINE_D3D9_PRIVATE_H */
1688diff -urN wine.20050419/dlls/d3d9/d3dcore_gl.h wine.20050419.dx9/dlls/d3d9/d3dcore_gl.h
1689--- wine.20050419/dlls/d3d9/d3dcore_gl.h 1969-12-31 17:00:00.000000000 -0700
1690+++ wine.20050419.dx9/dlls/d3d9/d3dcore_gl.h 2005-04-20 01:52:56.000000000 -0600
1691@@ -0,0 +1,878 @@
1692+/*
1693+ * Direct3D gl definitions
1694+ *
1695+ * Copyright 2003-2004 Raphael Junqueira
1696+ * Copyright 2004 Christian Costa
1697+ *
1698+ * This library is free software; you can redistribute it and/or
1699+ * modify it under the terms of the GNU Lesser General Public
1700+ * License as published by the Free Software Foundation; either
1701+ * version 2.1 of the License, or (at your option) any later version.
1702+ *
1703+ * This library is distributed in the hope that it will be useful,
1704+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
1705+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1706+ * Lesser General Public License for more details.
1707+ *
1708+ * You should have received a copy of the GNU Lesser General Public
1709+ * License along with this library; if not, write to the Free Software
1710+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
1711+ */
1712+
1713+#ifndef __WINE_D3DCORE_GL_H
1714+#define __WINE_D3DCORE_GL_H
1715+
1716+#ifndef __WINE_CONFIG_H
1717+# error You must include config.h to use this header
1718+#endif
1719+
1720+#define XMD_H /* This is to prevent the Xmd.h inclusion bug :-/ */
1721+#include <GL/gl.h>
1722+#include <GL/glx.h>
1723+#ifdef HAVE_GL_GLEXT_H
1724+# include <GL/glext.h>
1725+#endif
1726+#undef XMD_H
1727+
1728+#undef APIENTRY
1729+#define APIENTRY
1730+
1731+/**********************************
1732+ * OpenGL Extensions (EXT and ARB)
1733+ * defines and functions pointer
1734+ */
1735+
1736+/* GL_ARB_vertex_blend */
1737+#ifndef GL_ARB_vertex_blend
1738+#define GL_ARB_vertex_blend 1
1739+#define GL_MAX_VERTEX_UNITS_ARB 0x86A4
1740+#define GL_ACTIVE_VERTEX_UNITS_ARB 0x86A5
1741+#define GL_WEIGHT_SUM_UNITY_ARB 0x86A6
1742+#define GL_VERTEX_BLEND_ARB 0x86A7
1743+#define GL_CURRENT_WEIGHT_ARB 0x86A8
1744+#define GL_WEIGHT_ARRAY_TYPE_ARB 0x86A9
1745+#define GL_WEIGHT_ARRAY_STRIDE_ARB 0x86AA
1746+#define GL_WEIGHT_ARRAY_SIZE_ARB 0x86AB
1747+#define GL_WEIGHT_ARRAY_POINTER_ARB 0x86AC
1748+#define GL_WEIGHT_ARRAY_ARB 0x86AD
1749+#define GL_MODELVIEW0_ARB 0x1700
1750+#define GL_MODELVIEW1_ARB 0x850A
1751+#define GL_MODELVIEW2_ARB 0x8722
1752+#define GL_MODELVIEW3_ARB 0x8723
1753+#define GL_MODELVIEW4_ARB 0x8724
1754+#define GL_MODELVIEW5_ARB 0x8725
1755+#define GL_MODELVIEW6_ARB 0x8726
1756+#define GL_MODELVIEW7_ARB 0x8727
1757+#define GL_MODELVIEW8_ARB 0x8728
1758+#define GL_MODELVIEW9_ARB 0x8729
1759+#define GL_MODELVIEW10_ARB 0x872A
1760+#define GL_MODELVIEW11_ARB 0x872B
1761+#define GL_MODELVIEW12_ARB 0x872C
1762+#define GL_MODELVIEW13_ARB 0x872D
1763+#define GL_MODELVIEW14_ARB 0x872E
1764+#define GL_MODELVIEW15_ARB 0x872F
1765+#define GL_MODELVIEW16_ARB 0x8730
1766+#define GL_MODELVIEW17_ARB 0x8731
1767+#define GL_MODELVIEW18_ARB 0x8732
1768+#define GL_MODELVIEW19_ARB 0x8733
1769+#define GL_MODELVIEW20_ARB 0x8734
1770+#define GL_MODELVIEW21_ARB 0x8735
1771+#define GL_MODELVIEW22_ARB 0x8736
1772+#define GL_MODELVIEW23_ARB 0x8737
1773+#define GL_MODELVIEW24_ARB 0x8738
1774+#define GL_MODELVIEW25_ARB 0x8739
1775+#define GL_MODELVIEW26_ARB 0x873A
1776+#define GL_MODELVIEW27_ARB 0x873B
1777+#define GL_MODELVIEW28_ARB 0x873C
1778+#define GL_MODELVIEW29_ARB 0x873D
1779+#define GL_MODELVIEW30_ARB 0x873E
1780+#define GL_MODELVIEW31_ARB 0x873F
1781+#endif
1782+/* GL_EXT_secondary_color */
1783+#ifndef GL_EXT_secondary_color
1784+#define GL_EXT_secondary_color 1
1785+#define GL_COLOR_SUM_EXT 0x8458
1786+#define GL_CURRENT_SECONDARY_COLOR_EXT 0x8459
1787+#define GL_SECONDARY_COLOR_ARRAY_SIZE_EXT 0x845A
1788+#define GL_SECONDARY_COLOR_ARRAY_TYPE_EXT 0x845B
1789+#define GL_SECONDARY_COLOR_ARRAY_STRIDE_EXT 0x845C
1790+#define GL_SECONDARY_COLOR_ARRAY_POINTER_EXT 0x845D
1791+#define GL_SECONDARY_COLOR_ARRAY_EXT 0x845E
1792+#endif
1793+typedef void (APIENTRY * PGLFNGLSECONDARYCOLOR3FEXTPROC) (GLfloat red, GLfloat green, GLfloat blue);
1794+typedef void (APIENTRY * PGLFNGLSECONDARYCOLOR3FVEXTPROC) (const GLfloat *v);
1795+typedef void (APIENTRY * PGLFNGLSECONDARYCOLOR3UBEXTPROC) (GLubyte red, GLubyte green, GLubyte blue);
1796+typedef void (APIENTRY * PGLFNGLSECONDARYCOLORPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
1797+/* GL_EXT_paletted_texture */
1798+#ifndef GL_EXT_paletted_texture
1799+#define GL_EXT_paletted_texture 1
1800+#define GL_COLOR_INDEX1_EXT 0x80E2
1801+#define GL_COLOR_INDEX2_EXT 0x80E3
1802+#define GL_COLOR_INDEX4_EXT 0x80E4
1803+#define GL_COLOR_INDEX8_EXT 0x80E5
1804+#define GL_COLOR_INDEX12_EXT 0x80E6
1805+#define GL_COLOR_INDEX16_EXT 0x80E7
1806+#define GL_TEXTURE_INDEX_SIZE_EXT 0x80ED
1807+#endif
1808+typedef void (APIENTRY * PGLFNGLCOLORTABLEEXTPROC) (GLenum target, GLenum internalFormat, GLsizei width, GLenum format, GLenum type, const GLvoid *table);
1809+/* GL_EXT_point_parameters */
1810+#ifndef GL_EXT_point_parameters
1811+#define GL_EXT_point_parameters 1
1812+#define GL_POINT_SIZE_MIN_EXT 0x8126
1813+#define GL_POINT_SIZE_MAX_EXT 0x8127
1814+#define GL_POINT_FADE_THRESHOLD_SIZE_EXT 0x8128
1815+#define GL_DISTANCE_ATTENUATION_EXT 0x8129
1816+#endif
1817+typedef void (APIENTRY * PGLFNGLPOINTPARAMETERFEXTPROC) (GLenum pname, GLfloat param);
1818+typedef void (APIENTRY * PGLFNGLPOINTPARAMETERFVEXTPROC) (GLenum pname, const GLfloat *params);
1819+/* GL_EXT_texture_env_combine */
1820+#ifndef GL_EXT_texture_env_combine
1821+#define GL_EXT_texture_env_combine 1
1822+#define GL_COMBINE_EXT 0x8570
1823+#define GL_COMBINE_RGB_EXT 0x8571
1824+#define GL_COMBINE_ALPHA_EXT 0x8572
1825+#define GL_RGB_SCALE_EXT 0x8573
1826+#define GL_ADD_SIGNED_EXT 0x8574
1827+#define GL_INTERPOLATE_EXT 0x8575
1828+#define GL_SUBTRACT_EXT 0x84E7
1829+#define GL_CONSTANT_EXT 0x8576
1830+#define GL_PRIMARY_COLOR_EXT 0x8577
1831+#define GL_PREVIOUS_EXT 0x8578
1832+#define GL_SOURCE0_RGB_EXT 0x8580
1833+#define GL_SOURCE1_RGB_EXT 0x8581
1834+#define GL_SOURCE2_RGB_EXT 0x8582
1835+#define GL_SOURCE3_RGB_EXT 0x8583
1836+#define GL_SOURCE4_RGB_EXT 0x8584
1837+#define GL_SOURCE5_RGB_EXT 0x8585
1838+#define GL_SOURCE6_RGB_EXT 0x8586
1839+#define GL_SOURCE7_RGB_EXT 0x8587
1840+#define GL_SOURCE0_ALPHA_EXT 0x8588
1841+#define GL_SOURCE1_ALPHA_EXT 0x8589
1842+#define GL_SOURCE2_ALPHA_EXT 0x858A
1843+#define GL_SOURCE3_ALPHA_EXT 0x858B
1844+#define GL_SOURCE4_ALPHA_EXT 0x858C
1845+#define GL_SOURCE5_ALPHA_EXT 0x858D
1846+#define GL_SOURCE6_ALPHA_EXT 0x858E
1847+#define GL_SOURCE7_ALPHA_EXT 0x858F
1848+#define GL_OPERAND0_RGB_EXT 0x8590
1849+#define GL_OPERAND1_RGB_EXT 0x8591
1850+#define GL_OPERAND2_RGB_EXT 0x8592
1851+#define GL_OPERAND3_RGB_EXT 0x8593
1852+#define GL_OPERAND4_RGB_EXT 0x8594
1853+#define GL_OPERAND5_RGB_EXT 0x8595
1854+#define GL_OPERAND6_RGB_EXT 0x8596
1855+#define GL_OPERAND7_RGB_EXT 0x8597
1856+#define GL_OPERAND0_ALPHA_EXT 0x8598
1857+#define GL_OPERAND1_ALPHA_EXT 0x8599
1858+#define GL_OPERAND2_ALPHA_EXT 0x859A
1859+#define GL_OPERAND3_ALPHA_EXT 0x859B
1860+#define GL_OPERAND4_ALPHA_EXT 0x859C
1861+#define GL_OPERAND5_ALPHA_EXT 0x859D
1862+#define GL_OPERAND6_ALPHA_EXT 0x859E
1863+#define GL_OPERAND7_ALPHA_EXT 0x859F
1864+#endif
1865+/* GL_EXT_texture_env_dot3 */
1866+#ifndef GL_EXT_texture_env_dot3
1867+#define GL_EXT_texture_env_dot3 1
1868+#define GL_DOT3_RGB_EXT 0x8740
1869+#define GL_DOT3_RGBA_EXT 0x8741
1870+#endif
1871+/* GL_EXT_texture_lod_bias */
1872+#ifndef GL_EXT_texture_lod_bias
1873+#define GL_EXT_texture_lod_bias 1
1874+#define GL_MAX_TEXTURE_LOD_BIAS_EXT 0x84FD
1875+#define GL_TEXTURE_FILTER_CONTROL_EXT 0x8500
1876+#define GL_TEXTURE_LOD_BIAS_EXT 0x8501
1877+#endif
1878+/* GL_ARB_texture_border_clamp */
1879+#ifndef GL_ARB_texture_border_clamp
1880+#define GL_ARB_texture_border_clamp 1
1881+#define GL_CLAMP_TO_BORDER_ARB 0x812D
1882+#endif
1883+/* GL_ARB_texture_mirrored_repeat (full support GL1.4) */
1884+#ifndef GL_ARB_texture_mirrored_repeat
1885+#define GL_ARB_texture_mirrored_repeat 1
1886+#define GL_MIRRORED_REPEAT_ARB 0x8370
1887+#endif
1888+/* GL_ATI_texture_mirror_once */
1889+#ifndef GL_ATI_texture_mirror_once
1890+#define GL_ATI_texture_mirror_once 1
1891+#define GL_MIRROR_CLAMP_ATI 0x8742
1892+#define GL_MIRROR_CLAMP_TO_EDGE_ATI 0x8743
1893+#endif
1894+/* GL_ARB_texture_env_dot3 */
1895+#ifndef GL_ARB_texture_env_dot3
1896+#define GL_ARB_texture_env_dot3 1
1897+#define GL_DOT3_RGB_ARB 0x86AE
1898+#define GL_DOT3_RGBA_ARB 0x86AF
1899+#endif
1900+/* GL_EXT_texture_env_dot3 */
1901+#ifndef GL_EXT_texture_env_dot3
1902+#define GL_EXT_texture_env_dot3 1
1903+#define GL_DOT3_RGB_EXT 0x8740
1904+#define GL_DOT3_RGBA_EXT 0x8741
1905+#endif
1906+/* GL_ARB_vertex_program */
1907+#ifndef GL_ARB_vertex_program
1908+#define GL_ARB_vertex_program 1
1909+#define GL_VERTEX_PROGRAM_ARB 0x8620
1910+#define GL_VERTEX_PROGRAM_POINT_SIZE_ARB 0x8642
1911+#define GL_VERTEX_PROGRAM_TWO_SIDE_ARB 0x8643
1912+#define GL_COLOR_SUM_ARB 0x8458
1913+#define GL_PROGRAM_FORMAT_ASCII_ARB 0x8875
1914+#define GL_VERTEX_ATTRIB_ARRAY_ENABLED_ARB 0x8622
1915+#define GL_VERTEX_ATTRIB_ARRAY_SIZE_ARB 0x8623
1916+#define GL_VERTEX_ATTRIB_ARRAY_STRIDE_ARB 0x8624
1917+#define GL_VERTEX_ATTRIB_ARRAY_TYPE_ARB 0x8625
1918+#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED_ARB 0x886A
1919+#define GL_CURRENT_VERTEX_ATTRIB_ARB 0x8626
1920+#define GL_VERTEX_ATTRIB_ARRAY_POINTER_ARB 0x8645
1921+#define GL_PROGRAM_LENGTH_ARB 0x8627
1922+#define GL_PROGRAM_FORMAT_ARB 0x8876
1923+#define GL_PROGRAM_BINDING_ARB 0x8677
1924+#define GL_PROGRAM_INSTRUCTIONS_ARB 0x88A0
1925+#define GL_MAX_PROGRAM_INSTRUCTIONS_ARB 0x88A1
1926+#define GL_PROGRAM_NATIVE_INSTRUCTIONS_ARB 0x88A2
1927+#define GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB 0x88A3
1928+#define GL_PROGRAM_TEMPORARIES_ARB 0x88A4
1929+#define GL_MAX_PROGRAM_TEMPORARIES_ARB 0x88A5
1930+#define GL_PROGRAM_NATIVE_TEMPORARIES_ARB 0x88A6
1931+#define GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB 0x88A7
1932+#define GL_PROGRAM_PARAMETERS_ARB 0x88A8
1933+#define GL_MAX_PROGRAM_PARAMETERS_ARB 0x88A9
1934+#define GL_PROGRAM_NATIVE_PARAMETERS_ARB 0x88AA
1935+#define GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB 0x88AB
1936+#define GL_PROGRAM_ATTRIBS_ARB 0x88AC
1937+#define GL_MAX_PROGRAM_ATTRIBS_ARB 0x88AD
1938+#define GL_PROGRAM_NATIVE_ATTRIBS_ARB 0x88AE
1939+#define GL_MAX_PROGRAM_NATIVE_ATTRIBS_ARB 0x88AF
1940+#define GL_PROGRAM_ADDRESS_REGISTERS_ARB 0x88B0
1941+#define GL_MAX_PROGRAM_ADDRESS_REGISTERS_ARB 0x88B1
1942+#define GL_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB 0x88B2
1943+#define GL_MAX_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB 0x88B3
1944+#define GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB 0x88B4
1945+#define GL_MAX_PROGRAM_ENV_PARAMETERS_ARB 0x88B5
1946+#define GL_PROGRAM_UNDER_NATIVE_LIMITS_ARB 0x88B6
1947+#define GL_PROGRAM_STRING_ARB 0x8628
1948+#define GL_PROGRAM_ERROR_POSITION_ARB 0x864B
1949+#define GL_CURRENT_MATRIX_ARB 0x8641
1950+#define GL_TRANSPOSE_CURRENT_MATRIX_ARB 0x88B7
1951+#define GL_CURRENT_MATRIX_STACK_DEPTH_ARB 0x8640
1952+#define GL_MAX_VERTEX_ATTRIBS_ARB 0x8869
1953+#define GL_MAX_PROGRAM_MATRICES_ARB 0x862F
1954+#define GL_MAX_PROGRAM_MATRIX_STACK_DEPTH_ARB 0x862E
1955+#define GL_PROGRAM_ERROR_STRING_ARB 0x8874
1956+#define GL_MATRIX0_ARB 0x88C0
1957+#define GL_MATRIX1_ARB 0x88C1
1958+#define GL_MATRIX2_ARB 0x88C2
1959+#define GL_MATRIX3_ARB 0x88C3
1960+#define GL_MATRIX4_ARB 0x88C4
1961+#define GL_MATRIX5_ARB 0x88C5
1962+#define GL_MATRIX6_ARB 0x88C6
1963+#define GL_MATRIX7_ARB 0x88C7
1964+#define GL_MATRIX8_ARB 0x88C8
1965+#define GL_MATRIX9_ARB 0x88C9
1966+#define GL_MATRIX10_ARB 0x88CA
1967+#define GL_MATRIX11_ARB 0x88CB
1968+#define GL_MATRIX12_ARB 0x88CC
1969+#define GL_MATRIX13_ARB 0x88CD
1970+#define GL_MATRIX14_ARB 0x88CE
1971+#define GL_MATRIX15_ARB 0x88CF
1972+#define GL_MATRIX16_ARB 0x88D0
1973+#define GL_MATRIX17_ARB 0x88D1
1974+#define GL_MATRIX18_ARB 0x88D2
1975+#define GL_MATRIX19_ARB 0x88D3
1976+#define GL_MATRIX20_ARB 0x88D4
1977+#define GL_MATRIX21_ARB 0x88D5
1978+#define GL_MATRIX22_ARB 0x88D6
1979+#define GL_MATRIX23_ARB 0x88D7
1980+#define GL_MATRIX24_ARB 0x88D8
1981+#define GL_MATRIX25_ARB 0x88D9
1982+#define GL_MATRIX26_ARB 0x88DA
1983+#define GL_MATRIX27_ARB 0x88DB
1984+#define GL_MATRIX28_ARB 0x88DC
1985+#define GL_MATRIX29_ARB 0x88DD
1986+#define GL_MATRIX30_ARB 0x88DE
1987+#define GL_MATRIX31_ARB 0x88DF
1988+#endif
1989+typedef void (APIENTRY * PGLFNVERTEXATTRIB1DARBPROC) (GLuint index, GLdouble x);
1990+typedef void (APIENTRY * PGLFNVERTEXATTRIB1DVARBPROC) (GLuint index, const GLdouble *v);
1991+typedef void (APIENTRY * PGLFNVERTEXATTRIB1FARBPROC) (GLuint index, GLfloat x);
1992+typedef void (APIENTRY * PGLFNVERTEXATTRIB1FVARBPROC) (GLuint index, const GLfloat *v);
1993+typedef void (APIENTRY * PGLFNVERTEXATTRIB1SARBPROC) (GLuint index, GLshort x);
1994+typedef void (APIENTRY * PGLFNVERTEXATTRIB1SVARBPROC) (GLuint index, const GLshort *v);
1995+typedef void (APIENTRY * PGLFNVERTEXATTRIB2DARBPROC) (GLuint index, GLdouble x, GLdouble y);
1996+typedef void (APIENTRY * PGLFNVERTEXATTRIB2DVARBPROC) (GLuint index, const GLdouble *v);
1997+typedef void (APIENTRY * PGLFNVERTEXATTRIB2FARBPROC) (GLuint index, GLfloat x, GLfloat y);
1998+typedef void (APIENTRY * PGLFNVERTEXATTRIB2FVARBPROC) (GLuint index, const GLfloat *v);
1999+typedef void (APIENTRY * PGLFNVERTEXATTRIB2SARBPROC) (GLuint index, GLshort x, GLshort y);
2000+typedef void (APIENTRY * PGLFNVERTEXATTRIB2SVARBPROC) (GLuint index, const GLshort *v);
2001+typedef void (APIENTRY * PGLFNVERTEXATTRIB3DARBPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z);
2002+typedef void (APIENTRY * PGLFNVERTEXATTRIB3DVARBPROC) (GLuint index, const GLdouble *v);
2003+typedef void (APIENTRY * PGLFNVERTEXATTRIB3FARBPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z);
2004+typedef void (APIENTRY * PGLFNVERTEXATTRIB3FVARBPROC) (GLuint index, const GLfloat *v);
2005+typedef void (APIENTRY * PGLFNVERTEXATTRIB3SARBPROC) (GLuint index, GLshort x, GLshort y, GLshort z);
2006+typedef void (APIENTRY * PGLFNVERTEXATTRIB3SVARBPROC) (GLuint index, const GLshort *v);
2007+typedef void (APIENTRY * PGLFNVERTEXATTRIB4NBVARBPROC) (GLuint index, const GLbyte *v);
2008+typedef void (APIENTRY * PGLFNVERTEXATTRIB4NIVARBPROC) (GLuint index, const GLint *v);
2009+typedef void (APIENTRY * PGLFNVERTEXATTRIB4NSVARBPROC) (GLuint index, const GLshort *v);
2010+typedef void (APIENTRY * PGLFNVERTEXATTRIB4NUBARBPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w);
2011+typedef void (APIENTRY * PGLFNVERTEXATTRIB4NUBVARBPROC) (GLuint index, const GLubyte *v);
2012+typedef void (APIENTRY * PGLFNVERTEXATTRIB4NUIVARBPROC) (GLuint index, const GLuint *v);
2013+typedef void (APIENTRY * PGLFNVERTEXATTRIB4NUSVARBPROC) (GLuint index, const GLushort *v);
2014+typedef void (APIENTRY * PGLFNVERTEXATTRIB4BVARBPROC) (GLuint index, const GLbyte *v);
2015+typedef void (APIENTRY * PGLFNVERTEXATTRIB4DARBPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w);
2016+typedef void (APIENTRY * PGLFNVERTEXATTRIB4DVARBPROC) (GLuint index, const GLdouble *v);
2017+typedef void (APIENTRY * PGLFNVERTEXATTRIB4FARBPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
2018+typedef void (APIENTRY * PGLFNVERTEXATTRIB4FVARBPROC) (GLuint index, const GLfloat *v);
2019+typedef void (APIENTRY * PGLFNVERTEXATTRIB4IVARBPROC) (GLuint index, const GLint *v);
2020+typedef void (APIENTRY * PGLFNVERTEXATTRIB4SARBPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w);
2021+typedef void (APIENTRY * PGLFNVERTEXATTRIB4SVARBPROC) (GLuint index, const GLshort *v);
2022+typedef void (APIENTRY * PGLFNVERTEXATTRIB4UBVARBPROC) (GLuint index, const GLubyte *v);
2023+typedef void (APIENTRY * PGLFNVERTEXATTRIB4UIVARBPROC) (GLuint index, const GLuint *v);
2024+typedef void (APIENTRY * PGLFNVERTEXATTRIB4USVARBPROC) (GLuint index, const GLushort *v);
2025+typedef void (APIENTRY * PGLFNVERTEXATTRIBPOINTERARBPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer);
2026+typedef void (APIENTRY * PGLFNENABLEVERTEXATTRIBARRAYARBPROC) (GLuint index);
2027+typedef void (APIENTRY * PGLFNDISABLEVERTEXATTRIBARRAYARBPROC) (GLuint index);
2028+typedef void (APIENTRY * PGLFNPROGRAMSTRINGARBPROC) (GLenum target, GLenum format, GLsizei len, const GLvoid *string);
2029+typedef void (APIENTRY * PGLFNBINDPROGRAMARBPROC) (GLenum target, GLuint program);
2030+typedef void (APIENTRY * PGLFNDELETEPROGRAMSARBPROC) (GLsizei n, const GLuint *programs);
2031+typedef void (APIENTRY * PGLFNGENPROGRAMSARBPROC) (GLsizei n, GLuint *programs);
2032+typedef void (APIENTRY * PGLFNPROGRAMENVPARAMETER4DARBPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w);
2033+typedef void (APIENTRY * PGLFNPROGRAMENVPARAMETER4DVARBPROC) (GLenum target, GLuint index, const GLdouble *params);
2034+typedef void (APIENTRY * PGLFNPROGRAMENVPARAMETER4FARBPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
2035+typedef void (APIENTRY * PGLFNPROGRAMENVPARAMETER4FVARBPROC) (GLenum target, GLuint index, const GLfloat *params);
2036+typedef void (APIENTRY * PGLFNPROGRAMLOCALPARAMETER4DARBPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w);
2037+typedef void (APIENTRY * PGLFNPROGRAMLOCALPARAMETER4DVARBPROC) (GLenum target, GLuint index, const GLdouble *params);
2038+typedef void (APIENTRY * PGLFNPROGRAMLOCALPARAMETER4FARBPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
2039+typedef void (APIENTRY * PGLFNPROGRAMLOCALPARAMETER4FVARBPROC) (GLenum target, GLuint index, const GLfloat *params);
2040+typedef void (APIENTRY * PGLFNGETPROGRAMENVPARAMETERDVARBPROC) (GLenum target, GLuint index, GLdouble *params);
2041+typedef void (APIENTRY * PGLFNGETPROGRAMENVPARAMETERFVARBPROC) (GLenum target, GLuint index, GLfloat *params);
2042+typedef void (APIENTRY * PGLFNGETPROGRAMLOCALPARAMETERDVARBPROC) (GLenum target, GLuint index, GLdouble *params);
2043+typedef void (APIENTRY * PGLFNGETPROGRAMLOCALPARAMETERFVARBPROC) (GLenum target, GLuint index, GLfloat *params);
2044+typedef void (APIENTRY * PGLFNGETPROGRAMIVARBPROC) (GLenum target, GLenum pname, GLint *params);
2045+typedef void (APIENTRY * PGLFNGETPROGRAMSTRINGARBPROC) (GLenum target, GLenum pname, GLvoid *string);
2046+typedef void (APIENTRY * PGLFNGETVERTEXATTRIBDVARBPROC) (GLuint index, GLenum pname, GLdouble *params);
2047+typedef void (APIENTRY * PGLFNGETVERTEXATTRIBFVARBPROC) (GLuint index, GLenum pname, GLfloat *params);
2048+typedef void (APIENTRY * PGLFNGETVERTEXATTRIBIVARBPROC) (GLuint index, GLenum pname, GLint *params);
2049+typedef void (APIENTRY * PGLFNGETVERTEXATTRIBPOINTERVARBPROC) (GLuint index, GLenum pname, GLvoid* *pointer);
2050+typedef GLboolean (APIENTRY * PGLFNISPROGRAMARBPROC) (GLuint program);
2051+#ifndef GL_ARB_fragment_program
2052+#define GL_ARB_fragment_program 1
2053+#define GL_FRAGMENT_PROGRAM_ARB 0x8804
2054+#define GL_PROGRAM_ALU_INSTRUCTIONS_ARB 0x8805
2055+#define GL_PROGRAM_TEX_INSTRUCTIONS_ARB 0x8806
2056+#define GL_PROGRAM_TEX_INDIRECTIONS_ARB 0x8807
2057+#define GL_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB 0x8808
2058+#define GL_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB 0x8809
2059+#define GL_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB 0x880A
2060+#define GL_MAX_PROGRAM_ALU_INSTRUCTIONS_ARB 0x880B
2061+#define GL_MAX_PROGRAM_TEX_INSTRUCTIONS_ARB 0x880C
2062+#define GL_MAX_PROGRAM_TEX_INDIRECTIONS_ARB 0x880D
2063+#define GL_MAX_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB 0x880E
2064+#define GL_MAX_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB 0x880F
2065+#define GL_MAX_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB 0x8810
2066+#define GL_MAX_TEXTURE_COORDS_ARB 0x8871
2067+#define GL_MAX_TEXTURE_IMAGE_UNITS_ARB 0x8872
2068+/* All ARB_fragment_program entry points are shared with ARB_vertex_program. */
2069+#endif
2070+/* GL_EXT_texture_compression_s3tc */
2071+#ifndef GL_EXT_texture_compression_s3tc
2072+#define GL_EXT_texture_compression_s3tc 1
2073+#define GL_COMPRESSED_RGB_S3TC_DXT1_EXT 0x83F0
2074+#define GL_COMPRESSED_RGBA_S3TC_DXT1_EXT 0x83F1
2075+#define GL_COMPRESSED_RGBA_S3TC_DXT3_EXT 0x83F2
2076+#define GL_COMPRESSED_RGBA_S3TC_DXT5_EXT 0x83F3
2077+#endif
2078+typedef void (APIENTRY * PGLFNCOMPRESSEDTEXIMAGE3DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data);
2079+typedef void (APIENTRY * PGLFNCOMPRESSEDTEXIMAGE2DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data);
2080+typedef void (APIENTRY * PGLFNCOMPRESSEDTEXIMAGE1DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data);
2081+typedef void (APIENTRY * PGLFNCOMPRESSEDTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data);
2082+typedef void (APIENTRY * PGLFNCOMPRESSEDTEXSUBIMAGE2DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data);
2083+typedef void (APIENTRY * PGLFNCOMPRESSEDTEXSUBIMAGE1DPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data);
2084+typedef void (APIENTRY * PGLFNGETCOMPRESSEDTEXIMAGEPROC) (GLenum target, GLint level, void *img);
2085+/* GL_EXT_stencil_wrap */
2086+#ifndef GL_EXT_stencil_wrap
2087+#define GL_EXT_stencil_wrap 1
2088+#define GL_INCR_WRAP_EXT 0x8507
2089+#define GL_DECR_WRAP_EXT 0x8508
2090+#endif
2091+/* GL_NV_fog_distance */
2092+#ifndef GL_NV_fog_distance
2093+#define GL_NV_fog_distance 1
2094+#define GL_FOG_DISTANCE_MODE_NV 0x855A
2095+#define GL_EYE_RADIAL_NV 0x855B
2096+#define GL_EYE_PLANE_ABSOLUTE_NV 0x855C
2097+/* reuse GL_EYE_PLANE */
2098+#endif
2099+/* GL_NV_texgen_reflection */
2100+#ifndef GL_NV_texgen_reflection
2101+#define GL_NV_texgen_reflection 1
2102+#define GL_NORMAL_MAP_NV 0x8511
2103+#define GL_REFLECTION_MAP_NV 0x8512
2104+#endif
2105+/* GL_NV_register_combiners */
2106+#ifndef GL_NV_register_combiners
2107+#define GL_NV_register_combiners 1
2108+#define GL_REGISTER_COMBINERS_NV 0x8522
2109+#define GL_VARIABLE_A_NV 0x8523
2110+#define GL_VARIABLE_B_NV 0x8524
2111+#define GL_VARIABLE_C_NV 0x8525
2112+#define GL_VARIABLE_D_NV 0x8526
2113+#define GL_VARIABLE_E_NV 0x8527
2114+#define GL_VARIABLE_F_NV 0x8528
2115+#define GL_VARIABLE_G_NV 0x8529
2116+#define GL_CONSTANT_COLOR0_NV 0x852A
2117+#define GL_CONSTANT_COLOR1_NV 0x852B
2118+#define GL_PRIMARY_COLOR_NV 0x852C
2119+#define GL_SECONDARY_COLOR_NV 0x852D
2120+#define GL_SPARE0_NV 0x852E
2121+#define GL_SPARE1_NV 0x852F
2122+#define GL_DISCARD_NV 0x8530
2123+#define GL_E_TIMES_F_NV 0x8531
2124+#define GL_SPARE0_PLUS_SECONDARY_COLOR_NV 0x8532
2125+#define GL_UNSIGNED_IDENTITY_NV 0x8536
2126+#define GL_UNSIGNED_INVERT_NV 0x8537
2127+#define GL_EXPAND_NORMAL_NV 0x8538
2128+#define GL_EXPAND_NEGATE_NV 0x8539
2129+#define GL_HALF_BIAS_NORMAL_NV 0x853A
2130+#define GL_HALF_BIAS_NEGATE_NV 0x853B
2131+#define GL_SIGNED_IDENTITY_NV 0x853C
2132+#define GL_SIGNED_NEGATE_NV 0x853D
2133+#define GL_SCALE_BY_TWO_NV 0x853E
2134+#define GL_SCALE_BY_FOUR_NV 0x853F
2135+#define GL_SCALE_BY_ONE_HALF_NV 0x8540
2136+#define GL_BIAS_BY_NEGATIVE_ONE_HALF_NV 0x8541
2137+#define GL_COMBINER_INPUT_NV 0x8542
2138+#define GL_COMBINER_MAPPING_NV 0x8543
2139+#define GL_COMBINER_COMPONENT_USAGE_NV 0x8544
2140+#define GL_COMBINER_AB_DOT_PRODUCT_NV 0x8545
2141+#define GL_COMBINER_CD_DOT_PRODUCT_NV 0x8546
2142+#define GL_COMBINER_MUX_SUM_NV 0x8547
2143+#define GL_COMBINER_SCALE_NV 0x8548
2144+#define GL_COMBINER_BIAS_NV 0x8549
2145+#define GL_COMBINER_AB_OUTPUT_NV 0x854A
2146+#define GL_COMBINER_CD_OUTPUT_NV 0x854B
2147+#define GL_COMBINER_SUM_OUTPUT_NV 0x854C
2148+#define GL_MAX_GENERAL_COMBINERS_NV 0x854D
2149+#define GL_NUM_GENERAL_COMBINERS_NV 0x854E
2150+#define GL_COLOR_SUM_CLAMP_NV 0x854F
2151+#define GL_COMBINER0_NV 0x8550
2152+#define GL_COMBINER1_NV 0x8551
2153+#define GL_COMBINER2_NV 0x8552
2154+#define GL_COMBINER3_NV 0x8553
2155+#define GL_COMBINER4_NV 0x8554
2156+#define GL_COMBINER5_NV 0x8555
2157+#define GL_COMBINER6_NV 0x8556
2158+#define GL_COMBINER7_NV 0x8557
2159+/* reuse GL_TEXTURE0_ARB */
2160+/* reuse GL_TEXTURE1_ARB */
2161+/* reuse GL_ZERO */
2162+/* reuse GL_NONE */
2163+/* reuse GL_FOG */
2164+#endif
2165+typedef void (APIENTRY * PGLFNCOMBINERPARAMETERFVNVPROC) (GLenum pname, const GLfloat *params);
2166+typedef void (APIENTRY * PGLFNCOMBINERPARAMETERFNVPROC) (GLenum pname, GLfloat param);
2167+typedef void (APIENTRY * PGLFNCOMBINERPARAMETERIVNVPROC) (GLenum pname, const GLint *params);
2168+typedef void (APIENTRY * PGLFNCOMBINERPARAMETERINVPROC) (GLenum pname, GLint param);
2169+typedef void (APIENTRY * PGLFNCOMBINERINPUTNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage);
2170+typedef void (APIENTRY * PGLFNCOMBINEROUTPUTNVPROC) (GLenum stage, GLenum portion, GLenum abOutput, GLenum cdOutput, GLenum sumOutput, GLenum scale, GLenum bias, GLboolean abDotProduct, GLboolean cdDotProduct, GLboolean muxSum);
2171+typedef void (APIENTRY * PGLFNFINALCOMBINERINPUTNVPROC) (GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage);
2172+typedef void (APIENTRY * PGLFNGETCOMBINERINPUTPARAMETERFVNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLfloat *params);
2173+typedef void (APIENTRY * PGLFNGETCOMBINERINPUTPARAMETERIVNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLint *params);
2174+typedef void (APIENTRY * PGLFNGETCOMBINEROUTPUTPARAMETERFVNVPROC) (GLenum stage, GLenum portion, GLenum pname, GLfloat *params);
2175+typedef void (APIENTRY * PGLFNGETCOMBINEROUTPUTPARAMETERIVNVPROC) (GLenum stage, GLenum portion, GLenum pname, GLint *params);
2176+typedef void (APIENTRY * PGLFNGETFINALCOMBINERINPUTPARAMETERFVNVPROC) (GLenum variable, GLenum pname, GLfloat *params);
2177+typedef void (APIENTRY * PGLFNGETFINALCOMBINERINPUTPARAMETERIVNVPROC) (GLenum variable, GLenum pname, GLint *params);
2178+/* GL_NV_register_combiners2 */
2179+#ifndef GL_NV_register_combiners2
2180+#define GL_NV_register_combiners2 1
2181+#define GL_PER_STAGE_CONSTANTS_NV 0x8535
2182+#endif
2183+typedef void (APIENTRY * PGLFNCOMBINERSTAGEPARAMETERFVNVPROC) (GLenum stage, GLenum pname, const GLfloat *params);
2184+typedef void (APIENTRY * PGLFNGETCOMBINERSTAGEPARAMETERFVNVPROC) (GLenum stage, GLenum pname, GLfloat *params);
2185+/* GL_NV_texture_shader */
2186+#ifndef GL_NV_texture_shader
2187+#define GL_NV_texture_shader 1
2188+#define GL_OFFSET_TEXTURE_RECTANGLE_NV 0x864C
2189+#define GL_OFFSET_TEXTURE_RECTANGLE_SCALE_NV 0x864D
2190+#define GL_DOT_PRODUCT_TEXTURE_RECTANGLE_NV 0x864E
2191+#define GL_RGBA_UNSIGNED_DOT_PRODUCT_MAPPING_NV 0x86D9
2192+#define GL_UNSIGNED_INT_S8_S8_8_8_NV 0x86DA
2193+#define GL_UNSIGNED_INT_8_8_S8_S8_REV_NV 0x86DB
2194+#define GL_DSDT_MAG_INTENSITY_NV 0x86DC
2195+#define GL_SHADER_CONSISTENT_NV 0x86DD
2196+#define GL_TEXTURE_SHADER_NV 0x86DE
2197+#define GL_SHADER_OPERATION_NV 0x86DF
2198+#define GL_CULL_MODES_NV 0x86E0
2199+#define GL_OFFSET_TEXTURE_MATRIX_NV 0x86E1
2200+#define GL_OFFSET_TEXTURE_SCALE_NV 0x86E2
2201+#define GL_OFFSET_TEXTURE_BIAS_NV 0x86E3
2202+#define GL_OFFSET_TEXTURE_2D_MATRIX_NV GL_OFFSET_TEXTURE_MATRIX_NV
2203+#define GL_OFFSET_TEXTURE_2D_SCALE_NV GL_OFFSET_TEXTURE_SCALE_NV
2204+#define GL_OFFSET_TEXTURE_2D_BIAS_NV GL_OFFSET_TEXTURE_BIAS_NV
2205+#define GL_PREVIOUS_TEXTURE_INPUT_NV 0x86E4
2206+#define GL_CONST_EYE_NV 0x86E5
2207+#define GL_PASS_THROUGH_NV 0x86E6
2208+#define GL_CULL_FRAGMENT_NV 0x86E7
2209+#define GL_OFFSET_TEXTURE_2D_NV 0x86E8
2210+#define GL_DEPENDENT_AR_TEXTURE_2D_NV 0x86E9
2211+#define GL_DEPENDENT_GB_TEXTURE_2D_NV 0x86EA
2212+#define GL_DOT_PRODUCT_NV 0x86EC
2213+#define GL_DOT_PRODUCT_DEPTH_REPLACE_NV 0x86ED
2214+#define GL_DOT_PRODUCT_TEXTURE_2D_NV 0x86EE
2215+#define GL_DOT_PRODUCT_TEXTURE_CUBE_MAP_NV 0x86F0
2216+#define GL_DOT_PRODUCT_DIFFUSE_CUBE_MAP_NV 0x86F1
2217+#define GL_DOT_PRODUCT_REFLECT_CUBE_MAP_NV 0x86F2
2218+#define GL_DOT_PRODUCT_CONST_EYE_REFLECT_CUBE_MAP_NV 0x86F3
2219+#define GL_HILO_NV 0x86F4
2220+#define GL_DSDT_NV 0x86F5
2221+#define GL_DSDT_MAG_NV 0x86F6
2222+#define GL_DSDT_MAG_VIB_NV 0x86F7
2223+#define GL_HILO16_NV 0x86F8
2224+#define GL_SIGNED_HILO_NV 0x86F9
2225+#define GL_SIGNED_HILO16_NV 0x86FA
2226+#define GL_SIGNED_RGBA_NV 0x86FB
2227+#define GL_SIGNED_RGBA8_NV 0x86FC
2228+#define GL_SIGNED_RGB_NV 0x86FE
2229+#define GL_SIGNED_RGB8_NV 0x86FF
2230+#define GL_SIGNED_LUMINANCE_NV 0x8701
2231+#define GL_SIGNED_LUMINANCE8_NV 0x8702
2232+#define GL_SIGNED_LUMINANCE_ALPHA_NV 0x8703
2233+#define GL_SIGNED_LUMINANCE8_ALPHA8_NV 0x8704
2234+#define GL_SIGNED_ALPHA_NV 0x8705
2235+#define GL_SIGNED_ALPHA8_NV 0x8706
2236+#define GL_SIGNED_INTENSITY_NV 0x8707
2237+#define GL_SIGNED_INTENSITY8_NV 0x8708
2238+#define GL_DSDT8_NV 0x8709
2239+#define GL_DSDT8_MAG8_NV 0x870A
2240+#define GL_DSDT8_MAG8_INTENSITY8_NV 0x870B
2241+#define GL_SIGNED_RGB_UNSIGNED_ALPHA_NV 0x870C
2242+#define GL_SIGNED_RGB8_UNSIGNED_ALPHA8_NV 0x870D
2243+#define GL_HI_SCALE_NV 0x870E
2244+#define GL_LO_SCALE_NV 0x870F
2245+#define GL_DS_SCALE_NV 0x8710
2246+#define GL_DT_SCALE_NV 0x8711
2247+#define GL_MAGNITUDE_SCALE_NV 0x8712
2248+#define GL_VIBRANCE_SCALE_NV 0x8713
2249+#define GL_HI_BIAS_NV 0x8714
2250+#define GL_LO_BIAS_NV 0x8715
2251+#define GL_DS_BIAS_NV 0x8716
2252+#define GL_DT_BIAS_NV 0x8717
2253+#define GL_MAGNITUDE_BIAS_NV 0x8718
2254+#define GL_VIBRANCE_BIAS_NV 0x8719
2255+#define GL_TEXTURE_BORDER_VALUES_NV 0x871A
2256+#define GL_TEXTURE_HI_SIZE_NV 0x871B
2257+#define GL_TEXTURE_LO_SIZE_NV 0x871C
2258+#define GL_TEXTURE_DS_SIZE_NV 0x871D
2259+#define GL_TEXTURE_DT_SIZE_NV 0x871E
2260+#define GL_TEXTURE_MAG_SIZE_NV 0x871F
2261+#endif
2262+/* GL_NV_texture_shader2 */
2263+#ifndef GL_NV_texture_shader2
2264+#define GL_NV_texture_shader2 1
2265+#define GL_DOT_PRODUCT_TEXTURE_3D_NV 0x86EF
2266+#endif
2267+/* GL_NV_texture_shader3 */
2268+#ifndef GL_NV_texture_shader3
2269+#define GL_NV_texture_shader3 1
2270+#define GL_OFFSET_PROJECTIVE_TEXTURE_2D_NV 0x8850
2271+#define GL_OFFSET_PROJECTIVE_TEXTURE_2D_SCALE_NV 0x8851
2272+#define GL_OFFSET_PROJECTIVE_TEXTURE_RECTANGLE_NV 0x8852
2273+#define GL_OFFSET_PROJECTIVE_TEXTURE_RECTANGLE_SCALE_NV 0x8853
2274+#define GL_OFFSET_HILO_TEXTURE_2D_NV 0x8854
2275+#define GL_OFFSET_HILO_TEXTURE_RECTANGLE_NV 0x8855
2276+#define GL_OFFSET_HILO_PROJECTIVE_TEXTURE_2D_NV 0x8856
2277+#define GL_OFFSET_HILO_PROJECTIVE_TEXTURE_RECTANGLE_NV 0x8857
2278+#define GL_DEPENDENT_HILO_TEXTURE_2D_NV 0x8858
2279+#define GL_DEPENDENT_RGB_TEXTURE_3D_NV 0x8859
2280+#define GL_DEPENDENT_RGB_TEXTURE_CUBE_MAP_NV 0x885A
2281+#define GL_DOT_PRODUCT_PASS_THROUGH_NV 0x885B
2282+#define GL_DOT_PRODUCT_TEXTURE_1D_NV 0x885C
2283+#define GL_DOT_PRODUCT_AFFINE_DEPTH_REPLACE_NV 0x885D
2284+#define GL_HILO8_NV 0x885E
2285+#define GL_SIGNED_HILO8_NV 0x885F
2286+#define GL_FORCE_BLUE_TO_ONE_NV 0x8860
2287+#endif
2288+/* GL_ATI_texture_env_combine3 */
2289+#ifndef GL_ATI_texture_env_combine3
2290+#define GL_ATI_texture_env_combine3 1
2291+#define GL_MODULATE_ADD_ATI 0x8744
2292+#define GL_MODULATE_SIGNED_ADD_ATI 0x8745
2293+#define GL_MODULATE_SUBTRACT_ATI 0x8746
2294+/* #define ONE */
2295+/* #define ZERO */
2296+#endif
2297+
2298+/*******
2299+ * OpenGL Official Version
2300+ * defines
2301+ */
2302+
2303+/* GL_VERSION_1_3 */
2304+#if !defined(GL_DOT3_RGBA)
2305+# define GL_DOT3_RGBA 0x8741
2306+#endif
2307+#if !defined(GL_SUBTRACT)
2308+# define GL_SUBTRACT 0x84E7
2309+#endif
2310+
2311+
2312+/*********************************
2313+ * OpenGL GLX Extensions
2314+ * defines and functions pointer
2315+ */
2316+
2317+
2318+
2319+/*********************************
2320+ * OpenGL GLX Official Version
2321+ * defines and functions pointer
2322+ */
2323+
2324+/* GLX_VERSION_1_3 */
2325+typedef GLXFBConfig * (APIENTRY * PGLXFNGLXGETFBCONFIGSPROC) (Display *dpy, int screen, int *nelements);
2326+typedef GLXFBConfig * (APIENTRY * PGLXFNGLXCHOOSEFBCONFIGPROC) (Display *dpy, int screen, const int *attrib_list, int *nelements);
2327+typedef int (APIENTRY * PGLXFNGLXGETFBCONFIGATTRIBPROC) (Display *dpy, GLXFBConfig config, int attribute, int *value);
2328+typedef XVisualInfo * (APIENTRY * PGLXFNGLXGETVISUALFROMFBCONFIGPROC) (Display *dpy, GLXFBConfig config);
2329+typedef GLXWindow (APIENTRY * PGLXFNGLXCREATEWINDOWPROC) (Display *dpy, GLXFBConfig config, Window win, const int *attrib_list);
2330+typedef void (APIENTRY * PGLXFNGLXDESTROYWINDOWPROC) (Display *dpy, GLXWindow win);
2331+typedef GLXPixmap (APIENTRY * PGLXFNGLXCREATEPIXMAPPROC) (Display *dpy, GLXFBConfig config, Pixmap pixmap, const int *attrib_list);
2332+typedef void (APIENTRY * PGLXFNGLXDESTROYPIXMAPPROC) (Display *dpy, GLXPixmap pixmap);
2333+typedef GLXPbuffer (APIENTRY * PGLXFNGLXCREATEPBUFFERPROC) (Display *dpy, GLXFBConfig config, const int *attrib_list);
2334+typedef void (APIENTRY * PGLXFNGLXDESTROYPBUFFERPROC) (Display *dpy, GLXPbuffer pbuf);
2335+typedef void (APIENTRY * PGLXFNGLXQUERYDRAWABLEPROC) (Display *dpy, GLXDrawable draw, int attribute, unsigned int *value);
2336+typedef GLXContext (APIENTRY * PGLXFNGLXCREATENEWCONTEXTPROC) (Display *dpy, GLXFBConfig config, int render_type, GLXContext share_list, Bool direct);
2337+typedef Bool (APIENTRY * PGLXFNGLXMAKECONTEXTCURRENTPROC) (Display *dpy, GLXDrawable draw, GLXDrawable read, GLXContext ctx);
2338+typedef GLXDrawable (APIENTRY * PGLXFNGLXGETCURRENTREADDRAWABLEPROC) (void);
2339+typedef Display * (APIENTRY * PGLXFNGLXGETCURRENTDISPLAYPROC) (void);
2340+typedef int (APIENTRY * PGLXFNGLXQUERYCONTEXTPROC) (Display *dpy, GLXContext ctx, int attribute, int *value);
2341+typedef void (APIENTRY * PGLXFNGLXSELECTEVENTPROC) (Display *dpy, GLXDrawable draw, unsigned long event_mask);
2342+typedef void (APIENTRY * PGLXFNGLXGETSELECTEDEVENTPROC) (Display *dpy, GLXDrawable draw, unsigned long *event_mask);
2343+
2344+
2345+/********************************************
2346+ * OpenGL Supported Extensions (ARB and EXT)
2347+ */
2348+
2349+typedef enum _GL_SupportedExt {
2350+ /* ARB */
2351+ ARB_FRAGMENT_PROGRAM,
2352+ ARB_MULTISAMPLE,
2353+ ARB_MULTITEXTURE,
2354+ ARB_POINT_PARAMETERS,
2355+ ARB_TEXTURE_COMPRESSION,
2356+ ARB_TEXTURE_CUBE_MAP,
2357+ ARB_TEXTURE_ENV_ADD,
2358+ ARB_TEXTURE_ENV_COMBINE,
2359+ ARB_TEXTURE_ENV_DOT3,
2360+ ARB_TEXTURE_BORDER_CLAMP,
2361+ ARB_TEXTURE_MIRRORED_REPEAT,
2362+ ARB_VERTEX_PROGRAM,
2363+ ARB_VERTEX_BLEND,
2364+ /* EXT */
2365+ EXT_FOG_COORD,
2366+ EXT_PALETTED_TEXTURE,
2367+ EXT_POINT_PARAMETERS,
2368+ EXT_SECONDARY_COLOR,
2369+ EXT_STENCIL_WRAP,
2370+ EXT_TEXTURE_COMPRESSION_S3TC,
2371+ EXT_TEXTURE_FILTER_ANISOTROPIC,
2372+ EXT_TEXTURE_LOD,
2373+ EXT_TEXTURE_LOD_BIAS,
2374+ EXT_TEXTURE_ENV_ADD,
2375+ EXT_TEXTURE_ENV_COMBINE,
2376+ EXT_TEXTURE_ENV_DOT3,
2377+ EXT_VERTEX_WEIGHTING,
2378+ /* NVIDIA */
2379+ NV_FOG_DISTANCE,
2380+ NV_FRAGMENT_PROGRAM,
2381+ NV_REGISTER_COMBINERS,
2382+ NV_REGISTER_COMBINERS2,
2383+ NV_TEXGEN_REFLECTION,
2384+ NV_TEXTURE_ENV_COMBINE4,
2385+ NV_TEXTURE_SHADER,
2386+ NV_TEXTURE_SHADER2,
2387+ NV_TEXTURE_SHADER3,
2388+ NV_VERTEX_PROGRAM,
2389+ /* ATI */
2390+ ATI_TEXTURE_ENV_COMBINE3,
2391+ ATI_TEXTURE_MIRROR_ONCE,
2392+ EXT_VERTEX_SHADER,
2393+
2394+ OPENGL_SUPPORTED_EXT_END
2395+} GL_SupportedExt;
2396+
2397+typedef enum _GL_Vendors {
2398+ VENDOR_WINE = 0x0,
2399+ VENDOR_MESA = 0x1,
2400+ VENDOR_ATI = 0x1002,
2401+ VENDOR_NVIDIA = 0x10de
2402+} GL_Vendors;
2403+
2404+typedef enum _GL_Cards {
2405+ CARD_WINE = 0x0,
2406+ CARD_ATI_RADEON_8500 = 0x514c,
2407+ CARD_ATI_RADEON_9700PRO = 0x4e44,
2408+ CARD_ATI_RADEON_9800PRO = 0x4e48,
2409+ CARD_NVIDIA_GEFORCE4_TI4600 = 0x0250,
2410+ CARD_NVIDIA_GEFORCEFX_5900ULTRA = 0x0330
2411+} GL_Cards;
2412+
2413+typedef enum _GL_VSVersion {
2414+ VS_VERSION_NOT_SUPPORTED = 0x0,
2415+ VS_VERSION_10 = 0x10,
2416+ VS_VERSION_11 = 0x11,
2417+ VS_VERSION_20 = 0x20,
2418+ VS_VERSION_30 = 0x30,
2419+ /*Force 32-bits*/
2420+ VS_VERSION_FORCE_DWORD = 0x7FFFFFFF
2421+} GL_VSVersion;
2422+
2423+typedef enum _GL_PSVersion {
2424+ PS_VERSION_NOT_SUPPORTED = 0x0,
2425+ PS_VERSION_10 = 0x10,
2426+ PS_VERSION_11 = 0x11,
2427+ PS_VERSION_12 = 0x12,
2428+ PS_VERSION_13 = 0x13,
2429+ PS_VERSION_14 = 0x14,
2430+ PS_VERSION_20 = 0x20,
2431+ PS_VERSION_30 = 0x30,
2432+ /*Force 32-bits*/
2433+ PS_VERSION_FORCE_DWORD = 0x7FFFFFFF
2434+} GL_PSVersion;
2435+
2436+#define MAKEDWORD_VERSION(maj, min) ((maj & 0x0000FFFF) << 16) | (min & 0x0000FFFF)
2437+
2438+#define GL_EXT_FUNCS_GEN \
2439+ /** ARB Extensions **/ \
2440+ /* GL_ARB_texture_compression */ \
2441+ USE_GL_FUNC(PGLFNCOMPRESSEDTEXIMAGE2DPROC, glCompressedTexImage2DARB); \
2442+ USE_GL_FUNC(PGLFNCOMPRESSEDTEXIMAGE3DPROC, glCompressedTexImage3DARB); \
2443+ USE_GL_FUNC(PGLFNCOMPRESSEDTEXSUBIMAGE2DPROC, glCompressedTexSubImage2DARB); \
2444+ USE_GL_FUNC(PGLFNCOMPRESSEDTEXSUBIMAGE3DPROC, glCompressedTexSubImage3DARB); \
2445+ /** EXT Extensions **/ \
2446+ /* GL_EXT_fog_coord */ \
2447+ /* GL_EXT_paletted_texture */ \
2448+ USE_GL_FUNC(PGLFNGLCOLORTABLEEXTPROC, glColorTableEXT); \
2449+ /* GL_EXT_point_parameters */ \
2450+ USE_GL_FUNC(PGLFNGLPOINTPARAMETERFEXTPROC, glPointParameterfEXT); \
2451+ USE_GL_FUNC(PGLFNGLPOINTPARAMETERFVEXTPROC, glPointParameterfvEXT); \
2452+ /* GL_EXT_secondary_color */ \
2453+ USE_GL_FUNC(PGLFNGLSECONDARYCOLOR3UBEXTPROC, glSecondaryColor3ubEXT); \
2454+ USE_GL_FUNC(PGLFNGLSECONDARYCOLOR3FEXTPROC, glSecondaryColor3fEXT); \
2455+ USE_GL_FUNC(PGLFNGLSECONDARYCOLOR3FVEXTPROC, glSecondaryColor3fvEXT); \
2456+ USE_GL_FUNC(PGLFNGLSECONDARYCOLORPOINTEREXTPROC, glSecondaryColorPointerEXT); \
2457+ /* GL_EXT_secondary_color */ \
2458+ USE_GL_FUNC(PGLFNGENPROGRAMSARBPROC, glGenProgramsARB); \
2459+ USE_GL_FUNC(PGLFNBINDPROGRAMARBPROC, glBindProgramARB); \
2460+ USE_GL_FUNC(PGLFNPROGRAMSTRINGARBPROC, glProgramStringARB); \
2461+ USE_GL_FUNC(PGLFNDELETEPROGRAMSARBPROC, glDeleteProgramsARB); \
2462+ USE_GL_FUNC(PGLFNPROGRAMENVPARAMETER4FVARBPROC, glProgramEnvParameter4fvARB); \
2463+ USE_GL_FUNC(PGLFNVERTEXATTRIBPOINTERARBPROC, glVertexAttribPointerARB); \
2464+ USE_GL_FUNC(PGLFNENABLEVERTEXATTRIBARRAYARBPROC, glEnableVertexAttribArrayARB); \
2465+ USE_GL_FUNC(PGLFNDISABLEVERTEXATTRIBARRAYARBPROC, glDisableVertexAttribArrayARB); \
2466+
2467+#define GLX_EXT_FUNCS_GEN \
2468+ /** GLX_VERSION_1_3 **/ \
2469+ USE_GL_FUNC(PGLXFNGLXCREATEPBUFFERPROC, glXCreatePbuffer); \
2470+ USE_GL_FUNC(PGLXFNGLXDESTROYPBUFFERPROC, glXDestroyPbuffer); \
2471+ USE_GL_FUNC(PGLXFNGLXCREATEPIXMAPPROC, glXCreatePixmap); \
2472+ USE_GL_FUNC(PGLXFNGLXDESTROYPIXMAPPROC, glXDestroyPixmap); \
2473+ USE_GL_FUNC(PGLXFNGLXCREATENEWCONTEXTPROC, glXCreateNewContext); \
2474+ USE_GL_FUNC(PGLXFNGLXMAKECONTEXTCURRENTPROC, glXMakeContextCurrent); \
2475+ USE_GL_FUNC(PGLXFNGLXCHOOSEFBCONFIGPROC, glXChooseFBConfig); \
2476+
2477+#undef APIENTRY
2478+#undef CALLBACK
2479+#undef WINAPI
2480+
2481+/* Redefines the constants */
2482+#define CALLBACK __stdcall
2483+#define WINAPI __stdcall
2484+#define APIENTRY WINAPI
2485+
2486+/* Routine common to the draw primitive and draw indexed primitive routines */
2487+void drawPrimitive(LPDIRECT3DDEVICE9 iface,
2488+ int PrimitiveType,
2489+ long NumPrimitives,
2490+
2491+ /* for Indexed: */
2492+ long StartVertexIndex,
2493+ long StartIdx,
2494+ short idxBytes,
2495+ const void *idxData,
2496+ int minIndex);
2497+
2498+
2499+/*****************************************
2500+ * Structures required to draw primitives
2501+ */
2502+
2503+typedef struct Direct3DStridedData {
2504+ BYTE *lpData; /* Pointer to start of data */
2505+ DWORD dwStride; /* Stride between occurances of this data */
2506+ DWORD dwType; /* Type (as in D3DVSDT_TYPE) */
2507+} Direct3DStridedData;
2508+
2509+typedef struct Direct3DVertexStridedData {
2510+ union {
2511+ struct {
2512+ Direct3DStridedData position;
2513+ Direct3DStridedData blendWeights;
2514+ Direct3DStridedData blendMatrixIndices;
2515+ Direct3DStridedData normal;
2516+ Direct3DStridedData pSize;
2517+ Direct3DStridedData diffuse;
2518+ Direct3DStridedData specular;
2519+ Direct3DStridedData texCoords[8];
2520+ } s;
2521+ Direct3DStridedData input[16]; /* Indexed by constants in D3DVSDE_REGISTER */
2522+ } u;
2523+} Direct3DVertexStridedData;
2524+
2525+typedef struct _WineD3D_GLContext {
2526+ GLXContext glCtx;
2527+ XVisualInfo* visInfo;
2528+ Display* display;
2529+ Drawable drawable;
2530+ DWORD ref;
2531+} WineD3D_Context;
2532+
2533+#define USE_GL_FUNC(type, pfn) type pfn;
2534+typedef struct _GL_Info {
2535+ unsigned bIsFilled;
2536+
2537+ DWORD glx_version;
2538+ DWORD gl_version;
2539+
2540+ GL_Vendors gl_vendor;
2541+ GL_Cards gl_card;
2542+ DWORD gl_driver_version;
2543+ CHAR gl_renderer[255];
2544+ /**
2545+ * CAPS Constants
2546+ */
2547+ UINT max_lights;
2548+ UINT max_textures;
2549+ UINT max_clipplanes;
2550+
2551+ GL_PSVersion ps_arb_version;
2552+ GL_PSVersion ps_nv_version;
2553+
2554+ GL_VSVersion vs_arb_version;
2555+ GL_VSVersion vs_nv_version;
2556+ GL_VSVersion vs_ati_version;
2557+
2558+ BOOL supported[50];
2559+
2560+ /** OpenGL EXT and ARB functions ptr */
2561+ GL_EXT_FUNCS_GEN;
2562+ /** OpenGL GLX functions ptr */
2563+ GLX_EXT_FUNCS_GEN;
2564+ /**/
2565+} GL_Info;
2566+#undef USE_GL_FUNC
2567+
2568+
2569+#endif /* __WINE_D3DCORE_GL_H */
2570diff -urN wine.20050419/dlls/d3d9/device.c wine.20050419.dx9/dlls/d3d9/device.c
2571--- wine.20050419/dlls/d3d9/device.c 2005-03-29 12:01:00.000000000 -0700
2572+++ wine.20050419.dx9/dlls/d3d9/device.c 2005-04-20 01:52:56.000000000 -0600
2573@@ -32,7 +32,7 @@
2574
2575 if (IsEqualGUID(riid, &IID_IUnknown)
2576 || IsEqualGUID(riid, &IID_IDirect3DDevice9)) {
2577- IDirect3DDevice9Impl_AddRef(iface);
2578+ IUnknown_AddRef(iface);
2579 *ppobj = This;
2580 return D3D_OK;
2581 }
2582@@ -57,7 +57,6 @@
2583 TRACE("(%p) : ReleaseRef to %ld\n", This, ref);
2584
2585 if (ref == 0) {
2586- IDirect3D9_Release((LPDIRECT3D9) This->direct3d);
2587 IWineD3DDevice_Release(This->WineD3DDevice);
2588 HeapFree(GetProcessHeap(), 0, This);
2589 }
2590@@ -88,29 +87,128 @@
2591
2592 HRESULT WINAPI IDirect3DDevice9Impl_GetDirect3D(LPDIRECT3DDEVICE9 iface, IDirect3D9** ppD3D9) {
2593 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
2594- TRACE("(%p) : returning %p\n", This, This->direct3d);
2595- /* Inc ref count */
2596- *ppD3D9 = (IDirect3D9*) This->direct3d;
2597- IDirect3D9_AddRef(*ppD3D9);
2598- return D3D_OK;
2599+ HRESULT hr = D3D_OK;
2600+ IWineD3D* pWineD3D;
2601+
2602+ TRACE("(%p) Relay\n", This);
2603+
2604+ if(NULL == ppD3D9){
2605+ return D3DERR_INVALIDCALL;
2606+ }
2607+ hr = IWineD3DDevice_GetDirect3D(This->WineD3DDevice, &pWineD3D);
2608+ if(hr == D3D_OK && pWineD3D != NULL)
2609+ {
2610+ IWineD3DResource_GetParent((IWineD3DResource *)pWineD3D,(IUnknown **)ppD3D9);
2611+ IWineD3DResource_Release((IWineD3DResource *)pWineD3D);
2612+ }else{
2613+ FIXME("Call to IWineD3DDevice_GetDirect3D failed\n");
2614+ *ppD3D9 = NULL;
2615+ }
2616+ TRACE("(%p) returning %p\b",This , *ppD3D9);
2617+ return hr;
2618 }
2619
2620 HRESULT WINAPI IDirect3DDevice9Impl_GetDeviceCaps(LPDIRECT3DDEVICE9 iface, D3DCAPS9* pCaps) {
2621 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
2622- return IWineD3DDevice_GetDeviceCaps(This->WineD3DDevice, pCaps);
2623+ HRESULT hrc = D3D_OK;
2624+ WINED3DCAPS *pWineCaps;
2625+
2626+ TRACE("(%p) : Relay pCaps %p \n", This, pCaps);
2627+ if(NULL == pCaps){
2628+ return D3DERR_INVALIDCALL;
2629+ }
2630+ pWineCaps = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(WINED3DCAPS));
2631+ if(pWineCaps == NULL){
2632+ return D3DERR_INVALIDCALL; /*well this is what MSDN says to return*/
2633+ }
2634+
2635+ pWineCaps->DeviceType = &pCaps->DeviceType;
2636+ pWineCaps->AdapterOrdinal = &pCaps->AdapterOrdinal;
2637+ pWineCaps->Caps = &pCaps->Caps;
2638+ pWineCaps->Caps2 = &pCaps->Caps2;
2639+ pWineCaps->Caps3 = &pCaps->Caps3;
2640+ pWineCaps->PresentationIntervals = &pCaps->PresentationIntervals;
2641+ pWineCaps->CursorCaps = &pCaps->CursorCaps;
2642+ pWineCaps->DevCaps = &pCaps->DevCaps;
2643+ pWineCaps->PrimitiveMiscCaps = &pCaps->PrimitiveMiscCaps;
2644+ pWineCaps->RasterCaps = &pCaps->RasterCaps;
2645+ pWineCaps->ZCmpCaps = &pCaps->ZCmpCaps;
2646+ pWineCaps->SrcBlendCaps = &pCaps->SrcBlendCaps;
2647+ pWineCaps->DestBlendCaps = &pCaps->DestBlendCaps;
2648+ pWineCaps->AlphaCmpCaps = &pCaps->AlphaCmpCaps;
2649+ pWineCaps->ShadeCaps = &pCaps->ShadeCaps;
2650+ pWineCaps->TextureCaps = &pCaps->TextureCaps;
2651+ pWineCaps->TextureFilterCaps = &pCaps->TextureFilterCaps;
2652+ pWineCaps->CubeTextureFilterCaps = &pCaps->CubeTextureFilterCaps;
2653+ pWineCaps->VolumeTextureFilterCaps = &pCaps->VolumeTextureFilterCaps;
2654+ pWineCaps->TextureAddressCaps = &pCaps->TextureAddressCaps;
2655+ pWineCaps->VolumeTextureAddressCaps = &pCaps->VolumeTextureAddressCaps;
2656+ pWineCaps->LineCaps = &pCaps->LineCaps;
2657+ pWineCaps->MaxTextureWidth = &pCaps->MaxTextureWidth;
2658+ pWineCaps->MaxTextureHeight = &pCaps->MaxTextureHeight;
2659+ pWineCaps->MaxVolumeExtent = &pCaps->MaxVolumeExtent;
2660+ pWineCaps->MaxTextureRepeat = &pCaps->MaxTextureRepeat;
2661+ pWineCaps->MaxTextureAspectRatio = &pCaps->MaxTextureAspectRatio;
2662+ pWineCaps->MaxAnisotropy = &pCaps->MaxAnisotropy;
2663+ pWineCaps->MaxVertexW = &pCaps->MaxVertexW;
2664+ pWineCaps->GuardBandLeft = &pCaps->GuardBandLeft;
2665+ pWineCaps->GuardBandTop = &pCaps->GuardBandTop;
2666+ pWineCaps->GuardBandRight = &pCaps->GuardBandRight;
2667+ pWineCaps->GuardBandBottom = &pCaps->GuardBandBottom;
2668+ pWineCaps->ExtentsAdjust = &pCaps->ExtentsAdjust;
2669+ pWineCaps->StencilCaps = &pCaps->StencilCaps;
2670+ pWineCaps->FVFCaps = &pCaps->FVFCaps;
2671+ pWineCaps->TextureOpCaps = &pCaps->TextureOpCaps;
2672+ pWineCaps->MaxTextureBlendStages = &pCaps->MaxTextureBlendStages;
2673+ pWineCaps->MaxSimultaneousTextures = &pCaps->MaxSimultaneousTextures;
2674+ pWineCaps->VertexProcessingCaps = &pCaps->VertexProcessingCaps;
2675+ pWineCaps->MaxActiveLights = &pCaps->MaxActiveLights;
2676+ pWineCaps->MaxUserClipPlanes = &pCaps->MaxUserClipPlanes;
2677+ pWineCaps->MaxVertexBlendMatrices = &pCaps->MaxVertexBlendMatrices;
2678+ pWineCaps->MaxVertexBlendMatrixIndex = &pCaps->MaxVertexBlendMatrixIndex;
2679+ pWineCaps->MaxPointSize = &pCaps->MaxPointSize;
2680+ pWineCaps->MaxPrimitiveCount = &pCaps->MaxPrimitiveCount;
2681+ pWineCaps->MaxVertexIndex = &pCaps->MaxVertexIndex;
2682+ pWineCaps->MaxStreams = &pCaps->MaxStreams;
2683+ pWineCaps->MaxStreamStride = &pCaps->MaxStreamStride;
2684+ pWineCaps->VertexShaderVersion = &pCaps->VertexShaderVersion;
2685+ pWineCaps->MaxVertexShaderConst = &pCaps->MaxVertexShaderConst;
2686+ pWineCaps->PixelShaderVersion = &pCaps->PixelShaderVersion;
2687+ pWineCaps->PixelShader1xMaxValue = &pCaps->PixelShader1xMaxValue;
2688+ pWineCaps->DevCaps2 = &pCaps->DevCaps2;
2689+ pWineCaps->MaxNpatchTessellationLevel = &pCaps->MaxNpatchTessellationLevel;
2690+ pWineCaps->MasterAdapterOrdinal = &pCaps->MasterAdapterOrdinal;
2691+ pWineCaps->AdapterOrdinalInGroup = &pCaps->AdapterOrdinalInGroup;
2692+ pWineCaps->NumberOfAdaptersInGroup = &pCaps->NumberOfAdaptersInGroup;
2693+ pWineCaps->DeclTypes = &pCaps->DeclTypes;
2694+ pWineCaps->NumSimultaneousRTs = &pCaps->NumSimultaneousRTs;
2695+ pWineCaps->StretchRectFilterCaps = &pCaps->StretchRectFilterCaps;
2696+ pWineCaps->VS20Caps = (WINED3DVSHADERCAPS2_0 *)&pCaps->VS20Caps; /* structurally identical*/
2697+ pWineCaps->PS20Caps = (WINED3DPSHADERCAPS2_0 *)&pCaps->PS20Caps;
2698+ pWineCaps->VertexTextureFilterCaps = &pCaps->VertexTextureFilterCaps;
2699+ pWineCaps->MaxVShaderInstructionsExecuted = &pCaps->MaxVShaderInstructionsExecuted;
2700+ pWineCaps->MaxPShaderInstructionsExecuted = &pCaps->MaxPShaderInstructionsExecuted;
2701+ pWineCaps->MaxVertexShader30InstructionSlots = &pCaps->MaxVertexShader30InstructionSlots;
2702+ pWineCaps->MaxPixelShader30InstructionSlots = &pCaps->MaxPixelShader30InstructionSlots;
2703+ hrc = IWineD3DDevice_GetDeviceCaps(This->WineD3DDevice, pWineCaps);
2704+ HeapFree(GetProcessHeap(), 0, pWineCaps);
2705+ TRACE("Returning %p %p\n", This, pCaps);
2706+ return hrc;
2707 }
2708
2709 HRESULT WINAPI IDirect3DDevice9Impl_GetDisplayMode(LPDIRECT3DDEVICE9 iface, UINT iSwapChain, D3DDISPLAYMODE* pMode) {
2710 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
2711+
2712 TRACE("(%p) Relay\n", This);
2713+
2714 return IWineD3DDevice_GetDisplayMode(This->WineD3DDevice, iSwapChain, pMode);
2715 }
2716
2717 HRESULT WINAPI IDirect3DDevice9Impl_GetCreationParameters(LPDIRECT3DDEVICE9 iface, D3DDEVICE_CREATION_PARAMETERS *pParameters) {
2718 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
2719- FIXME("(%p) copying to %p\n", This, pParameters);
2720- memcpy(pParameters, &This->CreateParms, sizeof(D3DDEVICE_CREATION_PARAMETERS));
2721- return D3D_OK;
2722+
2723+ TRACE("(%p) Relay\n", This);
2724+ return IWineD3DDevice_GetCreationParameters(This->WineD3DDevice, pParameters);
2725 }
2726
2727 HRESULT WINAPI IDirect3DDevice9Impl_SetCursorProperties(LPDIRECT3DDEVICE9 iface, UINT XHotSpot, UINT YHotSpot, IDirect3DSurface9* pCursorBitmap) {
2728@@ -205,7 +303,6 @@
2729 return IWineD3DDevice_GetGammaRamp(This->WineD3DDevice, iSwapChain, pRamp);
2730 }
2731
2732-
2733 HRESULT WINAPI IDirect3DDevice9Impl_CreateSurface(LPDIRECT3DDEVICE9 iface, UINT Width, UINT Height, D3DFORMAT Format, BOOL Lockable, BOOL Discard, UINT Level, IDirect3DSurface9 **ppSurface,D3DRESOURCETYPE Type, UINT Usage,D3DPOOL Pool, D3DMULTISAMPLE_TYPE MultiSample, DWORD MultisampleQuality,HANDLE* pSharedHandle ) {
2734 HRESULT hrc;
2735 IDirect3DSurface9Impl *object;
2736@@ -343,56 +440,63 @@
2737 return IDirect3DDevice9Impl_CreateSurface(iface,Width,Height,Format,TRUE/*Loackable*/,FALSE/*Discard*/,0/*Level*/ , ppSurface,D3DRTYPE_SURFACE, 0/*Usage (undefined/none)*/,Pool,D3DMULTISAMPLE_NONE,0/*MultisampleQuality*/,pSharedHandle);
2738 }
2739
2740-/* TODO: move to wineD3D */
2741 HRESULT WINAPI IDirect3DDevice9Impl_SetRenderTarget(LPDIRECT3DDEVICE9 iface, DWORD RenderTargetIndex, IDirect3DSurface9* pRenderTarget) {
2742 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
2743- HRESULT hr = S_OK;
2744+ IDirect3DSurface9Impl *pSurface = (IDirect3DSurface9Impl*)pRenderTarget;
2745+ TRACE("(%p) Relay\n" , This);
2746+ return IWineD3DDevice_SetRenderTarget(This->WineD3DDevice,RenderTargetIndex,(IWineD3DSurface*)pSurface->wineD3DSurface);
2747+}
2748
2749- /* If pRenderTarget == NULL, it seems to default to back buffer */
2750- if (pRenderTarget == NULL) pRenderTarget = (IDirect3DSurface9*) This->backBuffer;
2751+HRESULT WINAPI IDirect3DDevice9Impl_GetRenderTarget(LPDIRECT3DDEVICE9 iface, DWORD RenderTargetIndex, IDirect3DSurface9 **ppRenderTarget) {
2752+ IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
2753+ HRESULT hr = D3D_OK;
2754+ IWineD3DSurface *pRenderTarget;
2755
2756- /* If we are trying to set what we already have, don't bother */
2757- if ((IDirect3DSurface9Impl*) pRenderTarget == This->renderTarget) {
2758- TRACE("Trying to do a NOP SetRenderTarget operation\n");
2759- } else {
2760- /* Otherwise, set the render target up */
2761- TRACE("(%p) : newRender@%p (default is backbuffer=(%p))\n", This, pRenderTarget, This->backBuffer);
2762- hr = E_FAIL; /* not supported yet */
2763- }
2764+ TRACE("(%p) Relay\n" , This);
2765
2766- return hr;
2767+ if(ppRenderTarget == NULL){
2768+ return D3DERR_INVALIDCALL;
2769 }
2770+ hr=IWineD3DDevice_GetRenderTarget(This->WineD3DDevice,RenderTargetIndex,&pRenderTarget);
2771
2772-/* TODO: move to wineD3D */
2773-HRESULT WINAPI IDirect3DDevice9Impl_GetRenderTarget(LPDIRECT3DDEVICE9 iface, DWORD RenderTargetIndex, IDirect3DSurface9** ppRenderTarget) {
2774- IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
2775- TRACE("(%p)->returning (%p) default is backbuffer=(%p)\n", This, This->renderTarget, This->backBuffer);
2776- *ppRenderTarget = (LPDIRECT3DSURFACE9) This->renderTarget;
2777- IDirect3DSurface9Impl_AddRef((LPDIRECT3DSURFACE9) *ppRenderTarget);
2778- return D3D_OK;
2779+ if(hr == D3D_OK && pRenderTarget != NULL){
2780+ IWineD3DResource_GetParent((IWineD3DResource *)pRenderTarget,(IUnknown**)ppRenderTarget);
2781+ IWineD3DResource_Release((IWineD3DResource *)pRenderTarget);
2782+ }else{
2783+ FIXME("Call to IWineD3DDevice_GetRenderTarget failed\n");
2784+ *ppRenderTarget = NULL;
2785+ }
2786+ return hr;
2787 }
2788
2789-/* TODO: move to wineD3D */
2790 HRESULT WINAPI IDirect3DDevice9Impl_SetDepthStencilSurface(LPDIRECT3DDEVICE9 iface, IDirect3DSurface9* pZStencilSurface) {
2791 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
2792- HRESULT hr = S_OK;
2793- /* If we are trying to set what we already have, don't bother */
2794- if ((IDirect3DSurface9Impl*) pZStencilSurface == This->stencilBufferTarget) {
2795- TRACE("Trying to do a NOP SetDepthStencilSurface operation\n");
2796- } else {
2797- /* Otherwise, set the target up */
2798- TRACE("(%p) : newDepthStencil@%p (default is stencilbuffer=(%p))\n", This, pZStencilSurface, This->depthStencilBuffer);
2799- hr = E_FAIL; /* not supported yet */
2800- }
2801- return D3D_OK;
2802+ IDirect3DSurface9Impl *pSurface;
2803+
2804+ TRACE("(%p) Relay\n" , This);
2805+
2806+ pSurface = (IDirect3DSurface9Impl*)pZStencilSurface;
2807+ return IWineD3DDevice_SetDepthStencilSurface(This->WineD3DDevice,NULL==pSurface?NULL:(IWineD3DSurface*)pSurface->wineD3DSurface);
2808 }
2809
2810-/* TODO: move to wineD3D */
2811 HRESULT WINAPI IDirect3DDevice9Impl_GetDepthStencilSurface(LPDIRECT3DDEVICE9 iface, IDirect3DSurface9** ppZStencilSurface) {
2812 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
2813- TRACE("(%p)->returning (%p) default is stencilbuffer=(%p)\n", This, This->stencilBufferTarget, This->depthStencilBuffer);
2814- *ppZStencilSurface = (LPDIRECT3DSURFACE9) This->stencilBufferTarget;
2815- if (NULL != *ppZStencilSurface) IDirect3DSurface9Impl_AddRef((LPDIRECT3DSURFACE9) *ppZStencilSurface);
2816+ HRESULT hr = D3D_OK;
2817+ IWineD3DSurface *pZStencilSurface;
2818+
2819+ TRACE("(%p) Relay\n" , This);
2820+ if(ppZStencilSurface == NULL){
2821+ return D3DERR_INVALIDCALL;
2822+ }
2823+
2824+ hr=IWineD3DDevice_GetDepthStencilSurface(This->WineD3DDevice,&pZStencilSurface);
2825+ if(hr == D3D_OK && pZStencilSurface != NULL){
2826+ IWineD3DResource_GetParent((IWineD3DResource *)pZStencilSurface,(IUnknown**)ppZStencilSurface);
2827+ IWineD3DResource_Release((IWineD3DResource *)pZStencilSurface);
2828+ }else{
2829+ FIXME("Call to IWineD3DDevice_GetRenderTarget failed\n");
2830+ *ppZStencilSurface = NULL;
2831+ }
2832 return D3D_OK;
2833 }
2834
2835@@ -521,7 +625,6 @@
2836 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
2837 IWineD3DBaseTexture *retTexture = NULL;
2838 HRESULT rc = D3D_OK;
2839-
2840 TRACE("(%p) Relay\n" , This);
2841
2842 if(ppTexture == NULL){
2843@@ -700,6 +803,9 @@
2844 if(pStream == NULL){
2845 return D3DERR_INVALIDCALL;
2846 }
2847+ if(pStream == NULL){
2848+ return D3DERR_INVALIDCALL;
2849+ }
2850
2851 rc = IWineD3DDevice_GetStreamSource(This->WineD3DDevice, StreamNumber, (IWineD3DVertexBuffer **)&retStream, OffsetInBytes, pStride);
2852 if (rc == D3D_OK && NULL != retStream) {
2853@@ -745,6 +851,9 @@
2854 if(ppIndexData == NULL){
2855 return D3DERR_INVALIDCALL;
2856 }
2857+ if(ppIndexData == NULL){
2858+ return D3DERR_INVALIDCALL;
2859+ }
2860
2861 rc = IWineD3DDevice_GetIndices(This->WineD3DDevice, &retIndexData, &tmp);
2862 if (rc == D3D_OK && NULL != retIndexData) {
2863@@ -775,6 +884,34 @@
2864 return IWineD3DDevice_DeletePatch(This->WineD3DDevice, Handle);
2865 }
2866
2867+HRESULT WINAPI IDirect3DDevice9Impl_CreateStateBlock(LPDIRECT3DDEVICE9 iface, D3DSTATEBLOCKTYPE Type, IDirect3DStateBlock9** ppStateBlock) {
2868+ IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
2869+ IDirect3DStateBlock9Impl* object;
2870+ HRESULT hrc = D3D_OK;
2871+
2872+ TRACE("(%p) Relay\n", This);
2873+
2874+ object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3DStateBlock9Impl));
2875+ if (NULL == object) {
2876+ FIXME("(%p) Failed to allocate %d bytes\n", This, sizeof(IDirect3DStateBlock9Impl));
2877+ *ppStateBlock = NULL;
2878+ return E_OUTOFMEMORY;
2879+ }
2880+ object->lpVtbl = &Direct3DStateBlock9_Vtbl;
2881+ object->ref = 1;
2882+
2883+ hrc=IWineD3DDevice_CreateStateBlock(This->WineD3DDevice,Type,&object->wineD3DStateBlock,(IUnknown*)object);
2884+ if(hrc != D3D_OK){
2885+ FIXME("(%p) Call to IWineD3DDevice_CreateStateBlock failed.\n", This);
2886+ HeapFree(GetProcessHeap(), 0, object);
2887+ *ppStateBlock = NULL;
2888+ } else {
2889+ *ppStateBlock = (IDirect3DStateBlock9*)object;
2890+ }
2891+ TRACE("(%p) returning token (ptr to stateblock) of %p\n", This, object);
2892+ return hrc;
2893+}
2894+
2895 IDirect3DDevice9Vtbl Direct3DDevice9_Vtbl =
2896 {
2897 IDirect3DDevice9Impl_QueryInterface,
2898@@ -921,3 +1058,4 @@
2899 }
2900 return res;
2901 }
2902+
2903diff -urN wine.20050419/dlls/d3d9/directx.c wine.20050419.dx9/dlls/d3d9/directx.c
2904--- wine.20050419/dlls/d3d9/directx.c 2005-03-29 12:01:00.000000000 -0700
2905+++ wine.20050419.dx9/dlls/d3d9/directx.c 2005-04-20 02:47:47.000000000 -0600
2906@@ -21,7 +21,7 @@
2907 #include "config.h"
2908 #include "d3d9_private.h"
2909
2910-WINE_DEFAULT_DEBUG_CHANNEL(d3d);
2911+WINE_DEFAULT_DEBUG_CHANNEL(d3d9);
2912
2913 /* IDirect3D9 IUnknown parts follow: */
2914 HRESULT WINAPI IDirect3D9Impl_QueryInterface(LPDIRECT3D9 iface, REFIID riid, LPVOID* ppobj)
2915@@ -30,7 +30,7 @@
2916
2917 if (IsEqualGUID(riid, &IID_IUnknown)
2918 || IsEqualGUID(riid, &IID_IDirect3D9)) {
2919- IDirect3D9Impl_AddRef(iface);
2920+ IUnknown_AddRef(iface);
2921 *ppobj = This;
2922 return D3D_OK;
2923 }
2924@@ -76,10 +76,11 @@
2925 HRESULT WINAPI IDirect3D9Impl_GetAdapterIdentifier(LPDIRECT3D9 iface, UINT Adapter, DWORD Flags, D3DADAPTER_IDENTIFIER9* pIdentifier) {
2926 IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
2927 WINED3DADAPTER_IDENTIFIER adapter_id;
2928-
2929+ TRACE("(%p) Relay \n", This);
2930 /* dx8 and dx9 have different structures to be filled in, with incompatible
2931 layouts so pass in pointers to the places to be filled via an internal
2932- structure */
2933+ structure
2934+ */
2935 adapter_id.Driver = pIdentifier->Driver;
2936 adapter_id.Description = pIdentifier->Description;
2937 adapter_id.DeviceName = pIdentifier->DeviceName;
2938@@ -96,16 +97,19 @@
2939
2940 UINT WINAPI IDirect3D9Impl_GetAdapterModeCount(LPDIRECT3D9 iface, UINT Adapter, D3DFORMAT Format) {
2941 IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
2942+ TRACE("(%p) Relay \n", This);
2943 return IWineD3D_GetAdapterModeCount(This->WineD3D, Adapter, Format);
2944 }
2945
2946 HRESULT WINAPI IDirect3D9Impl_EnumAdapterModes(LPDIRECT3D9 iface, UINT Adapter, D3DFORMAT Format, UINT Mode, D3DDISPLAYMODE* pMode) {
2947 IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
2948+ TRACE("(%p) Relay \n", This);
2949 return IWineD3D_EnumAdapterModes(This->WineD3D, Adapter, Format, Mode, pMode);
2950 }
2951
2952 HRESULT WINAPI IDirect3D9Impl_GetAdapterDisplayMode(LPDIRECT3D9 iface, UINT Adapter, D3DDISPLAYMODE* pMode) {
2953 IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
2954+ TRACE("(%p) Relay %p \n", This, This->WineD3D);
2955 return IWineD3D_GetAdapterDisplayMode(This->WineD3D, Adapter, pMode);
2956 }
2957
2958@@ -113,6 +117,7 @@
2959 UINT Adapter, D3DDEVTYPE CheckType, D3DFORMAT DisplayFormat,
2960 D3DFORMAT BackBufferFormat, BOOL Windowed) {
2961 IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
2962+ TRACE("(%p) Relay \n", This);
2963 return IWineD3D_CheckDeviceType(This->WineD3D, Adapter, CheckType, DisplayFormat,
2964 BackBufferFormat, Windowed);
2965 }
2966@@ -121,6 +126,7 @@
2967 UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT AdapterFormat,
2968 DWORD Usage, D3DRESOURCETYPE RType, D3DFORMAT CheckFormat) {
2969 IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
2970+ TRACE("(%p) Relay \n", This);
2971 return IWineD3D_CheckDeviceFormat(This->WineD3D, Adapter, DeviceType, AdapterFormat,
2972 Usage, RType, CheckFormat);
2973 }
2974@@ -129,6 +135,7 @@
2975 UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT SurfaceFormat,
2976 BOOL Windowed, D3DMULTISAMPLE_TYPE MultiSampleType, DWORD* pQualityLevels) {
2977 IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
2978+ TRACE("(%p) Relay \n", This);
2979 return IWineD3D_CheckDeviceMultiSampleType(This->WineD3D, Adapter, DeviceType, SurfaceFormat,
2980 Windowed, MultiSampleType, pQualityLevels);
2981 }
2982@@ -137,23 +144,113 @@
2983 UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT AdapterFormat,
2984 D3DFORMAT RenderTargetFormat, D3DFORMAT DepthStencilFormat) {
2985 IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
2986+ TRACE("(%p) Relay \n", This);
2987 return IWineD3D_CheckDepthStencilMatch(This->WineD3D, Adapter, DeviceType, AdapterFormat,
2988 RenderTargetFormat, DepthStencilFormat);
2989 }
2990
2991 HRESULT WINAPI IDirect3D9Impl_CheckDeviceFormatConversion(LPDIRECT3D9 iface, UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT SourceFormat, D3DFORMAT TargetFormat) {
2992 IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
2993+ TRACE("(%p) Relay \n", This);
2994 return IWineD3D_CheckDeviceFormatConversion(This->WineD3D, Adapter, DeviceType, SourceFormat,
2995 TargetFormat);
2996 }
2997
2998 HRESULT WINAPI IDirect3D9Impl_GetDeviceCaps(LPDIRECT3D9 iface, UINT Adapter, D3DDEVTYPE DeviceType, D3DCAPS9* pCaps) {
2999 IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
3000- return IWineD3D_GetDeviceCaps(This->WineD3D, Adapter, DeviceType, (WINED3DCAPS *)pCaps);
3001+ HRESULT hrc = D3D_OK;
3002+ WINED3DCAPS *pWineCaps;
3003+
3004+ TRACE("(%p) Relay %d %u %p \n", This, Adapter, DeviceType, pCaps);
3005+
3006+ if(NULL == pCaps){
3007+ return D3DERR_INVALIDCALL;
3008+ }
3009+ pWineCaps = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(WINED3DCAPS));
3010+ if(pWineCaps == NULL){
3011+ return D3DERR_INVALIDCALL; /*well this is what MSDN says to return*/
3012+ }
3013+
3014+ pWineCaps->DeviceType = &pCaps->DeviceType;
3015+ pWineCaps->AdapterOrdinal = &pCaps->AdapterOrdinal;
3016+ pWineCaps->Caps = &pCaps->Caps;
3017+ pWineCaps->Caps2 = &pCaps->Caps2;
3018+ pWineCaps->Caps3 = &pCaps->Caps3;
3019+ pWineCaps->PresentationIntervals = &pCaps->PresentationIntervals;
3020+ pWineCaps->CursorCaps = &pCaps->CursorCaps;
3021+ pWineCaps->DevCaps = &pCaps->DevCaps;
3022+ pWineCaps->PrimitiveMiscCaps = &pCaps->PrimitiveMiscCaps;
3023+ pWineCaps->RasterCaps = &pCaps->RasterCaps;
3024+ pWineCaps->ZCmpCaps = &pCaps->ZCmpCaps;
3025+ pWineCaps->SrcBlendCaps = &pCaps->SrcBlendCaps;
3026+ pWineCaps->DestBlendCaps = &pCaps->DestBlendCaps;
3027+ pWineCaps->AlphaCmpCaps = &pCaps->AlphaCmpCaps;
3028+ pWineCaps->ShadeCaps = &pCaps->ShadeCaps;
3029+ pWineCaps->TextureCaps = &pCaps->TextureCaps;
3030+ pWineCaps->TextureFilterCaps = &pCaps->TextureFilterCaps;
3031+ pWineCaps->CubeTextureFilterCaps = &pCaps->CubeTextureFilterCaps;
3032+ pWineCaps->VolumeTextureFilterCaps = &pCaps->VolumeTextureFilterCaps;
3033+ pWineCaps->TextureAddressCaps = &pCaps->TextureAddressCaps;
3034+ pWineCaps->VolumeTextureAddressCaps = &pCaps->VolumeTextureAddressCaps;
3035+ pWineCaps->LineCaps = &pCaps->LineCaps;
3036+ pWineCaps->MaxTextureWidth = &pCaps->MaxTextureWidth;
3037+ pWineCaps->MaxTextureHeight = &pCaps->MaxTextureHeight;
3038+ pWineCaps->MaxVolumeExtent = &pCaps->MaxVolumeExtent;
3039+ pWineCaps->MaxTextureRepeat = &pCaps->MaxTextureRepeat;
3040+ pWineCaps->MaxTextureAspectRatio = &pCaps->MaxTextureAspectRatio;
3041+ pWineCaps->MaxAnisotropy = &pCaps->MaxAnisotropy;
3042+ pWineCaps->MaxVertexW = &pCaps->MaxVertexW;
3043+ pWineCaps->GuardBandLeft = &pCaps->GuardBandLeft;
3044+ pWineCaps->GuardBandTop = &pCaps->GuardBandTop;
3045+ pWineCaps->GuardBandRight = &pCaps->GuardBandRight;
3046+ pWineCaps->GuardBandBottom = &pCaps->GuardBandBottom;
3047+ pWineCaps->ExtentsAdjust = &pCaps->ExtentsAdjust;
3048+ pWineCaps->StencilCaps = &pCaps->StencilCaps;
3049+ pWineCaps->FVFCaps = &pCaps->FVFCaps;
3050+ pWineCaps->TextureOpCaps = &pCaps->TextureOpCaps;
3051+ pWineCaps->MaxTextureBlendStages = &pCaps->MaxTextureBlendStages;
3052+ pWineCaps->MaxSimultaneousTextures = &pCaps->MaxSimultaneousTextures;
3053+ pWineCaps->VertexProcessingCaps = &pCaps->VertexProcessingCaps;
3054+ pWineCaps->MaxActiveLights = &pCaps->MaxActiveLights;
3055+ pWineCaps->MaxUserClipPlanes = &pCaps->MaxUserClipPlanes;
3056+ pWineCaps->MaxVertexBlendMatrices = &pCaps->MaxVertexBlendMatrices;
3057+ pWineCaps->MaxVertexBlendMatrixIndex = &pCaps->MaxVertexBlendMatrixIndex;
3058+ pWineCaps->MaxPointSize = &pCaps->MaxPointSize;
3059+ pWineCaps->MaxPrimitiveCount = &pCaps->MaxPrimitiveCount;
3060+ pWineCaps->MaxVertexIndex = &pCaps->MaxVertexIndex;
3061+ pWineCaps->MaxStreams = &pCaps->MaxStreams;
3062+ pWineCaps->MaxStreamStride = &pCaps->MaxStreamStride;
3063+ pWineCaps->VertexShaderVersion = &pCaps->VertexShaderVersion;
3064+ pWineCaps->MaxVertexShaderConst = &pCaps->MaxVertexShaderConst;
3065+ pWineCaps->PixelShaderVersion = &pCaps->PixelShaderVersion;
3066+ pWineCaps->PixelShader1xMaxValue = &pCaps->PixelShader1xMaxValue;
3067+ pWineCaps->DevCaps2 = &pCaps->DevCaps2;
3068+ pWineCaps->MaxNpatchTessellationLevel = &pCaps->MaxNpatchTessellationLevel;
3069+ pWineCaps->MasterAdapterOrdinal = &pCaps->MasterAdapterOrdinal;
3070+ pWineCaps->AdapterOrdinalInGroup = &pCaps->AdapterOrdinalInGroup;
3071+ pWineCaps->NumberOfAdaptersInGroup = &pCaps->NumberOfAdaptersInGroup;
3072+ pWineCaps->DeclTypes = &pCaps->DeclTypes;
3073+ pWineCaps->NumSimultaneousRTs = &pCaps->NumSimultaneousRTs;
3074+ pWineCaps->StretchRectFilterCaps = &pCaps->StretchRectFilterCaps;
3075+#if 0
3076+ pWineCaps->VS20Caps = &pCaps->VS20Caps;
3077+ pWineCaps->PS20Caps = &pCaps->PS20Caps;
3078+#endif
3079+ pWineCaps->VertexTextureFilterCaps = &pCaps->VertexTextureFilterCaps;
3080+ pWineCaps->MaxVShaderInstructionsExecuted = &pCaps->MaxVShaderInstructionsExecuted;
3081+ pWineCaps->MaxPShaderInstructionsExecuted = &pCaps->MaxPShaderInstructionsExecuted;
3082+ pWineCaps->MaxVertexShader30InstructionSlots = &pCaps->MaxVertexShader30InstructionSlots;
3083+ pWineCaps->MaxPixelShader30InstructionSlots = &pCaps->MaxPixelShader30InstructionSlots;
3084+ hrc = IWineD3D_GetDeviceCaps(This->WineD3D, Adapter, DeviceType, pWineCaps);
3085+ HeapFree(GetProcessHeap(), 0, pWineCaps);
3086+ TRACE("(%p) returning %p\n", This, pCaps);
3087+ return hrc;
3088+
3089 }
3090
3091 HMONITOR WINAPI IDirect3D9Impl_GetAdapterMonitor(LPDIRECT3D9 iface, UINT Adapter) {
3092 IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
3093+ TRACE("(%p) Relay \n", This);
3094 return IWineD3D_GetAdapterMonitor(This->WineD3D, Adapter);
3095 }
3096
3097@@ -164,33 +261,100 @@
3098 IWineD3DSurface** ppSurface, HANDLE* pSharedHandle) {
3099 HRESULT res = D3D_OK;
3100 IDirect3DSurface9Impl *d3dSurface = NULL;
3101- IDirect3DDevice9Impl* pDeviceImpl = (IDirect3DDevice9Impl*) device;
3102-
3103+ TRACE("(%p) call back\n", device);
3104 res = IDirect3DDevice9_CreateRenderTarget((IDirect3DDevice9 *)device, Width, Height,
3105 (D3DFORMAT) Format, MultiSample, MultisampleQuality, Lockable,
3106 (IDirect3DSurface9 **)&d3dSurface, pSharedHandle);
3107
3108 if (SUCCEEDED(res)) {
3109 *ppSurface = d3dSurface->wineD3DSurface;
3110- if (NULL == pDeviceImpl->backBuffer) {
3111- pDeviceImpl->backBuffer = d3dSurface;
3112- pDeviceImpl->renderTarget = d3dSurface;
3113- IDirect3DSurface9Impl_AddRef((LPDIRECT3DSURFACE9) pDeviceImpl->renderTarget);
3114- }
3115 } else {
3116 *ppSurface = NULL;
3117 }
3118 return res;
3119 }
3120
3121+HRESULT WINAPI D3D9CB_CreateAdditionalSwapChain(IUnknown *device,
3122+ WINED3DPRESENT_PARAMETERS* pPresentationParameters,
3123+ IWineD3DSwapChain ** ppSwapChain){
3124+ HRESULT res = D3D_OK;
3125+ IDirect3DSwapChain9Impl *d3dSwapChain =NULL;
3126+
3127+ D3DPRESENT_PARAMETERS localParameters;
3128+
3129+ localParameters.BackBufferWidth = *(pPresentationParameters->BackBufferWidth);
3130+ localParameters.BackBufferHeight = *(pPresentationParameters->BackBufferHeight);
3131+ localParameters.BackBufferFormat = *(pPresentationParameters->BackBufferFormat);
3132+ localParameters.BackBufferCount = *(pPresentationParameters->BackBufferCount);
3133+ localParameters.MultiSampleType = *(pPresentationParameters->MultiSampleType);
3134+ localParameters.MultiSampleQuality = *(pPresentationParameters->MultiSampleQuality);
3135+ localParameters.SwapEffect = *(pPresentationParameters->SwapEffect);
3136+ localParameters.hDeviceWindow = *(pPresentationParameters->hDeviceWindow);
3137+ localParameters.Windowed = *(pPresentationParameters->Windowed);
3138+ localParameters.EnableAutoDepthStencil = *(pPresentationParameters->EnableAutoDepthStencil);
3139+ localParameters.AutoDepthStencilFormat = *(pPresentationParameters->AutoDepthStencilFormat);
3140+ localParameters.Flags = *(pPresentationParameters->Flags);
3141+ localParameters.FullScreen_RefreshRateInHz = *(pPresentationParameters->FullScreen_RefreshRateInHz);
3142+ localParameters.PresentationInterval = *(pPresentationParameters->PresentationInterval);
3143+
3144+ TRACE("(%p) rellaying\n", device);
3145+ /*copy the presentation parameters*/
3146+ res = IDirect3DDevice9_CreateAdditionalSwapChain((IDirect3DDevice9 *)device, &localParameters, (IDirect3DSwapChain9 **)&d3dSwapChain);
3147+
3148+ if (res == D3D_OK){
3149+ *ppSwapChain = d3dSwapChain->wineD3DSwapChain;
3150+ } else {
3151+ *ppSwapChain = NULL;
3152+ }
3153+ /*Copy back the presentation parameters*/
3154+ TRACE("(%p) setting up return parameters\n", device);
3155+ *pPresentationParameters->BackBufferWidth = localParameters.BackBufferWidth;
3156+ *pPresentationParameters->BackBufferHeight = localParameters.BackBufferHeight;
3157+ *pPresentationParameters->BackBufferFormat = localParameters.BackBufferFormat;
3158+ *pPresentationParameters->BackBufferCount = localParameters.BackBufferCount;
3159+ *pPresentationParameters->MultiSampleType = localParameters.MultiSampleType;
3160+ *pPresentationParameters->MultiSampleQuality = localParameters.MultiSampleQuality;
3161+ *pPresentationParameters->SwapEffect = localParameters.SwapEffect;
3162+ *pPresentationParameters->hDeviceWindow = localParameters.hDeviceWindow;
3163+ *pPresentationParameters->Windowed = localParameters.Windowed;
3164+ *pPresentationParameters->EnableAutoDepthStencil = localParameters.EnableAutoDepthStencil;
3165+ *pPresentationParameters->AutoDepthStencilFormat = localParameters.AutoDepthStencilFormat;
3166+ *pPresentationParameters->Flags = localParameters.Flags;
3167+ *pPresentationParameters->FullScreen_RefreshRateInHz = localParameters.FullScreen_RefreshRateInHz;
3168+ *pPresentationParameters->PresentationInterval = localParameters.PresentationInterval;
3169+
3170+ return res;
3171+
3172+}
3173+
3174+
3175+
3176+/* Internal function called back during the CreateDevice to create a render target */
3177+HRESULT WINAPI D3D9CB_CreateDepthStencilSurface(IUnknown *device, UINT Width, UINT Height,
3178+ D3DFORMAT Format, D3DMULTISAMPLE_TYPE MultiSample,
3179+ DWORD MultisampleQuality, BOOL Discard,
3180+ IWineD3DSurface** ppSurface, HANDLE* pSharedHandle) {
3181+ HRESULT res = D3D_OK;
3182+ IDirect3DSurface9Impl *d3dSurface = NULL;
3183+
3184+ res = IDirect3DDevice9_CreateDepthStencilSurface((IDirect3DDevice9 *)device, Width, Height,
3185+ Format, MultiSample, MultisampleQuality, Discard,
3186+ (IDirect3DSurface9 **)&d3dSurface, pSharedHandle);
3187+ if (res == D3D_OK) {
3188+ *ppSurface = d3dSurface->wineD3DSurface;
3189+ }
3190+ return res;
3191+}
3192+
3193 HRESULT WINAPI IDirect3D9Impl_CreateDevice(LPDIRECT3D9 iface, UINT Adapter, D3DDEVTYPE DeviceType, HWND hFocusWindow,
3194 DWORD BehaviourFlags, D3DPRESENT_PARAMETERS* pPresentationParameters,
3195 IDirect3DDevice9** ppReturnedDeviceInterface) {
3196
3197+ /*TODO: This needs to call IWINED3D*/
3198 IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
3199 IDirect3DDevice9Impl *object = NULL;
3200 WINED3DPRESENT_PARAMETERS localParameters;
3201-
3202+ TRACE("(%p) Relay \n", This);
3203 /* Check the validity range of the adapter parameter */
3204 if (Adapter >= IDirect3D9Impl_GetAdapterCount(iface)) {
3205 *ppReturnedDeviceInterface = NULL;
3206@@ -207,8 +371,6 @@
3207
3208 object->lpVtbl = &Direct3DDevice9_Vtbl;
3209 object->ref = 1;
3210- object->direct3d = This;
3211- IDirect3D9_AddRef((LPDIRECT3D9) object->direct3d);
3212 *ppReturnedDeviceInterface = (IDirect3DDevice9 *)object;
3213
3214 /* Allocate an associated WineD3DDevice object */
3215@@ -226,7 +388,11 @@
3216 localParameters.Flags = &pPresentationParameters->Flags;
3217 localParameters.FullScreen_RefreshRateInHz = &pPresentationParameters->FullScreen_RefreshRateInHz;
3218 localParameters.PresentationInterval = &pPresentationParameters->PresentationInterval;
3219- return IWineD3D_CreateDevice(This->WineD3D, Adapter, DeviceType, hFocusWindow, BehaviourFlags, &localParameters, &object->WineD3DDevice, (IUnknown *)object, D3D9CB_CreateRenderTarget);
3220+
3221+ IWineD3D_CreateDevice(This->WineD3D, Adapter, DeviceType, hFocusWindow, BehaviourFlags, &localParameters, &object->WineD3DDevice, (IUnknown *)object, D3D9CB_CreateRenderTarget, D3D9CB_CreateDepthStencilSurface, D3D9CB_CreateAdditionalSwapChain);
3222+
3223+ TRACE("(%p) : Created Device %p\n", This, object);
3224+ return D3D_OK;
3225 }
3226
3227 IDirect3D9Vtbl Direct3D9_Vtbl =
3228diff -urN wine.20050419/dlls/d3d9/pixelshader.c wine.20050419.dx9/dlls/d3d9/pixelshader.c
3229--- wine.20050419/dlls/d3d9/pixelshader.c 2005-01-24 05:44:01.000000000 -0700
3230+++ wine.20050419.dx9/dlls/d3d9/pixelshader.c 2005-04-20 01:52:56.000000000 -0600
3231@@ -22,15 +22,16 @@
3232 #include "config.h"
3233 #include "d3d9_private.h"
3234
3235-WINE_DEFAULT_DEBUG_CHANNEL(d3d_shader);
3236+WINE_DEFAULT_DEBUG_CHANNEL(d3d9);
3237
3238-/* IDirect3DPixelShader9 IUnknown parts follow: */
3239+/*IUnknown Parts*/
3240 HRESULT WINAPI IDirect3DPixelShader9Impl_QueryInterface(LPDIRECT3DPIXELSHADER9 iface, REFIID riid, LPVOID* ppobj) {
3241 IDirect3DPixelShader9Impl *This = (IDirect3DPixelShader9Impl *)iface;
3242+ TRACE("(%p) Relay\n", This);
3243
3244 if (IsEqualGUID(riid, &IID_IUnknown)
3245 || IsEqualGUID(riid, &IID_IDirect3DPixelShader9)) {
3246- IDirect3DPixelShader9Impl_AddRef(iface);
3247+ IUnknown_AddRef(iface);
3248 *ppobj = This;
3249 return D3D_OK;
3250 }
3251@@ -63,16 +64,22 @@
3252 /* IDirect3DPixelShader9 Interface follow: */
3253 HRESULT WINAPI IDirect3DPixelShader9Impl_GetDevice(LPDIRECT3DPIXELSHADER9 iface, IDirect3DDevice9** ppDevice) {
3254 IDirect3DPixelShader9Impl *This = (IDirect3DPixelShader9Impl *)iface;
3255- TRACE("(%p) : returning %p\n", This, This->Device);
3256- *ppDevice = (LPDIRECT3DDEVICE9) This->Device;
3257- IDirect3DDevice9Impl_AddRef(*ppDevice);
3258+ IWineD3DDevice *myDevice = NULL;
3259+
3260+ TRACE("(%p) : Relay\n", This);
3261+
3262+ IWineD3DPixelShader_GetDevice(This->wineD3DPixelShader, &myDevice);
3263+ IWineD3DDevice_GetParent(myDevice, (IUnknown **)ppDevice);
3264+ IWineD3DDevice_Release(myDevice);
3265+ TRACE("(%p) returing (%p)", This, *ppDevice);
3266 return D3D_OK;
3267+
3268 }
3269
3270 HRESULT WINAPI IDirect3DPixelShader9Impl_GetFunction(LPDIRECT3DPIXELSHADER9 iface, VOID* pData, UINT* pSizeOfData) {
3271 IDirect3DPixelShader9Impl *This = (IDirect3DPixelShader9Impl *)iface;
3272- FIXME("(%p): stub\n", This);
3273- return D3D_OK;
3274+ TRACE("(%p) Relay\n", This);
3275+ return IWineD3DPixelShader_GetFunction(This->wineD3DPixelShader, pData, pSizeOfData);
3276 }
3277
3278
3279@@ -89,148 +96,100 @@
3280 /* IDirect3DDevice9 IDirect3DPixelShader9 Methods follow: */
3281 HRESULT WINAPI IDirect3DDevice9Impl_CreatePixelShader(LPDIRECT3DDEVICE9 iface, CONST DWORD* pFunction, IDirect3DPixelShader9** ppShader) {
3282 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
3283- FIXME("(%p) : stub\n", This);
3284+ IDirect3DPixelShader9Impl *object;
3285+ HRESULT hrc = D3D_OK;
3286+
3287+ FIXME("(%p) Relay (disabled)\n", This);
3288+ *ppShader = NULL;
3289 return D3D_OK;
3290+ if(ppShader == NULL){
3291+ TRACE("(%p) Invalid call\n", This);
3292+ return D3DERR_INVALIDCALL;
3293 }
3294+ object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
3295
3296-HRESULT WINAPI IDirect3DDevice9Impl_SetPixelShader(LPDIRECT3DDEVICE9 iface, IDirect3DPixelShader9* pShader) {
3297- IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
3298+ if(NULL == object){
3299+ return E_OUTOFMEMORY;
3300+ }else{
3301
3302- This->UpdateStateBlock->PixelShader = pShader;
3303- This->UpdateStateBlock->Changed.pixelShader = TRUE;
3304- This->UpdateStateBlock->Set.pixelShader = TRUE;
3305-
3306- /* Handle recording of state blocks */
3307- if (This->isRecordingState) {
3308- TRACE("Recording... not performing anything\n");
3309- return D3D_OK;
3310+ object->ref = 1;
3311+ object->lpVtbl = &Direct3DPixelShader9_Vtbl;
3312+ hrc = IWineD3DDevice_CreatePixelShader(This->WineD3DDevice, pFunction, &object->wineD3DPixelShader , (IUnknown *)object);
3313+ if(hrc != D3D_OK){
3314+ FIXME("(%p) call to IWineD3DDevice_CreatePixelShader failed\n", This);
3315+ HeapFree(GetProcessHeap(), 0 , object);
3316+ *ppShader = NULL;
3317+ }else{
3318+ *ppShader = (IDirect3DPixelShader9*) object;
3319 }
3320- /**
3321- * TODO: merge HAL shaders context switching from prototype
3322- */
3323- return D3D_OK;
3324+
3325 }
3326
3327-HRESULT WINAPI IDirect3DDevice9Impl_GetPixelShader(LPDIRECT3DDEVICE9 iface, IDirect3DPixelShader9** ppShader) {
3328+ TRACE("(%p) : returning %p\n", This, *ppShader);
3329+ return hrc;
3330+}
3331+
3332+HRESULT WINAPI IDirect3DDevice9Impl_SetPixelShader(LPDIRECT3DDEVICE9 iface, IDirect3DPixelShader9* pShader) {
3333 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
3334- TRACE("(%p) : GetPixelShader returning %p\n", This, This->StateBlock->PixelShader);
3335- *ppShader = This->StateBlock->PixelShader;
3336- IDirect3DPixelShader9Impl_AddRef(*ppShader);
3337+ IDirect3DPixelShader9Impl *shader = (IDirect3DPixelShader9Impl *)pShader;
3338+ TRACE("(%p) Relay\n", This);
3339+ IWineD3DDevice_SetPixelShader(This->WineD3DDevice, shader == NULL ? NULL :shader->wineD3DPixelShader);
3340 return D3D_OK;
3341 }
3342
3343-HRESULT WINAPI IDirect3DDevice9Impl_SetPixelShaderConstantF(LPDIRECT3DDEVICE9 iface, UINT Register, CONST float* pConstantData, UINT Vector4fCount) {
3344+HRESULT WINAPI IDirect3DDevice9Impl_GetPixelShader(LPDIRECT3DDEVICE9 iface, IDirect3DPixelShader9** ppShader) {
3345 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
3346+ IWineD3DPixelShader *object;
3347
3348- if (Register + Vector4fCount > D3D_VSHADER_MAX_CONSTANTS) {
3349- ERR("(%p) : SetPixelShaderConstant C[%u] invalid\n", This, Register);
3350+ HRESULT hrc = D3D_OK;
3351+ TRACE("(%p) Relay\n", This);
3352+ if(ppShader == NULL){
3353+ TRACE("(%p) Invalid call\n", This);
3354 return D3DERR_INVALIDCALL;
3355 }
3356- if (NULL == pConstantData) {
3357- return D3DERR_INVALIDCALL;
3358- }
3359- if (Vector4fCount > 1) {
3360- CONST FLOAT* f = pConstantData;
3361- UINT i;
3362- TRACE("(%p) : SetPixelShaderConstant C[%u..%u]=\n", This, Register, Register + Vector4fCount - 1);
3363- for (i = 0; i < Vector4fCount; ++i) {
3364- TRACE("{%f, %f, %f, %f}\n", f[0], f[1], f[2], f[3]);
3365- f += 4;
3366+
3367+ hrc = IWineD3DDevice_GetPixelShader(This->WineD3DDevice, &object);
3368+ if(hrc == D3D_OK){
3369+ hrc = IWineD3DPixelShader_GetParent(object, (IUnknown **)ppShader);
3370+ IWineD3DPixelShader_Release(object);
3371 }
3372- } else {
3373- const FLOAT* f = (const FLOAT*) pConstantData;
3374- TRACE("(%p) : SetPixelShaderConstant, C[%u]={%f, %f, %f, %f}\n", This, Register, f[0], f[1], f[2], f[3]);
3375+
3376+ TRACE("(%p) : returning %p\n", This, *ppShader);
3377+ return hrc;
3378 }
3379- This->UpdateStateBlock->Changed.pixelShaderConstant = TRUE;
3380- memcpy(&This->UpdateStateBlock->pixelShaderConstantF[Register], pConstantData, Vector4fCount * 4 * sizeof(FLOAT));
3381- return D3D_OK;
3382+
3383+HRESULT WINAPI IDirect3DDevice9Impl_SetPixelShaderConstantF(LPDIRECT3DDEVICE9 iface, UINT Register, CONST float* pConstantData, UINT Vector4fCount) {
3384+ IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
3385+ TRACE("(%p) Relay\n", This);
3386+ return IWineD3DDevice_SetPixelShaderConstantF(This->WineD3DDevice, Register, pConstantData, Vector4fCount);
3387 }
3388
3389 HRESULT WINAPI IDirect3DDevice9Impl_GetPixelShaderConstantF(LPDIRECT3DDEVICE9 iface, UINT Register, float* pConstantData, UINT Vector4fCount) {
3390 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
3391-
3392- TRACE("(%p) : C[%u] count=%u\n", This, Register, Vector4fCount);
3393- if (Register + Vector4fCount > D3D_VSHADER_MAX_CONSTANTS) {
3394- return D3DERR_INVALIDCALL;
3395- }
3396- if (NULL == pConstantData) {
3397- return D3DERR_INVALIDCALL;
3398- }
3399- memcpy(pConstantData, &This->UpdateStateBlock->pixelShaderConstantF[Register], Vector4fCount * 4 * sizeof(FLOAT));
3400- return D3D_OK;
3401+ TRACE("(%p) Relay\n", This);
3402+ return IWineD3DDevice_GetPixelShaderConstantF(This->WineD3DDevice, Register, pConstantData, Vector4fCount);
3403 }
3404
3405 HRESULT WINAPI IDirect3DDevice9Impl_SetPixelShaderConstantI(LPDIRECT3DDEVICE9 iface, UINT Register, CONST int* pConstantData, UINT Vector4iCount) {
3406 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
3407-
3408- if (Register + Vector4iCount > D3D_VSHADER_MAX_CONSTANTS) {
3409- ERR("(%p) : SetPixelShaderConstantI C[%u] invalid\n", This, Register);
3410- return D3DERR_INVALIDCALL;
3411- }
3412- if (NULL == pConstantData) {
3413- return D3DERR_INVALIDCALL;
3414- }
3415- if (Vector4iCount > 1) {
3416- CONST int* f = pConstantData;
3417- UINT i;
3418- TRACE("(%p) : SetPixelShaderConstantI C[%u..%u]=\n", This, Register, Register + Vector4iCount - 1);
3419- for (i = 0; i < Vector4iCount; ++i) {
3420- TRACE("{%d, %d, %d, %d}\n", f[0], f[1], f[2], f[3]);
3421- f += 4;
3422- }
3423- } else {
3424- CONST int* f = pConstantData;
3425- TRACE("(%p) : SetPixelShaderConstantI, C[%u]={%i, %i, %i, %i}\n", This, Register, f[0], f[1], f[2], f[3]);
3426- }
3427- This->UpdateStateBlock->Changed.pixelShaderConstant = TRUE;
3428- memcpy(&This->UpdateStateBlock->pixelShaderConstantI[Register], pConstantData, Vector4iCount * 4 * sizeof(int));
3429- return D3D_OK;
3430+ TRACE("(%p) Relay\n", This);
3431+ return IWineD3DDevice_SetPixelShaderConstantI(This->WineD3DDevice, Register, pConstantData, Vector4iCount);
3432 }
3433
3434 HRESULT WINAPI IDirect3DDevice9Impl_GetPixelShaderConstantI(LPDIRECT3DDEVICE9 iface, UINT Register, int* pConstantData, UINT Vector4iCount) {
3435 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
3436-
3437- TRACE("(%p) : C[%u] count=%u\n", This, Register, Vector4iCount);
3438- if (Register + Vector4iCount > D3D_VSHADER_MAX_CONSTANTS) {
3439- return D3DERR_INVALIDCALL;
3440- }
3441- if (NULL == pConstantData) {
3442- return D3DERR_INVALIDCALL;
3443- }
3444- memcpy(pConstantData, &This->UpdateStateBlock->pixelShaderConstantI[Register], Vector4iCount * 4 * sizeof(FLOAT));
3445- return D3D_OK;
3446+ TRACE("(%p) Relay\n", This);
3447+ return IWineD3DDevice_GetPixelShaderConstantI(This->WineD3DDevice, Register, pConstantData, Vector4iCount);
3448 }
3449
3450 HRESULT WINAPI IDirect3DDevice9Impl_SetPixelShaderConstantB(LPDIRECT3DDEVICE9 iface, UINT Register, CONST BOOL* pConstantData, UINT BoolCount) {
3451 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
3452- UINT i;
3453-
3454- if (Register + BoolCount > D3D_VSHADER_MAX_CONSTANTS) {
3455- ERR("(%p) : SetPixelShaderConstantB C[%u] invalid\n", This, Register);
3456- return D3DERR_INVALIDCALL;
3457- }
3458- if (NULL == pConstantData) {
3459- return D3DERR_INVALIDCALL;
3460- }
3461- if (BoolCount > 1) {
3462- CONST BOOL* f = pConstantData;
3463- TRACE("(%p) : SetPixelShaderConstantB C[%u..%u]=\n", This, Register, Register + BoolCount - 1);
3464- for (i = 0; i < BoolCount; ++i) {
3465- TRACE("{%u}\n", f[i]);
3466- }
3467- } else {
3468- CONST BOOL* f = pConstantData;
3469- TRACE("(%p) : SetPixelShaderConstantB, C[%u]={%u}\n", This, Register, f[0]);
3470- }
3471- This->UpdateStateBlock->Changed.pixelShaderConstant = TRUE;
3472- for (i = 0; i < BoolCount; ++i) {
3473- This->UpdateStateBlock->pixelShaderConstantB[Register] = pConstantData[i];
3474- }
3475- return D3D_OK;
3476+ TRACE("(%p) Relay\n", This);
3477+ return IWineD3DDevice_SetPixelShaderConstantB(This->WineD3DDevice, Register, pConstantData, BoolCount);
3478 }
3479
3480 HRESULT WINAPI IDirect3DDevice9Impl_GetPixelShaderConstantB(LPDIRECT3DDEVICE9 iface, UINT Register, BOOL* pConstantData, UINT BoolCount) {
3481 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
3482- FIXME("(%p) : stub\n", This);
3483- return D3D_OK;
3484+ TRACE("(%p) Relay\n", This);
3485+ return IWineD3DDevice_GetPixelShaderConstantB(This->WineD3DDevice, Register, pConstantData, BoolCount);
3486 }
3487diff -urN wine.20050419/dlls/d3d9/stateblock.c wine.20050419.dx9/dlls/d3d9/stateblock.c
3488--- wine.20050419/dlls/d3d9/stateblock.c 2005-01-24 05:44:01.000000000 -0700
3489+++ wine.20050419.dx9/dlls/d3d9/stateblock.c 2005-04-20 01:52:56.000000000 -0600
3490@@ -22,7 +22,7 @@
3491 #include "config.h"
3492 #include "d3d9_private.h"
3493
3494-WINE_DEFAULT_DEBUG_CHANNEL(d3d);
3495+WINE_DEFAULT_DEBUG_CHANNEL(d3d9);
3496
3497 /* IDirect3DStateBlock9 IUnknown parts follow: */
3498 HRESULT WINAPI IDirect3DStateBlock9Impl_QueryInterface(LPDIRECT3DSTATEBLOCK9 iface, REFIID riid, LPVOID* ppobj) {
3499@@ -30,7 +30,7 @@
3500
3501 if (IsEqualGUID(riid, &IID_IUnknown)
3502 || IsEqualGUID(riid, &IID_IDirect3DStateBlock9)) {
3503- IDirect3DStateBlock9Impl_AddRef(iface);
3504+ IUnknown_AddRef(iface);
3505 *ppobj = This;
3506 return D3D_OK;
3507 }
3508@@ -55,6 +55,7 @@
3509 TRACE("(%p) : ReleaseRef to %ld\n", This, ref);
3510
3511 if (ref == 0) {
3512+ IWineD3DStateBlock_Release(This->wineD3DStateBlock);
3513 HeapFree(GetProcessHeap(), 0, This);
3514 }
3515 return ref;
3516@@ -63,25 +64,22 @@
3517 /* IDirect3DStateBlock9 Interface follow: */
3518 HRESULT WINAPI IDirect3DStateBlock9Impl_GetDevice(LPDIRECT3DSTATEBLOCK9 iface, IDirect3DDevice9** ppDevice) {
3519 IDirect3DStateBlock9Impl *This = (IDirect3DStateBlock9Impl *)iface;
3520- TRACE("(%p) : returning %p\n", This, This->Device);
3521- *ppDevice = (LPDIRECT3DDEVICE9) This->Device;
3522- IDirect3DDevice9Impl_AddRef(*ppDevice);
3523- return D3D_OK;
3524+ TRACE("(%p) Relay\n", This);
3525+ return IDirect3DResource9Impl_GetDevice((LPDIRECT3DRESOURCE9) This, ppDevice);
3526 }
3527
3528 HRESULT WINAPI IDirect3DStateBlock9Impl_Capture(LPDIRECT3DSTATEBLOCK9 iface) {
3529 IDirect3DStateBlock9Impl *This = (IDirect3DStateBlock9Impl *)iface;
3530- FIXME("(%p) : stub\n", This);
3531- return D3D_OK;
3532+ TRACE("(%p) Relay\n", This);
3533+ return IWineD3DStateBlock_Capture(This->wineD3DStateBlock);
3534 }
3535
3536 HRESULT WINAPI IDirect3DStateBlock9Impl_Apply(LPDIRECT3DSTATEBLOCK9 iface) {
3537 IDirect3DStateBlock9Impl *This = (IDirect3DStateBlock9Impl *)iface;
3538- FIXME("(%p) : stub\n", This);
3539- return D3D_OK;
3540+ TRACE("(%p) Relay\n", This);
3541+ return IWineD3DStateBlock_Apply(This->wineD3DStateBlock);
3542 }
3543
3544-
3545 IDirect3DStateBlock9Vtbl Direct3DStateBlock9_Vtbl =
3546 {
3547 IDirect3DStateBlock9Impl_QueryInterface,
3548@@ -93,21 +91,36 @@
3549 };
3550
3551
3552-/* IDirect3DDevice9 IDirect3DStateBlock9 Methods follow: */
3553-HRESULT WINAPI IDirect3DDevice9Impl_CreateStateBlock(LPDIRECT3DDEVICE9 iface, D3DSTATEBLOCKTYPE Type, IDirect3DStateBlock9** ppSB) {
3554- IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
3555- FIXME("(%p) : stub\n", This);
3556- return D3D_OK;
3557-}
3558+
3559
3560 HRESULT WINAPI IDirect3DDevice9Impl_BeginStateBlock(LPDIRECT3DDEVICE9 iface) {
3561 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
3562- FIXME("(%p) : stub\n", This);
3563- return D3D_OK;
3564+ TRACE("(%p) Relay\n", This);
3565+ return IWineD3DDevice_BeginStateBlock(This->WineD3DDevice);
3566 }
3567
3568 HRESULT WINAPI IDirect3DDevice9Impl_EndStateBlock(LPDIRECT3DDEVICE9 iface, IDirect3DStateBlock9** ppSB) {
3569 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
3570- FIXME("(%p) : stub\n", This);
3571+ HRESULT hr;
3572+ IWineD3DStateBlock* wineD3DStateBlock;
3573+ IDirect3DStateBlock9Impl* object;
3574+
3575+ TRACE("(%p) Relay\n", This);
3576+
3577+ /*Tell wineD3D to endstatablock before anything else (incase we run out of memory later and cause locking problems)*/
3578+ hr=IWineD3DDevice_EndStateBlock(This->WineD3DDevice,&wineD3DStateBlock);
3579+ if(hr!= D3D_OK){
3580+ FIXME("IWineD3DDevice_EndStateBlock returned an error\n");
3581+ return hr;
3582+ }
3583+ /*allocate a new IDirectD3DStateBlock*/
3584+ object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY ,sizeof(IDirect3DStateBlock9Impl));
3585+ object->ref = 1;
3586+ object->lpVtbl = &Direct3DStateBlock9_Vtbl;
3587+
3588+ object->wineD3DStateBlock=wineD3DStateBlock;
3589+
3590+ *ppSB=(IDirect3DStateBlock9*)object;
3591+ TRACE("(%p)Returning %p %p\n", This, *ppSB, wineD3DStateBlock);
3592 return D3D_OK;
3593 }
3594diff -urN wine.20050419/dlls/d3d9/swapchain.c wine.20050419.dx9/dlls/d3d9/swapchain.c
3595--- wine.20050419/dlls/d3d9/swapchain.c 2005-01-24 05:44:01.000000000 -0700
3596+++ wine.20050419.dx9/dlls/d3d9/swapchain.c 2005-04-20 01:52:56.000000000 -0600
3597@@ -22,7 +22,7 @@
3598 #include "config.h"
3599 #include "d3d9_private.h"
3600
3601-WINE_DEFAULT_DEBUG_CHANNEL(d3d);
3602+WINE_DEFAULT_DEBUG_CHANNEL(d3d9);
3603
3604 /* IDirect3DSwapChain IUnknown parts follow: */
3605 HRESULT WINAPI IDirect3DSwapChain9Impl_QueryInterface(LPDIRECT3DSWAPCHAIN9 iface, REFIID riid, LPVOID* ppobj)
3606@@ -31,7 +31,7 @@
3607
3608 if (IsEqualGUID(riid, &IID_IUnknown)
3609 || IsEqualGUID(riid, &IID_IDirect3DSwapChain9)) {
3610- IDirect3DSwapChain9Impl_AddRef(iface);
3611+ IUnknown_AddRef(iface);
3612 *ppobj = This;
3613 return D3D_OK;
3614 }
3615@@ -56,58 +56,78 @@
3616 TRACE("(%p) : ReleaseRef to %ld\n", This, ref);
3617
3618 if (ref == 0) {
3619+ IWineD3DSwapChain_Release(This->wineD3DSwapChain);
3620 HeapFree(GetProcessHeap(), 0, This);
3621 }
3622 return ref;
3623 }
3624
3625+
3626 /* IDirect3DSwapChain9 parts follow: */
3627 HRESULT WINAPI IDirect3DSwapChain9Impl_Present(LPDIRECT3DSWAPCHAIN9 iface, CONST RECT* pSourceRect, CONST RECT* pDestRect, HWND hDestWindowOverride, CONST RGNDATA* pDirtyRegion, DWORD dwFlags) {
3628 IDirect3DSwapChain9Impl *This = (IDirect3DSwapChain9Impl *)iface;
3629- FIXME("(%p) : stub\n", This);
3630+ TRACE("(%p) Relay\n", This);
3631+ IWineD3DSwapChain_Present(This->wineD3DSwapChain, pSourceRect, pDestRect, hDestWindowOverride, pDirtyRegion, dwFlags);
3632 return D3D_OK;
3633 }
3634
3635 HRESULT WINAPI IDirect3DSwapChain9Impl_GetFrontBufferData(LPDIRECT3DSWAPCHAIN9 iface, IDirect3DSurface9* pDestSurface) {
3636 IDirect3DSwapChain9Impl *This = (IDirect3DSwapChain9Impl *)iface;
3637- FIXME("(%p) : stub\n", This);
3638- return D3D_OK;
3639+
3640+ TRACE("(%p) Relay\n", This);
3641+ return IWineD3DSwapChain_GetFrontBufferData(This->wineD3DSwapChain, ((IDirect3DSurface9Impl *)pDestSurface)->wineD3DSurface);
3642+
3643 }
3644
3645 HRESULT WINAPI IDirect3DSwapChain9Impl_GetBackBuffer(LPDIRECT3DSWAPCHAIN9 iface, UINT iBackBuffer, D3DBACKBUFFER_TYPE Type, IDirect3DSurface9** ppBackBuffer) {
3646 IDirect3DSwapChain9Impl *This = (IDirect3DSwapChain9Impl *)iface;
3647- FIXME("(%p) : stub\n", This);
3648- return D3D_OK;
3649+ HRESULT hrc = D3D_OK;
3650+ IWineD3DSurface *mySurface = NULL;
3651+
3652+ TRACE("(%p) Relay\n", This);
3653+
3654+ hrc = IWineD3DSwapChain_GetBackBuffer(This->wineD3DSwapChain, iBackBuffer, Type, &mySurface);
3655+ if (hrc == D3D_OK && NULL != mySurface) {
3656+ IWineD3DSurface_GetParent(mySurface, (IUnknown **)ppBackBuffer);
3657+ IWineD3DSurface_Release(mySurface);
3658+ }
3659+ return hrc;
3660 }
3661
3662 HRESULT WINAPI IDirect3DSwapChain9Impl_GetRasterStatus(LPDIRECT3DSWAPCHAIN9 iface, D3DRASTER_STATUS* pRasterStatus) {
3663 IDirect3DSwapChain9Impl *This = (IDirect3DSwapChain9Impl *)iface;
3664- FIXME("(%p) : stub\n", This);
3665- return D3D_OK;
3666+ TRACE("(%p) Relay\n", This);
3667+ return IWineD3DSwapChain_GetRasterStatus(This->wineD3DSwapChain, pRasterStatus);
3668 }
3669
3670 HRESULT WINAPI IDirect3DSwapChain9Impl_GetDisplayMode(LPDIRECT3DSWAPCHAIN9 iface, D3DDISPLAYMODE* pMode) {
3671 IDirect3DSwapChain9Impl *This = (IDirect3DSwapChain9Impl *)iface;
3672- FIXME("(%p) : stub\n", This);
3673- return D3D_OK;
3674+ TRACE("(%p) Relay\n", This);
3675+ return IWineD3DSwapChain_GetDisplayMode(This->wineD3DSwapChain, pMode);
3676 }
3677
3678 HRESULT WINAPI IDirect3DSwapChain9Impl_GetDevice(LPDIRECT3DSWAPCHAIN9 iface, IDirect3DDevice9** ppDevice) {
3679 IDirect3DSwapChain9Impl *This = (IDirect3DSwapChain9Impl *)iface;
3680- TRACE("(%p) : returning %p\n", This, This->Device);
3681- *ppDevice = (LPDIRECT3DDEVICE9) This->Device;
3682+ HRESULT hrc = D3D_OK;
3683+ IWineD3DDevice *device = NULL;
3684
3685- /* Note Calling this method will increase the internal reference count
3686- on the IDirect3DDevice9 interface. */
3687- IDirect3DDevice9Impl_AddRef(*ppDevice);
3688- return D3D_OK;
3689+ TRACE("(%p) Relay\n", This);
3690+
3691+ hrc = IWineD3DSwapChain_GetDevice(This->wineD3DSwapChain, &device);
3692+ if (hrc == D3D_OK && NULL != device) {
3693+ IWineD3DDevice_GetParent(device, (IUnknown **)ppDevice);
3694+ IWineD3DDevice_Release(device);
3695+ }
3696+ return hrc;
3697 }
3698
3699 HRESULT WINAPI IDirect3DSwapChain9Impl_GetPresentParameters(LPDIRECT3DSWAPCHAIN9 iface, D3DPRESENT_PARAMETERS* pPresentationParameters) {
3700 IDirect3DSwapChain9Impl *This = (IDirect3DSwapChain9Impl *)iface;
3701- FIXME("(%p) : copy\n", This);
3702+ FIXME("(%p) : inplement using WINED3DPRESENT_PARAMERS\n", This);
3703+ return IWineD3DSwapChain_GetPresentParameters(This->wineD3DSwapChain, pPresentationParameters);
3704+ /*
3705 memcpy(pPresentationParameters, &This->PresentParms, sizeof(D3DPRESENT_PARAMETERS));
3706- return D3D_OK;
3707+ */
3708 }
3709
3710
3711@@ -129,18 +149,69 @@
3712 /* IDirect3DDevice9 IDirect3DSwapChain9 Methods follow: */
3713 HRESULT WINAPI IDirect3DDevice9Impl_CreateAdditionalSwapChain(LPDIRECT3DDEVICE9 iface, D3DPRESENT_PARAMETERS* pPresentationParameters, IDirect3DSwapChain9** pSwapChain) {
3714 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
3715- FIXME("(%p) : stub\n", This);
3716+ IDirect3DSwapChain9Impl* object;
3717+ HRESULT hrc = D3D_OK;
3718+ WINED3DPRESENT_PARAMETERS localParameters;
3719+
3720+ TRACE("(%p) Relay\n", This);
3721+
3722+ object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
3723+ if (NULL == object) {
3724+ FIXME("Allocation of memory failed\n");
3725+ *pSwapChain = NULL;
3726+ return D3DERR_OUTOFVIDEOMEMORY;
3727+ }
3728+ object->ref = 1;
3729+ object->lpVtbl = &Direct3DSwapChain9_Vtbl;
3730+
3731+ /* Allocate an associated WineD3DDevice object */
3732+ localParameters.BackBufferWidth = &pPresentationParameters->BackBufferWidth;
3733+ localParameters.BackBufferHeight = &pPresentationParameters->BackBufferHeight;
3734+ localParameters.BackBufferFormat = &pPresentationParameters->BackBufferFormat;
3735+ localParameters.BackBufferCount = &pPresentationParameters->BackBufferCount;
3736+ localParameters.MultiSampleType = &pPresentationParameters->MultiSampleType;
3737+ localParameters.MultiSampleQuality = &pPresentationParameters->MultiSampleQuality;
3738+ localParameters.SwapEffect = &pPresentationParameters->SwapEffect;
3739+ localParameters.hDeviceWindow = &pPresentationParameters->hDeviceWindow;
3740+ localParameters.Windowed = &pPresentationParameters->Windowed;
3741+ localParameters.EnableAutoDepthStencil = &pPresentationParameters->EnableAutoDepthStencil;
3742+ localParameters.AutoDepthStencilFormat = &pPresentationParameters->AutoDepthStencilFormat;
3743+ localParameters.Flags = &pPresentationParameters->Flags;
3744+ localParameters.FullScreen_RefreshRateInHz = &pPresentationParameters->FullScreen_RefreshRateInHz;
3745+ localParameters.PresentationInterval = &pPresentationParameters->PresentationInterval;
3746+
3747+
3748+
3749+
3750+ hrc = IWineD3DDevice_CreateAdditionalSwapChain(This->WineD3DDevice, &localParameters, &object->wineD3DSwapChain, (IUnknown*)object, D3D9CB_CreateRenderTarget, D3D9CB_CreateDepthStencilSurface);
3751+ if(hrc != D3D_OK){
3752+ FIXME("(%p) call to IWineD3DDevice_CreateAdditionalSwapChain failed\n", This);
3753+ HeapFree(GetProcessHeap(), 0 , object);
3754+ *pSwapChain = NULL;
3755+ }else{
3756+ *pSwapChain = (IDirect3DSwapChain9 *)object;
3757+ }
3758+ TRACE("(%p) returning %p\n", This, *pSwapChain);
3759 return D3D_OK;
3760 }
3761
3762 HRESULT WINAPI IDirect3DDevice9Impl_GetSwapChain(LPDIRECT3DDEVICE9 iface, UINT iSwapChain, IDirect3DSwapChain9** pSwapChain) {
3763 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
3764- FIXME("(%p) : stub\n", This);
3765- return D3D_OK;
3766+ HRESULT hrc = D3D_OK;
3767+ IWineD3DSwapChain *swapchain = NULL;
3768+
3769+ TRACE("(%p) Relay\n", This);
3770+
3771+ hrc = IWineD3DDevice_GetSwapChain(This->WineD3DDevice, iSwapChain, &swapchain);
3772+ if (hrc == D3D_OK && NULL != swapchain) {
3773+ IWineD3DSwapChain_GetParent(swapchain, (IUnknown **)pSwapChain);
3774+ IWineD3DSwapChain_Release(swapchain);
3775+ }
3776+ return hrc;
3777 }
3778
3779 UINT WINAPI IDirect3DDevice9Impl_GetNumberOfSwapChains(LPDIRECT3DDEVICE9 iface) {
3780 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
3781- FIXME("(%p) : stub\n", This);
3782- return 1;
3783+ TRACE("(%p) Relay\n", This);
3784+ return IWineD3DDevice_GetNumberOfSwapChains(This->WineD3DDevice);
3785 }
3786diff -urN wine.20050419/dlls/d3d9/tests/.cvsignore wine.20050419.dx9/dlls/d3d9/tests/.cvsignore
3787--- wine.20050419/dlls/d3d9/tests/.cvsignore 1969-12-31 17:00:00.000000000 -0700
3788+++ wine.20050419.dx9/dlls/d3d9/tests/.cvsignore 2005-04-20 01:52:56.000000000 -0600
3789@@ -0,0 +1,3 @@
3790+Makefile
3791+ddrawmodes.ok
3792+testlist.c
3793diff -urN wine.20050419/dlls/d3d9/tests/Makefile.in wine.20050419.dx9/dlls/d3d9/tests/Makefile.in
3794--- wine.20050419/dlls/d3d9/tests/Makefile.in 1969-12-31 17:00:00.000000000 -0700
3795+++ wine.20050419.dx9/dlls/d3d9/tests/Makefile.in 2005-04-20 01:52:56.000000000 -0600
3796@@ -0,0 +1,13 @@
3797+TOPSRCDIR = @top_srcdir@
3798+TOPOBJDIR = ../../..
3799+SRCDIR = @srcdir@
3800+VPATH = @srcdir@
3801+TESTDLL = d3d9.dll
3802+IMPORTS = ddraw user32 gdi32 kernel32 d3d9 opengl
3803+
3804+CTESTS = \
3805+ d3d9tests.c
3806+
3807+@MAKE_TEST_RULES@
3808+
3809+### Dependencies:
3810diff -urN wine.20050419/dlls/d3d9/tests/d3d9tests.c wine.20050419.dx9/dlls/d3d9/tests/d3d9tests.c
3811--- wine.20050419/dlls/d3d9/tests/d3d9tests.c 1969-12-31 17:00:00.000000000 -0700
3812+++ wine.20050419.dx9/dlls/d3d9/tests/d3d9tests.c 2005-04-20 01:52:56.000000000 -0600
3813@@ -0,0 +1,783 @@
3814+/*
3815+ * Unit tests for ddraw functions
3816+ *
3817+ * Copyright (C) 2003 Sami Aario
3818+ *
3819+ * This library is free software; you can redistribute it and/or
3820+ * modify it under the terms of the GNU Lesser General Public
3821+ * License as published by the Free Software Foundation; either
3822+ * version 2.1 of the License, or (at your option) any later version.
3823+ *
3824+ * This library is distributed in the hope that it will be useful,
3825+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
3826+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
3827+ * Lesser General Public License for more details.
3828+ *
3829+ * You should have received a copy of the GNU Lesser General Public
3830+ * License along with this library; if not, write to the Free Software
3831+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
3832+ */
3833+
3834+#include <assert.h>
3835+#include "wine/test.h"
3836+#include "ddraw.h"
3837+#include "d3d9.h"
3838+#include "d3dx9.h" /*This is fore some of the structures, all code relating to calls is included in the testsuite*/
3839+
3840+#ifdef NONAMELESSUNION
3841+#define UNION_MEMBER(x, y) DUMMYUNIONNAME##x.y
3842+#else
3843+#define UNION_MEMBER(x, y) y
3844+#endif
3845+
3846+
3847+
3848+
3849+typedef struct MY_CUSTOM_VERTEX
3850+{
3851+ D3DXVECTOR3 position;
3852+ D3DCOLOR color;
3853+} MY_CUSTOM_VERTEX;
3854+
3855+#define MY_CUSTOM_VERTEX_FVF (D3DFVF_XYZ|D3DFVF_DIFFUSE)
3856+
3857+
3858+static D3DXVECTOR3 D3DXVector3(float x, float y, float z);
3859+//static extern D3DXMATR* D3DXMatrixInentity ( D3DXMATRIX *pOut );
3860+
3861+static IDirect3D9 *lpD3D9 = NULL;
3862+static IDirect3DDevice9* lpD3D9Device = NULL;
3863+static LPDIRECT3DVERTEXBUFFER9 m_pVertexBuffer = NULL;
3864+static WNDCLASS wc;
3865+static HWND hwnd;
3866+static float wndWidth;
3867+static float wndHeight;
3868+static int modes_cnt;
3869+static int modes_size;
3870+static LPDDSURFACEDESC modes;
3871+
3872+static D3DXMATRIX m_matProjection;
3873+static D3DXMATRIX m_matWorld;
3874+static D3DXMATRIX m_matView;
3875+
3876+ // These vars hold info on the vertices
3877+static int m_iNumVertices; // Number of vertices that will make the shape
3878+static int m_iNumPolygons; // Number of polygons to use
3879+static float m_fXPos; // The starting X position of our shape
3880+static float m_fYPos; // The starting Y position of our shape
3881+static float m_fZPos; // The starting Z position
3882+
3883+static void createdirectdraw()
3884+{
3885+ HRESULT rc;
3886+
3887+
3888+ wc.style = CS_HREDRAW | CS_VREDRAW;
3889+ wc.lpfnWndProc = DefWindowProcA;
3890+ wc.cbClsExtra = 0;
3891+ wc.cbWndExtra = 0;
3892+ wc.hInstance = GetModuleHandleA(0);
3893+ wc.hIcon = LoadIconA(wc.hInstance, IDI_APPLICATION);
3894+ wc.hCursor = LoadCursorA(NULL, IDC_ARROW);
3895+ wc.hbrBackground = (HBRUSH) GetStockObject(BLACK_BRUSH);
3896+ wc.lpszMenuName = NULL;
3897+ wc.lpszClassName = "TestWindowClass";
3898+ if(!RegisterClassA(&wc))
3899+ assert(0);
3900+
3901+ wndWidth = GetSystemMetrics(SM_CXSCREEN);
3902+ wndHeight = GetSystemMetrics(SM_CXSCREEN);
3903+
3904+
3905+ hwnd = CreateWindowExA(0, "TestWindowClass", "TestWindowClass",
3906+ WS_POPUP, 0, 0,
3907+ wndWidth,
3908+ wndHeight,
3909+ NULL, NULL, GetModuleHandleA(0), NULL);
3910+ assert(hwnd != NULL);
3911+
3912+ ShowWindow(hwnd, SW_HIDE);
3913+ UpdateWindow(hwnd);
3914+ SetFocus(hwnd);
3915+ ShowCursor(TRUE);
3916+
3917+ /*rc = DirectDrawCreate(NULL, &lpDD, NULL);*/
3918+
3919+ lpD3D9 = Direct3DCreate9(D3D_SDK_VERSION);
3920+ ok(lpD3D9 != NULL ,"Direct3DCreate9 returned: %lx\n",rc);
3921+
3922+ D3DDEVICE_CREATION_PARAMETERS dcp;
3923+ dcp.AdapterOrdinal = D3DADAPTER_DEFAULT;
3924+ dcp.DeviceType = D3DDEVTYPE_HAL;
3925+ dcp.hFocusWindow = hwnd;
3926+ dcp.BehaviorFlags = D3DCREATE_SOFTWARE_VERTEXPROCESSING;
3927+
3928+ D3DDISPLAYMODE d3ddm;
3929+
3930+ IDirect3D9_GetAdapterDisplayMode(lpD3D9, dcp.AdapterOrdinal, &d3ddm);
3931+
3932+ D3DPRESENT_PARAMETERS d3dpp;
3933+
3934+ memset(&d3dpp, 0 , sizeof(d3dpp));
3935+
3936+ /*Creation parameters*/
3937+ d3dpp.BackBufferCount = 1;
3938+ d3dpp.SwapEffect = 0;/*D3DSWAPEFFECT_DISCARD;*/
3939+ d3dpp.MultiSampleType = D3DMULTISAMPLE_NONE;
3940+ d3dpp.EnableAutoDepthStencil = TRUE;
3941+ d3dpp.AutoDepthStencilFormat = D3DFMT_D16;
3942+
3943+ d3dpp.BackBufferWidth = d3ddm.Width;
3944+ d3dpp.BackBufferHeight = d3ddm.Height;
3945+ d3dpp.BackBufferFormat = d3ddm.Format;
3946+ d3dpp.Windowed = FALSE;
3947+ d3dpp.FullScreen_RefreshRateInHz = D3DPRESENT_RATE_DEFAULT;
3948+ d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_ONE;
3949+
3950+ IDirect3D9_CreateDevice(lpD3D9, dcp.AdapterOrdinal, dcp.DeviceType, dcp.hFocusWindow,
3951+ dcp.BehaviorFlags, &d3dpp, &lpD3D9Device);
3952+
3953+ D3DXMatrixIdentity(&m_matWorld);
3954+ D3DXMatrixIdentity(&m_matView);
3955+ D3DXMatrixIdentity(&m_matProjection);
3956+}
3957+/*most of the tests will be run with the viewport set to the identity matrix*/
3958+static void setupDevice(){
3959+
3960+ IDirect3DDevice9_SetRenderState(lpD3D9Device, D3DRS_LIGHTING, FALSE);
3961+ IDirect3DDevice9_SetRenderState(lpD3D9Device, D3DRS_CULLMODE, D3DCULL_NONE);
3962+
3963+/* IDirect3DDevice9_SetTransform(lpD3D9Device, D3DRS_CULLMODE, D3DCULL_NONE);*/
3964+ IDirect3DDevice9_SetRenderState(lpD3D9Device, D3DRS_CULLMODE, D3DCULL_NONE);
3965+
3966+ /*The device needs to be setup with no perspectine since it's not needed for mosts tests
3967+ ideally it should be switched on for test without-perspective, test with-perspective.
3968+ */
3969+ /*
3970+ D3DXMatrixPerspectiveFovLH(&m_matProjection, D3DX_PI/4.0f,
3971+ (float)(wndWidth/wndHeight),
3972+ 1.0f, 1000.0f); */
3973+
3974+ IDirect3DDevice9_SetTransform(lpD3D9Device, D3DTS_PROJECTION, &m_matProjection);
3975+
3976+ D3DXVECTOR3 v1;
3977+ D3DXVECTOR3 v2;
3978+ D3DXVECTOR3 v3;
3979+
3980+ v1 = D3DXVector3(0, 0, -50);
3981+ v2 = D3DXVector3(0, 0, 0);
3982+ v3 = D3DXVector3(0, 1, 0);
3983+ /* D3DXVector3(0.0f, 00.0f, -50.0f) */
3984+ /* D3DXVector3(0.0f, 0.0f, 0.0f) */
3985+ /* D3DXVector3(0.0f, 1.0f, .0f) */
3986+
3987+ /* D3DXMatrixLookAtLH(&m_matView, &v1, &v2, &v3); */
3988+
3989+ IDirect3DDevice9_SetTransform(lpD3D9Device, D3DTS_VIEW, &m_matView);
3990+
3991+
3992+}
3993+#include <stdio.h>
3994+
3995+/* TODO: This needs to be a lot more generic so that it's easy to create vertex buffers with differnt sets of properties for testing */
3996+static void createVertexBuffer(){
3997+
3998+
3999+ MY_CUSTOM_VERTEX *pVertices = NULL;
4000+
4001+ m_pVertexBuffer = NULL;
4002+ // 3 vertices per triangle, and 2 triangles per square,
4003+ // and 2 squares. so we have 3*2*2 = 12 vertices.
4004+ m_iNumVertices = 6;
4005+ // 2 squares, and each square is made out of 2
4006+ // triangles. A triangle is a polygon, so we
4007+ // have 4 polygons.
4008+ m_iNumPolygons = 2;
4009+ m_fXPos = 0;
4010+ m_fYPos = 0;
4011+ m_fZPos = 0;
4012+
4013+
4014+
4015+ /* This function is used to initialize our vertex buffer
4016+ * interface. It is a straight forward function, which gives
4017+ * you back a pointer to your initialized vertex buffer
4018+ * ******************************************************/
4019+ IDirect3DDevice9_CreateVertexBuffer(lpD3D9Device, m_iNumVertices*sizeof(MY_CUSTOM_VERTEX), D3DUSAGE_WRITEONLY, MY_CUSTOM_VERTEX_FVF, D3DPOOL_DEFAULT, &m_pVertexBuffer, NULL);
4020+
4021+
4022+ /* Now we have to fill in the vertex buffer. To do that we have to
4023+ * lock the vertex buffer, then we fill in the vertex buffer, then we
4024+ * unlock it, so ...
4025+ * ******************************************************/
4026+ IDirect3DVertexBuffer9_Lock(m_pVertexBuffer, 0, 0, (void**)&pVertices, 0);
4027+
4028+
4029+ /* Now we use pVertices to access our vertex buffer, and change it
4030+ * This time we make 12 vertices. 6 for 2 squares (quads)
4031+ * ******************************************************/
4032+
4033+ /* First triangle in first quad */
4034+ pVertices[0].position = D3DXVector3(-.5f, -0.5f, 0.0f);
4035+ pVertices[1].position = D3DXVector3(.5f, -0.5f, 0.0f);
4036+ pVertices[2].position = D3DXVector3(-0.5f, 0.5f, 0.0f);
4037+
4038+ /* Second triangle in first quad */
4039+ pVertices[3].position = D3DXVector3(0.5f, 0.5f, 0.0f);
4040+ pVertices[4].position = D3DXVector3(0.5f, -0.5f, 0.0f);
4041+ pVertices[5].position = D3DXVector3(-0.5f, 0.5f, 0.0f);
4042+
4043+ #if 0
4044+ // First triangle in second quad
4045+ pVertices[6].position = D3DXVector3(-2.0f, -2.0f, 2.0f);
4046+ pVertices[7].position = D3DXVector3(2.0f, -2.0f, 2.0f);
4047+ pVertices[8].position = D3DXVector3(-2.0f, 2.0f, 2.0f);
4048+
4049+ // Second triangle in second quad
4050+ pVertices[9].position = D3DXVector3(2.0f, 2.0f, 2.0f);
4051+ pVertices[10].position = D3DXVector3(2.0f, -2.0f, 2.0f);
4052+ pVertices[11].position = D3DXVector3(-2.0f, 2.0f, 2.0f);
4053+ #endif
4054+ /* Ok we finished fixing the vertices' positions
4055+ * now we'll give them color
4056+
4057+ * We will fill in the first 6 vertices with one color
4058+ * and the last 6 vertices with a different color.
4059+ * m_iNumVertices is the total number of vertices, so
4060+ * divide by 2 and you fill in half the buffer with one
4061+ * color, and the other half with another colot
4062+ * ******************************************************/
4063+
4064+ int i;
4065+ for(i = 0; i < (int)(m_iNumVertices); i++)
4066+ {
4067+ pVertices[i].color = D3DCOLOR_ARGB(255,0 ,0, 255); //Blue
4068+ }
4069+#if 0
4070+ // Make the colors different for the second square
4071+ for(i = (int)(m_iNumVertices/2); i < m_iNumVertices; i++)
4072+ {
4073+ // Notice I am using a different D3DCOLOR macro
4074+ // this does the same thing. right click on it in
4075+ // VC++ 6.0 and click on Go To Definition, and see what comes up
4076+ pVertices[i].color = D3DCOLOR_XRGB(255, 255, 0); //Yellow
4077+ }
4078+#endif
4079+ /* Ok, we are done with the vertex buffer. now unlock it */
4080+ IDirect3DVertexBuffer9_Unlock(m_pVertexBuffer);
4081+
4082+ return TRUE;
4083+}
4084+
4085+
4086+
4087+
4088+static void destroyVertexBuffer(){
4089+ if(m_pVertexBuffer != NULL){
4090+ IDirect3DVertexBuffer9_Release(m_pVertexBuffer);
4091+ }
4092+}
4093+
4094+
4095+#include <stdio.h>
4096+
4097+static void drawSomething(){
4098+/*draw something onto the iface*/
4099+/*just draw a primitive*/
4100+
4101+ createVertexBuffer();
4102+ if(D3D_OK == IDirect3DDevice9_SetFVF(lpD3D9Device, MY_CUSTOM_VERTEX_FVF)){
4103+ printf("ok\n");
4104+ };
4105+
4106+ if(D3D_OK == IDirect3DDevice9_SetStreamSource(lpD3D9Device, 0, m_pVertexBuffer, 0, sizeof(MY_CUSTOM_VERTEX))){
4107+ printf("ok\n");
4108+ }
4109+
4110+ // We are going to be scaling our object, moving it, and rotating
4111+ // it about the Z_Axis, so we have a matrix for Traslation
4112+ // Scaling, and Rotation.
4113+ D3DXMATRIX matS, matZ, matT;
4114+
4115+ // We use handy D3DX functions to create our matrices
4116+ if(D3D_OK == D3DXMatrixScaling(&matS, 1.0f, 1.0f, 1.0f)){
4117+ printf("ok\n");
4118+ }
4119+
4120+ /* D3DXMatrixRotationZ(&matZ, timeGetTime()/1000.0f);*/
4121+ // We're creating the translation matrix with variables
4122+ // because we want to be able to move the quads on the
4123+ // screen.
4124+ if(D3D_OK == D3DXMatrixTranslation(&matT, m_fXPos, m_fYPos, m_fZPos)){
4125+ printf("ok\n");
4126+ }
4127+
4128+ // Multiply all teh matrices together to get the final matrix.
4129+ // So now m_matWorld is a combination of movement (matT),
4130+ // rotation along the z axis (matR) and a scale value (matS)
4131+ m_matWorld = matS;/* * matZ * matT;*/
4132+
4133+ IDirect3DDevice9_Clear(lpD3D9Device, 0, NULL, D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(0,0,30), 1.0f, 0);
4134+ IDirect3DDevice9_Present(lpD3D9Device, NULL, NULL, NULL, NULL);
4135+ printf("Dark blue filling the window\n");
4136+ getchar();
4137+ IDirect3DDevice9_BeginScene(lpD3D9Device);
4138+
4139+ // Set the world matrix to what we calculated above. Now anything
4140+ // you draw after setting the world amtrix will be affected by the
4141+ // transformations in m_matWorld. Try setting the world matrix
4142+ // to an identity and see what happens.
4143+ IDirect3DDevice9_SetTransform(lpD3D9Device, D3DTS_WORLD, &m_matWorld);
4144+
4145+ IDirect3DDevice9_DrawPrimitive(lpD3D9Device, D3DPT_TRIANGLELIST, 0, m_iNumPolygons);
4146+
4147+ IDirect3DDevice9_EndScene(lpD3D9Device);
4148+
4149+ IDirect3DDevice9_Present(lpD3D9Device, NULL, NULL, NULL, NULL);
4150+ printf("A light blue 'sqaure' on a darkblue background in the center of the window filling half the window\n");
4151+ getchar();
4152+ IDirect3DDevice9_Clear(lpD3D9Device, 0, NULL, D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(30,0,30), 1.0f, 0);
4153+ IDirect3DDevice9_Present(lpD3D9Device, NULL, NULL, NULL, NULL);
4154+ printf("A purple filling the window\n");
4155+ getchar();
4156+
4157+
4158+ #if 0
4159+ /* More stests */
4160+ /* Test all FVF's and custom formats */
4161+ /* Test colour blending operations */
4162+ /* Test render targets */
4163+ /* Textures */
4164+ /* Materials */
4165+ /* Transforms */
4166+ /* Cube Textures */
4167+ /* Volume Textures */
4168+ /* Locking */
4169+ /* n powe of two */
4170+ /* viewports */
4171+ #endif
4172+
4173+ IDirect3DDevice9_SetStreamSource(lpD3D9Device, 0, NULL, 0, sizeof(MY_CUSTOM_VERTEX));
4174+
4175+ return TRUE;
4176+
4177+
4178+ getchar();
4179+}
4180+static void releasedirectdraw()
4181+{
4182+ if( lpD3D9Device != NULL){
4183+ IDirect3DDevice9_Release(lpD3D9Device);
4184+ }
4185+ if( lpD3D9 != NULL )
4186+ {
4187+ IDirect3D9_Release(lpD3D9);
4188+ lpD3D9 = NULL;
4189+ }
4190+}
4191+
4192+
4193+#if 0
4194+D3DXMATRIX* D3DXMatrixIdentity ( D3DXMATRIX *pOut ){
4195+
4196+ pOut->_11 = 1;
4197+ pOut->_12 = 0;
4198+ pOut->_13 = 0;
4199+ pOut->_14 = 0;
4200+
4201+ pOut->_21 = 0;
4202+ pOut->_22 = 1;
4203+ pOut->_23 = 0;
4204+ pOut->_24 = 0;
4205+
4206+ pOut->_31 = 0;
4207+ pOut->_32 = 1;
4208+ pOut->_33 = 0;
4209+ pOut->_34 = 0;
4210+
4211+ pOut->_41 = 0;
4212+ pOut->_42 = 0;
4213+ pOut->_43 = 0;
4214+ pOut->_44 = 1;
4215+
4216+ return pOut;
4217+}
4218+
4219+#endif
4220+D3DXVECTOR3 D3DXVector3(float x, float y, float z){
4221+ D3DXVECTOR3 This;
4222+ This.x = x;
4223+ This.y = y;
4224+ This.z = z;
4225+ return This;
4226+}
4227+
4228+
4229+
4230+#if 0
4231+static void adddisplaymode(LPDDSURFACEDESC lpddsd)
4232+{
4233+ if (!modes)
4234+ modes = malloc((modes_size = 2) * sizeof(DDSURFACEDESC));
4235+ if (modes_cnt == modes_size)
4236+ modes = realloc(modes, (modes_size *= 2) * sizeof(DDSURFACEDESC));
4237+ assert(modes);
4238+ modes[modes_cnt++] = *lpddsd;
4239+}
4240+
4241+static void flushdisplaymodes()
4242+{
4243+ free(modes);
4244+ modes = 0;
4245+ modes_cnt = modes_size = 0;
4246+}
4247+
4248+HRESULT WINAPI enummodescallback(LPDDSURFACEDESC lpddsd, LPVOID lpContext)
4249+{
4250+ trace("Width = %li, Height = %li, Refresh Rate = %li\r\n",
4251+ lpddsd->dwWidth, lpddsd->dwHeight,
4252+ lpddsd->UNION_MEMBER(2, dwRefreshRate));
4253+ adddisplaymode(lpddsd);
4254+
4255+ return DDENUMRET_OK;
4256+}
4257+
4258+void enumdisplaymodes()
4259+{
4260+ DDSURFACEDESC ddsd;
4261+ HRESULT rc;
4262+
4263+ ZeroMemory(&ddsd, sizeof(DDSURFACEDESC));
4264+ ddsd.dwSize = sizeof(DDSURFACEDESC);
4265+ ddsd.dwFlags = DDSD_CAPS;
4266+ ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
4267+
4268+ rc = IDirectDraw_EnumDisplayModes(lpDD,
4269+ DDEDM_STANDARDVGAMODES, &ddsd, 0, enummodescallback);
4270+ ok(rc==DD_OK,"EnumDisplayModes returned: %lx\n",rc);
4271+}
4272+
4273+static void setdisplaymode(int i)
4274+{
4275+ HRESULT rc;
4276+
4277+ rc = IDirectDraw_SetCooperativeLevel(lpDD,
4278+ hwnd, DDSCL_ALLOWMODEX | DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
4279+ ok(rc==DD_OK,"SetCooperativeLevel returned: %lx\n",rc);
4280+ if (modes[i].dwFlags & DDSD_PIXELFORMAT)
4281+ {
4282+ if (modes[i].ddpfPixelFormat.dwFlags & DDPF_RGB)
4283+ {
4284+ rc = IDirectDraw_SetDisplayMode(lpDD,
4285+ modes[i].dwWidth, modes[i].dwHeight,
4286+ modes[i].ddpfPixelFormat.UNION_MEMBER(1, dwRGBBitCount));
4287+ ok(rc==DD_OK,"SetDisplayMode returned: %lx\n",rc);
4288+ rc = IDirectDraw_RestoreDisplayMode(lpDD);
4289+ ok(rc==DD_OK,"RestoreDisplayMode returned: %lx\n",rc);
4290+
4291+ }
4292+ }
4293+}
4294+
4295+static void createsurface()
4296+{
4297+ DDSURFACEDESC ddsd;
4298+ DDSCAPS ddscaps;
4299+ HRESULT rc;
4300+
4301+ ddsd.dwSize = sizeof(ddsd);
4302+ ddsd.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT;
4303+ ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE |
4304+ DDSCAPS_FLIP |
4305+ DDSCAPS_COMPLEX;
4306+ ddsd.dwBackBufferCount = 1;
4307+ rc = IDirectDraw_CreateSurface(lpDD, &ddsd, &lpDDSPrimary, NULL );
4308+ ok(rc==DD_OK,"CreateSurface returned: %lx\n",rc);
4309+ ddscaps.dwCaps = DDSCAPS_BACKBUFFER;
4310+ rc = IDirectDrawSurface_GetAttachedSurface(lpDDSPrimary, &ddscaps, &lpDDSBack);
4311+ ok(rc==DD_OK,"GetAttachedSurface returned: %lx\n",rc);
4312+}
4313+
4314+static void destroysurface()
4315+{
4316+ if( lpDDSPrimary != NULL )
4317+ {
4318+ IDirectDrawSurface_Release(lpDDSPrimary);
4319+ lpDDSPrimary = NULL;
4320+ }
4321+}
4322+
4323+static void testsurface()
4324+{
4325+ const char* testMsg = "ddraw device context test";
4326+ HDC hdc;
4327+ HRESULT rc;
4328+
4329+ rc = IDirectDrawSurface_GetDC(lpDDSBack, &hdc);
4330+ ok(rc==DD_OK, "IDirectDrawSurface_GetDC returned: %lx\n",rc);
4331+ SetBkColor(hdc, RGB(0, 0, 255));
4332+ SetTextColor(hdc, RGB(255, 255, 0));
4333+ TextOut(hdc, 0, 0, testMsg, lstrlen(testMsg));
4334+ IDirectDrawSurface_ReleaseDC(lpDDSBack, hdc);
4335+ ok(rc==DD_OK, "IDirectDrawSurface_ReleaseDC returned: %lx\n",rc);
4336+
4337+ while (1)
4338+ {
4339+ rc = IDirectDrawSurface_Flip(lpDDSPrimary, NULL, DDFLIP_WAIT);
4340+ ok(rc==DD_OK || rc==DDERR_SURFACELOST, "IDirectDrawSurface_BltFast returned: %lx\n",rc);
4341+
4342+ if (rc == DD_OK)
4343+ {
4344+ break;
4345+ }
4346+ else if (rc == DDERR_SURFACELOST)
4347+ {
4348+ rc = IDirectDrawSurface_Restore(lpDDSPrimary);
4349+ ok(rc==DD_OK, "IDirectDrawSurface_Restore returned: %lx\n",rc);
4350+ }
4351+ }
4352+}
4353+
4354+static void testdisplaymodes()
4355+{
4356+ int i;
4357+
4358+ for (i = 0; i < modes_cnt; ++i)
4359+ {
4360+ setdisplaymode(i);
4361+ createsurface();
4362+ testsurface();
4363+ destroysurface();
4364+ }
4365+}
4366+#endif
4367+
4368+START_TEST(d3d9tests)
4369+{
4370+ createdirectdraw();
4371+ #if 0
4372+ enumdisplaymodes();
4373+ testdisplaymodes();
4374+ flushdisplaymodes();
4375+ #endif
4376+ setupDevice();
4377+ getchar();
4378+ drawSomething();
4379+ getchar();
4380+ releasedirectdraw();
4381+}
4382+
4383+
4384+
4385+#if 0
4386+
4387+/* **************************************************************
4388+* DirectX 9 Test suite for Wine
4389+* Copyright
4390+* 2005 Oliver Stieber
4391+*
4392+*
4393+*
4394+*
4395+*
4396+*
4397+*
4398+*
4399+*
4400+* Features:
4401+*
4402+*
4403+* When something on the todo list is compleate move it to the features list
4404+* TODO:
4405+* Device Creation
4406+* Device Capabilities (manual checking required?)
4407+* Creating surfaces
4408+* Surface locking
4409+* Creating textures
4410+* Texture locking
4411+* Clear
4412+* Present
4413+* Reset
4414+*
4415+**************************************************************** */
4416+
4417+/*Basic RGBA additive colours and alpha as bitwise definitions*/
4418+
4419+#DEFINE RED (1 << 0)
4420+#DEFINE GREEN (1 << 1)
4421+#DEFINE BLUE (1 << 2)
4422+#DEFINE ALPHA (1 << 3)
4423+#DEFINE YELLOW (RED | GREEN)
4424+#DEFINE CYAN (GREEN | BLUE)
4425+#DEFINE MAGENTA (RED | BLUE)
4426+#DEFINE BLACK 0
4427+#DEFINE WHITE (RED | GREEN | BLUE)
4428+
4429+/*ARGB Definitiona*/
4430+#DEFINE ARGB_RED (1 << 1)
4431+#DEFINE ARGB_GREEN (1 << 2)
4432+#DEFINE ARGB_BLUE (1 << 3)
4433+#DEFINE ARGB_ALPHA (1 << 0)
4434+
4435+
4436+#DEFINE YELLOW (ARGB_RED | ARGB_GREEN)
4437+#DEFINE CYAN (ARGB_GREEN | ARGB_BLUE)
4438+#DEFINE MAGENTA (ARGB_RED | ARGB_BLUE)
4439+#DEFINE BLACK 0
4440+#DEFINE WHITE (ARGB_RED | ARGB_GREEN | ARGB_BLUE)
4441+
4442+/*Basic definiations for diffent colour formats*/
4443+#DEFINE MAKE_R8G8B8A8(r, g, b, a) ( r | (g << 8) | (b << 16) | (a << 24))
4444+#DEFINE MAKE_R4G4B4A4(r, g, b, a) ( r | (g << 4) | (b << 8) | (a << 16))
4445+
4446+
4447+#DEFINE MAKE_A8R8G8B8(a, r, g, b) ( a | (r << 8) | ( g << 16) | (b << 24))
4448+
4449+#DEFINE MAKE_R8G8B8(r, g, b) MAKE_R8G8B8A8(r, g, b, 0) /*This may not be correct?*/
4450+#DEFINE MAKE_R8G8B8X8(r, g, b) MAKE_R8G8B8(r, g, b
4451+
4452+/*Macros to go from 1bit to many bits
4453+
4454+
4455+*/
4456+
4457+#DEFINE RED_BIT(c) ((c & 1) )
4458+#DEFINE GREEN_BIT(c) ((c & 2) >> 1)
4459+#DEFINE BLUE_BIT(c) ((c & 4) >> 2)
4460+#DEFINE ALPHA_BIT(c) ((c & 8) >> 3)
4461+
4462+#DEFINE CONVERT_TO_8(v) (v | (v << 1) | (v << 2) | (v << 3) | (v << 4) | (v << 5) | (v << 6) | (v << 7))
4463+#DEFINE CONVERT_TO_4(v) (v | (v << 1) | (v << 2) | (v << 3))
4464+
4465+#DEFINE BITCOLOUR_TO_RGBA8(c) ( MAKE_R8G8B8A8(CONVERT_TO_8(RED_BIT(c))
4466+ ,CONVERT_TO_8(GREEN_BIT(c))
4467+ ,CONVERT_TO_8(BLUE_BIT(c)
4468+ ,CONVERT_TO_8(ALPHA_BIT(c)))
4469+
4470+#DEFINE BITCOLOUR_TO_RGBA4(c) ( MAKE_R4G4B4A4(CONVERT_TO_4(RED_BIT(c))
4471+ ,CONVERT_TO_4(GREEN_BIT(c))
4472+ ,CONVERT_TO_4(BLUE_BIT(c)
4473+ ,CONVERT_TO_4(ALPHA_BIT(c)))
4474+
4475+
4476+typdef enum TEXTURESTYPES {
4477+ PASS
4478+ FAIL
4479+ PASSCHECK
4480+ FAILCHECK
4481+ PASSCHECKALPHA
4482+ FAILCHECKALPHA
4483+} TEXTURESTYPES;
4484+
4485+MAX_TEXTURE_TYPES=FAILCHECKALPHA +1;
4486+
4487+int * checkpatterns[MAX_TEXTURE_TYPES];
4488+int * checkpatterns[PASS] = { 1, GREEN };
4489+int * checkpatterns[FAIL] = { 1, RED };
4490+int * checkpatterns[PASSCHECK] = { 2, GREEN, BLACK
4491+ , BLACK, GREEN};
4492+int * checkpatterns[FAILCHECK] = { 2, RED, BLACK
4493+ , BLACK, RED};
4494+
4495+int * checkpatterns[PASSCHECKALPHA] = { 2, BLACK , RED
4496+ GREEN ,BLACK}
4497+int * checkpatterns[FAILCHECKALPHA] = { 2, BLACK , GREEN
4498+ , RED | ALPHA , RED | ALPHA};
4499+
4500+
4501+
4502+/*
4503+make a basic texture using one of the check patterns
4504+*/
4505+void * CreateTexture(TEXTURESTYPES type, int width, int height, int format){
4506+
4507+ if(height != width){
4508+ /*fail, nopow2 textures arn't supported at the moment*/
4509+ return NULL;
4510+ }
4511+ int width;
4512+ int checkWidth = width / 2;
4513+
4514+ if( type < 0 || type >= MAX_TEXTURE_TYPES ){
4515+ /*fail out of range*/
4516+ return NULL;
4517+ }
4518+ int bpp = 32;
4519+
4520+ void * result = HeapAlloc(GetProcessHeap(), 0 , width * height * (bpp >> 3));
4521+
4522+ int* pattern = checkPatterns[type];
4523+
4524+ int checks = width >> 4; /*make each check 16x16*/
4525+ /*should adjust by the pattern width or something*/
4526+ if(checks >= 0 ){
4527+ checks = 2;
4528+ }
4529+
4530+ if(pattern[0] == 1){
4531+ checks = 1;
4532+ }
4533+
4534+ int checkwidth = width/checks;
4535+ char* data = result;
4536+
4537+ for(y = 0 ; y < height; y ++){
4538+ for(u = 0 ; u < checks; u ++){
4539+ colour = BITCOLOUR_TO_RGBA8(pattern[(u % pattern[0]) + (y / checkwidth) % pattern[0]) * pattern[0]]);
4540+ for(x = 0; x < checkwidth; x++){
4541+ (*data++)=colour;
4542+ }
4543+ }
4544+ }
4545+
4546+ return result;
4547+}
4548+
4549+typedef struct Parameter {
4550+ union {
4551+ int intV;
4552+ float floatV;
4553+ void* pV;
4554+ } value;
4555+ char* name;
4556+} Parameter;
4557+
4558+void * jobs;
4559+
4560+run(TEST_CASES test){
4561+/*The test is just going to consist of a lot of functions to run in order that return pass or fail*/
4562+/*We need to do some setting up of parametes*/
4563+ for(i = 0 ; i < totaljobs; i++){
4564+ if(jobs[i](parameters) == FAIL){
4565+ return FAIL;
4566+ }
4567+ }
4568+
4569+
4570+}
4571+
4572+int createWindowInThread(Parameter* parameters){
4573+ /*Create a window with it's event loop in a seperate thread (this allows for the runction to return, leaving the window intact)*/
4574+ setIParameter(parameters,"HWND", hwnd);
4575+
4576+}
4577+
4578+int initilize(Parameter * parameters){
4579+ return PASS;
4580+}
4581+
4582+
4583+void setIParameter(Parameter* parameters, char* parametername, int value){
4584+ /*if the parameter doesn't exist create it*/
4585+}
4586+
4587+void setFParameter(Parameter* parameters, char* parametername, float value){
4588+ /*if the parameter doesn't exist create it*/
4589+}
4590+
4591+void createIParameter(Parameter* parameters, char* parametername, int value){
4592+
4593+}
4594+void createFParameter(Pa
4595+
4596+#endif
4597diff -urN wine.20050419/dlls/d3d9/texture.c wine.20050419.dx9/dlls/d3d9/texture.c
4598--- wine.20050419/dlls/d3d9/texture.c 2005-03-29 12:01:00.000000000 -0700
4599+++ wine.20050419.dx9/dlls/d3d9/texture.c 2005-04-20 01:52:56.000000000 -0600
4600@@ -212,7 +212,6 @@
4601 IDirect3DTexture9Impl_AddDirtyRect
4602 };
4603
4604-
4605 /* IDirect3DDevice9 IDirect3DTexture9 Methods follow: */
4606 HRESULT WINAPI IDirect3DDevice9Impl_CreateTexture(LPDIRECT3DDEVICE9 iface, UINT Width, UINT Height, UINT Levels, DWORD Usage,
4607 D3DFORMAT Format, D3DPOOL Pool, IDirect3DTexture9** ppTexture, HANDLE* pSharedHandle) {
4608diff -urN wine.20050419/dlls/d3d9/vertexdeclaration.c wine.20050419.dx9/dlls/d3d9/vertexdeclaration.c
4609--- wine.20050419/dlls/d3d9/vertexdeclaration.c 2005-03-02 05:16:11.000000000 -0700
4610+++ wine.20050419.dx9/dlls/d3d9/vertexdeclaration.c 2005-04-20 01:52:56.000000000 -0600
4611@@ -22,7 +22,7 @@
4612 #include "config.h"
4613 #include "d3d9_private.h"
4614
4615-WINE_DEFAULT_DEBUG_CHANNEL(d3d);
4616+WINE_DEFAULT_DEBUG_CHANNEL(d3d9);
4617
4618 /* IDirect3DVertexDeclaration9 IUnknown parts follow: */
4619 HRESULT WINAPI IDirect3DVertexDeclaration9Impl_QueryInterface(LPDIRECT3DVERTEXDECLARATION9 iface, REFIID riid, LPVOID* ppobj) {
4620@@ -30,7 +30,7 @@
4621
4622 if (IsEqualGUID(riid, &IID_IUnknown)
4623 || IsEqualGUID(riid, &IID_IDirect3DVertexDeclaration9)) {
4624- IDirect3DVertexDeclaration9Impl_AddRef(iface);
4625+ IUnknown_AddRef(iface);
4626 *ppobj = This;
4627 return D3D_OK;
4628 }
4629@@ -124,13 +124,8 @@
4630 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
4631 IDirect3DVertexDeclaration9Impl *pDeclImpl = (IDirect3DVertexDeclaration9Impl *)pDecl;
4632 HRESULT hr = S_OK;
4633-
4634- This->UpdateStateBlock->vertexDecl = NULL;
4635 if (NULL != pDecl) {
4636 hr = IWineD3DDevice_SetVertexDeclaration(This->WineD3DDevice, pDeclImpl->wineD3DVertexDeclaration);
4637- if (SUCCEEDED(hr)) {
4638- This->UpdateStateBlock->vertexDecl = (IDirect3DVertexDeclaration9Impl*) pDecl;
4639- }
4640 }
4641 return hr;
4642 }
4643@@ -139,15 +134,19 @@
4644 IDirect3DDevice9Impl* This = (IDirect3DDevice9Impl*) iface;
4645 IWineD3DVertexDeclaration* pTest = NULL;
4646 HRESULT hr = S_OK;
4647- IDirect3DVertexDeclaration9Impl* pCur = This->StateBlock->vertexDecl;
4648
4649 if (NULL == ppDecl) {
4650 return D3DERR_INVALIDCALL;
4651 }
4652 *ppDecl = NULL;
4653 hr = IWineD3DDevice_GetVertexDeclaration(This->WineD3DDevice, &pTest);
4654- if (SUCCEEDED(hr) && (NULL == pCur || pCur->wineD3DVertexDeclaration == pTest)) {
4655- *ppDecl = (IDirect3DVertexDeclaration9*) pCur;
4656+ if(NULL != pTest){
4657+ IWineD3DResource_GetParent(pTest, (IUnknown **)ppDecl);
4658+ IWineD3DResource_Release(pTest);
4659+ }else{
4660+ *ppDecl = (IDirect3DVertexDeclaration9*)NULL;
4661 }
4662+
4663+ TRACE("(%p) : returning %p\n", This, *ppDecl);
4664 return hr;
4665 }
4666diff -urN wine.20050419/dlls/d3d9/vertexshader.c wine.20050419.dx9/dlls/d3d9/vertexshader.c
4667--- wine.20050419/dlls/d3d9/vertexshader.c 2005-01-24 05:44:01.000000000 -0700
4668+++ wine.20050419.dx9/dlls/d3d9/vertexshader.c 2005-04-20 01:52:56.000000000 -0600
4669@@ -22,7 +22,7 @@
4670 #include "config.h"
4671 #include "d3d9_private.h"
4672
4673-WINE_DEFAULT_DEBUG_CHANNEL(d3d_shader);
4674+WINE_DEFAULT_DEBUG_CHANNEL(d3d9);
4675
4676 /* IDirect3DVertexShader9 IUnknown parts follow: */
4677 HRESULT WINAPI IDirect3DVertexShader9Impl_QueryInterface(LPDIRECT3DVERTEXSHADER9 iface, REFIID riid, LPVOID* ppobj) {
4678@@ -30,7 +30,7 @@
4679
4680 if (IsEqualGUID(riid, &IID_IUnknown)
4681 || IsEqualGUID(riid, &IID_IDirect3DVertexShader9)) {
4682- IDirect3DVertexShader9Impl_AddRef(iface);
4683+ IUnknown_AddRef(iface);
4684 *ppobj = This;
4685 return D3D_OK;
4686 }
4687@@ -55,7 +55,9 @@
4688 TRACE("(%p) : ReleaseRef to %ld\n", This, ref);
4689
4690 if (ref == 0) {
4691+ IWineD3DVertexShader_Release(This->wineD3DVertexShader);
4692 HeapFree(GetProcessHeap(), 0, This);
4693+
4694 }
4695 return ref;
4696 }
4697@@ -63,16 +65,22 @@
4698 /* IDirect3DVertexShader9 Interface follow: */
4699 HRESULT WINAPI IDirect3DVertexShader9Impl_GetDevice(LPDIRECT3DVERTEXSHADER9 iface, IDirect3DDevice9** ppDevice) {
4700 IDirect3DVertexShader9Impl *This = (IDirect3DVertexShader9Impl *)iface;
4701- TRACE("(%p) : returning %p\n", This, This->Device);
4702- *ppDevice = (LPDIRECT3DDEVICE9) This->Device;
4703- IDirect3DDevice9Impl_AddRef(*ppDevice);
4704+ IWineD3DDevice *myDevice = NULL;
4705+
4706+ TRACE("(%p) : Relay\n", This);
4707+
4708+ IWineD3DVertexShader_GetDevice(This->wineD3DVertexShader, &myDevice);
4709+ IWineD3DDevice_GetParent(myDevice, (IUnknown **)ppDevice);
4710+ IWineD3DDevice_Release(myDevice);
4711+ TRACE("(%p) returing (%p)", This, *ppDevice);
4712 return D3D_OK;
4713 }
4714
4715 HRESULT WINAPI IDirect3DVertexShader9Impl_GetFunction(LPDIRECT3DVERTEXSHADER9 iface, VOID* pData, UINT* pSizeOfData) {
4716 IDirect3DVertexShader9Impl *This = (IDirect3DVertexShader9Impl *)iface;
4717- FIXME("(%p) : stub\n", This);
4718- return D3D_OK;
4719+
4720+ TRACE("(%p) : Relay\n", This);
4721+ return IWineD3DVertexShader_GetFunction(This->wineD3DVertexShader, pData, pSizeOfData);
4722 }
4723
4724
4725@@ -89,148 +97,92 @@
4726 /* IDirect3DDevice9 IDirect3DVertexShader9 Methods follow: */
4727 HRESULT WINAPI IDirect3DDevice9Impl_CreateVertexShader(LPDIRECT3DDEVICE9 iface, CONST DWORD* pFunction, IDirect3DVertexShader9** ppShader) {
4728 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
4729- FIXME("(%p) : stub\n", This);
4730+ HRESULT hrc = D3D_OK;
4731+ IDirect3DVertexShader9Impl *object;
4732+
4733+ FIXME("(%p) : Relay (disabled) \n", This);
4734+ *ppShader = NULL;
4735 return D3D_OK;
4736+ /* Setup a stub object for now */
4737+ object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
4738+ TRACE("(%p) : pFunction(%p), ppShader(%p)\n", This, pFunction, ppShader);
4739+ if (NULL == object) {
4740+ FIXME("Allocation of memory failed\n");
4741+ *ppShader = NULL;
4742+ return D3DERR_OUTOFVIDEOMEMORY;
4743+ }
4744+
4745+ object->ref = 1;
4746+ object->lpVtbl = &Direct3DVertexShader9_Vtbl;
4747+ hrc= IWineD3DDevice_CreateVertexShader(This->WineD3DDevice, pFunction, &object->wineD3DVertexShader, (IUnknown *)object);
4748+
4749+ if (FAILED(hrc)) {
4750+ /* free up object */
4751+ FIXME("Call to IWineD3DDevice_CreateVertexShader failed\n");
4752+ HeapFree(GetProcessHeap(), 0, object);
4753+ *ppShader = NULL;
4754+ }else{
4755+ *ppShader = (IDirect3DVertexShader9 *)object;
4756+ }
4757+
4758+ TRACE("(%p) : returning %p\n", This, *ppShader);
4759+ return hrc;
4760 }
4761
4762 HRESULT WINAPI IDirect3DDevice9Impl_SetVertexShader(LPDIRECT3DDEVICE9 iface, IDirect3DVertexShader9* pShader) {
4763 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
4764-
4765- This->UpdateStateBlock->VertexShader = pShader;
4766- This->UpdateStateBlock->Changed.vertexShader = TRUE;
4767- This->UpdateStateBlock->Set.vertexShader = TRUE;
4768-
4769- /* Handle recording of state blocks */
4770- if (This->isRecordingState) {
4771- TRACE("Recording... not performing anything\n");
4772- return D3D_OK;
4773- }
4774- /**
4775- * TODO: merge HAL shaders context switching from prototype
4776- */
4777+ TRACE("(%p) : Relay (disabled) \n", This);
4778 return D3D_OK;
4779+ return IWineD3DDevice_SetVertexShader(This->WineD3DDevice, pShader==NULL?NULL:((IDirect3DVertexShader9Impl *)pShader)->wineD3DVertexShader);
4780 }
4781
4782 HRESULT WINAPI IDirect3DDevice9Impl_GetVertexShader(LPDIRECT3DDEVICE9 iface, IDirect3DVertexShader9** ppShader) {
4783 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
4784- TRACE("(%p) : GetVertexShader returning %p\n", This, This->StateBlock->VertexShader);
4785- *ppShader = This->StateBlock->VertexShader;
4786- IDirect3DVertexShader9Impl_AddRef(*ppShader);
4787- return D3D_OK;
4788+ IWineD3DVertexShader *pShader;
4789+ HRESULT hrc = D3D_OK;
4790+ hrc = IWineD3DDevice_GetVertexShader(This->WineD3DDevice, &pShader);
4791+ if(hrc == D3D_OK){
4792+ hrc = IWineD3DVertexShader_GetParent(pShader, (IUnknown **)ppShader);
4793+ IWineD3DVertexShader_Release(pShader);
4794+ }
4795+ TRACE("(%p) : returning %p\n", This, *ppShader);
4796+ return hrc;
4797 }
4798
4799 HRESULT WINAPI IDirect3DDevice9Impl_SetVertexShaderConstantF(LPDIRECT3DDEVICE9 iface, UINT Register, CONST float* pConstantData, UINT Vector4fCount) {
4800 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
4801-
4802- if (Register + Vector4fCount > D3D_VSHADER_MAX_CONSTANTS) {
4803- ERR("(%p) : SetVertexShaderConstant C[%u] invalid\n", This, Register);
4804- return D3DERR_INVALIDCALL;
4805- }
4806- if (NULL == pConstantData) {
4807- return D3DERR_INVALIDCALL;
4808- }
4809- if (Vector4fCount > 1) {
4810- CONST FLOAT* f = pConstantData;
4811- UINT i;
4812- TRACE("(%p) : SetVertexShaderConstant C[%u..%u]=\n", This, Register, Register + Vector4fCount - 1);
4813- for (i = 0; i < Vector4fCount; ++i) {
4814- TRACE("{%f, %f, %f, %f}\n", f[0], f[1], f[2], f[3]);
4815- f += 4;
4816- }
4817- } else {
4818- const FLOAT* f = (const FLOAT*) pConstantData;
4819- TRACE("(%p) : SetVertexShaderConstant, C[%u]={%f, %f, %f, %f}\n", This, Register, f[0], f[1], f[2], f[3]);
4820- }
4821- This->UpdateStateBlock->Changed.vertexShaderConstant = TRUE;
4822- memcpy(&This->UpdateStateBlock->vertexShaderConstantF[Register], pConstantData, Vector4fCount * 4 * sizeof(FLOAT));
4823- return D3D_OK;
4824+ TRACE("(%p) : Relay\n", This);
4825+ return IWineD3DDevice_SetVertexShaderConstantF(This->WineD3DDevice, Register, pConstantData, Vector4fCount);
4826 }
4827
4828 HRESULT WINAPI IDirect3DDevice9Impl_GetVertexShaderConstantF(LPDIRECT3DDEVICE9 iface, UINT Register, float* pConstantData, UINT Vector4fCount) {
4829 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
4830-
4831- TRACE("(%p) : C[%u] count=%u\n", This, Register, Vector4fCount);
4832- if (Register + Vector4fCount > D3D_VSHADER_MAX_CONSTANTS) {
4833- return D3DERR_INVALIDCALL;
4834- }
4835- if (NULL == pConstantData) {
4836- return D3DERR_INVALIDCALL;
4837- }
4838- memcpy(pConstantData, &This->UpdateStateBlock->vertexShaderConstantF[Register], Vector4fCount * 4 * sizeof(FLOAT));
4839- return D3D_OK;
4840+ TRACE("(%p) : Relay\n", This);
4841+ return IWineD3DDevice_GetVertexShaderConstantF(This->WineD3DDevice, Register, pConstantData, Vector4fCount);
4842 }
4843
4844 HRESULT WINAPI IDirect3DDevice9Impl_SetVertexShaderConstantI(LPDIRECT3DDEVICE9 iface, UINT Register, CONST int* pConstantData, UINT Vector4iCount) {
4845 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
4846-
4847- if (Register + Vector4iCount > D3D_VSHADER_MAX_CONSTANTS) {
4848- ERR("(%p) : SetVertexShaderConstantI C[%u] invalid\n", This, Register);
4849- return D3DERR_INVALIDCALL;
4850- }
4851- if (NULL == pConstantData) {
4852- return D3DERR_INVALIDCALL;
4853- }
4854- if (Vector4iCount > 1) {
4855- CONST int* f = pConstantData;
4856- UINT i;
4857- TRACE("(%p) : SetVertexShaderConstantI C[%u..%u]=\n", This, Register, Register + Vector4iCount - 1);
4858- for (i = 0; i < Vector4iCount; ++i) {
4859- TRACE("{%d, %d, %d, %d}\n", f[0], f[1], f[2], f[3]);
4860- f += 4;
4861- }
4862- } else {
4863- CONST int* f = pConstantData;
4864- TRACE("(%p) : SetVertexShaderConstantI, C[%u]={%i, %i, %i, %i}\n", This, Register, f[0], f[1], f[2], f[3]);
4865- }
4866- This->UpdateStateBlock->Changed.vertexShaderConstant = TRUE;
4867- memcpy(&This->UpdateStateBlock->vertexShaderConstantI[Register], pConstantData, Vector4iCount * 4 * sizeof(int));
4868- return D3D_OK;
4869+ TRACE("(%p) : Relay\n", This);
4870+ return IWineD3DDevice_SetVertexShaderConstantI(This->WineD3DDevice, Register, pConstantData, Vector4iCount);
4871 }
4872
4873 HRESULT WINAPI IDirect3DDevice9Impl_GetVertexShaderConstantI(LPDIRECT3DDEVICE9 iface, UINT Register, int* pConstantData, UINT Vector4iCount) {
4874 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
4875+ TRACE("(%p) : Relay\n", This);
4876+ return IWineD3DDevice_GetVertexShaderConstantI(This->WineD3DDevice, Register, pConstantData, Vector4iCount);
4877
4878- TRACE("(%p) : C[%u] count=%u\n", This, Register, Vector4iCount);
4879- if (Register + Vector4iCount > D3D_VSHADER_MAX_CONSTANTS) {
4880- return D3DERR_INVALIDCALL;
4881- }
4882- if (NULL == pConstantData) {
4883- return D3DERR_INVALIDCALL;
4884- }
4885- memcpy(pConstantData, &This->UpdateStateBlock->vertexShaderConstantI[Register], Vector4iCount * 4 * sizeof(FLOAT));
4886- return D3D_OK;
4887 }
4888
4889 HRESULT WINAPI IDirect3DDevice9Impl_SetVertexShaderConstantB(LPDIRECT3DDEVICE9 iface, UINT Register, CONST BOOL* pConstantData, UINT BoolCount) {
4890 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
4891- UINT i;
4892-
4893- if (Register + BoolCount > D3D_VSHADER_MAX_CONSTANTS) {
4894- ERR("(%p) : SetVertexShaderConstantB C[%u] invalid\n", This, Register);
4895- return D3DERR_INVALIDCALL;
4896- }
4897- if (NULL == pConstantData) {
4898- return D3DERR_INVALIDCALL;
4899- }
4900- if (BoolCount > 1) {
4901- CONST BOOL* f = pConstantData;
4902- TRACE("(%p) : SetVertexShaderConstantB C[%u..%u]=\n", This, Register, Register + BoolCount - 1);
4903- for (i = 0; i < BoolCount; ++i) {
4904- TRACE("{%u}\n", f[i]);
4905- }
4906- } else {
4907- CONST BOOL* f = pConstantData;
4908- TRACE("(%p) : SetVertexShaderConstantB, C[%u]={%u}\n", This, Register, f[0]);
4909- }
4910- This->UpdateStateBlock->Changed.vertexShaderConstant = TRUE;
4911- for (i = 0; i < BoolCount; ++i) {
4912- This->UpdateStateBlock->vertexShaderConstantB[Register] = pConstantData[i];
4913- }
4914- return D3D_OK;
4915+ TRACE("(%p) : Relay\n", This);
4916+ return IWineD3DDevice_SetVertexShaderConstantB(This->WineD3DDevice, Register, pConstantData, BoolCount);
4917 }
4918
4919 HRESULT WINAPI IDirect3DDevice9Impl_GetVertexShaderConstantB(LPDIRECT3DDEVICE9 iface, UINT Register, BOOL* pConstantData, UINT BoolCount) {
4920 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
4921- FIXME("(%p) : stub\n", This);
4922- return D3D_OK;
4923+ TRACE("(%p) : Relay\n", This);
4924+ return IWineD3DDevice_GetVertexShaderConstantB(This->WineD3DDevice, Register, pConstantData, BoolCount);
4925+
4926 }
4927diff -urN wine.20050419/dlls/d3d9/volume.c wine.20050419.dx9/dlls/d3d9/volume.c
4928--- wine.20050419/dlls/d3d9/volume.c 2005-03-29 12:01:00.000000000 -0700
4929+++ wine.20050419.dx9/dlls/d3d9/volume.c 2005-04-20 01:52:56.000000000 -0600
4930@@ -114,6 +114,8 @@
4931
4932 TRACE("(%p) Relay\n", This);
4933
4934+ TRACE("(%p) Relay\n", This);
4935+
4936 /* As d3d8 and d3d9 structures differ, pass in ptrs to where data needs to go */
4937 wined3ddesc.Format = &pDesc->Format;
4938 wined3ddesc.Type = &pDesc->Type;
4939@@ -155,6 +157,7 @@
4940 };
4941
4942
4943+
4944 /* Internal function called back during the CreateVolumeTexture */
4945 HRESULT WINAPI D3D9CB_CreateVolume(IUnknown *pDevice, UINT Width, UINT Height, UINT Depth,
4946 WINED3DFORMAT Format, D3DPOOL Pool, DWORD Usage,
4947diff -urN wine.20050419/dlls/d3d9/volumetexture.c wine.20050419.dx9/dlls/d3d9/volumetexture.c
4948--- wine.20050419/dlls/d3d9/volumetexture.c 2005-03-29 12:01:00.000000000 -0700
4949+++ wine.20050419.dx9/dlls/d3d9/volumetexture.c 2005-04-20 01:52:56.000000000 -0600
4950@@ -157,6 +157,8 @@
4951
4952 TRACE("(%p) Relay\n", This);
4953
4954+ TRACE("(%p) Relay\n", This);
4955+
4956 /* As d3d8 and d3d9 structures differ, pass in ptrs to where data needs to go */
4957 wined3ddesc.Format = &pDesc->Format;
4958 wined3ddesc.Type = &pDesc->Type;
4959@@ -243,6 +245,8 @@
4960
4961 TRACE("(%p) Relay\n", This);
4962
4963+ TRACE("(%p) Relay\n", This);
4964+
4965 /* Allocate the storage for the device */
4966 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3DVolumeTexture9Impl));
4967 if (NULL == object) {
4968diff -urN wine.20050419/dlls/d3dx9/.cvsignore wine.20050419.dx9/dlls/d3dx9/.cvsignore
4969--- wine.20050419/dlls/d3dx9/.cvsignore 1969-12-31 17:00:00.000000000 -0700
4970+++ wine.20050419.dx9/dlls/d3dx9/.cvsignore 2005-04-20 01:52:56.000000000 -0600
4971@@ -0,0 +1,3 @@
4972+Makefile
4973+d3dx8.dll.dbg.c
4974+d3dx8.spec.def
4975diff -urN wine.20050419/dlls/d3dx9/Makefile.in wine.20050419.dx9/dlls/d3dx9/Makefile.in
4976--- wine.20050419/dlls/d3dx9/Makefile.in 1969-12-31 17:00:00.000000000 -0700
4977+++ wine.20050419.dx9/dlls/d3dx9/Makefile.in 2005-04-20 01:52:56.000000000 -0600
4978@@ -0,0 +1,17 @@
4979+TOPSRCDIR = @top_srcdir@
4980+TOPOBJDIR = ../..
4981+SRCDIR = @srcdir@
4982+VPATH = @srcdir@
4983+MODULE = d3dx9.dll
4984+IMPORTS = d3d9 user32 gdi32 kernel32
4985+EXTRAINCL = @X_CFLAGS@
4986+EXTRALIBS = -ldxguid -luuid @X_LIBS@ @X_PRE_LIBS@ @XLIB@ @X_EXTRA_LIBS@ @OPENGL_LIBS@
4987+
4988+C_SRCS = \
4989+ d3dx9_main.c \
4990+ d3dxbuffer.c \
4991+ font.c
4992+
4993+@MAKE_DLL_RULES@
4994+
4995+### Dependencies:
4996diff -urN wine.20050419/dlls/d3dx9/d3dx9.spec wine.20050419.dx9/dlls/d3dx9/d3dx9.spec
4997--- wine.20050419/dlls/d3dx9/d3dx9.spec 1969-12-31 17:00:00.000000000 -0700
4998+++ wine.20050419.dx9/dlls/d3dx9/d3dx9.spec 2005-04-20 01:52:56.000000000 -0600
4999@@ -0,0 +1,60 @@
5000+@ stdcall D3DXCreateBuffer(long ptr)
5001+@ stdcall D3DXCreateFontA(ptr long long long long long long long long long ptr ptr)
5002+@ stdcall D3DXGetFVFVertexSize(long)
5003+@ stdcall D3DXAssembleShader(ptr long long ptr ptr ptr)
5004+@ stdcall D3DXAssembleShaderFromFileA(ptr long ptr ptr ptr)
5005+@ stdcall D3DXAssembleShaderFromFileW(ptr long ptr ptr ptr)
5006+@ stdcall D3DXCreateTextureFromFile(ptr ptr ptr)
5007+@ stdcall D3DXMatrixPerspectiveFovLH(ptr double double double double)
5008+@ stdcall D3DXVec4Add(ptr ptr ptr)
5009+@ stdcall D3DXVec3Add(ptr ptr ptr)
5010+@ stdcall D3DXVec2Add(ptr ptr ptr)
5011+@ stdcall D3DXVec4Subtract(ptr ptr ptr)
5012+@ stdcall D3DXVec3Subtract(ptr ptr ptr)
5013+@ stdcall D3DXVec2Subtract(ptr ptr ptr)
5014+@ stdcall D3DXVec2Dot(ptr ptr)
5015+@ stdcall D3DXVec3Dot(ptr ptr)
5016+@ stdcall D3DXVec4Dot(ptr ptr)
5017+@ stdcall D3DXVec4Cross(ptr ptr ptr ptr)
5018+@ stdcall D3DXVec3Cross(ptr ptr ptr)
5019+@ stdcall D3DXVec4Scale(ptr ptr double)
5020+@ stdcall D3DXVec3Scale(ptr ptr double)
5021+@ stdcall D3DXVec2Scale(ptr ptr double)
5022+@ stdcall D3DXVec2LengthSq(ptr)
5023+@ stdcall D3DXVec2Length(ptr)
5024+@ stdcall D3DXVec3LengthSq(ptr)
5025+@ stdcall D3DXVec3Length(ptr)
5026+@ stdcall D3DXVec4LengthSq(ptr)
5027+@ stdcall D3DXVec4Length(ptr)
5028+@ stdcall D3DXVec3Normalize(ptr ptr)
5029+@ stdcall D3DXMatrixTranslation(ptr double double double)
5030+@ stdcall D3DXMatrixDeterminant(ptr)
5031+@ stdcall D3DXMatrixInverse(ptr ptr ptr)
5032+@ stdcall D3DXMatrixRotationYawPitchRoll(ptr double double double)
5033+@ stdcall D3DXMatrixRotationQuaternion(ptr ptr)
5034+@ stdcall D3DXMatrixRotationAxis(ptr ptr double)
5035+@ stdcall D3DXMatrixReflect(ptr ptr)
5036+@ stdcall D3DXMatrixDecompose(ptr ptr ptr ptr)
5037+@ stdcall D3DXMatrixLookAtRH(ptr ptr ptr ptr)
5038+@ stdcall D3DXMatrixLookAtLH(ptr ptr ptr ptr)
5039+@ stdcall D3DXFloat32To16Array(ptr ptr long)
5040+@ stdcall D3DXFloat16To32Array(ptr ptr long)
5041+@ stdcall D3DXColorSubtract(ptr ptr ptr)
5042+@ stdcall D3DXColorScale(ptr ptr double)
5043+@ stdcall D3DXColorNegative(ptr ptr)
5044+@ stdcall D3DXColorModulate(ptr ptr ptr)
5045+@ stdcall D3DXColorLerp(ptr ptr ptr double)
5046+@ stdcall D3DXColorAdjustSaturation(ptr ptr double)
5047+@ stdcall D3DXColorAdjustContrast(ptr ptr double)
5048+@ stdcall D3DXColorAdd(ptr ptr ptr)
5049+@ stdcall D3DXPlaneNormalize(ptr ptr)
5050+@ stdcall D3DXPlaneScale(ptr ptr double)
5051+@ stdcall D3DXPlaneLength(ptr)
5052+@ stdcall D3DXMatrixShadow(ptr ptr ptr)
5053+@ stdcall D3DXMatrixScaling(ptr double double double)
5054+@ stdcall D3DXMatrixRotationZ(ptr double)
5055+@ stdcall D3DXMatrixRotationY(ptr double)
5056+@ stdcall D3DXMatrixRotationX(ptr double)
5057+@ stdcall D3DXMatrixMultiply(ptr ptr ptr)
5058+@ stdcall D3DXMatrixOrthoLH(ptr double double double double)
5059+@ stdcall D3DXMatrixOrthoRH(ptr double double double double)
5060\ No newline at end of file
5061diff -urN wine.20050419/dlls/d3dx9/d3dx9_main.c wine.20050419.dx9/dlls/d3dx9/d3dx9_main.c
5062--- wine.20050419/dlls/d3dx9/d3dx9_main.c 1969-12-31 17:00:00.000000000 -0700
5063+++ wine.20050419.dx9/dlls/d3dx9/d3dx9_main.c 2005-04-20 01:52:56.000000000 -0600
5064@@ -0,0 +1,1861 @@
5065+/*
5066+ * Direct3D X 9 main file
5067+ *
5068+ * Copyright (C) 2005 Oliver Stieber
5069+ *
5070+ * This library is free software; you can redistribute it and/or
5071+ * modify it under the terms of the GNU Lesser General Public
5072+ * License as published by the Free Software Foundation; either
5073+ * version 2.1 of the License, or (at your option) any later version.
5074+ *
5075+ * This library is distributed in the hope that it will be useful,
5076+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
5077+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
5078+ * Lesser General Public License for more details.
5079+ *
5080+ * You should have received a copy of the GNU Lesser General Public
5081+ * License along with this library; if not, write to the Free Software
5082+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
5083+ *
5084+ */
5085+
5086+#include "config.h"
5087+#include "wine/port.h"
5088+
5089+#include <stdarg.h>
5090+
5091+#include "windef.h"
5092+#include "winbase.h"
5093+#include "wingdi.h"
5094+#include "winuser.h"
5095+#include "wine/debug.h"
5096+#include <d3d9.h>
5097+#include <d3dx9.h>
5098+#include "d3dx9core_private.h"
5099+#include <d3dx9math.h>
5100+
5101+
5102+WINE_DEFAULT_DEBUG_CHANNEL(d3d);
5103+typedef enum _predefinedtextures {
5104+WINE_PDT_DEFAULT = 0,
5105+WINE_PDT_CROSS,
5106+CHECK_COMPLEX,
5107+CHECK_BIG,
5108+WINE_PDT_NONE = 0xffffff
5109+}predefinedtextures;
5110+
5111+HRESULT WINAPI D3DXCreateTextureFromFile(LPDIRECT3DDEVICE9 pDevice, LPSTR pSrcFile, LPDIRECT3DTEXTURE9 *ppTexture){
5112+/**
5113+It may be a 'good' idea to give this function some 'magic' values for testing that load
5114+predefiend textures
5115+Create a texture, this ones just going to be a x and not a
5116+
5117+
5118+**/
5119+ int predfinedTexture = CHECK_BIG;
5120+ LPDIRECT3DSURFACE9 pSurface;
5121+
5122+ IDirect3DDevice9_CreateTexture(pDevice, 256,256,1,0,D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, ppTexture, NULL);
5123+ IDirect3DTexture9_GetSurfaceLevel(*ppTexture, 0, &pSurface);
5124+
5125+ if((int)pSrcFile < 0){
5126+ predfinedTexture = -((int)pSrcFile);
5127+ }
5128+ /*Draw a multi coloured cross on the texture*/
5129+ switch (predfinedTexture){
5130+ /*could test colour rect here too*/
5131+ case WINE_PDT_NONE:
5132+ break;
5133+ case CHECK_BIG:
5134+
5135+ {
5136+ /*This is a variation of a checkerboard using 4 bits (or 16 different check patterens)*/
5137+ /*I'm going to make the squares 8x8 so that the pattern repeats twice on the board, there should be 4 checks of each combination of RGBA*/
5138+ D3DLOCKED_RECT lockedRect;
5139+ int *data;
5140+ int u,v,x;
5141+
5142+ IDirect3DSurface9_LockRect(pSurface, &lockedRect, NULL, 0);
5143+ data = (int*)(lockedRect.pBits);
5144+ for(u = 0; u < 256; u ++){
5145+ for(v = 0; v < 8 ; v ++){
5146+ int check = (v + (u >> 5)) & 0x01; /*This is my check colour (1 bit per pixel!)*/
5147+ int colour = (check&1?255:0) | (check&1?255:0) << 8 | (check&1?255:0) << 16 | (check&1?255:0) << 24;
5148+ /*I could do this in 8x8 blocks which may get mmx'ed and be nice and quick
5149+ the other option is to do a streight run
5150+ */
5151+ for( x = 0 ; x < 32 ; x ++){
5152+ *data=colour;
5153+ data++;
5154+ }
5155+ }
5156+ }
5157+ }
5158+ IDirect3DSurface9_UnlockRect(pSurface);
5159+
5160+ break;
5161+
5162+ case CHECK_COMPLEX:
5163+ {
5164+ /*This is a variation of a checkerboard using 4 bits (or 16 different check patterens)*/
5165+ /*I'm going to make the squares 8x8 so that the pattern repeats twice on the board, there should be 4 checks of each combination of RGBA*/
5166+ D3DLOCKED_RECT lockedRect;
5167+ int *data;
5168+ int u,v,x;
5169+
5170+ IDirect3DSurface9_LockRect(pSurface, &lockedRect, NULL, 0);
5171+ data = (int*)(lockedRect.pBits);
5172+ for(u = 0; u < 256; u ++){
5173+ for(v = 0; v < 32 ; v ++){
5174+ int check = (v + ((u >> 4) << 2)) & 0x0F; /*This is my check colour (1 bit per pixel!)*/
5175+ int colour = (check&1?255:0) | (check&2?255:0) << 8 | (check&4?255:0) << 16 | (check&8?255:0) << 24;
5176+ /*I could do this in 8x8 blocks which may get mmx'ed and be nice and quick
5177+ the other option is to do a streight run
5178+ */
5179+ for( x = 0 ; x < 8 ; x ++){
5180+ *data=colour;
5181+ data++;
5182+ }
5183+ }
5184+ }
5185+ }
5186+ IDirect3DSurface9_UnlockRect(pSurface);
5187+
5188+ break;
5189+ case WINE_PDT_CROSS:
5190+ default:
5191+ {
5192+ D3DLOCKED_RECT lockedRect;
5193+ int x;
5194+ int *data;
5195+ int colour =255 | 255 << 8 | 255 << 16 | 255 << 24;
5196+ int colourr =255 | 255 << 24;
5197+ int colourg = 255 << 8 | 255 << 24;
5198+ int colourb = 255 << 16 | 255 << 24;
5199+
5200+ IDirect3DSurface9_LockRect(pSurface, &lockedRect, NULL, 0);
5201+ data = (int*)(lockedRect.pBits);
5202+ /*Draw an X on the texture*/
5203+ for(x =0;x<128;x++){
5204+ data[x + x*256] = colour;
5205+ data[255-x + x*256] = colourr;
5206+ data[x + (256*255)-x*256] = colourg;
5207+ data[255-x + (256*255)-x*256] = colourb;
5208+ }
5209+ IDirect3DSurface9_UnlockRect(pSurface);
5210+ }
5211+ }
5212+ return D3D_OK;
5213+}
5214+
5215+HRESULT WINAPI D3DXCreateBuffer(DWORD NumBytes, LPD3DXBUFFER* ppBuffer) {
5216+ ID3DXBufferImpl *object;
5217+
5218+ object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(ID3DXBufferImpl));
5219+ if (NULL == object) {
5220+ *ppBuffer = (LPD3DXBUFFER)NULL;
5221+ return E_OUTOFMEMORY;
5222+ }
5223+ object->lpVtbl = &D3DXBuffer_Vtbl;
5224+ object->ref = 1;
5225+ object->bufferSize = NumBytes;
5226+ object->buffer = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, NumBytes);
5227+ if (NULL == object->buffer) {
5228+ HeapFree(GetProcessHeap(), 0, object);
5229+ *ppBuffer = (LPD3DXBUFFER)NULL;
5230+ return E_OUTOFMEMORY;
5231+ }
5232+ *ppBuffer = (LPD3DXBUFFER)object;
5233+ return D3D_OK;
5234+}
5235+
5236+HRESULT WINAPI D3DXCreateFont(LPDIRECT3DDEVICE9 pDevice,
5237+ UINT Height,
5238+ UINT Width,
5239+ UINT Weight,
5240+ UINT MipLevels,
5241+ BOOL Italic,
5242+ DWORD CharSet,
5243+ DWORD OutputPrecision,
5244+ DWORD Quality,
5245+ DWORD PitchAndFamily,
5246+ LPCSTR pFaceName,
5247+ LPD3DXFONT* ppFont) {
5248+ ID3DXFontImpl* object;
5249+ FIXME("(void): stub\n");
5250+ object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(ID3DXFontImpl));
5251+ object->lpVtbl = &D3DXFont_Vtbl;
5252+ object->ref = 1;
5253+ object->device = pDevice;
5254+ return D3D_OK;
5255+}
5256+#if 0
5257+
5258+HRESULT WINAPI
5259+ D3DXCreateFontA(
5260+ LPDIRECT3DDEVICE9 pDevice,
5261+ UINT Height,
5262+ UINT Width,
5263+ UINT Weight,
5264+ UINT MipLevels,
5265+ BOOL Italic,
5266+ DWORD CharSet,
5267+ DWORD OutputPrecision,
5268+ DWORD Quality,
5269+ DWORD PitchAndFamily,
5270+ LPCSTR pFaceName,
5271+ LPD3DXFONT* ppFont){
5272+
5273+}{
5274+ ID3DXFontImpl* object;
5275+ object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(ID3DXFontImpl));
5276+ object->lpVtbl = &D3DXFont_Vtbl;
5277+ object->ref = 1;
5278+ object->device = pDevice;
5279+ IDirect3DDevice9_AddRef(pDevice);
5280+
5281+ *LPD3DXFONT = (LPD3DXFONT)object;
5282+ FIXME("(void): stub\n");
5283+ return D3D_OK;
5284+}
5285+
5286+HRESULT WINAPI
5287+ D3DXCreateFontW(
5288+ LPDIRECT3DDEVICE9 pDevice,
5289+ UINT Height,
5290+ UINT Width,
5291+ UINT Weight,
5292+ UINT MipLevels,
5293+ BOOL Italic,
5294+ DWORD CharSet,
5295+ DWORD OutputPrecision,
5296+ DWORD Quality,
5297+ DWORD PitchAndFamily,
5298+ LPSTR pFaceName,
5299+ LPD3DXFONT* ppFont){
5300+ ID3DXFontImpl* object;
5301+ object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(ID3DXFontImpl));
5302+ object->lpVtbl = &D3DXFont_Vtbl;
5303+ object->ref = 1;
5304+ *LPD3DXFONT = (LPD3DXFONT)object;
5305+ FIXME("(void): stub\n");
5306+ /*I need an WtoA function and then call the unicode version of this function.*/
5307+ return D3D_OK;
5308+
5309+}
5310+#endif
5311+
5312+
5313+
5314+UINT WINAPI D3DXGetFVFVertexSize(DWORD FVF) {
5315+ FIXME("(void): stub\n");
5316+ return 0;
5317+}
5318+
5319+HRESULT WINAPI D3DXAssembleShader(LPCVOID pSrcData, UINT SrcDataLen, DWORD Flags,
5320+ LPD3DXBUFFER* ppConstants,
5321+ LPD3DXBUFFER* ppCompiledShader,
5322+ LPD3DXBUFFER* ppCompilationErrors) {
5323+ FIXME("(void): stub\n");
5324+ return D3D_OK;
5325+}
5326+
5327+HRESULT WINAPI D3DXAssembleShaderFromFileA(LPSTR pSrcFile, DWORD Flags,
5328+ LPD3DXBUFFER* ppConstants,
5329+ LPD3DXBUFFER* ppCompiledShader,
5330+ LPD3DXBUFFER* ppCompilationErrors) {
5331+ FIXME("(void): stub\n");
5332+ return D3D_OK;
5333+}
5334+
5335+HRESULT WINAPI D3DXAssembleShaderFromFileW(LPSTR pSrcFile, DWORD Flags,
5336+ LPD3DXBUFFER* ppConstants,
5337+ LPD3DXBUFFER* ppCompiledShader,
5338+ LPD3DXBUFFER* ppCompilationErrors) {
5339+ FIXME("(void): stub\n");
5340+ return D3D_OK;
5341+}
5342+
5343+D3DXMATRIX *WINAPI D3DXMatrixAffineTransformation(D3DXMATRIX *pOut,
5344+ FLOAT Scaling,
5345+ const D3DXVECTOR3 *pRotationCenter,
5346+ const D3DXQUATERNION *pRotation,
5347+ const D3DXVECTOR3 *pTranslation
5348+){
5349+/*
5350+This function calculates the affine transformation matrix with the following formula, with matrix concatenation evaluated in left-to-right order:
5351+
5352+ pOut = Scaling * (pRotationCenter)^-1 * pRotation * pRotationCenter * pTranslation
5353+
5354+
5355+where:
5356+
5357+
5358+ pOut = output matrix (pOut)
5359+
5360+
5361+ Scaling = scaling matrix (Scaling)
5362+
5363+
5364+ pRotationCenter = center of rotation matrix (pRotationCenter)
5365+
5366+
5367+ pRotation = rotation matrix (pRotation)
5368+
5369+
5370+ pTranslation = translation matrix (pTranslation)
5371+
5372+*/
5373+ FIXME("(void): stub\n");
5374+ return pOut;
5375+}
5376+
5377+
5378+D3DXMATRIX *WINAPI D3DXMatrixAffineTransformation2D(
5379+ D3DXMATRIX *pOut,
5380+ FLOAT Scaling,
5381+ CONST D3DXVECTOR2 *pRotationCenter,
5382+ FLOAT Rotation,
5383+ CONST D3DXVECTOR2 *pTranslation
5384+){
5385+
5386+/*
5387+This function calculates the affine transformation matrix with the following formula, with matrix concatenation evaluated in left-to-right order:
5388+
5389+ Mout = Ms * (Mrc)^-1 * Mr * Mrc * Mt
5390+
5391+
5392+where:
5393+
5394+
5395+ Mout = output matrix (pOut)
5396+
5397+
5398+ Ms = scaling matrix (Scaling)
5399+
5400+
5401+ Mrc = center of rotation matrix (pRotationCenter)
5402+
5403+
5404+ Mr = rotation matrix (Rotation)
5405+
5406+
5407+ Mt = translation matrix (pTranslation)
5408+ */
5409+
5410+ FIXME("(void): stub\n");
5411+ return pOut;
5412+}
5413+
5414+HRESULT WINAPI D3DXMatrixDecompose(
5415+ D3DXVECTOR3 *pOutScale,
5416+ D3DXQUATERNION *pOutRotation,
5417+ D3DXVECTOR3 *pOutTranslation,
5418+ const D3DXMATRIX *pM
5419+){
5420+
5421+ FIXME("stub\n");
5422+ return S_OK;
5423+}
5424+
5425+
5426+FLOAT WINAPI D3DXMatrixDeterminant(
5427+ CONST D3DXMATRIX *pM
5428+){
5429+
5430+ return
5431+ pM->_14 * pM->_23 * pM->_32 * pM->_41-pM->_13 * pM->_24 * pM->_32 * pM->_41-pM->_14 * pM->_22 * pM->_33 * pM->_41+pM->_12 * pM->_24 * pM->_33 * pM->_41+
5432+ pM->_13 * pM->_22 * pM->_34 * pM->_41-pM->_12 * pM->_23 * pM->_34 * pM->_41-pM->_14 * pM->_23 * pM->_31 * pM->_42+pM->_13 * pM->_24 * pM->_31 * pM->_42+
5433+ pM->_14 * pM->_21 * pM->_33 * pM->_42-pM->_11 * pM->_24 * pM->_33 * pM->_42-pM->_13 * pM->_21 * pM->_34 * pM->_42+pM->_11 * pM->_23 * pM->_34 * pM->_42+
5434+ pM->_14 * pM->_22 * pM->_31 * pM->_43-pM->_12 * pM->_24 * pM->_31 * pM->_43-pM->_14 * pM->_21 * pM->_32 * pM->_43+pM->_11 * pM->_24 * pM->_32 * pM->_43+
5435+ pM->_12 * pM->_21 * pM->_34 * pM->_43-pM->_11 * pM->_22 * pM->_34 * pM->_43-pM->_13 * pM->_22 * pM->_31 * pM->_44+pM->_12 * pM->_23 * pM->_31 * pM->_44+
5436+ pM->_13 * pM->_21 * pM->_32 * pM->_44-pM->_11 * pM->_23 * pM->_32 * pM->_44-pM->_12 * pM->_21 * pM->_33 * pM->_44+pM->_11 * pM->_22 * pM->_33 * pM->_44;
5437+
5438+}
5439+
5440+
5441+
5442+
5443+D3DXMATRIX* WINAPI D3DXMatrixPerspectiveFovLH(D3DXMATRIX *pOut,
5444+ FLOAT fovy,
5445+ FLOAT aspect,
5446+ FLOAT zn,
5447+ FLOAT zf){
5448+
5449+ FLOAT yscale;
5450+ FLOAT xscale;
5451+
5452+
5453+
5454+ yscale = 1.0f/tan(fovy/2.0f);
5455+
5456+
5457+ xscale = aspect * yscale;
5458+
5459+ pOut->_11 = xscale;
5460+ pOut->_12 = 0;
5461+ pOut->_13 = 0;
5462+ pOut->_14 = 0;
5463+
5464+ pOut->_21 = 0;
5465+ pOut->_22 = yscale;
5466+ pOut->_23 = 0;
5467+ pOut->_24 = 0;
5468+
5469+ pOut->_31 = 0;
5470+ pOut->_32 = 0;
5471+ pOut->_33 = zf/(zf-zn);
5472+ pOut->_34 = 1;
5473+
5474+ pOut->_41 = 0;
5475+ pOut->_42 = 0;
5476+ pOut->_43 = -zn*zf/(zf-zn);
5477+ pOut->_44 = 0;
5478+
5479+ return pOut;
5480+
5481+}
5482+D3DXMATRIX *WINAPI D3DXMatrixPerspectiveFovRH(
5483+ D3DXMATRIX *pOut,
5484+ FLOAT fovy,
5485+ FLOAT Aspect,
5486+ FLOAT zn,
5487+ FLOAT zf
5488+){
5489+
5490+
5491+FLOAT yscale;
5492+ FLOAT xscale;
5493+
5494+
5495+
5496+ yscale = 1.0f/tan(fovy/2.0f);
5497+
5498+
5499+ xscale = Aspect * yscale;
5500+
5501+ pOut->_11 = xscale;
5502+ pOut->_12 = 0;
5503+ pOut->_13 = 0;
5504+ pOut->_14 = 0;
5505+
5506+ pOut->_21 = 0;
5507+ pOut->_22 = yscale;
5508+ pOut->_23 = 0;
5509+ pOut->_24 = 0;
5510+
5511+ pOut->_31 = 0;
5512+ pOut->_32 = 0;
5513+ pOut->_33 = zf/(zn-zf);
5514+ pOut->_34 = -1;
5515+
5516+ pOut->_41 = 0;
5517+ pOut->_42 = 0;
5518+ pOut->_43 = zn*zf/(zn-zf);
5519+ pOut->_44 = 0;
5520+
5521+ return pOut;
5522+
5523+}
5524+
5525+D3DXMATRIX *WINAPI D3DXMatrixPerspectiveLH(
5526+ D3DXMATRIX *pOut,
5527+ FLOAT w,
5528+ FLOAT h,
5529+ FLOAT zn,
5530+ FLOAT zf
5531+){
5532+/*
5533+2*zn/w 0 0 0
5534+0 2*zn/h 0 0
5535+0 0 zf/(zf-zn) 1
5536+0 0 zn*zf/(zn-zf) 0
5537+*/
5538+ return pOut;
5539+}
5540+
5541+D3DXMATRIX *WINAPI D3DXMatrixPerspectiveOffCenterLH(
5542+ D3DXMATRIX *pOut,
5543+ FLOAT l,
5544+ FLOAT r,
5545+ FLOAT b,
5546+ FLOAT t,
5547+ FLOAT zn,
5548+ FLOAT zf
5549+){
5550+/*
5551+2*zn/(r-l) 0 0 0
5552+0 2*zn/(t-b) 0 0
5553+(l+r)/(l-r) (t+b)/(b-t) zf/(zf-zn) 1
5554+0 0 zn*zf/(zn-zf) 0
5555+*/
5556+ return pOut;
5557+}
5558+
5559+D3DXMATRIX *WINAPI D3DXMatrixPerspectiveOffCenterRH(
5560+ D3DXMATRIX *pOut,
5561+ FLOAT l,
5562+ FLOAT r,
5563+ FLOAT b,
5564+ FLOAT t,
5565+ FLOAT zn,
5566+ FLOAT zf
5567+){
5568+/*
5569+
5570+2*zn/(r-l) 0 0 0
5571+0 2*zn*(t-b) 0 0
5572+(l+r)/(r-l) (t+b)/(t-b) zf/(zn-zf) -1
5573+0 0 zn*zf/(zn-zf) 0
5574+*/
5575+ return pOut;
5576+}
5577+
5578+D3DXMATRIX *WINAPI D3DXMatrixPerspectiveRH(
5579+ D3DXMATRIX *pOut,
5580+ FLOAT w,
5581+ FLOAT h,
5582+ FLOAT zn,
5583+ FLOAT zf
5584+){
5585+/*
5586+2*zn/w 0 0 0
5587+0 2*zn/h 0 0
5588+0 0 zf/(zn-zf) -1
5589+0 0 zn*zf/(zn-zf) 0
5590+*/
5591+ return pOut;
5592+}
5593+
5594+#if 0
5595+D3DXMATRIX *D3DXMatrixIdentity(D3DXMATRIX* pOut)
5596+{
5597+ pOut->_11 = 1;
5598+ pOut->_12 = 0;
5599+ pOut->_13 = 0;
5600+ pOut->_14 = 0;
5601+
5602+ pOut->_21 = 0;
5603+ pOut->_22 = 1;
5604+ pOut->_23 = 0;
5605+ pOut->_24 = 0;
5606+
5607+ pOut->_31 = 0;
5608+ pOut->_32 = 1;
5609+ pOut->_33 = 0;
5610+ pOut->_34 = 0;
5611+
5612+ pOut->_41 = 0;
5613+ pOut->_42 = 0;
5614+ pOut->_43 = 0;
5615+ pOut->_44 = 1;
5616+
5617+ return pOut;
5618+
5619+}
5620+
5621+BOOL D3DXMatrixIsIdentity(
5622+ CONST D3DXMATRIX *pM
5623+){
5624+return (pM->_11 == 1 &&
5625+ pM->_12 == 0 &&
5626+ pM->_13 == 0 &&
5627+ pM->_14 == 0 &&
5628+ pM->_21 == 0 &&
5629+ pM->_22 == 1 &&
5630+ pM->_23 == 0 &&
5631+ pM->_24 == 0 &&
5632+ pM->_31 == 0 &&
5633+ pM->_32 == 0 &&
5634+ pM->_33 == 1 &&
5635+ pM->_34 == 0 &&
5636+ pM->_41 == 0 &&
5637+ pM->_42 == 0 &&
5638+ pM->_43 == 0 &&
5639+ pM->_44 == 1) ? TRUE:FALSE;
5640+
5641+}
5642+#endif
5643+
5644+D3DXMATRIX *WINAPI D3DXMatrixMultiplyTranspose(
5645+ D3DXMATRIX* pOut,
5646+ const D3DXMATRIX* pM1,
5647+ const D3DXMATRIX* pM2
5648+){
5649+ /* pOut= T(M1*M2), justdo a matrix mulication but with ab's on the out put swaped for ba's.*/
5650+ FIXME("stub\n");
5651+ return pOut;
5652+}
5653+
5654+D3DXMATRIX *WINAPI D3DXMatrixMultiply(
5655+ D3DXMATRIX *pOut,
5656+ CONST D3DXMATRIX *pM1,
5657+ CONST D3DXMATRIX *pM2
5658+){
5659+
5660+
5661+
5662+
5663+ pOut->_11 = pM1->_11 * pM2->_11 + pM1->_12 * pM2->_21 + pM1->_13 * pM2->_31 + pM1->_14 * pM2->_41;
5664+ pOut->_12 = pM1->_11 * pM2->_12 + pM1->_12 * pM2->_22 + pM1->_13 * pM2->_32 + pM1->_14 * pM2->_42;
5665+ pOut->_13 = pM1->_11 * pM2->_13 + pM1->_12 * pM2->_23 + pM1->_13 * pM2->_33 + pM1->_14 * pM2->_43;
5666+ pOut->_14 = pM1->_11 * pM2->_14 + pM1->_12 * pM2->_24 + pM1->_13 * pM2->_34 + pM1->_14 * pM2->_44;
5667+
5668+ pOut->_21 = pM1->_21 * pM2->_11 + pM1->_22 * pM2->_21 + pM1->_23 * pM2->_31 + pM1->_24 * pM2->_41;
5669+ pOut->_22 = pM1->_21 * pM2->_12 + pM1->_22 * pM2->_22 + pM1->_23 * pM2->_32 + pM1->_24 * pM2->_42;
5670+ pOut->_23 = pM1->_21 * pM2->_13 + pM1->_22 * pM2->_23 + pM1->_23 * pM2->_33 + pM1->_24 * pM2->_43;
5671+ pOut->_24 = pM1->_21 * pM2->_14 + pM1->_22 * pM2->_24 + pM1->_23 * pM2->_34 + pM1->_24 * pM2->_44;
5672+
5673+ pOut->_31 = pM1->_31 * pM2->_11 + pM1->_32 * pM2->_21 + pM1->_33 * pM2->_31 + pM1->_34 * pM2->_41;
5674+ pOut->_32 = pM1->_31 * pM2->_12 + pM1->_32 * pM2->_22 + pM1->_33 * pM2->_32 + pM1->_34 * pM2->_42;
5675+ pOut->_33 = pM1->_31 * pM2->_13 + pM1->_32 * pM2->_23 + pM1->_33 * pM2->_33 + pM1->_34 * pM2->_43;
5676+ pOut->_34 = pM1->_31 * pM2->_14 + pM1->_32 * pM2->_24 + pM1->_33 * pM2->_34 + pM1->_34 * pM2->_44;
5677+
5678+ pOut->_41 = pM1->_41 * pM2->_11 + pM1->_42 * pM2->_21 + pM1->_43 * pM2->_31 + pM1->_44 * pM2->_41;
5679+ pOut->_42 = pM1->_41 * pM2->_12 + pM1->_42 * pM2->_22 + pM1->_43 * pM2->_32 + pM1->_44 * pM2->_42;
5680+ pOut->_43 = pM1->_41 * pM2->_13 + pM1->_42 * pM2->_23 + pM1->_43 * pM2->_33 + pM1->_44 * pM2->_43;
5681+ pOut->_44 = pM1->_41 * pM2->_14 + pM1->_42 * pM2->_24 + pM1->_43 * pM2->_34 + pM1->_44 * pM2->_44;
5682+
5683+ return pOut;
5684+
5685+}
5686+
5687+
5688+
5689+
5690+D3DXMATRIX *WINAPI D3DXMatrixRotationX(
5691+ D3DXMATRIX *pOut,
5692+ FLOAT Angle
5693+){
5694+/*I hope the handedness is correct, MSDN doesn't say*/
5695+
5696+ pOut->_11 = 1;
5697+ pOut->_12 = 0;
5698+ pOut->_13 = 0;
5699+ pOut->_14= 0;
5700+
5701+ pOut->_21 = 0;
5702+ pOut->_22 = cos(Angle);
5703+ pOut->_23 = sin(Angle);
5704+ pOut->_24 = 0;
5705+
5706+ pOut->_31 = 0;
5707+ pOut->_32 = -sin(Angle);
5708+ pOut->_33 = cos(Angle);
5709+ pOut->_34= 0;
5710+
5711+ pOut->_41 = 0;
5712+ pOut->_42 = 0;
5713+ pOut->_43 = 0;
5714+ pOut->_44= 1;/*is this 1*/
5715+
5716+ return pOut;
5717+}
5718+
5719+D3DXMATRIX *WINAPI D3DXMatrixRotationY(
5720+ D3DXMATRIX *pOut,
5721+ FLOAT Angle
5722+){
5723+
5724+ pOut->_11 = cos(Angle);
5725+ pOut->_12 = 0;
5726+ pOut->_13 = sin(Angle);
5727+ pOut->_14 = 0;
5728+
5729+ pOut->_21 = 0;
5730+ pOut->_22 = 1;
5731+ pOut->_23 = 0;
5732+ pOut->_24 = 0;
5733+
5734+
5735+ pOut->_31 = -sin(Angle);
5736+ pOut->_32 = 0;
5737+ pOut->_33 = cos(Angle);
5738+ pOut->_34 = 0;
5739+
5740+ pOut->_41 = 0;
5741+ pOut->_42 = 0;
5742+ pOut->_43 = 0;
5743+ pOut->_44 = 1;/*is this 1*/
5744+ return pOut;
5745+}
5746+
5747+D3DXMATRIX *WINAPI D3DXMatrixRotationZ(
5748+ D3DXMATRIX *pOut,
5749+ FLOAT Angle
5750+){
5751+ /*MSDN doesn't tell me which way arond this is!!*/
5752+
5753+ FIXME("Matrix rotation z\n");
5754+ pOut->_11 = cos(Angle);
5755+ pOut->_12 = sin(Angle);
5756+ pOut->_13 = 0;
5757+ pOut->_14 = 0;
5758+
5759+ pOut->_21 = -sin(Angle);
5760+ pOut->_22 = cos(Angle);
5761+ pOut->_23 = 0;
5762+ pOut->_24 = 0;
5763+
5764+
5765+ pOut->_31 = 0;
5766+ pOut->_32 = 0;
5767+ pOut->_33 = 1;
5768+ pOut->_34 = 0;
5769+
5770+ pOut->_41 = 0;
5771+ pOut->_42 = 0;
5772+ pOut->_43 = 0;
5773+ pOut->_44 = 1;/*is this 1*/
5774+
5775+ return pOut;
5776+}
5777+
5778+
5779+
5780+
5781+/*timeGetTime*/
5782+
5783+D3DXMATRIX *WINAPI D3DXMatrixScaling(
5784+ D3DXMATRIX *pOut,
5785+ FLOAT sx,
5786+ FLOAT sy,
5787+ FLOAT sz
5788+){
5789+ FIXME("Creating a scaling matrix\n");
5790+ pOut->_11 = sx;
5791+ pOut->_12 = 0;
5792+ pOut->_13 = 0;
5793+ pOut->_14 = 0;
5794+
5795+ pOut->_21 = 0;
5796+ pOut->_22 = sy;
5797+ pOut->_23 = 0;
5798+ pOut->_24 = 0;
5799+
5800+ pOut->_31 = 0;
5801+ pOut->_32 = 0;
5802+ pOut->_33 = sz;
5803+ pOut->_34 = 0;
5804+
5805+ pOut->_41 = 0;
5806+ pOut->_42 = 0;
5807+ pOut->_43 = 0;
5808+ pOut->_44 = 1;
5809+
5810+ return pOut;
5811+}
5812+
5813+
5814+
5815+D3DXMATRIX *WINAPI D3DXMatrixShadow(
5816+ D3DXMATRIX *pOut,
5817+ CONST D3DXVECTOR4 *pLight,
5818+ CONST D3DXPLANE *pPlane
5819+){
5820+ FIXME("stub\n");
5821+
5822+
5823+ /*
5824+ D3DXPLANE P = D3DXPlaneNormalize( &P, pPlane);
5825+ L = Light;
5826+ d = dot(P, L)
5827+
5828+ P.a * L.x + d P.a * L.y P.a * L.z P.a * L.w
5829+ P.b * L.x P.b * L.y + d P.b * L.z P.b * L.w
5830+ P.c * L.x P.c * L.y P.c * L.z + d P.c * L.w
5831+ P.d * L.x P.d * L.y P.d * L.z P.d * L.w + d
5832+ */
5833+
5834+ return pOut;
5835+}
5836+
5837+D3DXMATRIX *WINAPI D3DXMatrixTransformation(
5838+ D3DXMATRIX *pOut,
5839+ CONST D3DXVECTOR3 *pScalingCenter,
5840+ CONST D3DXQUATERNION *pScalingRotation,
5841+ CONST D3DXVECTOR3 *pScaling,
5842+ CONST D3DXVECTOR3 *pRotationCenter,
5843+ CONST D3DXQUATERNION *pRotation,
5844+ CONST D3DXVECTOR3 *pTranslation
5845+){
5846+
5847+/*
5848+This function calculates the transformation matrix with the following formula, with matrix concatenation evaluated in left-to-right order:
5849+
5850+ Mout = (Msc)-1 * (Msr)-1 * Ms * Msr * Msc * (Mrc)-1 * Mr * Mrc * Mt
5851+
5852+
5853+where:
5854+
5855+
5856+ Mout = output matrix (pOut)
5857+
5858+
5859+ Msc = scaling center matrix (pScalingCenter)
5860+
5861+
5862+ Msr = scaling rotation matrix (pScalingRotation)
5863+
5864+
5865+ Ms = scaling matrix (pScaling)
5866+
5867+
5868+ Mrc = center of rotation matrix (pRotationCenter)
5869+
5870+
5871+ Mr = rotation matrix (pRotation)
5872+
5873+
5874+ Mt = translation matrix (pTranslation)
5875+*/
5876+ FIXME("stub\n");
5877+ return pOut;
5878+}
5879+
5880+D3DXMATRIX *WINAPI D3DXMatrixTransformation2D(
5881+ D3DXMATRIX *pOut,
5882+ CONST D3DXVECTOR2 *pScalingCenter,
5883+ FLOAT *pScalingRotation,
5884+ CONST D3DXVECTOR2 *pScaling,
5885+ CONST D3DXVECTOR2 *pRotationCenter,
5886+ FLOAT Rotation,
5887+ CONST D3DXVECTOR2 *pTranslation
5888+){
5889+/*
5890+This function calculates the transformation matrix with the following formula, with matrix concatenation evaluated in left-to-right order:
5891+
5892+ Mout = (Msc)-1 * (Msr)-1 * Ms * Msr * Msc * (Mrc)-1 * Mr * Mrc * Mt
5893+
5894+
5895+where:
5896+
5897+
5898+ Mout = output matrix (pOut)
5899+
5900+
5901+ Msc = scaling center matrix (pScalingCenter)
5902+
5903+
5904+ Msr = scaling rotation matrix (pScalingRotation)
5905+
5906+
5907+ Ms = scaling matrix (pScaling)
5908+
5909+
5910+ Mrc = center of rotation matrix (pRotationCenter)
5911+
5912+
5913+ Mr = rotation matrix (Rotation)
5914+
5915+
5916+ Mt = translation matrix (pTranslation)
5917+*/
5918+ FIXME("stub\n");
5919+ return pOut;
5920+}
5921+
5922+
5923+D3DXMATRIX *WINAPI D3DXMatrixTranspose(
5924+ D3DXMATRIX *pOut,
5925+ CONST D3DXMATRIX *pM
5926+){
5927+
5928+ pOut->_11 = pM->_11;
5929+ pOut->_12 = pM->_21;
5930+ pOut->_13 = pM->_31;
5931+ pOut->_14 = pM->_41;
5932+
5933+ pOut->_21 = pM->_12;
5934+ pOut->_22 = pM->_22;
5935+ pOut->_23 = pM->_32;
5936+ pOut->_24 = pM->_42;
5937+
5938+ pOut->_31 = pM->_13;
5939+ pOut->_32 = pM->_23;
5940+ pOut->_33 = pM->_33;
5941+ pOut->_34 = pM->_43;
5942+
5943+ pOut->_41 = pM->_14;
5944+ pOut->_42 = pM->_24;
5945+ pOut->_43 = pM->_34;
5946+ pOut->_44 = pM->_44;
5947+
5948+ return pOut;
5949+
5950+}
5951+
5952+/*Not in Microsoft library*/
5953+float D3DXPlaneLength(CONST D3DXPLANE *pP){
5954+ return sqrt(pP->a * pP->a + pP->b * pP->b + pP->c * pP->c + pP->d * pP->d);
5955+}
5956+
5957+D3DXPLANE *D3DXPlaneScale(
5958+ D3DXPLANE *pOut,
5959+ CONST D3DXPLANE *pP,
5960+ FLOAT s
5961+){
5962+ pOut->a = pP->a * s;
5963+ pOut->b = pP->b * s;
5964+ pOut->c = pP->c * s;
5965+ pOut->d = pP->d * s;
5966+ return pOut;
5967+}
5968+
5969+D3DXPLANE *WINAPI D3DXPlaneNormalize(
5970+ D3DXPLANE *pOut,
5971+ CONST D3DXPLANE *pP
5972+){
5973+ /*|D3DXPLANE| */
5974+
5975+ float d = D3DXPlaneLength(pP);
5976+ if(d == 0 ){
5977+ pOut->a = 0;
5978+ pOut->b = 0;
5979+ pOut->c = 0;
5980+ pOut->d = 0;
5981+ }else{
5982+ return D3DXPlaneScale(pOut, pP, 1.0f/d);
5983+ }
5984+ return pOut;
5985+}
5986+
5987+D3DXPLANE *WINAPI D3DXPlaneTransform(
5988+ D3DXPLANE *pOut,
5989+ CONST D3DXPLANE *pP,
5990+ CONST D3DXMATRIX *pM
5991+){
5992+/*
5993+D3DXPLANE planeNew;
5994+D3DXPLANE plane(0,1,1,0);
5995+D3DXPlaneNormalize(&plane, &plane);
5996+
5997+D3DXMATRIX matrix;
5998+D3DXMatrixScaling(&matrix, 1.0f,2.0f,3.0f);
5999+D3DXMatrixInverse(&matrix, NULL, &matrix);
6000+D3DXMatrixTranspose(&matrix, &matrix);
6001+D3DXPlaneTransform(&planeNew, &plane, &matrix);
6002+
6003+
6004+
6005+A plane is described by ax + by + cz + dw = 0. The first plane is created with (a,b,c,d) = (0,1,1,0), which is a plane described by y + z = 0. After scaling, the new plane contains (a,b,c,d) = (0, 0.353f, 0.235f, 0), which shows the new plane to be described by 0.353y + 0.235z = 0.
6006+
6007+
6008+The parameter pM contains the inverse transpose of the transformation matrix. The inverse transpose is required by this method so that the normal vector of the transformed plane can be correctly transformed as well.
6009+*/
6010+ return pOut;
6011+}
6012+
6013+
6014+D3DXPLANE *WINAPI D3DXPlaneTransformArray(
6015+ D3DXPLANE *pOut,
6016+ UINT OutStride,
6017+ CONST D3DXPLANE* pP,
6018+ UINT PStride,
6019+ CONST D3DXMATRIX* pM,
6020+ UINT n
6021+){
6022+ /*http://msdn.microsoft.com/archive/default.asp?url=/archive/en-us/directx9_c_Summer_04/directx/graphics/reference/d3dx/functions/math/d3dxmatrixshadow.asp*/
6023+ return pOut;
6024+}
6025+
6026+
6027+D3DXQUATERNION *WINAPI D3DXQuaternionBaryCentric(
6028+ D3DXQUATERNION *pOut,
6029+ CONST D3DXQUATERNION *pQ1,
6030+ CONST D3DXQUATERNION *pQ2,
6031+ CONST D3DXQUATERNION *pQ3,
6032+ FLOAT f,
6033+ FLOAT g
6034+){
6035+/*http://msdn.microsoft.com/archive/default.asp?url=/archive/en-us/directx9_c_Summer_04/directx/graphics/reference/d3dx/functions/math/d3dxmatrixshadow.asp*/
6036+ return pOut;
6037+}
6038+
6039+D3DXQUATERNION *D3DXQuaternionConjugate(
6040+ D3DXQUATERNION *pOut,
6041+ CONST D3DXQUATERNION *pQ
6042+){
6043+ return pOut;
6044+}
6045+
6046+FLOAT D3DXQuaternionDot(
6047+ CONST D3DXQUATERNION *pQ1,
6048+ CONST D3DXQUATERNION *pQ2
6049+){
6050+ return 0.0f;
6051+}
6052+
6053+
6054+
6055+
6056+D3DXCOLOR *D3DXColorAdd(
6057+ D3DXCOLOR *pOut,
6058+ CONST D3DXCOLOR *pC1,
6059+ CONST D3DXCOLOR *pC2
6060+){
6061+ /*I think they mean this!*/
6062+ pOut->r = (pC1->r + pC2->r) * 0.5f;
6063+ pOut->g = (pC1->g + pC2->g) * 0.5f;
6064+ pOut->b = (pC1->b + pC2->b) * 0.5f;
6065+ return pOut;
6066+
6067+}
6068+
6069+
6070+D3DXCOLOR *WINAPI D3DXColorAdjustContrast(
6071+ D3DXCOLOR *pOut,
6072+ const D3DXCOLOR *pC,
6073+ FLOAT c
6074+){
6075+
6076+ pOut->r = 0.5f + c * (pC->r - 0.5f);
6077+ pOut->g = 0.5f + c * (pC->g - 0.5f);
6078+ pOut->b = 0.5f + c * (pC->b - 0.5f);
6079+ pOut->a = pC->a;
6080+ return pOut;
6081+}
6082+/*** Based upon MSDN, based on the NTSC standard described in ITU-R Recommendation BT.709***/
6083+#define NOSAT(pC) (pC->r * 0.2125f + pC->g * 0.7154f + pC->b * 0.0721f)
6084+
6085+D3DXCOLOR *WINAPI D3DXColorAdjustSaturation(
6086+ D3DXCOLOR *pOut,
6087+ const D3DXCOLOR *pC,
6088+ FLOAT s
6089+){
6090+
6091+ float grey = NOSAT(pC);
6092+ pOut->r = grey + s * (pC->r - grey);
6093+ pOut->g = grey + s * (pC->g - grey);
6094+ pOut->b = grey + s * (pC->b - grey);
6095+ pOut->a = pC->a;
6096+ return pOut;
6097+}
6098+
6099+
6100+/*Linear interplot*/
6101+D3DXCOLOR *D3DXColorLerp(
6102+ D3DXCOLOR *pOut,
6103+ CONST D3DXCOLOR *pC1,
6104+ CONST D3DXCOLOR *pC2,
6105+ FLOAT s
6106+){
6107+
6108+ pOut->r = pC1->r + s * (pC2->r - pC1->r);
6109+ pOut->g = pC1->g + s * (pC2->g - pC1->g);
6110+ pOut->b = pC1->b + s * (pC2->b - pC1->b);
6111+ pOut->a = pC1->a + s * (pC2->a - pC1->a);
6112+ return pOut;
6113+}
6114+
6115+D3DXCOLOR *D3DXColorModulate(
6116+ D3DXCOLOR *pOut,
6117+ CONST D3DXCOLOR *pC1,
6118+ CONST D3DXCOLOR *pC2
6119+){
6120+
6121+ pOut->r = pC1->r * pC2->r;
6122+ pOut->g = pC1->g * pC2->g;
6123+ pOut->b = pC1->b * pC2->b;
6124+ pOut->a = pC1->a * pC2->a;
6125+ return pOut;
6126+}
6127+
6128+D3DXCOLOR *D3DXColorNegative(
6129+ D3DXCOLOR *pOut,
6130+ CONST D3DXCOLOR *pC
6131+){
6132+
6133+ pOut->r = 1.0f - pC->r;
6134+ pOut->g = 1.0f - pC->g;
6135+ pOut->b = 1.0f - pC->b;
6136+ pOut->a = pC->a;
6137+
6138+ return pOut;
6139+}
6140+
6141+
6142+D3DXCOLOR *D3DXColorScale(
6143+ D3DXCOLOR *pOut,
6144+ CONST D3DXCOLOR *pC,
6145+ FLOAT s
6146+){
6147+ pOut->r = pC->r * s;
6148+ pOut->g = pC->g * s;
6149+ pOut->b = pC->b * s;
6150+ pOut->a = pC->a * s;
6151+ return pOut;
6152+}
6153+
6154+
6155+D3DXCOLOR *D3DXColorSubtract(
6156+ D3DXCOLOR *pOut,
6157+ CONST D3DXCOLOR *pC1,
6158+ CONST D3DXCOLOR *pC2
6159+){
6160+ /*I think they mean |r1 - r2| who knows*/
6161+ pOut->r = (pC1->r - pC2->r);
6162+ pOut->g = (pC1->g - pC2->g);
6163+ pOut->b = (pC1->b - pC2->b);
6164+ pOut->a = (pC1->a - pC2->a);
6165+
6166+ if(pOut->r < 0 ) pOut->r = -pOut->r;
6167+ if(pOut->g < 0 ) pOut->g = -pOut->g;
6168+ if(pOut->b < 0 ) pOut->b = -pOut->b;
6169+ if(pOut->a < 0 ) pOut->a = -pOut->a;
6170+
6171+ return pOut;
6172+
6173+}
6174+
6175+#if 0
6176+HRESULT WINAPI D3DXCreateMatrixStack(
6177+ DWORD Flags,
6178+ LPD3DXMATRIXSTACK *ppStack
6179+){
6180+ FIXME("stub\n");
6181+ return D3D_OK;
6182+}
6183+#endif
6184+
6185+
6186+
6187+FLOAT *WINAPI D3DXFloat16To32Array(
6188+ FLOAT *pOut,
6189+ const D3DXFLOAT16 *pIn,
6190+ UINT n
6191+){
6192+/*MSDN is kind and doesn't want to tell us what a float16 is (I expect it's a fixed 8.8 not a float!)*/
6193+ #if 0
6194+ int i;
6195+ for(i=0;i<n;i++){
6196+ pOut[i] = ((FLOAT)pIn[i]->Value)*;
6197+ }
6198+ #endif
6199+ return pOut;
6200+}
6201+
6202+D3DXFLOAT16 *WINAPI D3DXFloat32To16Array(
6203+ D3DXFLOAT16* pOut,
6204+ CONST FLOAT* pIn,
6205+ UINT n
6206+){
6207+ #if 0
6208+ int i;
6209+ for(i=0;i<n;i++){
6210+ pOut[i]->Value = (WORD)pIn[i];
6211+ }
6212+ #endif
6213+ return pOut;
6214+}
6215+
6216+
6217+FLOAT WINAPI D3DXFresnelTerm(
6218+ FLOAT CosTheta,
6219+ FLOAT RefractionIndex
6220+){
6221+/*
6222+To find the Fresnel term (F):
6223+
6224+
6225+If A is angle of incidence and B is the angle of refraction, then
6226+
6227+F = 0.5 * [tan2(A - B) / tan2(A + B) + sin2(A - B) / sin2(A + B)]
6228+ = 0.5 * sin2(A - B) / sin2(A + B) * [cos2(A + B) / cos2(A - B) + 1]
6229+
6230+Let r = sina(A) / sin(B) (the relative refractive index)
6231+Let c = cos(A)
6232+Let g = (r2 + c2 - 1)1/2
6233+
6234+
6235+Then, expanding using the trig identities and simplifying, you get:
6236+
6237+F = 0.5 * (g + c)2 / (g - c)2 * ([c(g + c) - 1]2 / [c(g - c) + 1]2 + 1)
6238+
6239+
6240+*/
6241+ FIXME("stub\n");
6242+ return 0.0f;
6243+}
6244+
6245+
6246+
6247+D3DXMATRIX *WINAPI D3DXMatrixLookAtLH(
6248+ D3DXMATRIX *pOut,
6249+ CONST D3DXVECTOR3 *pEye,
6250+ CONST D3DXVECTOR3 *pAt,
6251+ CONST D3DXVECTOR3 *pUp
6252+){
6253+
6254+/*
6255+zaxis = normal(At - Eye)
6256+xaxis = normal(cross(Up, zaxis))
6257+yaxis = cross(zaxis, xaxis)
6258+
6259+ xaxis.x yaxis.x zaxis.x 0
6260+ xaxis.y yaxis.y zaxis.y 0
6261+ xaxis.z yaxis.z zaxis.z 0
6262+-dot(xaxis, eye) -dot(yaxis, eye) -dot(zaxis, eye) 1
6263+*/
6264+
6265+ D3DXVECTOR3 tmp;
6266+ D3DXVECTOR3 zaxis;
6267+ D3DXVECTOR3 xaxis;
6268+ D3DXVECTOR3 yaxis;
6269+
6270+ D3DXVec3Normalize(&zaxis,D3DXVec3Subtract(&tmp, pAt, pEye));
6271+ D3DXVec3Normalize(&xaxis,D3DXVec3Cross(&tmp, pUp, &zaxis));
6272+ D3DXVec3Cross(&yaxis, &zaxis, &xaxis);
6273+
6274+ pOut->_11 = xaxis.x;
6275+ pOut->_12 = yaxis.x;
6276+ pOut->_13 = zaxis.x;
6277+ pOut->_14 = 0;
6278+
6279+ pOut->_21 = xaxis.y;
6280+ pOut->_22 = yaxis.y;
6281+ pOut->_23 = zaxis.y;
6282+ pOut->_24 = 0;
6283+
6284+
6285+ pOut->_31 = xaxis.z;
6286+ pOut->_32 = yaxis.z;
6287+ pOut->_33 = zaxis.z;
6288+ pOut->_34 = 0;
6289+
6290+ pOut->_41 = -D3DXVec3Dot(&xaxis, pEye);
6291+ pOut->_42 = -D3DXVec3Dot(&yaxis, pEye);
6292+ pOut->_43 = -D3DXVec3Dot(&zaxis, pEye);
6293+ pOut->_44 = 1;
6294+
6295+ return pOut;
6296+}
6297+
6298+D3DXMATRIX *WINAPI D3DXMatrixLookAtRH(
6299+ D3DXMATRIX *pOut,
6300+ CONST D3DXVECTOR3 *pEye,
6301+ CONST D3DXVECTOR3 *pAt,
6302+ CONST D3DXVECTOR3 *pUp
6303+){
6304+
6305+/*
6306+zaxis = normal(Eye - At)
6307+xaxis = normal(cross(Up, zaxis))
6308+yaxis = cross(zaxis, xaxis)
6309+
6310+ xaxis.x yaxis.x zaxis.x 0
6311+ xaxis.y yaxis.y zaxis.y 0
6312+ xaxis.z yaxis.z zaxis.z 0
6313+-dot(xaxis, eye) -dot(yaxis, eye) -dot(zaxis, eye) 1
6314+*/
6315+
6316+
6317+ D3DXVECTOR3 tmp;
6318+ D3DXVECTOR3 zaxis;
6319+ D3DXVECTOR3 xaxis;
6320+ D3DXVECTOR3 yaxis;
6321+
6322+ D3DXVec3Normalize(&zaxis,D3DXVec3Subtract(&tmp, pEye, pAt));
6323+ D3DXVec3Normalize(&xaxis,D3DXVec3Cross(&tmp, pUp, &zaxis));
6324+ D3DXVec3Cross(&yaxis, &zaxis, &xaxis);
6325+
6326+ pOut->_11 = xaxis.x;
6327+ pOut->_12 = yaxis.x;
6328+ pOut->_13 = zaxis.x;
6329+ pOut->_14 = 0;
6330+
6331+ pOut->_21 = xaxis.y;
6332+ pOut->_22 = yaxis.y;
6333+ pOut->_23 = zaxis.y;
6334+ pOut->_24 = 0;
6335+
6336+
6337+ pOut->_31 = xaxis.z;
6338+ pOut->_32 = yaxis.z;
6339+ pOut->_33 = zaxis.z;
6340+ pOut->_34 = 0;
6341+
6342+ pOut->_41 = -D3DXVec3Dot(&xaxis, pEye);
6343+ pOut->_42 = -D3DXVec3Dot(&yaxis, pEye);
6344+ pOut->_43 = -D3DXVec3Dot(&zaxis, pEye);
6345+ pOut->_44 = 1;
6346+
6347+ FIXME("stub\n");
6348+ return pOut;
6349+}
6350+
6351+
6352+
6353+
6354+FLOAT D3DXPlaneDot(
6355+ CONST D3DXPLANE *pP,
6356+ CONST D3DXVECTOR4 *pV
6357+){
6358+ return pP->a * pV->x +
6359+ pP->b * pV->y +
6360+ pP->c * pV->z +
6361+ pP->d * pV->w;
6362+
6363+}
6364+
6365+
6366+FLOAT D3DXPlaneDotCoord(
6367+ CONST D3DXPLANE *pP,
6368+ CONST D3DXVECTOR3 *pV
6369+){
6370+ return pP->a * pV->x +
6371+ pP->b * pV->y +
6372+ pP->c * pV->z +
6373+ pP->d;
6374+}
6375+
6376+FLOAT D3DXPlaneDotNormal(
6377+ CONST D3DXPLANE *pP,
6378+ CONST D3DXVECTOR3 *pV
6379+){
6380+ return pP->a * pV->x +
6381+ pP->b * pV->y +
6382+ pP->c * pV->z;
6383+}
6384+
6385+
6386+D3DXPLANE *WINAPI D3DXPlaneFromPointNormal(
6387+ D3DXPLANE *pOut,
6388+ CONST D3DXVECTOR3 *pPoint,
6389+ CONST D3DXVECTOR3 *pNormal
6390+){
6391+ return pOut;
6392+}
6393+
6394+D3DXPLANE *WINAPI D3DXPlaneFromPoints(
6395+ D3DXPLANE *pOut,
6396+ CONST D3DXVECTOR3 *pV1,
6397+ CONST D3DXVECTOR3 *pV2,
6398+ CONST D3DXVECTOR3 *pV3
6399+){
6400+ return pOut;
6401+}
6402+
6403+D3DXVECTOR3 *WINAPI D3DXPlaneIntersectLine(
6404+ D3DXVECTOR3 *pOut,
6405+ CONST D3DXPLANE *pP,
6406+ CONST D3DXVECTOR3 *pV1,
6407+ CONST D3DXVECTOR3 *pV2
6408+){
6409+ return pOut;
6410+}
6411+
6412+
6413+
6414+D3DXMATRIX *WINAPI D3DXMatrixReflect(
6415+ D3DXMATRIX *pOut,
6416+ CONST D3DXPLANE *pPlane
6417+){
6418+ D3DXPLANE ptmp;
6419+ D3DXPlaneNormalize(&ptmp,pPlane);
6420+
6421+ pOut->_11 = -2 * ptmp.a * ptmp.a + 1;
6422+ pOut->_12 = -2 * ptmp.b * ptmp.a;
6423+ pOut->_13 = -2 * ptmp.c * ptmp.a;
6424+ pOut->_14 = 0;
6425+
6426+ pOut->_21 = -2 * ptmp.a * ptmp.b;
6427+ pOut->_22 = -2 * ptmp.b * ptmp.b + 1;
6428+ pOut->_23 = -2 * ptmp.c * ptmp.b;
6429+ pOut->_24 = 0;
6430+
6431+ pOut->_31 = -2 * ptmp.a * ptmp.c;
6432+ pOut->_32 = -2 * ptmp.b * ptmp.c;
6433+ pOut->_33 = -2 * ptmp.b * ptmp.c;
6434+ pOut->_34 = 0;
6435+
6436+ pOut->_41 = -2 * ptmp.b * ptmp.c;
6437+ pOut->_42 = -2 * ptmp.b * ptmp.d;
6438+ pOut->_43 = -2 * ptmp.c * ptmp.d;
6439+ pOut->_44 = 1;
6440+
6441+ return pOut;
6442+
6443+}
6444+
6445+D3DXMATRIX *WINAPI D3DXMatrixRotationAxis(
6446+ D3DXMATRIX *pOut,
6447+ CONST D3DXVECTOR3 *pV,
6448+ FLOAT Angle
6449+){
6450+FIXME("stub\n");
6451+return pOut;
6452+}
6453+
6454+D3DXMATRIX *WINAPI D3DXMatrixRotationQuaternion(
6455+ D3DXMATRIX *pOut,
6456+ CONST D3DXQUATERNION *pQ
6457+){
6458+ FIXME("stub\n");
6459+ return pOut;
6460+}
6461+
6462+D3DXMATRIX *WINAPI D3DXMatrixRotationYawPitchRoll(
6463+ D3DXMATRIX *pOut,
6464+ FLOAT Yaw,
6465+ FLOAT Pitch,
6466+ FLOAT Roll
6467+){
6468+
6469+ D3DXMATRIX rotz;
6470+ D3DXMATRIX roty;
6471+ D3DXMATRIX rotx;
6472+ D3DXMATRIX mTmp;
6473+
6474+ D3DXMatrixRotationZ(&rotz,Roll);
6475+ D3DXMatrixRotationX(&rotx,Pitch);
6476+ D3DXMatrixRotationY(&roty,Yaw);
6477+ D3DXMatrixMultiply(&mTmp,&rotz,&rotx);
6478+ return D3DXMatrixMultiply(pOut,&mTmp,&roty);
6479+
6480+}
6481+
6482+
6483+D3DXMATRIX *WINAPI D3DXMatrixInverse(
6484+ D3DXMATRIX *pOut,
6485+ FLOAT *pDeterminant,
6486+ CONST D3DXMATRIX *pM
6487+){
6488+#if 0
6489+
6490+ pM->_11 = pM->_23*pM->_34*pM->_42 - pM->_24*pM->_33*pM->_42 + pM->_24*pM->_32*pM->_43 - pM->_22*pM->_34*pM->_43 - pM->_23*pM->_32*pM->_44 + pM->_22*pM->_33*pM->_44;
6491+ pM->_12 = pM->_14*pM->_33*pM->_42 - pM->_13*pM->_34*pM->_42 - pM->_14*pM->_32*pM->_43 + pM->_12*pM->_34*pM->_43 + pM->_13*pM->_32*pM->_44 - pM->_12*pM->_33*pM->_44;
6492+ pM->_13 = pM->_13*pM->_24*pM->_42 - pM->_14*pM->_23*pM->_42 + pM->_14*pM->_22*pM->_43 - pM->_12*pM->_24*pM->_43 - pM->_13*pM->_22*pM->_44 + pM->_12*pM->_23*pM->_44;
6493+ pM->_14 = pM->_14*pM->_23*pM->_32 - pM->_13*pM->_24*pM->_32 - pM->_14*pM->_22*pM->_33 + pM->_12*pM->_24*pM->_33 + pM->_13*pM->_22*pM->_34 - pM->_12*pM->_23*pM->_34;
6494+ pM->_21 = pM->_24*pM->_33*pM->_41 - pM->_23*pM->_34*pM->_41 - pM->_24*pM->_31*pM->_43 + pM->_21*pM->_34*pM->_43 + pM->_23*pM->_31*pM->_44 - pM->_21*pM->_33*pM->_44;
6495+ pM->_22 = pM->_13*pM->_34*pM->_41 - pM->_14*pM->_33*pM->_41 + pM->_14*pM->_31*pM->_43 - pM->_11*pM->_34*pM->_43 - pM->_13*pM->_31*pM->_44 + pM->_11*pM->_33*pM->_44;
6496+ pM->_23 = pM->_14*pM->_23*pM->_41 - pM->_13*pM->_24*pM->_41 - pM->_14*pM->_21*pM->_43 + pM->_11*pM->_24*pM->_43 + pM->_13*pM->_21*pM->_44 - pM->_11*pM->_23*pM->_44;
6497+ pM->_24 = pM->_13*pM->_24*pM->_31 - pM->_14*pM->_23*pM->_31 + pM->_14*pM->_21*pM->_33 - pM->_11*pM->_24*pM->_33 - pM->_13*pM->_21*pM->_34 + pM->_11*pM->_23*pM->_34;
6498+ pM->_31 = pM->_22*pM->_34*pM->_41 - pM->_24*pM->_32*pM->_41 + pM->_24*pM->_31*pM->_42 - pM->_21*pM->_34*pM->_42 - pM->_22*pM->_31*pM->_44 + pM->_21*pM->_32*pM->_44;
6499+ pM->_32 = pM->_14*pM->_32*pM->_41 - pM->_12*pM->_34*pM->_41 - pM->_14*pM->_31*pM->_42 + pM->_11*pM->_34*pM->_42 + pM->_12*pM->_31*pM->_44 - pM->_11*pM->_32*pM->_44;
6500+ pM->_33 = pM->_12*pM->_24*pM->_41 - pM->_14*pM->_22*pM->_41 + pM->_14*pM->_21*pM->_42 - pM->_11*pM->_24*pM->_42 - pM->_12*pM->_21*pM->_44 + pM->_11*pM->_22*pM->_44;
6501+ pM->_34 = pM->_14*pM->_22*pM->_31 - pM->_12*pM->_24*pM->_31 - pM->_14*pM->_21*pM->_32 + pM->_11*pM->_24*pM->_32 + pM->_12*pM->_21*pM->_34 - pM->_11*pM->_22*pM->_34;
6502+ pM->_41 = pM->_23*pM->_32*pM->_41 - pM->_22*pM->_33*pM->_41 - pM->_23*pM->_31*pM->_42 + pM->_21*pM->_33*pM->_42 + pM->_22*pM->_31*pM->_43 - pM->_21*pM->_32*pM->_43;
6503+ pM->_42 = pM->_12*pM->_33*pM->_41 - pM->_13*pM->_32*pM->_41 + pM->_13*pM->_31*pM->_42 - pM->_11*pM->_33*pM->_42 - pM->_12*pM->_31*pM->_43 + pM->_11*pM->_32*pM->_43;
6504+ pM->_43 = pM->_13*pM->_22*pM->_41 - pM->_12*pM->_23*pM->_41 - pM->_13*pM->_21*pM->_42 + pM->_11*pM->_23*pM->_42 + pM->_12*pM->_21*pM->_43 - pM->_11*pM->_22*pM->_43;
6505+ pM->_44 = pM->_12*pM->_23*pM->_31 - pM->_13*pM->_22*pM->_31 + pM->_13*pM->_21*pM->_32 - pM->_11*pM->_23*pM->_32 - pM->_12*pM->_21*pM->_33 + pM->_11*pM->_22*pM->_33;
6506+
6507+ scale(1/m1.determinant());
6508+#endif
6509+ FIXME("stub\n");
6510+ return pOut;
6511+
6512+}
6513+
6514+
6515+
6516+D3DXMATRIX *WINAPI D3DXMatrixTranslation(
6517+ D3DXMATRIX *pOut,
6518+ FLOAT x,
6519+ FLOAT y,
6520+ FLOAT z
6521+){
6522+
6523+/*I think it's something like this?*/
6524+ pOut->_11 = 1;
6525+ pOut->_12 = 0;
6526+ pOut->_13 = 0;
6527+ pOut->_14 = 0;
6528+
6529+ pOut->_21 = 0;
6530+ pOut->_22 = 1;
6531+ pOut->_23 = 0;
6532+ pOut->_24 = 0;
6533+
6534+ pOut->_31 = 0;
6535+ pOut->_32 = 0;
6536+ pOut->_33 = 1;
6537+ pOut->_34 = 0;
6538+
6539+ pOut->_41 = x;
6540+ pOut->_42 = y;
6541+ pOut->_43 = z;
6542+ pOut->_44 = 1;
6543+
6544+ return pOut;
6545+}
6546+
6547+D3DXMATRIX *WINAPI D3DXMatrixOrthoLH(
6548+ D3DXMATRIX *pOut,
6549+ FLOAT w,
6550+ FLOAT h,
6551+ FLOAT zn,
6552+ FLOAT zf
6553+){
6554+
6555+/*I'm not texting for a div0 at the moment because MSDN doesn't tell me what I should do (if anything!)
6556+
6557+if(zn == zf){
6558+}
6559+
6560+*/
6561+
6562+ pOut->_11 = 2/w;
6563+ pOut->_12 = 0;
6564+ pOut->_13 = 0;
6565+ pOut->_14 = 0;
6566+
6567+ pOut->_21 = 0;
6568+ pOut->_22 = 2/h;
6569+ pOut->_23 = 0;
6570+ pOut->_24 = 0;
6571+
6572+ pOut->_31 = 0;
6573+ pOut->_32 = 0;
6574+ pOut->_33 = 1/(zf-zn);
6575+ pOut->_34 = 0;
6576+
6577+ pOut->_41 = 0;
6578+ pOut->_42 = 0;
6579+ pOut->_43 = zn/(zn-zf);
6580+ pOut->_44 = 1;
6581+
6582+ return pOut;
6583+}
6584+
6585+
6586+D3DXMATRIX *WINAPI D3DXMatrixOrthoRH(
6587+ D3DXMATRIX *pOut,
6588+ FLOAT w,
6589+ FLOAT h,
6590+ FLOAT zn,
6591+ FLOAT zf
6592+){
6593+/*I'm not texting for a div0 at the moment because MSDN doesn't tell me what I should do (if anything!)
6594+
6595+if(zn == zf){
6596+}
6597+
6598+*/
6599+ pOut->_11 = 2/w;
6600+ pOut->_12 = 0;
6601+ pOut->_13 = 0;
6602+ pOut->_14 = 0;
6603+
6604+ pOut->_21 = 0;
6605+ pOut->_22 = 2/h;
6606+ pOut->_23 = 0;
6607+ pOut->_24 = 0;
6608+
6609+ pOut->_31 = 0;
6610+ pOut->_32 = 0;
6611+ pOut->_33 = 1/(zn-zf);
6612+ pOut->_34 = 0;
6613+
6614+ pOut->_41 = 0;
6615+ pOut->_42 = 0;
6616+ pOut->_43 = zn/(zn-zf);
6617+ pOut->_44 = 1;
6618+
6619+ return pOut;
6620+}
6621+
6622+D3DXMATRIX *WINAPI D3DXMatrixOrthoOffCenterLH(
6623+ D3DXMATRIX *pOut,
6624+ FLOAT l,
6625+ FLOAT r,
6626+ FLOAT b,
6627+ FLOAT t,
6628+ FLOAT zn,
6629+ FLOAT zf
6630+){
6631+/* MSDN doesn't say what to do with a div/0
6632+if(zf == zn){
6633+}
6634+*/
6635+ pOut->_11 = 2.0 / (r - 1.0);
6636+ pOut->_12 = 0;
6637+ pOut->_13 = 0;
6638+ pOut->_14 = 0;
6639+
6640+ pOut->_21 = 0;
6641+ pOut->_22 = 2.0 / (t - b);
6642+ pOut->_23 = 0;
6643+ pOut->_24 = 0;
6644+
6645+ pOut->_31 = 0;
6646+ pOut->_32 = 0;
6647+ pOut->_33 = 1.0 / (zf - zf);
6648+ pOut->_34 = 0;
6649+
6650+ pOut->_41 = (1.0 + r) / (1.0 - r);
6651+ pOut->_42 = (t + b) / (b - t);
6652+ pOut->_43 = zn / (zn - zf);
6653+ pOut->_44 = 1;
6654+
6655+ return pOut;
6656+}
6657+
6658+
6659+D3DXMATRIX *WINAPI D3DXMatrixOrthoOffCenterRH(
6660+ D3DXMATRIX *pOut,
6661+ FLOAT l,
6662+ FLOAT r,
6663+ FLOAT b,
6664+ FLOAT t,
6665+ FLOAT zn,
6666+ FLOAT zf
6667+){
6668+/* MSDN doesn't say what to do with a div/0
6669+if(zf == zn){
6670+}
6671+*/
6672+ pOut->_11 = 2.0 / (r - 1.0);
6673+ pOut->_12 = 0;
6674+ pOut->_13 = 0;
6675+ pOut->_14 = 0;
6676+
6677+ pOut->_21 = 0;
6678+ pOut->_22 = 2.0 / (t - b);
6679+ pOut->_23 = 0;
6680+ pOut->_24 = 0;
6681+
6682+ pOut->_31 = 0;
6683+ pOut->_32 = 0;
6684+ pOut->_33 = 1.0 / (zn - zf);
6685+ pOut->_34 = 0;
6686+
6687+ pOut->_41 = (1.0 + r) / (1.0 - r);
6688+ pOut->_42 = (t + b) / (b - t);
6689+ pOut->_43 = zn / (zn - zf);
6690+ pOut->_44 = 1;
6691+
6692+ return pOut;
6693+}
6694+
6695+
6696+
6697+
6698+
6699+/*I think this normalized on the magnitude, but I'm not sure!*/
6700+D3DXVECTOR3 *WINAPI D3DXVec3Normalize(
6701+ D3DXVECTOR3 *pOut,
6702+ CONST D3DXVECTOR3 *pV
6703+){
6704+ float d = D3DXVec3Length(pV);
6705+ if(d == 0 ){
6706+ pOut->x = 0;
6707+ pOut->y = 0;
6708+ pOut->z = 0;
6709+ }else{
6710+ return D3DXVec3Scale(pOut, pV, 1.0f/d);
6711+ }
6712+ return pOut;
6713+}
6714+
6715+
6716+float D3DXVec3Length(CONST D3DXVECTOR3 *pV){
6717+ return sqrt(pV->x * pV->y + pV->x * pV->x + pV->z * pV->z);
6718+}
6719+
6720+
6721+float D3DXVec3LengthSq(CONST D3DXVECTOR3 *pV){
6722+ return pV->x * pV->y + pV->x * pV->x + pV->z * pV->z;
6723+}
6724+
6725+float D3DXVec2Length(CONST D3DXVECTOR2 *pV){
6726+ return sqrt(pV->x * pV->y + pV->x * pV->x);
6727+}
6728+
6729+
6730+float D3DXVec2LengthSq(CONST D3DXVECTOR2 *pV){
6731+ return pV->x * pV->y + pV->x * pV->x;
6732+}
6733+
6734+float D3DXVec4Length(CONST D3DXVECTOR4 *pV){
6735+ return sqrt(pV->x * pV->y + pV->x * pV->x + pV->z * pV->z + pV->w * pV->w);
6736+}
6737+
6738+
6739+float D3DXVec4LengthSq(CONST D3DXVECTOR4 *pV){
6740+ return pV->x * pV->y + pV->x * pV->x + pV->z * pV->z + pV->w * pV->w;
6741+}
6742+
6743+
6744+
6745+D3DXVECTOR2 *D3DXVec2Scale(
6746+ D3DXVECTOR2 *pOut,
6747+ CONST D3DXVECTOR2 *pV,
6748+ FLOAT s
6749+){
6750+
6751+ pOut->x = pV->x * s;
6752+ pOut->y = pV->y * s;
6753+
6754+ return pOut;
6755+}
6756+
6757+
6758+D3DXVECTOR3 *D3DXVec3Scale(
6759+ D3DXVECTOR3 *pOut,
6760+ CONST D3DXVECTOR3 *pV,
6761+ FLOAT s
6762+){
6763+
6764+ pOut->x = pV->x * s;
6765+ pOut->y = pV->y * s;
6766+ pOut->z = pV->z * s;
6767+
6768+ return pOut;
6769+}
6770+
6771+
6772+
6773+D3DXVECTOR4 *D3DXVec4Scale(
6774+ D3DXVECTOR4 *pOut,
6775+ CONST D3DXVECTOR4 *pV,
6776+ FLOAT s
6777+){
6778+
6779+ pOut->x = pV->x * s;
6780+ pOut->y = pV->y * s;
6781+ pOut->z = pV->z * s;
6782+ pOut->w = pV->w * s;
6783+
6784+ return pOut;
6785+}
6786+
6787+
6788+D3DXVECTOR2 *D3DXVec2Add(
6789+ D3DXVECTOR2 *pOut,
6790+ CONST D3DXVECTOR2 *pV1,
6791+ CONST D3DXVECTOR2 *pV2
6792+){
6793+
6794+ pOut->x = pV1->x + pV2->x;
6795+ pOut->y = pV1->y + pV2->y;
6796+ return pOut;
6797+}
6798+
6799+
6800+D3DXVECTOR3 *D3DXVec3Add(
6801+ D3DXVECTOR3 *pOut,
6802+ CONST D3DXVECTOR3 *pV1,
6803+ CONST D3DXVECTOR3 *pV2
6804+){
6805+
6806+ pOut->x = pV1->x + pV2->x;
6807+ pOut->y = pV1->y + pV2->y;
6808+ pOut->z = pV1->z + pV2->z;
6809+ return pOut;
6810+}
6811+
6812+
6813+D3DXVECTOR4 *D3DXVec4Add(
6814+ D3DXVECTOR4 *pOut,
6815+ CONST D3DXVECTOR4 *pV1,
6816+ CONST D3DXVECTOR4 *pV2
6817+){
6818+
6819+ pOut->x = pV1->x + pV2->x;
6820+ pOut->y = pV1->y + pV2->y;
6821+ pOut->z = pV1->z + pV2->z;
6822+ pOut->w = pV1->w + pV2->w;
6823+ return pOut;
6824+}
6825+
6826+
6827+D3DXVECTOR3 *D3DXVec3Cross(
6828+ D3DXVECTOR3 *pOut,
6829+ CONST D3DXVECTOR3 *pV1,
6830+ CONST D3DXVECTOR3 *pV2
6831+){
6832+ /* MSDN says not MATRIX[3,3] = v[3,1]a * v[3,1]b */
6833+ pOut->x = pV1->y * pV2->z - pV1->z * pV2->y;
6834+ pOut->y = pV1->z * pV2->x - pV1->x * pV2->z;
6835+ pOut->z = pV1->x * pV2->y - pV1->y * pV2->x;
6836+ return pOut;
6837+}
6838+
6839+
6840+D3DXVECTOR4 *WINAPI D3DXVec4Cross(
6841+ D3DXVECTOR4 *pOut,
6842+ CONST D3DXVECTOR4 *pV1,
6843+ CONST D3DXVECTOR4 *pV2,
6844+ CONST D3DXVECTOR4 *pV3
6845+){
6846+/*MSDN doesn't give any clues to what they mean by this 'cross' product*/
6847+/*
6848+| X Y Z T |
6849+| Ux Uy Uz Ut |
6850+| Vx Vy Vz Vt |
6851+| Wx Wy Wz Wt |
6852+
6853+ pOut->_1 =
6854+ pOut->_2 =
6855+ pOut->_3 =
6856+ pOut->_4 =
6857+ */
6858+
6859+ FIXME("stub\n");
6860+ return pOut;
6861+}
6862+
6863+
6864+
6865+/*http://mathworld.wolfram.com/DotProduct.html*/
6866+FLOAT D3DXVec2Dot(
6867+ CONST D3DXVECTOR2 *pV1,
6868+ CONST D3DXVECTOR2 *pV2
6869+){
6870+ return pV1->x * pV2->x + pV1->y * pV2->y;
6871+}
6872+
6873+FLOAT D3DXVec3Dot(
6874+ CONST D3DXVECTOR3 *pV1,
6875+ CONST D3DXVECTOR3 *pV2
6876+){
6877+ return pV1->x * pV2->x + pV1->y * pV2->y + pV1->z * pV2->z;
6878+}
6879+
6880+
6881+FLOAT D3DXVec4Dot(
6882+ CONST D3DXVECTOR4 *pV1,
6883+ CONST D3DXVECTOR4 *pV2
6884+){
6885+ return pV1->x * pV2->x + pV1->y * pV2->y + pV1->z * pV2->z + pV1->w * pV2->w;
6886+}
6887+
6888+
6889+
6890+D3DXVECTOR2 *D3DXVec2Subtract(
6891+ D3DXVECTOR2 *pOut,
6892+ CONST D3DXVECTOR2 *pV1,
6893+ CONST D3DXVECTOR2 *pV2
6894+){
6895+ pOut->x = pV1->x - pV2->x;
6896+ pOut->y = pV1->y - pV2->y;
6897+ return pOut;
6898+}
6899+
6900+
6901+D3DXVECTOR3 *D3DXVec3Subtract(
6902+ D3DXVECTOR3 *pOut,
6903+ CONST D3DXVECTOR3 *pV1,
6904+ CONST D3DXVECTOR3 *pV2
6905+){
6906+
6907+ pOut->x = pV1->x - pV2->x;
6908+ pOut->y = pV1->y - pV2->y;
6909+ pOut->z = pV1->z - pV2->z;
6910+ return pOut;
6911+}
6912+
6913+
6914+D3DXVECTOR4 *D3DXVec4Subtract(
6915+ D3DXVECTOR4 *pOut,
6916+ CONST D3DXVECTOR4 *pV1,
6917+ CONST D3DXVECTOR4 *pV2
6918+){
6919+
6920+ pOut->x = pV1->x - pV2->x;
6921+ pOut->y = pV1->y - pV2->y;
6922+ pOut->z = pV1->z - pV2->z;
6923+ pOut->w = pV1->w - pV2->w;
6924+ return pOut;
6925+}
6926diff -urN wine.20050419/dlls/d3dx9/d3dx9core_private.h wine.20050419.dx9/dlls/d3dx9/d3dx9core_private.h
6927--- wine.20050419/dlls/d3dx9/d3dx9core_private.h 1969-12-31 17:00:00.000000000 -0700
6928+++ wine.20050419.dx9/dlls/d3dx9/d3dx9core_private.h 2005-04-20 01:52:56.000000000 -0600
6929@@ -0,0 +1,97 @@
6930+/*
6931+ * Direct3D X 8 private include file
6932+ *
6933+ * Copyright 2002 Raphael Junqueira
6934+ *
6935+ * This library is free software; you can redistribute it and/or
6936+ * modify it under the terms of the GNU Lesser General Public
6937+ * License as published by the Free Software Foundation; either
6938+ * version 2.1 of the License, or (at your option) any later version.
6939+ *
6940+ * This library is distributed in the hope that it will be useful,
6941+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
6942+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
6943+ * Lesser General Public License for more details.
6944+ *
6945+ * You should have received a copy of the GNU Lesser General Public
6946+ * License along with this library; if not, write to the Free Software
6947+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
6948+ */
6949+
6950+#ifndef __WINE_D3DX8CORE_PRIVATE_H
6951+#define __WINE_D3DX8CORE_PRIVATE_H
6952+
6953+#include <stdarg.h>
6954+
6955+#include "windef.h"
6956+#include "winbase.h"
6957+#include "d3dx9core.h"
6958+
6959+/* Interfaces */
6960+typedef struct ID3DXBufferImpl ID3DXBufferImpl;
6961+typedef struct ID3DXFontImpl ID3DXFontImpl;
6962+
6963+/* ----------- */
6964+/* ID3DXBuffer */
6965+/* ----------- */
6966+
6967+/*****************************************************************************
6968+ * Predeclare the interface implementation structures
6969+ */
6970+extern ID3DXBufferVtbl D3DXBuffer_Vtbl;
6971+
6972+
6973+/*****************************************************************************
6974+ * ID3DXBufferImpl implementation structure
6975+ */
6976+struct ID3DXBufferImpl
6977+{
6978+ /* IUnknown fields */
6979+ ID3DXBufferVtbl *lpVtbl;
6980+ DWORD ref;
6981+
6982+ /* ID3DXBuffer fields */
6983+ DWORD *buffer;
6984+ DWORD bufferSize;
6985+};
6986+
6987+/* IUnknown: */
6988+extern HRESULT WINAPI ID3DXBufferImpl_QueryInterface(LPD3DXBUFFER iface, REFIID refiid, LPVOID *obj);
6989+extern ULONG WINAPI ID3DXBufferImpl_AddRef(LPD3DXBUFFER iface);
6990+extern ULONG WINAPI ID3DXBufferImpl_Release(LPD3DXBUFFER iface);
6991+
6992+/* ID3DXBuffer: */
6993+extern LPVOID WINAPI ID3DXBufferImpl_GetBufferPointer(LPD3DXBUFFER iface);
6994+extern DWORD WINAPI ID3DXBufferImpl_GetBufferSize(LPD3DXBUFFER iface);
6995+
6996+/* --------- */
6997+/* ID3DXFont */
6998+/* --------- */
6999+
7000+/*****************************************************************************
7001+ * Predeclare the interface implementation structures
7002+ */
7003+extern ID3DXFontVtbl D3DXFont_Vtbl;
7004+
7005+/*****************************************************************************
7006+ * ID3DXFontImpl implementation structure
7007+ */
7008+struct ID3DXFontImpl
7009+{
7010+ /* IUnknown fields */
7011+ ID3DXFontVtbl *lpVtbl;
7012+ DWORD ref;
7013+
7014+ /* ID3DXFont fields */
7015+ LPDIRECT3DDEVICE9 device;
7016+};
7017+
7018+/* IUnknown: */
7019+extern HRESULT WINAPI ID3DXFontImpl_QueryInterface(LPD3DXFONT iface, REFIID refiid, LPVOID *obj);
7020+extern ULONG WINAPI ID3DXFontImpl_AddRef(LPD3DXFONT iface);
7021+extern ULONG WINAPI ID3DXFontImpl_Release(LPD3DXFONT iface);
7022+
7023+/* ID3DXFont: */
7024+/*extern INT WINAPI ID3DXFontImpl_DrawTextA(LPCSTR pString, INT Count, LPRECT pRect, DWORD Format, D3DCOLOR Color); */
7025+
7026+#endif /*__WINE_D3DX8CORE_PRIVATE_H */
7027diff -urN wine.20050419/dlls/d3dx9/d3dxbuffer.c wine.20050419.dx9/dlls/d3dx9/d3dxbuffer.c
7028--- wine.20050419/dlls/d3dx9/d3dxbuffer.c 1969-12-31 17:00:00.000000000 -0700
7029+++ wine.20050419.dx9/dlls/d3dx9/d3dxbuffer.c 2005-04-20 01:52:56.000000000 -0600
7030@@ -0,0 +1,87 @@
7031+/*
7032+ * ID3DXBuffer implementation
7033+ *
7034+ * Copyright 2002 Raphael Junqueira
7035+ *
7036+ * This library is free software; you can redistribute it and/or
7037+ * modify it under the terms of the GNU Lesser General Public
7038+ * License as published by the Free Software Foundation; either
7039+ * version 2.1 of the License, or (at your option) any later version.
7040+ *
7041+ * This library is distributed in the hope that it will be useful,
7042+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
7043+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
7044+ * Lesser General Public License for more details.
7045+ *
7046+ * You should have received a copy of the GNU Lesser General Public
7047+ * License along with this library; if not, write to the Free Software
7048+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
7049+ */
7050+
7051+#include "config.h"
7052+#include "wine/port.h"
7053+
7054+#include <stdarg.h>
7055+
7056+#include "windef.h"
7057+#include "winbase.h"
7058+#include "winuser.h"
7059+#include "wingdi.h"
7060+#include "wine/debug.h"
7061+
7062+#include "d3d9.h"
7063+#include "d3dx9core_private.h"
7064+
7065+WINE_DEFAULT_DEBUG_CHANNEL(d3d);
7066+
7067+/* ID3DXBuffer IUnknown parts follow: */
7068+HRESULT WINAPI ID3DXBufferImpl_QueryInterface(LPD3DXBUFFER iface, REFIID riid, LPVOID* ppobj) {
7069+ ID3DXBufferImpl *This = (ID3DXBufferImpl *)iface;
7070+
7071+ if (IsEqualGUID(riid, &IID_IUnknown)
7072+ || IsEqualGUID(riid, &IID_ID3DXBuffer)) {
7073+ ID3DXBufferImpl_AddRef(iface);
7074+ *ppobj = This;
7075+ return D3D_OK;
7076+ }
7077+
7078+ WARN("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppobj);
7079+ return E_NOINTERFACE;
7080+}
7081+
7082+ULONG WINAPI ID3DXBufferImpl_AddRef(LPD3DXBUFFER iface) {
7083+ ID3DXBufferImpl *This = (ID3DXBufferImpl *)iface;
7084+ TRACE("(%p) : AddRef from %ld\n", This, This->ref);
7085+ return ++(This->ref);
7086+}
7087+
7088+ULONG WINAPI ID3DXBufferImpl_Release(LPD3DXBUFFER iface) {
7089+ ID3DXBufferImpl *This = (ID3DXBufferImpl *)iface;
7090+ ULONG ref = --This->ref;
7091+ TRACE("(%p) : ReleaseRef to %ld\n", This, This->ref);
7092+ if (ref == 0) {
7093+ HeapFree(GetProcessHeap(), 0, This->buffer);
7094+ HeapFree(GetProcessHeap(), 0, This);
7095+ }
7096+ return ref;
7097+}
7098+
7099+/* ID3DXBuffer Interface follow: */
7100+LPVOID WINAPI ID3DXBufferImpl_GetBufferPointer(LPD3DXBUFFER iface) {
7101+ ID3DXBufferImpl *This = (ID3DXBufferImpl *)iface;
7102+ return This->buffer;
7103+}
7104+
7105+DWORD WINAPI ID3DXBufferImpl_GetBufferSize(LPD3DXBUFFER iface) {
7106+ ID3DXBufferImpl *This = (ID3DXBufferImpl *)iface;
7107+ return This->bufferSize;
7108+}
7109+
7110+ID3DXBufferVtbl D3DXBuffer_Vtbl =
7111+{
7112+ ID3DXBufferImpl_QueryInterface,
7113+ ID3DXBufferImpl_AddRef,
7114+ ID3DXBufferImpl_Release,
7115+ ID3DXBufferImpl_GetBufferPointer,
7116+ ID3DXBufferImpl_GetBufferSize
7117+};
7118diff -urN wine.20050419/dlls/d3dx9/font.c wine.20050419.dx9/dlls/d3dx9/font.c
7119--- wine.20050419/dlls/d3dx9/font.c 1969-12-31 17:00:00.000000000 -0700
7120+++ wine.20050419.dx9/dlls/d3dx9/font.c 2005-04-20 01:52:56.000000000 -0600
7121@@ -0,0 +1,152 @@
7122+/*
7123+ * ID3DXfont implementation
7124+ *
7125+ * Copyright 2005 Oliver Stieber
7126+ *
7127+ * This library is free software; you can redistribute it and/or
7128+ * modify it under the terms of the GNU Lesser General Public
7129+ * License as published by the Free Software Foundation; either
7130+ * version 2.1 of the License, or (at your option) any later version.
7131+ *
7132+ * This library is distributed in the hope that it will be useful,
7133+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
7134+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
7135+ * Lesser General Public License for more details.
7136+ *
7137+ * You should have received a copy of the GNU Lesser General Public
7138+ * License along with this library; if not, write to the Free Software
7139+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
7140+ */
7141+
7142+#include "config.h"
7143+#include "wine/port.h"
7144+
7145+#include <stdarg.h>
7146+
7147+#include "windef.h"
7148+#include "winbase.h"
7149+#include "winuser.h"
7150+#include "wingdi.h"
7151+#include "wine/debug.h"
7152+
7153+#include "d3d9.h"
7154+#include "d3dx9core_private.h"
7155+
7156+WINE_DEFAULT_DEBUG_CHANNEL(d3d);
7157+
7158+/* ID3DXBuffer IUnknown parts follow: */
7159+HRESULT WINAPI ID3DXFontImpl_QueryInterface(LPD3DXFONT iface, REFIID riid, LPVOID* ppobj) {
7160+ ID3DXFontImpl *This = (ID3DXFontImpl *)iface;
7161+
7162+ if (IsEqualGUID(riid, &IID_IUnknown)
7163+ || IsEqualGUID(riid, &IID_ID3DXBuffer)) {
7164+ ID3DXFontImpl_AddRef(iface);
7165+ *ppobj = This;
7166+ return D3D_OK;
7167+ }
7168+
7169+ WARN("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppobj);
7170+ return E_NOINTERFACE;
7171+}
7172+
7173+ULONG WINAPI ID3DXFontImpl_AddRef(LPD3DXFONT iface) {
7174+ ID3DXFontImpl *This = (ID3DXFontImpl *)iface;
7175+ TRACE("(%p) : AddRef from %ld\n", This, This->ref);
7176+ return ++(This->ref);
7177+}
7178+
7179+ULONG WINAPI ID3DXFontImpl_Release(LPD3DXFONT iface) {
7180+ ID3DXFontImpl *This = (ID3DXFontImpl *)iface;
7181+ ULONG ref = --This->ref;
7182+ TRACE("(%p) : ReleaseRef to %ld\n", This, This->ref);
7183+ if (ref == 0) {
7184+ /*TODO: relese the device if we have one*/
7185+ if(This->device != NULL){
7186+ IDirect3DDevice9_Release(This->device);
7187+ }
7188+ HeapFree(GetProcessHeap(), 0, This);
7189+ }
7190+ return ref;
7191+}
7192+
7193+
7194+
7195+/* ID3DXFont Interface follow: */
7196+
7197+
7198+HRESULT WINAPI ID3DXFontImpl_GetDevice(LPD3DXFONT iface, LPDIRECT3DDEVICE9* ppDevice){
7199+ ID3DXFontImpl *This = (ID3DXFontImpl *)iface;
7200+ TRACE("(%p) : rturning %p \n", This, This->device);
7201+ *ppDevice = This->device;
7202+ IDirect3DDevice9_AddRef(*ppDevice);
7203+ return S_OK;
7204+}
7205+
7206+HRESULT WINAPI ID3DXFontImpl_GetLogFont(LPD3DXFONT iface, PLOGFONTA pLogFont){
7207+ ID3DXFontImpl *This = (ID3DXFontImpl *)iface;
7208+ FIXME("(%p) : stub\n", This);
7209+ return D3D_OK;
7210+}
7211+
7212+HRESULT WINAPI ID3DXFontImpl_Begin(LPD3DXFONT iface){
7213+ ID3DXFontImpl *This = (ID3DXFontImpl *)iface;
7214+ FIXME("(%p) : stub\n", This);
7215+ return D3D_OK;
7216+}
7217+
7218+INT WINAPI ID3DXFontImpl_DrawTextA(LPD3DXFONT iface, LPCSTR pString, INT Count,
7219+ LPRECT pRect, DWORD Format, D3DCOLOR Color){
7220+ ID3DXFontImpl *This = (ID3DXFontImpl *)iface;
7221+ /*IWineD3D needs to have a writeText function that just wraps up the openGl text functions*/
7222+ FIXME("(%p) : stub\n", This);
7223+ return D3D_OK;
7224+}
7225+
7226+INT WINAPI ID3DXFontImpl_DrawTextW(LPD3DXFONT iface, LPCWSTR pString, INT Count,
7227+ LPRECT pRect, DWORD Format, D3DCOLOR Color){
7228+ ID3DXFontImpl *This = (ID3DXFontImpl *)iface;
7229+ /*IWineD3D needs to have a writeText function that just wraps up the openGl text functions*/
7230+ FIXME("(%p) : stub\n", This);
7231+ return D3D_OK;
7232+}
7233+
7234+
7235+
7236+HRESULT WINAPI ID3DXFontImpl_End(LPD3DXFONT iface){
7237+ ID3DXFontImpl *This = (ID3DXFontImpl *)iface;
7238+ FIXME("(%p) : stub\n", This);
7239+ return D3D_OK;
7240+}
7241+
7242+
7243+HRESULT WINAPI ID3DXFontImpl_OnLostDevice(LPD3DXFONT iface){
7244+ ID3DXFontImpl *This = (ID3DXFontImpl *)iface;
7245+ FIXME("(%p) : stub\n", This);
7246+ return S_OK;
7247+}
7248+
7249+HRESULT WINAPI ID3DXFontImpl_OnResetDevice(LPD3DXFONT iface){
7250+ ID3DXFontImpl *This = (ID3DXFontImpl *)iface;
7251+ FIXME("(%p) : stub\n", This);
7252+ return S_OK;
7253+}
7254+
7255+
7256+
7257+
7258+
7259+ID3DXFontVtbl D3DXFont_Vtbl =
7260+{
7261+ ID3DXFontImpl_QueryInterface,
7262+ ID3DXFontImpl_AddRef,
7263+ ID3DXFontImpl_Release,
7264+ ID3DXFontImpl_GetDevice,
7265+ ID3DXFontImpl_GetLogFont,
7266+ ID3DXFontImpl_Begin,
7267+ ID3DXFontImpl_DrawTextA,
7268+ ID3DXFontImpl_DrawTextW,
7269+ ID3DXFontImpl_End,
7270+ ID3DXFontImpl_OnLostDevice,
7271+ ID3DXFontImpl_OnResetDevice
7272+
7273+};
7274diff -urN wine.20050419/dlls/ddraw/ddraw/user.c wine.20050419.dx9/dlls/ddraw/ddraw/user.c
7275--- wine.20050419/dlls/ddraw/ddraw/user.c 2005-03-07 04:01:10.000000000 -0700
7276+++ wine.20050419.dx9/dlls/ddraw/ddraw/user.c 2005-04-20 06:35:28.000000000 -0600
7277@@ -162,8 +162,8 @@
7278 This->caps.dwCKeyCaps |= CKEY_CAPS;
7279 This->caps.dwFXCaps |= FX_CAPS;
7280 This->caps.dwPalCaps |= DDPCAPS_8BIT | DDPCAPS_PRIMARYSURFACE;
7281- This->caps.dwVidMemTotal = 16*1024*1024;
7282- This->caps.dwVidMemFree = 16*1024*1024;
7283+ This->caps.dwVidMemTotal = 96*1024*1024;
7284+ This->caps.dwVidMemFree = 80*1024*1024;
7285 This->caps.dwSVBCaps |= BLIT_CAPS;
7286 This->caps.dwSVBCKeyCaps |= CKEY_CAPS;
7287 This->caps.dwSVBFXCaps |= FX_CAPS;
7288diff -urN wine.20050419/dlls/wined3d/Makefile.in wine.20050419.dx9/dlls/wined3d/Makefile.in
7289--- wine.20050419/dlls/wined3d/Makefile.in 2005-03-03 06:57:15.000000000 -0700
7290+++ wine.20050419.dx9/dlls/wined3d/Makefile.in 2005-04-20 01:52:56.000000000 -0600
7291@@ -5,7 +5,7 @@
7292 MODULE = wined3d.dll
7293 IMPORTS = user32 gdi32 advapi32 kernel32
7294 EXTRAINCL = @X_CFLAGS@
7295-EXTRALIBS = -ldxguid -luuid @X_LIBS@ @X_PRE_LIBS@ @XLIB@ @X_EXTRA_LIBS@ @OPENGL_LIBS@
7296+EXTRALIBS = -luuid @X_LIBS@ @X_PRE_LIBS@ @XLIB@ @X_EXTRA_LIBS@ @OPENGL_LIBS@
7297
7298 C_SRCS = \
7299 basetexture.c \
7300@@ -14,10 +14,12 @@
7301 directx.c \
7302 drawprim.c \
7303 indexbuffer.c \
7304+ pixelshader.c \
7305 query.c \
7306 resource.c \
7307 stateblock.c \
7308 surface.c \
7309+ swapchain.c \
7310 texture.c \
7311 utils.c \
7312 vertexbuffer.c \
7313diff -urN wine.20050419/dlls/wined3d/cubetexture.c wine.20050419.dx9/dlls/wined3d/cubetexture.c
7314--- wine.20050419/dlls/wined3d/cubetexture.c 2005-03-29 12:01:00.000000000 -0700
7315+++ wine.20050419.dx9/dlls/wined3d/cubetexture.c 2005-04-20 05:17:56.000000000 -0600
7316@@ -75,7 +75,7 @@
7317 TRACE("(%p) : Releasing from %ld\n", This, This->resource.ref);
7318 ref = InterlockedDecrement(&This->resource.ref);
7319 if (ref == 0) {
7320- int i,j;
7321+ int i,j;
7322 for (i = 0; i < This->baseTexture.levels; i++) {
7323 for (j = 0; j < 6; j++) {
7324 if (This->surfaces[j][i] != NULL) {
7325@@ -84,7 +84,12 @@
7326 }
7327 }
7328 }
7329- IWineD3DBaseTextureImpl_CleanUp((IWineD3DBaseTexture *) iface);
7330+ if(This->baseTexture.textureName != 0){
7331+ ENTER_GL();
7332+ TRACE("Deleting texture %d\n", This->baseTexture.textureName);
7333+ glDeleteTextures(1, &This->baseTexture.textureName);
7334+ LEAVE_GL();
7335+ }
7336 HeapFree(GetProcessHeap(), 0, This);
7337 } else {
7338 IUnknown_Release(This->resource.parent); /* Released the reference to the d3dx object */
7339@@ -127,18 +132,32 @@
7340 TRACE("(%p) : About to load texture: dirtified(%d)\n", This, This->baseTexture.dirty);
7341
7342 IWineD3DCubeTexture_BindTexture(iface);
7343-
7344- ENTER_GL();
7345- /* If were dirty then reload the surfaces */
7346- if(This->baseTexture.dirty != FALSE) {
7347- for (i = 0; i < This->baseTexture.levels; i++) {
7348- for (j = 0; j < 6; j++)
7349- IWineD3DSurface_LoadTexture((IWineD3DSurface *) This->surfaces[j][i], cube_targets[j], i);
7350+ #if 0 /* TODO: context manager support */
7351+ IWineD3DContextManager_PushState(This->contextManager, GL_TEXTURE_CUBE_MAP_ARB, ENABLED, NOW /* make sure the state is applied now */);
7352+ #else
7353+ glEnable(GL_TEXTURE_CUBE_MAP_ARB);
7354+ #endif
7355+ /* TODO: remove the use of (IWineD3DSurfaceImpl *)
7356+ * (put the texturename in the cubetexture!)
7357+ */
7358+ for (i = 0; i < This->baseTexture.levels; i++) {
7359+ if (i == 0 && This->baseTexture.textureName != 0 && This->baseTexture.dirty == FALSE) {
7360+
7361+ glBindTexture(GLTEXTURECUBEMAP, This->baseTexture.textureName);
7362+ TRACE("Texture %p given name %d\n", This, This->baseTexture.textureName);
7363+ if (This->baseTexture.textureName == 0) {
7364+ glGenTextures(1, &This->baseTexture.textureName);
7365+ TRACE("Texture %p given name %d\n", This, This->baseTexture.textureName);
7366+ glBindTexture(GLTEXTURECUBEMAP, This->baseTexture.textureName);
7367+ }
7368 }
7369 /* No longer dirty */
7370 This->baseTexture.dirty = FALSE;
7371 }
7372 LEAVE_GL();
7373+ #if 0 /* TODO: context manager support */
7374+ IWineD3DContextManager_PopState(This->contextManager, GL_TEXTURE_CUBE_MAP_ARB, DISABLED, DELAYED);
7375+ #endif
7376 return ;
7377 }
7378
7379@@ -304,3 +323,4 @@
7380 IWineD3DCubeTextureImpl_UnlockRect,
7381 IWineD3DCubeTextureImpl_AddDirtyRect
7382 };
7383+
7384diff -urN wine.20050419/dlls/wined3d/device.c wine.20050419.dx9/dlls/wined3d/device.c
7385--- wine.20050419/dlls/wined3d/device.c 2005-03-29 12:01:00.000000000 -0700
7386+++ wine.20050419.dx9/dlls/wined3d/device.c 2005-04-20 05:31:50.000000000 -0600
7387@@ -21,14 +21,46 @@
7388 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
7389 */
7390
7391+
7392 #include "config.h"
7393 #include "wined3d_private.h"
7394
7395+/* TODO: repalce with iface usage! NOTE: this macro is used by other macros such as GL_SUPPORT */
7396+#if 0
7397+#define GLINFO_LOCATION (IWineD3D_GetGlInfo(This->wineD3D))
7398+#else
7399+#define GLINFO_LOCATION ((IWineD3DImpl *)(This->wineD3D))->gl_info
7400+#endif
7401 WINE_DEFAULT_DEBUG_CHANNEL(d3d);
7402-WINE_DECLARE_DEBUG_CHANNEL(d3d_caps);
7403-WINE_DECLARE_DEBUG_CHANNEL(d3d_fps);
7404 WINE_DECLARE_DEBUG_CHANNEL(d3d_shader);
7405-#define GLINFO_LOCATION ((IWineD3DImpl *)(This->wineD3D))->gl_info
7406+WINE_DECLARE_DEBUG_CHANNEL(d3d_surface);
7407+WINE_DECLARE_DEBUG_CHANNEL(d3d_timings);
7408+
7409+/* x11drv GDI escapes */
7410+#define X11DRV_ESCAPE 6789
7411+enum x11drv_escape_codes
7412+{
7413+ X11DRV_GET_DISPLAY, /* get X11 display for a DC */
7414+ X11DRV_GET_DRAWABLE, /* get current drawable for a DC */
7415+ X11DRV_GET_FONT, /* get current X font for a DC */
7416+};
7417+
7418+/* retrieve the X display to use on a given DC */
7419+inline static Display *get_display( HDC hdc )
7420+{
7421+ Display *display;
7422+ enum x11drv_escape_codes escape = X11DRV_GET_DISPLAY;
7423+
7424+ if (!ExtEscape( hdc, X11DRV_ESCAPE, sizeof(escape), (LPCSTR)&escape,
7425+ sizeof(display), (LPSTR)&display )) display = NULL;
7426+ return display;
7427+}
7428+
7429+
7430+/* Memory tracking and object counting */
7431+ int emmulated_textureram = 256*1024*1024;
7432+
7433+
7434
7435 /* helper macros */
7436 #define D3DMEMCHECK(object, ppResult) if(NULL == object){ *ppResult = NULL; WARN("Out of memory\n"); return D3DERR_OUTOFVIDEOMEMORY;}
7437@@ -80,7 +112,7 @@
7438 float colRGBA[] = {0.0, 0.0, 0.0, 0.0};
7439 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
7440
7441- /* Light settings are affected by the model view in OpenGL, the View transform in direct3d*/
7442+ /* Light settings are affected by the model view in OpenGL, the View transform in direct3d */
7443 glMatrixMode(GL_MODELVIEW);
7444 glPushMatrix();
7445 glLoadMatrixf((float *) &This->stateBlock->transforms[D3DTS_VIEW].u.m[0][0]);
7446@@ -170,7 +202,7 @@
7447 BOOL changeTexture = TRUE;
7448
7449 TRACE("-----------------------> Updating the texture at stage %ld to have new texture state information\n", Stage);
7450- for (i = 1; i < HIGHEST_TEXTURE_STATE; i++) {
7451+ for (i = 1; i <= HIGHEST_TEXTURE_STATE; i++) {
7452
7453 BOOL skip = FALSE;
7454
7455@@ -186,21 +218,21 @@
7456 skip = TRUE;
7457 break;
7458
7459- /* Performance: If the texture states only impact settings for the texture unit
7460+ /* Performance: If the texture states only impact settings for the texture unit
7461 (compared to the texture object) then there is no need to reapply them. The
7462- only time they need applying is the first time, since we cheat and put the
7463- values into the stateblock without applying.
7464+ only time they need applying is the first time, since we cheat and put the
7465+ values into the stateblock without applying.
7466 Per-texture unit: texture function (eg. combine), ops and args
7467- texture env color
7468- texture generation settings
7469+ texture env color
7470+ texture generation settings
7471 Note: Due to some special conditions there may be a need to do particular ones
7472 of these, which is what the Flags allows */
7473- case D3DTSS_COLOROP:
7474+ case D3DTSS_COLOROP:
7475 case D3DTSS_TEXCOORDINDEX:
7476 if (!(Flags == REAPPLY_ALL)) skip=TRUE;
7477 break;
7478
7479- case D3DTSS_ALPHAOP:
7480+ case D3DTSS_ALPHAOP:
7481 if (!(Flags & REAPPLY_ALPHAOP)) skip=TRUE;
7482 break;
7483
7484@@ -225,6 +257,9 @@
7485 }
7486 }
7487
7488+ for (i = 1; i <= HIGHEST_SAMPLER_STATE;i++) {
7489+ IWineD3DDevice_SetSamplerState(iface, Stage, i, This->stateBlock->samplerState[Stage][i]);
7490+ }
7491 /* Note the D3DRS value applies to all textures, but GL has one
7492 * per texture, so apply it now ready to be used!
7493 */
7494@@ -232,26 +267,23 @@
7495 glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, &col[0]);
7496 checkGLcall("glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, color);");
7497
7498- TRACE("-----------------------> Updated the texture at stage %ld to have new texture state information\n", Stage);
7499+ TRACE("-----------------------> Updated the texture at stage %ld to have new texture state information\n", Stage);
7500 }
7501
7502 /**********************************************************
7503 * IUnknown parts follows
7504 **********************************************************/
7505-
7506-HRESULT WINAPI IWineD3DDeviceImpl_QueryInterface(IWineD3DDevice *iface,REFIID riid,LPVOID *ppobj)
7507+HRESULT WINAPI IWineD3DDeviceImpl_QueryInterface(IWineD3DDevice *iface, REFIID riid, LPVOID *ppobj)
7508 {
7509 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
7510 /* FIXME: This needs to extend an IWineD3DBaseObject */
7511-
7512 TRACE("(%p)->(%s,%p)\n",This,debugstr_guid(riid),ppobj);
7513- if (IsEqualGUID(riid, &IID_IUnknown)
7514+ if (IsEqualGUID(riid, &IID_IUnknown)
7515 || IsEqualGUID(riid, &IID_IWineD3DDevice)) {
7516 IUnknown_AddRef(iface);
7517 *ppobj = This;
7518 return D3D_OK;
7519 }
7520-
7521 return E_NOINTERFACE;
7522 }
7523
7524@@ -263,21 +295,72 @@
7525 return refCount;
7526 }
7527
7528+
7529 ULONG WINAPI IWineD3DDeviceImpl_Release(IWineD3DDevice *iface) {
7530 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
7531- ULONG refCount = InterlockedDecrement(&This->ref);
7532-
7533- TRACE("(%p) : Releasing from %ld\n", This, refCount + 1);
7534-
7535+ ULONG refCount;
7536+ TRACE("(%p) : Releasing from %ld\n", This, This->ref);
7537+ refCount = InterlockedDecrement(&This->ref);
7538 if (!refCount) {
7539- /* TODO: Clean up all the surfaces and textures! */
7540- /* FIXME: Create targets and state blocks in d3d8 */
7541- if (((IWineD3DImpl *)This->wineD3D)->dxVersion > 8) { /*We don't create a state block in d3d8 yet*/
7542+ /* Clean up all the surfaces and textures! */
7543+ /* FIXME: Create targets and stablocks in d3d8 */
7544+ /* TODO: repalce impl usage with IWineD3D_GetVersion */
7545+ if (((IWineD3DImpl *)This->wineD3D)->dxVersion > 8) { /* We don't create a state block in d3d8 yet */
7546 /* NOTE: You must release the parent if the objects was created via a callback
7547+ * Some of thease objects are going to callback to the device and day that they have been relesed.
7548+ * I'm not sure what the best way to prevent a deadlock is, either tell the objets not to callback,
7549+ * tell the callback function not to do anything (this is better since it's internal to the device object)
7550+ * try to make the functions 100% atomic so that it doesn't matter (this is the best solution but trickier, and we'd also need more critical sections), because we should be using itterators on the collections so long as the itterators can cope we're ok?
7551 ** ***************************/
7552- IWineD3DStateBlock_Release((IWineD3DStateBlock *)This->stateBlock);
7553+ /* Release all of the swapchains, except the implicite swapchain */
7554+ int i;
7555+ IUnknown* stencilBufferParent;
7556+ IUnknown* swapChainParent;
7557+
7558+ /* NOTE: Don't release swapchain 0 here, it's 'special' */
7559+ for(i = 1; i < This->numberOfSwapChains; i++){
7560+ /* TODO: don't access swapchains[x] directly! */
7561+ IWineD3DSwapChain_Release(This->swapchains[i]);
7562+ }
7563+
7564+ /* Release the buffers (with sanity checks)*/
7565+ if(This->stencilBufferTarget != NULL && (IWineD3DSurface_Release(This->stencilBufferTarget) >0)){
7566+ if(This->depthStencilBuffer != This->stencilBufferTarget)
7567+ FIXME("(%p) Something's still holding the depthStencilBuffer\n",This);
7568+ }
7569+
7570+ if(IWineD3DSurface_Release(This->renderTarget) >0){
7571+ /* This check is a bit silly, itshould be in swapchain_release FIXME("(%p) Something's still holding the renderTarget\n",This); */
7572+ }
7573+
7574+ IWineD3DSurface_GetParent(This->depthStencilBuffer, &stencilBufferParent);
7575+ IUnknown_Release(stencilBufferParent); /* once for the get parent */
7576+ if(IUnknown_Release(stencilBufferParent) >0){ /* the second time for when it was created */
7577+ FIXME("(%p) Something's still holding the depthStencilBuffer\n",This);
7578+ }
7579+
7580+ /* Release the update stateblock */
7581+ if(IWineD3DStateBlock_Release((IWineD3DStateBlock *)This->updateStateBlock) > 0){
7582+ if(This->updateStateBlock != This->stateBlock)
7583+ FIXME("(%p) Something's still holding the Update stateblock\n",This);
7584+ }
7585+
7586+ /* Release the stateblock */
7587+ if(IWineD3DStateBlock_Release((IWineD3DStateBlock *)This->stateBlock) > 0){
7588+ FIXME("(%p) Something's still holding the Update stateblock\n",This);
7589+ }
7590+
7591+ /* Swapchain 0 is special because it's created in startup with a hanging parent, so we have to release it's parent now */
7592+ /* TODO: don't access swapchains[x] directly!, check that there are no-more swapchains left for this device! */
7593+ IWineD3DSwapChain_GetParent(This->swapchains[0], &swapChainParent);
7594+ IUnknown_Release(swapChainParent); /* once for the get parent */
7595+ if(IUnknown_Release(swapChainParent) > 0){ /* the second time for when it was created */
7596+ FIXME("(%p) Something's still holding the implicite swapchain\n",This);
7597+ }
7598+
7599 }
7600 IWineD3D_Release(This->wineD3D);
7601+ TRACE("freed device %p \n",This);
7602 HeapFree(GetProcessHeap(), 0, This);
7603 }
7604 return refCount;
7605@@ -293,14 +376,14 @@
7606 return D3D_OK;
7607 }
7608
7609-HRESULT WINAPI IWineD3DDeviceImpl_CreateVertexBuffer(IWineD3DDevice *iface, UINT Size, DWORD Usage,
7610+HRESULT WINAPI IWineD3DDeviceImpl_CreateVertexBuffer(IWineD3DDevice *iface, UINT Size, DWORD Usage,
7611 DWORD FVF, D3DPOOL Pool, IWineD3DVertexBuffer** ppVertexBuffer, HANDLE *sharedHandle,
7612 IUnknown *parent) {
7613 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
7614 IWineD3DVertexBufferImpl *object;
7615 WINED3DFORMAT Format = WINED3DFMT_VERTEXDATA; /* Dummy format for now */
7616 D3DCREATERESOURCEOBJECTINSTANCE(object, VertexBuffer, D3DRTYPE_VERTEXBUFFER)
7617-
7618+
7619 object->resource.size = Size;
7620 object->resource.allocatedMemory = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, object->resource.size);
7621 object->FVF = FVF;
7622@@ -311,20 +394,20 @@
7623 return D3D_OK;
7624 }
7625
7626-HRESULT WINAPI IWineD3DDeviceImpl_CreateIndexBuffer(IWineD3DDevice *iface, UINT Length, DWORD Usage,
7627+HRESULT WINAPI IWineD3DDeviceImpl_CreateIndexBuffer(IWineD3DDevice *iface, UINT Length, DWORD Usage,
7628 WINED3DFORMAT Format, D3DPOOL Pool, IWineD3DIndexBuffer** ppIndexBuffer,
7629 HANDLE *sharedHandle, IUnknown *parent) {
7630 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
7631 IWineD3DIndexBufferImpl *object;
7632 TRACE("(%p) Creating index buffer\n", This);
7633-
7634+
7635 /* Allocate the storage for the device */
7636 D3DCREATERESOURCEOBJECTINSTANCE(object,IndexBuffer,D3DRTYPE_INDEXBUFFER)
7637-
7638+
7639 object->resource.size = Length;
7640 object->resource.allocatedMemory = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,object->resource.size);
7641
7642- TRACE("(%p) : Len=%d, Use=%lx, Format=(%u,%s), Pool=%d - Memory@%p, Iface@%p\n", This, Length, Usage, Format,
7643+ TRACE("(%p) : Len=%d, Use=%lx, Format=(%u,%s), Pool=%d - Memory@%p, Iface@%p\n", This, Length, Usage, Format,
7644 debug_d3dformat(Format), Pool, object, object->resource.allocatedMemory);
7645 *ppIndexBuffer = (IWineD3DIndexBuffer *) object;
7646
7647@@ -332,52 +415,142 @@
7648 }
7649
7650 HRESULT WINAPI IWineD3DDeviceImpl_CreateStateBlock(IWineD3DDevice* iface, D3DSTATEBLOCKTYPE Type, IWineD3DStateBlock** ppStateBlock, IUnknown *parent) {
7651-
7652+
7653 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
7654 IWineD3DStateBlockImpl *object;
7655+ unsigned int i;
7656+ unsigned int j;
7657
7658 D3DCREATEOBJECTINSTANCE(object, StateBlock)
7659- object->blockType = Type;
7660+ object->blockType = Type;
7661
7662 /* Special case - Used during initialization to produce a placeholder stateblock
7663 so other functions called can update a state block */
7664- if (Type == (D3DSTATEBLOCKTYPE) 0) {
7665+ if (Type == (D3DSTATEBLOCKTYPE)0) {
7666 /* Don't bother increasing the reference count otherwise a device will never
7667- be freed due to circular dependencies */
7668+ be freed due to circular dependencies */
7669 return D3D_OK;
7670 }
7671
7672- /* Otherwise, might as well set the whole state block to the appropriate values */
7673- IWineD3DDevice_AddRef(iface);
7674- memcpy(object, This->stateBlock, sizeof(IWineD3DStateBlockImpl));
7675- FIXME("unfinished - needs to set up changed and set attributes\n");
7676- return D3D_OK;
7677+ /* Otherwise, might as well set the whole state block to the appropriate values */
7678+ /* don't do this it will overight ref count &co too!? */
7679+ if( This->stateBlock != NULL){
7680+ memcpy(object, This->stateBlock, sizeof(IWineD3DStateBlockImpl));
7681+ } else {
7682+ memset(object->streamFreq, 1, sizeof(object->streamFreq));
7683+ }
7684+
7685+ /* Reset the ref and type after kluging it */
7686+ object->wineD3DDevice = This;
7687+ object->ref = 1;
7688+ object->blockType = Type;
7689+
7690+ TRACE("Updating changed flags appropriate for type %d\n", Type);
7691+
7692+ if (Type == D3DSBT_ALL) {
7693+ TRACE("ALL => Pretend everything has changed\n");
7694+ memset(&object->changed, TRUE, sizeof(This->stateBlock->changed));
7695+ } else if (Type == D3DSBT_PIXELSTATE) {
7696+
7697+ memset(&object->changed, FALSE, sizeof(This->stateBlock->changed));
7698+ /* TODO: Pixel Shader Constants */
7699+ object->changed.pixelShader = TRUE;
7700+ for (i = 0; i < NUM_SAVEDPIXELSTATES_R; i++) {
7701+ object->changed.renderState[SavedPixelStates_R[i]] = TRUE;
7702+ }
7703+ for (j = 0; j < GL_LIMITS(textures); i++) {
7704+ for (i = 0; i < NUM_SAVEDPIXELSTATES_T; i++) {
7705+ object->changed.textureState[j][SavedPixelStates_T[i]] = TRUE;
7706+ }
7707+ }
7708+ FIXME("Setting sampler block changes states\n");
7709+ for (j = 0 ; j < 16; j++){
7710+ for (i =0; i < NUM_SAVEDPIXELSTATES_S;i++){
7711+
7712+ object->changed.samplerState[j][SavedPixelStates_S[i]] = TRUE;
7713+ }
7714+ }
7715+ } else if (Type == D3DSBT_VERTEXSTATE) {
7716+
7717+ memset(&object->changed, FALSE, sizeof(This->stateBlock->changed));
7718+
7719+ /* TODO: Vertex Shader Constants */
7720+ object->changed.vertexShader = TRUE;
7721+ for (i = 0; i < NUM_SAVEDVERTEXSTATES_R; i++) {
7722+ object->changed.renderState[SavedVertexStates_R[i]] = TRUE;
7723+ }
7724+ for (j = 0; j < GL_LIMITS(textures); i++) {
7725+ for (i = 0; i < NUM_SAVEDVERTEXSTATES_T; i++) {
7726+ object->changed.textureState[j][SavedVertexStates_T[i]] = TRUE;
7727+ }
7728+ }
7729+ FIXME("Setting sampler block changes states\n");
7730+ for (j = 0 ; j < 16; j++){
7731+ for (i =0; i < NUM_SAVEDVERTEXSTATES_S;i++){
7732+ object->changed.samplerState[j][SavedVertexStates_S[i]] = TRUE;
7733+ }
7734+ }
7735+
7736+ /* Duplicate light chain */
7737+ {
7738+ PLIGHTINFOEL *src = NULL;
7739+ PLIGHTINFOEL *dst = NULL;
7740+ PLIGHTINFOEL *newEl = NULL;
7741+ src = This->stateBlock->lights;
7742+ object->lights = NULL;
7743+
7744+
7745+ while (src) {
7746+ newEl = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(PLIGHTINFOEL));
7747+ if (newEl == NULL) return D3DERR_OUTOFVIDEOMEMORY;
7748+ memcpy(newEl, src, sizeof(PLIGHTINFOEL));
7749+ newEl->prev = dst;
7750+ newEl->changed = TRUE;
7751+ newEl->enabledChanged = TRUE;
7752+ if (dst == NULL) {
7753+ object->lights = newEl;
7754+ } else {
7755+ dst->next = newEl;
7756+ }
7757+ dst = newEl;
7758+ src = src->next;
7759+ }
7760+
7761+ }
7762+
7763+ } else {
7764+ FIXME("Unrecognized state block type %d\n", Type);
7765 }
7766
7767+ TRACE("(%p) returning token (ptr to stateblock) of %p\n", This, object);
7768+ return D3D_OK;
7769+}
7770
7771 /* ************************************
7772 MSDN:
7773 [in] Render targets are not lockable unless the application specifies TRUE for Lockable. Note that lockable render targets reduce performance on some graphics hardware.
7774
7775 Discard
7776- [in] Set this flag to TRUE to enable z-buffer discarding, and FALSE otherwise.
7777+ [in] Set this flag to TRUE to enable z-buffer discarding, and FALSE otherwise.
7778
7779 If this flag is set, the contents of the depth stencil buffer will be invalid after calling either IDirect3DDevice9::Present or IDirect3DDevice9::SetDepthStencilSurface with a different depth surface.
7780
7781 ******************************** */
7782-
7783-HRESULT WINAPI IWineD3DDeviceImpl_CreateSurface(IWineD3DDevice *iface, UINT Width, UINT Height, WINED3DFORMAT Format, BOOL Lockable, BOOL Discard, UINT Level, IWineD3DSurface **ppSurface,D3DRESOURCETYPE Type, DWORD Usage, D3DPOOL Pool, D3DMULTISAMPLE_TYPE MultiSample ,DWORD MultisampleQuality, HANDLE* pSharedHandle, IUnknown *parent) {
7784- IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
7785- IWineD3DSurfaceImpl *object; /*NOTE: impl ref allowed since this is a create function */
7786- unsigned int pow2Width, pow2Height;
7787
7788+HRESULT WINAPI IWineD3DDeviceImpl_CreateSurface(IWineD3DDevice *iface, UINT Width, UINT Height, WINED3DFORMAT Format, BOOL Lockable, BOOL Discard, UINT Level, IWineD3DSurface **ppSurface,D3DRESOURCETYPE Type, DWORD Usage, D3DPOOL Pool, D3DMULTISAMPLE_TYPE MultiSample ,DWORD MultisampleQuality, HANDLE* pSharedHandle, IUnknown *parent) {
7789+ IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
7790+ IWineD3DSurfaceImpl *object; /* NOTE: impl ref allowed since this is a create function */
7791+ unsigned int pow2Width = Width;
7792+ unsigned int pow2Height = Height;
7793+ unsigned int pow2Size = 1;
7794+ int surfacecount;
7795 TRACE("(%p) Create surface\n",This);
7796-
7797- /** FIXME: Check ranges on the inputs are valid
7798+
7799+ /** FIXME: Check ranges on the inputs are valid
7800 * MSDN
7801 * MultisampleQuality
7802 * [in] Quality level. The valid range is between zero and one less than the level
7803- * returned by pQualityLevels used by IDirect3D9::CheckDeviceMultiSampleType.
7804+ * returned by pQualityLevels used by IDirect3D9::CheckDeviceMultiSampleType.
7805 * Passing a larger value returns the error D3DERR_INVALIDCALL. The MultisampleQuality
7806 * values of paired render targets, depth stencil surfaces, and the MultiSample type
7807 * must all match.
7808@@ -386,7 +559,7 @@
7809
7810 /**
7811 * TODO: Discard MSDN
7812- * [in] Set this flag to TRUE to enable z-buffer discarding, and FALSE otherwise.
7813+ * [in] Set this flag to TRUE to enable z-buffer discarding, and FALSE otherwise.
7814 *
7815 * If this flag is set, the contents of the depth stencil buffer will be
7816 * invalid after calling either IDirect3DDevice9::Present or * IDirect3DDevice9::SetDepthStencilSurface
7817@@ -394,44 +567,54 @@
7818 *
7819 *This flag has the same behavior as the constant, D3DPRESENTFLAG_DISCARD_DEPTHSTENCIL, in D3DPRESENTFLAG.
7820 ***************************/
7821-
7822- if(MultisampleQuality < 0) {
7823- FIXME("Invalid multisample level %ld \n", MultisampleQuality);
7824+
7825+ if(MultisampleQuality < 0) {
7826+ FIXME("Invalid multisample level %ld \n", MultisampleQuality);
7827 return D3DERR_INVALIDCALL; /* TODO: Check that this is the case! */
7828 }
7829-
7830+
7831 if(MultisampleQuality > 0){
7832- FIXME("MultisampleQuality set to %ld, bstituting 0 \n" , MultisampleQuality);
7833+ FIXME("MultisampleQuality set to %ld, bstituting 0 \n" , MultisampleQuality);
7834 MultisampleQuality=0;
7835 }
7836
7837 /* Non-power2 support */
7838+ /* Find the neriest pow2 match */
7839+ for(pow2Size = 1 ; pow2Size < Width ; pow2Size<<=1);
7840+ pow2Width = pow2Size;
7841
7842- /* Find the nearest pow2 match */
7843- pow2Width = pow2Height = 1;
7844- while (pow2Width < Width) pow2Width <<= 1;
7845- while (pow2Height < Height) pow2Height <<= 1;
7846+ for(pow2Size = 1 ; pow2Size < Height ; pow2Size<<=1);
7847+ pow2Height = pow2Size;
7848
7849- /* TODO: support for non-power 2 textures */
7850 if(pow2Width > Width || pow2Height > Height){
7851 /** TODO: add support for non power two compressed textures (OpenGL provices support for * non-power-two textures gratis) **/
7852- return D3DERR_NOTAVAILABLE;
7853+ if(Format == WINED3DFMT_DXT1 || Format == WINED3DFMT_DXT2 || Format == WINED3DFMT_DXT3
7854+ || Format == WINED3DFMT_DXT4 || Format == WINED3DFMT_DXT5){
7855+
7856+ FIXME("(%p) Compressed non-power-two textures are not supported w(%d) h(%d) \n",
7857+ This, Width, Height);
7858+ return D3DERR_NOTAVAILABLE;
7859+ }
7860 }
7861
7862-
7863+
7864 /** TODO: Check against the maximum texture sizes supported by the video card **/
7865-
7866+
7867 D3DCREATERESOURCEOBJECTINSTANCE(object,Surface,D3DRTYPE_SURFACE)
7868 object->container = (IUnknown*) This;
7869-
7870+
7871 object->currentDesc.Width = Width;
7872 object->currentDesc.Height = Height;
7873 object->currentDesc.Level = Level;
7874 object->currentDesc.MultiSampleType = MultiSample;
7875 object->currentDesc.MultiSampleQuality = MultisampleQuality;
7876+ object->pow2Width = pow2Width;
7877+ object->pow2Height = pow2Height;
7878+ object->nonpow2 = (pow2Width != Width || pow2Height != Height) ? TRUE : FALSE;
7879 object->discard = Discard;
7880+ object->activeLock = FALSE;
7881 object->bytesPerPixel = D3DFmtGetBpp(This, Format);
7882-
7883+
7884 /** DXTn mipmaps use the same number of 'levels' down to eg. 8x1, but since
7885 * it is based around 4x4 pixel blocks it requires padding, so allocate enough
7886 * space!
7887@@ -439,26 +622,32 @@
7888 if (Format == WINED3DFMT_DXT1) {
7889 /* DXT1 is half byte per pixel */
7890 object->resource.size = ((max(Width,4) * object->bytesPerPixel) * max(Height,4)) / 2;
7891-
7892+
7893 } else if (Format == WINED3DFMT_DXT2 || Format == WINED3DFMT_DXT3 ||
7894 Format == WINED3DFMT_DXT4 || Format == WINED3DFMT_DXT5) {
7895 object->resource.size = ((max(Width,4) * object->bytesPerPixel) * max(Height,4));
7896 } else {
7897 object->resource.size = (Width * object->bytesPerPixel) * Height;
7898+ object->pow2Size = (pow2Width * object->bytesPerPixel) * pow2Height;
7899 }
7900-
7901+
7902+ /** FIXME: add support for real non-power-two if it's provided by the video card **/
7903+ /** TODO: change this into a texture transform matrix so that it's processed in hardware **/
7904+ /* Precalculated scaling for 'faked' non power of two texture coords */
7905+ object->pow2scalingFactorX = (((float)Width) / ((float)pow2Width));
7906+ object->pow2scalingFactorY = (((float)Height) / ((float)pow2Height));
7907+ TRACE(" xf(%f) yf(%f) \n", object->pow2scalingFactorX, object->pow2scalingFactorY);
7908+
7909 TRACE("Pool %d %d %d %d",Pool, D3DPOOL_DEFAULT, D3DPOOL_MANAGED, D3DPOOL_SYSTEMMEM);
7910
7911-#if 0
7912- /* TODO: Check that we have enough video ram left */
7913- if(Pool == D3DPOOL_DEFAULT && IWineD3DDevice_GetAvailableTextureMem(iface) <= object->currentDesc.Size){
7914+ /* Check that we have enough video ram left */
7915+ if(Pool == D3DPOOL_DEFAULT && IWineD3DDevice_GetAvailableTextureMem(iface) <= object->resource.size){
7916 TRACE("Out of 'bogus' video memory\n");
7917 HeapFree(GetProcessHeap(),0,object);
7918 *ppSurface = NULL;
7919 return D3DERR_OUTOFVIDEOMEMORY;
7920 }
7921-#endif
7922-
7923+
7924 /** Quick lockable sanity check TODO: remove this after surfaces, usage and locablility have been debugged properly
7925 * this function is too deap to need to care about things like this.
7926 * Levels need to be checked too, and possibly Type wince they all affect what can be done.
7927@@ -477,17 +666,17 @@
7928 if(Usage == D3DUSAGE_DYNAMIC) FIXME("Create surface called with a pool of MANAGED and a \
7929 Usage of DYNAMIC which are mutually exclusive, not doing \
7930 anything just telling you.\n");
7931- break;
7932- case D3DPOOL_DEFAULT: /*TODO: Create offscreen plain can cause this check to fail..., find out if it should */
7933+ break;
7934+ case D3DPOOL_DEFAULT: /* TODO: Create offscreen plain can cause this check to fail..., find out if it should */
7935 if(!(Usage & D3DUSAGE_DYNAMIC) && !(Usage & D3DUSAGE_RENDERTARGET)
7936 && !(Usage && D3DUSAGE_DEPTHSTENCIL ) && Lockable == TRUE)
7937 FIXME("Creating a surface with a POOL of DEFAULT with Locable true, that doesn't specify DYNAMIC usage.\n");
7938 break;
7939- default:
7940+ default:
7941 FIXME("(%p) Unknown pool %d\n", This, Pool);
7942 break;
7943 };
7944-
7945+
7946 if (Usage & D3DUSAGE_RENDERTARGET && Pool != D3DPOOL_DEFAULT){
7947 FIXME("Trying to create a render target that isn't in the default pool\n");
7948 }
7949@@ -495,19 +684,46 @@
7950
7951 object->locked = FALSE;
7952 object->lockable = (WINED3DFMT_D16_LOCKABLE == Format) ? TRUE : Lockable;
7953- /* TODO: memory management */
7954+
7955+ /* Textures in the default pool only get allocated system ram if and when they are locked. */
7956+ if(Pool == D3DPOOL_DEFAULT){
7957+ object->resource.allocatedMemory = NULL;
7958+ /* Should we pre-load the surface now? */
7959+ globalChangeGlRam(object->resource.size);
7960+ }else{
7961 object->resource.allocatedMemory = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,object->resource.size);
7962 if(object->resource.allocatedMemory == NULL ) {
7963- FIXME("Out of memory!\n");
7964- HeapFree(GetProcessHeap(),0,object);
7965- *ppSurface = NULL;
7966- return D3DERR_OUTOFVIDEOMEMORY;
7967- }
7968+ FIXME("Out of memory!\n");
7969+ HeapFree(GetProcessHeap(),0,object);
7970+ *ppSurface = NULL;
7971+ return D3DERR_OUTOFVIDEOMEMORY;
7972+ }
7973
7974
7975 IWineD3DSurface_CleanDirtyRect(*ppSurface);
7976- TRACE("(%p) : w(%d) h(%d) fmt(%d,%s) lockable(%d) surf@%p, surfmem@%p, %d bytes\n",
7977- This, Width, Height, Format, debug_d3dformat(Format),
7978+ }
7979+
7980+
7981+ /** TODO: change this to use the Devices resource store. **/
7982+ surfacecount = globalStoreSurface((IWineD3DSurface *)object);
7983+
7984+#ifdef USE_CONTEXT_MANAGER
7985+/* TODO: OpenGL context manager
7986+(this should happen in preload not here, a context manager could overload the vtable though */
7987+ if(Usage & D3DUSAGE_RENDERTARGET){
7988+ /** render targets are special
7989+ * because they can be render targets!
7990+ * so forward the object onto the context manager to see if it wants do anything special
7991+ * I think this only applies when the texture is loaded, not here
7992+ ************************************************/
7993+
7994+ IContextManager_CreateRenderTarget(This->contextManager, object);
7995+ }
7996+#endif
7997+
7998+ IWineD3DSurface_CleanDirtyRect(*ppSurface);
7999+ TRACE("(%p) : number %d w(%d) h(%d) pow2w(%d) pow2h(%d) fmt(%d,%s) lockable(%d) surf@%p, surfmem@%p, %d bytes\n",
8000+ This, surfacecount, Width, Height, pow2Width, pow2Height, Format, debug_d3dformat(Format),
8001 (WINED3DFMT_D16_LOCKABLE == Format), *ppSurface, object->resource.allocatedMemory, object->resource.size);
8002 return D3D_OK;
8003
8004@@ -516,22 +732,25 @@
8005 HRESULT WINAPI IWineD3DDeviceImpl_CreateTexture(IWineD3DDevice *iface, UINT Width, UINT Height, UINT Levels,
8006 DWORD Usage, WINED3DFORMAT Format, D3DPOOL Pool,
8007 IWineD3DTexture** ppTexture, HANDLE* pSharedHandle, IUnknown *parent,
8008- D3DCB_CREATESURFACEFN D3DCB_CreateSurface) {
8009+ D3DCB_CREATESURFACETFN D3DCB_CreateSurface) {
8010
8011 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
8012- IWineD3DTextureImpl *object;
8013+ IWineD3DTextureImpl *object;
8014+ DWORD startTime = 0;
8015 unsigned int i;
8016+ int texturecount;
8017 UINT tmpW;
8018 UINT tmpH;
8019 HRESULT hr;
8020-
8021 TRACE("(%p), Width(%d) Height(%d) Levels(%d) Usage(%ld) .... \n", This, Width, Height, Levels, Usage);
8022+ if (TRACE_ON(d3d_timings))
8023+ startTime = GetTickCount(); /* Use windows calls for this */
8024
8025 D3DCREATERESOURCEOBJECTINSTANCE(object, Texture, D3DRTYPE_TEXTURE);
8026 D3DINITILIZEBASETEXTURE(object->baseTexture);
8027 object->width = Width;
8028 object->height = Height;
8029-
8030+ object->resource.pool = Pool;
8031 /* Calculate levels for mip mapping */
8032 if (Levels == 0) {
8033 TRACE("calculating levels %d\n", object->baseTexture.levels);
8034@@ -545,11 +764,11 @@
8035 }
8036 TRACE("Calculated levels = %d\n", object->baseTexture.levels);
8037 }
8038-
8039+
8040 /* Generate all the surfaces */
8041 tmpW = Width;
8042 tmpH = Height;
8043- for (i = 0; i < object->baseTexture.levels; i++)
8044+ for (i = 0; i < object->baseTexture.levels; i++)
8045 {
8046 /* use the callback to create the texture surface */
8047 hr = D3DCB_CreateSurface(This->parent, tmpW, tmpH, Format, Usage, Pool, i, &object->surfaces[i],NULL);
8048@@ -566,42 +785,45 @@
8049 *ppTexture = NULL;
8050 return hr;
8051 }
8052-
8053+
8054 IWineD3DSurface_SetContainer(object->surfaces[i], (IUnknown *)object);
8055 TRACE("Created surface level %d @ %p\n", i, object->surfaces[i]);
8056 /* calculate the next mipmap level */
8057 tmpW = max(1, tmpW >> 1);
8058 tmpH = max(1, tmpH >> 1);
8059 }
8060-
8061- TRACE("(%p) : Created texture %p\n", This, object);
8062+ texturecount = globalStoreTexture((IWineD3DBaseTexture *)object);
8063+ TRACE("(%p) : Created texture %d %p\n", This, texturecount, object);
8064+ if (TRACE_ON(d3d_timings))
8065+ TRACE_(d3d_timings)("(%p) starttime %ld, total time %ld\n", This, startTime , GetTickCount() -startTime);
8066 return D3D_OK;
8067 }
8068
8069-HRESULT WINAPI IWineD3DDeviceImpl_CreateVolumeTexture(IWineD3DDevice *iface,
8070- UINT Width, UINT Height, UINT Depth,
8071- UINT Levels, DWORD Usage,
8072+HRESULT WINAPI IWineD3DDeviceImpl_CreateVolumeTexture(IWineD3DDevice *iface,
8073+ UINT Width, UINT Height, UINT Depth,
8074+ UINT Levels, DWORD Usage,
8075 WINED3DFORMAT Format, D3DPOOL Pool,
8076 IWineD3DVolumeTexture** ppVolumeTexture,
8077 HANDLE* pSharedHandle, IUnknown *parent,
8078 D3DCB_CREATEVOLUMEFN D3DCB_CreateVolume) {
8079-
8080 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
8081- IWineD3DVolumeTextureImpl *object;
8082+ IWineD3DVolumeTextureImpl *object; /** NOTE: impl ref allowed since this is a create function **/
8083 unsigned int i;
8084+ int texturecount;
8085 UINT tmpW;
8086 UINT tmpH;
8087 UINT tmpD;
8088
8089 D3DCREATERESOURCEOBJECTINSTANCE(object, VolumeTexture, D3DRTYPE_VOLUMETEXTURE);
8090 D3DINITILIZEBASETEXTURE(object->baseTexture);
8091-
8092+
8093 TRACE("(%p) : W(%d) H(%d) D(%d), Lvl(%d) Usage(%ld), Fmt(%u,%s), Pool(%s)\n", This, Width, Height,
8094 Depth, Levels, Usage, Format, debug_d3dformat(Format), debug_d3dpool(Pool));
8095
8096 object->width = Width;
8097 object->height = Height;
8098 object->depth = Depth;
8099+ object->resource.pool = Pool;
8100
8101 /* Calculate levels for mip mapping */
8102 if (Levels == 0) {
8103@@ -623,10 +845,10 @@
8104 tmpH = Height;
8105 tmpD = Depth;
8106
8107- for (i = 0; i < object->baseTexture.levels; i++)
8108+ for (i = 0; i < object->baseTexture.levels; i++)
8109 {
8110 /* Create the volume */
8111- D3DCB_CreateVolume(This->parent, Width, Height, Depth, Format, Pool, Usage,
8112+ D3DCB_CreateVolume(This->parent, Width, Height, Depth, Format, Pool, Usage,
8113 (IWineD3DVolume **)&object->volumes[i], pSharedHandle);
8114 IWineD3DVolume_SetContainer(object->volumes[i], (IUnknown *)object);
8115
8116@@ -636,13 +858,14 @@
8117 }
8118
8119 *ppVolumeTexture = (IWineD3DVolumeTexture *) object;
8120- TRACE("(%p) : Created volume texture %p\n", This, object);
8121+ texturecount = globalStoreTexture((IWineD3DBaseTexture *)object);
8122+ TRACE("(%p) : Created volume texture %d %p\n", This, texturecount, object);
8123 return D3D_OK;
8124 }
8125
8126-HRESULT WINAPI IWineD3DDeviceImpl_CreateVolume(IWineD3DDevice *iface,
8127- UINT Width, UINT Height, UINT Depth,
8128- DWORD Usage,
8129+HRESULT WINAPI IWineD3DDeviceImpl_CreateVolume(IWineD3DDevice *iface,
8130+ UINT Width, UINT Height, UINT Depth,
8131+ DWORD Usage,
8132 WINED3DFORMAT Format, D3DPOOL Pool,
8133 IWineD3DVolume** ppVolume,
8134 HANDLE* pSharedHandle, IUnknown *parent) {
8135@@ -670,16 +893,18 @@
8136 return IWineD3DVolume_CleanDirtyBox((IWineD3DVolume *) object);
8137 }
8138
8139-HRESULT WINAPI IWineD3DDeviceImpl_CreateCubeTexture(IWineD3DDevice *iface, UINT EdgeLength,
8140- UINT Levels, DWORD Usage,
8141+
8142+HRESULT WINAPI IWineD3DDeviceImpl_CreateCubeTexture(IWineD3DDevice *iface, UINT EdgeLength,
8143+ UINT Levels, DWORD Usage,
8144 WINED3DFORMAT Format, D3DPOOL Pool,
8145 IWineD3DCubeTexture** ppCubeTexture,
8146 HANDLE* pSharedHandle, IUnknown *parent,
8147- D3DCB_CREATESURFACEFN D3DCB_CreateSurface) {
8148+ D3DCB_CREATESURFACETFN D3DCB_CreateSurface) {
8149
8150 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
8151 IWineD3DCubeTextureImpl *object; /** NOTE: impl ref allowed since this is a create function **/
8152 unsigned int i,j;
8153+ int texturecount;
8154 UINT tmpW;
8155 HRESULT hr;
8156
8157@@ -687,8 +912,9 @@
8158 D3DINITILIZEBASETEXTURE(object->baseTexture);
8159
8160 TRACE("(%p) Create Cube Texture \n", This);
8161-
8162+
8163 object->edgeLength = EdgeLength;
8164+ object->resource.pool = Pool;
8165
8166 /* Calculate levels for mip mapping */
8167 if (Levels == 0) {
8168@@ -707,10 +933,10 @@
8169
8170 /* Create the 6 faces */
8171 for (j = 0; j < 6; j++) {
8172-
8173+
8174 hr=D3DCB_CreateSurface(This->parent, tmpW, tmpW, Format, Usage, Pool,
8175 i /* Level */, &object->surfaces[j][i],pSharedHandle);
8176-
8177+
8178 if(hr!= D3D_OK){
8179 /* clean up */
8180 int k;
8181@@ -735,14 +961,16 @@
8182 tmpW = max(1, tmpW >> 1);
8183 }
8184
8185- TRACE("(%p) : Created Cube Texture %p\n", This, object);
8186+ /** TODO: repalce globalStoreTexture with a device **/
8187+ texturecount = globalStoreTexture((IWineD3DBaseTexture *)object);
8188 *ppCubeTexture = (IWineD3DCubeTexture *) object;
8189+ TRACE("(%p) : Created Cube Texture %d %p\n", This, texturecount, object);
8190 return D3D_OK;
8191 }
8192
8193-HRESULT WINAPI IWineD3DDeviceImpl_CreateQuery(IWineD3DDevice *iface, WINED3DQUERYTYPE Type, IWineD3DQuery **ppQuery, IUnknown* parent){
8194+HRESULT WINAPI IWineD3DDeviceImpl_CreateQuery(IWineD3DDevice *iface, WINED3DQUERYTYPE Type, IWineD3DQuery** ppQuery, IUnknown* parent){
8195 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
8196- IWineD3DQueryImpl *object; /*NOTE: impl ref allowed since this is a create function */
8197+ IWineD3DQueryImpl *object; /* NOTE: impl ref allowed since this is a create function */
8198
8199 if(NULL == ppQuery){
8200 /* Just a check to see if we support this type of query */
8201@@ -766,7 +994,7 @@
8202 hr = D3D_OK;
8203 break;
8204 default:
8205- FIXME("(%p) Unhandled query type %d\n",This , Type);
8206+ FIXME("(%p) Unhandled query type %d\n",This , Type);
8207 }
8208 FIXME("(%p) : Stub request for query type %d returned %ld\n", This, Type, hr);
8209 return hr;
8210@@ -780,103 +1008,474 @@
8211 }
8212
8213 /* example at http://www.fairyengine.com/articles/dxmultiviews.htm */
8214-HRESULT WINAPI IWineD3DDeviceImpl_CreateAdditionalSwapChain(IWineD3DDevice* iface, WINED3DPRESENT_PARAMETERS* pPresentationParameters, void** ppSwapChain,
8215+HRESULT WINAPI IWineD3DDeviceImpl_CreateAdditionalSwapChain(IWineD3DDevice* iface, WINED3DPRESENT_PARAMETERS* pPresentationParameters, IWineD3DSwapChain** ppSwapChain,
8216 IUnknown* parent,
8217 D3DCB_CREATERENDERTARGETFN D3DCB_CreateRenderTarget,
8218 D3DCB_CREATEDEPTHSTENCILSURFACEFN D3DCB_CreateDepthStencil){
8219+
8220 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
8221- *ppSwapChain = NULL;
8222- FIXME("(%p) : Stub\n",This);
8223+
8224+ HWND whichHWND;
8225+ HDC hDc;
8226+ IWineD3DSwapChainImpl *object; /** NOTE: impl ref allowed since this is a create function **/
8227+ int num;
8228+ XVisualInfo template;
8229+ GLXContext oldContext;
8230+ Drawable oldDrawable;
8231+ DWORD startTime = 0;
8232+
8233+ if (TRACE_ON(d3d_timings))
8234+ startTime = GetTickCount(); /* Use windows calls for this */
8235+
8236+
8237+ TRACE("(%p) : Created Aditional Swap Chain\n", This);
8238+
8239+ /** FIXME: Test under windows to find out what the life cycle of a swap chain is,
8240+ * does a device hold a reference to a swap chain giving them a lifetime of the device
8241+ * or does the swap chain notify the device of it'd destruction.
8242+ *******************************/
8243+
8244+ D3DCREATEOBJECTINSTANCE(object, SwapChain)
8245+
8246+ /* Initialize other useful values */
8247+ object->presentParms.BackBufferCount = 1; /* TODO:? support for gl_aux buffers */
8248+
8249+ /*********************
8250+ * Lookup the window Handle and the relating X window handel
8251+ ********************/
8252+
8253+ /* Setup hwnd we are using, plus which display this equates to */
8254+ whichHWND = *(pPresentationParameters->hDeviceWindow);
8255+ if(!whichHWND){
8256+ whichHWND = This->createParms.hFocusWindow;
8257+ }
8258+
8259+ object->win_handle = whichHWND;
8260+
8261+ object->win = (Window)GetPropA( whichHWND, "__wine_x11_whole_window" );
8262+ hDc = GetDC(whichHWND);
8263+ object->display = get_display(hDc);
8264+ ReleaseDC(whichHWND, hDc);
8265+ TRACE("Using a dispaly of %p %p \n", object->display, hDc);
8266+
8267+ /**
8268+ * Create an opengl context for the display visuial
8269+ * NOTE: the visual is chosen as the window is created and the glcontext cannot
8270+ * use different properties after that point in time. FIXME: How to handle when requested format
8271+ * doesn't match actual visual? Cannot choose one here - code removed as it ONLY works if the one
8272+ * it chooses is identical to the one already being used!
8273+ **********************************/
8274+
8275+ /** FIXME: Handle stencil appropriately via EnableAutoDepthStencil / AutoDepthStencilFormat **/
8276+ ENTER_GL();
8277+
8278+ /* Create a new context for this swapchain */
8279+
8280+ template.visualid = (VisualID)GetPropA(GetDesktopWindow(), "__wine_x11_visual_id");
8281+ object->visInfo = XGetVisualInfo(object->display, VisualIDMask, &template, &num);
8282+ if (NULL == object->visInfo) {
8283+ ERR("cannot really get XVisual\n");
8284+ LEAVE_GL();
8285+ return D3DERR_NOTAVAILABLE;
8286+ }
8287+#ifdef USE_CONTEXT_MANAGER
8288+
8289+ /** TODO: use a context mamager **/
8290+#endif
8291+
8292+ /* The first time around we create the context that is shared with all other swapchians and render targets */
8293+ if(This->numberOfSwapChains == 0) {
8294+ object->glCtx = glXCreateContext(object->display, object->visInfo, NULL, GL_TRUE);
8295+ TRACE("Creating implicite context for vis %p, hwnd %p\n", object->display, object->visInfo);
8296+ }else{
8297+ IWineD3DSwapChain *implSwapChain;
8298+ TRACE("Creating context for vis %p, hwnd %p\n", object->display, object->visInfo);
8299+ /* TODO: don't use Impl structures outside of create functions! (a context manager will replace the ->glCtx) */
8300+ IWineD3DDevice_GetSwapChain(iface, 0 ,&implSwapChain);
8301+ object->glCtx = glXCreateContext(object->display, object->visInfo, ((IWineD3DSwapChainImpl *)implSwapChain)->glCtx, GL_TRUE);
8302+ IWineD3DSwapChain_Release(implSwapChain);
8303+ }
8304+ if (NULL == object->glCtx) {
8305+ ERR("cannot create glxContext\n");
8306+ LEAVE_GL();
8307+ return D3DERR_NOTAVAILABLE;
8308+ }
8309+
8310+ LEAVE_GL();
8311+ if (object->glCtx == NULL) {
8312+ ERR("Error in context creation !\n");
8313+ return D3DERR_INVALIDCALL;
8314+ } else {
8315+ TRACE("Context created (HWND=%p, glContext=%p, Window=%ld, VisInfo=%p)\n",
8316+ whichHWND, object->glCtx, object->win, object->visInfo);
8317+ }
8318+
8319+ /*********************
8320+ * Windowed / Fullscreen
8321+ *******************/
8322+
8323+ /**
8324+ * TODO: MSDNsays that we are only allowed one fullscreen swapchain per device,
8325+ * so we should really check to see if their is a fullscreen swapchain already
8326+ * I think Windows and X have differnt ideas about fullscreen, does a single head count as full screen?
8327+ **************************************/
8328+
8329+ if (!*(pPresentationParameters->Windowed)) {
8330+
8331+ DEVMODEW devmode;
8332+ HDC hdc;
8333+ int bpp = 0;
8334+
8335+ /* Get info on the current display setup */
8336+ hdc = CreateDCA("DISPLAY", NULL, NULL, NULL);
8337+ bpp = GetDeviceCaps(hdc, BITSPIXEL);
8338+ DeleteDC(hdc);
8339+
8340+ /* Change the display settings */
8341+ memset(&devmode, 0, sizeof(DEVMODEW));
8342+ devmode.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT;
8343+ devmode.dmBitsPerPel = (bpp >= 24) ? 32 : bpp; /* Stupid XVidMode cannot change bpp */
8344+ devmode.dmPelsWidth = *(pPresentationParameters->BackBufferWidth);
8345+ devmode.dmPelsHeight = *(pPresentationParameters->BackBufferHeight);
8346+ MultiByteToWideChar(CP_ACP, 0, "Gamers CG", -1, devmode.dmDeviceName, CCHDEVICENAME);
8347+ ChangeDisplaySettingsExW(devmode.dmDeviceName, &devmode, object->win_handle, CDS_FULLSCREEN, NULL);
8348+
8349+ /* Make popup window */
8350+ SetWindowLongA(whichHWND, GWL_STYLE, WS_POPUP);
8351+ SetWindowPos(object->win_handle, HWND_TOP, 0, 0,
8352+ *(pPresentationParameters->BackBufferWidth),
8353+ *(pPresentationParameters->BackBufferHeight), SWP_SHOWWINDOW | SWP_FRAMECHANGED);
8354+
8355+
8356+ }
8357+
8358+
8359+ /** MSDN: If Windowed is TRUE and either of the BackBufferWidth/Height values is zero,
8360+ * then the corresponding dimension of the client area of the hDeviceWindow
8361+ * (or the focus window, if hDeviceWindow is NULL) is taken.
8362+ **********************/
8363+
8364+ if (*(pPresentationParameters->Windowed) &&
8365+ ((*(pPresentationParameters->BackBufferWidth) == 0) ||
8366+ (*(pPresentationParameters->BackBufferHeight) == 0))) {
8367+
8368+ RECT Rect;
8369+ GetClientRect(whichHWND, &Rect);
8370+
8371+ if (*(pPresentationParameters->BackBufferWidth) == 0) {
8372+ *(pPresentationParameters->BackBufferWidth) = Rect.right;
8373+ TRACE("Updating width to %d\n", *(pPresentationParameters->BackBufferWidth));
8374+ }
8375+ if (*(pPresentationParameters->BackBufferHeight) == 0) {
8376+ *(pPresentationParameters->BackBufferHeight) = Rect.bottom;
8377+ TRACE("Updating height to %d\n", *(pPresentationParameters->BackBufferHeight));
8378+ }
8379+ }
8380+
8381+ /*********************
8382+ * finish off parameter initilazation
8383+ *******************/
8384+
8385+ /* Put the correct figures in the presentation parameters */
8386+ TRACE("Coppying accross presentaion paraneters\n");
8387+ object->presentParms.BackBufferWidth = *(pPresentationParameters->BackBufferWidth);
8388+ object->presentParms.BackBufferHeight = *(pPresentationParameters->BackBufferHeight);
8389+ object->presentParms.BackBufferFormat = *(pPresentationParameters->BackBufferFormat);
8390+ object->presentParms.BackBufferCount = *(pPresentationParameters->BackBufferCount);
8391+ object->presentParms.MultiSampleType = *(pPresentationParameters->MultiSampleType);
8392+ object->presentParms.MultiSampleQuality = *(pPresentationParameters->MultiSampleQuality);
8393+ object->presentParms.SwapEffect = *(pPresentationParameters->SwapEffect);
8394+ object->presentParms.hDeviceWindow = *(pPresentationParameters->hDeviceWindow);
8395+ object->presentParms.Windowed = *(pPresentationParameters->Windowed);
8396+ object->presentParms.EnableAutoDepthStencil = *(pPresentationParameters->EnableAutoDepthStencil);
8397+ object->presentParms.AutoDepthStencilFormat = *(pPresentationParameters->AutoDepthStencilFormat);
8398+ object->presentParms.Flags = *(pPresentationParameters->Flags);
8399+ object->presentParms.FullScreen_RefreshRateInHz = *(pPresentationParameters->FullScreen_RefreshRateInHz);
8400+ object->presentParms.PresentationInterval = *(pPresentationParameters->PresentationInterval);
8401+
8402+
8403+
8404+ /*********************
8405+ * Create the back, frontand stencil buffers
8406+ *******************/
8407+ TRACE("calling rendertarget CB\n");
8408+ D3DCB_CreateRenderTarget((IUnknown *) This->parent,
8409+ object->presentParms.BackBufferWidth,
8410+ object->presentParms.BackBufferHeight,
8411+ object->presentParms.BackBufferFormat,
8412+ object->presentParms.MultiSampleType,
8413+ object->presentParms.MultiSampleQuality,
8414+ TRUE /* Lockable */,
8415+ &object->frontBuffer,
8416+ NULL /* pShared (always null)*/);
8417+ IWineD3DSurface_SetContainer(object->frontBuffer, (IUnknown *)object);
8418+ TRACE("calling rendertarget CB\n");
8419+ D3DCB_CreateRenderTarget((IUnknown *) This->parent,
8420+ object->presentParms.BackBufferWidth,
8421+ object->presentParms.BackBufferHeight,
8422+ object->presentParms.BackBufferFormat,
8423+ object->presentParms.MultiSampleType,
8424+ object->presentParms.MultiSampleQuality,
8425+ TRUE /* Lockable */,
8426+ &object->backBuffer,
8427+ NULL /* pShared (always null)*/);
8428+ IWineD3DSurface_SetContainer(object->backBuffer, (IUnknown *)object);
8429+
8430+ /* Under directX swapchains share the depth stencil, so only create one depth-stencil */
8431+ if (pPresentationParameters->EnableAutoDepthStencil) {
8432+ TRACE("Creating depth stencil buffer\n");
8433+ if(This->depthStencilBuffer == NULL ){
8434+ D3DCB_CreateDepthStencil((IUnknown *) This->parent,
8435+ object->presentParms.BackBufferWidth,
8436+ object->presentParms.BackBufferHeight,
8437+ object->presentParms.AutoDepthStencilFormat,
8438+ object->presentParms.MultiSampleType,
8439+ object->presentParms.MultiSampleQuality,
8440+ FALSE /* FIXME: Discard */,
8441+ &This->depthStencilBuffer,
8442+ NULL /* pShared (always null)*/ );
8443+ IWineD3DSurface_SetContainer(This->depthStencilBuffer, (IUnknown *)iface);
8444+ }
8445+
8446+ /** TODO: A check on width, height and multisample types
8447+ *(since the zbuffer must be at least as large as the render target and have the same multisample parameters)
8448+ ****************************/
8449+ object->wantsDepthStencilBuffer = TRUE;
8450+ } else {
8451+ object->wantsDepthStencilBuffer = FALSE;
8452+ }
8453+
8454+ TRACE("FrontBuf @ %p, BackBuf @ %p, DepthStencil %d\n",object->frontBuffer, object->backBuffer, object->wantsDepthStencilBuffer);
8455+
8456+
8457+ /*********************
8458+ * init the default renderTarget management
8459+ *******************/
8460+ object->drawable = object->win;
8461+ object->render_ctx = object->glCtx;
8462+
8463+
8464+ /*********************
8465+ * Setup some defaults and clear down the buffers
8466+ *******************/
8467+ ENTER_GL();
8468+ /** save current context and drawable **/
8469+ oldContext = glXGetCurrentContext();
8470+ oldDrawable = glXGetCurrentDrawable();
8471+
8472+
8473+ if (glXMakeCurrent(object->display, object->win, object->glCtx) == False) {
8474+ ERR("Error in setting current context (display %p context %p drawable %ld)!\n", object->display, object->glCtx, object->win);
8475+ }
8476+ checkGLcall("glXMakeCurrent");
8477+
8478+
8479+ /* Clear the screen */
8480+ glClearColor(0.0, 0.0, 0.0, 0.0);
8481+ checkGLcall("glClearColor");
8482+ glClearIndex(0);
8483+ glClearDepth(1);
8484+ glClearStencil(0);
8485+
8486+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_ACCUM_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
8487+ checkGLcall("glClear");
8488+
8489+ glColor3f(1.0, 1.0, 1.0);
8490+ checkGLcall("glColor3f");
8491+
8492+ glEnable(GL_LIGHTING);
8493+ checkGLcall("glEnable");
8494+
8495+ glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, GL_TRUE);
8496+ checkGLcall("glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, GL_TRUE);");
8497+
8498+ glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT);
8499+ checkGLcall("glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT);");
8500+
8501+ glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL, GL_SEPARATE_SPECULAR_COLOR);
8502+ checkGLcall("glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL, GL_SEPARATE_SPECULAR_COLOR);");
8503+
8504+ /* switch back to the original context (unless it was zero)*/
8505+ if(This->numberOfSwapChains != 0){
8506+ /** TODO: restore the context and drawable **/
8507+ glXMakeCurrent(object->display, oldDrawable, oldContext);
8508+ }
8509+ LEAVE_GL();
8510+
8511+ /* TODO: move this off into a linked list implementation! (add swapchain, remove swapchain or something along those lines) */
8512+#if 0
8513+ IListOperator *listOperator;
8514+ IListStore_CreateListOperator(This->swapchainStore, &listOperator);
8515+ IListOperator_Append(listOperator, (void *)object);
8516+ IListOperator_Release(listOperator);
8517+#endif
8518+
8519+ This->swapchains[This->numberOfSwapChains++] = (IWineD3DSwapChain *)object;
8520+ if (TRACE_ON(d3d_timings))
8521+ TRACE_(d3d_timings)("(%p) starttime %ld , total time %ld\n", This, startTime , GetTickCount() -startTime);
8522+
8523+ TRACE("Set swapchain to %p\n", object);
8524 return D3D_OK;
8525+
8526 }
8527
8528 /** NOTE: These are ahead of the other getters and setters to save using a forward declartion **/
8529 UINT WINAPI IWineD3DDeviceImpl_GetNumberOfSwapChains(IWineD3DDevice *iface) {
8530 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
8531-
8532- FIXME("(%p) : Stub\n",This);
8533- return 1;
8534+
8535+
8536+#if 0 /** TODO: move over to using stores and linked lists. **/
8537+ unsigned int numberOfSwapChains = 0;
8538+ IListOperator *listOperator;
8539+ IListStore_CreateListOperator(This->swapChainStore, &listOperator);
8540+ numberOfSwapChains = IListOperator_count(listOperator);
8541+ IListOperator_Release(listOperator);
8542+
8543+ TRACE("(%p) returning %d\n", This, numberOfSwapChains);
8544+ return numberOfSwapChains;
8545+#endif
8546+
8547+
8548+ TRACE("(%p) returning %d\n", This, This->numberOfSwapChains);
8549+ return This->numberOfSwapChains;
8550 }
8551
8552-HRESULT WINAPI IWineD3DDeviceImpl_GetSwapChain(IWineD3DDevice *iface, UINT iSwapChain, void** pSwapChain) {
8553+HRESULT WINAPI IWineD3DDeviceImpl_GetSwapChain(IWineD3DDevice *iface, UINT iSwapChain, IWineD3DSwapChain** pSwapChain) {
8554 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
8555-
8556- FIXME("(%p) : Stub\n",This);
8557+ TRACE("(%p) : swapchain %d \n", This, iSwapChain);
8558+ if(iSwapChain > IWineD3DDeviceImpl_GetNumberOfSwapChains(iface) || iSwapChain<0){
8559+ *pSwapChain = NULL;
8560+ return D3DERR_INVALIDCALL;
8561+ }else{
8562+ /** TODO: move off to a linkesList implementation **/
8563+ *pSwapChain = This->swapchains[iSwapChain];
8564+ }
8565+#if 0 /* TODO: move over to using stores and linked lists. */
8566+ IListOperator *listOperator;
8567+ IListStore_CreateListOperator(This->swapChainStore, &listOperator);
8568+ hr = IListOperator_get(listOperator, iSwapChain, (void **)pSwapChain);
8569+ IListOperator_Release(listOperator);
8570+ if(hr != D3D_OK){
8571+ *pSwapChain = NULL;
8572+ return D3DERR_INVALIDCALL;
8573+ }
8574+#endif
8575+
8576+ IWineD3DSwapChain_AddRef(*pSwapChain);
8577+ TRACE("(%p) returning %p\n", This, *pSwapChain);
8578 return D3D_OK;
8579 }
8580
8581+
8582 HRESULT WINAPI IWineD3DDeviceImpl_Reset(IWineD3DDevice* iface, WINED3DPRESENT_PARAMETERS* pPresentationParameters){
8583- IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
8584
8585- FIXME("(%p) : Stub\n",This);
8586+ /** ********************************************************
8587+ * From dx9_lost_device....
8588+ *
8589+ * Reset will fail unless the application releases all
8590+ * resources that are allocated in D3DPOOL_DEFAULT, including
8591+ * those created by the IDirect3DDevice9::CreateRenderTarget
8592+ * and IDirect3DDevice9::CreateDepthStencilSurface methods.
8593+ * *****************************************************/
8594+
8595+ /** TODO: Move all the globalStore into the device object
8596+ * Check that all objects with a usage of D3DPOOL_DEFAULT have been released
8597+ * perform a reset using the new presentationParameters
8598+ **/
8599+
8600+#if 0
8601+ IListOperator *listOpertor = NULL;
8602+ IListStore_CreateListOperator(This->textureStore, &listOpertor);
8603+ IWIneD3DBaseTextureImpl *texture;
8604+ while(texture = (IWIneD3DBaseTextureImpl *)IListOperator_Next(listOpertor)){
8605+ if(texture->resource.pool == D3DPOOL_DEFAULT){
8606+ WARN("Application tried called reset, without first destroying all D3DPOOL_DEFAULT textures\n");
8607+ IListOperator_Release(listOpertor);
8608+ return D3DERR_INVALIDCALL;
8609+ }
8610+
8611+ }
8612+ IListOperator_Release(listOpertor);
8613+
8614+ IListStore_CreateListOperator(This->surfaceStore, &listOpertor);
8615+ IWIneD3DSurfaceImpl *texture;
8616+ while(surface = (IWIneD3DSurfaceImpl *)IListOperator_Next(listOpertor)){
8617+ if(surface->resource.pool == D3DPOOL_DEFAULT){
8618+ WARN("Application tried called reset, without first destroying all D3DPOOL_DEFAULT surfaces\n");
8619+ IListOperator_Release(listOpertor);
8620+ return D3DERR_INVALIDCALL;
8621+ }
8622+
8623+ }
8624+ IListOperator_Release(listOpertor);
8625+
8626+ /* TODO: check vertexBuffers (swapchains?) etc... */
8627+#endif
8628 return D3D_OK;
8629-
8630+
8631 }
8632
8633 /*****
8634 * Vertex Declaration
8635 *****/
8636+
8637 /* TODO: Get ridd of thease and put the functions in the IWineD3DVertexDeclaration interface */
8638-#if 1
8639 extern HRESULT IWineD3DVertexDeclarationImpl_ParseDeclaration8(IWineD3DDeviceImpl * This, const DWORD* pDecl, IWineD3DVertexDeclarationImpl * object);
8640 extern HRESULT IWineD3DVertexDeclarationImpl_ParseDeclaration9(IWineD3DDeviceImpl * This, const D3DVERTEXELEMENT9* pDecl, IWineD3DVertexDeclarationImpl * object);
8641
8642-
8643-HRESULT WINAPI IWineD3DDeviceImpl_CreateVertexDeclaration(IWineD3DDevice* iface, CONST VOID* pDeclaration, IWineD3DVertexDeclaration** ppVertexDeclaration, IUnknown *parent) {
8644+HRESULT WINAPI IWineD3DDeviceImpl_CreateVertexDeclaration8(IWineD3DDevice* iface, const DWORD* pDeclaration, IWineD3DVertexDeclaration** ppVertexDeclaration, IUnknown *parent){
8645 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
8646- IWineD3DVertexDeclarationImpl *object = NULL;
8647+ IWineD3DVertexDeclarationImpl *object = NULL; /* NOTE: impl allowed, this is a create */
8648 HRESULT hr = D3D_OK;
8649-
8650- TRACE("(%p) : directXVersion=%u, pFunction=%p, ppDecl=%p\n", This, ((IWineD3DImpl *)This->wineD3D)->dxVersion, pDeclaration, ppVertexDeclaration);
8651+ /* TODO: replace impl usage with a call to Version */
8652+ TRACE("(%p) : directXVersion=%u, pFunction=%p, ppDecl=%p\n", This, ((IWineD3DImpl *)This->wineD3D)->dxVersion, pDeclaration, ppVertexDeclaration);
8653 D3DCREATEOBJECTINSTANCE(object, VertexDeclaration)
8654 object->allFVF = 0;
8655-
8656- if (8 == ((IWineD3DImpl *)This->wineD3D)->dxVersion) {
8657- /** @TODO */
8658- hr = IWineD3DVertexDeclarationImpl_ParseDeclaration8(This, (const DWORD*) pDeclaration, object);
8659- } else {
8660- hr = IWineD3DVertexDeclarationImpl_ParseDeclaration9(This, (const D3DVERTEXELEMENT9*) pDeclaration, object);
8661- }
8662+ /* TODO: get ridd of the impl usage, we should only be using interfaces */
8663+ hr = IWineD3DVertexDeclarationImpl_ParseDeclaration8(This, pDeclaration, object);
8664
8665 return hr;
8666 }
8667
8668-
8669-#else
8670-HRESULT WINAPI IWineD3DDeviceImpl_CreateVertexDeclaration8(IWineD3DDevice* iface, const DWORD* pDeclaration, IWineD3DVertexDeclaration** ppVertexDeclaration, IUnknown *parent){
8671+HRESULT WINAPI IWineD3DDeviceImpl_CreateVertexDeclaration9(IWineD3DDevice* iface, const D3DVERTEXELEMENT9* pDeclaration, IWineD3DVertexDeclaration** ppVertexDeclaration, IUnknown *parent){
8672 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
8673 IWineD3DVertexDeclarationImpl *object = NULL; /* NOTE: impl allowed, this is a create */
8674 HRESULT hr = D3D_OK;
8675- /* TODO: replace impl usage with a call to Version*/
8676- TRACE("(%p) : directXVersion=%u, pFunction=%p, ppDecl=%p\n", This, ((IWineD3DImpl *)This->wineD3D)->dxVersion, pDeclaration, ppVertexDeclaration);
8677+ /* TODO: replace impl usage with a call to Version */
8678+ TRACE("(%p) : directXVersion=%u, pFunction=%p, ppDecl=%p\n", This, ((IWineD3DImpl *)This->wineD3D)->dxVersion, pDeclaration, ppVertexDeclaration);
8679 D3DCREATEOBJECTINSTANCE(object, VertexDeclaration)
8680 object->allFVF = 0;
8681 /* TODO: get ridd of the impl usage, we should only be using interfaces */
8682- hr = IWineD3DVertexDeclarationImpl_ParseDeclaration8(This, pDeclaration, object);
8683-
8684+ hr = IWineD3DVertexDeclarationImpl_ParseDeclaration9(This, pDeclaration, object);
8685+
8686 return hr;
8687 }
8688
8689-HRESULT WINAPI IWineD3DDeviceImpl_CreateVertexDeclaration9(IWineD3DDevice* iface, const D3DVERTEXELEMENT9* pDeclaration, IWineD3DVertexDeclaration** ppVertexDeclaration, IUnknown *parent){
8690+/** TODO: repalce with IWineD3DDeviceImpl_CreateVertexDeclaration8 and IWineD3DDeviceImpl_CreateVertexDeclaration9 to avoid the use of a void * (see above!) **/
8691+HRESULT WINAPI IWineD3DDeviceImpl_CreateVertexDeclaration(IWineD3DDevice* iface, CONST VOID* pDeclaration, IWineD3DVertexDeclaration** ppVertexDeclaration, IUnknown *parent) {
8692 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
8693 IWineD3DVertexDeclarationImpl *object = NULL; /* NOTE: impl allowed, this is a create */
8694 HRESULT hr = D3D_OK;
8695- /* TODO: replace impl usage with a call to Version*/
8696- TRACE("(%p) : directXVersion=%u, pFunction=%p, ppDecl=%p\n", This, ((IWineD3DImpl *)This->wineD3D)->dxVersion, pDeclaration, ppVertexDeclaration);
8697+ /* TODO: replace impl usage with a call to Version */
8698+ TRACE("(%p) : directXVersion=%u, pFunction=%p, ppDecl=%p\n", This, ((IWineD3DImpl *)This->wineD3D)->dxVersion, pDeclaration, ppVertexDeclaration);
8699 D3DCREATEOBJECTINSTANCE(object, VertexDeclaration)
8700 object->allFVF = 0;
8701- /* TODO: get ridd of the impl usage, we should only be using interfaces */
8702- hr = IWineD3DVertexDeclarationImpl_ParseDeclaration9(This, pDeclaration, object);
8703-
8704+
8705+ if (8 == ((IWineD3DImpl *)This->wineD3D)->dxVersion) {
8706+ /** @TODO */
8707+ hr = IWineD3DVertexDeclarationImpl_ParseDeclaration8(This, (const DWORD*) pDeclaration, object);
8708+ } else {
8709+ hr = IWineD3DVertexDeclarationImpl_ParseDeclaration9(This, (const D3DVERTEXELEMENT9*) pDeclaration, object);
8710+ }
8711+
8712 return hr;
8713 }
8714-#endif
8715
8716 /* http://msdn.microsoft.com/archive/default.asp?url=/archive/en-us/directx9_c/directx/graphics/programmingguide/programmable/vertexshaders/vscreate.asp */
8717 HRESULT WINAPI IWineD3DDeviceImpl_CreateVertexShader(IWineD3DDevice* iface, CONST DWORD* pFunction, IWineD3DVertexShader** ppVertexShader, IUnknown *parent){
8718 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
8719- IWineD3DVertexShaderImpl *object; /* NOTE: impl usage is ok, this is a create */
8720- D3DCREATEOBJECTINSTANCE(object, VertexShader)
8721+ IWineD3DVertexShaderImpl *object; /* NOTE: impl allowed, this is a create */
8722+ D3DCREATEOBJECTINSTANCE(object, VertexShader)
8723 object->function = pFunction;
8724 FIXME("(%p) : STUB: Created Vertex shader %p\n", This, ppVertexShader);
8725 return D3D_OK;
8726@@ -885,26 +1484,40 @@
8727
8728 HRESULT WINAPI IWineD3DDeviceImpl_CreatePixelShader(IWineD3DDevice* iface, CONST DWORD* pFunction, IWineD3DPixelShader** ppPixelShader, IUnknown *parent){
8729 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
8730- FIXME("(%p) : Stub\n", This);
8731+ IWineD3DPixelShaderImpl *object; /* NOTE: impl allowed, this is a create */
8732+ D3DCREATEOBJECTINSTANCE(object, PixelShader)
8733+ object->function = pFunction;
8734+ FIXME("(%p) : STUB: Created Pixel shader %p\n", This, ppPixelShader);
8735 return D3D_OK;
8736 }
8737
8738-HRESULT WINAPI IWineD3DDeviceImpl_GetDirect3D(IWineD3DDevice* iface, IWineD3D** ppD3D){
8739+HRESULT WINAPI IWineD3DDeviceImpl_GetDirect3D(IWineD3DDevice* iface, IWineD3D** ppD3D){
8740 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
8741 *ppD3D= This->wineD3D;
8742 TRACE("(%p) : wineD3D returning %p\n", This, *ppD3D);
8743 IWineD3D_AddRef(*ppD3D);
8744 return D3D_OK;
8745-
8746+
8747 }
8748-
8749+
8750 UINT WINAPI IWineD3DDeviceImpl_GetAvailableTextureMem(IWineD3DDevice *iface) {
8751+ /** NOTE: There's a probably a hack-around for this one by putting as many pbuffers, VBO's (or whatever)
8752+ * Into the video ram as possible and seeing how many fit
8753+ * you can also get the correct initial value from via X and ATI's driver
8754+ *******************/
8755 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
8756- FIXME("Stub :(%p) returning 64Mib\n", This);
8757- return 64*1024*1024;
8758+ static BOOL showfixmes = TRUE;
8759+ if(showfixmes){
8760+ FIXME("(%p) : stub, emulating %dMib for now, returning %dMib\n", This, (emmulated_textureram/(1024*1024)),
8761+ ((emmulated_textureram - wineD3DGlobalStatistics->glsurfaceram) / (1024*1024)));
8762+ showfixmes = FALSE;
8763+ }
8764+ TRACE("(%p) : emulating %dMib for now, returning %dMib\n", This, (emmulated_textureram/(1024*1024)),
8765+ ((emmulated_textureram - wineD3DGlobalStatistics->glsurfaceram) / (1024*1024)));
8766+ /* videomemory is simulated videomemory + AGP memory left */
8767+ return (emmulated_textureram - wineD3DGlobalStatistics->glsurfaceram);
8768 }
8769
8770-
8771 /*****
8772 * Get / Set FVF
8773 *****/
8774@@ -916,9 +1529,17 @@
8775 This->updateStateBlock->changed.fvf = TRUE;
8776 This->updateStateBlock->set.fvf = TRUE;
8777
8778+ /* clear down the vertex declaration
8779+ NOTE: Axis and Allies doesn't work properly otherwise
8780+ (may be a stateblock problem though!)
8781+ */
8782+
8783+ IWineD3DDevice_SetVertexDeclaration(iface, NULL);
8784+
8785 TRACE("(%p) : FVF Shader FVF set to %lx\n", This, fvf);
8786-
8787- /* No difference if recording or not */
8788+ if(This->isRecordingState) {
8789+ return D3D_OK;
8790+ }
8791 return D3D_OK;
8792 }
8793 HRESULT WINAPI IWineD3DDeviceImpl_GetFVF(IWineD3DDevice *iface, DWORD *pfvf) {
8794@@ -935,14 +1556,41 @@
8795 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
8796 IWineD3DVertexBuffer *oldSrc;
8797
8798- oldSrc = This->stateBlock->stream_source[StreamNumber];
8799+ /**TODO: instance and index data, see
8800+ http://msdn.microsoft.com/library/default.asp?url=/library/en-us/directx9_c/directx/graphics/programmingguide/advancedtopics/DrawingMultipleInstances.asp
8801+ and
8802+ http://msdn.microsoft.com/library/default.asp?url=/library/en-us/directx9_c/directx/graphics/reference/d3d/interfaces/idirect3ddevice9/SetStreamSourceFreq.asp
8803+ **************/
8804+
8805+ /* D3d9 only, but shouldn't hurt d3d8 */
8806+ UINT streamFlags;
8807+
8808+ streamFlags = StreamNumber &(D3DSTREAMSOURCE_INDEXEDDATA | D3DSTREAMSOURCE_INSTANCEDATA);
8809+ if(streamFlags){
8810+ if(streamFlags & D3DSTREAMSOURCE_INDEXEDDATA){
8811+ FIXME("stream index data not supported\n");
8812+ }
8813+ if(streamFlags & D3DSTREAMSOURCE_INDEXEDDATA){
8814+ FIXME("stream instance data not supported\n");
8815+ }
8816+ }
8817+
8818+ StreamNumber&= ~(D3DSTREAMSOURCE_INDEXEDDATA | D3DSTREAMSOURCE_INSTANCEDATA);
8819+
8820+ if(StreamNumber >= MAX_STREAMS){
8821+ ERR("Stream out of rance %d\n", StreamNumber);
8822+ return D3DERR_INVALIDCALL;
8823+ }
8824+
8825+ oldSrc = This->stateBlock->streamSource[StreamNumber];
8826 TRACE("(%p) : StreamNo: %d, OldStream (%p), NewStream (%p), NewStride %d\n", This, StreamNumber, oldSrc, pStreamData, Stride);
8827
8828- This->updateStateBlock->changed.stream_source[StreamNumber] = TRUE;
8829- This->updateStateBlock->set.stream_source[StreamNumber] = TRUE;
8830- This->updateStateBlock->stream_stride[StreamNumber] = Stride;
8831- This->updateStateBlock->stream_source[StreamNumber] = pStreamData;
8832- This->updateStateBlock->stream_offset[StreamNumber] = OffsetInBytes;
8833+ This->updateStateBlock->changed.streamSource[StreamNumber] = TRUE;
8834+ This->updateStateBlock->set.streamSource[StreamNumber] = TRUE;
8835+ This->updateStateBlock->streamStride[StreamNumber] = Stride;
8836+ This->updateStateBlock->streamSource[StreamNumber] = pStreamData;
8837+ This->updateStateBlock->streamOffset[StreamNumber] = OffsetInBytes;
8838+ This->updateStateBlock->streamFlags[StreamNumber] = streamFlags;
8839
8840 /* Handle recording of state blocks */
8841 if (This->isRecordingState) {
8842@@ -951,48 +1599,102 @@
8843 }
8844
8845 /* Not recording... */
8846+ /* Need to do a getParent and pass the reffs up */
8847+ /* MSDN says ..... When an application no longer holds a references to this interface, the interface will automatically be freed.
8848+ which suggests that we shouldn't be ref counting? and do need a _release on the stream source to reset the stream source
8849+ so for now, just count internally */
8850+#if 0 /* TODO: move over to using ResourceReleased */
8851+ /* do nothing we're using ResourceReleased instead */
8852+#else
8853 if (oldSrc != NULL) IWineD3DVertexBuffer_Release(oldSrc);
8854 if (pStreamData != NULL) IWineD3DVertexBuffer_AddRef(pStreamData);
8855-
8856+#endif
8857 return D3D_OK;
8858 }
8859
8860-HRESULT WINAPI IWineD3DDeviceImpl_GetStreamSource(IWineD3DDevice *iface, UINT StreamNumber,IWineD3DVertexBuffer** pStream, UINT *pOffset, UINT* pStride) {
8861+HRESULT WINAPI IWineD3DDeviceImpl_GetStreamSource(IWineD3DDevice *iface, UINT StreamNumber,
8862+ IWineD3DVertexBuffer** pStream, UINT *pOffset, UINT* pStride) {
8863 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
8864+ UINT streamFlags;
8865+
8866+ TRACE("(%p) : StreamNo: %d, Stream (%p), Stride %d\n", This, StreamNumber,
8867+ This->stateBlock->streamSource[StreamNumber], This->stateBlock->streamStride[StreamNumber]);
8868+
8869+
8870+ streamFlags = StreamNumber &(D3DSTREAMSOURCE_INDEXEDDATA | D3DSTREAMSOURCE_INSTANCEDATA);
8871+ if(streamFlags){
8872+ if(streamFlags & D3DSTREAMSOURCE_INDEXEDDATA){
8873+ FIXME("stream index data not supported\n");
8874+ }
8875+ if(streamFlags & D3DSTREAMSOURCE_INDEXEDDATA){
8876+ FIXME("stream instance data not supported\n");
8877+ }
8878+ }
8879+
8880+ StreamNumber&= ~(D3DSTREAMSOURCE_INDEXEDDATA | D3DSTREAMSOURCE_INSTANCEDATA);
8881+
8882+ if(StreamNumber >= MAX_STREAMS){
8883+ ERR("Stream out of rance %d\n", StreamNumber);
8884+ return D3DERR_INVALIDCALL;
8885+ }
8886+ *pStream = This->stateBlock->streamSource[StreamNumber];
8887+ *pStride = This->stateBlock->streamStride[StreamNumber];
8888+ *pOffset = This->stateBlock->streamOffset[StreamNumber];
8889+ if(*pStream == NULL){
8890+ FIXME("Attempting to get an empty stream %d\n", StreamNumber);
8891+ return D3DERR_INVALIDCALL;
8892+ }
8893
8894- TRACE("(%p) : StreamNo: %d, Stream (%p), Stride %d\n", This, StreamNumber, This->stateBlock->stream_source[StreamNumber], This->stateBlock->stream_stride[StreamNumber]);
8895- *pStream = This->stateBlock->stream_source[StreamNumber];
8896- *pStride = This->stateBlock->stream_stride[StreamNumber];
8897- *pOffset = This->stateBlock->stream_offset[StreamNumber];
8898- if (*pStream != NULL) IWineD3DVertexBuffer_AddRef(*pStream); /* We have created a new reference to the VB */
8899+ IWineD3DVertexBuffer_AddRef(*pStream); /* We have created a new reference to the VB */
8900 return D3D_OK;
8901 }
8902
8903-/*Should be quite easy, just an extension of vertexdata
8904+
8905+/* Should be quite easy, just an extension of vertexdata
8906 ref...
8907 http://msdn.microsoft.com/archive/default.asp?url=/archive/en-us/directx9_c_Summer_04/directx/graphics/programmingguide/advancedtopics/DrawingMultipleInstances.asp
8908
8909 The divider is a bit odd though
8910
8911-VertexOffset = StartVertex / Divider * StreamStride +
8912+VertexOffset = StartVertex / Divider * StreamStride +
8913 VertexIndex / Divider * StreamStride + StreamOffset
8914
8915 */
8916 HRESULT WINAPI IWineD3DDeviceImpl_SetStreamSourceFreq(IWineD3DDevice *iface, UINT StreamNumber, UINT Divider){
8917 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
8918-
8919- FIXME("(%p) : stub\n", This);
8920+
8921+ TRACE("(%p) StreamNumber(%d), Divider(%d)\n", This, StreamNumber, Divider);
8922+ This->updateStateBlock->streamFlags[StreamNumber] = Divider & (D3DSTREAMSOURCE_INSTANCEDATA | D3DSTREAMSOURCE_INDEXEDDATA );
8923+ This->updateStateBlock->changed.streamFreq[StreamNumber] = TRUE;
8924+ This->updateStateBlock->set.streamFreq[StreamNumber] = TRUE;
8925+ This->updateStateBlock->streamFreq[StreamNumber] = Divider & 0x7FFFFF;
8926+ if(This->updateStateBlock->streamFlags[StreamNumber] || This->updateStateBlock->streamFreq[StreamNumber] != 1){
8927+ FIXME("Stream indexing not fully supported\n");
8928+ }
8929 return D3D_OK;
8930-
8931+
8932 }
8933 HRESULT WINAPI IWineD3DDeviceImpl_GetStreamSourceFreq(IWineD3DDevice *iface, UINT StreamNumber, UINT* Divider){
8934 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
8935-
8936- FIXME("(%p) : stub\n", This);
8937+
8938+ TRACE("(%p) StreamNumber(%d), Divider(%p)\n", This, StreamNumber, Divider);
8939+ *Divider = This->updateStateBlock->streamFreq[StreamNumber] | This->updateStateBlock->streamFlags[StreamNumber];
8940+ TRACE("(%p) : returning %d\n", This, *Divider);
8941 return D3D_OK;
8942-
8943+
8944 }
8945
8946+/* Should be quite easy, just an extension of vertexdata
8947+ref...
8948+http://msdn.microsoft.com/archive/default.asp?url=/archive/en-us/directx9_c_Summer_04/directx/graphics/programmingguide/advancedtopics/DrawingMultipleInstances.asp
8949+
8950+The divider is a bit odd though
8951+
8952+VertexOffset = StartVertex / Divider * StreamStride +
8953+ VertexIndex / Divider * StreamStride + StreamOffset
8954+
8955+*/
8956+
8957 /*****
8958 * Get / Set & Multipy Transform
8959 *****/
8960@@ -1011,14 +1713,17 @@
8961 return D3D_OK;
8962 }
8963
8964- /*
8965+ /**
8966 * If the new matrix is the same as the current one,
8967 * we cut off any further processing. this seems to be a reasonable
8968 * optimization because as was noticed, some apps (warcraft3 for example)
8969 * tend towards setting the same matrix repeatedly for some reason.
8970 *
8971 * From here on we assume that the new matrix is different, wherever it matters.
8972- */
8973+ ******************/
8974+ dumpMatrixTRACE(lpmatrix);
8975+
8976+
8977 if (!memcmp(&This->stateBlock->transforms[d3dts].u.m[0][0], lpmatrix, sizeof(D3DMATRIX))) {
8978 TRACE("The app is setting the same matrix over again\n");
8979 return D3D_OK;
8980@@ -1026,13 +1731,13 @@
8981 conv_mat(lpmatrix, &This->stateBlock->transforms[d3dts].u.m[0][0]);
8982 }
8983
8984- /*
8985- ScreenCoord = ProjectionMat * ViewMat * WorldMat * ObjectCoord
8986- where ViewMat = Camera space, WorldMat = world space.
8987-
8988- In OpenGL, camera and world space is combined into GL_MODELVIEW
8989- matrix. The Projection matrix stay projection matrix.
8990- */
8991+ /**
8992+ * ScreenCoord = ProjectionMat * ViewMat * WorldMat * ObjectCoord
8993+ * where ViewMat = Camera space, WorldMat = world space.
8994+ *
8995+ * In OpenGL, camera and world space is combined into GL_MODELVIEW
8996+ * matrix. The Projection matrix stay projection matrix.
8997+ *****************************/
8998
8999 /* Capture the times we can just ignore the change for now */
9000 if (d3dts == D3DTS_WORLDMATRIX(0)) {
9001@@ -1043,13 +1748,16 @@
9002 This->proj_valid = FALSE;
9003 return D3D_OK;
9004
9005- } else if (d3dts >= D3DTS_WORLDMATRIX(1) && d3dts <= D3DTS_WORLDMATRIX(255)) {
9006+ } else if (d3dts >= D3DTS_WORLDMATRIX(1) && d3dts <= D3DTS_WORLDMATRIX(3)) {
9007+ This->proj_valid = FALSE;
9008+ return D3D_OK;
9009+ } else if (d3dts >= D3DTS_WORLDMATRIX(3) && d3dts <= D3DTS_WORLDMATRIX(255)) {
9010 /* Indexed Vertex Blending Matrices 256 -> 511 */
9011 /* Use arb_vertex_blend or NV_VERTEX_WEIGHTING? */
9012- FIXME("D3DTS_WORLDMATRIX(1..255) not handled\n");
9013+ FIXME("D3DTS_WORLDMATRIX(3..255) not handled\n");
9014 return D3D_OK;
9015- }
9016-
9017+ }
9018+
9019 /* Now we really are going to have to change a matrix */
9020 ENTER_GL();
9021
9022@@ -1057,19 +1765,20 @@
9023 if (d3dts < GL_LIMITS(textures)) {
9024 int tex = d3dts - D3DTS_TEXTURE0;
9025 GLACTIVETEXTURE(tex);
9026- set_texture_matrix((float *)lpmatrix,
9027+ FIXME("Texture matrix transform adn't applied yet\n");
9028+ set_texture_matrix((float *)lpmatrix,
9029 This->updateStateBlock->textureState[tex][D3DTSS_TEXTURETRANSFORMFLAGS]);
9030 }
9031
9032 } else if (d3dts == D3DTS_VIEW) { /* handle the VIEW matrice */
9033 unsigned int k;
9034
9035- /* If we are changing the View matrix, reset the light and clipping planes to the new view
9036+ /** If we are changing the View matrix, reset the light and clipping planes to the new view
9037 * NOTE: We have to reset the positions even if the light/plane is not currently
9038- * enabled, since the call to enable it will not reset the position.
9039+ * enabled, since the call to enable it will not reset the position.
9040 * NOTE2: Apparently texture transforms do NOT need reapplying
9041- */
9042-
9043+ ***********************/
9044+
9045 PLIGHTINFOEL *lightChain = NULL;
9046 This->modelview_valid = FALSE;
9047 This->view_ident = !memcmp(lpmatrix, identity, 16*sizeof(float));
9048@@ -1106,6 +1815,7 @@
9049 return D3D_OK;
9050
9051 }
9052+
9053 HRESULT WINAPI IWineD3DDeviceImpl_GetTransform(IWineD3DDevice *iface, D3DTRANSFORMSTATETYPE State, D3DMATRIX* pMatrix) {
9054 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
9055 TRACE("(%p) : for Transform State %d\n", This, State);
9056@@ -1117,11 +1827,11 @@
9057 D3DMATRIX *mat = NULL;
9058 D3DMATRIX temp;
9059
9060- /* Note: Using 'updateStateBlock' rather than 'stateblock' in the code
9061+ /** Note: Using 'updateStateBlock' rather than 'stateblock' in the code
9062 * below means it will be recorded in a state block change, but it
9063- * works regardless where it is recorded.
9064+ * works regardless where it is recorded.
9065 * If this is found to be wrong, change to StateBlock.
9066- */
9067+ *************************/
9068 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
9069 TRACE("(%p) : For state %u\n", This, State);
9070
9071@@ -1133,25 +1843,41 @@
9072 }
9073
9074 /* Copied from ddraw code: */
9075- temp.u.s._11 = (mat->u.s._11 * pMatrix->u.s._11) + (mat->u.s._21 * pMatrix->u.s._12) + (mat->u.s._31 * pMatrix->u.s._13) + (mat->u.s._41 * pMatrix->u.s._14);
9076- temp.u.s._21 = (mat->u.s._11 * pMatrix->u.s._21) + (mat->u.s._21 * pMatrix->u.s._22) + (mat->u.s._31 * pMatrix->u.s._23) + (mat->u.s._41 * pMatrix->u.s._24);
9077- temp.u.s._31 = (mat->u.s._11 * pMatrix->u.s._31) + (mat->u.s._21 * pMatrix->u.s._32) + (mat->u.s._31 * pMatrix->u.s._33) + (mat->u.s._41 * pMatrix->u.s._34);
9078- temp.u.s._41 = (mat->u.s._11 * pMatrix->u.s._41) + (mat->u.s._21 * pMatrix->u.s._42) + (mat->u.s._31 * pMatrix->u.s._43) + (mat->u.s._41 * pMatrix->u.s._44);
9079-
9080- temp.u.s._12 = (mat->u.s._12 * pMatrix->u.s._11) + (mat->u.s._22 * pMatrix->u.s._12) + (mat->u.s._32 * pMatrix->u.s._13) + (mat->u.s._42 * pMatrix->u.s._14);
9081- temp.u.s._22 = (mat->u.s._12 * pMatrix->u.s._21) + (mat->u.s._22 * pMatrix->u.s._22) + (mat->u.s._32 * pMatrix->u.s._23) + (mat->u.s._42 * pMatrix->u.s._24);
9082- temp.u.s._32 = (mat->u.s._12 * pMatrix->u.s._31) + (mat->u.s._22 * pMatrix->u.s._32) + (mat->u.s._32 * pMatrix->u.s._33) + (mat->u.s._42 * pMatrix->u.s._34);
9083- temp.u.s._42 = (mat->u.s._12 * pMatrix->u.s._41) + (mat->u.s._22 * pMatrix->u.s._42) + (mat->u.s._32 * pMatrix->u.s._43) + (mat->u.s._42 * pMatrix->u.s._44);
9084-
9085- temp.u.s._13 = (mat->u.s._13 * pMatrix->u.s._11) + (mat->u.s._23 * pMatrix->u.s._12) + (mat->u.s._33 * pMatrix->u.s._13) + (mat->u.s._43 * pMatrix->u.s._14);
9086- temp.u.s._23 = (mat->u.s._13 * pMatrix->u.s._21) + (mat->u.s._23 * pMatrix->u.s._22) + (mat->u.s._33 * pMatrix->u.s._23) + (mat->u.s._43 * pMatrix->u.s._24);
9087- temp.u.s._33 = (mat->u.s._13 * pMatrix->u.s._31) + (mat->u.s._23 * pMatrix->u.s._32) + (mat->u.s._33 * pMatrix->u.s._33) + (mat->u.s._43 * pMatrix->u.s._34);
9088- temp.u.s._43 = (mat->u.s._13 * pMatrix->u.s._41) + (mat->u.s._23 * pMatrix->u.s._42) + (mat->u.s._33 * pMatrix->u.s._43) + (mat->u.s._43 * pMatrix->u.s._44);
9089-
9090- temp.u.s._14 = (mat->u.s._14 * pMatrix->u.s._11) + (mat->u.s._24 * pMatrix->u.s._12) + (mat->u.s._34 * pMatrix->u.s._13) + (mat->u.s._44 * pMatrix->u.s._14);
9091- temp.u.s._24 = (mat->u.s._14 * pMatrix->u.s._21) + (mat->u.s._24 * pMatrix->u.s._22) + (mat->u.s._34 * pMatrix->u.s._23) + (mat->u.s._44 * pMatrix->u.s._24);
9092- temp.u.s._34 = (mat->u.s._14 * pMatrix->u.s._31) + (mat->u.s._24 * pMatrix->u.s._32) + (mat->u.s._34 * pMatrix->u.s._33) + (mat->u.s._44 * pMatrix->u.s._34);
9093- temp.u.s._44 = (mat->u.s._14 * pMatrix->u.s._41) + (mat->u.s._24 * pMatrix->u.s._42) + (mat->u.s._34 * pMatrix->u.s._43) + (mat->u.s._44 * pMatrix->u.s._44);
9094+ temp.u.s._11 = (mat->u.s._11 * pMatrix->u.s._11) + (mat->u.s._21 * pMatrix->u.s._12) +
9095+ (mat->u.s._31 * pMatrix->u.s._13) + (mat->u.s._41 * pMatrix->u.s._14);
9096+ temp.u.s._21 = (mat->u.s._11 * pMatrix->u.s._21) + (mat->u.s._21 * pMatrix->u.s._22) +
9097+ (mat->u.s._31 * pMatrix->u.s._23) + (mat->u.s._41 * pMatrix->u.s._24);
9098+ temp.u.s._31 = (mat->u.s._11 * pMatrix->u.s._31) + (mat->u.s._21 * pMatrix->u.s._32) +
9099+ (mat->u.s._31 * pMatrix->u.s._33) + (mat->u.s._41 * pMatrix->u.s._34);
9100+ temp.u.s._41 = (mat->u.s._11 * pMatrix->u.s._41) + (mat->u.s._21 * pMatrix->u.s._42) +
9101+ (mat->u.s._31 * pMatrix->u.s._43) + (mat->u.s._41 * pMatrix->u.s._44);
9102+
9103+ temp.u.s._12 = (mat->u.s._12 * pMatrix->u.s._11) + (mat->u.s._22 * pMatrix->u.s._12) +
9104+ (mat->u.s._32 * pMatrix->u.s._13) + (mat->u.s._42 * pMatrix->u.s._14);
9105+ temp.u.s._22 = (mat->u.s._12 * pMatrix->u.s._21) + (mat->u.s._22 * pMatrix->u.s._22) +
9106+ (mat->u.s._32 * pMatrix->u.s._23) + (mat->u.s._42 * pMatrix->u.s._24);
9107+ temp.u.s._32 = (mat->u.s._12 * pMatrix->u.s._31) + (mat->u.s._22 * pMatrix->u.s._32) +
9108+ (mat->u.s._32 * pMatrix->u.s._33) + (mat->u.s._42 * pMatrix->u.s._34);
9109+ temp.u.s._42 = (mat->u.s._12 * pMatrix->u.s._41) + (mat->u.s._22 * pMatrix->u.s._42) +
9110+ (mat->u.s._32 * pMatrix->u.s._43) + (mat->u.s._42 * pMatrix->u.s._44);
9111+
9112+ temp.u.s._13 = (mat->u.s._13 * pMatrix->u.s._11) + (mat->u.s._23 * pMatrix->u.s._12) +
9113+ (mat->u.s._33 * pMatrix->u.s._13) + (mat->u.s._43 * pMatrix->u.s._14);
9114+ temp.u.s._23 = (mat->u.s._13 * pMatrix->u.s._21) + (mat->u.s._23 * pMatrix->u.s._22) +
9115+ (mat->u.s._33 * pMatrix->u.s._23) + (mat->u.s._43 * pMatrix->u.s._24);
9116+ temp.u.s._33 = (mat->u.s._13 * pMatrix->u.s._31) + (mat->u.s._23 * pMatrix->u.s._32) +
9117+ (mat->u.s._33 * pMatrix->u.s._33) + (mat->u.s._43 * pMatrix->u.s._34);
9118+ temp.u.s._43 = (mat->u.s._13 * pMatrix->u.s._41) + (mat->u.s._23 * pMatrix->u.s._42) +
9119+ (mat->u.s._33 * pMatrix->u.s._43) + (mat->u.s._43 * pMatrix->u.s._44);
9120+
9121+ temp.u.s._14 = (mat->u.s._14 * pMatrix->u.s._11) + (mat->u.s._24 * pMatrix->u.s._12) +
9122+ (mat->u.s._34 * pMatrix->u.s._13) + (mat->u.s._44 * pMatrix->u.s._14);
9123+ temp.u.s._24 = (mat->u.s._14 * pMatrix->u.s._21) + (mat->u.s._24 * pMatrix->u.s._22) +
9124+ (mat->u.s._34 * pMatrix->u.s._23) + (mat->u.s._44 * pMatrix->u.s._24);
9125+ temp.u.s._34 = (mat->u.s._14 * pMatrix->u.s._31) + (mat->u.s._24 * pMatrix->u.s._32) +
9126+ (mat->u.s._34 * pMatrix->u.s._33) + (mat->u.s._44 * pMatrix->u.s._34);
9127+ temp.u.s._44 = (mat->u.s._14 * pMatrix->u.s._41) + (mat->u.s._24 * pMatrix->u.s._42) +
9128+ (mat->u.s._34 * pMatrix->u.s._43) + (mat->u.s._44 * pMatrix->u.s._44);
9129
9130 /* Apply change via set transform - will reapply to eg. lights this way */
9131 IWineD3DDeviceImpl_SetTransform(iface, State, &temp);
9132@@ -1162,12 +1888,12 @@
9133 * Get / Set Light
9134 * WARNING: This code relies on the fact that D3DLIGHT8 == D3DLIGHT9
9135 *****/
9136-/* Note lights are real special cases. Although the device caps state only eg. 8 are supported,
9137- you can reference any indexes you want as long as that number max are enabled at any
9138- one point in time! Therefore since the indexes can be anything, we need a linked list of them.
9139- However, this causes stateblock problems. When capturing the state block, I duplicate the list,
9140- but when recording, just build a chain pretty much of commands to be replayed. */
9141-
9142+/** Note lights are real special cases. Although the device caps state only eg. 8 are supported,
9143+* you can reference any indexes you want as long as that number max are enabled at any
9144+* one point in time! Therefore since the indexes can be anything, we need a linked list of them.
9145+* However, this causes stateblock problems. When capturing the state block, I duplicate the list,
9146+* but when recording, just build a chain pretty much of commands to be replayed.
9147+ *****************/
9148 HRESULT WINAPI IWineD3DDeviceImpl_SetLight(IWineD3DDevice *iface, DWORD Index, CONST WINED3DLIGHT* pLight) {
9149 float rho;
9150 PLIGHTINFOEL *object, *temp;
9151@@ -1177,7 +1903,7 @@
9152
9153 /* If recording state block, just add to end of lights chain */
9154 if (This->isRecordingState) {
9155- object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(PLIGHTINFOEL));
9156+ object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,sizeof(PLIGHTINFOEL));
9157 if (NULL == object) {
9158 return D3DERR_OUTOFVIDEOMEMORY;
9159 }
9160@@ -1213,7 +1939,7 @@
9161 object->OriginalIndex = Index;
9162 object->glIndex = -1;
9163
9164- /* Add it to the front of list with the idea that lights will be changed as needed
9165+ /* Add it to the front of list with the idea that lights will be changed as needed
9166 BUT after any lights currently assigned GL indexes */
9167 insertAt = This->stateBlock->lights;
9168 prevPos = NULL;
9169@@ -1285,13 +2011,13 @@
9170 object->lightDirn[2] = pLight->Direction.z;
9171 object->lightDirn[3] = 1.0;
9172
9173- /*
9174+ /**
9175 * opengl-ish and d3d-ish spot lights use too different models for the
9176 * light "intensity" as a function of the angle towards the main light direction,
9177 * so we only can approximate very roughly.
9178 * however spot lights are rather rarely used in games (if ever used at all).
9179 * furthermore if still used, probably nobody pays attention to such details.
9180- */
9181+ ********************************/
9182 if (pLight->Falloff == 0) {
9183 rho = 6.28f;
9184 } else {
9185@@ -1301,7 +2027,7 @@
9186 object->exponent = -0.3/log(cos(rho/2));
9187 object->cutoff = pLight->Phi*90/M_PI;
9188
9189- /* FIXME: Range */
9190+ /** FIXME: Range **/
9191 break;
9192
9193 default:
9194@@ -1317,9 +2043,9 @@
9195
9196 HRESULT WINAPI IWineD3DDeviceImpl_GetLight(IWineD3DDevice *iface, DWORD Index, WINED3DLIGHT* pLight) {
9197 PLIGHTINFOEL *lightInfo = NULL;
9198- IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
9199+ IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
9200 TRACE("(%p) : Idx(%ld), pLight(%p)\n", This, Index, pLight);
9201-
9202+
9203 /* Locate the light in the live lights */
9204 lightInfo = This->stateBlock->lights;
9205 while (lightInfo != NULL && lightInfo->OriginalIndex != Index) lightInfo = lightInfo->next;
9206@@ -1334,7 +2060,7 @@
9207 }
9208
9209 /*****
9210- * Get / Set Light Enable
9211+ * Get / Set Light Enable
9212 * (Note for consistency, renamed d3dx function by adding the 'set' prefix)
9213 *****/
9214 HRESULT WINAPI IWineD3DDeviceImpl_SetLightEnable(IWineD3DDevice *iface, DWORD Index, BOOL Enable) {
9215@@ -1371,35 +2097,36 @@
9216 /* Special case - enabling an undefined light creates one with a strict set of parms! */
9217 if (lightInfo == NULL) {
9218 D3DLIGHT9 lightParms;
9219- /* Warning - untested code :-) Prob safe to change fixme to a trace but
9220- wait until someone confirms it seems to work! */
9221- TRACE("Light enabled requested but light not defined, so defining one!\n");
9222- lightParms.Type = D3DLIGHT_DIRECTIONAL;
9223- lightParms.Diffuse.r = 1.0;
9224- lightParms.Diffuse.g = 1.0;
9225- lightParms.Diffuse.b = 1.0;
9226- lightParms.Diffuse.a = 0.0;
9227- lightParms.Specular.r = 0.0;
9228- lightParms.Specular.g = 0.0;
9229- lightParms.Specular.b = 0.0;
9230- lightParms.Specular.a = 0.0;
9231- lightParms.Ambient.r = 0.0;
9232- lightParms.Ambient.g = 0.0;
9233- lightParms.Ambient.b = 0.0;
9234- lightParms.Ambient.a = 0.0;
9235- lightParms.Position.x = 0.0;
9236- lightParms.Position.y = 0.0;
9237- lightParms.Position.z = 0.0;
9238- lightParms.Direction.x = 0.0;
9239- lightParms.Direction.y = 0.0;
9240- lightParms.Direction.z = 1.0;
9241- lightParms.Range = 0.0;
9242- lightParms.Falloff = 0.0;
9243+ /** WARNING: - untested code :-) Prob safe to change fixme to a trace but
9244+ * wait until someone confirms it seems to work!
9245+ ***********************/
9246+ FIXME("Light enabled requested but light not defined, so defining one!\n");
9247+ lightParms.Type = D3DLIGHT_DIRECTIONAL;
9248+ lightParms.Diffuse.r = 1.0;
9249+ lightParms.Diffuse.g = 1.0;
9250+ lightParms.Diffuse.b = 1.0;
9251+ lightParms.Diffuse.a = 0.0;
9252+ lightParms.Specular.r = 0.0;
9253+ lightParms.Specular.g = 0.0;
9254+ lightParms.Specular.b = 0.0;
9255+ lightParms.Specular.a = 0.0;
9256+ lightParms.Ambient.r = 0.0;
9257+ lightParms.Ambient.g = 0.0;
9258+ lightParms.Ambient.b = 0.0;
9259+ lightParms.Ambient.a = 0.0;
9260+ lightParms.Position.x = 0.0;
9261+ lightParms.Position.y = 0.0;
9262+ lightParms.Position.z = 0.0;
9263+ lightParms.Direction.x = 0.0;
9264+ lightParms.Direction.y = 0.0;
9265+ lightParms.Direction.z = 1.0;
9266+ lightParms.Range = 0.0;
9267+ lightParms.Falloff = 0.0;
9268 lightParms.Attenuation0 = 0.0;
9269 lightParms.Attenuation1 = 0.0;
9270 lightParms.Attenuation2 = 0.0;
9271- lightParms.Theta = 0.0;
9272- lightParms.Phi = 0.0;
9273+ lightParms.Theta = 0.0;
9274+ lightParms.Phi = 0.0;
9275 IWineD3DDeviceImpl_SetLight(iface, Index, &lightParms);
9276
9277 /* Search for it again! Should be fairly quick as near head of list */
9278@@ -1521,7 +2248,7 @@
9279 gl lights, setup a new light */
9280 } else if (pos->glIndex == -1) {
9281
9282- /* We reached the end of the allocated gl lights, so already
9283+ /* We reached the end of the allocated gl lights, so already
9284 know the index of the next one! */
9285 glIndex = Index;
9286 lightInfo->glIndex = glIndex;
9287@@ -1557,7 +2284,7 @@
9288 glEnable(GL_LIGHT0 + glIndex);
9289 checkGLcall("glEnable GL_LIGHT0 new setup");
9290 LEAVE_GL();
9291-
9292+
9293 }
9294 }
9295 }
9296@@ -1567,9 +2294,9 @@
9297 HRESULT WINAPI IWineD3DDeviceImpl_GetLightEnable(IWineD3DDevice *iface, DWORD Index,BOOL* pEnable) {
9298
9299 PLIGHTINFOEL *lightInfo = NULL;
9300- IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
9301+ IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
9302 TRACE("(%p) : for idx(%ld)\n", This, Index);
9303-
9304+
9305 /* Locate the light in the live lights */
9306 lightInfo = This->stateBlock->lights;
9307 while (lightInfo != NULL && lightInfo->OriginalIndex != Index) lightInfo = lightInfo->next;
9308@@ -1617,10 +2344,10 @@
9309 glPushMatrix();
9310 glLoadMatrixf((float *) &This->stateBlock->transforms[D3DTS_VIEW].u.m[0][0]);
9311
9312- TRACE("Clipplane [%f,%f,%f,%f]\n",
9313- This->updateStateBlock->clipplane[Index][0],
9314+ TRACE("Clipplane [%f,%f,%f,%f]\n",
9315+ This->updateStateBlock->clipplane[Index][0],
9316 This->updateStateBlock->clipplane[Index][1],
9317- This->updateStateBlock->clipplane[Index][2],
9318+ This->updateStateBlock->clipplane[Index][2],
9319 This->updateStateBlock->clipplane[Index][3]);
9320 glClipPlane(GL_CLIP_PLANE0 + Index, This->updateStateBlock->clipplane[Index]);
9321 checkGLcall("glClipPlane");
9322@@ -1665,7 +2392,7 @@
9323
9324 HRESULT WINAPI IWineD3DDeviceImpl_GetClipStatus(IWineD3DDevice *iface, WINED3DCLIPSTATUS* pClipStatus) {
9325 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
9326- FIXME("(%p) : stub\n", This);
9327+ FIXME("(%p) : stub\n", This);
9328 if (NULL == pClipStatus) {
9329 return D3DERR_INVALIDCALL;
9330 }
9331@@ -1692,12 +2419,15 @@
9332 }
9333
9334 ENTER_GL();
9335- TRACE("(%p) : Diffuse (%f,%f,%f,%f)\n", This, pMaterial->Diffuse.r, pMaterial->Diffuse.g, pMaterial->Diffuse.b, pMaterial->Diffuse.a);
9336- TRACE("(%p) : Ambient (%f,%f,%f,%f)\n", This, pMaterial->Ambient.r, pMaterial->Ambient.g, pMaterial->Ambient.b, pMaterial->Ambient.a);
9337- TRACE("(%p) : Specular (%f,%f,%f,%f)\n", This, pMaterial->Specular.r, pMaterial->Specular.g, pMaterial->Specular.b, pMaterial->Specular.a);
9338- TRACE("(%p) : Emissive (%f,%f,%f,%f)\n", This, pMaterial->Emissive.r, pMaterial->Emissive.g, pMaterial->Emissive.b, pMaterial->Emissive.a);
9339+ TRACE("(%p) : Diffuse (%f,%f,%f,%f)\n", This, pMaterial->Diffuse.r, pMaterial->Diffuse.g,
9340+ pMaterial->Diffuse.b, pMaterial->Diffuse.a);
9341+ TRACE("(%p) : Ambient (%f,%f,%f,%f)\n", This, pMaterial->Ambient.r, pMaterial->Ambient.g,
9342+ pMaterial->Ambient.b, pMaterial->Ambient.a);
9343+ TRACE("(%p) : Specular (%f,%f,%f,%f)\n", This, pMaterial->Specular.r, pMaterial->Specular.g,
9344+ pMaterial->Specular.b, pMaterial->Specular.a);
9345+ TRACE("(%p) : Emissive (%f,%f,%f,%f)\n", This, pMaterial->Emissive.r, pMaterial->Emissive.g,
9346+ pMaterial->Emissive.b, pMaterial->Emissive.a);
9347 TRACE("(%p) : Power (%f)\n", This, pMaterial->Power);
9348-
9349 glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, (float*) &This->updateStateBlock->material.Ambient);
9350 checkGLcall("glMaterialfv");
9351 glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, (float*) &This->updateStateBlock->material.Diffuse);
9352@@ -1716,7 +2446,6 @@
9353 checkGLcall("glMaterialfv");
9354 glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, This->updateStateBlock->material.Power);
9355 checkGLcall("glMaterialf");
9356-
9357 LEAVE_GL();
9358 return D3D_OK;
9359 }
9360@@ -1724,10 +2453,14 @@
9361 HRESULT WINAPI IWineD3DDeviceImpl_GetMaterial(IWineD3DDevice *iface, WINED3DMATERIAL* pMaterial) {
9362 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
9363 memcpy(pMaterial, &This->updateStateBlock->material, sizeof (WINED3DMATERIAL));
9364- TRACE("(%p) : Diffuse (%f,%f,%f,%f)\n", This, pMaterial->Diffuse.r, pMaterial->Diffuse.g, pMaterial->Diffuse.b, pMaterial->Diffuse.a);
9365- TRACE("(%p) : Ambient (%f,%f,%f,%f)\n", This, pMaterial->Ambient.r, pMaterial->Ambient.g, pMaterial->Ambient.b, pMaterial->Ambient.a);
9366- TRACE("(%p) : Specular (%f,%f,%f,%f)\n", This, pMaterial->Specular.r, pMaterial->Specular.g, pMaterial->Specular.b, pMaterial->Specular.a);
9367- TRACE("(%p) : Emissive (%f,%f,%f,%f)\n", This, pMaterial->Emissive.r, pMaterial->Emissive.g, pMaterial->Emissive.b, pMaterial->Emissive.a);
9368+ TRACE("(%p) : Diffuse (%f,%f,%f,%f)\n", This, pMaterial->Diffuse.r, pMaterial->Diffuse.g,
9369+ pMaterial->Diffuse.b, pMaterial->Diffuse.a);
9370+ TRACE("(%p) : Ambient (%f,%f,%f,%f)\n", This, pMaterial->Ambient.r, pMaterial->Ambient.g,
9371+ pMaterial->Ambient.b, pMaterial->Ambient.a);
9372+ TRACE("(%p) : Specular (%f,%f,%f,%f)\n", This, pMaterial->Specular.r, pMaterial->Specular.g,
9373+ pMaterial->Specular.b, pMaterial->Specular.a);
9374+ TRACE("(%p) : Emissive (%f,%f,%f,%f)\n", This, pMaterial->Emissive.r, pMaterial->Emissive.g,
9375+ pMaterial->Emissive.b, pMaterial->Emissive.a);
9376 TRACE("(%p) : Power (%f)\n", This, pMaterial->Power);
9377 return D3D_OK;
9378 }
9379@@ -1735,7 +2468,7 @@
9380 /*****
9381 * Get / Set Indices
9382 *****/
9383-HRESULT WINAPI IWineD3DDeviceImpl_SetIndices(IWineD3DDevice *iface, IWineD3DIndexBuffer* pIndexData,
9384+HRESULT WINAPI IWineD3DDeviceImpl_SetIndices(IWineD3DDevice *iface, IWineD3DIndexBuffer* pIndexData,
9385 UINT BaseVertexIndex) {
9386 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
9387 IWineD3DIndexBuffer *oldIdxs;
9388@@ -1753,7 +2486,7 @@
9389 TRACE("Recording... not performing anything\n");
9390 return D3D_OK;
9391 }
9392-
9393+ /* We shouldn't be reff counting! */
9394 if (oldIdxs) IWineD3DIndexBuffer_Release(oldIdxs);
9395 if (pIndexData) IWineD3DIndexBuffer_AddRef(This->stateBlock->pIndexData);
9396 return D3D_OK;
9397@@ -1763,11 +2496,16 @@
9398 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
9399
9400 *ppIndexData = This->stateBlock->pIndexData;
9401-
9402- /* up ref count on ppindexdata */
9403- if (*ppIndexData) IWineD3DIndexBuffer_AddRef(*ppIndexData);
9404- *pBaseVertexIndex = This->stateBlock->baseVertexIndex;
9405
9406+ /* up ref count on ppindexdata */
9407+ if (*ppIndexData) {
9408+ IWineD3DIndexBuffer_AddRef(*ppIndexData);
9409+ *pBaseVertexIndex = This->stateBlock->baseVertexIndex;
9410+ TRACE("(%p) index data set to %p + %u\n", This, ppIndexData, This->stateBlock->baseVertexIndex);
9411+ }else{
9412+ TRACE("(%p) No index data set\n", This);
9413+ }
9414+ TRACE("Returning %p %d \n",*ppIndexData, *pBaseVertexIndex);
9415 return D3D_OK;
9416 }
9417
9418@@ -1796,9 +2534,26 @@
9419 glDepthRange(pViewport->MinZ, pViewport->MaxZ);
9420 checkGLcall("glDepthRange");
9421 /* Note: GL requires lower left, DirectX supplies upper left */
9422- /* TODO: replace usage of renderTarget with context management */
9423- glViewport(pViewport->X, (((IWineD3DSurfaceImpl *)This->renderTarget)->currentDesc.Height - (pViewport->Y + pViewport->Height)),
9424- pViewport->Width, pViewport->Height);
9425+#if 1 /** TODO: replace IWineD3DSurfaceImpl * with IWineD3DSurface_GetDesc(or maybe just get height),
9426+ NOTE: moving over to context mamagement will fix things here **/
9427+ glViewport(pViewport->X, (((IWineD3DSurfaceImpl *)This->renderTarget)->currentDesc.Height - (pViewport->Y + pViewport->Height)),
9428+ pViewport->Width, pViewport->Height);
9429+#else /* NOTE: code below is a nasty hack to demostrate a fix for the problem in fr-030_candytron_final */
9430+ IWineD3DSurfaceImpl * backBuffer = (IWineD3DSurfaceImpl *)((IWineD3DSwapChainImpl *)This->swapchains[0])->backBuffer;
9431+ /** NOTE: This is a nasty hack, when we switch from an 'oversized' offscreen render target (in this case 1024x1024)
9432+ *to the back buffer we get nasty clipping problems fr-030_candytron_final is an example of the problem,
9433+ *and I think it happenes in pirates too everything should be solved by introducing an opengl context manager
9434+ *that knows a lot more about what context/drawable we're in and how to handel odd context/drawable problems.
9435+ **/
9436+ if(This->renderTarget == backBuffer){
9437+ glViewport(pViewport->X, (This->renderTarget->currentDesc.Height - (pViewport->Y + 1024)),
9438+ 1024, 1024);
9439+ } else{
9440+ glViewport(pViewport->X, (This->renderTarget->currentDesc.Height - (pViewport->Y + pViewport->Height)),
9441+ pViewport->Width, pViewport->Height);
9442+ }
9443+
9444+#endif
9445 checkGLcall("glViewport");
9446
9447 LEAVE_GL();
9448@@ -1821,15 +2576,28 @@
9449 HRESULT WINAPI IWineD3DDeviceImpl_SetRenderState(IWineD3DDevice *iface, D3DRENDERSTATETYPE State, DWORD Value) {
9450
9451 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
9452- DWORD OldValue = This->stateBlock->renderState[State];
9453-
9454+ DWORD OldValue;
9455 /* Simple way of referring to either a DWORD or a 4 byte float */
9456 union {
9457 DWORD d;
9458 float f;
9459 } tmpvalue;
9460-
9461+
9462+ union {
9463+ DWORD d;
9464+ float f;
9465+ } tmpvalue2;
9466+
9467 TRACE("(%p)->state = %s(%d), value = %ld\n", This, debug_d3drenderstate(State), State, Value);
9468+ if(State > WINEHIGHEST_RENDER_STATE ) {
9469+ FIXME("(%p) State %s(%d) out of range\n", This, debug_d3drenderstate(State), State);
9470+ return D3DERR_INVALIDCALL;
9471+ }
9472+
9473+ OldValue = This->stateBlock->renderState[State];
9474+ TRACE("(%p)->state = %s(%d), value = %ld OldValue %ld %p\n", This, debug_d3drenderstate(State), State,
9475+ Value, OldValue, This->updateStateBlock);
9476+
9477 This->updateStateBlock->changed.renderState[State] = TRUE;
9478 This->updateStateBlock->set.renderState[State] = TRUE;
9479 This->updateStateBlock->renderState[State] = Value;
9480@@ -1887,7 +2655,7 @@
9481 case WINED3DRS_CULLMODE :
9482
9483 /* If we are culling "back faces with clockwise vertices" then
9484- set front faces to be counter clockwise and enable culling
9485+ set front faces to be counter clockwise and enable culling
9486 of back faces */
9487 switch ((D3DCULL) Value) {
9488 case D3DCULL_NONE:
9489@@ -1910,7 +2678,7 @@
9490 glEnable(GL_CULL_FACE);
9491 checkGLcall("glEnable GL_CULL_FACE");
9492 if (This->renderUpsideDown) {
9493- glFrontFace(GL_CCW);
9494+ glFrontFace(GL_CCW);
9495 checkGLcall("glFrontFace GL_CCW");
9496 } else {
9497 glFrontFace(GL_CW);
9498@@ -1997,7 +2765,7 @@
9499
9500 case WINED3DRS_ALPHABLENDENABLE :
9501 if (Value) {
9502- glEnable(GL_BLEND);
9503+ glEnable(GL_BLEND);
9504 checkGLcall("glEnable GL_BLEND");
9505 } else {
9506 glDisable(GL_BLEND);
9507@@ -2096,7 +2864,7 @@
9508 /* Ensure we only do the changed clip planes */
9509 DWORD enable = 0xFFFFFFFF;
9510 DWORD disable = 0x00000000;
9511-
9512+
9513 /* If enabling / disabling all */
9514 if (State == WINED3DRS_CLIPPING) {
9515 if (Value) {
9516@@ -2110,14 +2878,14 @@
9517 enable = Value & ~OldValue;
9518 disable = ~Value & OldValue;
9519 }
9520-
9521+
9522 if (enable & D3DCLIPPLANE0) { glEnable(GL_CLIP_PLANE0); checkGLcall("glEnable(clip plane 0)"); }
9523 if (enable & D3DCLIPPLANE1) { glEnable(GL_CLIP_PLANE1); checkGLcall("glEnable(clip plane 1)"); }
9524 if (enable & D3DCLIPPLANE2) { glEnable(GL_CLIP_PLANE2); checkGLcall("glEnable(clip plane 2)"); }
9525 if (enable & D3DCLIPPLANE3) { glEnable(GL_CLIP_PLANE3); checkGLcall("glEnable(clip plane 3)"); }
9526 if (enable & D3DCLIPPLANE4) { glEnable(GL_CLIP_PLANE4); checkGLcall("glEnable(clip plane 4)"); }
9527 if (enable & D3DCLIPPLANE5) { glEnable(GL_CLIP_PLANE5); checkGLcall("glEnable(clip plane 5)"); }
9528-
9529+
9530 if (disable & D3DCLIPPLANE0) { glDisable(GL_CLIP_PLANE0); checkGLcall("glDisable(clip plane 0)"); }
9531 if (disable & D3DCLIPPLANE1) { glDisable(GL_CLIP_PLANE1); checkGLcall("glDisable(clip plane 1)"); }
9532 if (disable & D3DCLIPPLANE2) { glDisable(GL_CLIP_PLANE2); checkGLcall("glDisable(clip plane 2)"); }
9533@@ -2159,7 +2927,7 @@
9534 {
9535 unsigned int i;
9536
9537- /* Note the texture color applies to all textures whereas
9538+ /* Note the texture color applies to all textures whereas
9539 GL_TEXTURE_ENV_COLOR applies to active only */
9540 float col[4];
9541 D3DCOLORTOGLFLOAT4(Value, col);
9542@@ -2285,9 +3053,9 @@
9543
9544 case WINED3DRS_STENCILFAIL :
9545 {
9546- GLenum fail ;
9547- GLenum zpass ;
9548- GLenum zfail ;
9549+ GLenum fail ;
9550+ GLenum zpass ;
9551+ GLenum zfail ;
9552
9553 fail = StencilOp(Value);
9554 glGetIntegerv(GL_STENCIL_PASS_DEPTH_PASS, &zpass);
9555@@ -2302,9 +3070,9 @@
9556 break;
9557 case WINED3DRS_STENCILZFAIL :
9558 {
9559- GLenum fail ;
9560- GLenum zpass ;
9561- GLenum zfail ;
9562+ GLenum fail ;
9563+ GLenum zpass ;
9564+ GLenum zfail ;
9565
9566 glGetIntegerv(GL_STENCIL_FAIL, &fail);
9567 checkGLcall("glGetIntegerv(GL_STENCIL_FAIL, &fail);");
9568@@ -2319,9 +3087,9 @@
9569 break;
9570 case WINED3DRS_STENCILPASS :
9571 {
9572- GLenum fail ;
9573- GLenum zpass ;
9574- GLenum zfail ;
9575+ GLenum fail ;
9576+ GLenum zpass ;
9577+ GLenum zfail ;
9578
9579 glGetIntegerv(GL_STENCIL_FAIL, &fail);
9580 checkGLcall("glGetIntegerv(GL_STENCIL_FAIL, &fail);");
9581@@ -2345,7 +3113,7 @@
9582
9583 case WINED3DRS_FOGENABLE :
9584 {
9585- if (Value/* && This->stateBlock->renderState[WINED3DRS_FOGTABLEMODE] != D3DFOG_NONE*/) {
9586+ if (Value/* && This->stateBlock->renderState[WINED3DRS_FOGTABLEMODE] != D3DFOG_NONE */) {
9587 glEnable(GL_FOG);
9588 checkGLcall("glEnable GL_FOG");
9589 } else {
9590@@ -2376,13 +3144,13 @@
9591 break;
9592
9593 case WINED3DRS_FOGTABLEMODE :
9594- {
9595+ {
9596 glHint(GL_FOG_HINT, GL_NICEST);
9597 switch (Value) {
9598- case D3DFOG_NONE: /* I don't know what to do here */ checkGLcall("glFogi(GL_FOG_MODE, GL_EXP"); break;
9599- case D3DFOG_EXP: glFogi(GL_FOG_MODE, GL_EXP); checkGLcall("glFogi(GL_FOG_MODE, GL_EXP"); break;
9600- case D3DFOG_EXP2: glFogi(GL_FOG_MODE, GL_EXP2); checkGLcall("glFogi(GL_FOG_MODE, GL_EXP2"); break;
9601- case D3DFOG_LINEAR: glFogi(GL_FOG_MODE, GL_LINEAR); checkGLcall("glFogi(GL_FOG_MODE, GL_LINEAR"); break;
9602+ case D3DFOG_NONE: /* I don't know what to do here */ checkGLcall("glFogi(GL_FOG_MODE, GL_EXP"); break;
9603+ case D3DFOG_EXP: glFogi(GL_FOG_MODE, GL_EXP); checkGLcall("glFogi(GL_FOG_MODE, GL_EXP"); break;
9604+ case D3DFOG_EXP2: glFogi(GL_FOG_MODE, GL_EXP2); checkGLcall("glFogi(GL_FOG_MODE, GL_EXP2"); break;
9605+ case D3DFOG_LINEAR: glFogi(GL_FOG_MODE, GL_LINEAR); checkGLcall("glFogi(GL_FOG_MODE, GL_LINEAR"); break;
9606 default:
9607 FIXME("Unsupported Value(%lu) for WINED3DRS_FOGTABLEMODE!\n", Value);
9608 }
9609@@ -2393,13 +3161,13 @@
9610 break;
9611
9612 case WINED3DRS_FOGVERTEXMODE :
9613- {
9614+ {
9615 glHint(GL_FOG_HINT, GL_FASTEST);
9616 switch (Value) {
9617- case D3DFOG_NONE: /* I don't know what to do here */ checkGLcall("glFogi(GL_FOG_MODE, GL_EXP"); break;
9618- case D3DFOG_EXP: glFogi(GL_FOG_MODE, GL_EXP); checkGLcall("glFogi(GL_FOG_MODE, GL_EXP"); break;
9619- case D3DFOG_EXP2: glFogi(GL_FOG_MODE, GL_EXP2); checkGLcall("glFogi(GL_FOG_MODE, GL_EXP2"); break;
9620- case D3DFOG_LINEAR: glFogi(GL_FOG_MODE, GL_LINEAR); checkGLcall("glFogi(GL_FOG_MODE, GL_LINEAR"); break;
9621+ case D3DFOG_NONE: /* I don't know what to do here */ checkGLcall("glFogi(GL_FOG_MODE, GL_EXP"); break;
9622+ case D3DFOG_EXP: glFogi(GL_FOG_MODE, GL_EXP); checkGLcall("glFogi(GL_FOG_MODE, GL_EXP"); break;
9623+ case D3DFOG_EXP2: glFogi(GL_FOG_MODE, GL_EXP2); checkGLcall("glFogi(GL_FOG_MODE, GL_EXP2"); break;
9624+ case D3DFOG_LINEAR: glFogi(GL_FOG_MODE, GL_LINEAR); checkGLcall("glFogi(GL_FOG_MODE, GL_LINEAR"); break;
9625 default:
9626 FIXME("Unsupported Value(%lu) for WINED3DRS_FOGTABLEMODE!\n", Value);
9627 }
9628@@ -2452,7 +3220,7 @@
9629
9630 case WINED3DRS_INDEXEDVERTEXBLENDENABLE :
9631 {
9632- TRACE("Indexed Vertex Blend Enable to %ul\n", (BOOL) Value);
9633+ TRACE("Stub: Indexed Vertex Blend Enable to %ul\n", (BOOL) Value);
9634 }
9635 break;
9636
9637@@ -2498,9 +3266,16 @@
9638 if (This->tracking_color != DISABLED_TRACKING) This->tracking_color = NEEDS_DISABLE;
9639 }
9640 }
9641- break;
9642-
9643- case WINED3DRS_LINEPATTERN :
9644+ break;
9645+ case WINED3DRS_SCISSORTESTENABLE:
9646+ if(Value !=0 ){/* ignore default of off */
9647+ glDisable(GL_SCISSOR_TEST);
9648+ }else{
9649+ glEnable(GL_SCISSOR_TEST);
9650+ }
9651+ /* All this stuff is D3D* only, so there needs to be a set of flags for WineD3D that's inclusive */
9652+#if 0
9653+ case WINED3DRS_LINEPATTERN:
9654 {
9655 union {
9656 DWORD d;
9657@@ -2521,13 +3296,17 @@
9658 }
9659 }
9660 break;
9661+#endif
9662+ case WINED3DRS_DEPTHBIAS :
9663+ case WINED3DRS_SLOPESCALEDEPTHBIAS :
9664
9665- case WINED3DRS_ZBIAS :
9666- {
9667- if (Value) {
9668- tmpvalue.d = Value;
9669- TRACE("ZBias value %f\n", tmpvalue.f);
9670- glPolygonOffset(0, -tmpvalue.f);
9671+ tmpvalue.d = This->stateBlock->renderState[WINED3DRS_SLOPESCALEDEPTHBIAS];
9672+ tmpvalue2.d = This->stateBlock->renderState[WINED3DRS_DEPTHBIAS];
9673+
9674+ {
9675+ if (tmpvalue.f) {
9676+ TRACE("DEPTHBIAS value %f %f\n",tmpvalue.f, tmpvalue2.f);
9677+ glPolygonOffset(-tmpvalue.f, -tmpvalue2.f);
9678 checkGLcall("glPolygonOffset(0, -Value)");
9679 glEnable(GL_POLYGON_OFFSET_FILL);
9680 checkGLcall("glEnable(GL_POLYGON_OFFSET_FILL);");
9681@@ -2558,12 +3337,15 @@
9682
9683 case WINED3DRS_POINTSIZE :
9684 tmpvalue.d = Value;
9685- TRACE("Set point size to %f\n", tmpvalue.f);
9686+ /* FIXME: check that pointSize isn't outside glGetFloatv( GL_POINT_SIZE_MAX_ARB, &maxSize ); or -ve */
9687+ VTRACE(("glPointSize: %f\n", tmpvalue.f));
9688 glPointSize(tmpvalue.f);
9689 checkGLcall("glPointSize(...);");
9690 break;
9691
9692 case WINED3DRS_POINTSIZE_MIN :
9693+ /* TODO: Arb
9694+ GL_EXTCALL(glPointParameterfARB)( GL_POINT_SIZE_MIN_ARB, 1.0f );*/
9695 if (GL_SUPPORT(EXT_POINT_PARAMETERS)) {
9696 tmpvalue.d = Value;
9697 GL_EXTCALL(glPointParameterfEXT)(GL_POINT_SIZE_MIN_EXT, tmpvalue.f);
9698@@ -2574,6 +3356,10 @@
9699 break;
9700
9701 case WINED3DRS_POINTSIZE_MAX :
9702+ /* TODO: Arb
9703+ GL_EXTCALL(glPointParameterfARB)( GL_POINT_FADE_THRESHOLD_SIZE_ARB, 60.0f );
9704+ GL_EXTCALL(glPointParameterfARB)( GL_POINT_SIZE_MAX_ARB, 60.0f );
9705+ */
9706 if (GL_SUPPORT(EXT_POINT_PARAMETERS)) {
9707 tmpvalue.d = Value;
9708 GL_EXTCALL(glPointParameterfEXT)(GL_POINT_SIZE_MAX_EXT, tmpvalue.f);
9709@@ -2588,41 +3374,44 @@
9710 case WINED3DRS_POINTSCALE_C :
9711 case WINED3DRS_POINTSCALEENABLE :
9712 {
9713- /* If enabled, supply the parameters, otherwise fall back to defaults */
9714 if (This->stateBlock->renderState[WINED3DRS_POINTSCALEENABLE]) {
9715 GLfloat att[3] = {1.0f, 0.0f, 0.0f};
9716- att[0] = *((float*)&This->stateBlock->renderState[WINED3DRS_POINTSCALE_A]);
9717- att[1] = *((float*)&This->stateBlock->renderState[WINED3DRS_POINTSCALE_B]);
9718- att[2] = *((float*)&This->stateBlock->renderState[WINED3DRS_POINTSCALE_C]);
9719+ /* This scaling seems to be ok, the z's not correct though */
9720+ att[0] = *((float*)&This->stateBlock->renderState[WINED3DRS_POINTSCALE_A])/ This->stateBlock->viewport.Width;
9721+ att[1] = *((float*)&This->stateBlock->renderState[WINED3DRS_POINTSCALE_B])/ This->stateBlock->viewport.Height;
9722+ att[2] = *((float*)&This->stateBlock->renderState[WINED3DRS_POINTSCALE_C]) * 2.0f /
9723+ (This->stateBlock->viewport.Width * This->stateBlock->viewport.Height);
9724+
9725
9726 if (GL_SUPPORT(EXT_POINT_PARAMETERS)) {
9727- GL_EXTCALL(glPointParameterfvEXT)(GL_DISTANCE_ATTENUATION_EXT, att);
9728- checkGLcall("glPointParameterfvEXT(GL_DISTANCE_ATTENUATION_EXT, ...);");
9729+ TRACE("glPointParameterfvARB %f %f %f\n",att[0],att[1],att[2]);
9730+ GL_EXTCALL(glPointParameterfvEXT)(GL_DISTANCE_ATTENUATION_EXT, att);
9731+ checkGLcall("glPointParameterfvEXT(GL_DISTANCE_ATTENUATION_EXT, ...);");
9732 } else {
9733- TRACE("WINED3DRS_POINTSCALEENABLE not supported on this opengl\n");
9734+ TRACE("WINED3DRS_POINTSCALEENABLE not supported on this opengl\n");
9735 }
9736 } else {
9737 GLfloat att[3] = {1.0f, 0.0f, 0.0f};
9738 if (GL_SUPPORT(EXT_POINT_PARAMETERS)) {
9739- GL_EXTCALL(glPointParameterfvEXT)(GL_DISTANCE_ATTENUATION_EXT, att);
9740- checkGLcall("glPointParameterfvEXT(GL_DISTANCE_ATTENUATION_EXT, ...);");
9741+ GL_EXTCALL(glPointParameterfvEXT)(GL_DISTANCE_ATTENUATION_EXT, att);
9742+ checkGLcall("glPointParameterfvEXT(GL_DISTANCE_ATTENUATION_EXT, ...);");
9743 } else {
9744 TRACE("WINED3DRS_POINTSCALEENABLE not supported, but not on either\n");
9745 }
9746 }
9747- break;
9748 }
9749+ break;
9750
9751 case WINED3DRS_COLORWRITEENABLE :
9752 {
9753- TRACE("Color mask: r(%d) g(%d) b(%d) a(%d)\n",
9754+ TRACE("Color mask: r(%d) g(%d) b(%d) a(%d)\n",
9755 Value & D3DCOLORWRITEENABLE_RED ? 1 : 0,
9756 Value & D3DCOLORWRITEENABLE_GREEN ? 1 : 0,
9757 Value & D3DCOLORWRITEENABLE_BLUE ? 1 : 0,
9758- Value & D3DCOLORWRITEENABLE_ALPHA ? 1 : 0);
9759- glColorMask(Value & D3DCOLORWRITEENABLE_RED ? GL_TRUE : GL_FALSE,
9760+ Value & D3DCOLORWRITEENABLE_ALPHA ? 1 : 0);
9761+ glColorMask(Value & D3DCOLORWRITEENABLE_RED ? GL_TRUE : GL_FALSE,
9762 Value & D3DCOLORWRITEENABLE_GREEN ? GL_TRUE : GL_FALSE,
9763- Value & D3DCOLORWRITEENABLE_BLUE ? GL_TRUE : GL_FALSE,
9764+ Value & D3DCOLORWRITEENABLE_BLUE ? GL_TRUE : GL_FALSE,
9765 Value & D3DCOLORWRITEENABLE_ALPHA ? GL_TRUE : GL_FALSE);
9766 checkGLcall("glColorMask(...)");
9767 }
9768@@ -2631,7 +3420,7 @@
9769 case WINED3DRS_LOCALVIEWER :
9770 {
9771 GLint state = (Value) ? 1 : 0;
9772- TRACE("Local Viewer Enable to %ul\n", (BOOL) Value);
9773+ TRACE("Local Viewer Enable to %ul\n", (BOOL) Value);
9774 glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, state);
9775 }
9776 break;
9777@@ -2639,9 +3428,9 @@
9778 case WINED3DRS_LASTPIXEL :
9779 {
9780 if (Value) {
9781- TRACE("Last Pixel Drawing Enabled\n");
9782+ TRACE("Last Pixel Drawing Enabled\n");
9783 } else {
9784- FIXME("Last Pixel Drawing Disabled, not handled yet\n");
9785+ TRACE("Last Pixel Drawing Disabled, not handled yet\n");
9786 }
9787 }
9788 break;
9789@@ -2649,22 +3438,67 @@
9790 case WINED3DRS_SOFTWAREVERTEXPROCESSING :
9791 {
9792 if (Value) {
9793- TRACE("Software Processing Enabled\n");
9794+ TRACE("Software Processing Enabled\n");
9795 } else {
9796- TRACE("Software Processing Disabled\n");
9797+ TRACE("Software Processing Disabled\n");
9798 }
9799 }
9800 break;
9801
9802 /** not supported */
9803- case WINED3DRS_ZVISIBLE :
9804+ case WINED3DRS_ZVISIBLE :
9805+ case WINED3DRS_EDGEANTIALIAS :
9806 {
9807 LEAVE_GL();
9808 return D3DERR_INVALIDCALL;
9809 }
9810
9811- /* Unhandled yet...! */
9812- case WINED3DRS_EDGEANTIALIAS :
9813+
9814+ case WINED3DRS_POINTSPRITEENABLE :
9815+ /* http://data.plok.be/ExNihilo/pages/Tutorialpointsprite.htm
9816+ http://oss.sgi.com/projects/ogl-sample/registry/ARB/point_sprite.txt
9817+ */
9818+ /** TODO:
9819+ * if (GL_SUPPORT(GL_POINT_SPRITE_ARB)) {
9820+ **/
9821+ if(Value != FALSE){
9822+#if 1
9823+ /* Doesn't work with GL_POINT_SMOOTH on on my ATI 9600, but then ATI drivers are buggered! */
9824+ glDisable(GL_POINT_SMOOTH);
9825+#endif
9826+
9827+ /* Centre the texture on the vertex */
9828+ VTRACE("glTexEnvf( GL_POINT_SPRITE_ARB, GL_COORD_REPLACE_ARB, GL_TRUE)\n");
9829+ glTexEnvf( GL_POINT_SPRITE_ARB, GL_COORD_REPLACE_ARB, GL_TRUE);
9830+
9831+ VTRACE("glTexEnvf( GL_POINT_SPRITE_ARB, GL_COORD_REPLACE_ARB, GL_TRUE)\n");
9832+ glTexEnvf( GL_POINT_SPRITE_ARB, GL_COORD_REPLACE_ARB, GL_TRUE);
9833+ checkGLcall("glTexEnvf(...)");
9834+ VTRACE("glEnable( GL_POINT_SPRITE_ARB )\n");
9835+ glEnable( GL_POINT_SPRITE_ARB );
9836+ checkGLcall("glEnable(...)");
9837+ }else{
9838+ VTRACE("glDisable( GL_POINT_SPRITE_ARB )\n");
9839+ glDisable( GL_POINT_SPRITE_ARB );
9840+ checkGLcall("glEnable(...)");
9841+ }
9842+ break;
9843+ case WINED3DRS_MULTISAMPLEANTIALIAS :
9844+ /* implementation at http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=46
9845+ GL_ARB_MULTISAMPLE
9846+ */
9847+ if(Value != 0){
9848+ FIXME("(%p) multisample antialias not yet supported\n",This);
9849+ }
9850+ break;
9851+ case WINED3DRS_DEBUGMONITORTOKEN :
9852+ if(Value){
9853+ This->debug=TRUE;
9854+ FIXME("(%p) Debug streams not yet supported\n",This);
9855+ }else{
9856+ This->debug=FALSE;
9857+ }
9858+ break;
9859 case WINED3DRS_WRAP0 :
9860 case WINED3DRS_WRAP1 :
9861 case WINED3DRS_WRAP2 :
9862@@ -2673,23 +3507,27 @@
9863 case WINED3DRS_WRAP5 :
9864 case WINED3DRS_WRAP6 :
9865 case WINED3DRS_WRAP7 :
9866- case WINED3DRS_POINTSPRITEENABLE :
9867- case WINED3DRS_MULTISAMPLEANTIALIAS :
9868+ /**
9869+ http://www.cosc.brocku.ca/Offerings/3P98/course/lectures/texture/
9870+ http://msdn.microsoft.com/archive/default.asp?url=/archive/en-us/directx9_c/directx/graphics/programmingguide/FixedFunction/Textures/texturewrapping.asp
9871+ http://www.gamedev.net/reference/programming/features/rendererdll3/page2.asp
9872+ Descussion that ways to turn on WRAPing to solve an opengl conversion problem.
9873+ http://www.flipcode.org/cgi-bin/fcmsg.cgi?thread_show=10248
9874+ */
9875+ TRACE("(%p)->(%d,%ld) Texture wraping not yet supported\n",This, State, Value);
9876+ break;
9877 case WINED3DRS_MULTISAMPLEMASK :
9878 case WINED3DRS_PATCHEDGESTYLE :
9879 case WINED3DRS_PATCHSEGMENTS :
9880- case WINED3DRS_DEBUGMONITORTOKEN :
9881 case WINED3DRS_POSITIONORDER :
9882 case WINED3DRS_NORMALORDER :
9883- /*Put back later: FIXME("(%p)->(%d,%ld) not handled yet\n", This, State, Value); */
9884 FIXME("(%p)->(%d,%ld) not handled yet\n", This, State, Value);
9885 break;
9886 default:
9887- FIXME("(%p)->(%d,%ld) unrecognized\n", This, State, Value);
9888+ TRACE("(%p)->(%d,%ld) unrecognized\n", This, State, Value);
9889 }
9890
9891 LEAVE_GL();
9892-
9893 return D3D_OK;
9894 }
9895
9896@@ -2700,130 +3538,435 @@
9897 return D3D_OK;
9898 }
9899
9900-HRESULT WINAPI IWineD3DDeviceImpl_SetSamplerState(IWineD3DDevice *iface, DWORD Sampler, WINED3DSAMPLERSTATETYPE Type, DWORD Value){
9901- IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
9902-
9903- FIXME("(%p) : stub\n", This);
9904- return D3D_OK;
9905-}
9906-
9907-HRESULT WINAPI IWineD3DDeviceImpl_GetSamplerState(IWineD3DDevice *iface, DWORD Sampler, WINED3DSAMPLERSTATETYPE Type, DWORD* Value){
9908+HRESULT WINAPI IWineD3DDeviceImpl_SetSamplerState(IWineD3DDevice *iface, DWORD Sampler, WINED3DSAMPLERSTATETYPE Type, DWORD Value){
9909 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
9910
9911- FIXME("(%p) : stub\n", This);
9912- return D3D_OK;
9913-
9914-}
9915-
9916-HRESULT WINAPI IWineD3DDeviceImpl_SetScissorRect(IWineD3DDevice *iface, CONST RECT* pRect){
9917- IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
9918- ENTER_GL();
9919+ /**
9920+ * SetSampler is designed to allow fore more than the standard upto 8 textures?
9921+ * and Geforce has stopped suporting more than 6 standards texture in openGL,
9922+ * So I have to use ARB for Gforce. (maybe if the sampler > 4 then use ARB?)
9923+ *
9924+ * http://developer.nvidia.com/object/General_FAQ.html#t6
9925+ *
9926+ * There are two new settings for GForce
9927+ * the sampler one:
9928+ * GL_MAX_TEXTURE_IMAGE_UNITS_ARB
9929+ * and the texture one:
9930+ * GL_MAX_TEXTURE_COORDS_ARB.
9931+ * Ok GForce say it's ok to use glTexParameter/glGetTexParameter(...).
9932+ ******************/
9933+
9934+ /** FIXME: Somethis isn't working properly, textures states don't seem to be being applied,
9935+ * or there being cleared down oddly, or GLACTIVETEXTURE isn't working properly.
9936+ *****************/
9937+ union {
9938+ float f;
9939+ DWORD d;
9940+ } tmpvalue;
9941+ GLint maxSamplers;
9942
9943- /** FIXME: Windows uses a top,left origin openGL uses a bottom Right? **/
9944- TRACE("(%p)Setting new Scissor Rect to %ld:%ld-%ld:%ld\n", This, pRect->left, pRect->top, pRect->right, pRect->bottom);
9945- glScissor(pRect->left, pRect->top, pRect->right - pRect->left, pRect->bottom - pRect->top);
9946- LEAVE_GL();
9947- return D3D_OK;
9948-}
9949-
9950-HRESULT WINAPI IWineD3DDeviceImpl_GetScissorRect(IWineD3DDevice *iface, RECT* pRect){
9951- IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
9952- GLint scissorBox[4];
9953+ TRACE("(%p) Sampler(%ld), Type(%d) Value(%ld)\n",This, Sampler ,Type, Value);
9954
9955- ENTER_GL();
9956- /** FIXME: Windows uses a top,left origin openGL uses a bottom Right? **/
9957- glGetIntegerv(GL_SCISSOR_BOX, scissorBox);
9958- pRect->left = scissorBox[1];
9959- pRect->top = scissorBox[2];
9960- pRect->right = scissorBox[1] + scissorBox[3];
9961- pRect->bottom = scissorBox[2] + scissorBox[4];
9962- TRACE("(%p)Returning a Scissor Rect of %ld:%ld-%ld:%ld\n", This, pRect->left, pRect->top, pRect->right, pRect->bottom);
9963- LEAVE_GL();
9964- return D3D_OK;
9965-}
9966+#if 0
9967+ if supported GL_MAX_TEXTURE_IMAGE_UNITS_ARB
9968+ glenable(GL_ARB_fragment_program)
9969+#endif
9970+ glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS_ARB,&maxSamplers);
9971
9972-HRESULT WINAPI IWineD3DDeviceImpl_SetVertexDeclaration(IWineD3DDevice* iface, IWineD3DVertexDeclaration* pDecl) {
9973- IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *) iface;
9974-
9975- TRACE("(%p) : pDecl=%p\n", This, pDecl);
9976+ if (Sampler < maxSamplers && GL_SUPPORT(ARB_MULTITEXTURE)) {
9977+ maxSamplers = GL_LIMITS(textures);
9978+ } else{
9979+ maxSamplers = 1;
9980+ }
9981
9982- IWineD3DVertexDeclaration_AddRef(pDecl);
9983- if (NULL != This->updateStateBlock->vertexDecl) {
9984- IWineD3DVertexDeclaration_Release(This->updateStateBlock->vertexDecl);
9985+ if(Sampler > maxSamplers || Sampler < 0 || Type > HIGHEST_SAMPLER_STATE || Type < 0){
9986+ FIXME("out of range %d %d sampler %ld type %u\n", maxSamplers, HIGHEST_SAMPLER_STATE, Sampler, Type);
9987+ return D3D_OK;
9988 }
9989- This->updateStateBlock->vertexDecl = pDecl;
9990- This->updateStateBlock->changed.vertexDecl = TRUE;
9991- This->updateStateBlock->set.vertexDecl = TRUE;
9992- return D3D_OK;
9993-}
9994
9995-HRESULT WINAPI IWineD3DDeviceImpl_GetVertexDeclaration(IWineD3DDevice* iface, IWineD3DVertexDeclaration** ppDecl) {
9996- IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
9997+ This->updateStateBlock->changed.samplerState[Sampler][Type] = TRUE;
9998+ This->updateStateBlock->set.samplerState[Sampler][Type] = TRUE;
9999
10000- TRACE("(%p) : ppDecl=%p\n", This, ppDecl);
10001-
10002- *ppDecl = This->updateStateBlock->vertexDecl;
10003- if (NULL != *ppDecl) IWineD3DVertexDeclaration_AddRef(*ppDecl);
10004- return D3D_OK;
10005-}
10006+#if 0 /* We need to do something so that we only set stateblocks when they change
10007+ this may meed keeping 'another' stateblock that holds the 'real' state
10008+ (but shouldn't ->stateblock already do that?
10009+ */
10010
10011-HRESULT WINAPI IWineD3DDeviceImpl_SetVertexShader(IWineD3DDevice *iface, IWineD3DVertexShader* pShader){
10012- IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
10013+ if(This->updateStateBlock->samplerState[Sampler][Type] == Value &&( Type == WINED3DSAMP_MINFILTER || Type == D3DSAMP_MIPFILTER)){
10014
10015- static BOOL showFixmes = TRUE;
10016-
10017- This->updateStateBlock->vertexShader = pShader;
10018- This->updateStateBlock->changed.vertexShader = TRUE;
10019- This->updateStateBlock->set.vertexShader = TRUE;
10020-
10021- if(pShader == NULL){
10022- /* clear down the shader */
10023- TRACE("Clear down the shader\n");
10024- }else{
10025- if(showFixmes){
10026- FIXME("(%p) : stub pShader(%p)\n", This, pShader);
10027- showFixmes = FALSE;
10028- }
10029+ FIXME("(%p) no %d %d change of state %d \n",This, Sampler, Type, Value);
10030+ return D3D_OK;
10031 }
10032+#endif
10033+ TRACE("Setting sampler %ld %d to %ld \n", Sampler, Type, Value);
10034+ This->updateStateBlock->samplerState[Sampler][Type] = Value;
10035
10036- return D3D_OK;
10037-
10038- /** FIXME: refernece counting? **/
10039- if (pShader == NULL) { /* only valid with non FVF shaders */
10040- TRACE_(d3d_shader)("(%p) : FVF Shader, pShader=%p\n", This, pShader);
10041- This->updateStateBlock->vertexShader = NULL;
10042- } else {
10043- TRACE_(d3d_shader)("(%p) : Created shader, pShader=%p\n", This, pShader);
10044- This->updateStateBlock->vertexShader = pShader;
10045- }
10046-
10047- This->updateStateBlock->changed.vertexShader = TRUE;
10048- This->updateStateBlock->set.vertexShader = TRUE;
10049-
10050 /* Handle recording of state blocks */
10051 if (This->isRecordingState) {
10052- TRACE("Recording... not performing anything\n");
10053- return D3D_OK;
10054+ TRACE("Recording... not performing anything\n");
10055+ return D3D_OK;
10056 }
10057- /**
10058- * TODO: merge HAL shaders context switching from prototype
10059- */
10060- return D3D_OK;
10061-
10062+ /* In addition, IDirect3DDevice9::SetSamplerState will now be used for filtering, tiling,
10063+ clamping, MIPLOD, etc. This will work for up to 16 samplers.
10064+ is this just GL_TEXTURE_2D or is it GL_TEXTURE_1D and GL_TEXTURE_3D as well?
10065+ */
10066+ ENTER_GL();
10067+
10068+ VTRACE(("Activating appropriate texture state %ld\n", Sampler));
10069+ if (GL_SUPPORT(ARB_MULTITEXTURE)) {
10070+ GLACTIVETEXTURE(Sampler);
10071+ } else if (Sampler > 0) {
10072+ FIXME("Program using multiple concurrent textures which this opengl implementation doesn't support\n");
10073+ }
10074+
10075+ switch (Type) {
10076+
10077+ case WINED3DSAMP_ADDRESSU : /* 1 */
10078+ case WINED3DSAMP_ADDRESSV : /* 2 */
10079+ case WINED3DSAMP_ADDRESSW : /* 3 */
10080+ {
10081+ GLint wrapParm = GL_REPEAT;
10082+ switch (Value) {
10083+ case D3DTADDRESS_WRAP: wrapParm = GL_REPEAT; break;
10084+ case D3DTADDRESS_CLAMP: wrapParm = GL_CLAMP_TO_EDGE; break;
10085+ case D3DTADDRESS_BORDER:
10086+ {
10087+ if (GL_SUPPORT(ARB_TEXTURE_BORDER_CLAMP)) {
10088+ wrapParm = GL_CLAMP_TO_BORDER_ARB;
10089+ } else {
10090+ /* FIXME: Not right, but better */
10091+ TRACE("Unrecognized or unsupported D3DTADDRESS_* value %ld, state %d\n", Value, Type);
10092+ wrapParm = GL_REPEAT;
10093+ }
10094+ }
10095+ break;
10096+ case D3DTADDRESS_MIRROR:
10097+ {
10098+ if (GL_SUPPORT(ARB_TEXTURE_MIRRORED_REPEAT)) {
10099+ wrapParm = GL_MIRRORED_REPEAT_ARB;
10100+ } else {
10101+ /* Unsupported in OpenGL pre-1.4 */
10102+ TRACE("Unsupported D3DTADDRESS_MIRROR (needs GL_ARB_texture_mirrored_repeat) state %d\n", Type);
10103+ wrapParm = GL_REPEAT;
10104+ }
10105+ }
10106+ break;
10107+ case D3DTADDRESS_MIRRORONCE:
10108+ {
10109+ if (GL_SUPPORT(ATI_TEXTURE_MIRROR_ONCE)) {
10110+ wrapParm = GL_MIRROR_CLAMP_TO_EDGE_ATI;
10111+ } else {
10112+ TRACE("Unsupported D3DTADDRESS_MIRRORONCE (needs GL_ATI_texture_mirror_once) state %d\n", Type);
10113+ wrapParm = GL_REPEAT;
10114+ }
10115+ }
10116+ break;
10117+
10118+ default:
10119+ /* This is for the whole context, not just the sampler,
10120+ so we should warn if two states are baing set for any given scene */
10121+ if(Type!=0)
10122+ TRACE("Unrecognized or unsupported D3DTADDRESS_* value %ld, state %d\n", Value, Type);
10123+ wrapParm = GL_REPEAT;
10124+ }
10125+ switch (Type) {
10126+ case WINED3DSAMP_ADDRESSU:
10127+ TRACE("Setting WRAP_S for %ld to %d \n", Sampler, wrapParm);
10128+ glTexParameteri(This->stateBlock->textureDimensions[Sampler], GL_TEXTURE_WRAP_S, wrapParm);
10129+ checkGLcall("glTexParameteri(..., GL_TEXTURE_WRAP_S, wrapParm)");
10130+ break;
10131+ case WINED3DSAMP_ADDRESSV:
10132+ TRACE("Setting WRAP_T for %ld to %d\n", Sampler, wrapParm);
10133+ glTexParameteri(This->stateBlock->textureDimensions[Sampler], GL_TEXTURE_WRAP_T, wrapParm);
10134+ checkGLcall("glTexParameteri(..., GL_TEXTURE_WRAP_T, wrapParm)");
10135+ break;
10136+
10137+ case WINED3DSAMP_ADDRESSW:
10138+ TRACE("Setting WRAP_R for %ld to %d\n", Sampler, wrapParm);
10139+ glTexParameteri(This->stateBlock->textureDimensions[Sampler], GL_TEXTURE_WRAP_R, wrapParm);
10140+ checkGLcall("glTexParameteri(..., GL_TEXTURE_WRAP_R, wrapParm)");
10141+ break;
10142+ default: /* nop */
10143+ break; /** stupic compilator */
10144+ }
10145+ }
10146+ break;
10147+
10148+ case WINED3DSAMP_BORDERCOLOR : /* 4 */
10149+ {
10150+ float col[4];
10151+ D3DCOLORTOGLFLOAT4(Value, col);
10152+ TRACE("Setting border color for %ld to %lx\n", Sampler, Value);
10153+ glTexParameterfv(This->stateBlock->textureDimensions[Sampler], GL_TEXTURE_BORDER_COLOR, &col[0]);
10154+ checkGLcall("glTexParameteri(..., GL_TEXTURE_BORDER_COLOR, ...)");
10155+ }
10156+ break;
10157+
10158+ case WINED3DSAMP_MAGFILTER : /* 5 */
10159+ {
10160+ DWORD ValueMAG = This->stateBlock->samplerState[Sampler][WINED3DSAMP_MAGFILTER];
10161+ GLint realVal = GL_NEAREST;
10162+
10163+ if (ValueMAG == D3DTEXF_POINT) {
10164+ realVal = GL_NEAREST;
10165+ } else if (ValueMAG == D3DTEXF_LINEAR) {
10166+ realVal = GL_LINEAR;
10167+ } else if (ValueMAG == D3DTEXF_ANISOTROPIC) {
10168+ if (GL_SUPPORT(EXT_TEXTURE_FILTER_ANISOTROPIC)) {
10169+ realVal = GL_LINEAR;
10170+ } else {
10171+ FIXME("Trying to use ANISOTROPIC_FILTERING for D3DTSS_MAGFILTER. But not supported by current OpenGL driver\n");
10172+ realVal = GL_NEAREST;
10173+ }
10174+ } else {
10175+ FIXME("Unhandled D3DTSS_MAGFILTER value of %ld\n", ValueMAG);
10176+ realVal = GL_NEAREST;
10177+ }
10178+ TRACE("ValueMAG=%ld setting MAGFILTER to %x\n", ValueMAG, realVal);
10179+ glTexParameteri(This->stateBlock->textureDimensions[Sampler], GL_TEXTURE_MAG_FILTER, realVal);
10180+ checkGLcall("glTexParameter GL_TEXTURE_MAG_FILTER, ...");
10181+ /**
10182+ * if we juste choose to use ANISOTROPIC filtering, refresh openGL state
10183+ */
10184+ if (GL_SUPPORT(EXT_TEXTURE_FILTER_ANISOTROPIC) && D3DTEXF_ANISOTROPIC == ValueMAG) {
10185+ glTexParameteri(This->stateBlock->textureDimensions[Sampler],
10186+ GL_TEXTURE_MAX_ANISOTROPY_EXT,
10187+ This->stateBlock->samplerState[Sampler][WINED3DSAMP_MAXANISOTROPY]);
10188+ checkGLcall("glTexParameter GL_TEXTURE_MAX_ANISOTROPY_EXT, ...");
10189+ }
10190+ }
10191+ break;
10192+
10193+ case WINED3DSAMP_MINFILTER: /* 6 */
10194+ case WINED3DSAMP_MIPFILTER: /* 7 */
10195+ {
10196+ DWORD ValueMIN = This->stateBlock->samplerState[Sampler][WINED3DSAMP_MINFILTER];
10197+ DWORD ValueMIP = This->stateBlock->samplerState[Sampler][WINED3DSAMP_MIPFILTER];
10198+ GLint realVal = GL_LINEAR;
10199+
10200+ if (ValueMIN == D3DTEXF_NONE) {
10201+ /* Doesn't really make sense - Windows just seems to disable
10202+ mipmapping when this occurs */
10203+ FIXME("Odd - minfilter of none, just disabling mipmaps\n");
10204+ realVal = GL_LINEAR;
10205+ } else if (ValueMIN == D3DTEXF_POINT) {
10206+ /* GL_NEAREST_* */
10207+ if (ValueMIP == D3DTEXF_NONE) {
10208+ realVal = GL_NEAREST;
10209+ } else if (ValueMIP == D3DTEXF_POINT) {
10210+ realVal = GL_NEAREST_MIPMAP_NEAREST;
10211+ } else if (ValueMIP == D3DTEXF_LINEAR) {
10212+ realVal = GL_NEAREST_MIPMAP_LINEAR;
10213+ } else {
10214+ FIXME("Unhandled D3DTSS_MIPFILTER value of %ld\n", ValueMIP);
10215+ realVal = GL_NEAREST;
10216+ }
10217+ } else if (ValueMIN == D3DTEXF_LINEAR) {
10218+ /* GL_LINEAR_* */
10219+ if (ValueMIP == D3DTEXF_NONE) {
10220+ realVal = GL_LINEAR;
10221+ } else if (ValueMIP == D3DTEXF_POINT) {
10222+ realVal = GL_LINEAR_MIPMAP_NEAREST;
10223+ } else if (ValueMIP == D3DTEXF_LINEAR) {
10224+ realVal = GL_LINEAR_MIPMAP_LINEAR;
10225+ } else {
10226+ FIXME("Unhandled D3DTSS_MIPFILTER value of %ld\n", ValueMIP);
10227+ realVal = GL_LINEAR;
10228+ }
10229+ } else if (ValueMIN == D3DTEXF_ANISOTROPIC) {
10230+ if (GL_SUPPORT(EXT_TEXTURE_FILTER_ANISOTROPIC)) {
10231+ if (ValueMIP == D3DTEXF_NONE) {
10232+ realVal = GL_LINEAR_MIPMAP_LINEAR;
10233+ } else if (ValueMIP == D3DTEXF_POINT) {
10234+ realVal = GL_LINEAR_MIPMAP_NEAREST;
10235+ } else if (ValueMIP == D3DTEXF_LINEAR) {
10236+ realVal = GL_LINEAR_MIPMAP_LINEAR;
10237+ } else {
10238+ FIXME("Unhandled D3DTSS_MIPFILTER value of %ld\n", ValueMIP);
10239+ realVal = GL_LINEAR;
10240+ }
10241+ } else {
10242+ WARN("Trying to use ANISOTROPIC_FILTERING for D3DTSS_MINFILTER. But not supported by OpenGL driver\n");
10243+ realVal = GL_LINEAR;
10244+ }
10245+ } else {
10246+ FIXME("Unhandled D3DTSS_MINFILTER value of %ld\n", ValueMIN);
10247+ realVal = GL_LINEAR_MIPMAP_LINEAR;
10248+ }
10249+
10250+ TRACE("ValueMIN=%ld, ValueMIP=%ld, setting MINFILTER to %x\n", ValueMIN, ValueMIP, realVal);
10251+ glTexParameteri(This->stateBlock->textureDimensions[Sampler], GL_TEXTURE_MIN_FILTER, realVal);
10252+ checkGLcall("glTexParameter GL_TEXTURE_MIN_FILTER, ...");
10253+ /**
10254+ * if we just choose to use ANISOTROPIC filtering, refresh openGL state
10255+ */
10256+ if (GL_SUPPORT(EXT_TEXTURE_FILTER_ANISOTROPIC) && D3DTEXF_ANISOTROPIC == ValueMIN) {
10257+ glTexParameteri(This->stateBlock->textureDimensions[Sampler], GL_TEXTURE_MAX_ANISOTROPY_EXT,
10258+ This->stateBlock->samplerState[Sampler][WINED3DSAMP_MAXANISOTROPY]);
10259+ checkGLcall("glTexParameter GL_TEXTURE_MAX_ANISOTROPY_EXT, ...");
10260+ }
10261+ }
10262+ break;
10263+
10264+ case WINED3DSAMP_MIPMAPLODBIAS : /* 8 */
10265+ {
10266+ if (GL_SUPPORT(EXT_TEXTURE_LOD_BIAS)) {
10267+ tmpvalue.d = Value;
10268+ glTexEnvf(GL_TEXTURE_FILTER_CONTROL_EXT,
10269+ GL_TEXTURE_LOD_BIAS_EXT,
10270+ tmpvalue.f);
10271+ checkGLcall("glTexEnvi GL_TEXTURE_LOD_BIAS_EXT ...");
10272+ }
10273+ }
10274+ break;
10275+
10276+ case WINED3DSAMP_MAXMIPLEVEL : /* 9 */
10277+ {
10278+ /**
10279+ * Not really the same, but the more apprioprate than nothing
10280+ */
10281+ glTexParameteri(This->stateBlock->textureDimensions[Sampler],
10282+ GL_TEXTURE_BASE_LEVEL,
10283+ This->stateBlock->samplerState[Sampler][WINED3DSAMP_MAXMIPLEVEL]);
10284+ checkGLcall("glTexParameteri GL_TEXTURE_BASE_LEVEL ...");
10285+ }
10286+ break;
10287+
10288+ case WINED3DSAMP_MAXANISOTROPY : /* 10 */
10289+ {
10290+ if (GL_SUPPORT(EXT_TEXTURE_FILTER_ANISOTROPIC)) {
10291+ glTexParameteri(This->stateBlock->textureDimensions[Sampler],
10292+ GL_TEXTURE_MAX_ANISOTROPY_EXT,
10293+ This->stateBlock->samplerState[Sampler][WINED3DSAMP_MAXANISOTROPY]);
10294+ checkGLcall("glTexParameteri GL_TEXTURE_MAX_ANISOTROPY_EXT ...");
10295+ }
10296+ }
10297+ break;
10298+ case WINED3DSAMP_SRGBTEXTURE : /* 11 */
10299+ /* Per texture gamma correction, default 0 */
10300+ case WINED3DSAMP_ELEMENTINDEX : /* 12 */
10301+ /* When a multi-element textures is used this indicates the element, (what's a multielement texture?) */
10302+ case WINED3DSAMP_DMAPOFFSET : /* 13 */
10303+ /* Value of a precompiled displacement map used by the tesselator, default 0 */
10304+ default:
10305+
10306+ TRACE("invalid sampler setting, Sampler=%ld, Type=%d, Value =%ld\n", Sampler, Type, Value);
10307+ };
10308+ LEAVE_GL();
10309+ return D3D_OK;
10310+
10311+}
10312+
10313+HRESULT WINAPI IWineD3DDeviceImpl_GetSamplerState(IWineD3DDevice *iface, DWORD Sampler, WINED3DSAMPLERSTATETYPE Type, DWORD* Value){
10314+ IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
10315+ /** TODO: check that sampler is in range **/
10316+ *Value = This->updateStateBlock->samplerState[Sampler][Type];
10317+ return D3D_OK;
10318+
10319+}
10320+
10321+HRESULT WINAPI IWineD3DDeviceImpl_SetScissorRect(IWineD3DDevice *iface, CONST RECT* pRect){
10322+ IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
10323+ ENTER_GL();
10324+
10325+ /** FIXME: Windows uses a top,left origin openGL uses a bottom Right? **/
10326+ TRACE("(%p)Setting new Scissor Rect to %ld:%ld-%ld:%ld\n", This, pRect->left, pRect->top, pRect->right, pRect->bottom);
10327+ glScissor( pRect->left, pRect->top, pRect->right - pRect->left, pRect->bottom - pRect->top);
10328+ LEAVE_GL();
10329+ return D3D_OK;
10330+}
10331+
10332+HRESULT WINAPI IWineD3DDeviceImpl_GetScissorRect(IWineD3DDevice *iface, RECT* pRect){
10333+ IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
10334+ GLint scissorBox[4];
10335+ ENTER_GL();
10336+
10337+ /** FIXME: Windows uses a top,left origin openGL uses a bottom Right? **/
10338+ glGetIntegerv(GL_SCISSOR_BOX, scissorBox);
10339+ pRect->left = scissorBox[1];
10340+ pRect->top = scissorBox[2];
10341+ pRect->right = scissorBox[1] + scissorBox[3];
10342+ pRect->bottom = scissorBox[2] + scissorBox[4];
10343+ TRACE("(%p)Returning a Scissor Rect of %ld:%ld-%ld:%ld\n", This, pRect->left, pRect->top, pRect->right, pRect->bottom);
10344+ LEAVE_GL();
10345+ return D3D_OK;
10346+}
10347+
10348+HRESULT WINAPI IWineD3DDeviceImpl_SetVertexDeclaration(IWineD3DDevice* iface, IWineD3DVertexDeclaration* pDecl) {
10349+ IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *) iface;
10350+
10351+ TRACE("(%p) : pDecl=%p\n", This, pDecl);
10352+ This->updateStateBlock->vertexDecl = pDecl;
10353+ This->updateStateBlock->changed.vertexDecl = TRUE;
10354+ This->updateStateBlock->set.vertexDecl = TRUE;
10355+ return D3D_OK;
10356+}
10357+
10358+HRESULT WINAPI IWineD3DDeviceImpl_GetVertexDeclaration(IWineD3DDevice* iface, IWineD3DVertexDeclaration** ppDecl) {
10359+ IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
10360+
10361+ TRACE("(%p) : ppDecl=%p\n", This, ppDecl);
10362+
10363+ *ppDecl = This->updateStateBlock->vertexDecl;
10364+ if (NULL != *ppDecl) IWineD3DVertexDeclaration_AddRef(*ppDecl);
10365+ TRACE("(%p) : returning %p\n", This, *ppDecl);
10366+ return D3D_OK;
10367+}
10368+
10369+HRESULT WINAPI IWineD3DDeviceImpl_SetVertexShader(IWineD3DDevice *iface, IWineD3DVertexShader* pShader){
10370+ IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
10371+
10372+ static BOOL showFixmes = TRUE;
10373+
10374+ This->updateStateBlock->vertexShader = pShader;
10375+ This->updateStateBlock->changed.vertexShader = TRUE;
10376+ This->updateStateBlock->set.vertexShader = TRUE;
10377+
10378+ if(pShader == NULL){
10379+ /* clear down the shader */
10380+ TRACE("Clear down the shader\n");
10381+ }else{
10382+ if(showFixmes){
10383+ FIXME("(%p) : stub pShader(%p)\n", This, pShader);
10384+ showFixmes = FALSE;
10385+ }
10386+ }
10387+
10388+ return D3D_OK;
10389+
10390+ /** FIXME: refernece counting? **/
10391+ if (pShader == NULL) { /* only valid with non FVF shaders */
10392+ TRACE_(d3d_shader)("(%p) : FVF Shader, pShader=%p\n", This, pShader);
10393+ This->updateStateBlock->vertexShader = NULL;
10394+ } else {
10395+ TRACE_(d3d_shader)("(%p) : Created shader, pShader=%p\n", This, pShader);
10396+ This->updateStateBlock->vertexShader = pShader;
10397+ }
10398+
10399+ This->updateStateBlock->changed.vertexShader = TRUE;
10400+ This->updateStateBlock->set.vertexShader = TRUE;
10401+
10402+ /* Handle recording of state blocks */
10403+ if (This->isRecordingState) {
10404+ TRACE("Recording... not performing anything\n");
10405+ return D3D_OK;
10406+ }
10407+ /**
10408+ * TODO: merge HAL shaders context switching from prototype
10409+ */
10410+ return D3D_OK;
10411+
10412 }
10413
10414 HRESULT WINAPI IWineD3DDeviceImpl_GetVertexShader(IWineD3DDevice *iface, IWineD3DVertexShader** ppShader){
10415 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
10416 *ppShader = This->stateBlock->vertexShader;
10417- if(*ppShader != NULL)
10418- IWineD3DVertexShader_AddRef(*ppShader);
10419+ IWineD3DVertexShader_AddRef(*ppShader);
10420 TRACE("(%p) : returning %p\n", This, *ppShader);
10421 return D3D_OK;
10422 }
10423-
10424 HRESULT WINAPI IWineD3DDeviceImpl_SetVertexShaderConstantB(IWineD3DDevice *iface, UINT StartRegister, CONST BOOL *pConstantData, UINT BoolCount){
10425 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
10426-
10427 TRACE("(%p) : stub\n", This);
10428 return D3D_OK;
10429 }
10430@@ -2852,7 +3995,7 @@
10431 return D3D_OK;
10432 }
10433
10434-HRESULT WINAPI IWineD3DDeviceImpl_GetVertexShaderConstantF(IWineD3DDevice *iface, UINT StartRegister, float *pConstantData, UINT Vector4fCount){
10435+HRESULT WINAPI IWineD3DDeviceImpl_GetVertexShaderConstantF(IWineD3DDevice *iface, UINT StartRegister, float *pConstantData, UINT Vector4fCount){
10436 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
10437 TRACE("(%p) : stub\n", This);
10438 return D3D_OK;
10439@@ -2919,21 +4062,17 @@
10440 *****/
10441 HRESULT WINAPI IWineD3DDeviceImpl_SetTextureStageState(IWineD3DDevice *iface, DWORD Stage, D3DTEXTURESTAGESTATETYPE Type, DWORD Value) {
10442 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
10443- union {
10444- float f;
10445- DWORD d;
10446- } tmpvalue;
10447
10448 /* FIXME: Handle 3d textures? What if TSS value set before set texture? Need to reapply all values? */
10449-
10450+
10451 TRACE("(%p) : Stage=%ld, Type=%s(%d), Value=%ld\n", This, Stage, debug_d3dtexturestate(Type), Type, Value);
10452
10453 /* Reject invalid texture units */
10454 if (Stage >= GL_LIMITS(textures)) {
10455 TRACE("Attempt to access invalid texture rejected\n");
10456 return D3DERR_INVALIDCALL;
10457- }
10458-
10459+ }
10460+ /* FIXME: Only change if the value is different!*/
10461 This->updateStateBlock->changed.textureState[Stage][Type] = TRUE;
10462 This->updateStateBlock->set.textureState[Stage][Type] = TRUE;
10463 This->updateStateBlock->textureState[Stage][Type] = Value;
10464@@ -2942,162 +4081,19 @@
10465 if (This->isRecordingState) {
10466 TRACE("Recording... not performing anything\n");
10467 return D3D_OK;
10468- }
10469+ }
10470
10471 ENTER_GL();
10472
10473 /* Make appropriate texture active */
10474 VTRACE(("Activating appropriate texture state %ld\n", Stage));
10475 if (GL_SUPPORT(ARB_MULTITEXTURE)) {
10476- GLACTIVETEXTURE(Stage);
10477- } else if (Stage > 0) {
10478- FIXME("Program using multiple concurrent textures which this opengl implementation doesn't support\n");
10479- }
10480-
10481- switch (Type) {
10482-
10483- case D3DTSS_MINFILTER :
10484- case D3DTSS_MIPFILTER :
10485- {
10486- DWORD ValueMIN = This->stateBlock->textureState[Stage][D3DTSS_MINFILTER];
10487- DWORD ValueMIP = This->stateBlock->textureState[Stage][D3DTSS_MIPFILTER];
10488- GLint realVal = GL_LINEAR;
10489-
10490- if (ValueMIN == D3DTEXF_NONE) {
10491- /* Doesn't really make sense - Windows just seems to disable
10492- mipmapping when this occurs */
10493- FIXME("Odd - minfilter of none, just disabling mipmaps\n");
10494- realVal = GL_LINEAR;
10495- } else if (ValueMIN == D3DTEXF_POINT) {
10496- /* GL_NEAREST_* */
10497- if (ValueMIP == D3DTEXF_NONE) {
10498- realVal = GL_NEAREST;
10499- } else if (ValueMIP == D3DTEXF_POINT) {
10500- realVal = GL_NEAREST_MIPMAP_NEAREST;
10501- } else if (ValueMIP == D3DTEXF_LINEAR) {
10502- realVal = GL_NEAREST_MIPMAP_LINEAR;
10503- } else {
10504- FIXME("Unhandled D3DTSS_MIPFILTER value of %ld\n", ValueMIP);
10505- realVal = GL_NEAREST;
10506- }
10507- } else if (ValueMIN == D3DTEXF_LINEAR) {
10508- /* GL_LINEAR_* */
10509- if (ValueMIP == D3DTEXF_NONE) {
10510- realVal = GL_LINEAR;
10511- } else if (ValueMIP == D3DTEXF_POINT) {
10512- realVal = GL_LINEAR_MIPMAP_NEAREST;
10513- } else if (ValueMIP == D3DTEXF_LINEAR) {
10514- realVal = GL_LINEAR_MIPMAP_LINEAR;
10515- } else {
10516- FIXME("Unhandled D3DTSS_MIPFILTER value of %ld\n", ValueMIP);
10517- realVal = GL_LINEAR;
10518- }
10519- } else if (ValueMIN == D3DTEXF_ANISOTROPIC) {
10520- if (GL_SUPPORT(EXT_TEXTURE_FILTER_ANISOTROPIC)) {
10521- if (ValueMIP == D3DTEXF_NONE) {
10522- realVal = GL_LINEAR_MIPMAP_LINEAR;
10523- } else if (ValueMIP == D3DTEXF_POINT) {
10524- realVal = GL_LINEAR_MIPMAP_NEAREST;
10525- } else if (ValueMIP == D3DTEXF_LINEAR) {
10526- realVal = GL_LINEAR_MIPMAP_LINEAR;
10527- } else {
10528- FIXME("Unhandled D3DTSS_MIPFILTER value of %ld\n", ValueMIP);
10529- realVal = GL_LINEAR;
10530- }
10531- } else {
10532- WARN("Trying to use ANISOTROPIC_FILTERING for D3DTSS_MINFILTER. But not supported by OpenGL driver\n");
10533- realVal = GL_LINEAR;
10534- }
10535- } else {
10536- FIXME("Unhandled D3DTSS_MINFILTER value of %ld\n", ValueMIN);
10537- realVal = GL_LINEAR_MIPMAP_LINEAR;
10538- }
10539-
10540- TRACE("ValueMIN=%ld, ValueMIP=%ld, setting MINFILTER to %x\n", ValueMIN, ValueMIP, realVal);
10541- glTexParameteri(This->stateBlock->textureDimensions[Stage], GL_TEXTURE_MIN_FILTER, realVal);
10542- checkGLcall("glTexParameter GL_TEXTURE_MIN_FILTER, ...");
10543- /**
10544- * if we juste choose to use ANISOTROPIC filtering, refresh openGL state
10545- */
10546- if (GL_SUPPORT(EXT_TEXTURE_FILTER_ANISOTROPIC) && D3DTEXF_ANISOTROPIC == ValueMIN) {
10547- glTexParameteri(This->stateBlock->textureDimensions[Stage],
10548- GL_TEXTURE_MAX_ANISOTROPY_EXT,
10549- This->stateBlock->textureState[Stage][D3DTSS_MAXANISOTROPY]);
10550- checkGLcall("glTexParameter GL_TEXTURE_MAX_ANISOTROPY_EXT, ...");
10551- }
10552- }
10553- break;
10554-
10555- case D3DTSS_MAGFILTER :
10556- {
10557- DWORD ValueMAG = This->stateBlock->textureState[Stage][D3DTSS_MAGFILTER];
10558- GLint realVal = GL_NEAREST;
10559-
10560- if (ValueMAG == D3DTEXF_POINT) {
10561- realVal = GL_NEAREST;
10562- } else if (ValueMAG == D3DTEXF_LINEAR) {
10563- realVal = GL_LINEAR;
10564- } else if (ValueMAG == D3DTEXF_ANISOTROPIC) {
10565- if (GL_SUPPORT(EXT_TEXTURE_FILTER_ANISOTROPIC)) {
10566- realVal = GL_LINEAR;
10567- } else {
10568- FIXME("Trying to use ANISOTROPIC_FILTERING for D3DTSS_MAGFILTER. But not supported by current OpenGL driver\n");
10569- realVal = GL_NEAREST;
10570- }
10571- } else {
10572- FIXME("Unhandled D3DTSS_MAGFILTER value of %ld\n", ValueMAG);
10573- realVal = GL_NEAREST;
10574- }
10575- TRACE("ValueMAG=%ld setting MAGFILTER to %x\n", ValueMAG, realVal);
10576- glTexParameteri(This->stateBlock->textureDimensions[Stage], GL_TEXTURE_MAG_FILTER, realVal);
10577- checkGLcall("glTexParameter GL_TEXTURE_MAG_FILTER, ...");
10578- /**
10579- * if we juste choose to use ANISOTROPIC filtering, refresh openGL state
10580- */
10581- if (GL_SUPPORT(EXT_TEXTURE_FILTER_ANISOTROPIC) && D3DTEXF_ANISOTROPIC == ValueMAG) {
10582- glTexParameteri(This->stateBlock->textureDimensions[Stage],
10583- GL_TEXTURE_MAX_ANISOTROPY_EXT,
10584- This->stateBlock->textureState[Stage][D3DTSS_MAXANISOTROPY]);
10585- checkGLcall("glTexParameter GL_TEXTURE_MAX_ANISOTROPY_EXT, ...");
10586- }
10587- }
10588- break;
10589-
10590- case D3DTSS_MAXMIPLEVEL :
10591- {
10592- /**
10593- * Not really the same, but the more apprioprate than nothing
10594- */
10595- glTexParameteri(This->stateBlock->textureDimensions[Stage],
10596- GL_TEXTURE_BASE_LEVEL,
10597- This->stateBlock->textureState[Stage][D3DTSS_MAXMIPLEVEL]);
10598- checkGLcall("glTexParameteri GL_TEXTURE_BASE_LEVEL ...");
10599- }
10600- break;
10601-
10602- case D3DTSS_MAXANISOTROPY :
10603- {
10604- if (GL_SUPPORT(EXT_TEXTURE_FILTER_ANISOTROPIC)) {
10605- glTexParameteri(This->stateBlock->textureDimensions[Stage],
10606- GL_TEXTURE_MAX_ANISOTROPY_EXT,
10607- This->stateBlock->textureState[Stage][D3DTSS_MAXANISOTROPY]);
10608- checkGLcall("glTexParameteri GL_TEXTURE_MAX_ANISOTROPY_EXT ...");
10609- }
10610- }
10611- break;
10612-
10613- case D3DTSS_MIPMAPLODBIAS :
10614- {
10615- if (GL_SUPPORT(EXT_TEXTURE_LOD_BIAS)) {
10616- tmpvalue.d = Value;
10617- glTexEnvf(GL_TEXTURE_FILTER_CONTROL_EXT,
10618- GL_TEXTURE_LOD_BIAS_EXT,
10619- tmpvalue.f);
10620- checkGLcall("glTexEnvi GL_TEXTURE_LOD_BIAS_EXT ...");
10621- }
10622+ GLACTIVETEXTURE(Stage);
10623+ } else if (Stage > 0) {
10624+ FIXME("Program using multiple concurrent textures which this opengl implementation doesn't support\n");
10625 }
10626- break;
10627
10628+ switch (Type) {
10629 case D3DTSS_ALPHAOP :
10630 case D3DTSS_COLOROP :
10631 {
10632@@ -3120,7 +4116,7 @@
10633 } else {
10634 glDisable(GL_TEXTURE_1D);
10635 checkGLcall("Disable GL_TEXTURE_1D");
10636- }
10637+ }
10638 if (This->stateBlock->textureDimensions[Stage] == GL_TEXTURE_2D) {
10639 if (GL_SUPPORT(NV_TEXTURE_SHADER) && This->texture_shader_active) {
10640 glTexEnvi(GL_TEXTURE_SHADER_NV, GL_SHADER_OPERATION_NV, GL_TEXTURE_2D);
10641@@ -3157,44 +4153,41 @@
10642 case D3DTSS_ALPHAARG1 :
10643 case D3DTSS_ALPHAARG2 :
10644 {
10645- BOOL isAlphaArg = (Type == D3DTSS_ALPHAOP || Type == D3DTSS_ALPHAARG1 ||
10646+ BOOL isAlphaArg = (Type == D3DTSS_ALPHAOP || Type == D3DTSS_ALPHAARG1 ||
10647 Type == D3DTSS_ALPHAARG2 || Type == D3DTSS_ALPHAARG0);
10648 if (isAlphaArg) {
10649 set_tex_op(iface, TRUE, Stage, This->stateBlock->textureState[Stage][D3DTSS_ALPHAOP],
10650- This->stateBlock->textureState[Stage][D3DTSS_ALPHAARG1],
10651- This->stateBlock->textureState[Stage][D3DTSS_ALPHAARG2],
10652+ This->stateBlock->textureState[Stage][D3DTSS_ALPHAARG1],
10653+ This->stateBlock->textureState[Stage][D3DTSS_ALPHAARG2],
10654 This->stateBlock->textureState[Stage][D3DTSS_ALPHAARG0]);
10655 } else {
10656 set_tex_op(iface, FALSE, Stage, This->stateBlock->textureState[Stage][D3DTSS_COLOROP],
10657- This->stateBlock->textureState[Stage][D3DTSS_COLORARG1],
10658- This->stateBlock->textureState[Stage][D3DTSS_COLORARG2],
10659+ This->stateBlock->textureState[Stage][D3DTSS_COLORARG1],
10660+ This->stateBlock->textureState[Stage][D3DTSS_COLORARG2],
10661 This->stateBlock->textureState[Stage][D3DTSS_COLORARG0]);
10662 }
10663 }
10664 break;
10665 }
10666-
10667- case D3DTSS_ADDRESSU :
10668- case D3DTSS_ADDRESSV :
10669 case D3DTSS_ADDRESSW :
10670 {
10671 GLint wrapParm = GL_REPEAT;
10672
10673 switch (Value) {
10674 case D3DTADDRESS_WRAP: wrapParm = GL_REPEAT; break;
10675- case D3DTADDRESS_CLAMP: wrapParm = GL_CLAMP_TO_EDGE; break;
10676- case D3DTADDRESS_BORDER:
10677+ case D3DTADDRESS_CLAMP: wrapParm = GL_CLAMP_TO_EDGE; break;
10678+ case D3DTADDRESS_BORDER:
10679 {
10680 if (GL_SUPPORT(ARB_TEXTURE_BORDER_CLAMP)) {
10681- wrapParm = GL_CLAMP_TO_BORDER_ARB;
10682+ wrapParm = GL_CLAMP_TO_BORDER_ARB;
10683 } else {
10684 /* FIXME: Not right, but better */
10685 FIXME("Unrecognized or unsupported D3DTADDRESS_* value %ld, state %d\n", Value, Type);
10686- wrapParm = GL_REPEAT;
10687+ wrapParm = GL_REPEAT;
10688 }
10689 }
10690 break;
10691- case D3DTADDRESS_MIRROR:
10692+ case D3DTADDRESS_MIRROR:
10693 {
10694 if (GL_SUPPORT(ARB_TEXTURE_MIRRORED_REPEAT)) {
10695 wrapParm = GL_MIRRORED_REPEAT_ARB;
10696@@ -3205,33 +4198,23 @@
10697 }
10698 }
10699 break;
10700- case D3DTADDRESS_MIRRORONCE:
10701+ case D3DTADDRESS_MIRRORONCE:
10702 {
10703 if (GL_SUPPORT(ATI_TEXTURE_MIRROR_ONCE)) {
10704 wrapParm = GL_MIRROR_CLAMP_TO_EDGE_ATI;
10705 } else {
10706 FIXME("Unsupported D3DTADDRESS_MIRRORONCE (needs GL_ATI_texture_mirror_once) state %d\n", Type);
10707- wrapParm = GL_REPEAT;
10708+ wrapParm = GL_REPEAT;
10709 }
10710 }
10711 break;
10712
10713 default:
10714- FIXME("Unrecognized or unsupported D3DTADDRESS_* value %ld, state %d\n", Value, Type);
10715- wrapParm = GL_REPEAT;
10716+ if(Value != 0 /* default GL_REPEAT */)
10717+ FIXME("Unrecognized or unsupported D3DTADDRESS_* value %ld, state %d\n", Value, Type);
10718+ wrapParm = GL_REPEAT;
10719 }
10720-
10721 switch (Type) {
10722- case D3DTSS_ADDRESSU:
10723- TRACE("Setting WRAP_S to %d for %x\n", wrapParm, This->stateBlock->textureDimensions[Stage]);
10724- glTexParameteri(This->stateBlock->textureDimensions[Stage], GL_TEXTURE_WRAP_S, wrapParm);
10725- checkGLcall("glTexParameteri(..., GL_TEXTURE_WRAP_S, wrapParm)");
10726- break;
10727- case D3DTSS_ADDRESSV:
10728- TRACE("Setting WRAP_T to %d for %x\n", wrapParm, This->stateBlock->textureDimensions[Stage]);
10729- glTexParameteri(This->stateBlock->textureDimensions[Stage], GL_TEXTURE_WRAP_T, wrapParm);
10730- checkGLcall("glTexParameteri(..., GL_TEXTURE_WRAP_T, wrapParm)");
10731- break;
10732 case D3DTSS_ADDRESSW:
10733 TRACE("Setting WRAP_R to %d for %x\n", wrapParm, This->stateBlock->textureDimensions[Stage]);
10734 glTexParameteri(This->stateBlock->textureDimensions[Stage], GL_TEXTURE_WRAP_R, wrapParm);
10735@@ -3242,150 +4225,139 @@
10736 }
10737 }
10738 break;
10739-
10740- case D3DTSS_BORDERCOLOR :
10741- {
10742- float col[4];
10743- D3DCOLORTOGLFLOAT4(Value, col);
10744- TRACE("Setting border color for %x to %lx\n", This->stateBlock->textureDimensions[Stage], Value);
10745- glTexParameterfv(This->stateBlock->textureDimensions[Stage], GL_TEXTURE_BORDER_COLOR, &col[0]);
10746- checkGLcall("glTexParameteri(..., GL_TEXTURE_BORDER_COLOR, ...)");
10747- }
10748- break;
10749-
10750 case D3DTSS_TEXCOORDINDEX :
10751 {
10752 /* Values 0-7 are indexes into the FVF tex coords - See comments in DrawPrimitive */
10753
10754- /* FIXME: From MSDN: The D3DTSS_TCI_* flags are mutually exclusive. If you include
10755- one flag, you can still specify an index value, which the system uses to
10756- determine the texture wrapping mode.
10757+ /** FIXME: From MSDN: The D3DTSS_TCI_* flags are mutually exclusive. If you include
10758+ one flag, you can still specify an index value, which the system uses to
10759+ determine the texture wrapping mode.
10760 eg. SetTextureStageState( 0, D3DTSS_TEXCOORDINDEX, D3DTSS_TCI_CAMERASPACEPOSITION | 1 );
10761- means use the vertex position (camera-space) as the input texture coordinates
10762+ means use the vertex position (camera-space) as the input texture coordinates
10763 for this texture stage, and the wrap mode set in the WINED3DRS_WRAP1 render
10764 state. We do not (yet) support the D3DRENDERSTATE_WRAPx values, nor tie them up
10765- to the TEXCOORDINDEX value */
10766-
10767- /**
10768- * Be careful the value of the mask 0xF0000 come from d3d8types.h infos
10769+ to the TEXCOORDINDEX value **/
10770+
10771+ /**
10772+ * Be careful the value of the mask 0xF0000 come from d3d8types.h infos
10773 */
10774 switch (Value & 0xFFFF0000) {
10775 case D3DTSS_TCI_PASSTHRU:
10776- /*Use the specified texture coordinates contained within the vertex format. This value resolves to zero.*/
10777- glDisable(GL_TEXTURE_GEN_S);
10778- glDisable(GL_TEXTURE_GEN_T);
10779- glDisable(GL_TEXTURE_GEN_R);
10780- checkGLcall("glDisable(GL_TEXTURE_GEN_S,T,R)");
10781- break;
10782+ /* Use the specified texture coordinates contained within the vertex format. This value resolves to zero.*/
10783+ glDisable(GL_TEXTURE_GEN_S);
10784+ glDisable(GL_TEXTURE_GEN_T);
10785+ glDisable(GL_TEXTURE_GEN_R);
10786+ checkGLcall("glDisable(GL_TEXTURE_GEN_S,T,R)");
10787+ break;
10788
10789 case D3DTSS_TCI_CAMERASPACEPOSITION:
10790- /* CameraSpacePosition means use the vertex position, transformed to camera space,
10791- as the input texture coordinates for this stage's texture transformation. This
10792- equates roughly to EYE_LINEAR */
10793- {
10794- float s_plane[] = { 1.0, 0.0, 0.0, 0.0 };
10795- float t_plane[] = { 0.0, 1.0, 0.0, 0.0 };
10796- float r_plane[] = { 0.0, 0.0, 1.0, 0.0 };
10797- float q_plane[] = { 0.0, 0.0, 0.0, 1.0 };
10798- TRACE("D3DTSS_TCI_CAMERASPACEPOSITION - Set eye plane\n");
10799-
10800- glMatrixMode(GL_MODELVIEW);
10801- glPushMatrix();
10802- glLoadIdentity();
10803- glTexGenfv(GL_S, GL_EYE_PLANE, s_plane);
10804- glTexGenfv(GL_T, GL_EYE_PLANE, t_plane);
10805- glTexGenfv(GL_R, GL_EYE_PLANE, r_plane);
10806- glTexGenfv(GL_Q, GL_EYE_PLANE, q_plane);
10807- glPopMatrix();
10808-
10809- TRACE("D3DTSS_TCI_CAMERASPACEPOSITION - Set GL_TEXTURE_GEN_x and GL_x, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR\n");
10810- glEnable(GL_TEXTURE_GEN_S);
10811- checkGLcall("glEnable(GL_TEXTURE_GEN_S);");
10812- glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR);
10813- checkGLcall("glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR)");
10814- glEnable(GL_TEXTURE_GEN_T);
10815- checkGLcall("glEnable(GL_TEXTURE_GEN_T);");
10816- glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR);
10817- checkGLcall("glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR)");
10818- glEnable(GL_TEXTURE_GEN_R);
10819- checkGLcall("glEnable(GL_TEXTURE_GEN_R);");
10820- glTexGeni(GL_R, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR);
10821- checkGLcall("glTexGeni(GL_R, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR)");
10822- }
10823- break;
10824+ /* CameraSpacePosition means use the vertex position, transformed to camera space,
10825+ as the input texture coordinates for this stage's texture transformation. This
10826+ equates roughly to EYE_LINEAR */
10827+ {
10828+ float s_plane[] = { 1.0, 0.0, 0.0, 0.0 };
10829+ float t_plane[] = { 0.0, 1.0, 0.0, 0.0 };
10830+ float r_plane[] = { 0.0, 0.0, 1.0, 0.0 };
10831+ float q_plane[] = { 0.0, 0.0, 0.0, 1.0 };
10832+ TRACE("D3DTSS_TCI_CAMERASPACEPOSITION - Set eye plane\n");
10833+
10834+ glMatrixMode(GL_MODELVIEW);
10835+ glPushMatrix();
10836+ glLoadIdentity();
10837+ glTexGenfv(GL_S, GL_EYE_PLANE, s_plane);
10838+ glTexGenfv(GL_T, GL_EYE_PLANE, t_plane);
10839+ glTexGenfv(GL_R, GL_EYE_PLANE, r_plane);
10840+ glTexGenfv(GL_Q, GL_EYE_PLANE, q_plane);
10841+ glPopMatrix();
10842+
10843+ TRACE("D3DTSS_TCI_CAMERASPACEPOSITION - Set GL_TEXTURE_GEN_x and GL_x, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR\n");
10844+ glEnable(GL_TEXTURE_GEN_S);
10845+ checkGLcall("glEnable(GL_TEXTURE_GEN_S);");
10846+ glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR);
10847+ checkGLcall("glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR)");
10848+ glEnable(GL_TEXTURE_GEN_T);
10849+ checkGLcall("glEnable(GL_TEXTURE_GEN_T);");
10850+ glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR);
10851+ checkGLcall("glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR)");
10852+ glEnable(GL_TEXTURE_GEN_R);
10853+ checkGLcall("glEnable(GL_TEXTURE_GEN_R);");
10854+ glTexGeni(GL_R, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR);
10855+ checkGLcall("glTexGeni(GL_R, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR)");
10856+ }
10857+ break;
10858
10859 case D3DTSS_TCI_CAMERASPACENORMAL:
10860- {
10861- if (GL_SUPPORT(NV_TEXGEN_REFLECTION)) {
10862- float s_plane[] = { 1.0, 0.0, 0.0, 0.0 };
10863- float t_plane[] = { 0.0, 1.0, 0.0, 0.0 };
10864- float r_plane[] = { 0.0, 0.0, 1.0, 0.0 };
10865- float q_plane[] = { 0.0, 0.0, 0.0, 1.0 };
10866- TRACE("D3DTSS_TCI_CAMERASPACEPOSITION - Set eye plane\n");
10867-
10868- glMatrixMode(GL_MODELVIEW);
10869- glPushMatrix();
10870- glLoadIdentity();
10871- glTexGenfv(GL_S, GL_EYE_PLANE, s_plane);
10872- glTexGenfv(GL_T, GL_EYE_PLANE, t_plane);
10873- glTexGenfv(GL_R, GL_EYE_PLANE, r_plane);
10874- glTexGenfv(GL_Q, GL_EYE_PLANE, q_plane);
10875- glPopMatrix();
10876-
10877- glEnable(GL_TEXTURE_GEN_S);
10878- checkGLcall("glEnable(GL_TEXTURE_GEN_S);");
10879- glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_NORMAL_MAP_NV);
10880- checkGLcall("glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_NORMAL_MAP_NV)");
10881- glEnable(GL_TEXTURE_GEN_T);
10882- checkGLcall("glEnable(GL_TEXTURE_GEN_T);");
10883- glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_NORMAL_MAP_NV);
10884- checkGLcall("glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_NORMAL_MAP_NV)");
10885- glEnable(GL_TEXTURE_GEN_R);
10886- checkGLcall("glEnable(GL_TEXTURE_GEN_R);");
10887- glTexGeni(GL_R, GL_TEXTURE_GEN_MODE, GL_NORMAL_MAP_NV);
10888- checkGLcall("glTexGeni(GL_R, GL_TEXTURE_GEN_MODE, GL_NORMAL_MAP_NV)");
10889+ {
10890+ if (GL_SUPPORT(NV_TEXGEN_REFLECTION)) {
10891+ float s_plane[] = { 1.0, 0.0, 0.0, 0.0 };
10892+ float t_plane[] = { 0.0, 1.0, 0.0, 0.0 };
10893+ float r_plane[] = { 0.0, 0.0, 1.0, 0.0 };
10894+ float q_plane[] = { 0.0, 0.0, 0.0, 1.0 };
10895+ TRACE("D3DTSS_TCI_CAMERASPACEPOSITION - Set eye plane\n");
10896+
10897+ glMatrixMode(GL_MODELVIEW);
10898+ glPushMatrix();
10899+ glLoadIdentity();
10900+ glTexGenfv(GL_S, GL_EYE_PLANE, s_plane);
10901+ glTexGenfv(GL_T, GL_EYE_PLANE, t_plane);
10902+ glTexGenfv(GL_R, GL_EYE_PLANE, r_plane);
10903+ glTexGenfv(GL_Q, GL_EYE_PLANE, q_plane);
10904+ glPopMatrix();
10905+
10906+ glEnable(GL_TEXTURE_GEN_S);
10907+ checkGLcall("glEnable(GL_TEXTURE_GEN_S);");
10908+ glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_NORMAL_MAP_NV);
10909+ checkGLcall("glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_NORMAL_MAP_NV)");
10910+ glEnable(GL_TEXTURE_GEN_T);
10911+ checkGLcall("glEnable(GL_TEXTURE_GEN_T);");
10912+ glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_NORMAL_MAP_NV);
10913+ checkGLcall("glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_NORMAL_MAP_NV)");
10914+ glEnable(GL_TEXTURE_GEN_R);
10915+ checkGLcall("glEnable(GL_TEXTURE_GEN_R);");
10916+ glTexGeni(GL_R, GL_TEXTURE_GEN_MODE, GL_NORMAL_MAP_NV);
10917+ checkGLcall("glTexGeni(GL_R, GL_TEXTURE_GEN_MODE, GL_NORMAL_MAP_NV)");
10918+ }
10919 }
10920- }
10921- break;
10922+ break;
10923
10924 case D3DTSS_TCI_CAMERASPACEREFLECTIONVECTOR:
10925- {
10926- if (GL_SUPPORT(NV_TEXGEN_REFLECTION)) {
10927- float s_plane[] = { 1.0, 0.0, 0.0, 0.0 };
10928- float t_plane[] = { 0.0, 1.0, 0.0, 0.0 };
10929- float r_plane[] = { 0.0, 0.0, 1.0, 0.0 };
10930- float q_plane[] = { 0.0, 0.0, 0.0, 1.0 };
10931- TRACE("D3DTSS_TCI_CAMERASPACEPOSITION - Set eye plane\n");
10932-
10933- glMatrixMode(GL_MODELVIEW);
10934- glPushMatrix();
10935- glLoadIdentity();
10936- glTexGenfv(GL_S, GL_EYE_PLANE, s_plane);
10937- glTexGenfv(GL_T, GL_EYE_PLANE, t_plane);
10938- glTexGenfv(GL_R, GL_EYE_PLANE, r_plane);
10939- glTexGenfv(GL_Q, GL_EYE_PLANE, q_plane);
10940- glPopMatrix();
10941-
10942- glEnable(GL_TEXTURE_GEN_S);
10943- checkGLcall("glEnable(GL_TEXTURE_GEN_S);");
10944- glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_REFLECTION_MAP_NV);
10945- checkGLcall("glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_REFLECTION_MAP_NV)");
10946- glEnable(GL_TEXTURE_GEN_T);
10947- checkGLcall("glEnable(GL_TEXTURE_GEN_T);");
10948- glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_REFLECTION_MAP_NV);
10949- checkGLcall("glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_REFLECTION_MAP_NV)");
10950- glEnable(GL_TEXTURE_GEN_R);
10951- checkGLcall("glEnable(GL_TEXTURE_GEN_R);");
10952- glTexGeni(GL_R, GL_TEXTURE_GEN_MODE, GL_REFLECTION_MAP_NV);
10953- checkGLcall("glTexGeni(GL_R, GL_TEXTURE_GEN_MODE, GL_REFLECTION_MAP_NV)");
10954+ {
10955+ if (GL_SUPPORT(NV_TEXGEN_REFLECTION)) {
10956+ float s_plane[] = { 1.0, 0.0, 0.0, 0.0 };
10957+ float t_plane[] = { 0.0, 1.0, 0.0, 0.0 };
10958+ float r_plane[] = { 0.0, 0.0, 1.0, 0.0 };
10959+ float q_plane[] = { 0.0, 0.0, 0.0, 1.0 };
10960+ TRACE("D3DTSS_TCI_CAMERASPACEPOSITION - Set eye plane\n");
10961+
10962+ glMatrixMode(GL_MODELVIEW);
10963+ glPushMatrix();
10964+ glLoadIdentity();
10965+ glTexGenfv(GL_S, GL_EYE_PLANE, s_plane);
10966+ glTexGenfv(GL_T, GL_EYE_PLANE, t_plane);
10967+ glTexGenfv(GL_R, GL_EYE_PLANE, r_plane);
10968+ glTexGenfv(GL_Q, GL_EYE_PLANE, q_plane);
10969+ glPopMatrix();
10970+
10971+ glEnable(GL_TEXTURE_GEN_S);
10972+ checkGLcall("glEnable(GL_TEXTURE_GEN_S);");
10973+ glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_REFLECTION_MAP_NV);
10974+ checkGLcall("glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_REFLECTION_MAP_NV)");
10975+ glEnable(GL_TEXTURE_GEN_T);
10976+ checkGLcall("glEnable(GL_TEXTURE_GEN_T);");
10977+ glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_REFLECTION_MAP_NV);
10978+ checkGLcall("glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_REFLECTION_MAP_NV)");
10979+ glEnable(GL_TEXTURE_GEN_R);
10980+ checkGLcall("glEnable(GL_TEXTURE_GEN_R);");
10981+ glTexGeni(GL_R, GL_TEXTURE_GEN_MODE, GL_REFLECTION_MAP_NV);
10982+ checkGLcall("glTexGeni(GL_R, GL_TEXTURE_GEN_MODE, GL_REFLECTION_MAP_NV)");
10983+ }
10984 }
10985- }
10986- break;
10987+ break;
10988
10989 /* Unhandled types: */
10990 default:
10991- /* Todo: */
10992- /* ? disable GL_TEXTURE_GEN_n ? */
10993+ /** Todo: **/
10994+ /* ? disable GL_TEXTURE_GEN_n ? */
10995 glDisable(GL_TEXTURE_GEN_S);
10996 glDisable(GL_TEXTURE_GEN_T);
10997 glDisable(GL_TEXTURE_GEN_R);
10998@@ -3398,27 +4370,27 @@
10999 /* Unhandled */
11000 case D3DTSS_TEXTURETRANSFORMFLAGS :
11001 set_texture_matrix((float *)&This->stateBlock->transforms[D3DTS_TEXTURE0 + Stage].u.m[0][0], Value);
11002- break;
11003+ break;
11004
11005 case D3DTSS_BUMPENVMAT00 :
11006 case D3DTSS_BUMPENVMAT01 :
11007- TRACE("BUMPENVMAT0%u Stage=%ld, Type=%d, Value =%ld\n", Type - D3DTSS_BUMPENVMAT00, Stage, Type, Value);
11008+ TRACE("FIXME: BUMPENVMAT0%u Stage=%ld, Type=%d, Value =%ld\n", Type - D3DTSS_BUMPENVMAT00, Stage, Type, Value);
11009 break;
11010 case D3DTSS_BUMPENVMAT10 :
11011 case D3DTSS_BUMPENVMAT11 :
11012- TRACE("BUMPENVMAT1%u Stage=%ld, Type=%d, Value =%ld\n", Type - D3DTSS_BUMPENVMAT10, Stage, Type, Value);
11013+ TRACE("FIXME: BUMPENVMAT1%u Stage=%ld, Type=%d, Value =%ld\n", Type - D3DTSS_BUMPENVMAT10, Stage, Type, Value);
11014 break;
11015
11016 case D3DTSS_BUMPENVLSCALE :
11017- TRACE("BUMPENVLSCALE Stage=%ld, Type=%d, Value =%ld\n", Stage, Type, Value);
11018+ TRACE("FIXME: BUMPENVLSCALE Stage=%ld, Type=%d, Value =%ld\n", Stage, Type, Value);
11019 break;
11020
11021 case D3DTSS_BUMPENVLOFFSET :
11022- TRACE("BUMPENVLOFFSET Stage=%ld, Type=%d, Value =%ld\n", Stage, Type, Value);
11023+ TRACE("FIXME: BUMPENVLOFFSET Stage=%ld, Type=%d, Value =%ld\n", Stage, Type, Value);
11024 break;
11025
11026 case D3DTSS_RESULTARG :
11027- TRACE("RESULTARG Still a stub, Stage=%ld, Type=%d, Value =%ld\n", Stage, Type, Value);
11028+ TRACE("FIXME: RESULTARG Still a stub, Stage=%ld, Type=%d, Value =%ld\n", Stage, Type, Value);
11029 break;
11030
11031 default:
11032@@ -3439,19 +4411,18 @@
11033 }
11034
11035 /*****
11036- * Get / Set Texture
11037+ * Get / Set Texture
11038 *****/
11039-HRESULT WINAPI IWineD3DDeviceImpl_SetTexture(IWineD3DDevice *iface, DWORD Stage, IWineD3DBaseTexture* pTexture) {
11040-
11041+HRESULT WINAPI IWineD3DDeviceImpl_SetTexture(IWineD3DDevice* iface, DWORD Stage, IWineD3DBaseTexture* pTexture){
11042 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
11043+
11044 IWineD3DBaseTexture *oldTexture;
11045 BOOL reapplyStates = TRUE;
11046- DWORD reapplyFlags = 0;
11047 INT oldTextureDimensions = -1;
11048+ DWORD reapplyFlags = 0;
11049 D3DRESOURCETYPE textureType;
11050
11051- oldTexture = This->updateStateBlock->textures[Stage];
11052- TRACE("(%p) : Stage(%ld), Texture (%p)\n", This, Stage, pTexture);
11053+ TRACE("(%p) : Stage(%ld), pTexture(%p) \n", This, Stage, pTexture);
11054
11055 /* Reject invalid texture units */
11056 if (Stage >= GL_LIMITS(textures)) {
11057@@ -3459,8 +4430,14 @@
11058 return D3DERR_INVALIDCALL;
11059 }
11060
11061- This->updateStateBlock->set.textures[Stage] = TRUE;
11062+ oldTexture = This->updateStateBlock->textures[Stage];
11063+ TRACE("GL_LIMITS %d\n",GL_LIMITS(textures));
11064+ TRACE("(%p) : oldtexture(%p)\n", This,oldTexture);
11065+
11066+ This->updateStateBlock->set.textures[Stage] = TRUE;
11067 This->updateStateBlock->changed.textures[Stage] = TRUE;
11068+
11069+ TRACE("(%p) : setting new texture to %p\n", This,pTexture);
11070 This->updateStateBlock->textures[Stage] = pTexture;
11071
11072 /* Handle recording of state blocks */
11073@@ -3469,14 +4446,38 @@
11074 return D3D_OK;
11075 }
11076
11077+ /** NOTE: MSDN says that setTexture increases the reference count,
11078+ * and the the application nust set the texture back to null (or have a leaky application),
11079+ * This means we should pass the refcount upto the parent
11080+ *******************************/
11081+ if (NULL != oldTexture) {
11082+
11083+ IUnknown *textureParent;
11084+ IWineD3DBaseTexture_GetParent(oldTexture, (IUnknown **)&textureParent);
11085+ IUnknown_Release(textureParent);
11086+ IUnknown_Release(textureParent); /** NOTE: Twice because GetParent adds a ref **/
11087+ oldTexture = NULL;
11088+ }
11089+ if(NULL != This->updateStateBlock->textures[Stage]){
11090+
11091+ IUnknown *textureParent;
11092+ IWineD3DBaseTexture_GetParent(This->updateStateBlock->textures[Stage], (IUnknown **)&textureParent);
11093+ /** NOTE: GetParent will increase the ref count for me, I won't clean up untill the texture is set to NULL **/
11094+ }
11095+
11096 oldTextureDimensions = This->updateStateBlock->textureDimensions[Stage];
11097
11098 ENTER_GL();
11099
11100 /* Make appropriate texture active */
11101 if (GL_SUPPORT(ARB_MULTITEXTURE)) {
11102- GLACTIVETEXTURE(Stage);
11103-
11104+#if defined(GL_VERSION_1_3)
11105+ glActiveTexture(GL_TEXTURE0 + Stage);
11106+ checkGLcall("glActiveTexture");
11107+#else
11108+ glActiveTextureARB(GL_TEXTURE0_ARB + Stage);
11109+ checkGLcall("glActiveTextureARB");
11110+#endif
11111 } else if (Stage>0) {
11112 FIXME("Program using multiple concurrent textures which this opengl implementation doesn't support\n");
11113 }
11114@@ -3485,78 +4486,67 @@
11115 * and the the application nust set the texture back to null (or have a leaky application),
11116 * This means we should pass the refcount upto the parent
11117 *******************************/
11118- if (NULL != oldTexture) {
11119
11120 IUnknown *textureParent;
11121 IWineD3DBaseTexture_GetParent(oldTexture, (IUnknown **)&textureParent);
11122 IUnknown_Release(textureParent);
11123 IUnknown_Release(textureParent); /** NOTE: Twice because GetParent adds a ref **/
11124 oldTexture = NULL;
11125- }
11126
11127
11128 if (NULL != pTexture) {
11129 IUnknown *textureParent;
11130 IWineD3DBaseTexture_GetParent(This->updateStateBlock->textures[Stage], (IUnknown **)&textureParent);
11131 /** NOTE: GetParent will increase the ref count for me, I won't clean up untill the texture is set to NULL **/
11132-
11133+ TRACE("Getting type\n");
11134 /* Now setup the texture appropraitly */
11135 textureType = IWineD3DBaseTexture_GetType(pTexture);
11136
11137 if (textureType == D3DRTYPE_TEXTURE) {
11138-
11139- if (oldTexture == pTexture && !IWineD3DBaseTexture_GetDirty(pTexture)) {
11140+ if (oldTexture == pTexture && IWineD3DBaseTexture_GetDirty(pTexture)) {
11141 TRACE("Skipping setting texture as old == new\n");
11142 reapplyStates = FALSE;
11143-
11144 } else {
11145-
11146 /* Standard 2D texture */
11147 TRACE("Standard 2d texture\n");
11148 This->updateStateBlock->textureDimensions[Stage] = GL_TEXTURE_2D;
11149
11150 /* Load up the texture now */
11151- IWineD3DTexture_PreLoad((IWineD3DTexture *) pTexture);
11152+ IWineD3DTexture_PreLoad((IWineD3DTexture*) pTexture);
11153 }
11154
11155 } else if (textureType == D3DRTYPE_VOLUMETEXTURE) {
11156-
11157- if (oldTexture == pTexture && !IWineD3DBaseTexture_GetDirty(pTexture)) {
11158- TRACE("Skipping setting texture as old == new\n");
11159- reapplyStates = FALSE;
11160-
11161+ if (oldTexture == pTexture && IWineD3DBaseTexture_GetDirty(pTexture)) {
11162+ TRACE("Skipping setting texture as old == new\n");
11163+ reapplyStates = FALSE;
11164 } else {
11165-
11166- /* Standard 3D (volume) texture */
11167- TRACE("Standard 3d texture\n");
11168- This->updateStateBlock->textureDimensions[Stage] = GL_TEXTURE_3D;
11169-
11170- /* Load up the texture now */
11171- IWineD3DVolumeTexture_PreLoad((IWineD3DVolumeTexture *) pTexture);
11172+ /* Standard 3D (volume) texture */
11173+ TRACE("Standard 3d texture\n");
11174+ This->updateStateBlock->textureDimensions[Stage] = GL_TEXTURE_3D;
11175+ /** TODO: change this to use bind texture **/
11176+ /* Load up the texture now */
11177+ IWineD3DVolumeTexture_PreLoad((IWineD3DVolumeTexture*) pTexture);
11178 }
11179
11180- } else if (textureType == D3DRTYPE_CUBETEXTURE) {
11181
11182- if (oldTexture == pTexture && !IWineD3DBaseTexture_GetDirty(pTexture)) {
11183+ } else if (textureType == D3DRTYPE_CUBETEXTURE) {
11184+ if (oldTexture == pTexture && IWineD3DBaseTexture_GetDirty(pTexture)) {
11185 TRACE("Skipping setting texture as old == new\n");
11186 reapplyStates = FALSE;
11187-
11188 } else {
11189-
11190 /* Standard Cube texture */
11191+
11192 TRACE("Standard Cube texture\n");
11193 This->updateStateBlock->textureDimensions[Stage] = GL_TEXTURE_CUBE_MAP_ARB;
11194-
11195+ /** TODO: change this to use bind texture **/
11196 /* Load up the texture now */
11197- IWineD3DCubeTexture_PreLoad((IWineD3DCubeTexture *) pTexture);
11198+ IWineD3DCubeTexture_PreLoad((IWineD3DCubeTexture*) pTexture);
11199 }
11200
11201 } else {
11202 FIXME("(%p) : Incorrect type for a texture : (%d,%s)\n", This, textureType, debug_d3dresourcetype(textureType));
11203 }
11204-
11205 } else {
11206-
11207 TRACE("Setting to no texture (ie default texture)\n");
11208 This->updateStateBlock->textureDimensions[Stage] = GL_TEXTURE_1D;
11209 glBindTexture(GL_TEXTURE_1D, This->dummyTextureName[Stage]);
11210@@ -3577,7 +4567,7 @@
11211
11212 /* If Alpha arg1 is texture then handle the special case when there changes between a
11213 texture and no texture - See comments in set_tex_op */
11214- if ((This->stateBlock->textureState[Stage][D3DTSS_ALPHAARG1] == D3DTA_TEXTURE) &&
11215+ if ((This->stateBlock->textureState[Stage][D3DTSS_ALPHAARG1] == D3DTA_TEXTURE) &&
11216 (((oldTexture == NULL) && (pTexture != NULL)) || ((pTexture == NULL) && (oldTexture != NULL))))
11217 {
11218 reapplyFlags |= REAPPLY_ALPHAOP;
11219@@ -3591,43 +4581,52 @@
11220 IWineD3DDeviceImpl_SetupTextureStates(iface, Stage, reapplyFlags);
11221 }
11222
11223- LEAVE_GL();
11224+ LEAVE_GL();
11225 TRACE("Texture now fully setup\n");
11226
11227 return D3D_OK;
11228 }
11229
11230-HRESULT WINAPI IWineD3DDeviceImpl_GetTexture(IWineD3DDevice *iface, DWORD Stage, IWineD3DBaseTexture** ppTexture) {
11231- IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
11232- TRACE("(%p) : returning %p for stage %ld\n", This, This->updateStateBlock->textures[Stage], Stage);
11233- *ppTexture = (IWineD3DBaseTexture *) This->updateStateBlock->textures[Stage];
11234- if (*ppTexture)
11235- IWineD3DBaseTexture_AddRef(*ppTexture);
11236- return D3D_OK;
11237+HRESULT WINAPI IWineD3DDeviceImpl_GetTexture(IWineD3DDevice* iface, DWORD Stage, IWineD3DBaseTexture** ppTexture){
11238+ IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
11239+ TRACE("(%p) : (%ld /* Stage */,%p /* ppTexture */) \n", This, Stage, ppTexture);
11240+
11241+ /* Reject invalid texture units */
11242+ if (Stage >= GL_LIMITS(textures)) {
11243+ TRACE("Attempt to access invalid texture rejected\n");
11244+ return D3DERR_INVALIDCALL;
11245+ }
11246+ *ppTexture=This->updateStateBlock->textures[Stage];
11247+ if(*ppTexture)
11248+ IWineD3DTexture_AddRef(*ppTexture);
11249+ else
11250+ return D3DERR_INVALIDCALL;
11251+ return D3D_OK;
11252 }
11253
11254 /*****
11255 * Get Back Buffer
11256 *****/
11257-HRESULT WINAPI IWineD3DDeviceImpl_GetBackBuffer(IWineD3DDevice *iface, UINT iSwapChain, UINT BackBuffer, D3DBACKBUFFER_TYPE Type,
11258- IWineD3DSurface** ppBackBuffer) {
11259+
11260+HRESULT WINAPI IWineD3DDeviceImpl_GetBackBuffer(IWineD3DDevice *iface, UINT iSwapChain, UINT BackBuffer, D3DBACKBUFFER_TYPE Type,
11261+ IWineD3DSurface **ppBackBuffer) {
11262 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
11263+ IWineD3DSwapChain *swapChain;
11264+ HRESULT hr;
11265
11266- *ppBackBuffer = (IWineD3DSurface *) This->backBuffer;
11267 TRACE("(%p) : BackBuf %d Type %d SwapChain %d returning %p\n", This, BackBuffer, Type, iSwapChain, *ppBackBuffer);
11268-
11269- if (BackBuffer > This->presentParms.BackBufferCount - 1) {
11270- FIXME("Only one backBuffer currently supported\n");
11271- return D3DERR_INVALIDCALL;
11272+
11273+ hr = IWineD3DDeviceImpl_GetSwapChain(iface, iSwapChain, &swapChain);
11274+ if(hr == D3D_OK){
11275+ hr = IWineD3DSwapChain_GetBackBuffer(swapChain, BackBuffer, Type, ppBackBuffer);
11276+ IWineD3DSwapChain_Release(swapChain);
11277+ }else{
11278+ *ppBackBuffer = NULL;
11279 }
11280-
11281- /* Note inc ref on returned surface */
11282- IWineD3DSurface_AddRef(*ppBackBuffer);
11283-
11284- return D3D_OK;
11285+ return hr;
11286 }
11287
11288-HRESULT WINAPI IWineD3DDeviceImpl_GetDeviceCaps(IWineD3DDevice *iface, D3DCAPS9* pCaps) {
11289+HRESULT WINAPI IWineD3DDeviceImpl_GetDeviceCaps(IWineD3DDevice *iface, WINED3DCAPS* pCaps) {
11290 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
11291 WARN("(%p) : stub, calling idirect3d for now\n", This);
11292 IWineD3D_GetDeviceCaps(This->wineD3D, This->adapterNo, This->devType, pCaps);
11293@@ -3637,36 +4636,23 @@
11294 /** TODO: move to swapchains **/
11295 HRESULT WINAPI IWineD3DDeviceImpl_GetDisplayMode(IWineD3DDevice *iface, UINT iSwapChain, D3DDISPLAYMODE* pMode) {
11296 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
11297- HDC hdc;
11298- int bpp = 0;
11299+ IWineD3DSwapChain *swapChain;
11300+ HRESULT hr;
11301
11302- pMode->Width = GetSystemMetrics(SM_CXSCREEN);
11303- pMode->Height = GetSystemMetrics(SM_CYSCREEN);
11304- pMode->RefreshRate = 85; /*FIXME: How to identify? */
11305-
11306- hdc = CreateDCA("DISPLAY", NULL, NULL, NULL);
11307- bpp = GetDeviceCaps(hdc, BITSPIXEL);
11308- DeleteDC(hdc);
11309-
11310- switch (bpp) {
11311- case 8: pMode->Format = WINED3DFMT_R8G8B8; break;
11312- case 16: pMode->Format = WINED3DFMT_R5G6B5; break;
11313- case 24: /*pMode->Format = WINED3DFMT_R8G8B8; break; */
11314- case 32: pMode->Format = WINED3DFMT_A8R8G8B8; break;
11315- default:
11316- FIXME("Unrecognized display mode format\n");
11317- pMode->Format = WINED3DFMT_UNKNOWN;
11318+ hr = IWineD3DDeviceImpl_GetSwapChain(iface, iSwapChain, (IWineD3DSwapChain **)&swapChain);
11319+ if(hr == D3D_OK){
11320+ hr = IWineD3DSwapChain_GetDisplayMode(swapChain, pMode);
11321+ IWineD3DSwapChain_Release(swapChain);
11322+ }else{
11323+ FIXME("(%p) Error getting display mode\n", This);
11324 }
11325-
11326- FIXME("(%p) : returning w(%d) h(%d) rr(%d) fmt(%u,%s)\n", This, pMode->Width, pMode->Height, pMode->RefreshRate,
11327- pMode->Format, debug_d3dformat(pMode->Format));
11328- return D3D_OK;
11329+ return hr;
11330 }
11331 /*****
11332 * Stateblock related functions
11333 *****/
11334
11335- HRESULT WINAPI IWineD3DDeviceImpl_BeginStateBlock(IWineD3DDevice *iface) {
11336+HRESULT WINAPI IWineD3DDeviceImpl_BeginStateBlock(IWineD3DDevice *iface) {
11337 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
11338 IWineD3DStateBlockImpl *object;
11339 TRACE("(%p)", This);
11340@@ -3676,19 +4662,19 @@
11341 return E_OUTOFMEMORY;
11342 }
11343 TRACE("(%p) creted object %p\n", This, object);
11344- object->wineD3DDevice= This;
11345+ object->wineD3DDevice= This;
11346 /** FIXME: object->parent = parent; **/
11347 object->parent = NULL;
11348- object->blockType = D3DSBT_ALL;
11349+ object->blockType = D3DSBT_ALL;
11350 object->ref = 1;
11351- object->lpVtbl = &IWineD3DStateBlock_Vtbl;
11352-
11353+ object->lpVtbl = &IWineD3DStateBlock_Vtbl;
11354+
11355 IWineD3DStateBlock_Release((IWineD3DStateBlock*)This->updateStateBlock);
11356 This->updateStateBlock = object;
11357 This->isRecordingState = TRUE;
11358-
11359+
11360 TRACE("(%p) recording stateblock %p\n",This , object);
11361- return D3D_OK;
11362+ return D3D_OK;
11363 }
11364
11365 HRESULT WINAPI IWineD3DDeviceImpl_EndStateBlock(IWineD3DDevice *iface, IWineD3DStateBlock** ppStateBlock) {
11366@@ -3702,11 +4688,11 @@
11367
11368 *ppStateBlock = (IWineD3DStateBlock*)This->updateStateBlock;
11369 This->isRecordingState = FALSE;
11370- This->updateStateBlock = This->stateBlock;
11371+ This->updateStateBlock = This->stateBlock;
11372 IWineD3DStateBlock_AddRef((IWineD3DStateBlock*)This->updateStateBlock);
11373 /* IWineD3DStateBlock_AddRef(*ppStateBlock); don't need to do this, since we should really just release UpdateStateBlock first */
11374 TRACE("(%p) returning token (ptr to stateblock) of %p\n", This, *ppStateBlock);
11375- return D3D_OK;
11376+ return D3D_OK;
11377 }
11378
11379 /*****
11380@@ -3714,7 +4700,15 @@
11381 *****/
11382 HRESULT WINAPI IWineD3DDeviceImpl_BeginScene(IWineD3DDevice *iface) {
11383 /* At the moment we have no need for any functionality at the beginning
11384- of a scene */
11385+ of a scene */
11386+
11387+ /**
11388+ * TODO: Pass this onto the context manager
11389+ * it may be a good idea to really set the renderTarget at beginScene
11390+ * not when set render target is called, but this will be upto the
11391+ * context mamager
11392+ *****************************/
11393+
11394 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
11395 TRACE("(%p) : stub\n", This);
11396 return D3D_OK;
11397@@ -3722,16 +4716,34 @@
11398
11399 HRESULT WINAPI IWineD3DDeviceImpl_EndScene(IWineD3DDevice *iface) {
11400 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
11401+ DWORD startTime = 0;
11402+ if (TRACE_ON(d3d_timings))
11403+ startTime = GetTickCount();
11404+
11405 TRACE("(%p)\n", This);
11406 ENTER_GL();
11407 /* We only have to do this if we need to read the, swapbuffers performs a flush for us */
11408 glFlush();
11409 checkGLcall("glFlush");
11410+ /* Potentially I have to loop through the swapchains,
11411+ I should really do this...
11412+ IUnknown *targetContainer;
11413+ IUnknown *bufferContainter;
11414+
11415+ IWineD3DSurface_GetContainer(This->renderTarget, targetContainer);
11416+ IWineD3DSurface_GetContainer(This->backBuffer, bufferContainter);
11417+
11418+
11419+ if(classof(targetContainer) != SwapChain || classof(bufferContainter) != SwapChain){
11420
11421+ }
11422+ ,but as a poor option I can compaire the container aginst the device (This)
11423+ since renderTargets that arn't created as part of a swapchain will have
11424+ the device as their container.
11425+ */
11426 TRACE("End Scene\n");
11427 if(This->renderTarget != NULL){
11428
11429- /* If the container of the rendertarget is a texture then we need to save the data from the pbuffer */
11430 IUnknown *targetContainer = NULL;
11431 if (D3D_OK == IWineD3DSurface_GetContainer(This->renderTarget, &IID_IWineD3DBaseTexture, (void **)&targetContainer)) {
11432 TRACE("RenderTarget is either standalone of a texture.\n");
11433@@ -3744,99 +4756,55 @@
11434 IWineD3DBaseTexture_PreLoad((IWineD3DBaseTexture *)targetContainer);
11435 IWineD3DSurface_SetPBufferState(This->renderTarget, FALSE /* inPBuffer */, FALSE /* inTexture */);
11436 IUnknown_Release(targetContainer);
11437+ } else
11438+ if (D3D_OK == IWineD3DSurface_GetContainer(This->renderTarget, &IID_IWineD3DDevice, (void **)&targetContainer)){
11439+ /* Were testing to see if the texture is standalone, standalone textures has a container of IWineD3DDevice */
11440+ FIXME("If your seeing corrupt textures, this may be why\n");
11441+ IWineD3DSurface_SetPBufferState(This->renderTarget, TRUE /* inPBuffer */, FALSE /* inTexture */);
11442+ IWineD3DSurface_AddDirtyRect(This->renderTarget, NULL);
11443+ IWineD3DSurface_PreLoad(This->renderTarget);
11444+ IWineD3DSurface_SetPBufferState(This->renderTarget, FALSE /* inPBuffer */, FALSE /* inTexture */);
11445+ IUnknown_Release(targetContainer);
11446 }
11447
11448 }
11449-
11450 LEAVE_GL();
11451+ if (TRACE_ON(d3d_timings))
11452+ TRACE_(d3d_timings)("(%p) starttime %ld, total time %ld\n", This, startTime , GetTickCount() -startTime);
11453+
11454 return D3D_OK;
11455 }
11456
11457-HRESULT WINAPI IWineD3DDeviceImpl_Present(IWineD3DDevice *iface,
11458- CONST RECT* pSourceRect, CONST RECT* pDestRect,
11459+HRESULT WINAPI IWineD3DDeviceImpl_Present(IWineD3DDevice *iface,
11460+ CONST RECT* pSourceRect, CONST RECT* pDestRect,
11461 HWND hDestWindowOverride, CONST RGNDATA* pDirtyRegion) {
11462 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
11463- TRACE("(%p) Presenting the frame\n", This);
11464-
11465- ENTER_GL();
11466-
11467- if (pSourceRect || pDestRect) FIXME("Unhandled present options %p/%p\n", pSourceRect, pDestRect);
11468-
11469- glXSwapBuffers(This->display, This->drawable);
11470- /* Don't call checkGLcall, as glGetError is not applicable here */
11471-
11472- TRACE("glXSwapBuffers called, Starting new frame\n");
11473-
11474- /* FPS support */
11475- if (TRACE_ON(d3d_fps))
11476- {
11477- static long prev_time, frames;
11478-
11479- DWORD time = GetTickCount();
11480- frames++;
11481- /* every 1.5 seconds */
11482- if (time - prev_time > 1500) {
11483- TRACE_(d3d_fps)("@ approx %.2ffps\n", 1000.0*frames/(time - prev_time));
11484- prev_time = time;
11485- frames = 0;
11486- }
11487- }
11488+ IWineD3DSwapChain *swapChain = NULL;
11489+ int i;
11490+ int swapchains = IWineD3DDeviceImpl_GetNumberOfSwapChains(iface);
11491
11492-#if defined(FRAME_DEBUGGING)
11493-{
11494- if (GetFileAttributesA("C:\\D3DTRACE") != INVALID_FILE_ATTRIBUTES) {
11495- if (!isOn) {
11496- isOn = TRUE;
11497- FIXME("Enabling D3D Trace\n");
11498- __WINE_SET_DEBUGGING(__WINE_DBCL_TRACE, __wine_dbch_d3d, 1);
11499-#if defined(SHOW_FRAME_MAKEUP)
11500- FIXME("Singe Frame snapshots Starting\n");
11501- isDumpingFrames = TRUE;
11502- glClear(GL_COLOR_BUFFER_BIT);
11503-#endif
11504+ TRACE("(%p) Presenting the frame\n", This);
11505
11506-#if defined(SINGLE_FRAME_DEBUGGING)
11507- } else {
11508-#if defined(SHOW_FRAME_MAKEUP)
11509- FIXME("Singe Frame snapshots Finishing\n");
11510- isDumpingFrames = FALSE;
11511-#endif
11512- FIXME("Singe Frame trace complete\n");
11513- DeleteFileA("C:\\D3DTRACE");
11514- __WINE_SET_DEBUGGING(__WINE_DBCL_TRACE, __wine_dbch_d3d, 0);
11515-#endif
11516- }
11517- } else {
11518- if (isOn) {
11519- isOn = FALSE;
11520-#if defined(SHOW_FRAME_MAKEUP)
11521- FIXME("Singe Frame snapshots Finishing\n");
11522- isDumpingFrames = FALSE;
11523-#endif
11524- FIXME("Disabling D3D Trace\n");
11525- __WINE_SET_DEBUGGING(__WINE_DBCL_TRACE, __wine_dbch_d3d, 0);
11526- }
11527- }
11528-}
11529-#endif
11530+ for(i = 0 ; i < swapchains ; i ++){
11531
11532- LEAVE_GL();
11533- /* Although this is not strictly required, a simple demo showed this does occur
11534- on (at least non-debug) d3d */
11535- if (This->presentParms.SwapEffect == D3DSWAPEFFECT_DISCARD) {
11536- IWineD3DDevice_Clear(iface, 0, NULL, D3DCLEAR_STENCIL|D3DCLEAR_ZBUFFER|D3DCLEAR_TARGET, 0x00, 1.0, 0);
11537+ IWineD3DDeviceImpl_GetSwapChain(iface, i , (IWineD3DSwapChain **)&swapChain);
11538+ TRACE("presentinng chain %d, %p\n", i, swapChain);
11539+ IWineD3DSwapChain_Present(swapChain, pSourceRect, pDestRect, hDestWindowOverride, pDirtyRegion, 0);
11540+ IWineD3DSwapChain_Release(swapChain);
11541 }
11542
11543 return D3D_OK;
11544 }
11545
11546-HRESULT WINAPI IWineD3DDeviceImpl_Clear(IWineD3DDevice *iface, DWORD Count, CONST D3DRECT* pRects,
11547+HRESULT WINAPI IWineD3DDeviceImpl_Clear(IWineD3DDevice *iface, DWORD Count, CONST D3DRECT* pRects,
11548 DWORD Flags, D3DCOLOR Color, float Z, DWORD Stencil) {
11549 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
11550
11551 /* TODO: From MSDN This method fails if you specify the D3DCLEAR_ZBUFFER or D3DCLEAR_STENCIL flags when the
11552 render target does not have an attached depth buffer. Similarly, if you specify the D3DCLEAR_STENCIL flag
11553 when the depth-buffer format does not contain stencil buffer information, this method fails. */
11554+ /* TODO: Check that the scissortests in here doesn't affect DirectX scissor tests */
11555+ /* TODO: what about swapchains? */
11556 GLbitfield glMask = 0;
11557 GLboolean old_ztest;
11558 GLfloat old_z_clear_value;
11559@@ -3847,7 +4815,6 @@
11560
11561 TRACE("(%p) Count (%ld), pRects (%p), Flags (%lx), Z (%f), Stencil (%ld)\n", This,
11562 Count, pRects, Flags, Z, Stencil);
11563-
11564 ENTER_GL();
11565
11566 glEnable(GL_SCISSOR_TEST);
11567@@ -3860,7 +4827,7 @@
11568 }
11569
11570 /* Only set the values up once, as they are not changing */
11571- if (Flags & D3DCLEAR_STENCIL) {
11572+ if (Flags & D3DCLEAR_STENCIL) {
11573 glGetIntegerv(GL_STENCIL_CLEAR_VALUE, &old_stencil_clear_value);
11574 glClearStencil(Stencil);
11575 checkGLcall("glClearStencil");
11576@@ -3870,7 +4837,7 @@
11577
11578 if (Flags & D3DCLEAR_ZBUFFER) {
11579 glGetBooleanv(GL_DEPTH_WRITEMASK, &old_ztest);
11580- glDepthMask(GL_TRUE);
11581+ glDepthMask(GL_TRUE);
11582 glGetFloatv(GL_DEPTH_CLEAR_VALUE, &old_z_clear_value);
11583 glClearDepth(Z);
11584 checkGLcall("glClearDepth");
11585@@ -3880,9 +4847,9 @@
11586 if (Flags & D3DCLEAR_TARGET) {
11587 TRACE("Clearing screen with glClear to color %lx\n", Color);
11588 glGetFloatv(GL_COLOR_CLEAR_VALUE, old_color_clear_value);
11589- glClearColor(((Color >> 16) & 0xFF) / 255.0f,
11590+ glClearColor(((Color >> 16) & 0xFF) / 255.0f,
11591 ((Color >> 8) & 0xFF) / 255.0f,
11592- ((Color >> 0) & 0xFF) / 255.0f,
11593+ ((Color >> 0) & 0xFF) / 255.0f,
11594 ((Color >> 24) & 0xFF) / 255.0f);
11595 checkGLcall("glClearColor");
11596
11597@@ -3890,28 +4857,31 @@
11598 glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
11599 glMask = glMask | GL_COLOR_BUFFER_BIT;
11600 }
11601-
11602+TRACE("running through each rect\n");
11603 /* Now process each rect in turn */
11604 for (i = 0; i < Count || i == 0; i++) {
11605
11606 if (curRect) {
11607 /* Note gl uses lower left, width/height */
11608+ /* TODO: repalce impl usage with iface usage */
11609 TRACE("(%p) %p Rect=(%ld,%ld)->(%ld,%ld) glRect=(%ld,%ld), len=%ld, hei=%ld\n", This, curRect,
11610 curRect->x1, curRect->y1, curRect->x2, curRect->y2,
11611- curRect->x1, (((IWineD3DSurfaceImpl *)This->renderTarget)->currentDesc.Height - curRect->y2),
11612+ curRect->x1, (((IWineD3DSurfaceImpl *)This->renderTarget)->currentDesc.Height - curRect->y2),
11613 curRect->x2 - curRect->x1, curRect->y2 - curRect->y1);
11614- glScissor(curRect->x1, (((IWineD3DSurfaceImpl *)This->renderTarget)->currentDesc.Height - curRect->y2),
11615+ glScissor(curRect->x1, (((IWineD3DSurfaceImpl *)This->renderTarget)->currentDesc.Height - curRect->y2),
11616 curRect->x2 - curRect->x1, curRect->y2 - curRect->y1);
11617 checkGLcall("glScissor");
11618 } else {
11619- glScissor(This->stateBlock->viewport.X,
11620- (((IWineD3DSurfaceImpl *)This->renderTarget)->currentDesc.Height - (This->stateBlock->viewport.Y + This->stateBlock->viewport.Height)),
11621- This->stateBlock->viewport.Width,
11622+ glScissor(This->stateBlock->viewport.X,
11623+ (((IWineD3DSurfaceImpl *)This->renderTarget)->currentDesc.Height -
11624+ (This->stateBlock->viewport.Y + This->stateBlock->viewport.Height)),
11625+ This->stateBlock->viewport.Width,
11626 This->stateBlock->viewport.Height);
11627 checkGLcall("glScissor");
11628 }
11629
11630- /* Clear the selected rectangle (or full screen) */
11631+ /* Clear the selected r
11632+ ectangle (or full screen) */
11633 glClear(glMask);
11634 checkGLcall("glClear");
11635
11636@@ -3923,15 +4893,15 @@
11637 if (Flags & D3DCLEAR_STENCIL) {
11638 glClearStencil(old_stencil_clear_value);
11639 glStencilMask(This->stateBlock->renderState[WINED3DRS_STENCILWRITEMASK]);
11640- }
11641+ }
11642 if (Flags & D3DCLEAR_ZBUFFER) {
11643 glDepthMask(old_ztest);
11644 glClearDepth(old_z_clear_value);
11645 }
11646 if (Flags & D3DCLEAR_TARGET) {
11647- glClearColor(old_color_clear_value[0],
11648+ glClearColor(old_color_clear_value[0],
11649 old_color_clear_value[1],
11650- old_color_clear_value[2],
11651+ old_color_clear_value[2],
11652 old_color_clear_value[3]);
11653 glColorMask(This->stateBlock->renderState[WINED3DRS_COLORWRITEENABLE] & D3DCOLORWRITEENABLE_RED ? GL_TRUE : GL_FALSE,
11654 This->stateBlock->renderState[WINED3DRS_COLORWRITEENABLE] & D3DCOLORWRITEENABLE_GREEN ? GL_TRUE : GL_FALSE,
11655@@ -3942,29 +4912,34 @@
11656 glDisable(GL_SCISSOR_TEST);
11657 checkGLcall("glDisable");
11658 LEAVE_GL();
11659-
11660 return D3D_OK;
11661 }
11662
11663 /*****
11664 * Drawing functions
11665 *****/
11666-HRESULT WINAPI IWineD3DDeviceImpl_DrawPrimitive(IWineD3DDevice *iface, D3DPRIMITIVETYPE PrimitiveType, UINT StartVertex,
11667+HRESULT WINAPI IWineD3DDeviceImpl_DrawPrimitive(IWineD3DDevice *iface, D3DPRIMITIVETYPE PrimitiveType, UINT StartVertex,
11668 UINT PrimitiveCount) {
11669
11670 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
11671- This->stateBlock->streamIsUP = FALSE;
11672+ DWORD startTime = 0;
11673
11674- TRACE("(%p) : Type=(%d,%s), Start=%d, Count=%d\n", This, PrimitiveType,
11675- debug_d3dprimitivetype(PrimitiveType),
11676+ This->stateBlock->streamIsUP = FALSE;
11677+ if (TRACE_ON(d3d_timings))
11678+ startTime = GetTickCount(); /* Use windows calls for this */
11679+ TRACE("(%p) : Type=(%d,%s), Start=%d, Count=%d\n", This, PrimitiveType,
11680+ debug_d3dprimitivetype(PrimitiveType),
11681 StartVertex, PrimitiveCount);
11682 drawPrimitive(iface, PrimitiveType, PrimitiveCount, StartVertex, -1, 0, NULL, 0);
11683
11684+ if (TRACE_ON(d3d_timings))
11685+ TRACE_(d3d_timings)("(%p) starttime %ld, total time %ld\n", This, startTime , GetTickCount() -startTime);
11686+
11687 return D3D_OK;
11688 }
11689
11690-/* TODO: baseVIndex needs to be provided from This->stateBlock->baseVertexIndex when called from d3d8 */
11691-HRESULT WINAPI IWineD3DDeviceImpl_DrawIndexedPrimitive(IWineD3DDevice *iface,
11692+/** TODO: baseVIndex needs to be provided from This->stateBlock->baseVertexIndex when called from d3d8 **/
11693+HRESULT WINAPI IWineD3DDeviceImpl_DrawIndexedPrimitive(IWineD3DDevice *iface,
11694 D3DPRIMITIVETYPE PrimitiveType,
11695 INT baseVIndex, UINT minIndex,
11696 UINT NumVertices,UINT startIndex,UINT primCount) {
11697@@ -3973,11 +4948,14 @@
11698 UINT idxStride = 2;
11699 IWineD3DIndexBuffer *pIB;
11700 D3DINDEXBUFFER_DESC IdxBufDsc;
11701-
11702+ DWORD startTime = 0;
11703+ if (TRACE_ON(d3d_timings))
11704+ startTime = GetTickCount(); /* Use windows calls for this */
11705+
11706 pIB = This->stateBlock->pIndexData;
11707 This->stateBlock->streamIsUP = FALSE;
11708
11709- TRACE("(%p) : Type=(%d,%s), min=%d, CountV=%d, startIdx=%d, baseVidx=%d, countP=%d \n", This,
11710+ TRACE("(%p) : Type=(%d,%s), min=%d, CountV=%d, startIdx=%d, baseVidx=%d, countP=%d \n", This,
11711 PrimitiveType, debug_d3dprimitivetype(PrimitiveType),
11712 minIndex, NumVertices, startIndex, baseVIndex, primCount);
11713
11714@@ -3987,35 +4965,46 @@
11715 } else {
11716 idxStride = 4;
11717 }
11718-
11719- drawPrimitive(iface, PrimitiveType, primCount, baseVIndex,
11720- startIndex, idxStride,
11721+ /** TODO: get rid of the IWineD3DIndexBufferImpl * cast **/
11722+ drawPrimitive(iface, PrimitiveType, primCount, baseVIndex,
11723+ startIndex, idxStride,
11724 ((IWineD3DIndexBufferImpl *) pIB)->resource.allocatedMemory,
11725 minIndex);
11726+ if (TRACE_ON(d3d_timings))
11727+ TRACE_(d3d_timings)("(%p) starttime %ld, total time %ld\n", This, startTime , GetTickCount() -startTime);
11728
11729 return D3D_OK;
11730 }
11731
11732+
11733 HRESULT WINAPI IWineD3DDeviceImpl_DrawPrimitiveUP(IWineD3DDevice *iface, D3DPRIMITIVETYPE PrimitiveType,
11734 UINT PrimitiveCount, CONST void* pVertexStreamZeroData,
11735 UINT VertexStreamZeroStride) {
11736 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
11737
11738- TRACE("(%p) : Type=(%d,%s), pCount=%d, pVtxData=%p, Stride=%d\n", This, PrimitiveType,
11739- debug_d3dprimitivetype(PrimitiveType),
11740- PrimitiveCount, pVertexStreamZeroData, VertexStreamZeroStride);
11741-
11742- if (This->stateBlock->stream_source[0] != NULL) IWineD3DVertexBuffer_Release(This->stateBlock->stream_source[0]);
11743-
11744+ TRACE("(%p) : Type=(%d,%s), pCount=%d, pVtxData=%p, Stride=%d\n", This, PrimitiveType,
11745+ debug_d3dprimitivetype(PrimitiveType),
11746+ PrimitiveCount, pVertexStreamZeroData, VertexStreamZeroStride);
11747+ /* TODO: instancing */
11748+#if 0 /* move over to using callbacks */
11749+#else
11750+ if(This->stateBlock->streamSource[0] != NULL){
11751+ IWineD3DVertexBuffer_Release(This->stateBlock->streamSource[0]);
11752+ }
11753+#endif
11754+ TRACE("Setting the stream source to something odd\n");
11755 /* Note in the following, it's not this type, but that's the purpose of streamIsUP */
11756- This->stateBlock->stream_source[0] = (IWineD3DVertexBuffer *)pVertexStreamZeroData;
11757- This->stateBlock->stream_stride[0] = VertexStreamZeroStride;
11758+ This->stateBlock->streamSource[0] = (IWineD3DVertexBuffer *)pVertexStreamZeroData;
11759+ This->stateBlock->streamStride[0] = VertexStreamZeroStride;
11760 This->stateBlock->streamIsUP = TRUE;
11761+ TRACE("calling draw primitive\n");
11762 drawPrimitive(iface, PrimitiveType, PrimitiveCount, 0, 0, 0, NULL, 0);
11763- This->stateBlock->stream_stride[0] = 0;
11764- This->stateBlock->stream_source[0] = NULL;
11765+ /* stream zero settings set to null at end, as per the msdn
11766+ http://msdn.microsoft.com/archive/default.asp?url=/archive/en-us/directx9_c/directx/graphics/reference/d3d/interfaces/idirect3ddevice9/DrawPrimitiveUP.asp
11767+ */
11768+ This->stateBlock->streamStride[0] = 0;
11769+ This->stateBlock->streamSource[0] = NULL;
11770
11771- /*stream zero settings set to null at end, as per the msdn */
11772 return D3D_OK;
11773 }
11774
11775@@ -4024,32 +5013,37 @@
11776 UINT NumVertexIndices,UINT PrimitiveCount,CONST void* pIndexData,
11777 WINED3DFORMAT IndexDataFormat, CONST void* pVertexStreamZeroData,
11778 UINT VertexStreamZeroStride) {
11779- int idxStride;
11780 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
11781+ int idxStride;
11782
11783- TRACE("(%p) : Type=(%d,%s), MinVtxIdx=%d, NumVIdx=%d, PCount=%d, pidxdata=%p, IdxFmt=%d, pVtxdata=%p, stride=%d\n",
11784+ TRACE("(%p) : Type=(%d,%s), MinVtxIdx=%d, NumVIdx=%d, PCount=%d, pidxdata=%p, IdxFmt=%d, pVtxdata=%p, stride=%d\n",
11785 This, PrimitiveType, debug_d3dprimitivetype(PrimitiveType),
11786- MinVertexIndex, NumVertexIndices, PrimitiveCount, pIndexData,
11787+ MinVertexIndex, NumVertexIndices, PrimitiveCount, pIndexData,
11788 IndexDataFormat, pVertexStreamZeroData, VertexStreamZeroStride);
11789
11790- if (This->stateBlock->stream_source[0] != NULL) IWineD3DVertexBuffer_Release(This->stateBlock->stream_source[0]);
11791-
11792 if (IndexDataFormat == WINED3DFMT_INDEX16) {
11793 idxStride = 2;
11794 } else {
11795 idxStride = 4;
11796 }
11797
11798+#if 0 /* move over to using callbacks */
11799+#else
11800+ if(This->stateBlock->streamSource[0] != NULL){
11801+ IWineD3DVertexBuffer_Release(This->stateBlock->streamSource[0]);
11802+ }
11803+#endif
11804+
11805 /* Note in the following, it's not this type, but that's the purpose of streamIsUP */
11806- This->stateBlock->stream_source[0] = (IWineD3DVertexBuffer *)pVertexStreamZeroData;
11807+ This->stateBlock->streamSource[0] = (IWineD3DVertexBuffer *)pVertexStreamZeroData;
11808 This->stateBlock->streamIsUP = TRUE;
11809- This->stateBlock->stream_stride[0] = VertexStreamZeroStride;
11810-
11811+ This->stateBlock->streamStride[0] = VertexStreamZeroStride;
11812 drawPrimitive(iface, PrimitiveType, PrimitiveCount, 0, 0, idxStride, pIndexData, MinVertexIndex);
11813-
11814- /* stream zero settings set to null at end as per the msdn */
11815- This->stateBlock->stream_source[0] = NULL;
11816- This->stateBlock->stream_stride[0] = 0;
11817+ /* stream zero settings set to null at end as per the msdn
11818+ http://msdn.microsoft.com/archive/default.asp?url=/archive/en-us/directx9_c/directx/graphics/reference/d3d/interfaces/idirect3ddevice9/DrawPrimitiveUP.asp
11819+ */
11820+ This->stateBlock->streamSource[0] = NULL;
11821+ This->stateBlock->streamStride[0] = 0;
11822 IWineD3DDevice_SetIndices(iface, NULL, 0);
11823
11824 return D3D_OK;
11825@@ -4057,31 +5051,252 @@
11826
11827 HRESULT WINAPI IWineD3DDeviceImpl_UpdateTexture (IWineD3DDevice *iface, IWineD3DBaseTexture *pSourceTexture, IWineD3DBaseTexture *pDestinationTexture){
11828 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
11829-
11830- TRACE("(%p) : stub\n", This);
11831+ /* Well it should be easy, just write from one texture in memory to another in video ram */
11832+
11833+
11834+ D3DRESOURCETYPE sourceType;
11835+ D3DRESOURCETYPE destinationType;
11836+ IWineD3DTextureImpl *pDestTexture = (IWineD3DTextureImpl *)pDestinationTexture;
11837+ IWineD3DTextureImpl *pSrcTexture = (IWineD3DTextureImpl *)pSourceTexture;
11838+ int i;
11839+ DWORD startTime = 0;
11840+ if (TRACE_ON(d3d_timings))
11841+ startTime = GetTickCount(); /* Use windows calls for this */
11842+
11843+ sourceType = IWineD3DBaseTexture_GetType(pSourceTexture);
11844+ destinationType = IWineD3DBaseTexture_GetType(pDestinationTexture);
11845+ if(sourceType != D3DRTYPE_TEXTURE && destinationType != D3DRTYPE_TEXTURE){
11846+ FIXME("(%p) Only D3DRTYPE_TEXTURE to D3DRTYPE_TEXTURE supported\n", This);
11847+ return D3DERR_INVALIDCALL;
11848+ }
11849+ TRACE("(%p) Source %p Destination %p\n", This, pSourceTexture, pDestinationTexture);
11850+
11851+ /** TODO: Get rid of the casts to IWineD3DBaseTextureImpl
11852+ repalce surfaces[x] with GetSurfaceLevel, or GetCubeMapSurface etc..
11853+ think about moving the code into texture, and adding a member to base texture to occomplish this **/
11854+
11855+ /* Make sure that the destination textrue is loaded */
11856+ IWineD3DBaseTexture_PreLoad(pDestinationTexture);
11857+ TRACE("Loading source texture\n");
11858+
11859+ if(pSrcTexture->surfaces[0] == NULL || pDestTexture->surfaces[0] == NULL){
11860+ FIXME("(%p) Texture src %p or dest %p has not surface %p %p\n", This, pSrcTexture, pDestTexture,
11861+ pSrcTexture->surfaces[0], pDestTexture->surfaces[0]);
11862+ }
11863+
11864+ if(((IWineD3DSurfaceImpl *)pSrcTexture->surfaces[0])->resource.pool != D3DPOOL_SYSTEMMEM ||
11865+ ((IWineD3DSurfaceImpl *)pDestTexture->surfaces[0])->resource.pool != D3DPOOL_DEFAULT){
11866+
11867+ FIXME("(%p) source %p must be SYSTEMMEM and dest %p must be DEFAULT\n",This, pSrcTexture, pDestTexture);
11868+ return D3DERR_INVALIDCALL;
11869+ }
11870+ /** TODO: check that both textures have the same number of levels **/
11871+#if 0
11872+ if(IWineD3DBaseTexture_GetLevelCount(pDestinationTexture) !=IWineD3DBaseTexture_GetLevelCount(pSourceTexture))
11873+ return D3DERR_INVALIDCALL;
11874+#endif
11875+ /** TODO: move this code into baseTexture? device should never touch impl*'s **/
11876+ for(i = 0 ; i < IWineD3DBaseTexture_GetLevelCount(pDestinationTexture) ; i++){
11877+ IWineD3DDevice_UpdateSurface(iface, pSrcTexture->surfaces[i], NULL, pDestTexture->surfaces[i], NULL);
11878+ }
11879+ if (TRACE_ON(d3d_timings))
11880+ TRACE_(d3d_timings)("(%p) starttime %ld, total time %ld\n", This, startTime , GetTickCount() -startTime);
11881+
11882 return D3D_OK;
11883 }
11884
11885-HRESULT WINAPI IWineD3DDeviceImpl_StretchRect(IWineD3DDevice *iface, IWineD3DSurface *pSourceSurface,
11886- CONST RECT* pSourceRect, IWineD3DSurface *pDestinationSurface,
11887- CONST RECT* pDestRect, D3DTEXTUREFILTERTYPE Filter) {
11888- IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
11889+HRESULT WINAPI IWineD3DDeviceImpl_StretchRect(IWineD3DDevice *iface, IWineD3DSurface *pSourceSurface, CONST RECT* pSourceRect, IWineD3DSurface *pDestinationSurface, CONST RECT* pDestRect, D3DTEXTUREFILTERTYPE Filter) {
11890+ IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *) iface;
11891+ /**
11892+ * TODO: get rid of the cases to IWineD3DSurfaceImpl think about moving the code into surface
11893+ * look at ways to implement (converting the dest into a rendertarget and
11894+ * then writing the texture out seems the 'best' way forward)
11895+ ******************************************************************/
11896+
11897+ IWineD3DSurfaceImpl *pDestSurface = (IWineD3DSurfaceImpl *)pDestinationSurface;
11898+ IWineD3DSurfaceImpl *pSrcSurface = (IWineD3DSurfaceImpl *)pSourceSurface;
11899+ int width, height;
11900+ RECT sourceLock;
11901+ RECT destLock;
11902+ D3DLOCKED_RECT lockedSrcRect;
11903+ D3DLOCKED_RECT lockedDestRect;
11904+ static BOOL showFixmes = TRUE;
11905+
11906+ if(pSrcSurface->resource.pool != D3DPOOL_DEFAULT || pDestSurface->resource.pool != D3DPOOL_DEFAULT){
11907+ /* This shouldn't happen, unless the calling application or wined3d is buggy */
11908+ WARN("source %p must be DEFAULT and dest %p must be DEFAULT\n", pSrcSurface, pDestSurface);
11909+ return D3DERR_INVALIDCALL;
11910+ }
11911+
11912+#if 0
11913+ /** This is a non aligned psudo, software version
11914+ * an aligned version would always start the origin at the same pixel
11915+ * and calaulate the error from there, here were just calculating
11916+ * the error from the starting pixel.
11917+ * ***********************************/
11918+ int x1;
11919+ int y1;
11920+ int x2;
11921+ int y2;
11922+ int dx;
11923+ int dy;
11924+
11925+ for(y1 = 0; y1 < destHeight; y1++){
11926+ dx=0;
11927+ for(x1 = 0; x1 < destwidth; x1++){
11928+
11929+ /* TODO: optional linearblending */
11930+ dx+=destwidth;
11931+ if(dx > sourceWidth){
11932+ x2 += dx/sourceWidth;
11933+ dx%=sourceWidth;
11934+ }
11935+ }
11936+ /** TODO: optional linearblending
11937+ * (colour = adv(etc...,
11938+ * optional weighted left most, and rightmost blended pixels become weighted blends middle pixels are left)
11939+ * or where were streaching
11940+ * color = weighted(y2,y2+1,dy/sourceHeight) =ish (y2 * dy + y2 * (sourceHeight - dy ))/(sourceHeight * 2)
11941+ * also random noise or other dithering techniques can be used to
11942+ * make streatching look better by giving it greater 'visuial' colour deapth.
11943+ **********************************/
11944+ dy+=destHeight;
11945+ if(dy > sourceHeight){
11946+ y2 += dy/sourceHeight;
11947+ dy%=sourceHeight;
11948+ }
11949+
11950+ }
11951+#endif
11952+ if(pSrcSurface->resource.format != pDestSurface->resource.format){
11953+ D3DCOLOR color = 0xFF0000FF;
11954+ if(showFixmes)
11955+ FIXME("Soruce and destination must be the same format\n");
11956+ /**
11957+ * FIXME: For now just colour the target area in red!
11958+ * software implmentation is easy, hardware isn't too hard
11959+ * but there are lots of performance/compatability playoffs
11960+ ****************************************************/
11961+ if(showFixmes)
11962+ FIXME("(%p) Streaching and filering not yet supported, colouring the target rect in red\n", This);
11963+ IWineD3DDevice_ColorFill(iface, pDestinationSurface, (D3DRECT*)pDestRect, color);
11964+
11965+ showFixmes = FALSE;
11966+ return D3D_OK;
11967+ }
11968+
11969+ return D3D_OK;
11970+
11971+ /** FIXME: This is the slowest possibly way to copy the texture, but it will do for now. */
11972+ if((pSourceRect->right - pSourceRect->left) != (pDestRect->right - pDestRect->left)
11973+ || (pSourceRect->bottom - pSourceRect->top) != (pDestRect->bottom - pDestRect->top)){
11974+ FIXME("Texture scaling not supported\n");
11975+ }
11976+ /* no zooming for now either, just copy across the minimum sized block */
11977+
11978+ width = min((pSourceRect->right - pSourceRect->left), (pDestRect->right - pDestRect->left));
11979+ height = min((pSourceRect->bottom - pSourceRect->top), (pDestRect->bottom - pDestRect->top));
11980
11981- TRACE("(%p) : stub\n", This);
11982+ sourceLock.top = pSourceRect->top;
11983+ sourceLock.left = pSourceRect->left;
11984+ sourceLock.bottom = pSourceRect->top + height;
11985+ sourceLock.right = pSourceRect->left + width;
11986+
11987+ destLock.top = pDestRect->top;
11988+ destLock.left = pDestRect->left;
11989+ destLock.bottom = pDestRect->top + height;
11990+ destLock.right = pDestRect->left + width;
11991+
11992+
11993+ IWineD3DSurface_LockRect(pSourceSurface, &lockedSrcRect, &sourceLock, D3DLOCK_READONLY);
11994+ IWineD3DSurface_LockRect(pDestinationSurface, &lockedDestRect, &destLock, 0);
11995+
11996+ /* copy across the data! */
11997+ {
11998+ int y;
11999+ int srcoff = 0;
12000+ int destoff = 0;
12001+ for(y = 0 ; y < height; y++){
12002+ memcpy(((char *)lockedDestRect.pBits) +srcoff, ((char *)lockedSrcRect.pBits) +destoff, width * pSrcSurface->bytesPerPixel);
12003+ }
12004+ srcoff+= lockedSrcRect.Pitch;
12005+ destoff+= lockedDestRect.Pitch;
12006+
12007+ }
12008+ IWineD3DSurface_UnlockRect(pSourceSurface);
12009+ IWineD3DSurface_UnlockRect(pDestinationSurface);
12010+ /* we need to make sure that the format is the same.... */
12011+
12012 return D3D_OK;
12013+
12014 }
12015+
12016 HRESULT WINAPI IWineD3DDeviceImpl_GetRenderTargetData(IWineD3DDevice *iface, IWineD3DSurface *pRenderTarget, IWineD3DSurface *pSurface){
12017- IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
12018-
12019- TRACE("(%p) : stub\n", This);
12020- return D3D_OK;
12021+IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
12022+/** TODO: remove remove casts to IWineD3DSurfaceImpl *
12023+ * NOTE It may be best to move the code into surface to occomplish this
12024+ ****************************************/
12025+
12026+ IWineD3DSurfaceImpl *renderTarget = (IWineD3DSurfaceImpl *)pRenderTarget;
12027+ IWineD3DSurfaceImpl *surface = (IWineD3DSurfaceImpl *)pSurface;
12028+ GLenum format;
12029+ GLenum type;
12030+ IWineD3DSwapChainImpl *container = NULL;
12031+ ENTER_GL();
12032+
12033+ /* check to see if it's the backbuffer or the frontbuffer being requested (to make sureteh data is upto date)*/
12034+ format = D3DFmt2GLFmt(This, surface->resource.format);
12035+ type = D3DFmt2GLType(This, surface->resource.format);
12036+
12037+ /* Ok, I may need to setup some kind of active swapchain reference on the device */
12038+ IWineD3DSurface_GetContainer(pRenderTarget, &IID_IWineD3DSwapChain, (void **)&container);
12039+
12040+ /* TODO: opengl Context switching for swapchains etc... */
12041+ if(NULL != container || pRenderTarget == This->renderTarget || pRenderTarget == This->depthStencilBuffer){
12042+#ifndef USE_CONTEXT_MANAGER /* TODO: opengl context managers */
12043+ if (NULL != container && (pRenderTarget == container->backBuffer)) {
12044+ glReadBuffer(GL_BACK);
12045+ } else if ((NULL != container && (pRenderTarget == container->frontBuffer)) || (pRenderTarget == This->renderTarget)) {
12046+ glReadBuffer(GL_FRONT);
12047+ } else if (pRenderTarget == This->depthStencilBuffer) {
12048+ FIXME("Reading of depthstencil not yet supported\n");
12049+ }
12050+
12051+ glReadPixels(0,
12052+ 0,
12053+ surface->currentDesc.Width,
12054+ surface->currentDesc.Height,
12055+ format,
12056+ type,
12057+ surface->resource.allocatedMemory);
12058+#endif
12059+ if(NULL != container ){
12060+ IWineD3DSwapChain_Release((IWineD3DSwapChain*) container);
12061+ }
12062+ }else{
12063+ glEnable(GL_TEXTURE_2D);
12064+ vcheckGLcall("glEnable(GL_TEXTURE_2D)");
12065+ glBindTexture(GL_TEXTURE_2D,renderTarget->textureName);
12066+ vcheckGLcall("glBindTexture");
12067+ glGetTexImage(GL_TEXTURE_2D,
12068+ renderTarget->currentDesc.Level,
12069+ format,
12070+ type,
12071+ surface->resource.allocatedMemory);
12072+ }
12073+ LEAVE_GL();
12074+ return D3D_OK;
12075 }
12076
12077 HRESULT WINAPI IWineD3DDeviceImpl_GetFrontBufferData(IWineD3DDevice *iface,UINT iSwapChain, IWineD3DSurface *pDestSurface){
12078- IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
12079-
12080- TRACE("(%p) : stub\n", This);
12081- return D3D_OK;
12082+ IWineD3DSwapChain *swapChain;
12083+ HRESULT hr;
12084+ hr = IWineD3DDeviceImpl_GetSwapChain(iface, iSwapChain, (IWineD3DSwapChain **)&swapChain);
12085+ if(hr == D3D_OK){
12086+ hr = IWineD3DSwapChain_GetFrontBufferData(swapChain, pDestSurface);
12087+ IWineD3DSwapChain_Release(swapChain);
12088+ }
12089+ return hr;
12090 }
12091
12092 HRESULT WINAPI IWineD3DDeviceImpl_ValidateDevice(IWineD3DDevice *iface, DWORD* pNumPasses) {
12093@@ -4093,7 +5308,7 @@
12094 }
12095
12096 HRESULT WINAPI IWineD3DDeviceImpl_SetPaletteEntries(IWineD3DDevice *iface, UINT PaletteNumber, CONST PALETTEENTRY* pEntries) {
12097- IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
12098+ IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
12099 FIXME("(%p) : stub\n", This);
12100 return D3D_OK;
12101 }
12102@@ -4132,9 +5347,19 @@
12103
12104 HRESULT WINAPI IWineD3DDeviceImpl_GetRasterStatus(IWineD3DDevice *iface, UINT iSwapChain, D3DRASTER_STATUS* pRasterStatus) {
12105 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
12106-
12107- pRasterStatus->InVBlank = TRUE;
12108- pRasterStatus->ScanLine = 0;
12109+ IWineD3DSwapChain *swapChain;
12110+ HRESULT hr;
12111+
12112+ TRACE("(%p) : SwapChain %d returning %p\n", This, iSwapChain, pRasterStatus);
12113+
12114+ hr = IWineD3DDeviceImpl_GetSwapChain(iface, iSwapChain, (IWineD3DSwapChain **)&swapChain);
12115+ if(hr == D3D_OK){
12116+ hr = IWineD3DSwapChain_GetRasterStatus(swapChain, pRasterStatus);
12117+ IWineD3DSwapChain_Release(swapChain);
12118+ }else{
12119+ FIXME("(%p) IWineD3DSwapChain_GetRasterStatus returned in error \n", This);
12120+ }
12121+ return hr;
12122 FIXME("(%p) : stub\n", This);
12123 return D3D_OK;
12124 }
12125@@ -4164,8 +5389,95 @@
12126
12127
12128 HRESULT WINAPI IWineD3DDeviceImpl_UpdateSurface(IWineD3DDevice *iface, IWineD3DSurface *pSourceSurface, CONST RECT* pSourceRect, IWineD3DSurface *pDestinationSurface, CONST POINT* pDestPoint) {
12129- IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *) iface;
12130- FIXME("(%p) : stub\n", This);
12131+
12132+ IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *) iface;
12133+ /** TODO: remove casts to IWineD3DSurfaceImpl
12134+ * NOTE: move code to surface to occomplish this
12135+ ****************************************/
12136+ IWineD3DSurfaceImpl *pDestSurface = (IWineD3DSurfaceImpl *)pDestinationSurface;
12137+ IWineD3DSurfaceImpl *pSrcSurface = (IWineD3DSurfaceImpl *)pSourceSurface;
12138+ int srcWidth, srcHeight;
12139+ int destLeft, destTop;
12140+ int offset = 0;
12141+ int rowoffset = 0; /* how many bytes to add onto the end of a row to wraparound to the begining of the next */
12142+
12143+ if(pSrcSurface->resource.pool != D3DPOOL_SYSTEMMEM || pDestSurface->resource.pool != D3DPOOL_DEFAULT){
12144+ FIXME("source %p must be SYSTEMMEM and dest %p must be DEFAULT\n", pSrcSurface, pDestSurface);
12145+ return D3DERR_INVALIDCALL;
12146+ }
12147+ /* TODO: change this to use bindTexture */
12148+ /* Make sure the surface is loaded */
12149+ IWineD3DSurface_PreLoad(pDestinationSurface);
12150+ ENTER_GL();
12151+
12152+ /* this needs to be done in lines if the sourceRect != the sourceWidth */
12153+ srcWidth = pSourceRect ? pSourceRect->right - pSourceRect->left : pSrcSurface->currentDesc.Width;
12154+ srcHeight = pSourceRect ? pSourceRect->top - pSourceRect->bottom : pSrcSurface->currentDesc.Height;
12155+ destLeft = pDestPoint ? pDestPoint->x : 0;
12156+ destTop = pDestPoint ? pDestPoint->y : 0;
12157+
12158+
12159+ /* This function doesn't support compressed textures
12160+ the pitch is just bytesPerPixel * width */
12161+
12162+ if(srcWidth != pSrcSurface->currentDesc.Width || (pSourceRect != NULL && pSourceRect->left != 0) ){
12163+ rowoffset = (pSrcSurface->currentDesc.Width - srcWidth) * pSrcSurface->bytesPerPixel;
12164+ offset += pSourceRect->left * pSrcSurface->bytesPerPixel;
12165+ /* TODO: do we ever get 3bpp?, would a shift and an add be quicker than a mul (well maybe a cycle or two) */
12166+ }
12167+ if(pSourceRect != NULL && pSourceRect->top != 0){
12168+ offset += pSourceRect->top * pSrcSurface->currentDesc.Width * pSrcSurface->bytesPerPixel;
12169+ }
12170+ TRACE("glTexSubImage2D, Level %d, left %d, top %d, width %d, height %d ,ftm %d, type %d, memory %p\n"
12171+ ,pDestSurface->currentDesc.Level
12172+ ,destLeft
12173+ ,destTop
12174+ ,srcWidth
12175+ ,srcHeight
12176+ ,D3DFmt2GLFmt(This, pSrcSurface->resource.format)
12177+ ,D3DFmt2GLType(This, pSrcSurface->resource.format)
12178+ ,pSrcSurface->resource.allocatedMemory
12179+ );
12180+ if(pSrcSurface->resource.allocatedMemory == NULL){
12181+ /* need to lock the surface to get the data */
12182+ FIXME("Surfaces has no allocated memory, but should be an in memory only surface\n");
12183+ }
12184+
12185+ if(rowoffset != 0){
12186+ /* not a whole row so we have to do it a line at a time */
12187+ int j;
12188+ /* hopefully using pointer addtion will be quicker than using a point + j * rowoffset */
12189+ unsigned char* data =((unsigned char *)pSrcSurface->resource.allocatedMemory) + offset;
12190+
12191+ for(j = destTop ; j < (srcHeight + destTop) ; j++){
12192+
12193+ glTexSubImage2D( GL_TEXTURE_2D
12194+ ,pDestSurface->currentDesc.Level
12195+ ,destLeft
12196+ ,j
12197+ ,srcWidth
12198+ ,1
12199+ ,D3DFmt2GLFmt(This, pSrcSurface->resource.format)
12200+ ,D3DFmt2GLType(This, pSrcSurface->resource.format)
12201+ ,data/* could be quicker using */
12202+ );
12203+ data+=rowoffset;
12204+ }
12205+ }else{ /* Full width, so just write out the whole texture */
12206+ glTexSubImage2D( GL_TEXTURE_2D
12207+ ,pDestSurface->currentDesc.Level
12208+ ,destLeft
12209+ ,destTop
12210+ ,srcWidth
12211+ ,srcHeight
12212+ ,D3DFmt2GLFmt(This, pSrcSurface->resource.format)
12213+ ,D3DFmt2GLType(This, pSrcSurface->resource.format)
12214+ ,pSrcSurface->resource.allocatedMemory
12215+ );
12216+ }
12217+ checkGLcall("glTexSubImage2D");
12218+ glDisable(GL_TEXTURE_2D);
12219+ LEAVE_GL();
12220 return D3D_OK;
12221
12222 }
12223@@ -4194,39 +5506,164 @@
12224 return D3D_OK;
12225 }
12226
12227-HRESULT WINAPI IWineD3DDeviceImpl_DeletePatch(IWineD3DDevice *iface, UINT Handle){
12228+HRESULT WINAPI IWineD3DDeviceImpl_DeletePatch(IWineD3DDevice *iface, UINT Handle){
12229 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
12230 TRACE("(%p) Handle(%d)\n", This, Handle);
12231 FIXME("(%p) : Stub\n", This);
12232 return D3D_OK;
12233-}
12234+}
12235+
12236
12237 HRESULT WINAPI IWineD3DDeviceImpl_ColorFill(IWineD3DDevice *iface, IWineD3DSurface *pSurface, CONST D3DRECT* pRect, D3DCOLOR color){
12238- IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *) iface;
12239
12240- FIXME("(%p) : stub\n", This);
12241+ /* I couldn't find a 'really' quick way of doing this in openGl so here goes
12242+ fill a surface with a block of color! */
12243+
12244+ IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
12245+ /* TODO: get rid of the use of IWineD3DSurfaceImpl, move code into surface.c */
12246+ IWineD3DSurfaceImpl *surface = (IWineD3DSurfaceImpl *)pSurface;
12247+ IWineD3DSwapChainImpl *container = NULL;
12248+ BOOL isRenderTarget = FALSE;
12249+ unsigned int width,height;
12250+ unsigned int top,left;
12251+ unsigned int u, v;
12252+ DWORD *data;
12253+ TRACE("(%p) Colour fill Surface: %p rect: %p color: %ld\n", This, pSurface, pRect, color);
12254+
12255+ if(surface->resource.pool != D3DPOOL_DEFAULT){
12256+ FIXME("call to colorfill with non D3DPOOL_DEFAULT surface\n");
12257+ return D3DERR_INVALIDCALL;
12258+ }
12259+
12260+ /* TODO: get rid of IWineD3DSwapChainImpl reference, a 'context' manager may help with this */
12261+ IWineD3DSurface_GetContainer(pSurface, &IID_IWineD3DSwapChain, (void **)&container);
12262+
12263+ if(NULL != container || pSurface == This->renderTarget){
12264+ if(surface->resource.usage & D3DUSAGE_RENDERTARGET){
12265+
12266+ /* TODO: make sure we set everything back to the way it was, and context management!
12267+ glGetIntegerv(GL_READ_BUFFER, &prev_read);
12268+ vcheckGLcall("glIntegerv");
12269+ glGetIntegerv(GL_PACK_SWAP_BYTES, &prev_store);
12270+ vcheckGLcall("glIntegerv");
12271+ */
12272+ TRACE("Color fill to render targets may cause some graphics issues\n");
12273+
12274+ /* return D3D_OK; Try this if you get raster problems (or just implement state saving!)*/
12275+#ifndef USE_RENDER_MANAGER /* TODO: opengl context managers */
12276+ if(pSurface == container->frontBuffer){
12277+ glDrawBuffer(GL_FRONT);
12278+ }else{
12279+ glDrawBuffer(GL_BACK);
12280+ }
12281+ if(container != NULL){
12282+ IWineD3DSwapChain_Release((IWineD3DSwapChain *)container);
12283+ }
12284+#endif
12285+ }else{
12286+ if(pSurface != This->renderTarget && D3DUSAGE_DEPTHSTENCIL & surface->resource.usage){
12287+ FIXME("colouring of depth_stencil? %p buffers is not yet supported? %ld \n", surface, surface->resource.usage);
12288+ }else{
12289+ /* in theory we should never get here, but it has once so put some sanity checks in just incase it happens again */
12290+ if(pSurface == This->renderTarget){
12291+ FIXME("REGRESSION: This surface has been set as a render target, but doesn't have a usage of render target surface %p, usage %ld! \n",
12292+ surface, surface->resource.usage);
12293+ }else{
12294+ if(pSurface == container->frontBuffer || pSurface == container->backBuffer){
12295+ FIXME("REGRESSION: front or back buffer of the swapchain has invalid usage flags\n");
12296+ } if(container != NULL){
12297+ FIXME("REGRESSION: 'unknown' surface has swaphcain %p as parent (odd!) %p, usage %ld! \n",container,
12298+ surface, surface->resource.usage);
12299+ }else{
12300+ FIXME("REGRESSION: Trying to color an 'unknown' surface %p, usage %ld! \n",surface, surface->resource.usage);
12301+ }
12302+ }
12303+ }
12304+ /* we can use GL_STENCIL_INDEX etc...*/
12305+ return D3D_OK;
12306+ }
12307+ isRenderTarget = TRUE;
12308+ }
12309+ /* TODO: drawing to GL_FRONT and GL_BACK */
12310+
12311+ if(isRenderTarget == FALSE){
12312+ IWineD3DSurface_PreLoad(pSurface);
12313+ }
12314+ /* TODO: see if things can be speeded up by using the correct
12315+ * colour model of the target texture from the start (16 bit graphics on 32 X are slow anyway!) */
12316+ if(pRect == NULL){
12317+ top = 0;
12318+ left = 0;
12319+ width = surface->currentDesc.Width;
12320+ height = surface->currentDesc.Height;
12321+ }else{
12322+ left = pRect->x1;
12323+ top = pRect->y1;
12324+ width = pRect->x2 - left;
12325+ height = pRect->y2 - top;
12326+ }
12327+
12328+ data = HeapAlloc(GetProcessHeap(), 0, 4 * width);
12329+ /* Create a 'line' of color color, in the correct format for the surface */
12330+ for(u = 0 ; u < width ; u ++){
12331+ data[u] = color;
12332+ }
12333+
12334+ ENTER_GL();
12335+ if(isRenderTarget == FALSE){
12336+ glEnable(GL_TEXTURE_2D);
12337+ checkGLcall("glEnable");
12338+ glBindTexture(GL_TEXTURE_2D, surface->textureName);
12339+ checkGLcall("glBindTexture");
12340+
12341+ /* draw a block of that line on the sufrace */
12342+ for(v = 0 ; v< height;v++){
12343+ glTexSubImage2D( GL_TEXTURE_2D
12344+ ,0 /* level */
12345+ ,left
12346+ ,top + v
12347+ ,width
12348+ ,1 /* height */
12349+ ,GL_RGBA
12350+ ,GL_UNSIGNED_BYTE
12351+ ,data
12352+ );
12353+ }
12354+ checkGLcall("glTexSubImage2D"); /* only do this once not 1000 times in the loop! */
12355+
12356+ /* clean up */
12357+ glDisable(GL_TEXTURE_2D);
12358+ }else{
12359+ /** FIXME: Using GLClear may be faster **/
12360+ glRasterPos2i(left, top);
12361+ glPixelZoom((float)width ,(float)height);
12362+ glDrawPixels(1, 1, GL_RGBA, GL_UNSIGNED_BYTE, data);
12363+ checkGLcall("glDrawPixels");
12364+ }
12365+ HeapFree(GetProcessHeap(),0,data);
12366+ LEAVE_GL();
12367 return D3D_OK;
12368 }
12369
12370 /* rendertarget and deptth stencil functions */
12371 HRESULT WINAPI IWineD3DDeviceImpl_GetRenderTarget(IWineD3DDevice* iface,DWORD RenderTargetIndex, IWineD3DSurface **ppRenderTarget){
12372 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
12373-
12374+
12375 /* FIXME: Implelent RenderTargetIndex >0 */
12376 if(RenderTargetIndex > 0)
12377- FIXME("(%p) : RenderTargetIndex %ld >0 not currently supported\n", This, RenderTargetIndex);
12378-
12379- *ppRenderTarget = (IWineD3DSurface *)This->renderTarget;
12380+ FIXME("(%p) : RenderTargetIndex %ld >0 not currently supported\n",This,RenderTargetIndex);
12381+
12382+ *ppRenderTarget = This->renderTarget;
12383 TRACE("(%p) : RenderTarget %ld Index returning %p\n", This, RenderTargetIndex, *ppRenderTarget);
12384 /* Note inc ref on returned surface */
12385- if(*ppRenderTarget != NULL)
12386- IWineD3DSurface_AddRef(*ppRenderTarget);
12387+ IWineD3DSurface_AddRef(*ppRenderTarget);
12388 return D3D_OK;
12389 }
12390
12391+
12392 HRESULT WINAPI IWineD3DDeviceImpl_GetDepthStencilSurface(IWineD3DDevice* iface, IWineD3DSurface **ppZStencilSurface){
12393 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
12394- *ppZStencilSurface = (IWineD3DSurface *)This->depthStencilBuffer;
12395+ *ppZStencilSurface = This->depthStencilBuffer;
12396 TRACE("(%p) : zStencilSurface returning %p\n", This, *ppZStencilSurface);
12397
12398 if(*ppZStencilSurface != NULL){
12399@@ -4236,27 +5673,549 @@
12400 return D3D_OK;
12401 }
12402
12403+/* internal static helper functions */
12404+HRESULT WINAPI static IWineD3DDeviceImpl_ActiveRender(IWineD3DDevice* iface,
12405+ IWineD3DSurface *RenderSurface);
12406+
12407+HRESULT WINAPI static IWineD3DDeviceImpl_CleanRender(IWineD3DDevice* iface, IWineD3DSwapChainImpl *swapchain);
12408+
12409 HRESULT WINAPI IWineD3DDeviceImpl_SetRenderTarget(IWineD3DDevice *iface, DWORD RenderTargetIndex, IWineD3DSurface *pRenderTarget){
12410- IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *) iface;
12411+ IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
12412+ HRESULT hr = D3D_OK;
12413+ WINED3DVIEWPORT viewport;
12414
12415- FIXME("(%p) : stub\n", This);
12416- return D3D_OK;
12417+ DWORD startTime = 0;
12418+ if (TRACE_ON(d3d_timings))
12419+ startTime = GetTickCount();
12420+
12421+ TRACE("(%p) Swapping rendertarget\n",This);
12422+ if(RenderTargetIndex>0){
12423+ FIXME("(%p) Render targets other than the first are not supported\n",This);
12424+ RenderTargetIndex=0;
12425+ }
12426+
12427+ /* Hmm.. what does msdn say?, not a lot except that null disables the render target
12428+ but a device must always be associatated with a render target
12429+ nope MSDN says that we return invalid call to a null rendertarget with an index of 0
12430+
12431+ see http://msdn.microsoft.com/library/default.asp?url=/library/en-us/directx9_c/directx/graphics/programmingguide/AdvancedTopics/PixelPipe/MultipleRenderTarget.asp
12432+ for more details
12433+ */
12434+ if(RenderTargetIndex == 0 && pRenderTarget == NULL){
12435+ FIXME("Trying to set render target 0 to NULL\n");
12436+ return D3DERR_INVALIDCALL;
12437+ }
12438+ /* TODO: raplce Impl* usage with interface usage */
12439+ if(! ((IWineD3DSurfaceImpl *)pRenderTarget)->resource.usage & D3DUSAGE_RENDERTARGET){
12440+ FIXME("(%p)Trying to set the render target to a surface(%p) that wasn't created with a usage of D3DUSAGE_RENDERTARGET\n",This ,pRenderTarget);
12441+ return D3DERR_INVALIDCALL;
12442+ }
12443+ /** TODO: check that the depth stencil format matches the render target, this is only done in debug
12444+ * builds, but I think wine counts as a 'debug' build for now.
12445+ ******************************/
12446+ /* If we are trying to set what we already have, don't bother */
12447+ if (pRenderTarget == This->renderTarget) {
12448+ TRACE("Trying to do a NOP SetRenderTarget operation\n");
12449+ } else {
12450+ /* Otherwise, set the render target up */
12451+ TRACE("clearing renderer\n");
12452+ /* IWineD3DDeviceImpl_CleanRender(iface); */
12453+ /* OpenGL doesn't support 'sharing' of the stencilBuffer so we may incure an extra memory overhead
12454+ depending on the renter target implemenattion being used.
12455+ A shared context implementation will share all buffers between all rendertargets (including swapchains),
12456+ implemenations that use serperate pbuffers for different swapchains or rendertargets will have to duplicate the
12457+ stencil buffer and incure an extra memory overhead */
12458+ hr = IWineD3DDeviceImpl_ActiveRender(iface, pRenderTarget);
12459+ }
12460+
12461+ if (SUCCEEDED(hr)) {
12462+ /* Finally, reset the viewport as the MSDN states. */
12463+ /* TODO: Repalace impl usage */
12464+ viewport.Height = ((IWineD3DSurfaceImpl *)This->renderTarget)->currentDesc.Height;
12465+ viewport.Width = ((IWineD3DSurfaceImpl *)This->renderTarget)->currentDesc.Width;
12466+ viewport.X = 0;
12467+ viewport.Y = 0;
12468+ viewport.MaxZ = 1.0f;
12469+ viewport.MinZ = 0.0f;
12470+ IWineD3DDeviceImpl_SetViewport(iface, &viewport);
12471+ }else{
12472+ FIXME("Unknown error setting the render target\n");
12473+ }
12474+ if (TRACE_ON(d3d_timings))
12475+ TRACE_(d3d_timings)("(%p) starttime %ld, total time %ld\n", This, startTime , GetTickCount() -startTime);
12476+ return hr;
12477 }
12478
12479 HRESULT WINAPI IWineD3DDeviceImpl_SetDepthStencilSurface(IWineD3DDevice *iface, IWineD3DSurface *pNewZStencil){
12480- IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *) iface;
12481+ IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
12482+ HRESULT hr = D3D_OK;
12483+ WINED3DVIEWPORT viewport;
12484+ DWORD startTime = 0;
12485+ IWineD3DSurface *tmp;
12486+ if (TRACE_ON(d3d_timings))
12487+ startTime = GetTickCount();
12488+ TRACE("(%p) Swapping z-buffer\n",This);
12489+
12490+ if(pNewZStencil == This->stencilBufferTarget){
12491+ TRACE("Trying to do a NOP SetRenderTarget operation\n");
12492+ }else{
12493+ /** OpenGL doesn't support 'sharing' of the stencilBuffer so we may incure an extra memory overhead
12494+ * depending on the renter target implemenattion being used.
12495+ * A shared context implementation will share all buffers between all rendertargets (including swapchains),
12496+ * implemenations that use serperate pbuffers for different swapchains or rendertargets will have to duplicate the
12497+ * stencil buffer and incure an extra memory overhead
12498+ ******************************************************/
12499+
12500+
12501+ tmp = This->stencilBufferTarget;
12502+ This->stencilBufferTarget = pNewZStencil;
12503+ /* should we be calling the parent or the wined3d surface? */
12504+ if (NULL != This->stencilBufferTarget) IWineD3DSurface_AddRef(This->stencilBufferTarget);
12505+ if (NULL != tmp) IWineD3DSurface_Release(tmp);
12506+ hr = D3D_OK;
12507+ /** TODO: glEnable/glDisable on depth/stencil depending on
12508+ * pNewZStencil is NULL and the depth/stencil is enabled in d3d
12509+ **********************************************************/
12510+ }
12511+
12512+ if (SUCCEEDED(hr)) {
12513+ /* Finally, reset the viewport as the MSDN states.*/
12514+ /* TODO: get ridd of Impl usage */
12515+ viewport.Height = ((IWineD3DSurfaceImpl *)This->renderTarget)->currentDesc.Height;
12516+ viewport.Width = ((IWineD3DSurfaceImpl *)This->renderTarget)->currentDesc.Width;
12517+ viewport.X = 0;
12518+ viewport.Y = 0;
12519+ viewport.MaxZ = 1.0f;
12520+ viewport.MinZ = 0.0f;
12521+ IWineD3DDeviceImpl_SetViewport(iface, &viewport);
12522+ }
12523+
12524+ if (TRACE_ON(d3d_timings))
12525+ TRACE_(d3d_timings)("(%p) starttime %ld, total time %ld\n", This, startTime , GetTickCount() -startTime);
12526+ return hr;
12527+}
12528+
12529+
12530+/* Internal functions not in DirectX */
12531+ /** TODO: move this off to the opengl context manager
12532+ *(the swapchain doesn't need to know anything about offscreen rendering!)
12533+ ****************************************************/
12534+
12535+HRESULT WINAPI IWineD3DDeviceImpl_CleanRender(IWineD3DDevice* iface, IWineD3DSwapChainImpl *swapchain)
12536+{
12537+ IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
12538+ DWORD startTime = 0;
12539+ if (TRACE_ON(d3d_timings))
12540+ startTime = GetTickCount();
12541+#if defined(GL_VERSION_1_3) /* @see comments on ActiveRender */
12542+
12543+ TRACE("(%p), %p\n", This, swapchain);
12544+
12545+ if(swapchain->win != swapchain->drawable) {
12546+ ENTER_GL();
12547+ if(swapchain->glCtx != swapchain->render_ctx) {
12548+ FIXME("Destroying context %p \n", swapchain->render_ctx);
12549+ glXDestroyContext(swapchain->display, swapchain->render_ctx);
12550+
12551+ }
12552+ FIXME("glXDestroyPbuffer %ld \n", swapchain->drawable);
12553+ glXDestroyPbuffer(swapchain->display, swapchain->drawable);
12554+#endif
12555+ LEAVE_GL();
12556+ /* Set everything back to the way that it ws */
12557+ swapchain->render_ctx = swapchain->glCtx;
12558+ swapchain->drawable = swapchain->win;
12559+ }
12560+ if (TRACE_ON(d3d_timings))
12561+ TRACE_(d3d_timings)("(%p) starttime %ld, total time %ld\n", This, startTime , GetTickCount() -startTime);
12562+ return D3D_OK;
12563+}
12564+
12565+/** FIXME: This is currently used called whenever SetRenderTarget or SetStencilBuffer are called
12566+* the functiolaity needs splitting up so that we don't do more than we should do.
12567+* this only seems to affect performance a little.
12568+ ******************************/
12569+HRESULT WINAPI IWineD3DDeviceImpl_ActiveRender(IWineD3DDevice* iface,
12570+ IWineD3DSurface *RenderSurface) {
12571+ IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
12572+#ifndef USE_RENDER_MANAGER
12573+
12574+ IWineD3DSurface *StencilSurface = This->stencilBufferTarget;
12575+ HRESULT ret = D3DERR_INVALIDCALL;
12576+ /**
12577+ * Currently only active for GLX >= 1.3
12578+ * for others versions we'll have to use GLXPixmaps
12579+ *
12580+ * normally we must test GLX_VERSION_1_3 but nvidia headers are not correct
12581+ * as they implements GLX 1.3 but only define GLX_VERSION_1_2
12582+ * so only check OpenGL version
12583+ * ..........................
12584+ * I don't belive that it is a problem with NVidia headers,
12585+ * XFree only supports GLX1.2, nVidia (and ATI to some extent) provide 1.3 functions
12586+ * in GLX 1.2, there is no mention of the correct way to tell if the extensions are provided.
12587+ * ATI Note:
12588+ * Your application will report GLX version 1.2 on glXQueryVersion.
12589+ * However, it is safe to call the GLX 1.3 functions as described below.
12590+ */
12591+#if defined(GL_VERSION_1_3)
12592+
12593+ /** TODO: we only need to look up the configuration !IF! we are setting the target to a texture **/
12594+ GLXFBConfig* cfgs = NULL;
12595+ int nCfgs = 0;
12596+ int attribs[256];
12597+ int nAttribs = 0;
12598+ IWineD3DSwapChain *currentSwapchain;
12599+ IWineD3DSwapChainImpl *swapchain;
12600+ /** TODO: get rid of Impl usage we should always create a zbuffer/stencil with our contexts if pussible,
12601+ * but switch them off if the StencilSurface is set to NULL
12602+ ** *********************************************************/
12603+ D3DFORMAT BackBufferFormat = ((IWineD3DSurfaceImpl *) RenderSurface)->resource.format;
12604+ D3DFORMAT StencilBufferFormat = (NULL != StencilSurface) ? ((IWineD3DSurfaceImpl *) StencilSurface)->resource.format : 0;
12605+ UINT Width = ((IWineD3DSurfaceImpl *) RenderSurface)->currentDesc.Width;
12606+ UINT Height = ((IWineD3DSurfaceImpl *) RenderSurface)->currentDesc.Height;
12607+
12608+ IWineD3DSurface *tmp;
12609+
12610+ /**TODO:
12611+ if StencilSurface == NULL && zBufferTarget != NULL then swtich the zbuffer off,
12612+ it StencilSurface != NULL && zBufferTarget == NULL switch it on
12613+ */
12614+
12615+#define PUSH1(att) attribs[nAttribs++] = (att);
12616+#define PUSH2(att,value) attribs[nAttribs++] = (att); attribs[nAttribs++] = (value);
12617+
12618+ /* PUSH2(GLX_BIND_TO_TEXTURE_RGBA_ATI, True); examples of this are few and far between (but I've got a nice working one!)*/
12619+
12620+ /** TODO: remove the reff to Impl (context manager should fis this!) **/
12621+ IWineD3DSwapChainImpl *impSwapChain;
12622+ IWineD3DDevice_GetSwapChain(iface, 0, (IWineD3DSwapChain **)&impSwapChain);
12623+ if(NULL == impSwapChain){ /* NOTE: This should NEVER fail */
12624+ ERR("(%p) Failed to get a the implicite swapchain\n", iface);
12625+ }
12626+
12627+ ENTER_GL();
12628+
12629+ PUSH2(GLX_DRAWABLE_TYPE, GLX_PBUFFER_BIT);
12630+ PUSH2(GLX_X_RENDERABLE, TRUE);
12631+ PUSH2(GLX_DOUBLEBUFFER, TRUE);
12632+ TRACE("calling makeglcfg\n");
12633+ D3DFmtMakeGlCfg(BackBufferFormat, StencilBufferFormat, attribs, &nAttribs, FALSE /* alternate */);
12634+
12635+ PUSH1(None);
12636+
12637+
12638+ TRACE("calling chooseFGConfig\n");
12639+ cfgs = glXChooseFBConfig(impSwapChain->display, DefaultScreen(impSwapChain->display),
12640+ attribs, &nCfgs);
12641+
12642+ if(!cfgs){ /* OK we didn't find the exact config, so use any reasonably match */
12643+ /* TODO: fill in the 'requested' and 'current' depths, also make sure that's
12644+ why we failed and only show this message once! */
12645+ MESSAGE("Failed to find exact match, finding alternative but you may suffer performance issues, try changing xfree's depth to match the requested depth\n"); /**/
12646+ nAttribs = 0;
12647+ PUSH2(GLX_DRAWABLE_TYPE, GLX_PBUFFER_BIT | GLX_WINDOW_BIT);
12648+ /* PUSH2(GLX_X_RENDERABLE, TRUE); */
12649+ PUSH2(GLX_RENDER_TYPE, GLX_RGBA_BIT);
12650+ PUSH2(GLX_DOUBLEBUFFER, FALSE);
12651+ TRACE("calling makeglcfg\n");
12652+ D3DFmtMakeGlCfg(BackBufferFormat, StencilBufferFormat, attribs, &nAttribs, TRUE /* alternate */);
12653+ PUSH1(None);
12654+ cfgs = glXChooseFBConfig(impSwapChain->display, DefaultScreen(impSwapChain->display),
12655+ attribs, &nCfgs);
12656+ }
12657+
12658+#if 0
12659+ if (NULL != cfgs) {
12660+#if 0 /* find the best possible config (should try to get the closest match to the texture format */
12661+ int bestConfig = 0;
12662+ int minBits = 0x7FFFFFFF;
12663+ for (int i = 0; i < nConfigs; i++){
12664+ int red, green, blue, alpha, depth, stencil;
12665+ glXGetFBConfigAttrib(display, configs[i], GLX_RED_SIZE, &red);
12666+ glXGetFBConfigAttrib(display, configs[i], GLX_GREEN_SIZE, &green);
12667+ glXGetFBConfigAttrib(display, configs[i], GLX_BLUE_SIZE, &blue);
12668+ glXGetFBConfigAttrib(display, configs[i], GLX_ALPHA_SIZE, &alpha);
12669+ glXGetFBConfigAttrib(display, configs[i], GLX_DEPTH_SIZE, &depth);
12670+ glXGetFBConfigAttrib(display, configs[i], GLX_STENCIL_SIZE, &stencil);
12671+
12672+ int bits = red + green + blue + alpha + depth + stencil;
12673+ if (bits < minBits){
12674+ bestConfig = i;
12675+ minBits = bits;
12676+ }
12677+ }
12678+
12679+#endif
12680+ TRACE("found config\n");
12681+
12682+#ifdef EXTRA_TRACES
12683+ int i;
12684+ for (i = 0; i < nCfgs; ++i) {
12685+ TRACE("for (%u,%s)/(%u,%s) found config[%d]@%p\n", BackBufferFormat,
12686+ debug_d3dformat(BackBufferFormat), StencilBufferFormat,
12687+ debug_d3dformat(StencilBufferFormat), i, cfgs[i]);
12688+ }
12689+#endif
12690+#endif
12691+ if (NULL != This->renderTarget) {
12692+#ifdef EXTRA_TRACES
12693+ glFlush();
12694+ vcheckGLcall("glFlush");
12695+ /** This is only usefuly if the old render target was a swapchain,
12696+ * we need to supercede this with a function that displays
12697+ * the current buffer on the screen. This is easy to do in glx1.3 but
12698+ * we need to do copy-write pixels in glx 1.2.
12699+ ************************************************/
12700+ glXSwapBuffers(impSwapChain->display, impSwapChain->drawable);
12701+
12702+ printf("Hit Enter to get next frame ...\n");
12703+ getchar();
12704+#endif
12705+ }
12706+
12707+ if(IWineD3DSurface_GetContainer(This->renderTarget, &IID_IWineD3DSwapChain, (void **)&currentSwapchain) != D3D_OK){
12708+ /* the selected render target doesn't belong to a swapchain, so use the devices implicite swapchain */
12709+ IWineD3DDevice_GetSwapChain(iface, 0, &currentSwapchain);
12710+ }
12711+
12712+ /**
12713+ * TODO: remove the use of IWineD3DSwapChainImpl, a context manager will help since it will replace the
12714+ * renderTarget = swapchain->backBuffer bit and anything to do with *glContexts
12715+ **********************************************************************/
12716+ if(IWineD3DSurface_GetContainer(RenderSurface, &IID_IWineD3DSwapChain, (void **)&swapchain) == D3D_OK){
12717+ /* We also need to make sure that the lights &co are also in the context of the swapchains */
12718+ /* FIXME: If the render target gets sent to the frontBuffer should be be presenting it raw? */
12719+ TRACE("making swapchain active\n");
12720+ if(RenderSurface != This->renderTarget){
12721+ if(RenderSurface == swapchain->backBuffer){
12722+ } else {
12723+ /* This could be flagged so that some operations work directly with the front buffer */
12724+ FIXME("Attempting to set the renderTarget to the frontBuffer\n");
12725+ }
12726+ if(glXMakeCurrent(swapchain->display, swapchain->win, swapchain->glCtx)
12727+ == False) {
12728+ TRACE("Error in setting current context: context %p drawable %ld !\n",
12729+ impSwapChain->glCtx, impSwapChain->win);
12730+ }
12731+
12732+
12733+#if 1 /* TODO: apply the state block to the 'possibly' new context. */
12734+ if(1){
12735+ BOOL oldRecording;
12736+ IWineD3DStateBlockImpl *oldUpdateStateBlock;
12737+ oldUpdateStateBlock = This->updateStateBlock;
12738+ oldRecording= This->isRecordingState;
12739+ This->isRecordingState = FALSE;
12740+ This->updateStateBlock = This->stateBlock;
12741+ IWineD3DStateBlock_Apply((IWineD3DStateBlock *)This->stateBlock);
12742+
12743+ This->isRecordingState = oldRecording;
12744+ This->updateStateBlock = oldUpdateStateBlock;
12745+ }
12746+#endif
12747+
12748+#if 0 /* optionally */
12749+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
12750+#endif
12751+
12752+ IWineD3DDeviceImpl_CleanRender(iface, (IWineD3DSwapChainImpl *)currentSwapchain);
12753+ }
12754+ checkGLcall("glXMakeContextCurrent");
12755+
12756+ IWineD3DSwapChain_Release((IWineD3DSwapChain *)swapchain);
12757+ }else
12758+ if (FALSE && NULL != cfgs &&
12759+ (((IWineD3DSwapChainImpl *)currentSwapchain)->drawable == ((IWineD3DSwapChainImpl *)currentSwapchain)->win
12760+ || BackBufferFormat != ((IWineD3DSurfaceImpl *)This->renderTarget)->resource.format
12761+ || (Width > ((IWineD3DSurfaceImpl *)This->renderTarget)->currentDesc.Width
12762+ || Height > ((IWineD3DSurfaceImpl *)This->renderTarget)->currentDesc.Height))) {
12763+
12764+ /** ********************************************************************
12765+ * This code is far too leaky to be usefull IWineD3DDeviceImpl_CleanRender
12766+ * doesn't seem to work properly and creating a new context Every time is 'extream' overkill.
12767+ * The code does however work, and should be moved to a context manager to
12768+ * manage caching of pbuffers or render to texture are appropriate.
12769+ *
12770+ * There are some real speed vs compatability issues here:
12771+ * we should really use a new context for every texture, but that eats ram.
12772+ * we should also be restoring the texture to the pbuffer but that eats CPU
12773+ * we can also 'reuse' the current pbuffer if the size is larger than the requested buffer,
12774+ * but if this means reusing the display backbuffer then we need to make sure that
12775+ * states are correctly preserved.
12776+ * In many cases I would expect that we can 'skip' some functions, such as preserving states,
12777+ * and gain a good performance increase at the cost of compatability.
12778+ * I would suggest that, when this is the case, a user configurable flag be made
12779+ * available, alowing the user to choose the best emmulated experiance for them.
12780+ *********************************************************************/
12781+
12782+ /**
12783+ * TODO: support for faces of cube textures, possibly volumes
12784+ * (this should be easy for ATI as I have examples)
12785+ **/
12786+
12787+ GLXContext newContext;
12788+ Drawable newDrawable;
12789+ XVisualInfo *visinfo;
12790+
12791+ TRACE("making new buffer\n");
12792+ nAttribs = 0;
12793+ PUSH2(GLX_PBUFFER_WIDTH, Width);
12794+ PUSH2(GLX_PBUFFER_HEIGHT, Height);
12795+
12796+#if 0 /* ATI render to texture support */
12797+ PUSH2(GLX_LARGEST_PBUFFER, True);/* This is ignored by ATI */
12798+ PUSH2(GLX_TEXTURE_FORMAT_ATI, GLX_TEXTURE_RGBA_ATI);
12799+ PUSH2(GLX_TEXTURE_TARGET_ATI, cubemap? GLX_TEXTURE_CUBE_MAP_ATI : GLX_TEXTURE_2D_ATI);
12800+ PUSH2(GLX_MIPMAP_TEXTURE_ATI, mipmapped? True : False);
12801+#endif
12802+
12803+#if 0
12804+ /* TODO: discardable Pbuffer */
12805+ PUSH2(GLX_PRESERVED_CONTENTS, FALSE);
12806+#endif
12807+
12808+ PUSH1(None);
12809+ newDrawable = glXCreatePbuffer(impSwapChain->display, cfgs[0], attribs);
12810+
12811+ /** ****************************************
12812+ *GLX1.3 isn't supported by XFree 'yet' untill that point ATI emulates pBuffers
12813+ *they note:
12814+ * In future releases, we may provide the calls glXCreateNewContext,
12815+ * glXQueryDrawable and glXMakeContextCurrent.
12816+ * so until then we have to use glXGetVisualFromFBConfig &co..
12817+ ********************************************/
12818+
12819+#define CREATE_ATI_STYLE 1
12820+#if CREATE_ATI_STYLE
12821+ visinfo = glXGetVisualFromFBConfig(impSwapChain->display, cfgs[0]);
12822+ if (!visinfo) {
12823+ ERR("Error: couldn't get an RGBA, double-buffered visual\n");
12824+ }
12825+ newContext = glXCreateContext(impSwapChain->display, visinfo, impSwapChain->glCtx, GL_TRUE);
12826+ XFree(visinfo);
12827+#else
12828+ newContext = glXCreateNewContext(impSwapChain->display, cfgs[0], GLX_RGBA_TYPE, impSwapChain->glCtx, TRUE);
12829+
12830+#endif
12831+
12832+ /* Make sure that the sorface exists as a glTexture */
12833+ IWineD3DSurface_PreLoad(RenderSurface);
12834+
12835+#if 0 /* preload must do this for us, if it isn't then fix it. untill then here's some 'debug' code. */
12836+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, Width, Height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
12837+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE_EXT);
12838+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE_EXT);
12839+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
12840+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
12841+#endif
12842+
12843+ newContext = glXCreateNewContext(impSwapChain->display, cfgs[0], GLX_RGBA_TYPE, impSwapChain->glCtx, TRUE);
12844+
12845+ if (NULL == newContext) {
12846+ ERR("cannot create glxContext\n");
12847+ }else{
12848+ /* Debug logging, (this function leaks), change to a TRACE when the leak is plugged */
12849+ FIXME("Created context %p drawable %ld \n", newContext, newDrawable);
12850+#if 1 /* If we set the context textures don't load properly, even if they come from memory, but why? */
12851+#if CREATE_ATI_STYLE
12852+ if (glXMakeCurrent(impSwapChain->display, newDrawable, newContext) == False) {
12853+#else
12854+ if (glXMakeContextCurrent(impSwapChain->display, newDrawable, newDrawable, newContext) == False) {
12855+#endif
12856+ TRACE("Error in setting current context: context %p drawable %ld\n", newContext, newDrawable);
12857+ }
12858+#endif
12859+ /* TODO: find out what of the current context needs to be coppied accross */
12860+
12861+ checkGLcall("glXMakeContextCurrent");
12862+
12863+ /* clean renderer should become part of the context manager so I'm not goint to put in in SwapChain just to remove it */
12864+ IWineD3DDeviceImpl_CleanRender(iface, (IWineD3DSwapChainImpl *)currentSwapchain);
12865+ /** TODO: We may need to copy the bits into the buffer,
12866+ * this should !!ONLY!! be done if an operation is performed on the target
12867+ * without it being cleared and the buffer is not discardable.
12868+ * (basicly only bother preserving the contents if there's a possiblity that it will be reused)
12869+ ** *********************************************************************/
12870+ impSwapChain->drawable = newDrawable;
12871+ impSwapChain->render_ctx = newContext;
12872+
12873+ }
12874+
12875+ }
12876+ /* clean up the current rendertargets swapchain (if it belonged to one) */
12877+ if (currentSwapchain != NULL){
12878+ IWineD3DSwapChain_Release((IWineD3DSwapChain *)currentSwapchain);
12879+ }
12880+
12881+ /* Were done with the opengl context management, setup the rendertargets */
12882+
12883+ tmp = This->renderTarget;
12884+ This->renderTarget = RenderSurface;
12885+ IWineD3DSurface_AddRef(This->renderTarget);
12886+ IWineD3DSurface_Release(tmp);
12887+
12888+
12889+
12890+ {
12891+ DWORD value;
12892+ /* The surface must be rendered upside down to cancel the flip produce by glCopyTexImage */
12893+ /* Check that the container is not a swapchain member */
12894+
12895+ IWineD3DSwapChain *tmpSwapChain;
12896+ if(D3D_OK != IWineD3DSurface_GetContainer(This->renderTarget, &IID_IWineD3DSwapChain, (void **)&tmpSwapChain)){
12897+ This->renderUpsideDown = TRUE;
12898+ }else{
12899+ This->renderUpsideDown = FALSE;
12900+ IWineD3DSwapChain_Release(tmpSwapChain);
12901+ }
12902+ /* Force updating the cull mode */
12903+ TRACE("setting render state\n");
12904+ IWineD3DDevice_GetRenderState(iface, WINED3DRS_CULLMODE, &value);
12905+ IWineD3DDevice_SetRenderState(iface, WINED3DRS_CULLMODE, value);
12906+
12907+ /* Force updating projection matrix */
12908+ This->last_was_rhw = FALSE;
12909+ This->proj_valid = FALSE;
12910+ }
12911+
12912+ ret = D3D_OK;
12913+
12914+ if(cfgs != NULL){
12915+ XFree(cfgs);
12916+ } else {
12917+ ERR("cannot get valides GLXFBConfig for (%u,%s)/(%u,%s)\n", BackBufferFormat,
12918+ debug_d3dformat(BackBufferFormat), StencilBufferFormat, debug_d3dformat(StencilBufferFormat));
12919+ }
12920+
12921+#undef PUSH1
12922+#undef PUSH2
12923+ if( NULL != impSwapChain) {
12924+ IWineD3DSwapChain_Release((IWineD3DSwapChain *)impSwapChain);
12925+ }
12926+ LEAVE_GL();
12927+
12928+#endif
12929+#else
12930+
12931+ IWineD3DSurface *tmp;
12932+ /* This should be handled outside of this function */
12933+ tmp = This->renderTarget;
12934+ This->renderTarget = RenderSurface;
12935+ IWineD3DSurface_AddRef(This->renderTarget);
12936+ IWineD3DSurface_Release( tmp);
12937+ tmp = This->stencilBufferTarget;
12938+ This->stencilBufferTarget = StencilSurface;
12939+
12940+#endif
12941+ return ret;
12942
12943- FIXME("(%p) : stub\n", This);
12944- return D3D_OK;
12945 }
12946
12947 HRESULT WINAPI IWineD3DDeviceImpl_SetCursorProperties(IWineD3DDevice* iface, UINT XHotSpot,
12948 UINT YHotSpot, IWineD3DSurface *pCursorBitmap) {
12949- IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *) iface;
12950- /* TODO: the use of Impl is deprecated. */
12951- /* some basic validation checks */
12952+ IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *) iface;
12953 IWineD3DSurfaceImpl * pSur = (IWineD3DSurfaceImpl *) pCursorBitmap;
12954-
12955+ /* some basic validation checks */
12956 TRACE("(%p) : Spot Pos(%u,%u)\n", This, XHotSpot, YHotSpot);
12957
12958 if (WINED3DFMT_A8R8G8B8 != pSur->resource.format) {
12959@@ -4268,37 +6227,38 @@
12960 return D3DERR_INVALIDCALL;
12961 }
12962 /* TODO: make the cursor 'real' */
12963-
12964+
12965 This->xHotSpot = XHotSpot;
12966 This->yHotSpot = YHotSpot;
12967-
12968- return D3D_OK;
12969+
12970+ return D3D_OK;
12971 }
12972
12973 void WINAPI IWineD3DDeviceImpl_SetCursorPosition(IWineD3DDevice* iface, int XScreenSpace, int YScreenSpace, DWORD Flags) {
12974 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *) iface;
12975 TRACE("(%p) : SetPos to (%u,%u)\n", This, XScreenSpace, YScreenSpace);
12976-
12977+
12978 This->xScreenSpace = XScreenSpace;
12979 This->yScreenSpace = YScreenSpace;
12980-
12981+
12982 return;
12983
12984 }
12985
12986 BOOL WINAPI IWineD3DDeviceImpl_ShowCursor(IWineD3DDevice* iface, BOOL bShow) {
12987- IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *) iface;
12988+ IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *) iface;
12989 TRACE("(%p) : visible(%d)\n", This, bShow);
12990-
12991+
12992 This->bCursorVisible = bShow;
12993-
12994- return D3D_OK;
12995+
12996+ return D3D_OK;
12997 }
12998
12999 HRESULT WINAPI IWineD3DDeviceImpl_TestCooperativeLevel(IWineD3DDevice* iface) {
13000 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *) iface;
13001 FIXME("(%p) : stub\n", This); /* No way of notifying yet! */
13002 return D3D_OK;
13003+
13004 }
13005
13006
13007@@ -4319,7 +6279,7 @@
13008 * textures out of video memory and deletes all glTextures (glDeleteTextures)
13009 * and should clear down the context and set it up according to pPresentationParameters
13010 ***********************************************************/
13011- FIXME("(%p) : stub\n", This);
13012+ FIXME("(%p) : stub\n", This);
13013 return D3D_OK;
13014 }
13015
13016@@ -4329,43 +6289,132 @@
13017 if(bEnableDialogs == FALSE){
13018 FIXME("(%p) Dialogs cannot be disabled yet\n", This);
13019 }
13020- return D3D_OK;
13021+ return D3D_OK;
13022 }
13023
13024
13025 HRESULT WINAPI IWineD3DDeviceImpl_GetCreationParameters(IWineD3DDevice *iface, D3DDEVICE_CREATION_PARAMETERS *pParameters) {
13026 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *) iface;
13027-
13028+
13029 FIXME("(%p) : stub\n", This);
13030 /* Setup some reasonable defaults */
13031 pParameters->AdapterOrdinal = 0; /* always for now */
13032 pParameters->DeviceType = D3DDEVTYPE_HAL; /* always for now */
13033 pParameters->hFocusWindow = 0;
13034- pParameters->BehaviorFlags =0;
13035+ pParameters->BehaviorFlags =0;
13036 return D3D_OK;
13037 }
13038
13039+void WINAPI IWineD3DDeviceImpl_GetGammaRamp(IWineD3DDevice *iface, UINT iSwapChain, D3DGAMMARAMP* pRamp) {
13040+
13041+ IWineD3DSwapChain *swapchain;
13042+ HRESULT hrc = D3D_OK;
13043+
13044+ TRACE("Relaying to swapchain\n");
13045+
13046+ if((hrc = IWineD3DDeviceImpl_GetSwapChain(iface, iSwapChain, &swapchain)) == D3D_OK){
13047+ hrc =IWineD3DSwapChain_GetGammaRamp(swapchain, pRamp);
13048+ IWineD3DSwapChain_Release(swapchain);
13049+ }
13050+ return;
13051+
13052+}
13053+
13054 void WINAPI IWineD3DDeviceImpl_SetGammaRamp(IWineD3DDevice * iface, UINT iSwapChain, DWORD Flags, CONST D3DGAMMARAMP* pRamp) {
13055- HDC hDC;
13056- IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *) iface;
13057-
13058- FIXME("(%p) : pRamp@%p\n", This, pRamp);
13059- hDC = GetDC(This->win_handle);
13060- SetDeviceGammaRamp(hDC, (LPVOID) pRamp);
13061- ReleaseDC(This->win_handle, hDC);
13062+
13063+ IWineD3DSwapChain *swapchain;
13064+ HRESULT hrc = D3D_OK;
13065+
13066+ TRACE("Relaying to swapchain\n");
13067+
13068+ if((hrc = IWineD3DDeviceImpl_GetSwapChain(iface, iSwapChain, &swapchain)) == D3D_OK){
13069+ IWineD3DSwapChain_SetGammaRamp(swapchain, Flags, (D3DGAMMARAMP *)pRamp);
13070+ IWineD3DSwapChain_Release(swapchain);
13071+ }
13072 return;
13073+
13074 }
13075+/** ********************************************************
13076+* Notification functions
13077+** ********************************************************/
13078+#if 0 /** TODO: notification **/
13079+/** This function must be called in the release of a resource when ref == 0,
13080+* the contents of resource must still be correct,
13081+* any handels to other resource held by the caller must be closed
13082+* (e.g. a texture should release all held surfaces because telling the device that it's been released.)
13083+ *****************************************************/
13084+void IWineD3DDeviceImpl_ResourceReleased(IWineD3DDevice *iface, IWineD3DResource *resource){
13085
13086-void WINAPI IWineD3DDeviceImpl_GetGammaRamp(IWineD3DDevice *iface, UINT iSwapChain, D3DGAMMARAMP* pRamp) {
13087- HDC hDC;
13088 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *) iface;
13089+#if 0
13090+ switch(IWineD3DResource_GetType(resource)){
13091+ case D3DRESOURCE_SURFACE:
13092+ /* TODO: check front and back buffers, rendertargets etc.. possibly swapchains? */
13093+ break;
13094+ case D3DRTYPE_TEXTURE:
13095+ case D3DRTYPE_CUBETEXTURE:
13096+ case D3DRTYPE_VOLUMETEXTURE:
13097+
13098+ /* TODO: nothing really? */
13099+ break;
13100+ case D3DRTYPE_VERTEXBUFFER:
13101+ int streamNumber;
13102+ for(streamNumber = 0; streamNumber < MAX_STREAMS; streamNumber ++){
13103+ /* FINDOUT: should a warn be generated if were recording and updateStateBlock->streamSource is lost?
13104+ FINDOUT: should changes.streamSource[StreamNumber] be set ?
13105+ */
13106+ if((IWineD3DResource *)This->updateStateBlock->streamSource[StreamNumber] == vertexBuffer){
13107+ This->updateStateBlock->streamSource[StreamNumber] = 0;
13108+ }
13109+ if((IWineD3DResource *)This->stateBlock->streamSource[StreamNumber] == vertexBuffer){
13110+ This->updateStateBlock->streamSource[StreamNumber] = 0;
13111+ }
13112+
13113+ }
13114+ break;
13115+ case D3DRTYPE_INDEXBUFFER:
13116+
13117+ break;
13118+ }
13119+
13120+ HRESULT hr;
13121+ /* Remove the resoruce from the resourceStore */
13122+ IListOperator *listOperator;
13123+ IListStore_CreateListOperator(This->resourceStore, &listOperator);
13124+ hr = IListOperator_remove(listOperator, (void *)object);
13125+ if(hr != D3D_OK){
13126+ FIXME("failed to remove %p from the list\n", object);
13127+ }
13128+ IListOperator_Release(listOperator);
13129+#else
13130+ FIXME("stub\n");
13131+#endif
13132+
13133+}
13134+
13135+/** This function is to be called by the swapchain when it is released and it's ref = 0
13136+ *****************************************************/
13137+void IWineD3DDeviceImpl_SwapChainReleased(IWineD3DDevice *iface, IWineD3DSwapChain *swapChain){
13138+ IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *) iface;
13139+#if 0
13140+ /** TODO: Use a list operator to remove the swapcahin from the swapchainstore,
13141+ * check rendertargets still in use **/
13142+ /* Remove the resoruce from the resourceStore */
13143+ IListOperator *listOperator;
13144+ IListStore_CreateListOperator(This->swapChainStore, &listOperator);
13145+ hr = IListOperator_remove(listOperator, (void *)object);
13146+ if(hr != D3D_OK){
13147+ FIXME("failed to remove %p from the list\n", object);
13148+ }
13149+ IListOperator_Release(listOperator);
13150+#else
13151+ FIXME("stub\n");
13152+#endif
13153+
13154
13155- FIXME("(%p) : pRamp@%p\n", This, pRamp);
13156- hDC = GetDC(This->win_handle);
13157- GetDeviceGammaRamp(hDC, pRamp);
13158- ReleaseDC(This->win_handle, hDC);
13159- return;
13160 }
13161+#endif
13162+
13163
13164 /**********************************************************
13165 * IWineD3DDevice VTbl follows
13166@@ -4393,9 +6442,9 @@
13167 IWineD3DDeviceImpl_CreateVertexDeclaration,
13168 IWineD3DDeviceImpl_CreateVertexShader,
13169 IWineD3DDeviceImpl_CreatePixelShader,
13170-
13171+
13172 /*** Odd functions **/
13173- IWineD3DDeviceImpl_EvictManagedResources,
13174+ IWineD3DDeviceImpl_EvictManagedResources,
13175 IWineD3DDeviceImpl_GetAvailableTextureMem,
13176 IWineD3DDeviceImpl_GetBackBuffer,
13177 IWineD3DDeviceImpl_GetCreationParameters,
13178@@ -4423,9 +6472,9 @@
13179 IWineD3DDeviceImpl_SetFVF,
13180 IWineD3DDeviceImpl_GetFVF,
13181 IWineD3DDeviceImpl_SetGammaRamp,
13182- IWineD3DDeviceImpl_GetGammaRamp,
13183+ IWineD3DDeviceImpl_GetGammaRamp,
13184 IWineD3DDeviceImpl_SetIndices,
13185- IWineD3DDeviceImpl_GetIndices,
13186+ IWineD3DDeviceImpl_GetIndices,
13187 IWineD3DDeviceImpl_SetLight,
13188 IWineD3DDeviceImpl_GetLight,
13189 IWineD3DDeviceImpl_SetLightEnable,
13190@@ -4433,7 +6482,7 @@
13191 IWineD3DDeviceImpl_SetMaterial,
13192 IWineD3DDeviceImpl_GetMaterial,
13193 IWineD3DDeviceImpl_SetNPatchMode,
13194- IWineD3DDeviceImpl_GetNPatchMode,
13195+ IWineD3DDeviceImpl_GetNPatchMode,
13196 IWineD3DDeviceImpl_SetPaletteEntries,
13197 IWineD3DDeviceImpl_GetPaletteEntries,
13198 IWineD3DDeviceImpl_SetPixelShader,
13199@@ -4459,7 +6508,7 @@
13200 IWineD3DDeviceImpl_SetStreamSourceFreq,
13201 IWineD3DDeviceImpl_GetStreamSourceFreq,
13202 IWineD3DDeviceImpl_SetTexture,
13203- IWineD3DDeviceImpl_GetTexture,
13204+ IWineD3DDeviceImpl_GetTexture,
13205 IWineD3DDeviceImpl_SetTextureStageState,
13206 IWineD3DDeviceImpl_GetTextureStageState,
13207 IWineD3DDeviceImpl_SetTransform,
13208@@ -4503,4 +6552,114 @@
13209 IWineD3DDeviceImpl_GetFrontBufferData,
13210 /*** Internal use IWineD3DDevice methods ***/
13211 IWineD3DDeviceImpl_SetupTextureStates
13212+ /*** Notification functions ***/
13213+#if 0 /* TODO: part of the interface cleanup work */
13214+ IWineD3DDeviceImpl_ResourceReleased,
13215+ IWineD3DDeviceImpl_SwapChainReleased
13216+#endif
13217+};
13218+
13219+
13220+DWORD SavedPixelStates_R[NUM_SAVEDPIXELSTATES_R] = {
13221+ WINED3DRS_ALPHABLENDENABLE ,
13222+ WINED3DRS_ALPHAFUNC ,
13223+ WINED3DRS_ALPHAREF ,
13224+ WINED3DRS_ALPHATESTENABLE ,
13225+ WINED3DRS_BLENDOP ,
13226+ WINED3DRS_COLORWRITEENABLE ,
13227+ WINED3DRS_DESTBLEND ,
13228+ WINED3DRS_DITHERENABLE ,
13229+ WINED3DRS_FILLMODE ,
13230+ WINED3DRS_FOGDENSITY ,
13231+ WINED3DRS_FOGEND ,
13232+ WINED3DRS_FOGSTART ,
13233+ WINED3DRS_LASTPIXEL ,
13234+ WINED3DRS_SHADEMODE ,
13235+ WINED3DRS_SRCBLEND ,
13236+ WINED3DRS_STENCILENABLE ,
13237+ WINED3DRS_STENCILFAIL ,
13238+ WINED3DRS_STENCILFUNC ,
13239+ WINED3DRS_STENCILMASK ,
13240+ WINED3DRS_STENCILPASS ,
13241+ WINED3DRS_STENCILREF ,
13242+ WINED3DRS_STENCILWRITEMASK ,
13243+ WINED3DRS_STENCILZFAIL ,
13244+ WINED3DRS_TEXTUREFACTOR ,
13245+ WINED3DRS_WRAP0 ,
13246+ WINED3DRS_WRAP1 ,
13247+ WINED3DRS_WRAP2 ,
13248+ WINED3DRS_WRAP3 ,
13249+ WINED3DRS_WRAP4 ,
13250+ WINED3DRS_WRAP5 ,
13251+ WINED3DRS_WRAP6 ,
13252+ WINED3DRS_WRAP7 ,
13253+ WINED3DRS_ZENABLE ,
13254+ WINED3DRS_ZFUNC ,
13255+ WINED3DRS_ZWRITEENABLE
13256+};
13257+
13258+DWORD SavedPixelStates_T[NUM_SAVEDPIXELSTATES_T] = {
13259+ D3DTSS_ADDRESSW ,
13260+ D3DTSS_ALPHAARG0 ,
13261+ D3DTSS_ALPHAARG1 ,
13262+ D3DTSS_ALPHAARG2 ,
13263+ D3DTSS_ALPHAOP ,
13264+ D3DTSS_BUMPENVLOFFSET ,
13265+ D3DTSS_BUMPENVLSCALE ,
13266+ D3DTSS_BUMPENVMAT00 ,
13267+ D3DTSS_BUMPENVMAT01 ,
13268+ D3DTSS_BUMPENVMAT10 ,
13269+ D3DTSS_BUMPENVMAT11 ,
13270+ D3DTSS_COLORARG0 ,
13271+ D3DTSS_COLORARG1 ,
13272+ D3DTSS_COLORARG2 ,
13273+ D3DTSS_COLOROP ,
13274+ D3DTSS_RESULTARG ,
13275+ D3DTSS_TEXCOORDINDEX ,
13276+ D3DTSS_TEXTURETRANSFORMFLAGS
13277+};
13278+
13279+DWORD SavedPixelStates_S[NUM_SAVEDPIXELSTATES_S] = {
13280+};
13281+
13282+DWORD SavedVertexStates_R[NUM_SAVEDVERTEXSTATES_R] = {
13283+ WINED3DRS_AMBIENT ,
13284+ WINED3DRS_AMBIENTMATERIALSOURCE ,
13285+ WINED3DRS_CLIPPING ,
13286+ WINED3DRS_CLIPPLANEENABLE ,
13287+ WINED3DRS_COLORVERTEX ,
13288+ WINED3DRS_DIFFUSEMATERIALSOURCE ,
13289+ WINED3DRS_EMISSIVEMATERIALSOURCE ,
13290+ WINED3DRS_FOGDENSITY ,
13291+ WINED3DRS_FOGEND ,
13292+ WINED3DRS_FOGSTART ,
13293+ WINED3DRS_FOGTABLEMODE ,
13294+ WINED3DRS_FOGVERTEXMODE ,
13295+ WINED3DRS_INDEXEDVERTEXBLENDENABLE ,
13296+ WINED3DRS_LIGHTING ,
13297+ WINED3DRS_LOCALVIEWER ,
13298+ WINED3DRS_MULTISAMPLEANTIALIAS ,
13299+ WINED3DRS_MULTISAMPLEMASK ,
13300+ WINED3DRS_NORMALIZENORMALS ,
13301+ WINED3DRS_PATCHEDGESTYLE ,
13302+ WINED3DRS_POINTSCALE_A ,
13303+ WINED3DRS_POINTSCALE_B ,
13304+ WINED3DRS_POINTSCALE_C ,
13305+ WINED3DRS_POINTSCALEENABLE ,
13306+ WINED3DRS_POINTSIZE ,
13307+ WINED3DRS_POINTSIZE_MAX ,
13308+ WINED3DRS_POINTSIZE_MIN ,
13309+ WINED3DRS_POINTSPRITEENABLE ,
13310+ WINED3DRS_RANGEFOGENABLE ,
13311+ WINED3DRS_SPECULARMATERIALSOURCE ,
13312+ WINED3DRS_TWEENFACTOR ,
13313+ WINED3DRS_VERTEXBLEND
13314+};
13315+
13316+DWORD SavedVertexStates_T[NUM_SAVEDVERTEXSTATES_T] = {
13317+ D3DTSS_TEXCOORDINDEX ,
13318+ D3DTSS_TEXTURETRANSFORMFLAGS
13319+};
13320+
13321+DWORD SavedVertexStates_S[NUM_SAVEDVERTEXSTATES_S] = {
13322 };
13323diff -urN wine.20050419/dlls/wined3d/directx.c wine.20050419.dx9/dlls/wined3d/directx.c
13324--- wine.20050419/dlls/wined3d/directx.c 2005-03-29 12:01:00.000000000 -0700
13325+++ wine.20050419.dx9/dlls/wined3d/directx.c 2005-04-20 01:52:56.000000000 -0600
13326@@ -4,6 +4,7 @@
13327 * Copyright 2002-2004 Jason Edmeades
13328 * Copyright 2003-2004 Raphael Junqueira
13329 * Copyright 2004 Christian Costa
13330+ * Copyright 2005 Oliver Stieber
13331 *
13332 * This library is free software; you can redistribute it and/or
13333 * modify it under the terms of the GNU Lesser General Public
13334@@ -31,6 +32,9 @@
13335
13336 WINE_DEFAULT_DEBUG_CHANNEL(d3d);
13337 WINE_DECLARE_DEBUG_CHANNEL(d3d_caps);
13338+extern long DeviceMemory;
13339+static long DeviceMemory = 0; /*Only look this up once!*/
13340+
13341 #define GLINFO_LOCATION This->gl_info
13342
13343 /**********************************************************
13344@@ -57,6 +61,12 @@
13345 return display;
13346 }
13347
13348+
13349+long int IWineD3DImpl_CalculateGraphicsMemory( int maxAlloc);
13350+void IWineD3DImpl_CheckGraphicsMemory(void);
13351+
13352+
13353+
13354 /**
13355 * Note: GL seems to trap if GetDeviceCaps is called before any HWND's created
13356 * ie there is no GL Context - Get a default rendering context to enable the
13357@@ -65,7 +75,7 @@
13358 static WineD3D_Context* WineD3D_CreateFakeGLContext(void) {
13359 static WineD3D_Context ctx = { NULL, NULL, NULL, 0, 0 };
13360 WineD3D_Context* ret = NULL;
13361-
13362+ TRACE("Creating fake context\n");
13363 if (glXGetCurrentContext() == NULL) {
13364 BOOL gotContext = FALSE;
13365 BOOL created = FALSE;
13366@@ -112,6 +122,7 @@
13367 }
13368
13369 /* Make it the current GL context */
13370+ /* What happens if were already rendering? */
13371 if (!failed && glXMakeCurrent(ctx.display, ctx.drawable, ctx.glCtx) == False) {
13372 glXDestroyContext(ctx.display, ctx.glCtx);
13373 LEAVE_GL();
13374@@ -140,6 +151,7 @@
13375 /* If we created a dummy context, throw it away */
13376 if (NULL != ctx) {
13377 if (0 == InterlockedDecrement(&ctx->ref)) {
13378+ TRACE("Destroying fake context\n");
13379 glXMakeCurrent(ctx->display, None, NULL);
13380 glXDestroyContext(ctx->display, ctx->glCtx);
13381 ctx->display = NULL;
13382@@ -183,6 +195,8 @@
13383 TRACE("(%p) : Releasing from %ld\n", This, This->ref);
13384 ref = InterlockedDecrement(&This->ref);
13385 if (ref == 0) {
13386+ /* release the critical section */
13387+ DeleteCriticalSection(&This->wined3dCriticalSection);
13388 HeapFree(GetProcessHeap(), 0, This);
13389 }
13390
13391@@ -204,6 +218,9 @@
13392
13393 TRACE_(d3d_caps)("(%p, %p)\n", gl_info, display);
13394
13395+
13396+
13397+
13398 /* Fill in the GL info retrievable depending on the display */
13399 if (NULL != display) {
13400 test = glXQueryVersion(display, &major, &minor);
13401@@ -222,6 +239,12 @@
13402 gl_info->gl_vendor = VENDOR_WINE;
13403 }
13404
13405+
13406+ #if 0
13407+ /*auxiliery buffers would be great for speeding up rendering to offscreens (if the graphics card support them!)*/
13408+ glGetIntegerv(GL_AUX_BUFFERS, &gl_max);
13409+ FIXME("Maximum number of auxiliery buffers %d\n" , gl_max);
13410+ #endif
13411 TRACE_(d3d_caps)("found GL_VENDOR (%s)->(0x%04x)\n", debugstr_a(gl_string), gl_info->gl_vendor);
13412
13413 /* Parse the GL_VERSION field into major and minor information */
13414@@ -275,13 +298,6 @@
13415 if (error)
13416 gl_string_cursor = 0;
13417 }
13418-
13419- if (!gl_string_cursor)
13420- WARN_(d3d_caps)("malformed GL_VERSION (%s)\n", debugstr_a(gl_string));
13421- else {
13422- major = *gl_string_cursor - '0';
13423- minor = (*(gl_string_cursor+2) - '0') * 256 + (*(gl_string_cursor+4) - '0');
13424- }
13425 break;
13426
13427 default:
13428@@ -347,7 +363,11 @@
13429 glGetIntegerv(GL_MAX_LIGHTS, &gl_max);
13430 gl_info->max_lights = gl_max;
13431 TRACE_(d3d_caps)("Lights support - max lights=%d\n", gl_max);
13432-
13433+#if 0
13434+ glGetIntegerv(MAX_DRAW_BUFFERS_ATI, &gl_max);
13435+ TRACE_(d3d_caps)("Render targets supported - max render targets=%d\n", gl_max);
13436+ gl_info->max_render_targets = gl_max;
13437+#endif
13438 /* Parse the gl supported features, in theory enabling parts of our code appropriately */
13439 GL_Extensions = glGetString(GL_EXTENSIONS);
13440 TRACE_(d3d_caps)("GL_Extensions reported:\n");
13441@@ -404,6 +424,14 @@
13442 } else if (strcmp(ThisExtn, "GL_ARB_texture_mirrored_repeat") == 0) {
13443 TRACE_(d3d_caps)(" FOUND: ARB Texture mirrored repeat support\n");
13444 gl_info->supported[ARB_TEXTURE_MIRRORED_REPEAT] = TRUE;
13445+ } else if (strcmp(ThisExtn, "GLX_ARB_multisample") == 0) {
13446+ TRACE_(d3d_caps)(" FOUND: ARB multisample support\n");
13447+ gl_info->supported[ARB_MULTISAMPLE] = TRUE;
13448+#if 0
13449+ } else if (strcmp(ThisExtn, "GL_ARB_point_sprite") == 0) {
13450+ TRACE_(d3d_caps)(" FOUND: ARB point sprint support\n");
13451+ gl_info->supported[ARB_POINT_SPRITE] = TRUE;
13452+#endif
13453 } else if (strstr(ThisExtn, "GL_ARB_vertex_program")) {
13454 gl_info->vs_arb_version = VS_VERSION_11;
13455 TRACE_(d3d_caps)(" FOUND: ARB Vertex Shader support - version=%02x\n", gl_info->vs_arb_version);
13456@@ -457,6 +485,11 @@
13457 } else if (strcmp(ThisExtn, "GL_EXT_vertex_weighting") == 0) {
13458 TRACE_(d3d_caps)(" FOUND: EXT Vertex weighting support\n");
13459 gl_info->supported[EXT_VERTEX_WEIGHTING] = TRUE;
13460+ } else if (strcmp(ThisExtn, "GL_EXT_texture_filter_anisotropic") == 0) {
13461+ TRACE_(d3d_caps)(" FOUND: EXT anisotropic filtering support\n");
13462+ gl_info->supported[EXT_TEXTURE_FILTER_ANISOTROPIC] = TRUE;
13463+
13464+
13465
13466 /**
13467 * NVIDIA
13468@@ -508,6 +541,20 @@
13469 gl_info->vs_ati_version = VS_VERSION_11;
13470 TRACE_(d3d_caps)(" FOUND: ATI (EXT) Vertex Shader support - version=%02x\n", gl_info->vs_ati_version);
13471 gl_info->supported[EXT_VERTEX_SHADER] = TRUE;
13472+#if 0
13473+ } else if (strcmp(ThisExtn, "GL_ATI_draw_buffers") == 0){
13474+ TRACE_(d3d_caps)(" FOUND: ATI draw buffers support\n");
13475+ gl_info->supported[GL_ATI_DRAW_BUFFERS] = TRUE;
13476+ } else if (strcmp(ThisExtn, "GL_SGIS_generate_mipmap\n"){
13477+ TRACE_(d3d_caps)(" FOUND: SGIS generate mipmaps support\n");
13478+ gl_info->supported[GL_SGIS_GENERATE_MIPMAPS] = TRUE;
13479+ } else if(strcmp(ThisExtn, "GLX_ATI_pixel_format_float\n"){
13480+ TRACE_(d3d_caps)(" FOUND ATI pixel format float support\n");
13481+ gl_info->supported[GLX_ATI_PIXEL_FORMAT_FLOAT] = TRUE;
13482+ } else if(strcmp(ThisExtn, "GLX_ATI_render_texture\n"){
13483+ TRACE_(d3d_caps)(" FOUND: ATI render to texture support\n");
13484+ gl_info->supported[GLX_ATI_RENDER_TEXTURE] = TRUE;
13485+#endif
13486 }
13487
13488
13489@@ -762,7 +809,7 @@
13490 pMode->Width = DevModeW.dmPelsWidth;
13491 pMode->Height = DevModeW.dmPelsHeight;
13492 bpp = DevModeW.dmBitsPerPel;
13493- pMode->RefreshRate = D3DADAPTER_DEFAULT;
13494+ pMode->RefreshRate = 80; /* D3DADAPTER_DEFAULT; */
13495 if (DevModeW.dmFields&DM_DISPLAYFREQUENCY)
13496 {
13497 pMode->RefreshRate = DevModeW.dmDisplayFrequency;
13498@@ -1029,7 +1076,7 @@
13499 HRESULT WINAPI IWineD3DImpl_CheckDeviceFormatConversion(IWineD3D *iface, UINT Adapter, D3DDEVTYPE DeviceType, WINED3DFORMAT SourceFormat, WINED3DFORMAT TargetFormat) {
13500 IWineD3DImpl *This = (IWineD3DImpl *)iface;
13501
13502- FIXME_(d3d_caps)("(%p)-> (STUB) (Adptr:%d, DevType:(%u,%s), SrcFmt:(%u,%s), TgtFmt:(%u,%s))",
13503+ FIXME_(d3d_caps)("(%p)-> (STUB) (Adptr:%d, DevType:(%u,%s), SrcFmt:(%u,%s), TgtFmt:(%u,%s))\n",
13504 This,
13505 Adapter,
13506 DeviceType, debug_d3ddevicetype(DeviceType),
13507@@ -1040,22 +1087,27 @@
13508
13509 /* Note: d3d8 passes in a pointer to a D3DCAPS8 structure, which is a true
13510 subset of a D3DCAPS9 structure. However, it has to come via a void *
13511- as the d3d8 interface cannot import the d3d9 header */
13512-HRESULT WINAPI IWineD3DImpl_GetDeviceCaps(IWineD3D *iface, UINT Adapter, D3DDEVTYPE DeviceType, WINED3DCAPS* pCapsIn) {
13513+ as the d3d8 interface cannot import the d3d9 header
13514+ see http://msdn.microsoft.com/archive/default.asp?url=/archive/en-us/directx9_c/directx/graphics/reference/d3d/structures/d3dcaps9.asp
13515+ */
13516+ /* This is buggy if no window or device is created */
13517+HRESULT WINAPI IWineD3DImpl_GetDeviceCaps(IWineD3D *iface, UINT Adapter, D3DDEVTYPE DeviceType, WINED3DCAPS* pCaps) {
13518
13519 IWineD3DImpl *This = (IWineD3DImpl *)iface;
13520 BOOL gotContext = FALSE;
13521 GLint gl_tex_size = 0;
13522 WineD3D_Context *fake_ctx = NULL;
13523- D3DCAPS9 *pCaps = (D3DCAPS9 *)pCapsIn;
13524
13525+ /*TODO: only do this once per adapter please! */
13526 TRACE_(d3d_caps)("(%p)->(Adptr:%d, DevType: %x, pCaps: %p)\n", This, Adapter, DeviceType, pCaps);
13527
13528 if (Adapter >= IWineD3D_GetAdapterCount(iface)) {
13529 return D3DERR_INVALIDCALL;
13530 }
13531
13532- /* Note: GL seems to trap if GetDeviceCaps is called before any HWND's created
13533+ /* Note: GL seems to trap if GetDeviceCaps is c
13534+trace:d3d9:IDirect3DSurface9Impl_Release (0x4048e928) : ReleaseRef to 2
13535+alled before any HWND's created
13536 ie there is no GL Context - Get a default rendering context to enable the
13537 function query some info from GL */
13538 if (glXGetCurrentContext() == NULL) {
13539@@ -1069,18 +1121,20 @@
13540
13541 FIXME_(d3d_caps)("GetDeviceCaps called but no GL Context - Returning dummy values\n");
13542 gl_tex_size=65535;
13543- pCaps->MaxTextureBlendStages = 2;
13544- pCaps->MaxSimultaneousTextures = 2;
13545- pCaps->MaxUserClipPlanes = 8;
13546- pCaps->MaxActiveLights = 8;
13547- pCaps->MaxVertexBlendMatrices = 0;
13548- pCaps->MaxVertexBlendMatrixIndex = 1;
13549- pCaps->MaxAnisotropy = 0;
13550- pCaps->MaxPointSize = 255.0;
13551+ *pCaps->MaxTextureBlendStages = 2;
13552+ *pCaps->MaxSimultaneousTextures = 2;
13553+ *pCaps->MaxUserClipPlanes = 8;
13554+ *pCaps->MaxActiveLights = 8;
13555+ *pCaps->MaxVertexBlendMatrices = 0;
13556+ *pCaps->MaxVertexBlendMatrixIndex = 1;
13557+ *pCaps->MaxAnisotropy = 0;
13558+ *pCaps->MaxPointSize = 255.0;
13559+
13560 } else {
13561 glGetIntegerv(GL_MAX_TEXTURE_SIZE, &gl_tex_size);
13562 }
13563
13564+
13565 /* If we don't know the device settings, go query them now */
13566 if (This->isGLInfoValid == FALSE) {
13567 BOOL rc = IWineD3DImpl_FillGLCaps(&This->gl_info, NULL);
13568@@ -1092,21 +1146,23 @@
13569 /* ------------------------------------------------
13570 The following fields apply to both d3d8 and d3d9
13571 ------------------------------------------------ */
13572- pCaps->DeviceType = (DeviceType == D3DDEVTYPE_HAL) ? D3DDEVTYPE_HAL : D3DDEVTYPE_REF; /* Not quite true, but use h/w supported by opengl I suppose */
13573- pCaps->AdapterOrdinal = Adapter;
13574+ *pCaps->DeviceType = (DeviceType == D3DDEVTYPE_HAL) ? D3DDEVTYPE_HAL : D3DDEVTYPE_REF; /* Not quite true, but use h/w supported by opengl I suppose */
13575+ *pCaps->AdapterOrdinal = Adapter;
13576+
13577+ *pCaps->Caps = 0;
13578+ *pCaps->Caps2 = D3DCAPS2_CANRENDERWINDOWED;
13579+ *pCaps->Caps3 = D3DDEVCAPS_HWTRANSFORMANDLIGHT;
13580+ *pCaps->PresentationIntervals = D3DPRESENT_INTERVAL_IMMEDIATE;
13581
13582- pCaps->Caps = 0;
13583- pCaps->Caps2 = D3DCAPS2_CANRENDERWINDOWED;
13584- pCaps->Caps3 = D3DDEVCAPS_HWTRANSFORMANDLIGHT;
13585- pCaps->PresentationIntervals = D3DPRESENT_INTERVAL_IMMEDIATE;
13586+ *pCaps->CursorCaps = 0;
13587
13588- pCaps->CursorCaps = 0;
13589
13590- pCaps->DevCaps = D3DDEVCAPS_DRAWPRIMTLVERTEX |
13591+ *pCaps->DevCaps = D3DDEVCAPS_DRAWPRIMTLVERTEX |
13592 D3DDEVCAPS_HWTRANSFORMANDLIGHT |
13593 D3DDEVCAPS_PUREDEVICE;
13594
13595- pCaps->PrimitiveMiscCaps = D3DPMISCCAPS_CULLCCW |
13596+
13597+ *pCaps->PrimitiveMiscCaps = D3DPMISCCAPS_CULLCCW |
13598 D3DPMISCCAPS_CULLCW |
13599 D3DPMISCCAPS_COLORWRITEENABLE |
13600 D3DPMISCCAPS_CLIPTLVERTS |
13601@@ -1114,7 +1170,7 @@
13602 D3DPMISCCAPS_MASKZ;
13603 /*NOT: D3DPMISCCAPS_TSSARGTEMP*/
13604
13605- pCaps->RasterCaps = D3DPRASTERCAPS_DITHER |
13606+ *pCaps->RasterCaps = D3DPRASTERCAPS_DITHER |
13607 D3DPRASTERCAPS_PAT |
13608 D3DPRASTERCAPS_WFOG |
13609 D3DPRASTERCAPS_ZFOG |
13610@@ -1123,18 +1179,18 @@
13611 D3DPRASTERCAPS_FOGRANGE;
13612
13613 if (GL_SUPPORT(EXT_TEXTURE_FILTER_ANISOTROPIC)) {
13614- pCaps->RasterCaps |= D3DPRASTERCAPS_ANISOTROPY;
13615+ *pCaps->RasterCaps |= D3DPRASTERCAPS_ANISOTROPY |
13616+ D3DPRASTERCAPS_ZBIAS |
13617+ D3DPRASTERCAPS_MIPMAPLODBIAS;
13618 }
13619 /* FIXME Add:
13620- D3DPRASTERCAPS_MIPMAPLODBIAS
13621- D3DPRASTERCAPS_ZBIAS
13622 D3DPRASTERCAPS_COLORPERSPECTIVE
13623 D3DPRASTERCAPS_STRETCHBLTMULTISAMPLE
13624 D3DPRASTERCAPS_ANTIALIASEDGES
13625 D3DPRASTERCAPS_ZBUFFERLESSHSR
13626 D3DPRASTERCAPS_WBUFFER */
13627
13628- pCaps->ZCmpCaps = D3DPCMPCAPS_ALWAYS |
13629+ *pCaps->ZCmpCaps = D3DPCMPCAPS_ALWAYS |
13630 D3DPCMPCAPS_EQUAL |
13631 D3DPCMPCAPS_GREATER |
13632 D3DPCMPCAPS_GREATEREQUAL |
13633@@ -1143,89 +1199,100 @@
13634 D3DPCMPCAPS_NEVER |
13635 D3DPCMPCAPS_NOTEQUAL;
13636
13637- pCaps->SrcBlendCaps = 0xFFFFFFFF; /*FIXME: Tidy up later */
13638- pCaps->DestBlendCaps = 0xFFFFFFFF; /*FIXME: Tidy up later */
13639- pCaps->AlphaCmpCaps = 0xFFFFFFFF; /*FIXME: Tidy up later */
13640+ *pCaps->SrcBlendCaps = 0xFFFFFFFF; /*FIXME: Tidy up later */
13641+ *pCaps->DestBlendCaps = 0xFFFFFFFF; /*FIXME: Tidy up later */
13642+ *pCaps->AlphaCmpCaps = 0xFFFFFFFF; /*FIXME: Tidy up later */
13643
13644- pCaps->ShadeCaps = D3DPSHADECAPS_SPECULARGOURAUDRGB |
13645+ *pCaps->ShadeCaps = D3DPSHADECAPS_SPECULARGOURAUDRGB |
13646 D3DPSHADECAPS_COLORGOURAUDRGB;
13647
13648- pCaps->TextureCaps = D3DPTEXTURECAPS_ALPHA |
13649+ *pCaps->TextureCaps = D3DPTEXTURECAPS_ALPHA |
13650 D3DPTEXTURECAPS_ALPHAPALETTE |
13651- D3DPTEXTURECAPS_POW2 |
13652 D3DPTEXTURECAPS_VOLUMEMAP |
13653 D3DPTEXTURECAPS_MIPMAP |
13654- D3DPTEXTURECAPS_PROJECTED;
13655+ D3DPTEXTURECAPS_PROJECTED |
13656+ D3DPTEXTURECAPS_PERSPECTIVE |
13657+ D3DPTEXTURECAPS_VOLUMEMAP_POW2 ;
13658+ /* TODO: add support for NON-POW2 if avaialble
13659+
13660+ */
13661+ if (This->dxVersion > 8){
13662+ *pCaps->TextureCaps |= D3DPTEXTURECAPS_NONPOW2CONDITIONAL;
13663+
13664+ }else{ /* NONPOW2 isn't accessable by d3d8 yet */
13665+ *pCaps->TextureCaps |= D3DPTEXTURECAPS_POW2;
13666+ }
13667
13668 if (GL_SUPPORT(ARB_TEXTURE_CUBE_MAP)) {
13669- pCaps->TextureCaps |= D3DPTEXTURECAPS_CUBEMAP |
13670+ *pCaps->TextureCaps |= D3DPTEXTURECAPS_CUBEMAP |
13671 D3DPTEXTURECAPS_MIPCUBEMAP |
13672 D3DPTEXTURECAPS_CUBEMAP_POW2;
13673+
13674 }
13675
13676- pCaps->TextureFilterCaps = D3DPTFILTERCAPS_MAGFLINEAR |
13677+ *pCaps->TextureFilterCaps = D3DPTFILTERCAPS_MAGFLINEAR |
13678 D3DPTFILTERCAPS_MAGFPOINT |
13679 D3DPTFILTERCAPS_MINFLINEAR |
13680 D3DPTFILTERCAPS_MINFPOINT |
13681 D3DPTFILTERCAPS_MIPFLINEAR |
13682 D3DPTFILTERCAPS_MIPFPOINT;
13683
13684- pCaps->CubeTextureFilterCaps = 0;
13685- pCaps->VolumeTextureFilterCaps = 0;
13686+ *pCaps->CubeTextureFilterCaps = 0;
13687+ *pCaps->VolumeTextureFilterCaps = 0;
13688
13689- pCaps->TextureAddressCaps = D3DPTADDRESSCAPS_BORDER |
13690+ *pCaps->TextureAddressCaps = D3DPTADDRESSCAPS_BORDER |
13691 D3DPTADDRESSCAPS_CLAMP |
13692 D3DPTADDRESSCAPS_WRAP;
13693
13694 if (GL_SUPPORT(ARB_TEXTURE_BORDER_CLAMP)) {
13695- pCaps->TextureAddressCaps |= D3DPTADDRESSCAPS_BORDER;
13696+ *pCaps->TextureAddressCaps |= D3DPTADDRESSCAPS_BORDER;
13697 }
13698 if (GL_SUPPORT(ARB_TEXTURE_MIRRORED_REPEAT)) {
13699- pCaps->TextureAddressCaps |= D3DPTADDRESSCAPS_MIRROR;
13700+ *pCaps->TextureAddressCaps |= D3DPTADDRESSCAPS_MIRROR;
13701 }
13702 if (GL_SUPPORT(ATI_TEXTURE_MIRROR_ONCE)) {
13703- pCaps->TextureAddressCaps |= D3DPTADDRESSCAPS_MIRRORONCE;
13704+ *pCaps->TextureAddressCaps |= D3DPTADDRESSCAPS_MIRRORONCE;
13705 }
13706
13707- pCaps->VolumeTextureAddressCaps = 0;
13708+ *pCaps->VolumeTextureAddressCaps = 0;
13709
13710- pCaps->LineCaps = D3DLINECAPS_TEXTURE |
13711+ *pCaps->LineCaps = D3DLINECAPS_TEXTURE |
13712 D3DLINECAPS_ZTEST;
13713 /* FIXME: Add
13714 D3DLINECAPS_BLEND
13715 D3DLINECAPS_ALPHACMP
13716 D3DLINECAPS_FOG */
13717
13718- pCaps->MaxTextureWidth = gl_tex_size;
13719- pCaps->MaxTextureHeight = gl_tex_size;
13720+ *pCaps->MaxTextureWidth = gl_tex_size;
13721+ *pCaps->MaxTextureHeight = gl_tex_size;
13722
13723- pCaps->MaxVolumeExtent = 0;
13724+ *pCaps->MaxVolumeExtent = 0;
13725
13726- pCaps->MaxTextureRepeat = 32768;
13727- pCaps->MaxTextureAspectRatio = 32768;
13728- pCaps->MaxVertexW = 1.0;
13729+ *pCaps->MaxTextureRepeat = 32768;
13730+ *pCaps->MaxTextureAspectRatio = 32768;
13731+ *pCaps->MaxVertexW = 1.0;
13732
13733- pCaps->GuardBandLeft = 0;
13734- pCaps->GuardBandTop = 0;
13735- pCaps->GuardBandRight = 0;
13736- pCaps->GuardBandBottom = 0;
13737+ *pCaps->GuardBandLeft = 0;
13738+ *pCaps->GuardBandTop = 0;
13739+ *pCaps->GuardBandRight = 0;
13740+ *pCaps->GuardBandBottom = 0;
13741
13742- pCaps->ExtentsAdjust = 0;
13743+ *pCaps->ExtentsAdjust = 0;
13744
13745- pCaps->StencilCaps = D3DSTENCILCAPS_DECRSAT |
13746+ *pCaps->StencilCaps = D3DSTENCILCAPS_DECRSAT |
13747 D3DSTENCILCAPS_INCRSAT |
13748 D3DSTENCILCAPS_INVERT |
13749 D3DSTENCILCAPS_KEEP |
13750 D3DSTENCILCAPS_REPLACE |
13751 D3DSTENCILCAPS_ZERO;
13752 if (GL_SUPPORT(EXT_STENCIL_WRAP)) {
13753- pCaps->StencilCaps |= D3DSTENCILCAPS_DECR |
13754+ *pCaps->StencilCaps |= D3DSTENCILCAPS_DECR |
13755 D3DSTENCILCAPS_INCR;
13756 }
13757
13758- pCaps->FVFCaps = D3DFVFCAPS_PSIZE | 0x0008; /* 8 texture coords */
13759+ *pCaps->FVFCaps = D3DFVFCAPS_PSIZE | 0x0008; /* 8 texture coords */
13760
13761- pCaps->TextureOpCaps = D3DTEXOPCAPS_ADD |
13762+ *pCaps->TextureOpCaps = D3DTEXOPCAPS_ADD |
13763 D3DTEXOPCAPS_ADDSIGNED |
13764 D3DTEXOPCAPS_ADDSIGNED2X |
13765 D3DTEXOPCAPS_MODULATE |
13766@@ -1235,20 +1302,20 @@
13767 D3DTEXOPCAPS_SELECTARG2 |
13768 D3DTEXOPCAPS_DISABLE;
13769 #if defined(GL_VERSION_1_3)
13770- pCaps->TextureOpCaps |= D3DTEXOPCAPS_DOTPRODUCT3 |
13771+ *pCaps->TextureOpCaps |= D3DTEXOPCAPS_DOTPRODUCT3 |
13772 D3DTEXOPCAPS_SUBTRACT;
13773 #endif
13774 if (GL_SUPPORT(ARB_TEXTURE_ENV_COMBINE) ||
13775 GL_SUPPORT(EXT_TEXTURE_ENV_COMBINE) ||
13776 GL_SUPPORT(NV_TEXTURE_ENV_COMBINE4)) {
13777- pCaps->TextureOpCaps |= D3DTEXOPCAPS_BLENDDIFFUSEALPHA |
13778+ *pCaps->TextureOpCaps |= D3DTEXOPCAPS_BLENDDIFFUSEALPHA |
13779 D3DTEXOPCAPS_BLENDTEXTUREALPHA |
13780 D3DTEXOPCAPS_BLENDFACTORALPHA |
13781 D3DTEXOPCAPS_BLENDCURRENTALPHA |
13782 D3DTEXOPCAPS_LERP;
13783 }
13784 if (GL_SUPPORT(NV_TEXTURE_ENV_COMBINE4)) {
13785- pCaps->TextureOpCaps |= D3DTEXOPCAPS_ADDSMOOTH |
13786+ *pCaps->TextureOpCaps |= D3DTEXOPCAPS_ADDSMOOTH |
13787 D3DTEXOPCAPS_MULTIPLYADD |
13788 D3DTEXOPCAPS_MODULATEALPHA_ADDCOLOR |
13789 D3DTEXOPCAPS_MODULATECOLOR_ADDALPHA |
13790@@ -1256,7 +1323,7 @@
13791 }
13792
13793 #if 0
13794- pCaps->TextureOpCaps |= D3DTEXOPCAPS_BUMPENVMAP;
13795+ *pCaps->TextureOpCaps |= D3DTEXOPCAPS_BUMPENVMAP;
13796 /* FIXME: Add
13797 D3DTEXOPCAPS_BUMPENVMAPLUMINANCE
13798 D3DTEXOPCAPS_PREMODULATE */
13799@@ -1271,38 +1338,38 @@
13800 glGetIntegerv(GL_MAX_TEXTURE_UNITS_ARB, &gl_max);
13801 #endif
13802 TRACE_(d3d_caps)("GLCaps: GL_MAX_TEXTURE_UNITS_ARB=%d\n", gl_max);
13803- pCaps->MaxTextureBlendStages = min(8, gl_max);
13804- pCaps->MaxSimultaneousTextures = min(8, gl_max);
13805+ *pCaps->MaxTextureBlendStages = min(8, gl_max);
13806+ *pCaps->MaxSimultaneousTextures = min(8, gl_max);
13807
13808 glGetIntegerv(GL_MAX_CLIP_PLANES, &gl_max);
13809- pCaps->MaxUserClipPlanes = min(D3DMAXUSERCLIPPLANES, gl_max);
13810- TRACE_(d3d_caps)("GLCaps: GL_MAX_CLIP_PLANES=%ld\n", pCaps->MaxUserClipPlanes);
13811+ *pCaps->MaxUserClipPlanes = min(D3DMAXUSERCLIPPLANES, gl_max);
13812+ TRACE_(d3d_caps)("GLCaps: GL_MAX_CLIP_PLANES=%ld\n", *pCaps->MaxUserClipPlanes);
13813
13814 glGetIntegerv(GL_MAX_LIGHTS, &gl_max);
13815- pCaps->MaxActiveLights = gl_max;
13816- TRACE_(d3d_caps)("GLCaps: GL_MAX_LIGHTS=%ld\n", pCaps->MaxActiveLights);
13817+ *pCaps->MaxActiveLights = gl_max;
13818+ TRACE_(d3d_caps)("GLCaps: GL_MAX_LIGHTS=%ld\n", *pCaps->MaxActiveLights);
13819
13820 if (GL_SUPPORT(ARB_VERTEX_BLEND)) {
13821 glGetIntegerv(GL_MAX_VERTEX_UNITS_ARB, &gl_max);
13822- pCaps->MaxVertexBlendMatrices = gl_max;
13823- pCaps->MaxVertexBlendMatrixIndex = 1;
13824+ *pCaps->MaxVertexBlendMatrices = gl_max;
13825+ *pCaps->MaxVertexBlendMatrixIndex = 1;
13826 } else {
13827- pCaps->MaxVertexBlendMatrices = 0;
13828- pCaps->MaxVertexBlendMatrixIndex = 1;
13829+ *pCaps->MaxVertexBlendMatrices = 0;
13830+ *pCaps->MaxVertexBlendMatrixIndex = 1;
13831 }
13832
13833 if (GL_SUPPORT(EXT_TEXTURE_FILTER_ANISOTROPIC)) {
13834 glGetIntegerv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &gl_max);
13835- pCaps->MaxAnisotropy = gl_max;
13836+ *pCaps->MaxAnisotropy = gl_max;
13837 } else {
13838- pCaps->MaxAnisotropy = 0;
13839+ *pCaps->MaxAnisotropy = 0;
13840 }
13841
13842 glGetFloatv(GL_POINT_SIZE_RANGE, &gl_float);
13843- pCaps->MaxPointSize = gl_float;
13844+ *pCaps->MaxPointSize = gl_float;
13845 }
13846
13847- pCaps->VertexProcessingCaps = D3DVTXPCAPS_DIRECTIONALLIGHTS |
13848+ *pCaps->VertexProcessingCaps = D3DVTXPCAPS_DIRECTIONALLIGHTS |
13849 D3DVTXPCAPS_MATERIALSOURCE7 |
13850 D3DVTXPCAPS_POSITIONALLIGHTS |
13851 D3DVTXPCAPS_LOCALVIEWER |
13852@@ -1310,57 +1377,90 @@
13853 /* FIXME: Add
13854 D3DVTXPCAPS_TWEENING */
13855
13856- pCaps->MaxPrimitiveCount = 0xFFFFFFFF;
13857- pCaps->MaxVertexIndex = 0xFFFFFFFF;
13858- pCaps->MaxStreams = MAX_STREAMS;
13859- pCaps->MaxStreamStride = 1024;
13860+ *pCaps->MaxPrimitiveCount = 0xFFFFFFFF;
13861+ *pCaps->MaxVertexIndex = 0xFFFFFFFF;
13862+ *pCaps->MaxStreams = MAX_STREAMS;
13863+ *pCaps->MaxStreamStride = 1024;
13864
13865 if (((vs_mode == VS_HW) && GL_SUPPORT(ARB_VERTEX_PROGRAM)) || (vs_mode == VS_SW) || (DeviceType == D3DDEVTYPE_REF)) {
13866- pCaps->VertexShaderVersion = D3DVS_VERSION(1,1);
13867+ *pCaps->VertexShaderVersion = D3DVS_VERSION(1,1);
13868
13869 if (This->gl_info.gl_vendor == VENDOR_MESA ||
13870 This->gl_info.gl_vendor == VENDOR_WINE) {
13871- pCaps->MaxVertexShaderConst = 95;
13872+ *pCaps->MaxVertexShaderConst = 95;
13873 } else {
13874- pCaps->MaxVertexShaderConst = WINED3D_VSHADER_MAX_CONSTANTS;
13875+ *pCaps->MaxVertexShaderConst = WINED3D_VSHADER_MAX_CONSTANTS;
13876 }
13877 } else {
13878- pCaps->VertexShaderVersion = 0;
13879- pCaps->MaxVertexShaderConst = 0;
13880+ *pCaps->VertexShaderVersion = 0;
13881+ *pCaps->MaxVertexShaderConst = 0;
13882 }
13883
13884 if ((ps_mode == PS_HW) && GL_SUPPORT(ARB_FRAGMENT_PROGRAM) && (DeviceType != D3DDEVTYPE_REF)) {
13885- pCaps->PixelShaderVersion = D3DPS_VERSION(1,4);
13886- pCaps->MaxPixelShaderValue = 1.0;
13887+ *pCaps->PixelShaderVersion = D3DPS_VERSION(1,4);
13888+ #if 0 /*FIXME: d3d8*/
13889+ *pCaps->MaxPixelShaderValue = 1.0;
13890+ #endif
13891 } else {
13892- pCaps->PixelShaderVersion = 0;
13893- pCaps->MaxPixelShaderValue = 0.0;
13894+ *pCaps->PixelShaderVersion = 0;
13895+ #if 0 /*FIXME: d3d8*/
13896+ *pCaps->MaxPixelShaderValue = 0.0;
13897+ #endif
13898 }
13899+ /* TODO: ARB_FRAGMENT_PROGRAM_100 */
13900
13901 /* ------------------------------------------------
13902 The following fields apply to d3d9 only
13903 ------------------------------------------------ */
13904 if (This->dxVersion > 8) {
13905- FIXME("Caps support for directx9 is nonexistent at the moment!\n");
13906- pCaps->DevCaps2 = 0;
13907- pCaps->MaxNpatchTessellationLevel = 0;
13908- pCaps->MasterAdapterOrdinal = 0;
13909- pCaps->AdapterOrdinalInGroup = 0;
13910- pCaps->NumberOfAdaptersInGroup = 1;
13911- pCaps->DeclTypes = 0;
13912- pCaps->NumSimultaneousRTs = 0;
13913- pCaps->StretchRectFilterCaps = 0;
13914- pCaps->VS20Caps.Caps = 0;
13915- pCaps->PS20Caps.Caps = 0;
13916- pCaps->VertexTextureFilterCaps = 0;
13917- pCaps->MaxVShaderInstructionsExecuted = 0;
13918- pCaps->MaxPShaderInstructionsExecuted = 0;
13919- pCaps->MaxVertexShader30InstructionSlots = 0;
13920- pCaps->MaxPixelShader30InstructionSlots = 0;
13921+ GLint max_buffers=1;
13922+
13923+ TRACE("Caps support for directx9 is non-existent at the moment!\n");
13924+ *pCaps->DevCaps2 = 0;
13925+ /* TODO: add support for, this may have to be done in software though, so should be optional?
13926+ D3DDEVCAPS2_CAN_STRETCHRECT_FROM_TEXTURES
13927+
13928+ */
13929+ *pCaps->MaxNpatchTessellationLevel = 0;
13930+ *pCaps->MasterAdapterOrdinal = 0;
13931+ *pCaps->AdapterOrdinalInGroup = 0;
13932+ *pCaps->NumberOfAdaptersInGroup = 1;
13933+ *pCaps->DeclTypes = 0;
13934+ #if 0 /*FIXME: Simultaneous render targets*/
13935+ #ifndef GL_MAX_DRAW_BUFFERS_ATI
13936+ #define GL_MAX_DRAW_BUFFERS_ATI 0x00008824
13937+ #endif
13938+ ENTER_GL();
13939+/* if(GL_SUPPORT(GL_MAX_DRAW_BUFFERS_ATI) ){ */
13940+ glEnable(GL_MAX_DRAW_BUFFERS_ATI);
13941+ glGetIntegerv(GL_MAX_DRAW_BUFFERS_ATI, &max_buffers);
13942+ glDisable(GL_MAX_DRAW_BUFFERS_ATI);
13943+ FIXME("Setting maxbuffers to %d\n", max_buffers);
13944+ LEAVE_GL();
13945+/* }*/
13946+ #endif
13947+ *pCaps->NumSimultaneousRTs = max_buffers;/*max_buffers*/
13948+ *pCaps->StretchRectFilterCaps = 0;
13949+ /* TODO: add
13950+ D3DPTFILTERCAPS_MINFPOINT
13951+ D3DPTFILTERCAPS_MAGFPOINT
13952+ D3DPTFILTERCAPS_MINFLINEAR
13953+ D3DPTFILTERCAPS_MAGFLINEAR
13954+ */
13955+ #if 0
13956+ pCaps.VS20Caps->Caps = 0;
13957+ pCaps.PS20Caps->Caps = 0;
13958+ #endif
13959+ *pCaps->VertexTextureFilterCaps = 0;
13960+ *pCaps->MaxVShaderInstructionsExecuted = 0;
13961+ *pCaps->MaxPShaderInstructionsExecuted = 0;
13962+ *pCaps->MaxVertexShader30InstructionSlots = 0;
13963+ *pCaps->MaxPixelShader30InstructionSlots = 0;
13964 }
13965
13966 /* If we created a dummy context, throw it away */
13967 if (NULL != fake_ctx) WineD3D_ReleaseFakeGLContext(fake_ctx);
13968+
13969 return D3D_OK;
13970 }
13971
13972@@ -1368,14 +1468,14 @@
13973 and fields being inserted in the middle, a new structure is used in place */
13974 HRESULT WINAPI IWineD3DImpl_CreateDevice(IWineD3D *iface, UINT Adapter, D3DDEVTYPE DeviceType, HWND hFocusWindow,
13975 DWORD BehaviourFlags, WINED3DPRESENT_PARAMETERS* pPresentationParameters,
13976- IWineD3DDevice** ppReturnedDeviceInterface, IUnknown *parent, D3DCB_CREATERENDERTARGETFN D3DCB_CreateRenderTarget) {
13977+ IWineD3DDevice** ppReturnedDeviceInterface, IUnknown *parent,
13978+ D3DCB_CREATERENDERTARGETFN D3DCB_CreateRenderTarget,
13979+ D3DCB_CREATEDEPTHSTENCILSURFACEFN D3DCB_CreateDepthStencil,
13980+ D3DCB_CREATEADDITIONALSWAPCHAIN D3DCB_CreateAdditionalSwapChain) {
13981
13982- HWND whichHWND;
13983- HDC hDc;
13984 IWineD3DDeviceImpl *object = NULL;
13985 IWineD3DImpl *This = (IWineD3DImpl *)iface;
13986- int num;
13987- XVisualInfo template;
13988+ IWineD3DSwapChainImpl *swapchain;
13989
13990 /* Validate the adapter number */
13991 if (Adapter >= IWineD3D_GetAdapterCount(iface)) {
13992@@ -1387,6 +1487,7 @@
13993 *ppReturnedDeviceInterface = (IWineD3DDevice *)object;
13994 TRACE("Created WineD3DDevice object @ %p \n", object);
13995 if (NULL == object) {
13996+ ppReturnedDeviceInterface = NULL;
13997 return D3DERR_OUTOFVIDEOMEMORY;
13998 }
13999
14000@@ -1397,6 +1498,7 @@
14001 IWineD3D_AddRef(object->wineD3D);
14002 object->parent = parent;
14003
14004+
14005 TRACE("(%p)->(Adptr:%d, DevType: %x, FocusHwnd: %p, BehFlags: %lx, PresParms: %p, RetDevInt: %p)\n", This, Adapter, DeviceType,
14006 hFocusWindow, BehaviourFlags, pPresentationParameters, ppReturnedDeviceInterface);
14007 TRACE("(%p)->(DepthStencil:(%u,%s), BackBufferFormat:(%u,%s))\n", This,
14008@@ -1408,221 +1510,55 @@
14009 object->createParms.DeviceType = DeviceType;
14010 object->createParms.hFocusWindow = hFocusWindow;
14011 object->createParms.BehaviorFlags = BehaviourFlags;
14012-
14013- /* Initialize other useful values */
14014- object->presentParms.BackBufferCount = 1; /* Opengl only supports one? */
14015 object->adapterNo = Adapter;
14016 object->devType = DeviceType;
14017
14018- /* Setup hwnd we are using, plus which display this equates to */
14019- whichHWND = *(pPresentationParameters->hDeviceWindow);
14020- if (!whichHWND) {
14021- whichHWND = hFocusWindow;
14022- }
14023- object->win_handle = whichHWND;
14024- object->win = (Window)GetPropA( whichHWND, "__wine_x11_whole_window" );
14025- hDc = GetDC(whichHWND);
14026- object->display = get_display(hDc);
14027- ReleaseDC(whichHWND, hDc);
14028
14029 /* FIXME: Use for dx8 code eventually too! */
14030 /* Deliberately no indentation here, as this if will be removed when dx8 support merged in */
14031 if (This->dxVersion > 8) {
14032
14033- /* Create a context based off the properties of the existing visual */
14034- /* Note the visual is chosen as the window is created and the glcontext cannot
14035- use different properties after that point in time. FIXME: How to handle when requested format
14036- doesn't match actual visual? Cannot choose one here - code removed as it ONLY works if the one
14037- it chooses is identical to the one already being used! */
14038- /* FIXME: Handle stencil appropriately via EnableAutoDepthStencil / AutoDepthStencilFormat */
14039- ENTER_GL();
14040- template.visualid = (VisualID)GetPropA(GetDesktopWindow(), "__wine_x11_visual_id");
14041- object->visInfo = XGetVisualInfo(object->display, VisualIDMask, &template, &num);
14042- if (NULL == object->visInfo) {
14043- ERR("cannot really get XVisual\n");
14044- LEAVE_GL();
14045- return D3DERR_NOTAVAILABLE;
14046- }
14047- object->glCtx = glXCreateContext(object->display, object->visInfo, NULL, GL_TRUE);
14048- if (NULL == object->glCtx) {
14049- ERR("cannot create glxContext\n");
14050- LEAVE_GL();
14051- return D3DERR_NOTAVAILABLE;
14052- }
14053- LEAVE_GL();
14054-
14055- if (object->glCtx == NULL) {
14056- ERR("Error in context creation !\n");
14057- return D3DERR_INVALIDCALL;
14058- } else {
14059- TRACE("Context created (HWND=%p, glContext=%p, Window=%ld, VisInfo=%p)\n",
14060- whichHWND, object->glCtx, object->win, object->visInfo);
14061- }
14062-
14063- /* If not windowed, need to go fullscreen, and resize the HWND to the appropriate */
14064- /* dimensions */
14065- if (!*(pPresentationParameters->Windowed)) {
14066-
14067- DEVMODEW devmode;
14068- HDC hdc;
14069- int bpp = 0;
14070-
14071- /* Get info on the current display setup */
14072- hdc = CreateDCA("DISPLAY", NULL, NULL, NULL);
14073- bpp = GetDeviceCaps(hdc, BITSPIXEL);
14074- DeleteDC(hdc);
14075-
14076- /* Change the display settings */
14077- memset(&devmode, 0, sizeof(DEVMODEW));
14078- devmode.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT;
14079- devmode.dmBitsPerPel = (bpp >= 24) ? 32 : bpp; /*Stupid XVidMode cannot change bpp D3DFmtGetBpp(object, pPresentationParameters->BackBufferFormat);*/
14080- devmode.dmPelsWidth = *(pPresentationParameters->BackBufferWidth);
14081- devmode.dmPelsHeight = *(pPresentationParameters->BackBufferHeight);
14082- MultiByteToWideChar(CP_ACP, 0, "Gamers CG", -1, devmode.dmDeviceName, CCHDEVICENAME);
14083- ChangeDisplaySettingsExW(devmode.dmDeviceName, &devmode, object->win_handle, CDS_FULLSCREEN, NULL);
14084-
14085- /* Make popup window */
14086- SetWindowLongA(whichHWND, GWL_STYLE, WS_POPUP);
14087- SetWindowPos(object->win_handle, HWND_TOP, 0, 0,
14088- *(pPresentationParameters->BackBufferWidth),
14089- *(pPresentationParameters->BackBufferHeight), SWP_SHOWWINDOW | SWP_FRAMECHANGED);
14090- }
14091-
14092- /* MSDN: If Windowed is TRUE and either of the BackBufferWidth/Height values is zero,
14093- then the corresponding dimension of the client area of the hDeviceWindow
14094- (or the focus window, if hDeviceWindow is NULL) is taken. */
14095- if (*(pPresentationParameters->Windowed) &&
14096- ((*(pPresentationParameters->BackBufferWidth) == 0) ||
14097- (*(pPresentationParameters->BackBufferHeight) == 0))) {
14098-
14099- RECT Rect;
14100- GetClientRect(whichHWND, &Rect);
14101-
14102- if (*(pPresentationParameters->BackBufferWidth) == 0) {
14103- *(pPresentationParameters->BackBufferWidth) = Rect.right;
14104- TRACE("Updating width to %d\n", *(pPresentationParameters->BackBufferWidth));
14105- }
14106- if (*(pPresentationParameters->BackBufferHeight) == 0) {
14107- *(pPresentationParameters->BackBufferHeight) = Rect.bottom;
14108- TRACE("Updating height to %d\n", *(pPresentationParameters->BackBufferHeight));
14109- }
14110- }
14111-
14112- /* Save the presentation parms now filled in correctly */
14113- object->presentParms.BackBufferWidth = *(pPresentationParameters->BackBufferWidth);
14114- object->presentParms.BackBufferHeight = *(pPresentationParameters->BackBufferHeight);
14115- object->presentParms.BackBufferFormat = *(pPresentationParameters->BackBufferFormat);
14116- object->presentParms.BackBufferCount = *(pPresentationParameters->BackBufferCount);
14117- object->presentParms.MultiSampleType = *(pPresentationParameters->MultiSampleType);
14118- object->presentParms.MultiSampleQuality = *(pPresentationParameters->MultiSampleQuality);
14119- object->presentParms.SwapEffect = *(pPresentationParameters->SwapEffect);
14120- object->presentParms.hDeviceWindow = *(pPresentationParameters->hDeviceWindow);
14121- object->presentParms.Windowed = *(pPresentationParameters->Windowed);
14122- object->presentParms.EnableAutoDepthStencil = *(pPresentationParameters->EnableAutoDepthStencil);
14123- object->presentParms.AutoDepthStencilFormat = *(pPresentationParameters->AutoDepthStencilFormat);
14124- object->presentParms.Flags = *(pPresentationParameters->Flags);
14125- object->presentParms.FullScreen_RefreshRateInHz = *(pPresentationParameters->FullScreen_RefreshRateInHz);
14126- object->presentParms.PresentationInterval = *(pPresentationParameters->PresentationInterval);
14127-
14128 /* Creating the startup stateBlock - Note Special Case: 0 => Don't fill in yet! */
14129 IWineD3DDevice_CreateStateBlock((IWineD3DDevice *)object,
14130 (D3DSTATEBLOCKTYPE) 0,
14131 (IWineD3DStateBlock **)&object->stateBlock,
14132 NULL); /* Note: No parent needed for initial internal stateblock */
14133 object->updateStateBlock = object->stateBlock;
14134-
14135+ IWineD3DStateBlock_AddRef((IWineD3DStateBlock*)object->updateStateBlock);
14136 /* Setup surfaces for the backbuffer, frontbuffer and depthstencil buffer */
14137- TRACE("Creating initial device surfaces\n");
14138
14139- /* We need to 'magic' either d3d8 or d3d9 surfaces for the front and backbuuffer
14140- but the respective CreateRenderTarget functions take a differing number of
14141- parms. Fix this by passing in a function to call which takes identical parms
14142- and handles the differences at the d3dx layer, and returns the IWineD3DSurface
14143- pointer rather than the created D3D8/9 one */
14144- D3DCB_CreateRenderTarget((IUnknown *) parent,
14145- *(pPresentationParameters->BackBufferWidth),
14146- *(pPresentationParameters->BackBufferHeight),
14147- *(pPresentationParameters->BackBufferFormat),
14148- *(pPresentationParameters->MultiSampleType),
14149- *(pPresentationParameters->MultiSampleQuality),
14150- TRUE,
14151- (IWineD3DSurface **) &object->frontBuffer,
14152- NULL);
14153-
14154- D3DCB_CreateRenderTarget((IUnknown *) parent,
14155- *(pPresentationParameters->BackBufferWidth),
14156- *(pPresentationParameters->BackBufferHeight),
14157- *(pPresentationParameters->BackBufferFormat),
14158- *(pPresentationParameters->MultiSampleType),
14159- *(pPresentationParameters->MultiSampleQuality),
14160- TRUE,
14161- (IWineD3DSurface **) &object->backBuffer,
14162- NULL);
14163-
14164-/* TODO:
14165- if (*(pPresentationParameters->EnableAutoDepthStencil)) {
14166- IWineD3DDevice_CreateDepthStencilSurface((IWineD3DDevice *) object,
14167- *(pPresentationParameters->BackBufferWidth),
14168- *(pPresentationParameters->BackBufferHeight),
14169- *(pPresentationParameters->AutoDepthStencilFormat,
14170- D3DMULTISAMPLE_NONE,
14171- (IWineD3DSurface *) &object->depthStencilBuffer);
14172- } else {
14173- object->depthStencilBuffer = NULL;
14174- }
14175- TRACE("FrontBuf @ %p, BackBuf @ %p, DepthStencil @ %p\n",object->frontBuffer, object->backBuffer, object->depthStencilBuffer);
14176-*/
14177+ TRACE("Creating implicite swapchain\n");
14178
14179- /* init the default renderTarget management */
14180- object->drawable = object->win;
14181- object->render_ctx = object->glCtx;
14182- object->renderTarget = object->backBuffer;
14183+ D3DCB_CreateAdditionalSwapChain((IUnknown *) object->parent, pPresentationParameters, (IWineD3DSwapChain **)&swapchain);
14184
14185- IWineD3DSurface_AddRef((IWineD3DSurface *) object->renderTarget);
14186-/* TODO: Depth Stencil support
14187+ object->renderTarget =swapchain->backBuffer;
14188+ IWineD3DSurface_AddRef(object->renderTarget);
14189+ /* Depth Stencil support */
14190 object->stencilBufferTarget = object->depthStencilBuffer;
14191 if (NULL != object->stencilBufferTarget) {
14192- IDirect3DSurface8Impl_AddRef((LPDIRECT3DSURFACE8) object->stencilBufferTarget);
14193+ IWineD3DSurface_AddRef(object->stencilBufferTarget);
14194 }
14195-*/
14196-
14197- /* Set up some starting GL setup */
14198- ENTER_GL();
14199-
14200- if (glXMakeCurrent(object->display, object->win, object->glCtx) == False) {
14201- ERR("Error in setting current context (context %p drawable %ld)!\n", object->glCtx, object->win);
14202- }
14203- checkGLcall("glXMakeCurrent");
14204-
14205- /* Clear the screen */
14206- glClearColor(1.0, 0.0, 0.0, 0.0);
14207- checkGLcall("glClearColor");
14208- glColor3f(1.0, 1.0, 1.0);
14209- checkGLcall("glColor3f");
14210-
14211- glEnable(GL_LIGHTING);
14212- checkGLcall("glEnable");
14213-
14214- glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, GL_TRUE);
14215- checkGLcall("glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, GL_TRUE);");
14216
14217- glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT);
14218- checkGLcall("glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT);");
14219
14220- glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL, GL_SEPARATE_SPECULAR_COLOR);
14221- checkGLcall("glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL, GL_SEPARATE_SPECULAR_COLOR);");
14222+ /* Set up some starting GL setup */
14223
14224+ ENTER_GL();
14225 /*
14226 * Initialize openGL extension related variables
14227 * with Default values
14228 */
14229- This->isGLInfoValid = IWineD3DImpl_FillGLCaps(&This->gl_info, object->display);
14230+
14231+
14232+ This->isGLInfoValid = IWineD3DImpl_FillGLCaps(&This->gl_info, swapchain->display);
14233
14234 /* Setup all the devices defaults */
14235 IWineD3DStateBlock_InitStartupStateBlock((IWineD3DStateBlock *)object->stateBlock);
14236-
14237+ #if 0
14238+ IWineD3DImpl_CheckGraphicsMemory();
14239+ #endif
14240 LEAVE_GL();
14241
14242+
14243 { /* Set a default viewport */
14244 D3DVIEWPORT9 vp;
14245 vp.X = 0;
14246@@ -1645,18 +1581,129 @@
14247 /* Clear the screen */
14248 IWineD3DDevice_Clear((IWineD3DDevice *) object, 0, NULL, D3DCLEAR_STENCIL|D3DCLEAR_ZBUFFER|D3DCLEAR_TARGET, 0x00, 1.0, 0);
14249
14250- } /* End of FIXME: remove when dx8 merged in */
14251+ }else { /* End of FIXME: remove when dx8 merged in */
14252+ FIXME("(%p) Incomplete stub for d3d8\n", This);
14253+ }
14254
14255 return D3D_OK;
14256 }
14257
14258 HRESULT WINAPI IWineD3DImpl_GetParent(IWineD3D *iface, IUnknown **pParent) {
14259 IWineD3DImpl *This = (IWineD3DImpl *)iface;
14260- IUnknown_AddRef(This->parent);
14261 *pParent = This->parent;
14262+ TRACE("(%p) returning %p\n", This, *pParent);
14263+ IUnknown_AddRef(*pParent);
14264 return D3D_OK;
14265 }
14266
14267+/*This is a very simple 'hackish' check for Video memory, but the best you can do with OpenGL
14268+AGP memory can be assitained from
14269+*/
14270+void IWineD3DImpl_CheckGraphicsMemory(void){
14271+
14272+
14273+ if (DeviceMemory == 0){
14274+ DeviceMemory = IWineD3DImpl_CalculateGraphicsMemory(0);
14275+ FIXME("Memmory calculated as %ld\n",DeviceMemory);
14276+ }
14277+
14278+
14279+ if(DeviceMemory == -1){
14280+ FIXME("Unable to determin the ammount of memory for the display adapter\n");
14281+ DeviceMemory =0;
14282+ return;
14283+ }
14284+
14285+}
14286+ #include <stdio.h>
14287+
14288+long int IWineD3DImpl_CalculateGraphicsMemory(int maxAlloc){
14289+
14290+/*This function calculates the amount of grahpics memory on a device (or atleast the ammount left)
14291+Do not use in the middle of rendering as it will clobber all you textures!
14292+(This doesn't work on a ati9600 on linux with 8.8.25 drivers, it never reports any textures as resident)
14293+
14294+*/
14295+ int i, j;
14296+ int counter = 0;
14297+ long videoMemoryGuess = 0;
14298+ GLclampf priority1 = 1;
14299+ int* texturedata;
14300+ GLuint texture[2048]; /*upto 2gb of textures*/
14301+ GLboolean residences[2048];
14302+ if(maxAlloc <= 0) maxAlloc = 256; /* should look at the agp apeture or the system memory size and guess */
14303+ for(i=0;i<maxAlloc;i++){
14304+ residences[i]=0;
14305+ texture[i] = 0;
14306+ }
14307+ glGenTextures(maxAlloc, texture);
14308+ checkGLcall("glGenTextures");
14309+
14310+ texturedata = HeapAlloc(GetProcessHeap(), 0, 512*512*4 /*1Mib*/);
14311+ if(texturedata == 0 ) {
14312+ FIXME("Memmory allocation error\n");
14313+ return 0;
14314+ }
14315+
14316+ for(i=0;i<maxAlloc;i++){
14317+ texturedata[i] = 1;
14318+ texturedata[i*512] = 1;
14319+
14320+
14321+ /* Give it priority 1 so that it should be put into videoram */
14322+
14323+ glEnable(GL_TEXTURE_2D);
14324+ glBindTexture(GL_TEXTURE_2D, texture[i]);
14325+ checkGLcall("glBindTexture");
14326+ glPrioritizeTextures(i, texture, &priority1);
14327+ glTexImage2D(GL_TEXTURE_2D
14328+ , 0 /* level */
14329+ , GL_RGBA
14330+ , 512 /* width */
14331+ , 512 /* height */
14332+ , 0
14333+ , GL_RGBA
14334+ , GL_UNSIGNED_BYTE
14335+ , texturedata);
14336+ checkGLcall("glTexImage2D");
14337+
14338+ glPrioritizeTextures(i, texture, &priority1);
14339+ checkGLcall("glPrioritizeTextures");
14340+
14341+ /* When we reach the next locical memory size 2,4,8,176,32,64,128,256 Mib check to see if any of the textures are no longer resident
14342+ giving a crude approximation as to the amout of memory that the video card has.
14343+ */
14344+ glPrioritizeTextures(i, texture, &priority1);
14345+ if(i == (1<<counter)-1){
14346+ int rescount=0;
14347+ TRACE("checking for %d textures\n",i);
14348+ videoMemoryGuess = 1<<counter;
14349+ /*Well, my ATI9600 !never! returns any resident textures*/
14350+ glAreTexturesResident(i, texture, residences);
14351+ counter++;
14352+ for(j=i;j>=0;j--){
14353+ if(residences[j])
14354+ rescount++;
14355+ }
14356+ FIXME("Resident textures %d\n",rescount);
14357+ }
14358+
14359+ }
14360+ /* clean up */
14361+ FIXME("clean up %d\n",i);
14362+ glDeleteTextures(maxAlloc,texture);
14363+ /* return out guess */
14364+ HeapFree(GetProcessHeap(), 0, texturedata);
14365+ FIXME("Guessing as %ld\n",videoMemoryGuess);
14366+ return videoMemoryGuess;
14367+}
14368+#if 0 /* TODO: part of the interface cleanup */
14369+/* TODO: think about making this inline? */
14370+WineD3D_GL_Info WINAPI IWineD3DImpl_GetGLInfo(IWineD3D *iface){
14371+ IWineD3DImpl *This = (IWineD3DImpl *)iface;
14372+ return This->gl_info;
14373+}
14374+#endif
14375 /**********************************************************
14376 * IWineD3D VTbl follows
14377 **********************************************************/
14378@@ -1681,4 +1728,7 @@
14379 IWineD3DImpl_CheckDeviceFormatConversion,
14380 IWineD3DImpl_GetDeviceCaps,
14381 IWineD3DImpl_CreateDevice
14382+ #if 0 /* TODO: part of the interface cleanup */
14383+ ,IWineD3DImpl_GetGLInfo
14384+ #endif
14385 };
14386diff -urN wine.20050419/dlls/wined3d/drawprim.c wine.20050419.dx9/dlls/wined3d/drawprim.c
14387--- wine.20050419/dlls/wined3d/drawprim.c 2005-03-29 12:01:00.000000000 -0700
14388+++ wine.20050419.dx9/dlls/wined3d/drawprim.c 2005-04-20 03:38:00.000000000 -0600
14389@@ -4,6 +4,7 @@
14390 * Copyright 2002-2004 Jason Edmeades
14391 * Copyright 2002-2004 Raphael Junqueira
14392 * Copyright 2004 Christian Costa
14393+ * Copyright 2005 Oliver Stieber
14394 *
14395 * This library is free software; you can redistribute it and/or
14396 * modify it under the terms of the GNU Lesser General Public
14397@@ -23,7 +24,7 @@
14398 #include "config.h"
14399 #include "wined3d_private.h"
14400
14401-WINE_DEFAULT_DEBUG_CHANNEL(d3d);
14402+WINE_DEFAULT_DEBUG_CHANNEL(d3d_draw);
14403 WINE_DECLARE_DEBUG_CHANNEL(d3d_shader);
14404 #define GLINFO_LOCATION ((IWineD3DImpl *)(This->wineD3D))->gl_info
14405
14406@@ -39,12 +40,16 @@
14407 a vertex shader will be in use. Note the fvf bits returned may be split over
14408 multiple streams only if the vertex shader was created, otherwise it all relates
14409 to stream 0 */
14410+/* It may be better to just use the new vertex shaders, and off load this code to the setFVF functions on the device
14411+ *
14412+ * */
14413 BOOL initializeFVF(IWineD3DDevice *iface,
14414 DWORD *FVFbits, /* What to expect in the FVF across all streams */
14415 BOOL *useVertexShaderFunction) /* Should we use the vertex shader */
14416 {
14417
14418 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
14419+ static BOOL fixmes = TRUE;/* only write out FIXME's if fixmes*/
14420
14421 #if 0 /* TODO: d3d8 call setvertexshader needs to set the FVF in the state block when implemented */
14422 /* The first thing to work out is if we are using the fixed function pipeline
14423@@ -63,6 +68,7 @@
14424 TRACE("FVF explicitally defined, using fixed function pipeline with FVF=%lx\n", *FVFbits);
14425
14426 } else {
14427+ FIXME("line %d Vertex shaders\n", __LINE__);
14428
14429 #if 0 /* TODO */
14430 /* Use created shader */
14431@@ -91,7 +97,11 @@
14432 }
14433 }
14434 #else
14435+ if(fixmes == TRUE){
14436 FIXME("Vertex Shaders not moved into wined3d yet\n");
14437+ fixmes = FALSE;
14438+ }
14439+
14440 #endif
14441 }
14442 return FALSE;
14443@@ -142,13 +152,14 @@
14444 break;
14445
14446 default:
14447- FIXME("Unhandled primitive\n");
14448+ FIXME("Unhandled primitive, defaulting to GL_POINT\n");
14449 *primType = GL_POINTS;
14450 break;
14451 }
14452 return NumVertexes;
14453 }
14454
14455+
14456 /* Ensure the appropriate material states are set up - only change
14457 state if really required */
14458 void init_materials(IWineD3DDevice *iface, BOOL isDiffuseSupplied) {
14459@@ -186,7 +197,6 @@
14460 This->tracking_color = DISABLED_TRACKING;
14461 requires_material_reset = TRUE; /* Restore material settings as will be used */
14462 }
14463-
14464 /* Reset the material colors which may have been tracking the color*/
14465 if (requires_material_reset) {
14466 glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, (float*) &This->stateBlock->material.Ambient);
14467@@ -222,16 +232,21 @@
14468 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
14469
14470 /* If no normals, DISABLE lighting otherwise, don't touch lighing as it is
14471- set by the appropriate render state. Note Vertex Shader output is already lit */
14472- if (vtx_lit || useVS) {
14473+ set by the appropriate render state. Note Vertex Shader output is already lit
14474+
14475+
14476+
14477+ */
14478 isLightingOn = glIsEnabled(GL_LIGHTING);
14479+ if (vtx_lit || useVS) {
14480+ if(!isLightingOn){
14481 glDisable(GL_LIGHTING);
14482 checkGLcall("glDisable(GL_LIGHTING);");
14483 TRACE("Disabled lighting as no normals supplied, old state = %d\n", isLightingOn);
14484 }
14485+ }
14486
14487 if (!useVS && vtx_transformed) {
14488-
14489 /* If the last draw was transformed as well, no need to reapply all the matrixes */
14490 if (!This->last_was_rhw) {
14491
14492@@ -275,22 +290,70 @@
14493 } else {
14494
14495 /* Untransformed, so relies on the view and projection matrices */
14496+ /* TODO: blends */
14497
14498 if (!useVS && (This->last_was_rhw || !This->modelview_valid)) {
14499 /* Only reapply when have to */
14500 This->modelview_valid = TRUE;
14501+
14502 glMatrixMode(GL_MODELVIEW);
14503- checkGLcall("glMatrixMode");
14504+ checkGLcall("glMatrixMode(GL_MODELVIEW)");
14505
14506 /* In the general case, the view matrix is the identity matrix */
14507 if (This->view_ident) {
14508+ checkGLcall("glMatrixMode(GL_MODELVIEW)");
14509 glLoadMatrixf((float *) &This->stateBlock->transforms[D3DTS_WORLDMATRIX(0)].u.m[0][0]);
14510 checkGLcall("glLoadMatrixf");
14511 } else {
14512+
14513+ switch (This->stateBlock->renderState[D3DRS_VERTEXBLEND]) {
14514+#if 0 /* TODO: Vertex blending */
14515+ default:
14516+ case D3DVBF_3WEIGHTS:
14517+ glMatrixMode(GL_MODELVIEW3_ARB);
14518+ checkGLcall("glMatrixMode(GL_MODELVIEW3_ARB)");
14519+ glLoadMatrixf((float *)&This->stateBlock->transforms[D3DTS_VIEW].u.m[0][0]);
14520+ checkGLcall("glLoadMatrixf");
14521+ glMultMatrixf((float *)&This->stateBlock->transforms[D3DTS_WORLDMATRIX(3)].u.m[0][0]);
14522+ checkGLcall("glMultMatrixf");
14523+ case D3DVBF_2WEIGHTS: /* fall through */
14524+ glMatrixMode(GL_MODELVIEW2_ARB);
14525+ checkGLcall("glMatrixMode(GL_MODELVIEW2_ARB)");
14526+ glLoadMatrixf((float *)&This->stateBlock->transforms[D3DTS_VIEW].u.m[0][0]);
14527+ checkGLcall("glLoadMatrixf");
14528+ glMultMatrixf((float *)&This->stateBlock->transforms[D3DTS_WORLDMATRIX(2)].u.m[0][0]);
14529+ checkGLcall("glMultMatrixf");
14530+ case D3DVBF_1WEIGHTS: /* fall through */
14531+ glMatrixMode(GL_MODELVIEW1_ARB);
14532+ checkGLcall("glMatrixMode(GL_MODELVIEW2_ARB)");
14533+ glLoadMatrixf((float *)&This->stateBlock->transforms[D3DTS_VIEW].u.m[0][0]);
14534+ checkGLcall("glLoadMatrixf");
14535+ glMultMatrixf((float *)&This->stateBlock->transforms[D3DTS_WORLDMATRIX(1)].u.m[0][0]);
14536+ checkGLcall("glMultMatrixf");
14537+#else
14538+ default:
14539+ case D3DVBF_3WEIGHTS:
14540+ case D3DVBF_2WEIGHTS:
14541+ case D3DVBF_1WEIGHTS:
14542+#endif
14543+ case D3DVBF_DISABLE: /* default state (fall through) */
14544+ glMatrixMode(GL_MODELVIEW);
14545+ checkGLcall("glMatrixMode(GL_MODELVIEW)");
14546 glLoadMatrixf((float *) &This->stateBlock->transforms[D3DTS_VIEW].u.m[0][0]);
14547 checkGLcall("glLoadMatrixf");
14548 glMultMatrixf((float *) &This->stateBlock->transforms[D3DTS_WORLDMATRIX(0)].u.m[0][0]);
14549 checkGLcall("glMultMatrixf");
14550+ break;
14551+ case D3DVBF_0WEIGHTS: /* identity */
14552+ glMatrixMode(GL_MODELVIEW);
14553+ checkGLcall("glMatrixMode(GL_MODELVIEW)");
14554+ glLoadMatrixf((float *) &This->stateBlock->transforms[D3DTS_WORLDMATRIX(0)].u.m[0][0]);
14555+ checkGLcall("glLoadMatrixf");
14556+ break;
14557+ case D3DVBF_TWEENING:
14558+ FIXME("TODO: Tweening\n");
14559+ break;
14560+ };
14561 }
14562 }
14563
14564@@ -346,7 +409,147 @@
14565 return isLightingOn;
14566 }
14567
14568+
14569+
14570+
14571+void primitiveDeclarationConvertToStridedData(IWineD3DDevice *iface, Direct3DVertexStridedData *strided, LONG BaseVertexIndex, DWORD *fvf) {
14572+ /* We need to deal with frequency data!*/
14573+
14574+ int textureNo =0;
14575+ BYTE *data = NULL;
14576+ IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
14577+ IWineD3DVertexDeclarationImpl* vertexDeclaration = (IWineD3DVertexDeclarationImpl*)This->stateBlock->vertexDecl;
14578+ int i;
14579+ D3DVERTEXELEMENT9 *element;
14580+ DWORD stride;
14581+ for(i = 0 ; i <vertexDeclaration->declaration9NumElements -1; i++){
14582+ element=vertexDeclaration->pDeclaration9+i;
14583+ if (This->stateBlock->streamIsUP) {
14584+ data = (BYTE *)This->stateBlock->streamSource[element->Stream];
14585+ } else {
14586+ data = ((IWineD3DVertexBufferImpl *)This->stateBlock->streamSource[element->Stream])->resource.allocatedMemory;
14587+ }
14588+ stride = This->stateBlock->streamStride[element->Stream];
14589+ data = data + (BaseVertexIndex * stride);
14590+ data+= element->Offset;
14591+ /* Why can't I just use a lookup table instead of a switch statment?*/
14592+ switch(element->Usage){
14593+ case D3DDECLUSAGE_POSITION:
14594+ switch(element->UsageIndex){
14595+ case 0: /* N-patch */
14596+ strided->u.s.position.lpData = data;
14597+ strided->u.s.position.dwType = element->Type;
14598+ strided->u.s.position.dwStride = stride;
14599+ break;
14600+ case 1: /* skinning */
14601+ FIXME("Skinning positions\n");
14602+ break;
14603+ }
14604+ break;
14605+ case D3DDECLUSAGE_NORMAL:
14606+ switch(element->UsageIndex){
14607+ case 0: /* N-patch */
14608+ strided->u.s.normal.lpData = data;
14609+ strided->u.s.normal.dwType = element->Type;
14610+ strided->u.s.normal.dwStride = stride;
14611+ break;
14612+ case 1: /* skinning */
14613+ FIXME("Skinning normals\n");
14614+ break;
14615+ }
14616+ *fvf |= D3DFVF_NORMAL;
14617+ break;
14618+ case D3DDECLUSAGE_BLENDINDICES:
14619+ strided->u.s.blendMatrixIndices.lpData = data;
14620+ strided->u.s.blendMatrixIndices.dwType = element->Type;
14621+ strided->u.s.blendMatrixIndices.dwStride= stride;
14622+ break;
14623+ case D3DDECLUSAGE_BLENDWEIGHT:
14624+ strided->u.s.blendWeights.lpData = data;
14625+ strided->u.s.blendWeights.dwType = element->Type;
14626+ strided->u.s.blendWeights.dwStride = stride;
14627+ break;
14628+ case D3DDECLUSAGE_PSIZE:
14629+ strided->u.s.pSize.lpData = data;
14630+ strided->u.s.pSize.dwType = element->Type;
14631+ strided->u.s.pSize.dwStride = stride;
14632+ break;
14633+ case D3DDECLUSAGE_COLOR:
14634+ switch(element->UsageIndex){
14635+ case 0:/* diffuse */
14636+ strided->u.s.diffuse.lpData = data;
14637+ strided->u.s.diffuse.dwType = element->Type;
14638+ strided->u.s.diffuse.dwStride = stride;
14639+ break;
14640+ case 1: /* specular */
14641+ strided->u.s.specular.lpData = data;
14642+ strided->u.s.specular.dwType = element->Type;
14643+ strided->u.s.specular.dwStride = stride;
14644+ }
14645+
14646+ break;
14647+ case D3DDECLUSAGE_TEXCOORD:
14648+ /* For some odd reason Microsoft desided to sum usage accross all the streams,
14649+ which means we need to do a count and not just use the usage number */
14650+
14651+ strided->u.s.texCoords[textureNo].lpData = data;
14652+ strided->u.s.texCoords[textureNo].dwType = element->Type;
14653+ strided->u.s.texCoords[textureNo].dwStride = stride;
14654+
14655+ textureNo++;
14656+ break;
14657+ case D3DDECLUSAGE_TANGENT:
14658+ /* example of using tangents in opengl http://opengl.nutty.org/*/
14659+ /* here's a description of not using tangents! http://www.3dkingdoms.com/tutorial.htm (should a tangent just be the perpendicular of the normal anyhow?)
14660+ */
14661+ FIXME("Tangents\n");
14662+ break;
14663+ case D3DDECLUSAGE_BINORMAL:
14664+ /* don't know what d3d uses this for but I would expect it to be
14665+ something like y=mx+c */
14666+ FIXME("BI-Normal\n");
14667+ break;
14668+ case D3DDECLUSAGE_TESSFACTOR:
14669+ FIXME("Tess Factor\n");
14670+ break;
14671+ case D3DDECLUSAGE_POSITIONT:
14672+
14673+ switch(element->UsageIndex){
14674+ case 0: /* N-patch */
14675+ strided->u.s.position.lpData = data;
14676+ strided->u.s.position.dwType = element->Type;
14677+ strided->u.s.position.dwStride = stride;
14678+ break;
14679+ case 1: /* skinning */
14680+ FIXME("Skinning positionsT?\n");
14681+ break;
14682+ }
14683+ *fvf |= D3DFVF_XYZRHW;
14684+ /* FIXME: were faking this flag so that we don't transform the data again */
14685+ break;
14686+ case D3DDECLUSAGE_FOG:
14687+ FIXME("Fog\n");
14688+ break;
14689+ case D3DDECLUSAGE_DEPTH: /* Who knows!*/
14690+ FIXME("depth\n");
14691+ break;
14692+#if 0
14693+ case D3DDECLUSAGE_SAMPLE:
14694+ break:
14695+#endif
14696+ };
14697+
14698+ };
14699+
14700+}
14701+
14702+
14703+
14704+
14705+
14706+
14707 void primitiveConvertToStridedData(IWineD3DDevice *iface, Direct3DVertexStridedData *strided, LONG BaseVertexIndex) {
14708+ /* We need to deal with frequency data!*/
14709
14710 short LoopThroughTo = 0;
14711 short nStream;
14712@@ -356,9 +559,15 @@
14713 int textureNo;
14714 int coordIdxInfo = 0x00; /* Information on number of coords supplied */
14715 int numCoords[8]; /* Holding place for D3DFVF_TEXTUREFORMATx */
14716+ BYTE *data = NULL;
14717+ DWORD thisFVF = 0;
14718+ DWORD stride;
14719+
14720+
14721
14722 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
14723
14724+ /* We also mage vertex declarations to manage!*/
14725 /* OK, Now to setup the data locations
14726 For the non-created vertex shaders, the VertexShader var holds the real
14727 FVF and only stream 0 matters
14728@@ -367,39 +576,48 @@
14729 LoopThroughTo = MAX_STREAMS;
14730 } else {
14731 LoopThroughTo = 1;
14732+ if(This->updateStateBlock->vertexShader){
14733+ FIXME("line %d Vertex shaders\n", __LINE__);
14734+ }
14735 }
14736
14737 /* Work through stream by stream */
14738 for (nStream=0; nStream<LoopThroughTo; nStream++) {
14739- DWORD stride = This->stateBlock->stream_stride[nStream];
14740- BYTE *data = NULL;
14741- DWORD thisFVF = 0;
14742+ if(This->stateBlock->streamFreq[nStream]!=1 && This->stateBlock->streamFreq[nStream] != 0){
14743+ FIXME("Indexed or instanced data arn't managed properly yet\n");
14744+ /*
14745+ continue;
14746+ */
14747+ }else{
14748+ TRACE("stream fres %d \n", This->stateBlock->streamFreq[nStream]);
14749+ }
14750+ stride = This->stateBlock->streamStride[nStream];
14751
14752 /* Skip empty streams */
14753- if (This->stateBlock->stream_source[nStream] == NULL) continue;
14754-
14755+ if (This->stateBlock->streamSource[nStream] == NULL) continue;
14756 /* Retrieve appropriate FVF */
14757 if (LoopThroughTo == 1) { /* Use FVF, not vertex shader */
14758 thisFVF = This->updateStateBlock->fvf;
14759 /* Handle memory passed directly as well as vertex buffers */
14760 if (This->stateBlock->streamIsUP) {
14761- data = (BYTE *)This->stateBlock->stream_source[nStream];
14762+ data = (BYTE *)This->stateBlock->streamSource[nStream];
14763 } else {
14764- data = ((IWineD3DVertexBufferImpl *)This->stateBlock->stream_source[nStream])->resource.allocatedMemory;
14765+ data = ((IWineD3DVertexBufferImpl *)This->stateBlock->streamSource[nStream])->resource.allocatedMemory;
14766 }
14767 } else {
14768-#if 0 /* TODO: Vertex shader support */
14769- thisFVF = This->stateBlock->vertexShaderDecl->fvf[nStream];
14770- data = ((IDirect3DVertexBuffer8Impl *)This->stateBlock->stream_source[nStream])->allocatedMemory;
14771-#endif
14772+ /*
14773+ FIXME("TODO: vertex shader support\n");
14774+ thisFVF = ((IWineD3DVertexDeclarationImpl *)This->stateBlock->vertexDecl)->fvf[nStream];
14775+ data = ((IWineD3DVertexBufferImpl *)This->stateBlock->streamSource[nStream])->allocatedMemory;
14776+ */
14777 }
14778 VTRACE(("FVF for stream %d is %lx\n", nStream, thisFVF));
14779- if (thisFVF == 0) continue;
14780+ if (thisFVF == 0 /*|| thisFVF == 274 */) continue;
14781
14782 /* Now convert the stream into pointers */
14783
14784 /* Shuffle to the beginning of the vertexes to render and index from there */
14785- data = data + (BaseVertexIndex * stride);
14786+ data += (BaseVertexIndex * stride);
14787
14788 /* Either 3 or 4 floats depending on the FVF */
14789 /* FIXME: Can blending data be in a different stream to the position data?
14790@@ -417,15 +635,20 @@
14791
14792 /* Blending is numBlends * FLOATs followed by a DWORD for UBYTE4 */
14793 /** do we have to Check This->updateStateBlock->renderState[D3DRS_INDEXEDVERTEXBLENDENABLE] ? */
14794- numBlends = ((thisFVF & D3DFVF_POSITION_MASK) >> 1) - 2 +
14795- ((FALSE == (thisFVF & D3DFVF_LASTBETA_UBYTE4)) ? 0 : -1); /* WARNING can be < 0 because -2 */
14796+ /* What about this */
14797+
14798+ numBlends = ((thisFVF & D3DFVF_XYZB4) == D3DFVF_XYZB4)?4:(((thisFVF & D3DFVF_XYZB3) == D3DFVF_XYZB3)?3:0);
14799+ if(thisFVF & D3DFVF_LASTBETA_UBYTE4) numBlends--;
14800+
14801 if (numBlends > 0) {
14802 canDoViaGLPointers = FALSE;
14803+
14804 strided->u.s.blendWeights.lpData = data;
14805- strided->u.s.blendWeights.dwType = D3DDECLTYPE_FLOAT1 + (numBlends - 1);
14806+ strided->u.s.blendWeights.dwType = D3DDECLTYPE_FLOAT1 +numBlends -1;
14807 strided->u.s.blendWeights.dwStride = stride;
14808 data += numBlends * sizeof(FLOAT);
14809
14810+ /* setup matrix indicies */
14811 if (thisFVF & D3DFVF_LASTBETA_UBYTE4) {
14812 strided->u.s.blendMatrixIndices.lpData = data;
14813 strided->u.s.blendMatrixIndices.dwType = D3DDECLTYPE_UBYTE4;
14814@@ -637,7 +860,7 @@
14815 * Faster GL version using pointers to data, harder to debug though
14816 * Note does not handle vertex shaders yet
14817 */
14818-void drawStridedFast(IWineD3DDevice *iface, Direct3DVertexStridedData *sd,
14819+BOOL drawStridedFast(IWineD3DDevice *iface, Direct3DVertexStridedData *sd,
14820 int PrimitiveType, ULONG NumPrimitives,
14821 const void *idxData, short idxSize, ULONG minIndex, ULONG startIdx) {
14822 unsigned int textureNo = 0;
14823@@ -647,82 +870,112 @@
14824
14825 TRACE("Using fast vertex array code\n");
14826
14827- /* Vertex Pointers -----------------------------------------*/
14828- if (sd->u.s.position.lpData != NULL) {
14829
14830- /* Note dwType == float3 or float4 == 2 or 3 */
14831- VTRACE(("glVertexPointer(%ld, GL_FLOAT, %ld, %p)\n",
14832- sd->u.s.position.dwStride,
14833- sd->u.s.position.dwType + 1,
14834- sd->u.s.position.lpData));
14835-
14836- /* Disable RHW mode as 'w' coord handling for rhw mode should
14837- not impact screen position whereas in GL it does. This may
14838- result in very slightly distored textures in rhw mode, but
14839- a very minimal different */
14840- glVertexPointer(3, GL_FLOAT, /* RHW: Was 'sd->u.s.position.dwType + 1' */
14841- sd->u.s.position.dwStride,
14842- sd->u.s.position.lpData);
14843- checkGLcall("glVertexPointer(...)");
14844- glEnableClientState(GL_VERTEX_ARRAY);
14845- checkGLcall("glEnableClientState(GL_VERTEX_ARRAY)");
14846-
14847- } else {
14848-
14849- glDisableClientState(GL_VERTEX_ARRAY);
14850- checkGLcall("glDisableClientState(GL_VERTEX_ARRAY)");
14851- }
14852
14853 /* Blend Data ----------------------------------------------*/
14854 if ((sd->u.s.blendWeights.lpData != NULL) ||
14855 (sd->u.s.blendMatrixIndices.lpData != NULL)) {
14856-#if 1 /* Vertex blend support needs to be added */
14857+
14858+
14859 if (GL_SUPPORT(ARB_VERTEX_BLEND)) {
14860- DWORD fvf = (sd->u.s.blendWeights.dwType - D3DDECLTYPE_FLOAT1) + 1;
14861- int numBlends = ((fvf & D3DFVF_POSITION_MASK) >> 1) - 2 + ((FALSE == (fvf & D3DFVF_LASTBETA_UBYTE4)) ? 0 : -1);
14862
14863+ int numBlends = sd->u.s.blendWeights.dwType - D3DDECLTYPE_FLOAT1 + 1;
14864+
14865+ glEnableClientState(GL_WEIGHT_ARRAY_ARB);
14866+ checkGLcall("glEnableClientState(GL_WEIGHT_ARRAY_ARB)");
14867+
14868+
14869+ TRACE("Blend %d %ld %p %ld\n", numBlends, startIdx, sd->u.s.blendWeights.lpData, sd->u.s.blendWeights.dwStride);
14870 /*FIXME("TODO\n");*/
14871 /* Note dwType == float3 or float4 == 2 or 3 */
14872 VTRACE(("glWeightPointerARB(%ld, GL_FLOAT, %ld, %p)\n",
14873 numBlends,
14874 sd->u.s.blendWeights.dwStride,
14875 sd->u.s.blendWeights.lpData));
14876+
14877 GL_EXTCALL(glWeightPointerARB)(numBlends, GL_FLOAT,
14878 sd->u.s.blendWeights.dwStride,
14879 sd->u.s.blendWeights.lpData);
14880- checkGLcall("glWeightPointerARB(...)");
14881- glEnableClientState(GL_WEIGHT_ARRAY_ARB);
14882- checkGLcall("glEnableClientState(GL_VERTEX_ARRAY)");
14883+
14884+ checkGLcall("glWeightPointerARB");
14885+#if 0 /* TODO: Vertex blending TODO: move this to before drawstrided so that it is shared with slow and fast */
14886+ /* with this on, the normals appear to be being modified,
14887+ but the textices aren't being translated as they should be
14888+ Maybe the world matrix aren't being setup properly? */
14889+
14890+ glEnable(GL_VERTEX_BLEND_ARB);
14891+ GL_EXTCALL(glVertexBlendARB)(numBlends + 1);
14892+#endif
14893+
14894+ if(sd->u.s.blendMatrixIndices.lpData != NULL){
14895+ FIXME("blendMatrixIndices support\n");
14896+ }
14897+
14898+
14899 } else if (GL_SUPPORT(EXT_VERTEX_WEIGHTING)) {
14900 /*FIXME("TODO\n");*/
14901- /*
14902- GLExtCall(glVertexWeightPointerEXT)(numBlends, GL_FLOAT, skip, curPos);
14903+#if 0
14904+ GL_EXTCALL(glVertexWeightPointerEXT)(numBlends, GL_FLOAT,
14905+ sd->u.s.blendWeights.dwStride,
14906+ sd->u.s.blendWeights.lpData);
14907 checkGLcall("glVertexWeightPointerEXT(numBlends, ...)");
14908 glEnableClientState(GL_VERTEX_WEIGHT_ARRAY_EXT);
14909 checkGLcall("glEnableClientState(GL_VERTEX_WEIGHT_ARRAY_EXT)");
14910- */
14911+#endif
14912+
14913 } else {
14914 FIXME("unsupported blending in openGl\n");
14915+ return FALSE;
14916 }
14917 } else {
14918 if (GL_SUPPORT(ARB_VERTEX_BLEND)) {
14919- FIXME("TODO\n");
14920+#if 0 /* TODO: Vertex blending */
14921+ glDisable(GL_VERTEX_BLEND_ARB);
14922+#endif
14923+ TRACE("ARB_VERTEX_BLEND \n");
14924 } else if (GL_SUPPORT(EXT_VERTEX_WEIGHTING)) {
14925- FIXME("TODO\n");
14926- /*
14927+ TRACE(" EXT_VERTEX_WEIGHTING\n");
14928 glDisableClientState(GL_VERTEX_WEIGHT_ARRAY_EXT);
14929 checkGLcall("glDisableClientState(GL_VERTEX_WEIGHT_ARRAY_EXT)");
14930- */
14931+
14932 }
14933-#else
14934- /* FIXME: Won't get here as will drop to slow method */
14935- FIXME("Blending not supported in fast draw routine\n");
14936-#endif
14937+ }
14938+
14939+ /* Point Size ----------------------------------------------*/
14940+ if (sd->u.s.pSize.lpData != NULL) {
14941+
14942+ /* no such functionality in the fixed function GL pipeline */
14943+ TRACE("Cannot change ptSize here in openGl\n");
14944+ return FALSE;
14945+
14946+ }
14947+
14948+ /* Vertex Pointers -----------------------------------------*/
14949+ if (sd->u.s.position.lpData != NULL) {
14950+ /* Note dwType == float3 or float4 == 2 or 3 */
14951+ VTRACE(("glVertexPointer(%ld, GL_FLOAT, %ld, %p)\n",
14952+ sd->u.s.position.dwStride,
14953+ sd->u.s.position.dwType + 1,
14954+ sd->u.s.position.lpData));
14955+
14956+ /* Disable RHW mode as 'w' coord handling for rhw mode should
14957+ not impact screen position whereas in GL it does. This may
14958+ result in very slightly distored textures in rhw mode, but
14959+ a very minimal different */
14960+ glVertexPointer(3, GL_FLOAT, /* RHW: Was 'sd->u.s.position.dwType + 1' */
14961+ sd->u.s.position.dwStride,
14962+ sd->u.s.position.lpData);
14963+ checkGLcall("glVertexPointer(...)");
14964+ glEnableClientState(GL_VERTEX_ARRAY);
14965+ checkGLcall("glEnableClientState(GL_VERTEX_ARRAY)");
14966+
14967+ } else {
14968+ glDisableClientState(GL_VERTEX_ARRAY);
14969+ checkGLcall("glDisableClientState(GL_VERTEX_ARRAY)");
14970 }
14971
14972 /* Normals -------------------------------------------------*/
14973 if (sd->u.s.normal.lpData != NULL) {
14974-
14975 /* Note dwType == float3 or float4 == 2 or 3 */
14976 VTRACE(("glNormalPointer(GL_FLOAT, %ld, %p)\n",
14977 sd->u.s.normal.dwStride,
14978@@ -735,31 +988,22 @@
14979 checkGLcall("glEnableClientState(GL_NORMAL_ARRAY)");
14980
14981 } else {
14982-
14983 glDisableClientState(GL_NORMAL_ARRAY);
14984 checkGLcall("glDisableClientState(GL_NORMAL_ARRAY)");
14985 glNormal3f(0, 0, 1);
14986 checkGLcall("glNormal3f(0, 0, 1)");
14987 }
14988
14989- /* Point Size ----------------------------------------------*/
14990- if (sd->u.s.pSize.lpData != NULL) {
14991-
14992- /* no such functionality in the fixed function GL pipeline */
14993- /* FIXME: Won't get here as will drop to slow method */
14994- FIXME("Cannot change ptSize here in openGl\n");
14995- }
14996-
14997 /* Diffuse Colour ------------------------------------------*/
14998 /* WARNING: Data here MUST be in RGBA format, so cannot */
14999 /* go directly into fast mode from app pgm, because */
15000 /* directx requires data in BGRA format. */
15001 if (sd->u.s.diffuse.lpData != NULL) {
15002-
15003 /* Note dwType == float3 or float4 == 2 or 3 */
15004 VTRACE(("glColorPointer(4, GL_UNSIGNED_BYTE, %ld, %p)\n",
15005 sd->u.s.diffuse.dwStride,
15006 sd->u.s.diffuse.lpData));
15007+
15008 glColorPointer(4, GL_UNSIGNED_BYTE,
15009 sd->u.s.diffuse.dwStride,
15010 sd->u.s.diffuse.lpData);
15011@@ -768,7 +1012,6 @@
15012 checkGLcall("glEnableClientState(GL_COLOR_ARRAY)");
15013
15014 } else {
15015-
15016 glDisableClientState(GL_COLOR_ARRAY);
15017 checkGLcall("glDisableClientState(GL_COLOR_ARRAY)");
15018 glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
15019@@ -777,7 +1020,7 @@
15020
15021 /* Specular Colour ------------------------------------------*/
15022 if (sd->u.s.specular.lpData != NULL) {
15023-
15024+ TRACE("setting specular colour\n");
15025 /* Note dwType == float3 or float4 == 2 or 3 */
15026 VTRACE(("glSecondaryColorPointer(4, GL_UNSIGNED_BYTE, %ld, %p)\n",
15027 sd->u.s.specular.dwStride,
15028@@ -791,17 +1034,19 @@
15029 glEnableClientState(GL_SECONDARY_COLOR_ARRAY_EXT);
15030 vcheckGLcall("glEnableClientState(GL_SECONDARY_COLOR_ARRAY_EXT)");
15031 } else {
15032+
15033 /* Missing specular color is not critical, no warnings */
15034 VTRACE(("Specular colour is not supported in this GL implementation\n"));
15035 }
15036
15037 } else {
15038-
15039 if (GL_SUPPORT(EXT_SECONDARY_COLOR)) {
15040+
15041 glDisableClientState(GL_SECONDARY_COLOR_ARRAY_EXT);
15042 checkGLcall("glDisableClientState(GL_SECONDARY_COLOR_ARRAY_EXT)");
15043 GL_EXTCALL(glSecondaryColor3fEXT)(0, 0, 0);
15044 checkGLcall("glSecondaryColor3fEXT(0, 0, 0)");
15045+
15046 } else {
15047 /* Missing specular color is not critical, no warnings */
15048 VTRACE(("Specular colour is not supported in this GL implementation\n"));
15049@@ -809,12 +1054,11 @@
15050 }
15051
15052 /* Texture coords -------------------------------------------*/
15053+
15054 for (textureNo = 0; textureNo < GL_LIMITS(textures); ++textureNo) {
15055
15056 /* Select the correct texture stage */
15057 GLCLIENTACTIVETEXTURE(textureNo);
15058-
15059- /* Query tex coords */
15060 if (This->stateBlock->textures[textureNo] != NULL) {
15061 int coordIdx = This->updateStateBlock->textureState[textureNo][D3DTSS_TEXCOORDINDEX];
15062
15063@@ -852,7 +1096,6 @@
15064 default: FIXME("Unrecognized data type %ld\n", sd->u.s.texCoords[coordIdx].dwType);
15065 size = 4; type = GL_UNSIGNED_BYTE;
15066 }
15067-
15068 glTexCoordPointer(size, type, sd->u.s.texCoords[coordIdx].dwStride, sd->u.s.texCoords[coordIdx].lpData);
15069 glEnableClientState(GL_TEXTURE_COORD_ARRAY);
15070 }
15071@@ -865,15 +1108,16 @@
15072 /* Ok, Work out which primitive is requested and how many vertexes that
15073 will be */
15074 NumVertexes = primitiveToGl(PrimitiveType, NumPrimitives, &glPrimType);
15075-
15076 /* Finally do the drawing */
15077- if (idxData != NULL) {
15078
15079- TRACE("glElements(%x, %d, %ld, ...)\n", glPrimType, NumVertexes, minIndex);
15080-#if 1 /* FIXME: Want to use DrawRangeElements, but wrong calculation! */
15081+ if (idxData != NULL /* This crashes sometimes!*/) {
15082+ VTRACE(("glElements(%x, %d, %ld, ...)\n", glPrimType, NumVertexes, minIndex));
15083+#if 0
15084+
15085 glDrawElements(glPrimType, NumVertexes, idxSize==2?GL_UNSIGNED_SHORT:GL_UNSIGNED_INT,
15086 (const char *)idxData+(idxSize * startIdx));
15087-#else
15088+#else /* This calcualtion works fine for my ATI-9600!*/
15089+
15090 glDrawRangeElements(glPrimType, minIndex, minIndex+NumVertexes-1, NumVertexes,
15091 idxSize==2?GL_UNSIGNED_SHORT:GL_UNSIGNED_INT,
15092 (const char *)idxData+(idxSize * startIdx));
15093@@ -888,6 +1132,7 @@
15094 checkGLcall("glDrawArrays");
15095
15096 }
15097+ return TRUE;
15098 }
15099
15100 /*
15101@@ -905,20 +1150,50 @@
15102 const long *pIdxBufL = NULL;
15103 LONG SkipnStrides = 0;
15104 LONG vx_index;
15105+ int numBlends = 0;
15106 float x = 0.0f, y = 0.0f, z = 0.0f; /* x,y,z coordinates */
15107 float nx = 0.0f, ny = 0.0, nz = 0.0f; /* normal x,y,z coordinates */
15108 float rhw = 0.0f; /* rhw */
15109 float ptSize = 0.0f; /* Point size */
15110+ float *bw; /* blend weights */
15111 DWORD diffuseColor = 0xFFFFFFFF; /* Diffuse Color */
15112 DWORD specularColor = 0; /* Specular Color */
15113 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
15114+ /* For each primitive */
15115+ float *ptrToCoords;
15116+
15117+ char *position = sd->u.s.position.lpData;
15118+ int positionStrideSize = sd->u.s.position.dwStride;
15119+ char *blendWeights = sd->u.s.blendWeights.lpData;
15120+ int blendWeightsStrideSize = sd->u.s.blendWeights.dwStride;
15121+
15122+ char *normal = sd->u.s.normal.lpData;
15123+ int normalStrideSize = sd->u.s.normal.dwStride;
15124+ char *pSize = sd->u.s.pSize.lpData;
15125+ int pSizeStrideSize = sd->u.s.pSize.dwStride;
15126+
15127+ char *diffuse = sd->u.s.diffuse.lpData;
15128+ int diffuseStrideSize = sd->u.s.diffuse.dwStride;
15129+ char *specular = sd->u.s.specular.lpData;
15130+ int specularStrideSize = sd->u.s.specular.dwStride;
15131
15132- TRACE("Using slow vertex array code\n");
15133+ /* OK this is a bit of a mess... tidy up, use pointer arythnamitic to make things a lot clearer!*/
15134+ /* Ok, what the hell is u.s.[name].dwStride */
15135
15136+
15137+ TRACE("Using slow vertex array code %p type%d, count:%ld ,idxData%p, idxSize%d min%ld start%ld\n" ,sd, PrimitiveType, NumPrimitives, idxData, idxSize, minIndex, startIdx);
15138+#if 0
15139+ /* dodgy stuff in Axis&Allies !! s*/
15140+ if((int) sd == 0x406ef5c4) return;
15141+ if((int) sd == 0x406ef588) return;
15142+ if((int) sd == 0x406efad4 && NumPrimitives == 2) return; /* another bad one!*/
15143+#endif
15144 /* Variable Initialization */
15145 if (idxData != NULL) {
15146- if (idxSize == 2) pIdxBufS = (const short *) idxData;
15147- else pIdxBufL = (const long *) idxData;
15148+ if (idxSize == 2)
15149+ pIdxBufS = ((const short *) idxData) + startIdx;
15150+ else
15151+ pIdxBufL = ((const long *) idxData) + startIdx;
15152 }
15153
15154 /* Ok, Work out which primitive is requested and how many vertexes that will be */
15155@@ -928,90 +1203,80 @@
15156 VTRACE(("glBegin(%x)\n", glPrimType));
15157 glBegin(glPrimType);
15158
15159- /* For each primitive */
15160+ /* It may be a good idea to split into draw indexes and draw non-indexed to help the compiler out (and make this function a bit smaller! */
15161 for (vx_index = 0; vx_index < NumVertexes; vx_index++) {
15162
15163- /* Initialize diffuse color */
15164- diffuseColor = 0xFFFFFFFF;
15165-
15166- /* For indexed data, we need to go a few more strides in */
15167 if (idxData != NULL) {
15168-
15169- /* Indexed so work out the number of strides to skip */
15170- if (idxSize == 2) {
15171- VTRACE(("Idx for vertex %ld = %d\n", vx_index, pIdxBufS[startIdx+vx_index]));
15172- SkipnStrides = pIdxBufS[startIdx+vx_index];
15173- } else {
15174- VTRACE(("Idx for vertex %ld = %ld\n", vx_index, pIdxBufL[startIdx+vx_index]));
15175- SkipnStrides = pIdxBufL[startIdx+vx_index];
15176- }
15177+ if (idxSize == 2)
15178+ SkipnStrides = *pIdxBufS++;
15179+ else
15180+ SkipnStrides = *pIdxBufL++;
15181 }
15182
15183- /* Position Information ------------------ */
15184- if (sd->u.s.position.lpData != NULL) {
15185+ /* Initialize diffuse color */
15186+ diffuseColor = 0xFFFFFFFF;
15187
15188- float *ptrToCoords = (float *)(sd->u.s.position.lpData + (SkipnStrides * sd->u.s.position.dwStride));
15189- x = ptrToCoords[0];
15190- y = ptrToCoords[1];
15191- z = ptrToCoords[2];
15192- rhw = 1.0;
15193- VTRACE(("x,y,z=%f,%f,%f\n", x,y,z));
15194+ /* Position information ------------------- */
15195+ if(position != NULL){
15196+ ptrToCoords = (float*)(position + (SkipnStrides * positionStrideSize));
15197+ x = *ptrToCoords++;
15198+ y = *ptrToCoords++;
15199+ z = *ptrToCoords++;
15200
15201 /* RHW follows, only if transformed, ie 4 floats were provided */
15202 if (sd->u.s.position.dwType == D3DDECLTYPE_FLOAT4) {
15203- rhw = ptrToCoords[3];
15204- VTRACE(("rhw=%f\n", rhw));
15205+ rhw = *ptrToCoords;
15206+ } else {
15207+ rhw = 1.0;
15208 }
15209+ VTRACE(("x,y,z,rhw=%f,%f,%f,%f\n", x,y,z,rhw));
15210 }
15211
15212 /* Blending data -------------------------- */
15213- if (sd->u.s.blendWeights.lpData != NULL) {
15214- /*float *ptrToCoords = (float *)(sd->u.s.blendWeights.lpData + (SkipnStrides * sd->u.s.blendWeights.dwStride));*/
15215- FIXME("Blending not supported yet\n");
15216-
15217+ if (blendWeights != NULL) {
15218+ bw = (float *)(blendWeights + (SkipnStrides * blendWeightsStrideSize));
15219+ numBlends = sd->u.s.blendWeights.dwType - D3DDECLTYPE_FLOAT1 + 1;
15220 if (sd->u.s.blendMatrixIndices.lpData != NULL) {
15221- /*DWORD *ptrToCoords = (DWORD *)(sd->u.s.blendMatrixIndices.lpData + (SkipnStrides * sd->u.s.blendMatrixIndices.dwStride));*/
15222+ DWORD *ptrToCoords = (DWORD *)(sd->u.s.blendMatrixIndices.lpData + (SkipnStrides * sd->u.s.blendMatrixIndices.dwStride));
15223+ TRACE("Blending matrix not supported yet %p\n", ptrToCoords);
15224 }
15225 }
15226
15227 /* Vertex Normal Data (untransformed only)- */
15228- if (sd->u.s.normal.lpData != NULL) {
15229-
15230- float *ptrToCoords = (float *)(sd->u.s.normal.lpData + (SkipnStrides * sd->u.s.normal.dwStride));
15231- nx = ptrToCoords[0];
15232- ny = ptrToCoords[1];
15233- nz = ptrToCoords[2];
15234+ if (normal != NULL) {
15235+ ptrToCoords = (float *)(normal + (SkipnStrides * normalStrideSize));
15236+ nx = *ptrToCoords++;
15237+ ny = *ptrToCoords++;
15238+ nz = *ptrToCoords++;
15239 VTRACE(("nx,ny,nz=%f,%f,%f\n", nx, ny, nz));
15240 }
15241
15242- /* Point Size ----------------------------- */
15243- if (sd->u.s.pSize.lpData != NULL) {
15244
15245- float *ptrToCoords = (float *)(sd->u.s.pSize.lpData + (SkipnStrides * sd->u.s.pSize.dwStride));
15246- ptSize = ptrToCoords[0];
15247+ /* Point Size ----------------------------- */
15248+ if (pSize != NULL) {
15249+ ptSize = * (float *)(pSize + (SkipnStrides * pSizeStrideSize));
15250 VTRACE(("ptSize=%f\n", ptSize));
15251- FIXME("No support for ptSize yet\n");
15252+ /* FIXME: Only do this once, not for every itteration! */
15253+ TRACE("No support for ptSize yet\n");
15254+ /* Just do a glPointSize(ptSize)*/
15255 }
15256
15257 /* Diffuse -------------------------------- */
15258- if (sd->u.s.diffuse.lpData != NULL) {
15259-
15260- DWORD *ptrToCoords = (DWORD *)(sd->u.s.diffuse.lpData + (SkipnStrides * sd->u.s.diffuse.dwStride));
15261- diffuseColor = ptrToCoords[0];
15262+ if (diffuse != NULL) {
15263+ diffuseColor = *(DWORD *)(diffuse + (SkipnStrides * diffuseStrideSize));
15264 VTRACE(("diffuseColor=%lx\n", diffuseColor));
15265 }
15266
15267 /* Specular -------------------------------- */
15268- if (sd->u.s.specular.lpData != NULL) {
15269-
15270- DWORD *ptrToCoords = (DWORD *)(sd->u.s.specular.lpData + (SkipnStrides * sd->u.s.specular.dwStride));
15271- specularColor = ptrToCoords[0];
15272+ if (specular != NULL) {
15273+ specularColor = *(DWORD *)(specular + (SkipnStrides * specularStrideSize));
15274 VTRACE(("specularColor=%lx\n", specularColor));
15275+
15276 }
15277
15278 /* Texture coords --------------------------- */
15279 for (textureNo = 0; textureNo < GL_LIMITS(textures); ++textureNo) {
15280-
15281+ /* FIXME: , do this first, instead of every single call*/
15282 if (!GL_SUPPORT(ARB_MULTITEXTURE) && textureNo > 0) {
15283 FIXME("Program using multiple concurrent textures which this opengl implementation doesn't support\n");
15284 continue ;
15285@@ -1020,6 +1285,7 @@
15286 /* Query tex coords */
15287 if (This->stateBlock->textures[textureNo] != NULL) {
15288
15289+ /* This kind of looking up can be done once, instead of thousnads of times*/
15290 int coordIdx = This->updateStateBlock->textureState[textureNo][D3DTSS_TEXCOORDINDEX];
15291 float *ptrToCoords = (float *)(sd->u.s.texCoords[coordIdx].lpData + (SkipnStrides * sd->u.s.texCoords[coordIdx].dwStride));
15292 float s = 0.0, t = 0.0, r = 0.0, q = 0.0;
15293@@ -1035,6 +1301,24 @@
15294 int coordsToUse = sd->u.s.texCoords[coordIdx].dwType + 1; /* 0 == D3DDECLTYPE_FLOAT1 etc */
15295
15296 /* The coords to supply depend completely on the fvf / vertex shader */
15297+
15298+
15299+
15300+ /* FIXME: we need to adjust textures by 0x5 pixels in all directions because opengl uses cordners and d3d uses centers*/
15301+ if(This->stateBlock->vertexDecl){
15302+ /* It looks like vertex declarations can have the texture co-ordinates a weird was around (or some kind of wrapping's been set up!)*/
15303+
15304+
15305+ switch (coordsToUse) {
15306+ case 4: q = ptrToCoords[3]; /* drop through */
15307+ case 3: r = ptrToCoords[2]; /* drop through */
15308+ case 2: t = ptrToCoords[1]; /* drop through, vertexDeclarations seem to have transposed co-ords (x==1 y==0) */
15309+ case 1: s = ptrToCoords[0];
15310+ TRACE("Coords are q%f r%f t%f s%f\n", q ,r ,t ,s);
15311+
15312+
15313+ }
15314+ }else{
15315 switch (coordsToUse) {
15316 case 4: q = ptrToCoords[3]; /* drop through */
15317 case 3: r = ptrToCoords[2]; /* drop through */
15318@@ -1042,12 +1326,18 @@
15319 case 1: s = ptrToCoords[0];
15320 }
15321
15322+ }
15323+
15324+
15325 /* Projected is more 'fun' - Move the last coord to the 'q'
15326 parameter (see comments under D3DTSS_TEXTURETRANSFORMFLAGS */
15327 if ((This->updateStateBlock->textureState[textureNo][D3DTSS_TEXTURETRANSFORMFLAGS] != D3DTTFF_DISABLE) &&
15328 (This->updateStateBlock->textureState[textureNo][D3DTSS_TEXTURETRANSFORMFLAGS] & D3DTTFF_PROJECTED)) {
15329-
15330+ FIXME("projected texture\n");
15331 if (This->updateStateBlock->textureState[textureNo][D3DTSS_TEXTURETRANSFORMFLAGS] & D3DTTFF_PROJECTED) {
15332+ /* According to god.....
15333+ all four floating point values must be written to the corresponding texture register. Each texture coordinate is divided by the last element before being passed to the rasterizer.
15334+ */
15335 switch (coordsToUse) {
15336 case 0: /* Drop Through */
15337 case 1:
15338@@ -1072,9 +1362,16 @@
15339 }
15340 }
15341
15342+ /* TODO: replace with a texture matrix when the non-pow2 texture is created in device.c (this will choke on cube textures!!!) */
15343+ /* Non-pow-two scaling, I should be able to do this via a texture transform? */
15344+ if(((IWineD3DSurfaceImpl *) ((IWineD3DTextureImpl *)This->stateBlock->textures[textureNo])->surfaces[0])->nonpow2){
15345+ t *= ((IWineD3DSurfaceImpl *)((IWineD3DTextureImpl *)This->stateBlock->textures[textureNo])->surfaces[0])->pow2scalingFactorY;
15346+ s *= ((IWineD3DSurfaceImpl *)((IWineD3DTextureImpl *)This->stateBlock->textures[textureNo])->surfaces[0])->pow2scalingFactorX;
15347+
15348+ }
15349 switch (coordsToUse) { /* Supply the provided texture coords */
15350 case D3DTTFF_COUNT1:
15351- VTRACE(("tex:%d, s=%f\n", textureNo, s));
15352+ VTRACE(("glMultiTexCoord1f:%d, s=%f\n", textureNo, s));
15353 if (GL_SUPPORT(ARB_MULTITEXTURE)) {
15354 GLMULTITEXCOORD1F(textureNo, s);
15355 } else {
15356@@ -1082,7 +1379,7 @@
15357 }
15358 break;
15359 case D3DTTFF_COUNT2:
15360- VTRACE(("tex:%d, s=%f, t=%f\n", textureNo, s, t));
15361+ VTRACE(("glMultiTexCoord2f:%d, s=%f, t=%f\n", textureNo, s, t));
15362 if (GL_SUPPORT(ARB_MULTITEXTURE)) {
15363 GLMULTITEXCOORD2F(textureNo, s, t);
15364 } else {
15365@@ -1090,7 +1387,7 @@
15366 }
15367 break;
15368 case D3DTTFF_COUNT3:
15369- VTRACE(("tex:%d, s=%f, t=%f, r=%f\n", textureNo, s, t, r));
15370+ VTRACE(("glMultiTexCoord3f:%d, s=%f, t=%f, r=%f\n", textureNo, s, t, r));
15371 if (GL_SUPPORT(ARB_MULTITEXTURE)) {
15372 GLMULTITEXCOORD3F(textureNo, s, t, r);
15373 } else {
15374@@ -1098,7 +1395,7 @@
15375 }
15376 break;
15377 case D3DTTFF_COUNT4:
15378- VTRACE(("tex:%d, s=%f, t=%f, r=%f, q=%f\n", textureNo, s, t, r, q));
15379+ VTRACE(("glMultiTexCoord4f:%d, s=%f, t=%f, r=%f, q=%f\n", textureNo, s, t, r, q));
15380 if (GL_SUPPORT(ARB_MULTITEXTURE)) {
15381 GLMULTITEXCOORD4F(textureNo, s, t, r, q);
15382 } else {
15383@@ -1112,8 +1409,9 @@
15384 }
15385 } /* End of textures */
15386
15387+
15388 /* Diffuse -------------------------------- */
15389- if (sd->u.s.diffuse.lpData != NULL) {
15390+ if (diffuse != NULL) {
15391 glColor4ub((diffuseColor >> 16) & 0xFF,
15392 (diffuseColor >> 8) & 0xFF,
15393 (diffuseColor >> 0) & 0xFF,
15394@@ -1124,11 +1422,14 @@
15395 ((diffuseColor >> 0) & 0xFF) / 255.0f,
15396 ((diffuseColor >> 24) & 0xFF) / 255.0f));
15397 } else {
15398- if (vx_index == 0) glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
15399+ if (vx_index == 0) {
15400+ glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
15401+ VTRACE(("glColor4f: r,g,b,a=%f,%f,%f,%f\n", 1.0f, 1.0f, 1.0f, 1.0f));
15402+ }
15403 }
15404
15405 /* Specular ------------------------------- */
15406- if (sd->u.s.diffuse.lpData != NULL) {
15407+ if (specular != NULL) {
15408 VTRACE(("glSecondaryColor4ub: r,g,b=%f,%f,%f\n",
15409 ((specularColor >> 16) & 0xFF) / 255.0f,
15410 ((specularColor >> 8) & 0xFF) / 255.0f,
15411@@ -1145,6 +1446,7 @@
15412 } else {
15413 if (vx_index == 0) {
15414 if (GL_SUPPORT(EXT_SECONDARY_COLOR)) {
15415+ VTRACE(("glSecondaryColor3fEXT: %d,%d,%d\n",0,0,0));
15416 GL_EXTCALL(glSecondaryColor3fEXT)(0, 0, 0);
15417 } else {
15418 /* Do not worry if specular colour missing and disable request */
15419@@ -1154,15 +1456,18 @@
15420 }
15421
15422 /* Normal -------------------------------- */
15423- if (sd->u.s.normal.lpData != NULL) {
15424+ if (normal != NULL) {
15425 VTRACE(("glNormal:nx,ny,nz=%f,%f,%f\n", nx,ny,nz));
15426 glNormal3f(nx, ny, nz);
15427 } else {
15428- if (vx_index == 0) glNormal3f(0, 0, 1);
15429+ if (vx_index == 0) {
15430+ VTRACE(("glNormal:nx,ny,nz=%f,%f,%f\n", 0F,0F,1F));
15431+ glNormal3f(0, 0, 1);
15432+ }
15433 }
15434
15435 /* Position -------------------------------- */
15436- if (sd->u.s.position.lpData != NULL) {
15437+ if (position != NULL) {
15438 if (1.0f == rhw || ((rhw < 0.0001f) && (rhw > -0.0001f))) {
15439 VTRACE(("Vertex: glVertex:x,y,z=%f,%f,%f\n", x,y,z));
15440 glVertex3f(x, y, z);
15441@@ -1173,12 +1478,48 @@
15442 }
15443 }
15444
15445+ if (blendWeights != NULL) {
15446+ if (GL_SUPPORT(ARB_VERTEX_BLEND)) {
15447+#if 0 /* TODO: blend support */
15448+ GL_EXTCALL(glWeightfvARB)(numBlends, (float *)bw);
15449+#endif
15450+ } else {
15451+ /* For a full software implementation do .... */
15452+ /* opengl translate the normal into eyespace using
15453+ n-1
15454+ (nx' ny' nz') = SUM w_i * (nx ny nz) Inv(Mu_i)
15455+ i=0
15456+ where Mu_i is the upper leftmost 3x3 matrix taken from the
15457+ model-view for vertex unit i, w_i is the vertex's
15458+ associated weight for vertex unit i, and
15459+
15460+ and
15461+
15462+ "When vertex blending is enabled, the vertex's eye
15463+ coordinates are found as:
15464+
15465+ (xe) n-1 (xo)
15466+ (ye) = SUM w_i * M_i * (yo)
15467+ (ze) i=0 (zo)
15468+ (we) (wo)
15469+
15470+ where M_i is the i'th model-view matrix, w_i is the
15471+ vertex's associated weight for vertex unit i,
15472+
15473+ and
15474+
15475+ n = ACTIVE_VERTEX_UNITS_ARB
15476+ "
15477+ */
15478+ }
15479+ }
15480+
15481 /* For non indexed mode, step onto next parts */
15482 if (idxData == NULL) {
15483- SkipnStrides += 1;
15484+ SkipnStrides++;
15485 }
15486 }
15487-
15488+ VTRACE("glEnd\n");
15489 glEnd();
15490 checkGLcall("glEnd and previous calls");
15491 }
15492@@ -1405,71 +1746,51 @@
15493 }
15494 #endif
15495
15496-/* Routine common to the draw primitive and draw indexed primitive routines */
15497-void drawPrimitive(IWineD3DDevice *iface,
15498- int PrimitiveType, long NumPrimitives,
15499
15500- /* for Indexed: */
15501- long StartVertexIndex,
15502- long StartIdx,
15503- short idxSize,
15504- const void *idxData,
15505- int minIndex) {
15506
15507- BOOL rc = FALSE;
15508- DWORD fvf = 0;
15509+/* Routine common to the draw primitive and draw indexed primitive routines
15510+ I'm going to split this out because it's a bit of a mess at the moment (and broken)
15511+ */
15512+inline void drawPimitiveVertexShaderInitilize(IWineD3DDeviceImpl *This, IWineD3DVertexShader **vertex_shader, int *useHW){
15513 #if 0 /* TODO: vertex and pixel shaders */
15514- IDirect3DVertexShaderImpl *vertex_shader = NULL;
15515- IDirect3DPixelShaderImpl *pixel_shader = NULL;
15516-#endif
15517- IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
15518- unsigned int i;
15519- BOOL useVertexShaderFunction = FALSE;
15520- BOOL isLightingOn = FALSE;
15521- Direct3DVertexStridedData dataLocations;
15522- int useHW = FALSE;
15523
15524- /* Work out what the FVF should look like */
15525- rc = initializeFVF(iface, &fvf, &useVertexShaderFunction);
15526- if (rc) return;
15527-
15528- /* If we will be using a vertex shader, do some initialization for it */
15529- if (useVertexShaderFunction) {
15530-#if 0 /* TODO: vertex and pixel shaders */
15531- vertex_shader = VERTEX_SHADER(This->updateStateBlock->VertexShader);
15532- memset(&vertex_shader->input, 0, sizeof(VSHADERINPUTDATA8));
15533+ *vertex_shader = VERTEX_SHADER(This->updateStateBlock->VertexShader);
15534+ memset(&(*vertex_shader)->input, 0, sizeof(VSHADERINPUTDATA0));
15535
15536- useHW = (((vs_mode == VS_HW) && GL_SUPPORT(ARB_VERTEX_PROGRAM)) &&
15537+ *useHW = (((vs_mode == VS_HW) && GL_SUPPORT(ARB_VERTEX_PROGRAM)) &&
15538 This->devType != D3DDEVTYPE_REF &&
15539 !This->stateBlock->renderState[D3DRS_SOFTWAREVERTEXPROCESSING] &&
15540- vertex_shader->usage != D3DUSAGE_SOFTWAREPROCESSING);
15541+ (*vertex_shader)->usage != D3DUSAGE_SOFTWAREPROCESSING);
15542
15543 /** init Constants */
15544 if (This->updateStateBlock->Changed.vertexShaderConstant) {
15545 TRACE_(d3d_shader)("vertex shader initializing constants\n");
15546- IDirect3DVertexShaderImpl_SetConstantF(vertex_shader, 0, (CONST FLOAT*) &This->updateStateBlock->vertexShaderConstant[0], 96);
15547+ IDirect3DVertexShaderImpl_SetConstantF(*vertex_shader, 0, (CONST FLOAT*) &This->updateStateBlock->vertexShaderConstant[0], 96);
15548 }
15549+
15550 #endif /* TODO: vertex and pixel shaders */
15551+
15552 }
15553
15554- /* Ok, we will be updating the screen from here onwards so grab the lock */
15555- ENTER_GL();
15556
15557-#if 0 /* TODO: vertex and pixel shaders */
15558+inline void drawPrimitivePixelShaderCrap(IWineD3DDeviceImpl *This, IWineD3DPixelShader **pixel_shader ){
15559+
15560+#if 0
15561+ int i;
15562 /* If we will be using a pixel, do some initialization for it */
15563- if ((pixel_shader = PIXEL_SHADER(This->updateStateBlock->PixelShader))) {
15564+ if ((*pixel_shader = PIXEL_SHADER(This->updateStateBlock->PixelShader))) {
15565 TRACE("drawing with pixel shader handle %p\n", pixel_shader);
15566- memset(&pixel_shader->input, 0, sizeof(PSHADERINPUTDATA8));
15567+ memset(&(*pixel_shader)->input, 0, sizeof(PSHADERINPUTDATA8));
15568
15569- GL_EXTCALL(glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, pixel_shader->prgId));
15570- checkGLcall("glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, pixel_shader->prgId);");
15571+ GL_EXTCALL(glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, (*pixel_shader)->prgId));
15572+ checkGLcall("glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, (*pixel_shader)->prgId);");
15573 glEnable(GL_FRAGMENT_PROGRAM_ARB);
15574 checkGLcall("glEnable(GL_FRAGMENT_PROGRAM_ARB);");
15575
15576 /* init Constants */
15577 if (This->updateStateBlock->Changed.pixelShaderConstant) {
15578- TRACE_(d3d_shader)("pixel shader initializing constants %p\n",pixel_shader);
15579- IDirect3DPixelShaderImpl_SetConstantF(pixel_shader, 0, (CONST FLOAT*) &This->updateStateBlock->pixelShaderConstant[0], 8);
15580+ TRACE_(d3d_shader)("pixel shader initializing constants %p\n",*pixel_shader);
15581+ IDirect3DPixelShaderImpl_SetConstantF((*pixel_shader), 0, (CONST FLOAT*) &This->updateStateBlock->pixelShaderConstant[0], 8);/* FIXME: use a global define instead of [0], 8*/
15582 }
15583 /* Update the constants */
15584 for (i=0; i<D3D8_PSHADER_MAX_CONSTANTS; i++) {
15585@@ -1477,107 +1798,226 @@
15586 checkGLcall("glProgramEnvParameter4fvARB(GL_FRAGMENT_PROGRAM_ARB");
15587 }
15588 }
15589-#endif /* TODO: vertex and pixel shaders */
15590+#endif
15591+}
15592
15593+/* This should be performed POST processing og FVF and vertexDecl*/
15594+BOOL inline drawPrimitiveSetupTransformMatrices(IWineD3DDevice *iface, int useHW, DWORD fvf, BOOL useVertexShaderFunction){
15595+ int isLightingOn;
15596 /* Setup transform matrices and sort out */
15597 if (useHW) {
15598 /* Lighting is not completely bypassed with ATI drivers although it should be. Mesa is ok from this respect...
15599 So make sure lighting is disabled. */
15600+
15601 isLightingOn = glIsEnabled(GL_LIGHTING);
15602 glDisable(GL_LIGHTING);
15603 checkGLcall("glDisable(GL_LIGHTING);");
15604 TRACE("Disabled lighting as no normals supplied, old state = %d\n", isLightingOn);
15605- } else
15606+ } else {
15607+ if(((IWineD3DDeviceImpl*)iface)->stateBlock->vertexDecl != NULL){
15608+
15609+ isLightingOn = primitiveInitState(iface, fvf & D3DFVF_XYZRHW, !(fvf & D3DFVF_NORMAL), useVertexShaderFunction);
15610+
15611+ }else{
15612 isLightingOn = primitiveInitState(iface,
15613 fvf & D3DFVF_XYZRHW,
15614 !(fvf & D3DFVF_NORMAL),
15615 useVertexShaderFunction);
15616+ }
15617+ }
15618
15619- /* Initialize all values to null */
15620- if (useVertexShaderFunction == FALSE) {
15621- memset(&dataLocations, 0x00, sizeof(dataLocations));
15622+ return isLightingOn;
15623+}
15624+
15625+void inline drawPrimitiveTraceDataLocations(Direct3DVertexStridedData *dataLocations,DWORD fvf){
15626
15627- /* Convert to strided data */
15628- primitiveConvertToStridedData(iface, &dataLocations, StartVertexIndex);
15629+ if((int) dataLocations == 0x406ef5c4) FIXME("Bad conversion\n");
15630+ if((int) dataLocations == 0x406ef588) FIXME("Bad conversion\n");
15631+ if((int) dataLocations == 0x406efad4) FIXME("Bad conversion\n");
15632
15633 /* Dump out what parts we have supplied */
15634 TRACE("Strided Data (from FVF/VS): %lx\n", fvf);
15635- TRACE_STRIDED((&dataLocations), position);
15636- TRACE_STRIDED((&dataLocations), blendWeights);
15637- TRACE_STRIDED((&dataLocations), blendMatrixIndices);
15638- TRACE_STRIDED((&dataLocations), normal);
15639- TRACE_STRIDED((&dataLocations), pSize);
15640- TRACE_STRIDED((&dataLocations), diffuse);
15641- TRACE_STRIDED((&dataLocations), specular);
15642- TRACE_STRIDED((&dataLocations), texCoords[0]);
15643- TRACE_STRIDED((&dataLocations), texCoords[1]);
15644- TRACE_STRIDED((&dataLocations), texCoords[2]);
15645- TRACE_STRIDED((&dataLocations), texCoords[3]);
15646- TRACE_STRIDED((&dataLocations), texCoords[4]);
15647- TRACE_STRIDED((&dataLocations), texCoords[5]);
15648- TRACE_STRIDED((&dataLocations), texCoords[6]);
15649- TRACE_STRIDED((&dataLocations), texCoords[7]);
15650- }
15651-
15652- /* Now initialize the materials state */
15653- init_materials(iface, (dataLocations.u.s.diffuse.lpData != NULL));
15654+ TRACE_STRIDED((dataLocations), position);
15655+ TRACE_STRIDED((dataLocations), blendWeights);
15656+ TRACE_STRIDED((dataLocations), blendMatrixIndices);
15657+ TRACE_STRIDED((dataLocations), normal);
15658+ TRACE_STRIDED((dataLocations), pSize);
15659+ TRACE_STRIDED((dataLocations), diffuse);
15660+ TRACE_STRIDED((dataLocations), specular);
15661+ TRACE_STRIDED((dataLocations), texCoords[0]);
15662+ TRACE_STRIDED((dataLocations), texCoords[1]);
15663+ TRACE_STRIDED((dataLocations), texCoords[2]);
15664+ TRACE_STRIDED((dataLocations), texCoords[3]);
15665+ TRACE_STRIDED((dataLocations), texCoords[4]);
15666+ TRACE_STRIDED((dataLocations), texCoords[5]);
15667+ TRACE_STRIDED((dataLocations), texCoords[6]);
15668+ TRACE_STRIDED((dataLocations), texCoords[7]);
15669+ return;
15670
15671+}
15672
15673+void inline drawPrimitiveUploadDirtyTextures(IWineD3DDeviceImpl* This){
15674+ int i;
15675 /* And re-upload any dirty textures */
15676 for (i=0; i<GL_LIMITS(textures); i++) {
15677-
15678 if ((This->stateBlock->textures[i] != NULL) &&
15679 (IWineD3DBaseTexture_GetDirty(This->stateBlock->textures[i])))
15680 {
15681 /* Load up the texture now */
15682 IWineD3DTexture_PreLoad((IWineD3DTexture *) This->stateBlock->textures[i]);
15683- /* TODO: Is this right, as its cast all texture types to texture8... checkme */
15684 }
15685 }
15686
15687+}
15688+
15689+void inline drawPrimitiveDrawStrided(IWineD3DDevice *iface, BOOL useVertexShaderFunction, int useHW, Direct3DVertexStridedData *dataLocations, int PrimitiveType, long NumPrimitives, const void *idxData, short idxSize, int minIndex, long StartIdx){
15690+ IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
15691+
15692+
15693 /* Now draw the graphics to the screen */
15694 if (useVertexShaderFunction) {
15695-
15696+ FIXME("line %d Vertex shaders\n", __LINE__);
15697 /* Ideally, we should have software FV and hardware VS, possibly
15698 depending on the device type? */
15699
15700 if (useHW) {
15701- TRACE("Swap HW vertex shader\n");
15702+ FIXME("Swap HW vertex shader\n");
15703 #if 0 /* TODO: vertex and pixel shaders */
15704- drawStridedHardwareVS(iface, &dataLocations, PrimitiveType, NumPrimitives,
15705+ drawStridedHardwareVS(iface, dataLocations, PrimitiveType, NumPrimitives,
15706 idxData, idxSize, minIndex, StartIdx);
15707 #endif
15708 } else {
15709 /* We will have to use the very, very slow emulation layer */
15710- TRACE("Swap SW vertex shader\n");
15711+ FIXME("Swap SW vertex shader\n");
15712 #if 0 /* TODO: vertex and pixel shaders */
15713- drawStridedSoftwareVS(iface, &dataLocations, PrimitiveType, NumPrimitives,
15714+ drawStridedSoftwareVS(iface, dataLocations, PrimitiveType, NumPrimitives,
15715 idxData, idxSize, minIndex, StartIdx);
15716 #endif
15717 }
15718
15719- } else if ((dataLocations.u.s.pSize.lpData != NULL)
15720- || (dataLocations.u.s.diffuse.lpData != NULL)
15721- /*|| (dataLocations.u.s.blendWeights.lpData != NULL)*/) {
15722-
15723- /* Fixme, Ideally, only use the per-vertex code for software HAL
15724- but until opengl supports all the functions returned to setup
15725- vertex arrays, we need to drop down to the slow mechanism for
15726- certain functions */
15727+ } else
15728+ {
15729+ /* FIXME: change non-power2 textures to use a texture transform matrix
15730+ make this check 'cheeper' by flagging nonpower2 textures in setTexture. */
15731+ BOOL nonpower2 = FALSE;
15732+ int textureNo;
15733+ for (textureNo = 0 ; textureNo < 8 ;textureNo++){
15734+ if(This->stateBlock->textures[textureNo] != NULL){
15735+ if(((IWineD3DSurfaceImpl *) ((IWineD3DTextureImpl *)This->stateBlock->textures[textureNo])->surfaces[0])->nonpow2){
15736+ nonpower2 = TRUE;
15737+ break;
15738+
15739+ }
15740+ }
15741+ }
15742
15743- /* We will have to use the slow version of GL per vertex setup */
15744- drawStridedSlow(iface, &dataLocations, PrimitiveType, NumPrimitives,
15745+ if(nonpower2){
15746+ /* each texture coord gets rescaled for non-power-2, so we can't use hardware drawing
15747+ TODO: use a texture transform martix so that ahardware cna be used to draw nom-power-2 textures
15748+ */
15749+ drawStridedSlow(iface, dataLocations, PrimitiveType, NumPrimitives,
15750 idxData, idxSize, minIndex, StartIdx);
15751+ }else{
15752+ /* We can use the fast version of GL pointers
15753+ NOTE: ATI-drivers < 8.10.19 have problems with this method */
15754+ if(!drawStridedFast(iface, dataLocations, PrimitiveType, NumPrimitives,
15755+ idxData, idxSize, minIndex, StartIdx)){
15756+ drawStridedSlow(iface, dataLocations, PrimitiveType, NumPrimitives,
15757+ idxData, idxSize, minIndex, StartIdx);
15758+
15759+ }
15760+
15761+ }
15762+ }
15763+
15764+
15765+}
15766+
15767+void drawPrimitive(IWineD3DDevice *iface,
15768+ int PrimitiveType, long NumPrimitives,
15769+
15770+ /* for Indexed: */
15771+ long StartVertexIndex,
15772+ long StartIdx,
15773+ short idxSize,
15774+ const void *idxData,
15775+ int minIndex) {
15776+
15777+ BOOL rc = FALSE;
15778+ DWORD fvf =0;
15779+#if 0 /* TODO: vertex and pixel shaders */
15780+ IDirect3DVertexShaderImpl *vertex_shader = NULL;
15781+ IDirect3DPixelShaderImpl *pixel_shader = NULL;
15782+#endif
15783+ IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
15784+ BOOL useVertexShaderFunction = FALSE; /* needs to be moved to flags so
15785+ that extensations can easly be added*/
15786+ BOOL isLightingOn = FALSE;
15787+ Direct3DVertexStridedData dataLocations;
15788+ int useHW = FALSE;
15789+
15790+
15791+#if 0
15792+ /* If we will be using a vertex shader, do some initialization for it */
15793+ if (useVertexShaderFunction) {
15794+ drawPimitiveVertexShaderInitilize(This, vertex_shader, useHW);
15795+ }
15796+#endif
15797+ if(This->stateBlock->vertexDecl == NULL){
15798+ /* This needs to be a bit differnt for vertexDecl's
15799+ Work out what the FVF should look like */
15800+ rc = initializeFVF(iface, &fvf, &useVertexShaderFunction);
15801+ if (rc) return;
15802
15803 } else {
15804+ TRACE("using vertex declaration\n");
15805+ }
15806+ /* Ok, we will be updating the screen from here onwards so grab the lock */
15807+ ENTER_GL();
15808
15809- /* We can use the fast version of GL pointers */
15810- drawStridedFast(iface, &dataLocations, PrimitiveType, NumPrimitives,
15811- idxData, idxSize, minIndex, StartIdx);
15812+#if 0 /* TODO: vertex and pixel shaders */
15813+ drawPrimitivePixelShaderCrap(This, &pixel_shader );
15814+#endif /* TODO: vertex and pixel shaders */
15815+
15816+
15817+
15818+
15819+ /* Initialize all values to null */
15820+ if (useVertexShaderFunction == FALSE) {
15821+ memset(&dataLocations, 0x00, sizeof(dataLocations));
15822+
15823+ /* Convert to strided data, this isn't working properly at the moment,
15824+ probably because DirectX not supports data split across streams */
15825+ if(This->stateBlock->vertexDecl != NULL){
15826+/* TRACE("================ Vertex Declaration ++ ===================\n");*/
15827+ primitiveDeclarationConvertToStridedData(iface, &dataLocations, StartVertexIndex, &fvf);
15828+ }else{
15829+/* TRACE("================ Vertex Declaration -- ===================\n");*/
15830+ primitiveConvertToStridedData(iface, &dataLocations, StartVertexIndex);
15831+ }
15832+ /* write out some debug information*/
15833+ drawPrimitiveTraceDataLocations(&dataLocations, fvf);
15834+ }else{
15835+ FIXME("line %d Vertex shaders\n", __LINE__);
15836 }
15837
15838+ /* This must happen after setting up the data, because we don't have a fvf*/
15839+ isLightingOn = drawPrimitiveSetupTransformMatrices(iface, useHW, fvf, useVertexShaderFunction);
15840+
15841+
15842+ /* Now initialize the materials state */
15843+ TRACE("init_materials\n");
15844+ init_materials(iface, (dataLocations.u.s.diffuse.lpData != NULL));
15845+
15846+ drawPrimitiveUploadDirtyTextures(This);
15847+
15848+ drawPrimitiveDrawStrided(iface, useVertexShaderFunction, useHW, &dataLocations, PrimitiveType, NumPrimitives, idxData, idxSize, minIndex, StartIdx);
15849+
15850+
15851+
15852 /* If vertex shaders or no normals, restore previous lighting state */
15853 if (useVertexShaderFunction || !(fvf & D3DFVF_NORMAL)) {
15854+
15855 if (isLightingOn) glEnable(GL_LIGHTING);
15856 else glDisable(GL_LIGHTING);
15857 TRACE("Restored lighting to original state\n");
15858@@ -1600,35 +2040,37 @@
15859 LEAVE_GL();
15860 TRACE("Done all gl drawing\n");
15861
15862- /* Diagnostics */
15863-#if defined(SHOW_FRAME_MAKEUP)
15864+
15865+ /* Diagnostics (may be an idea to save out the strided data too so that the whole draw can be recreated) */
15866+#ifdef SHOW_FRAME_MAKEUP
15867 {
15868 if (isDumpingFrames) {
15869 D3DLOCKED_RECT r;
15870 char buffer[80];
15871- IDirect3DSurface8Impl_LockRect((LPDIRECT3DSURFACE8) This->renderTarget, &r, NULL, D3DLOCK_READONLY);
15872+ IWineD3DSurface_LockRect((IWineD3DSurface*) This->renderTarget, &r, NULL, D3DLOCK_READONLY);
15873 sprintf(buffer, "/tmp/backbuffer_%ld.ppm", primCounter);
15874 TRACE("Saving screenshot %s\n", buffer);
15875- IDirect3DSurface8Impl_SaveSnapshot((LPDIRECT3DSURFACE8) This->renderTarget, buffer);
15876- IDirect3DSurface8Impl_UnlockRect((LPDIRECT3DSURFACE8) This->renderTarget);
15877+ IWineD3DSurface_SaveSnapshot((IWineD3DSurface*) This->renderTarget, buffer);
15878+ IWineD3DSurface_UnlockRect((IWineD3DSurface*) This->renderTarget);
15879
15880-#if defined(SHOW_TEXTURE_MAKEUP)
15881+#ifdef SHOW_TEXTURE_MAKEUP
15882 {
15883- LPDIRECT3DSURFACE8 pSur;
15884+ IWineD3DSurface* pSur;
15885 int textureNo;
15886 for (textureNo = 0; textureNo < GL_LIMITS(textures); ++textureNo) {
15887 if (This->stateBlock->textures[textureNo] != NULL) {
15888 sprintf(buffer, "/tmp/texture_%ld_%d.ppm", primCounter, textureNo);
15889- TRACE("Saving texture %s (Format:%s)\n", buffer, debug_d3dformat(((IDirect3DBaseTexture8Impl *)This->stateBlock->textures[textureNo])->format));
15890- IDirect3DTexture8Impl_GetSurfaceLevel((LPDIRECT3DTEXTURE8) This->stateBlock->textures[textureNo], 0, &pSur);
15891- IDirect3DSurface8Impl_SaveSnapshot(pSur, buffer);
15892- IDirect3DSurface8Impl_Release(pSur);
15893+ TRACE("Saving texture %s (Format:%s)\n", buffer, debug_d3dformat(((IWineD3DBaseTextureImpl *)This->stateBlock->textures[textureNo])->format));
15894+ IWineD3DTexture_GetSurfaceLevel((IWineD3DTexture*) This->stateBlock->textures[textureNo], 0, &pSur);
15895+ IWineD3DSurface_SaveSnapshot(pSur, buffer);
15896+ IWineD3DSurface_Release(pSur);
15897 }
15898 }
15899 }
15900 #endif
15901- primCounter = primCounter + 1;
15902+ primCounter++;
15903 }
15904 }
15905 #endif
15906+
15907 }
15908diff -urN wine.20050419/dlls/wined3d/listfuncs.c wine.20050419.dx9/dlls/wined3d/listfuncs.c
15909--- wine.20050419/dlls/wined3d/listfuncs.c 1969-12-31 17:00:00.000000000 -0700
15910+++ wine.20050419.dx9/dlls/wined3d/listfuncs.c 2005-04-20 01:52:56.000000000 -0600
15911@@ -0,0 +1,210 @@
15912+/*
15913+ * IListOperator and IListStore implementations
15914+ *
15915+ * Copyright 2005 Oliver Stieber
15916+ *
15917+ * This library is free software; you can redistribute it and/or
15918+ * modify it under the terms of the GNU Lesser General Public
15919+ * License as published by the Free Software Foundation; either
15920+ * version 2.1 of the License, or (at your option) any later version.
15921+ *
15922+ * This library is distributed in the hope that it will be useful,
15923+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
15924+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15925+ * Lesser General Public License for more details.
15926+ *
15927+ * You should have received a copy of the GNU Lesser General Public
15928+ * License along with this library; if not, write to the Free Software
15929+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
15930+ */
15931+
15932+
15933+ /* NOTE: This code is only here if/until it gets moved to a more central part of wine */
15934+
15935+ /** ********************************
15936+ Basic usage notes
15937+
15938+ IListOperator and IListStore provide optionally thread safe
15939+ asynchronious access to data stored in a linked list.
15940+
15941+ To use.
15942+
15943+
15944+ Create a threadSafe store with a standalone critical section
15945+
15946+ IListStore* myDataStore;
15947+ CreateListStore( TRUE, NULL, &myDataStore);
15948+
15949+
15950+ Create a threadSafe store with a shared critical section
15951+
15952+ IListStore* myDataStore1;
15953+ IListStore* myDataStore2;
15954+ BOOL threadSafe = TRUE;
15955+ CRITICALSECTION sharedCriticalSection;
15956+ CreateCriticalSection(&sharedCriticalSection);
15957+
15958+ CreateListStore( TRUE, &sharedCriticalSection, &myDataStore1);
15959+ CreateListStore( TRUE, &sharedCriticalSection, &myDataStore2);
15960+
15961+ Using a shared critical section cuts down on the number of critical sections, and may be a better locking policy for your calss.
15962+
15963+
15964+ Create a non-thread safe store
15965+
15966+ IListStore* myDataStore;
15967+ CreateListStore( FALSE, NULL, &myDataStore);
15968+
15969+
15970+ Using the data...
15971+ To access, add and remove data from the store you must use IListOperator,
15972+ this will insure that all data access obays the threading method requested..
15973+
15974+
15975+ asynchrionous thread safe access is provided by reference counting and invalidating list members.
15976+ The operators garantee that the data was valid when requested,
15977+ and won't invalidate the data until all opertors using the data are no longer looking at it.
15978+
15979+ so you can be sure that the data pointer to by the result of a next statement will be
15980+ valid until you issue the next 'next' statement, you destroy the iterator or you call release of the data
15981+ even if another thread can release while you still hold a pointer to the data.
15982+ ISStillValid sill erturn false if the data has been released by another thread.
15983+
15984+ The contents of the data is not gaurenteed,
15985+ you will need to use your own critical sections or referecning mechinisms to enssure that.
15986+ (see tests for examples)
15987+
15988+
15989+ ** ************************************************************************************/
15990+
15991+HRESULT WINAPI IListStoreImpl_QueryInterface(IListStore* iface,){
15992+ IListStoreImpl *This = (IListStoreImpl *)iface;
15993+ FIXME("This shouldn't be called, no GUIDS generated yet. \n");
15994+ return E_NOINTERFACE;
15995+
15996+}
15997+
15998+ULONG WINAPI IListStoreImpl_AddRef(IListStore* iface){
15999+ IListStoreImpl *This = (IListStoreImpl *)iface;
16000+
16001+}
16002+
16003+ULONG WINAPI IListStoreImpl_Release(IListStore* iface){
16004+ IListStoreImpl *This = (IListStoreImpl *)iface;
16005+
16006+}
16007+
16008+
16009+HRESULT WINAPI IListStoreImpl_CreateListOperator(IListStore* iface, IListOperator** listOperator){
16010+ IListStoreImpl *This = (IListStoreImpl *)iface;
16011+
16012+}
16013+
16014+HRESULT WINAPI IListOperatorImpl_QueryInterface(IListOperator* iface, REFIID riid, LPVOID *ppobj){
16015+ IListOperatorImpl *This = (IListOperatorImpl *)iface;
16016+ FIXME("This shouldn't be called, no GUIDS generated yet. \n");
16017+ return E_NOINTERFACE;
16018+}
16019+
16020+ULONG WINAPI IListOperatorImpl_AddRef(IListOperator* iface){
16021+ IListOperatorImpl *This = (IListOperatorImpl *)iface;
16022+
16023+}
16024+
16025+ULONG WINAPI IListOperatorImpl_Release(IListOperator* iface){
16026+ IListOperatorImpl *This = (IListOperatorImpl *)iface;
16027+ if(This->store->criticalSection != NULL)
16028+ EnterCriticalSection(This->criticalSection);
16029+
16030+ IListItem_Release(currentItem);
16031+ This->currentItem = NULL;
16032+ if(This->store->criticalSection != NULL)
16033+ LeaveCriticalSection(This->criticalSection);
16034+
16035+ IListStore_Release(This->list);
16036+ /* The cricital section may be invalid after the list has been released. */
16037+ HeapFree(GetProcessHeap() ,0 , This);
16038+
16039+
16040+}
16041+HRESULT WINAPI IListOperatorImpl_Remove(IListOperator* iface, void* data){
16042+ IListOperatorImpl *This = (IListOperatorImpl *)iface;
16043+ /* This invalidates and the releases */
16044+
16045+}
16046+unsigned int WINAPI IListOperatorImpl_Add(IListOperator* iface, void* data){
16047+ IListOperatorImpl *This = (IListOperatorImpl *)iface;
16048+
16049+}
16050+
16051+void * WINAPI IListOperatorImpl_Next(IListOperator* iface){
16052+ IListOperatorImpl *This = (IListOperatorImpl *)iface;
16053+ balh *listItem = NULL;
16054+
16055+ if(This->currentItem != NULL){
16056+ if(This->store->criticalSection != NULL)
16057+ EnterCriticalSection(This->criticalSection);
16058+
16059+
16060+ if( 0 == IListItem_Release(currentItem))){
16061+ /* what's the cleanest way of doing this... */
16062+ This->currentItem = This->currentItem->next
16063+ HeapFree(GetProcessHeap(), 0,
16064+ }else{
16065+ This->currentItem = This->currentItem->next
16066+ }
16067+ while(This->currentItem != NULL && This->currentItem->valid == false)
16068+ This->currentItem = This->currentItem->next;
16069+
16070+ IListItem_AddRef(This->currentItem);
16071+
16072+ listItem = This->currentItem;
16073+
16074+ if(This->store->criticalSection != NULL)
16075+ LeaveCriticalSection(This->criticalSection);
16076+ }
16077+
16078+ return listItem;
16079+
16080+}
16081+unsigned int WINAPI IListOperatorImpl_Find(IListOperator* iface, void* data){
16082+ IListOperatorImpl *This = (IListOperatorImpl *)iface;
16083+
16084+ IListOperatorImpl *This = (IListOperatorImpl *)iface;
16085+ unsigned int count = 0;
16086+ balh *listItem;
16087+ if(This->store->criticalSection != NULL)
16088+ EnterCriticalSection(This->criticalSection);
16089+
16090+ for(listItem = This->store->first; (listItem->data != data) && (listItem->valid == TRUE); listItem = listItem->next)
16091+ count++
16092+
16093+ if(This->store->criticalSection != NULL)
16094+ LeaveCriticalSection(This->criticalSection);
16095+
16096+ return if(listItem == NULL)?-1:count;
16097+}
16098+
16099+unsigned int WINAPI IListOperatorImpl_Count(IListOperator* iface){
16100+ IListOperatorImpl *This = (IListOperatorImpl *)iface;
16101+ unsigned int count = 0;
16102+ balh *listItem;
16103+ if(This->store->criticalSection != NULL)
16104+ EnterCriticalSection(This->criticalSection);
16105+
16106+ for(listItem = This->store->first; listItem != NULL; listItem = listItem->next)
16107+ if(listItem->valid == TRUE) count++
16108+ if(This->store->criticalSection != NULL)
16109+ LeaveCriticalSection(This->criticalSection);
16110+
16111+ return count;
16112+}
16113+
16114+HRESULT WINAPI IListOperatorImpl_IsStillValid(IListOperator* iface, void* data){
16115+ IListOperatorImpl *This = (IListOperatorImpl *)iface;
16116+
16117+}
16118+HRESULT WINAPI IListOperatorImpl_Get(IListOperator* iface, unsigned int pos, void **data){
16119+ IListOperatorImpl *This = (IListOperatorImpl *)iface;
16120+
16121+}
16122diff -urN wine.20050419/dlls/wined3d/pixelshader.c wine.20050419.dx9/dlls/wined3d/pixelshader.c
16123--- wine.20050419/dlls/wined3d/pixelshader.c 1969-12-31 17:00:00.000000000 -0700
16124+++ wine.20050419.dx9/dlls/wined3d/pixelshader.c 2005-04-20 01:52:56.000000000 -0600
16125@@ -0,0 +1,122 @@
16126+/*
16127+ * shaders implementation
16128+ *
16129+ * Copyright 2005 Oliver Stieber
16130+ *
16131+ * This library is free software; you can redistribute it and/or
16132+ * modify it under the terms of the GNU Lesser General Public
16133+ * License as published by the Free Software Foundation; either
16134+ * version 2.1 of the License, or (at your option) any later version.
16135+ *
16136+ * This library is distributed in the hope that it will be useful,
16137+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
16138+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16139+ * Lesser General Public License for more details.
16140+ *
16141+ * You should have received a copy of the GNU Lesser General Public
16142+ * License along with this library; if not, write to the Free Software
16143+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16144+ */
16145+
16146+#include "config.h"
16147+
16148+#include <math.h>
16149+
16150+#include "wined3d_private.h"
16151+
16152+WINE_DEFAULT_DEBUG_CHANNEL(d3d_shader);
16153+
16154+
16155+/* *******************************************
16156+ IWineD3DPixelShader IUnknown parts follow
16157+ ******************************************* */
16158+HRESULT WINAPI IWineD3DPixelShaderImpl_QueryInterface(IWineD3DPixelShader *iface, REFIID riid, LPVOID *ppobj)
16159+{
16160+ IWineD3DPixelShaderImpl *This = (IWineD3DPixelShaderImpl *)iface;
16161+ TRACE("(%p)->(%s,%p)\n",This,debugstr_guid(riid),ppobj);
16162+ if (IsEqualGUID(riid, &IID_IUnknown)
16163+ || IsEqualGUID(riid, &IID_IWineD3DPixelShader)) {
16164+ IUnknown_AddRef(iface);
16165+ *ppobj = This;
16166+ return D3D_OK;
16167+ }
16168+ return E_NOINTERFACE;
16169+}
16170+
16171+ULONG WINAPI IWineD3DPixelShaderImpl_AddRef(IWineD3DPixelShader *iface) {
16172+ IWineD3DPixelShaderImpl *This = (IWineD3DPixelShaderImpl *)iface;
16173+ TRACE("(%p) : AddRef increasing from %ld\n", This, This->ref);
16174+ return InterlockedIncrement(&This->ref);
16175+}
16176+
16177+ULONG WINAPI IWineD3DPixelShaderImpl_Release(IWineD3DPixelShader *iface) {
16178+ IWineD3DPixelShaderImpl *This = (IWineD3DPixelShaderImpl *)iface;
16179+ ULONG ref;
16180+ TRACE("(%p) : Releasing from %ld\n", This, This->ref);
16181+ ref = InterlockedDecrement(&This->ref);
16182+ if (ref == 0) {
16183+ HeapFree(GetProcessHeap(), 0, This);
16184+ }
16185+ return ref;
16186+}
16187+
16188+/* *******************************************
16189+ IWineD3DPixelShader IWineD3DPixelShader parts follow
16190+ ******************************************* */
16191+
16192+HRESULT WINAPI IWineD3DPixelShaderImpl_GetParent(IWineD3DPixelShader *iface, IUnknown** parent){
16193+ IWineD3DPixelShaderImpl *This = (IWineD3DPixelShaderImpl *)iface;
16194+
16195+ *parent= (IUnknown*) parent;
16196+ IUnknown_AddRef(*parent);
16197+ TRACE("(%p) : returning %p\n", This, *parent);
16198+ return D3D_OK;
16199+}
16200+
16201+HRESULT WINAPI IWineD3DPixelShaderImpl_GetDevice(IWineD3DPixelShader* iface, IWineD3DDevice **pDevice){
16202+ IWineD3DPixelShaderImpl *This = (IWineD3DPixelShaderImpl *)iface;
16203+ IWineD3DDevice_AddRef((IWineD3DDevice *)This->wineD3DDevice);
16204+ *pDevice = (IWineD3DDevice *)This->wineD3DDevice;
16205+ TRACE("(%p) returning %p\n", This, *pDevice);
16206+ return D3D_OK;
16207+}
16208+
16209+
16210+HRESULT WINAPI IWineD3DPixelShaderImpl_GetFunction(IWineD3DPixelShader* impl, VOID* pData, UINT* pSizeOfData) {
16211+ IWineD3DPixelShaderImpl *This = (IWineD3DPixelShaderImpl *)impl;
16212+ FIXME("(%p) : pData(%p), pSizeOfData(%p)\n", This, pData, pSizeOfData);
16213+
16214+ if (NULL == pData) {
16215+ *pSizeOfData = This->functionLength;
16216+ return D3D_OK;
16217+ }
16218+ if (*pSizeOfData < This->functionLength) {
16219+ *pSizeOfData = This->functionLength;
16220+ return D3DERR_MOREDATA;
16221+ }
16222+ if (NULL == This->function) { /* no function defined */
16223+ TRACE("(%p) : GetFunction no User Function defined using NULL to %p\n", This, pData);
16224+ (*(DWORD **) pData) = NULL;
16225+ } else {
16226+ if(This->functionLength == 0){
16227+
16228+ }
16229+ TRACE("(%p) : GetFunction copying to %p\n", This, pData);
16230+ memcpy(pData, This->function, This->functionLength);
16231+ }
16232+ return D3D_OK;
16233+}
16234+
16235+
16236+
16237+IWineD3DPixelShaderVtbl IWineD3DPixelShader_Vtbl =
16238+{
16239+ /*** IUnknown methods ***/
16240+ IWineD3DPixelShaderImpl_QueryInterface,
16241+ IWineD3DPixelShaderImpl_AddRef,
16242+ IWineD3DPixelShaderImpl_Release,
16243+ /*** IWineD3DPixelShader methods ***/
16244+ IWineD3DPixelShaderImpl_GetParent,
16245+ IWineD3DPixelShaderImpl_GetDevice,
16246+ IWineD3DPixelShaderImpl_GetFunction
16247+};
16248diff -urN wine.20050419/dlls/wined3d/stateblock.c wine.20050419.dx9/dlls/wined3d/stateblock.c
16249--- wine.20050419/dlls/wined3d/stateblock.c 2005-03-03 06:57:15.000000000 -0700
16250+++ wine.20050419.dx9/dlls/wined3d/stateblock.c 2005-04-20 01:52:56.000000000 -0600
16251@@ -27,7 +27,7 @@
16252 #define GLINFO_LOCATION ((IWineD3DImpl *)(((IWineD3DDeviceImpl *)This->wineD3DDevice)->wineD3D))->gl_info
16253
16254 /**********************************************************
16255- * IWineD3DStateBlockImpl IUnknown parts follows
16256+ * IUnknown parts follows
16257 **********************************************************/
16258 HRESULT WINAPI IWineD3DStateBlockImpl_QueryInterface(IWineD3DStateBlock *iface,REFIID riid,LPVOID *ppobj)
16259 {
16260@@ -57,15 +57,12 @@
16261 TRACE("(%p) : Releasing from %ld\n", This, refCount + 1);
16262
16263 if (!refCount) {
16264- IWineD3DDevice_Release((IWineD3DDevice *)This->wineD3DDevice);
16265+ /* The applicaion is responsible for making sure the texture references are cleared down */
16266 HeapFree(GetProcessHeap(), 0, This);
16267 }
16268 return refCount;
16269 }
16270
16271-/**********************************************************
16272- * IWineD3DStateBlockImpl parts follows
16273- **********************************************************/
16274 HRESULT WINAPI IWineD3DStateBlockImpl_GetParent(IWineD3DStateBlock *iface, IUnknown **pParent) {
16275 IWineD3DStateBlockImpl *This = (IWineD3DStateBlockImpl *)iface;
16276 IUnknown_AddRef(This->parent);
16277@@ -76,10 +73,12 @@
16278 HRESULT WINAPI IWineD3DStateBlockImpl_InitStartupStateBlock(IWineD3DStateBlock* iface) {
16279 IWineD3DStateBlockImpl *This = (IWineD3DStateBlockImpl *)iface;
16280 IWineD3DDeviceImpl *ThisDevice = (IWineD3DDeviceImpl *)(This->wineD3DDevice);
16281+ #if 0 /*TODO: d3d8*/
16282 union {
16283 D3DLINEPATTERN lp;
16284 DWORD d;
16285 } lp;
16286+ #endif
16287 union {
16288 float f;
16289 DWORD d;
16290@@ -89,7 +88,7 @@
16291 /* Note this may have a large overhead but it should only be executed
16292 once, in order to initialize the complete state of the device and
16293 all opengl equivalents */
16294- TRACE("-----------------------> Setting up device defaults...\n");
16295+ TRACE("(%p) -----------------------> Setting up device defaults... %p \n",This,This->wineD3DDevice);
16296 This->blockType = D3DSBT_ALL;
16297
16298 /* FIXME: Set some of the defaults for lights, transforms etc */
16299@@ -98,47 +97,52 @@
16300 for (i = 0; i < 256; ++i) {
16301 memcpy(&This->transforms[D3DTS_WORLDMATRIX(i)], &identity, sizeof(identity));
16302 }
16303-
16304+ TRACE("Render states\n");
16305 /* Render states: */
16306- if (ThisDevice->presentParms.EnableAutoDepthStencil) {
16307- IWineD3DDevice_SetRenderState((IWineD3DDevice *)This->wineD3DDevice, WINED3DRS_ZENABLE, D3DZB_TRUE);
16308+ if (ThisDevice->depthStencilBuffer != NULL) {
16309+ IWineD3DDevice_SetRenderState((IWineD3DDevice *)This->wineD3DDevice, D3DRS_ZENABLE, D3DZB_TRUE);
16310 } else {
16311 IWineD3DDevice_SetRenderState((IWineD3DDevice *)This->wineD3DDevice, WINED3DRS_ZENABLE, D3DZB_FALSE);
16312 }
16313- IWineD3DDevice_SetRenderState((IWineD3DDevice *)This->wineD3DDevice, WINED3DRS_FILLMODE, D3DFILL_SOLID);
16314- IWineD3DDevice_SetRenderState((IWineD3DDevice *)This->wineD3DDevice, WINED3DRS_SHADEMODE, D3DSHADE_GOURAUD);
16315-
16316+ IWineD3DDevice_SetRenderState((IWineD3DDevice *)This->wineD3DDevice, D3DRS_FILLMODE, D3DFILL_SOLID);
16317+ IWineD3DDevice_SetRenderState((IWineD3DDevice *)This->wineD3DDevice, D3DRS_SHADEMODE, D3DSHADE_GOURAUD);
16318+ #if 0 /*FIXME: d3d8*/
16319 lp.lp.wRepeatFactor = 0; lp.lp.wLinePattern = 0;
16320- IWineD3DDevice_SetRenderState((IWineD3DDevice *)This->wineD3DDevice, WINED3DRS_LINEPATTERN, lp.d);
16321- IWineD3DDevice_SetRenderState((IWineD3DDevice *)This->wineD3DDevice, WINED3DRS_ZWRITEENABLE, TRUE);
16322- IWineD3DDevice_SetRenderState((IWineD3DDevice *)This->wineD3DDevice, WINED3DRS_ALPHATESTENABLE, FALSE);
16323- IWineD3DDevice_SetRenderState((IWineD3DDevice *)This->wineD3DDevice, WINED3DRS_LASTPIXEL, TRUE);
16324- IWineD3DDevice_SetRenderState((IWineD3DDevice *)This->wineD3DDevice, WINED3DRS_SRCBLEND, D3DBLEND_ONE);
16325- IWineD3DDevice_SetRenderState((IWineD3DDevice *)This->wineD3DDevice, WINED3DRS_DESTBLEND, D3DBLEND_ZERO);
16326- IWineD3DDevice_SetRenderState((IWineD3DDevice *)This->wineD3DDevice, WINED3DRS_CULLMODE, D3DCULL_CCW);
16327- IWineD3DDevice_SetRenderState((IWineD3DDevice *)This->wineD3DDevice, WINED3DRS_ZFUNC, D3DCMP_LESSEQUAL);
16328- IWineD3DDevice_SetRenderState((IWineD3DDevice *)This->wineD3DDevice, WINED3DRS_ALPHAFUNC, D3DCMP_ALWAYS);
16329- IWineD3DDevice_SetRenderState((IWineD3DDevice *)This->wineD3DDevice, WINED3DRS_ALPHAREF, 0xff); /*??*/
16330- IWineD3DDevice_SetRenderState((IWineD3DDevice *)This->wineD3DDevice, WINED3DRS_DITHERENABLE, FALSE);
16331- IWineD3DDevice_SetRenderState((IWineD3DDevice *)This->wineD3DDevice, WINED3DRS_ALPHABLENDENABLE, FALSE);
16332- IWineD3DDevice_SetRenderState((IWineD3DDevice *)This->wineD3DDevice, WINED3DRS_FOGENABLE, FALSE);
16333- IWineD3DDevice_SetRenderState((IWineD3DDevice *)This->wineD3DDevice, WINED3DRS_SPECULARENABLE, FALSE);
16334- IWineD3DDevice_SetRenderState((IWineD3DDevice *)This->wineD3DDevice, WINED3DRS_ZVISIBLE, 0);
16335- IWineD3DDevice_SetRenderState((IWineD3DDevice *)This->wineD3DDevice, WINED3DRS_FOGCOLOR, 0);
16336- IWineD3DDevice_SetRenderState((IWineD3DDevice *)This->wineD3DDevice, WINED3DRS_FOGTABLEMODE, D3DFOG_NONE);
16337+ IWineD3DDevice_SetRenderState((IWineD3DDevice *)This->wineD3DDevice, D3DRS_LINEPATTERN, lp.d);
16338+ #endif
16339+ IWineD3DDevice_SetRenderState((IWineD3DDevice *)This->wineD3DDevice, D3DRS_ZWRITEENABLE, TRUE);
16340+ IWineD3DDevice_SetRenderState((IWineD3DDevice *)This->wineD3DDevice, D3DRS_ALPHATESTENABLE, FALSE);
16341+ IWineD3DDevice_SetRenderState((IWineD3DDevice *)This->wineD3DDevice, D3DRS_LASTPIXEL, TRUE);
16342+ IWineD3DDevice_SetRenderState((IWineD3DDevice *)This->wineD3DDevice, D3DRS_SRCBLEND, D3DBLEND_ONE);
16343+ IWineD3DDevice_SetRenderState((IWineD3DDevice *)This->wineD3DDevice, D3DRS_DESTBLEND, D3DBLEND_ZERO);
16344+ IWineD3DDevice_SetRenderState((IWineD3DDevice *)This->wineD3DDevice, D3DRS_CULLMODE, D3DCULL_CCW);
16345+ IWineD3DDevice_SetRenderState((IWineD3DDevice *)This->wineD3DDevice, D3DRS_ZFUNC, D3DCMP_LESSEQUAL);
16346+ IWineD3DDevice_SetRenderState((IWineD3DDevice *)This->wineD3DDevice, D3DRS_ALPHAFUNC, D3DCMP_ALWAYS);
16347+ IWineD3DDevice_SetRenderState((IWineD3DDevice *)This->wineD3DDevice, D3DRS_ALPHAREF, 0xff); /*??*/
16348+ IWineD3DDevice_SetRenderState((IWineD3DDevice *)This->wineD3DDevice, D3DRS_DITHERENABLE, FALSE);
16349+ IWineD3DDevice_SetRenderState((IWineD3DDevice *)This->wineD3DDevice, D3DRS_ALPHABLENDENABLE, FALSE);
16350+ IWineD3DDevice_SetRenderState((IWineD3DDevice *)This->wineD3DDevice, D3DRS_FOGENABLE, FALSE);
16351+ IWineD3DDevice_SetRenderState((IWineD3DDevice *)This->wineD3DDevice, D3DRS_SPECULARENABLE, FALSE);
16352+ #if 0 /*FIXME: d3d8*/
16353+ IWineD3DDevice_SetRenderState((IWineD3DDevice *)This->wineD3DDevice, D3DRS_ZVISIBLE, 0);
16354+ #endif
16355+ IWineD3DDevice_SetRenderState((IWineD3DDevice *)This->wineD3DDevice, D3DRS_FOGCOLOR, 0);
16356+ IWineD3DDevice_SetRenderState((IWineD3DDevice *)This->wineD3DDevice, D3DRS_FOGTABLEMODE, D3DFOG_NONE);
16357 tmpfloat.f = 0.0f;
16358 IWineD3DDevice_SetRenderState((IWineD3DDevice *)This->wineD3DDevice, WINED3DRS_FOGSTART, tmpfloat.d);
16359 tmpfloat.f = 1.0f;
16360 IWineD3DDevice_SetRenderState((IWineD3DDevice *)This->wineD3DDevice, WINED3DRS_FOGEND, tmpfloat.d);
16361 tmpfloat.f = 1.0f;
16362- IWineD3DDevice_SetRenderState((IWineD3DDevice *)This->wineD3DDevice, WINED3DRS_FOGDENSITY, tmpfloat.d);
16363- IWineD3DDevice_SetRenderState((IWineD3DDevice *)This->wineD3DDevice, WINED3DRS_EDGEANTIALIAS, FALSE);
16364- IWineD3DDevice_SetRenderState((IWineD3DDevice *)This->wineD3DDevice, WINED3DRS_ZBIAS, 0);
16365- IWineD3DDevice_SetRenderState((IWineD3DDevice *)This->wineD3DDevice, WINED3DRS_RANGEFOGENABLE, FALSE);
16366- IWineD3DDevice_SetRenderState((IWineD3DDevice *)This->wineD3DDevice, WINED3DRS_STENCILENABLE, FALSE);
16367- IWineD3DDevice_SetRenderState((IWineD3DDevice *)This->wineD3DDevice, WINED3DRS_STENCILFAIL, D3DSTENCILOP_KEEP);
16368- IWineD3DDevice_SetRenderState((IWineD3DDevice *)This->wineD3DDevice, WINED3DRS_STENCILZFAIL, D3DSTENCILOP_KEEP);
16369- IWineD3DDevice_SetRenderState((IWineD3DDevice *)This->wineD3DDevice, WINED3DRS_STENCILPASS, D3DSTENCILOP_KEEP);
16370+ IWineD3DDevice_SetRenderState((IWineD3DDevice *)This->wineD3DDevice, D3DRS_FOGDENSITY, tmpfloat.d);
16371+ #if 0 /*FIXME: d3d8*/
16372+ IWineD3DDevice_SetRenderState((IWineD3DDevice *)This->wineD3DDevice, D3DRS_EDGEANTIALIAS, FALSE);
16373+ IWineD3DDevice_SetRenderState((IWineD3DDevice *)This->wineD3DDevice, D3DRS_ZBIAS, 0);
16374+ #endif
16375+ IWineD3DDevice_SetRenderState((IWineD3DDevice *)This->wineD3DDevice, D3DRS_RANGEFOGENABLE, FALSE);
16376+ IWineD3DDevice_SetRenderState((IWineD3DDevice *)This->wineD3DDevice, D3DRS_STENCILENABLE, FALSE);
16377+ IWineD3DDevice_SetRenderState((IWineD3DDevice *)This->wineD3DDevice, D3DRS_STENCILFAIL, D3DSTENCILOP_KEEP);
16378+ IWineD3DDevice_SetRenderState((IWineD3DDevice *)This->wineD3DDevice, D3DRS_STENCILZFAIL, D3DSTENCILOP_KEEP);
16379+ IWineD3DDevice_SetRenderState((IWineD3DDevice *)This->wineD3DDevice, D3DRS_STENCILPASS, D3DSTENCILOP_KEEP);
16380
16381 /* Setting stencil func also uses values for stencil ref/mask, so manually set defaults
16382 * so only a single call performed (and ensure defaults initialized before making that call)
16383@@ -146,58 +150,62 @@
16384 * IWineD3DDevice_SetRenderState((IWineD3DDevice *)This->wineD3DDevice, WINED3DRS_STENCILREF, 0);
16385 * IWineD3DDevice_SetRenderState((IWineD3DDevice *)This->wineD3DDevice, WINED3DRS_STENCILMASK, 0xFFFFFFFF);
16386 */
16387- This->renderState[WINED3DRS_STENCILREF] = 0;
16388- This->renderState[WINED3DRS_STENCILMASK] = 0xFFFFFFFF;
16389- IWineD3DDevice_SetRenderState((IWineD3DDevice *)This->wineD3DDevice, WINED3DRS_STENCILFUNC, D3DCMP_ALWAYS);
16390- IWineD3DDevice_SetRenderState((IWineD3DDevice *)This->wineD3DDevice, WINED3DRS_STENCILWRITEMASK, 0xFFFFFFFF);
16391- IWineD3DDevice_SetRenderState((IWineD3DDevice *)This->wineD3DDevice, WINED3DRS_TEXTUREFACTOR, 0xFFFFFFFF);
16392- IWineD3DDevice_SetRenderState((IWineD3DDevice *)This->wineD3DDevice, WINED3DRS_WRAP0, 0);
16393- IWineD3DDevice_SetRenderState((IWineD3DDevice *)This->wineD3DDevice, WINED3DRS_WRAP1, 0);
16394- IWineD3DDevice_SetRenderState((IWineD3DDevice *)This->wineD3DDevice, WINED3DRS_WRAP2, 0);
16395- IWineD3DDevice_SetRenderState((IWineD3DDevice *)This->wineD3DDevice, WINED3DRS_WRAP3, 0);
16396- IWineD3DDevice_SetRenderState((IWineD3DDevice *)This->wineD3DDevice, WINED3DRS_WRAP4, 0);
16397- IWineD3DDevice_SetRenderState((IWineD3DDevice *)This->wineD3DDevice, WINED3DRS_WRAP5, 0);
16398- IWineD3DDevice_SetRenderState((IWineD3DDevice *)This->wineD3DDevice, WINED3DRS_WRAP6, 0);
16399- IWineD3DDevice_SetRenderState((IWineD3DDevice *)This->wineD3DDevice, WINED3DRS_WRAP7, 0);
16400- IWineD3DDevice_SetRenderState((IWineD3DDevice *)This->wineD3DDevice, WINED3DRS_CLIPPING, TRUE);
16401- IWineD3DDevice_SetRenderState((IWineD3DDevice *)This->wineD3DDevice, WINED3DRS_LIGHTING, TRUE);
16402- IWineD3DDevice_SetRenderState((IWineD3DDevice *)This->wineD3DDevice, WINED3DRS_AMBIENT, 0);
16403- IWineD3DDevice_SetRenderState((IWineD3DDevice *)This->wineD3DDevice, WINED3DRS_FOGVERTEXMODE, D3DFOG_NONE);
16404- IWineD3DDevice_SetRenderState((IWineD3DDevice *)This->wineD3DDevice, WINED3DRS_COLORVERTEX, TRUE);
16405- IWineD3DDevice_SetRenderState((IWineD3DDevice *)This->wineD3DDevice, WINED3DRS_LOCALVIEWER, TRUE);
16406- IWineD3DDevice_SetRenderState((IWineD3DDevice *)This->wineD3DDevice, WINED3DRS_NORMALIZENORMALS, FALSE);
16407- IWineD3DDevice_SetRenderState((IWineD3DDevice *)This->wineD3DDevice, WINED3DRS_DIFFUSEMATERIALSOURCE, D3DMCS_COLOR1);
16408- IWineD3DDevice_SetRenderState((IWineD3DDevice *)This->wineD3DDevice, WINED3DRS_SPECULARMATERIALSOURCE, D3DMCS_COLOR2);
16409- IWineD3DDevice_SetRenderState((IWineD3DDevice *)This->wineD3DDevice, WINED3DRS_AMBIENTMATERIALSOURCE, D3DMCS_COLOR2);
16410- IWineD3DDevice_SetRenderState((IWineD3DDevice *)This->wineD3DDevice, WINED3DRS_EMISSIVEMATERIALSOURCE, D3DMCS_MATERIAL);
16411- IWineD3DDevice_SetRenderState((IWineD3DDevice *)This->wineD3DDevice, WINED3DRS_VERTEXBLEND, D3DVBF_DISABLE);
16412- IWineD3DDevice_SetRenderState((IWineD3DDevice *)This->wineD3DDevice, WINED3DRS_CLIPPLANEENABLE, 0);
16413- IWineD3DDevice_SetRenderState((IWineD3DDevice *)This->wineD3DDevice, WINED3DRS_SOFTWAREVERTEXPROCESSING, FALSE);
16414+ This->renderState[D3DRS_STENCILREF] = 0;
16415+ This->renderState[D3DRS_STENCILMASK] = 0xFFFFFFFF;
16416+ IWineD3DDevice_SetRenderState((IWineD3DDevice *)This->wineD3DDevice, D3DRS_STENCILFUNC, D3DCMP_ALWAYS);
16417+ IWineD3DDevice_SetRenderState((IWineD3DDevice *)This->wineD3DDevice, D3DRS_STENCILWRITEMASK, 0xFFFFFFFF);
16418+ IWineD3DDevice_SetRenderState((IWineD3DDevice *)This->wineD3DDevice, D3DRS_TEXTUREFACTOR, 0xFFFFFFFF);
16419+ IWineD3DDevice_SetRenderState((IWineD3DDevice *)This->wineD3DDevice, D3DRS_WRAP0, 0);
16420+ IWineD3DDevice_SetRenderState((IWineD3DDevice *)This->wineD3DDevice, D3DRS_WRAP1, 0);
16421+ IWineD3DDevice_SetRenderState((IWineD3DDevice *)This->wineD3DDevice, D3DRS_WRAP2, 0);
16422+ IWineD3DDevice_SetRenderState((IWineD3DDevice *)This->wineD3DDevice, D3DRS_WRAP3, 0);
16423+ IWineD3DDevice_SetRenderState((IWineD3DDevice *)This->wineD3DDevice, D3DRS_WRAP4, 0);
16424+ IWineD3DDevice_SetRenderState((IWineD3DDevice *)This->wineD3DDevice, D3DRS_WRAP5, 0);
16425+ IWineD3DDevice_SetRenderState((IWineD3DDevice *)This->wineD3DDevice, D3DRS_WRAP6, 0);
16426+ IWineD3DDevice_SetRenderState((IWineD3DDevice *)This->wineD3DDevice, D3DRS_WRAP7, 0);
16427+ IWineD3DDevice_SetRenderState((IWineD3DDevice *)This->wineD3DDevice, D3DRS_CLIPPING, TRUE);
16428+ IWineD3DDevice_SetRenderState((IWineD3DDevice *)This->wineD3DDevice, D3DRS_LIGHTING, TRUE);
16429+ IWineD3DDevice_SetRenderState((IWineD3DDevice *)This->wineD3DDevice, D3DRS_AMBIENT, 0);
16430+ IWineD3DDevice_SetRenderState((IWineD3DDevice *)This->wineD3DDevice, D3DRS_FOGVERTEXMODE, D3DFOG_NONE);
16431+ IWineD3DDevice_SetRenderState((IWineD3DDevice *)This->wineD3DDevice, D3DRS_COLORVERTEX, TRUE);
16432+ IWineD3DDevice_SetRenderState((IWineD3DDevice *)This->wineD3DDevice, D3DRS_LOCALVIEWER, TRUE);
16433+ IWineD3DDevice_SetRenderState((IWineD3DDevice *)This->wineD3DDevice, D3DRS_NORMALIZENORMALS, FALSE);
16434+ IWineD3DDevice_SetRenderState((IWineD3DDevice *)This->wineD3DDevice, D3DRS_DIFFUSEMATERIALSOURCE, D3DMCS_COLOR1);
16435+ IWineD3DDevice_SetRenderState((IWineD3DDevice *)This->wineD3DDevice, D3DRS_SPECULARMATERIALSOURCE, D3DMCS_COLOR2);
16436+ IWineD3DDevice_SetRenderState((IWineD3DDevice *)This->wineD3DDevice, D3DRS_AMBIENTMATERIALSOURCE, D3DMCS_COLOR2);
16437+ IWineD3DDevice_SetRenderState((IWineD3DDevice *)This->wineD3DDevice, D3DRS_EMISSIVEMATERIALSOURCE, D3DMCS_MATERIAL);
16438+ IWineD3DDevice_SetRenderState((IWineD3DDevice *)This->wineD3DDevice, D3DRS_VERTEXBLEND, D3DVBF_DISABLE);
16439+ IWineD3DDevice_SetRenderState((IWineD3DDevice *)This->wineD3DDevice, D3DRS_CLIPPLANEENABLE, 0);
16440+ #if 0 /*FIXME: d3d8*/
16441+ IWineD3DDevice_SetRenderState((IWineD3DDevice *)This->wineD3DDevice, D3DRS_SOFTWAREVERTEXPROCESSING, FALSE);
16442+ #endif
16443 tmpfloat.f = 1.0f;
16444 IWineD3DDevice_SetRenderState((IWineD3DDevice *)This->wineD3DDevice, WINED3DRS_POINTSIZE, tmpfloat.d);
16445 tmpfloat.f = 0.0f;
16446- IWineD3DDevice_SetRenderState((IWineD3DDevice *)This->wineD3DDevice, WINED3DRS_POINTSIZE_MIN, tmpfloat.d);
16447- IWineD3DDevice_SetRenderState((IWineD3DDevice *)This->wineD3DDevice, WINED3DRS_POINTSPRITEENABLE, FALSE);
16448- IWineD3DDevice_SetRenderState((IWineD3DDevice *)This->wineD3DDevice, WINED3DRS_POINTSCALEENABLE, FALSE);
16449- IWineD3DDevice_SetRenderState((IWineD3DDevice *)This->wineD3DDevice, WINED3DRS_POINTSCALE_A, TRUE);
16450- IWineD3DDevice_SetRenderState((IWineD3DDevice *)This->wineD3DDevice, WINED3DRS_POINTSCALE_B, TRUE);
16451- IWineD3DDevice_SetRenderState((IWineD3DDevice *)This->wineD3DDevice, WINED3DRS_POINTSCALE_C, TRUE);
16452- IWineD3DDevice_SetRenderState((IWineD3DDevice *)This->wineD3DDevice, WINED3DRS_MULTISAMPLEANTIALIAS, TRUE);
16453- IWineD3DDevice_SetRenderState((IWineD3DDevice *)This->wineD3DDevice, WINED3DRS_MULTISAMPLEMASK, 0xFFFFFFFF);
16454- IWineD3DDevice_SetRenderState((IWineD3DDevice *)This->wineD3DDevice, WINED3DRS_PATCHEDGESTYLE, D3DPATCHEDGE_DISCRETE);
16455+ IWineD3DDevice_SetRenderState((IWineD3DDevice *)This->wineD3DDevice, D3DRS_POINTSIZE_MIN, tmpfloat.d);
16456+ IWineD3DDevice_SetRenderState((IWineD3DDevice *)This->wineD3DDevice, D3DRS_POINTSPRITEENABLE, FALSE);
16457+ IWineD3DDevice_SetRenderState((IWineD3DDevice *)This->wineD3DDevice, D3DRS_POINTSCALEENABLE, FALSE);
16458+ IWineD3DDevice_SetRenderState((IWineD3DDevice *)This->wineD3DDevice, D3DRS_POINTSCALE_A, TRUE);
16459+ IWineD3DDevice_SetRenderState((IWineD3DDevice *)This->wineD3DDevice, D3DRS_POINTSCALE_B, TRUE);
16460+ IWineD3DDevice_SetRenderState((IWineD3DDevice *)This->wineD3DDevice, D3DRS_POINTSCALE_C, TRUE);
16461+ IWineD3DDevice_SetRenderState((IWineD3DDevice *)This->wineD3DDevice, D3DRS_MULTISAMPLEANTIALIAS, TRUE);
16462+ IWineD3DDevice_SetRenderState((IWineD3DDevice *)This->wineD3DDevice, D3DRS_MULTISAMPLEMASK, 0xFFFFFFFF);
16463+ IWineD3DDevice_SetRenderState((IWineD3DDevice *)This->wineD3DDevice, D3DRS_PATCHEDGESTYLE, D3DPATCHEDGE_DISCRETE);
16464+ #if 0 /*FIXME: d3d8*/
16465 tmpfloat.f = 1.0f;
16466- IWineD3DDevice_SetRenderState((IWineD3DDevice *)This->wineD3DDevice, WINED3DRS_PATCHSEGMENTS, tmpfloat.d);
16467- IWineD3DDevice_SetRenderState((IWineD3DDevice *)This->wineD3DDevice, WINED3DRS_DEBUGMONITORTOKEN, D3DDMT_DISABLE);
16468+ IWineD3DDevice_SetRenderState((IWineD3DDevice *)This->wineD3DDevice, D3DRS_PATCHSEGMENTS, tmpfloat.d);
16469+ #endif
16470+ IWineD3DDevice_SetRenderState((IWineD3DDevice *)This->wineD3DDevice, D3DRS_DEBUGMONITORTOKEN, D3DDMT_DISABLE);
16471 tmpfloat.f = 64.0f;
16472 IWineD3DDevice_SetRenderState((IWineD3DDevice *)This->wineD3DDevice, WINED3DRS_POINTSIZE_MAX, tmpfloat.d);
16473 IWineD3DDevice_SetRenderState((IWineD3DDevice *)This->wineD3DDevice, WINED3DRS_INDEXEDVERTEXBLENDENABLE, FALSE);
16474 IWineD3DDevice_SetRenderState((IWineD3DDevice *)This->wineD3DDevice, WINED3DRS_COLORWRITEENABLE, 0x0000000F);
16475 tmpfloat.f = 0.0f;
16476- IWineD3DDevice_SetRenderState((IWineD3DDevice *)This->wineD3DDevice, WINED3DRS_TWEENFACTOR, tmpfloat.d);
16477- IWineD3DDevice_SetRenderState((IWineD3DDevice *)This->wineD3DDevice, WINED3DRS_BLENDOP, D3DBLENDOP_ADD);
16478- IWineD3DDevice_SetRenderState((IWineD3DDevice *)This->wineD3DDevice, WINED3DRS_POSITIONORDER, WINED3DDEGREE_CUBIC);
16479- IWineD3DDevice_SetRenderState((IWineD3DDevice *)This->wineD3DDevice, WINED3DRS_NORMALORDER, WINED3DDEGREE_LINEAR);
16480-
16481+ IWineD3DDevice_SetRenderState((IWineD3DDevice *)This->wineD3DDevice, D3DRS_TWEENFACTOR, tmpfloat.d);
16482+ IWineD3DDevice_SetRenderState((IWineD3DDevice *)This->wineD3DDevice, D3DRS_BLENDOP, D3DBLENDOP_ADD);
16483+ IWineD3DDevice_SetRenderState((IWineD3DDevice *)This->wineD3DDevice, D3DRS_POSITIONDEGREE, D3DDEGREE_CUBIC);
16484+ IWineD3DDevice_SetRenderState((IWineD3DDevice *)This->wineD3DDevice, D3DRS_NORMALDEGREE, D3DDEGREE_LINEAR);
16485+ TRACE("clipping status\n");
16486 /** clipping status */
16487 This->clip_status.ClipUnion = 0;
16488 This->clip_status.ClipIntersection = 0xFFFFFFFF;
16489@@ -217,15 +225,6 @@
16490 This->textureState[i][D3DTSS_BUMPENVMAT10 ] = (DWORD) 0.0;
16491 This->textureState[i][D3DTSS_BUMPENVMAT11 ] = (DWORD) 0.0;
16492 This->textureState[i][D3DTSS_TEXCOORDINDEX ] = i;
16493- This->textureState[i][D3DTSS_ADDRESSU ] = D3DTADDRESS_WRAP;
16494- This->textureState[i][D3DTSS_ADDRESSV ] = D3DTADDRESS_WRAP;
16495- This->textureState[i][D3DTSS_BORDERCOLOR ] = 0x00;
16496- This->textureState[i][D3DTSS_MAGFILTER ] = D3DTEXF_POINT;
16497- This->textureState[i][D3DTSS_MINFILTER ] = D3DTEXF_POINT;
16498- This->textureState[i][D3DTSS_MIPFILTER ] = D3DTEXF_NONE;
16499- This->textureState[i][D3DTSS_MIPMAPLODBIAS ] = 0;
16500- This->textureState[i][D3DTSS_MAXMIPLEVEL ] = 0;
16501- This->textureState[i][D3DTSS_MAXANISOTROPY ] = 1;
16502 This->textureState[i][D3DTSS_BUMPENVLSCALE ] = (DWORD) 0.0;
16503 This->textureState[i][D3DTSS_BUMPENVLOFFSET ] = (DWORD) 0.0;
16504 This->textureState[i][D3DTSS_TEXTURETRANSFORMFLAGS ] = D3DTTFF_DISABLE;
16505@@ -233,6 +232,22 @@
16506 This->textureState[i][D3DTSS_COLORARG0 ] = D3DTA_CURRENT;
16507 This->textureState[i][D3DTSS_ALPHAARG0 ] = D3DTA_CURRENT;
16508 This->textureState[i][D3DTSS_RESULTARG ] = D3DTA_CURRENT;
16509+ This->textureState[i][D3DRS_LASTPIXEL ] = TRUE;
16510+
16511+ }
16512+ /* Sampler states*/
16513+ for ( i = 0 ; i< 16 /* MAX_SAMPLERS*/; i++){
16514+ TRACE("Setting up default samplers states for sampler %d\n", i);
16515+ This->samplerState[i][D3DSAMP_ADDRESSU ] = D3DTADDRESS_WRAP;
16516+ This->samplerState[i][D3DSAMP_ADDRESSV ] = D3DTADDRESS_WRAP;
16517+ This->samplerState[i][D3DSAMP_BORDERCOLOR ] = 0x00;
16518+ This->samplerState[i][D3DSAMP_MAGFILTER ] = D3DTEXF_POINT;
16519+ This->samplerState[i][D3DSAMP_MINFILTER ] = D3DTEXF_POINT;
16520+ This->samplerState[i][D3DSAMP_MIPFILTER ] = D3DTEXF_NONE;
16521+ This->samplerState[i][D3DSAMP_MIPMAPLODBIAS ] = 0;
16522+ This->samplerState[i][D3DSAMP_MAXMIPLEVEL ] = 0;
16523+ This->samplerState[i][D3DSAMP_MAXANISOTROPY ] = 1;
16524+
16525 }
16526
16527 /* Under DirectX you can have texture stage operations even if no texture is
16528@@ -293,6 +308,390 @@
16529 return D3D_OK;
16530 }
16531
16532+
16533+HRESULT WINAPI IWineD3DStateBlockImpl_Capture(IWineD3DStateBlock *iface){
16534+
16535+ IWineD3DStateBlockImpl *This = (IWineD3DStateBlockImpl *)iface;
16536+ IWineD3DDevice* pDevice = (IWineD3DDevice*)This->wineD3DDevice;
16537+ IWineD3DDeviceImpl* pDeviceImpl = This->wineD3DDevice;
16538+
16539+
16540+
16541+ TRACE("(%p) : Updating state block %p ------------------v \n", pDeviceImpl, This);
16542+
16543+ /* If not recorded, then update can just recapture */
16544+ if (/*TODO: 'magic' statetype, replace with BOOL This->blockType == D3DSBT_RECORDED */ 0) {
16545+ IWineD3DStateBlockImpl* tmpBlock;
16546+ PLIGHTINFOEL *tmp = This->lights;
16547+
16548+ /*FIXME: I would have thought that CreateStateBlock should call capture... not the other way around!*/
16549+ IWineD3DDevice_CreateStateBlock(pDevice, This->blockType, (IWineD3DStateBlock**) &tmpBlock, NULL/*parent*/);
16550+
16551+
16552+ /* Note just swap the light chains over so when deleting, the old one goes */
16553+ memcpy(This, tmpBlock, sizeof(IWineD3DStateBlockImpl));
16554+ tmpBlock->lights = tmp;
16555+
16556+ /* Delete the temporary one (which points to the old light chain though */
16557+ IWineD3DStateBlock_Release((IWineD3DStateBlock *)tmpBlock);
16558+ /*IDirect3DDevice_DeleteStateBlock(pDeviceImpl, tmpBlock);*/
16559+
16560+ } else {
16561+ unsigned int i, j;
16562+
16563+ PLIGHTINFOEL *src;
16564+
16565+ /* Recorded => Only update 'changed' values */
16566+ if (This->set.vertexShader && This->vertexShader != pDeviceImpl->stateBlock->vertexShader) {
16567+ This->vertexShader = pDeviceImpl->stateBlock->vertexShader;
16568+ TRACE("Updating vertex shader to %p\n", pDeviceImpl->stateBlock->vertexShader);
16569+ }
16570+
16571+ /* TODO: Vertex Shader Constants */
16572+
16573+ /* Lights... For a recorded state block, we just had a chain of actions to perform,
16574+ so we need to walk that chain and update any actions which differ */
16575+ src = This->lights;
16576+ while (src != NULL) {
16577+ PLIGHTINFOEL *realLight = NULL;
16578+
16579+ /* Locate the light in the live lights */
16580+ realLight = pDeviceImpl->stateBlock->lights;
16581+ while (realLight != NULL && realLight->OriginalIndex != src->OriginalIndex) realLight = realLight->next;
16582+
16583+ if (realLight == NULL) {
16584+ FIXME("A captured light no longer exists...?\n");
16585+ } else {
16586+
16587+ /* If 'changed' then its a SetLight command. Rather than comparing to see
16588+ if the OriginalParms have changed and then copy them (twice through
16589+ memory) just do the copy */
16590+ if (src->changed) {
16591+ TRACE("Updating lights for light %ld\n", src->OriginalIndex);
16592+ memcpy(&src->OriginalParms, &realLight->OriginalParms, sizeof(PLIGHTINFOEL));
16593+ }
16594+
16595+ /* If 'enabledchanged' then its a LightEnable command */
16596+ if (src->enabledChanged) {
16597+ TRACE("Updating lightEnabled for light %ld\n", src->OriginalIndex);
16598+ src->lightEnabled = realLight->lightEnabled;
16599+ }
16600+
16601+ }
16602+
16603+ src = src->next;
16604+ }
16605+
16606+
16607+
16608+#if 0 /*TODO: Pixel shaders*/
16609+
16610+ if (This->set.pixelShader && This->pixelShader != pDeviceImpl->stateBlock->pixelShader) {
16611+ TRACE("Updating pixel shader to %p\n", pDeviceImpl->stateBlock->pixelShader);
16612+ IWineD3DDevice_SetPixelShader(pDevice, This->pixelShader);
16613+ }
16614+#endif
16615+ /* TODO: Pixel Shader Constants */
16616+
16617+ /* Others + Render & Texture */
16618+ for (i = 1; i <= HIGHEST_TRANSFORMSTATE; i++) {
16619+ if (This->set.transform[i] && memcmp(&pDeviceImpl->stateBlock->transforms[i],
16620+ &This->transforms[i],
16621+ sizeof(D3DMATRIX)) != 0) {
16622+ TRACE("Updating transform %d\n", i);
16623+ memcpy(&This->transforms[i], &pDeviceImpl->stateBlock->transforms[i], sizeof(D3DMATRIX));
16624+ }
16625+ }
16626+
16627+ if (This->set.indices && ((This->pIndexData != pDeviceImpl->stateBlock->pIndexData)
16628+ || (This->baseVertexIndex != pDeviceImpl->stateBlock->baseVertexIndex))) {
16629+ TRACE("Updating pindexData to %p, baseVertexIndex to %d\n",
16630+ pDeviceImpl->stateBlock->pIndexData, pDeviceImpl->stateBlock->baseVertexIndex);
16631+ This->pIndexData = pDeviceImpl->stateBlock->pIndexData;
16632+ This->baseVertexIndex = pDeviceImpl->stateBlock->baseVertexIndex;
16633+ }
16634+#if 1
16635+
16636+ if(This->set.vertexDecl && This->vertexDecl != pDeviceImpl->stateBlock->vertexDecl){
16637+ This->vertexDecl = pDeviceImpl->stateBlock->vertexDecl;
16638+ }
16639+
16640+ if(This->set.fvf && This->fvf != pDeviceImpl->stateBlock->fvf){
16641+ This->fvf = pDeviceImpl->stateBlock->fvf;
16642+ }
16643+#endif
16644+ if (This->set.material && memcmp(&pDeviceImpl->stateBlock->material,
16645+ &This->material,
16646+ sizeof(D3DMATERIAL9)) != 0) {
16647+ TRACE("Updating material\n");
16648+ memcpy(&This->material, &pDeviceImpl->stateBlock->material, sizeof(D3DMATERIAL9));
16649+ }
16650+
16651+ if (This->set.viewport && memcmp(&pDeviceImpl->stateBlock->viewport,
16652+ &This->viewport,
16653+ sizeof(D3DVIEWPORT9)) != 0) {
16654+ TRACE("Updating viewport\n");
16655+ memcpy(&This->viewport, &pDeviceImpl->stateBlock->viewport, sizeof(D3DVIEWPORT9));
16656+ }
16657+
16658+ for (i = 0; i < MAX_STREAMS; i++) {
16659+ if (This->set.streamSource[i] &&
16660+ ((This->streamStride[i] != pDeviceImpl->stateBlock->streamStride[i]) ||
16661+ (This->streamSource[i] != pDeviceImpl->stateBlock->streamSource[i]))) {
16662+ TRACE("Updating stream source %d to %p, stride to %d\n", i, pDeviceImpl->stateBlock->streamSource[i],
16663+ pDeviceImpl->stateBlock->streamStride[i]);
16664+ This->streamStride[i] = pDeviceImpl->stateBlock->streamStride[i];
16665+ This->streamSource[i] = pDeviceImpl->stateBlock->streamSource[i];
16666+ }
16667+
16668+ if (This->set.streamFreq[i] &&
16669+ (This->streamFreq[i] != pDeviceImpl->stateBlock->streamFreq[i]
16670+ || This->streamFlags[i] != pDeviceImpl->stateBlock->streamFlags[i])){
16671+ TRACE("Updating stream frequency %d to %d flags to %d\n", i , pDeviceImpl->stateBlock->streamFreq[i] , pDeviceImpl->stateBlock->streamFlags[i]);
16672+ This->streamFreq[i] = pDeviceImpl->stateBlock->streamFreq[i];
16673+ This->streamFlags[i] = pDeviceImpl->stateBlock->streamFlags[i];
16674+ }
16675+ }
16676+
16677+ for (i = 0; i < GL_LIMITS(clipplanes); i++) {
16678+ if (This->set.clipplane[i] && memcmp(&pDeviceImpl->stateBlock->clipplane[i],
16679+ &This->clipplane[i],
16680+ sizeof(This->clipplane)) != 0) {
16681+
16682+ TRACE("Updating clipplane %d\n", i);
16683+ memcpy(&This->clipplane[i], &pDeviceImpl->stateBlock->clipplane[i],
16684+ sizeof(This->clipplane));
16685+ }
16686+ }
16687+
16688+ /* Render */
16689+ for (i = 1; i <= WINEHIGHEST_RENDER_STATE; i++) {
16690+
16691+ if (This->set.renderState[i] && (This->renderState[i] !=
16692+ pDeviceImpl->stateBlock->renderState[i])) {
16693+ TRACE("Updating renderState %d to %ld\n", i, pDeviceImpl->stateBlock->renderState[i]);
16694+ This->renderState[i] = pDeviceImpl->stateBlock->renderState[i];
16695+ }
16696+ }
16697+
16698+ /* Texture */
16699+ for (j = 0; j < GL_LIMITS(textures); j++) {
16700+ for (i = 1; i <= HIGHEST_TEXTURE_STATE ; i++) {
16701+
16702+ if (This->set.textureState[j][i] && (This->textureState[j][i] !=
16703+ pDeviceImpl->stateBlock->textureState[j][i])) {
16704+ TRACE("Updating texturestagestate %d,%d to %ld (was %ld)\n", j,i, pDeviceImpl->stateBlock->textureState[j][i],
16705+ This->textureState[j][i]);
16706+ This->textureState[j][i] = pDeviceImpl->stateBlock->textureState[j][i];
16707+ This->renderState[i] = pDeviceImpl->stateBlock->renderState[i];
16708+ }
16709+
16710+ }
16711+
16712+ if ((This->set.textures[j] && (This->textures[j] != pDeviceImpl->stateBlock->textures[j]))) {
16713+ TRACE("Updating texture %d to %p (was %p)\n", j, pDeviceImpl->stateBlock->textures[j], This->textures[j]);
16714+ This->textures[j] = pDeviceImpl->stateBlock->textures[j];
16715+ }
16716+
16717+ }
16718+
16719+
16720+ /* TODO: MAX_Samplers */
16721+ for (j = 0 ; j < 16; j++){
16722+ for (i = 1; i <= HIGHEST_SAMPLER_STATE ; i++){ /* States are 1 based */
16723+ if (This->set.samplerState[j][i] && (This->samplerState[j][i] !=
16724+ pDeviceImpl->stateBlock->samplerState[j][i])) {
16725+ TRACE("Updating sampler state %d,%d to %ld (was %ld)\n",
16726+ j, i, pDeviceImpl->stateBlock->samplerState[j][i],
16727+ This->samplerState[j][i]);
16728+ This->samplerState[j][i] = pDeviceImpl->stateBlock->samplerState[j][i];
16729+ }
16730+ }
16731+ }
16732+ }
16733+
16734+ TRACE("(%p) : Updated state block %p ------------------^\n", pDeviceImpl, This);
16735+
16736+ return D3D_OK;
16737+}
16738+
16739+HRESULT WINAPI IWineD3DStateBlockImpl_GetDevice(IWineD3DStateBlock *iface, IWineD3DDevice** ppDevice){
16740+
16741+ IWineD3DStateBlockImpl *This = (IWineD3DStateBlockImpl *)iface;
16742+
16743+ *ppDevice = (IWineD3DDevice*)This->wineD3DDevice;
16744+ IWineD3DDevice_AddRef(*ppDevice);
16745+ return D3D_OK;
16746+
16747+}
16748+
16749+HRESULT WINAPI IWineD3DStateBlockImpl_Apply(IWineD3DStateBlock *iface){
16750+ IWineD3DStateBlockImpl *This = (IWineD3DStateBlockImpl *)iface;
16751+ IWineD3DDevice* pDevice = (IWineD3DDevice*)This->wineD3DDevice;
16752+
16753+/*Copy thing over to updateBlock is isRecording otherwise StateBlock,
16754+should really perform a delta so that only the changes get updated*/
16755+
16756+
16757+ UINT i;
16758+ UINT j;
16759+
16760+ TRACE("(%p) : Applying state block %p ------------------v\n", This, pDevice);
16761+
16762+ /* FIXME: Only apply applicable states not all states */
16763+
16764+ if (/*TODO: 'magic' statetype, replace with BOOL This->blockType == D3DSBT_RECORDED || */This->blockType == D3DSBT_ALL || This->blockType == D3DSBT_VERTEXSTATE) {
16765+
16766+
16767+ PLIGHTINFOEL *toDo = This->lights;
16768+ while (toDo != NULL) {
16769+ if (toDo->changed)
16770+ IWineD3DDevice_SetLight(pDevice, toDo->OriginalIndex, &toDo->OriginalParms);
16771+ if (toDo->enabledChanged)
16772+ IWineD3DDevice_SetLightEnable(pDevice, toDo->OriginalIndex, toDo->lightEnabled);
16773+ toDo = toDo->next;
16774+ }
16775+
16776+ #if 0 /*TODO: VertexShaders*/
16777+ if (This->set.vertexShader && This->changed.vertexShader)
16778+ IWineD3DDevice_SetTexture(iface, 0, pSB->vertexShader);
16779+
16780+ /* TODO: Vertex Shader Constants */
16781+
16782+ #endif
16783+ }
16784+
16785+ #if 0 /*TODO: Pixel Shaders*/
16786+ if (/*TODO: 'magic' statetype, replace with BOOL This->blockType == D3DSBT_RECORDED || */ This->blockType == D3DSBT_ALL || This->blockType == D3DSBT_PIXELSTATE) {
16787+
16788+ if (This->set.pixelShader && This->changed.pixelShader)
16789+ IWineD3DDevice_SetPixelShader(pDevice, This->pixelShader);
16790+
16791+ /* TODO: Pixel Shader Constants */
16792+ }
16793+ #endif
16794+#if 1
16795+ if(This->set.fvf && This->changed.fvf){
16796+ IWineD3DDevice_SetFVF(pDevice, This->fvf);
16797+ }
16798+
16799+ if(This->set.vertexDecl && This->changed.vertexDecl){
16800+ IWineD3DDevice_SetVertexDeclaration(pDevice, This->vertexDecl);
16801+ }
16802+#endif
16803+ /* Others + Render & Texture */
16804+ if (/*TODO: 'magic' statetype, replace with BOOL This->blockType == D3DSBT_RECORDED || */ This->blockType == D3DSBT_ALL) {
16805+ for (i = 1; i <= HIGHEST_TRANSFORMSTATE; i++) {
16806+ if (This->set.transform[i] && This->changed.transform[i])
16807+ IWineD3DDevice_SetTransform(pDevice, i, &This->transforms[i]);
16808+ }
16809+ TRACE("TODO: Implement vertex buffers\n");
16810+ #if 0
16811+ if (pSB->set.Indices && pSB->changed.Indices)
16812+ IWineD3DDevice_SetIndices(iface, pSB->pIndexData, pSB->baseVertexIndex);
16813+ #endif
16814+ if (This->set.material && This->changed.material )
16815+ IWineD3DDevice_SetMaterial(pDevice, &This->material);
16816+
16817+ if (This->set.viewport && This->changed.viewport)
16818+ IWineD3DDevice_SetViewport(pDevice, &This->viewport);
16819+ TRACE("TODO: Proper implementation using SetStreamSource offset (set to 0 for the moment)\n");
16820+ for (i=0; i<MAX_STREAMS; i++) {
16821+ if (This->set.streamSource[i] && This->changed.streamSource[i])
16822+ IWineD3DDevice_SetStreamSource(pDevice, i, This->streamSource[i],0, This->streamStride[i]);
16823+
16824+ if (This->set.streamFreq[i] && This->changed.streamFreq[i])
16825+ IWineD3DDevice_SetStreamSourceFreq(pDevice, i, This->streamFreq[i] | This->streamFlags[i]);
16826+
16827+ }
16828+
16829+ for (i = 0; i < GL_LIMITS(clipplanes); i++) {
16830+ if (This->set.clipplane[i] && This->changed.clipplane[i]) {
16831+ float clip[4];
16832+
16833+ clip[0] = This->clipplane[i][0];
16834+ clip[1] = This->clipplane[i][1];
16835+ clip[2] = This->clipplane[i][2];
16836+ clip[3] = This->clipplane[i][3];
16837+ IWineD3DDevice_SetClipPlane(pDevice, i, clip);
16838+ }
16839+ }
16840+
16841+ /* Render */
16842+ for (i = 1; i <= WINEHIGHEST_RENDER_STATE; i++) {
16843+ if (This->set.renderState[i] && This->changed.renderState[i])
16844+ IWineD3DDevice_SetRenderState(pDevice, i, This->renderState[i]);
16845+ }
16846+
16847+ /* Texture */
16848+ for (j = 0; j < GL_LIMITS(textures); j++) { /* Set The texture first, just incase it resets the states? */
16849+ if (This->set.textures[j] && This->changed.textures[j]) {
16850+ IWineD3DDevice_SetTexture(pDevice, j, This->textures[j]);
16851+ }
16852+ for (i = 1; i <= HIGHEST_TEXTURE_STATE; i++) {
16853+ if (This->set.textureState[j][i] && This->changed.textureState[j][i]) {
16854+ IWineD3DDevice_SetTextureStageState(pDevice, j, i, This->textureState[j][i]);
16855+ }
16856+ }
16857+ }
16858+
16859+ /* TODO: MAX_Samplers */
16860+ for (j = 0 ; j< 16; j++){
16861+ for (i = 1; i <= HIGHEST_SAMPLER_STATE; i++){
16862+ if (This->set.samplerState[j][i] && This->changed.samplerState[j][i] && This->samplerState[j][i] != 0) {
16863+ IWineD3DDevice_SetSamplerState(pDevice, j, i, This->samplerState[j][i]);
16864+ }
16865+ }
16866+
16867+ }
16868+
16869+
16870+ } else if (This->blockType == D3DSBT_PIXELSTATE) {
16871+
16872+ for (i = 0; i < NUM_SAVEDPIXELSTATES_R; i++) {
16873+ if (This->set.renderState[SavedPixelStates_R[i]] && This->changed.renderState[SavedPixelStates_R[i]])
16874+ IWineD3DDevice_SetRenderState(pDevice, SavedPixelStates_R[i], This->renderState[SavedPixelStates_R[i]]);
16875+
16876+ }
16877+
16878+ for (j = 0; j < GL_LIMITS(textures); i++) {
16879+ for (i = 0; i < NUM_SAVEDPIXELSTATES_T; i++) {
16880+ if (This->set.textureState[j][SavedPixelStates_T[i]] &&
16881+ This->changed.textureState[j][SavedPixelStates_T[i]])
16882+ IWineD3DDevice_SetTextureStageState(pDevice, j, SavedPixelStates_T[i], This->textureState[j][SavedPixelStates_T[i]]);
16883+ }
16884+ }
16885+
16886+
16887+ } else if (This->blockType == D3DSBT_VERTEXSTATE) {
16888+
16889+ for (i = 0; i < NUM_SAVEDVERTEXSTATES_R; i++) {
16890+ if ( This->set.renderState[SavedVertexStates_R[i]] && This->changed.renderState[SavedVertexStates_R[i]])
16891+ IWineD3DDevice_SetRenderState(pDevice, SavedVertexStates_R[i], This->renderState[SavedVertexStates_R[i]]);
16892+ }
16893+
16894+ for (j = 0; j < GL_LIMITS(textures); i++) {
16895+ for (i = 0; i < NUM_SAVEDVERTEXSTATES_T; i++) {
16896+ if ( This->set.textureState[j][SavedVertexStates_T[i]] &&
16897+ This->changed.textureState[j][SavedVertexStates_T[i]])
16898+ IWineD3DDevice_SetTextureStageState(pDevice, j, SavedVertexStates_T[i], This->textureState[j][SavedVertexStates_T[i]]);
16899+ }
16900+ }
16901+
16902+
16903+
16904+ } else {
16905+ FIXME("Unrecognized state block type %d\n", This->blockType);
16906+ }
16907+ memcpy(&((IWineD3DDeviceImpl*)pDevice)->stateBlock->changed, &This->changed, sizeof(((IWineD3DDeviceImpl*)pDevice)->stateBlock->changed));
16908+ TRACE("(%p) : Applied state block %p ------------------^\n", This, pDevice);
16909+
16910+ return D3D_OK;
16911+
16912+
16913+}
16914+
16915+
16916 /**********************************************************
16917 * IWineD3DStateBlock VTbl follows
16918 **********************************************************/
16919@@ -303,5 +702,9 @@
16920 IWineD3DStateBlockImpl_AddRef,
16921 IWineD3DStateBlockImpl_Release,
16922 IWineD3DStateBlockImpl_GetParent,
16923+ IWineD3DStateBlockImpl_GetDevice,
16924+ IWineD3DStateBlockImpl_Capture,
16925+ IWineD3DStateBlockImpl_Apply,
16926 IWineD3DStateBlockImpl_InitStartupStateBlock
16927 };
16928+
16929diff -urN wine.20050419/dlls/wined3d/surface.c wine.20050419.dx9/dlls/wined3d/surface.c
16930--- wine.20050419/dlls/wined3d/surface.c 2005-03-29 12:01:00.000000000 -0700
16931+++ wine.20050419.dx9/dlls/wined3d/surface.c 2005-04-20 05:51:33.000000000 -0600
16932@@ -1,4 +1,4 @@
16933-/*
16934+ /*
16935 * IWineD3DSurface Implementation
16936 *
16937 * Copyright 2002-2005 Jason Edmeades
16938@@ -24,7 +24,17 @@
16939 #include "config.h"
16940 #include "wined3d_private.h"
16941
16942+/*Experemental memory management that releases the allocated memory from
16943+a surface when the texture is loaded until a lock is requested
16944+on the surface.
16945+*/
16946+#define MANAGED_D3D_MEMORY
16947+
16948+
16949 WINE_DEFAULT_DEBUG_CHANNEL(d3d_surface);
16950+WINE_DECLARE_DEBUG_CHANNEL(d3d_ref);
16951+WINE_DECLARE_DEBUG_CHANNEL(d3d_timings);
16952+
16953 #define GLINFO_LOCATION ((IWineD3DImpl *)(((IWineD3DDeviceImpl *)This->resource.wineD3DDevice)->wineD3D))->gl_info
16954
16955 /* *******************************************
16956@@ -58,16 +68,30 @@
16957 ULONG WINAPI IWineD3DSurfaceImpl_Release(IWineD3DSurface *iface) {
16958 IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface;
16959 ULONG ref = InterlockedDecrement(&This->resource.ref);
16960- TRACE("(%p) : Releasing from %ld\n", This, ref + 1);
16961+ TRACE_(d3d_ref)("(%p) : Releasing to %ld from %ld\n", This, ref, ref + 1);
16962 if (ref == 0) {
16963- if (This->textureName != 0) { /* release the openGL texture.. */
16964+ int surfacecount = globalStoreReleaseSurface(iface);
16965+ if(This->resource.pool == D3DPOOL_DEFAULT){
16966+ globalChangeGlRam(-This->resource.size);
16967+ }
16968+ if(This->resource.usage & D3DUSAGE_RENDERTARGET){
16969+ TRACE("Relessing a render target\n");
16970+ #ifdef OPENGLCONTEXTMANAGER
16971+ IContextManager_DestroyRenderTarget(This->contextManager, (IWineD3DSurface *)object);
16972+ #endif
16973+ }
16974+ if(This->textureName != 0){/*release the openGL texture..*/
16975 ENTER_GL();
16976 TRACE("Deleting texture %d\n", This->textureName);
16977 glDeleteTextures(1, &This->textureName);
16978- LEAVE_GL();
16979+ LEAVE_GL();
16980+ }
16981+ if(This->resource.allocatedMemory != NULL){
16982+ globalChangeSysRam(-This->resource.size);
16983+ HeapFree(GetProcessHeap(),0,This->resource.allocatedMemory);
16984 }
16985- IWineD3DResourceImpl_CleanUp((IWineD3DResource *)iface);
16986- HeapFree(GetProcessHeap(), 0, This);
16987+ TRACE("(%p) Released, surfaces left %d using %d bytes\n",This , surfacecount, wineD3DGlobalStatistics->totalsurfaceram);
16988+ HeapFree(GetProcessHeap(),0,This);
16989
16990 }
16991 return ref;
16992@@ -124,6 +148,7 @@
16993 glGenTextures(1, &This->textureName);
16994 checkGLcall("glGenTextures");
16995 TRACE("Surface %p given name %d\n", This, This->textureName);
16996+ /* FIXME: should be using dimensions noe GL_TEXTURE_2D, since this may be a 1d or 3d surface! */
16997 glBindTexture(GL_TEXTURE_2D, This->textureName);
16998 checkGLcall("glBindTexture");
16999 IWineD3DSurface_LoadTexture((IWineD3DSurface *) This, GL_TEXTURE_2D, This->currentDesc.Level);
17000@@ -162,10 +187,12 @@
17001 return IWineD3DResourceImpl_GetParent((IWineD3DResource *)iface, pParent);
17002 }
17003
17004+
17005 /* ******************************************************
17006 IWineD3DSurface IWineD3DSurface parts follow
17007 ****************************************************** */
17008-
17009+
17010+
17011 HRESULT WINAPI IWineD3DSurfaceImpl_GetContainer(IWineD3DSurface* iface, REFIID riid, void** ppContainer) {
17012 IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface;
17013 HRESULT hr;
17014@@ -178,12 +205,15 @@
17015 * If the surface is created using CreateImageSurface/CreateOffscreenPlainSurface, CreateRenderTarget,
17016 * or CreateDepthStencilSurface, the surface is considered stand alone. In this case,
17017 * GetContainer will return the Direct3D device used to create the surface.
17018- */
17019+ */
17020 hr = IUnknown_QueryInterface(This->container, riid, ppContainer);
17021 return hr;
17022 }
17023
17024-HRESULT WINAPI IWineD3DSurfaceImpl_GetDesc(IWineD3DSurface *iface, WINED3DSURFACE_DESC *pDesc) {
17025+
17026+
17027+
17028+HRESULT WINAPI IWineD3DSurfaceImpl_GetDesc(IWineD3DSurface * iface, WINED3DSURFACE_DESC* pDesc) {
17029 IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface;
17030
17031 TRACE("(%p) : copying into %p\n", This, pDesc);
17032@@ -196,27 +226,39 @@
17033 *(pDesc->MultiSampleQuality) = This->currentDesc.MultiSampleQuality;
17034 *(pDesc->Width) = This->currentDesc.Width;
17035 *(pDesc->Height) = This->currentDesc.Height;
17036+
17037+ TRACE("(%p) returning \n",This);
17038 return D3D_OK;
17039 }
17040
17041+
17042 HRESULT WINAPI IWineD3DSurfaceImpl_LockRect(IWineD3DSurface *iface, D3DLOCKED_RECT* pLockedRect, CONST RECT* pRect, DWORD Flags) {
17043 IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface;
17044+ IWineD3DDeviceImpl *myDevice = This->resource.wineD3DDevice;
17045+ IWineD3DSwapChainImpl *swapchain = NULL;
17046+ DWORD startTime = 0;
17047+ static int messages =0; /*flag to say which FIXME messages have already been dispalyed*/
17048+ if (TRACE_ON(d3d_timings))
17049+ startTime = GetTickCount(); /* Use windows calls for this */
17050
17051+ TRACE("(%p) pLockedRect %p pRect %p Flags %ld \n",This,pLockedRect,pRect,Flags);
17052+
17053 /* fixme: should we really lock as such? */
17054 if (This->inTexture && This->inPBuffer) {
17055 FIXME("Warning: Surface is in texture memory or pbuffer\n");
17056 This->inTexture = 0;
17057 This->inPBuffer = 0;
17058 }
17059-
17060+
17061 if (FALSE == This->lockable) {
17062 /* Note: UpdateTextures calls CopyRects which calls this routine to populate the
17063 texture regions, and since the destination is an unlockable region we need
17064- to tolerate this */
17065- TRACE("Warning: trying to lock unlockable surf@%p\n", This);
17066- /*return D3DERR_INVALIDCALL; */
17067+ to find someway tolerate this (or fix update textures!) */
17068+ FIXME("Warning: trying to lock unlockable surf@%p\n", This);
17069+ /* return D3DERR_INVALIDCALL;*/
17070 }
17071
17072+#if 0
17073 if (iface == This->resource.wineD3DDevice->backBuffer || iface == This->resource.wineD3DDevice->renderTarget ||
17074 iface == This->resource.wineD3DDevice->frontBuffer || iface == This->resource.wineD3DDevice->depthStencilBuffer) {
17075 if (iface == This->resource.wineD3DDevice->backBuffer) {
17076@@ -228,13 +270,15 @@
17077 } else if (iface == This->resource.wineD3DDevice->depthStencilBuffer) {
17078 TRACE("(%p, stencilBuffer) : rect@%p flags(%08lx), output lockedRect@%p, memory@%p\n", This, pRect, Flags, pLockedRect, This->resource.allocatedMemory);
17079 }
17080+ IWineD3DSwapChain_Release((IWineD3DSwapChain *)swapchain);
17081 } else {
17082 TRACE("(%p) : rect@%p flags(%08lx), output lockedRect@%p, memory@%p\n", This, pRect, Flags, pLockedRect, This->resource.allocatedMemory);
17083 }
17084+#endif
17085
17086 /* DXTn formats don't have exact pitches as they are to the new row of blocks,
17087 where each block is 4x4 pixels, 8 bytes (dxt1) and 16 bytes (dxt3/5)
17088- ie pitch = (width/4) * bytes per block */
17089+ ie pitch = (width/4) * bytes per block */
17090 if (This->resource.format == WINED3DFMT_DXT1) /* DXT1 is 8 bytes per block */
17091 pLockedRect->Pitch = (This->currentDesc.Width >> 2) << 3;
17092 else if (This->resource.format == WINED3DFMT_DXT3 || This->resource.format == WINED3DFMT_DXT5) /* DXT3/5 is 16 bytes per block */
17093@@ -242,7 +286,7 @@
17094 else
17095 pLockedRect->Pitch = This->bytesPerPixel * This->currentDesc.Width; /* Bytes / row */
17096
17097- if (NULL == pRect) {
17098+ if (NULL == pRect) {
17099 pLockedRect->pBits = This->resource.allocatedMemory;
17100 This->lockedRect.left = 0;
17101 This->lockedRect.top = 0;
17102@@ -264,22 +308,89 @@
17103 }
17104
17105
17106+ TRACE("Locking non-power 2 texture\n");
17107 if (0 == This->resource.usage) { /* classic surface */
17108-
17109- /* Nothing to do ;) */
17110+ IWineD3DBaseTexture *baseTexture = NULL;
17111+ TRACE("locking an ordinarary surface\n");
17112+ /* Check to see if memory has already been allocated fro the sufrace*/
17113+ if(NULL == This->resource.allocatedMemory){
17114+ /*Surface has no memory currently allocate to it!*/
17115+ TRACE("(%p) Locking rect\n" , This);
17116+ This->resource.allocatedMemory = HeapAlloc(GetProcessHeap() ,0 , This->pow2Size);
17117+
17118+ /*Now I have to copy thing bits back*/
17119+ This->activeLock = TRUE; /*When this flag is set to true, laoding the surface again won't free THis->resource.allocatedMemory*/
17120+ ENTER_GL();
17121+ TRACE("(%p) glEnable \n" , This);
17122+ glEnable(GL_TEXTURE_2D);
17123+ vcheckGLcall("glEnable(GL_TEXTURE_2D)");
17124+ TRACE("(%p) bind texture %d \n" , This, This->textureName);
17125+ /** TODO: replace this with a call to 'bindtexture' on the surface,
17126+ * to make sure that we have a valid textureName.
17127+ ************************************************/
17128+ /* This a problem if the container is a texture */
17129+ IWineD3DSurface_GetContainer(iface, &IID_IWineD3DBaseTexture, (void **)&baseTexture);
17130+ if(baseTexture == NULL){
17131+ IWineD3DSurface_PreLoad(iface); /* Make sure there is a texture to bind! */
17132+ TRACE("Binding texture %d\n", This->textureName);
17133+ glBindTexture(GL_TEXTURE_2D, This->textureName);
17134+ }else{
17135+ TRACE("Bind a texture to the target, not a standalone surface\n");
17136+ /* Tell the texture to bind it's self*/
17137+ IWineD3DBaseTexture_BindTexture(baseTexture);
17138+ IWineD3DBaseTexture_Release(baseTexture);
17139+ }
17140+ vcheckGLcall("glBindTexture");
17141+ TRACE("(%p) glGetTexImage level(%d), fmt(%d), typ(%d), mem(%p) \n" , This, This->currentDesc.Level, D3DFmt2GLFmt(myDevice, This->resource.format), D3DFmt2GLType(myDevice, This->resource.format), This->resource.allocatedMemory);
17142+ glGetTexImage(GL_TEXTURE_2D,
17143+ This->currentDesc.Level,
17144+ D3DFmt2GLFmt(myDevice, This->resource.format),
17145+ D3DFmt2GLType(myDevice, This->resource.format),
17146+ This->resource.allocatedMemory);
17147+ vcheckGLcall("glGetTexImage");
17148+ glDisable(GL_TEXTURE_2D);
17149+ vcheckGLcall("glDisable(GL_TEXTURE_2D)");
17150+ LEAVE_GL();
17151+ } else {
17152+ TRACE("Memory already allocted for texture\n");
17153+ }
17154+
17155+ if(NULL == pRect){
17156+ pLockedRect->pBits = This->resource.allocatedMemory;
17157+ } else{
17158+ if (This->resource.format == D3DFMT_DXT1) { /* DXT1 is half byte per pixel */
17159+ pLockedRect->pBits = This->resource.allocatedMemory + (pLockedRect->Pitch * pRect->top) + ((pRect->left * This->bytesPerPixel/2));
17160+ } else {
17161+ pLockedRect->pBits = This->resource.allocatedMemory + (pLockedRect->Pitch * pRect->top) + (pRect->left * This->bytesPerPixel);
17162+ }
17163+ }
17164
17165 } else if (D3DUSAGE_RENDERTARGET & This->resource.usage && !(Flags&D3DLOCK_DISCARD)) { /* render surfaces */
17166+ GLint prev_store;
17167
17168- if (iface == This->resource.wineD3DDevice->backBuffer || iface == This->resource.wineD3DDevice->renderTarget || iface == This->resource.wineD3DDevice->frontBuffer) {
17169- GLint prev_store;
17170+ /****************************
17171+ * TODO: Render targets are 'special' and
17172+ * ?some? locking needs to be passed onto the context manager
17173+ * this would enable the use of auxilary buffers, pbuffers
17174+ * render-to-texture, shared, cached contexts etc...
17175+ * ****************************/
17176 GLenum prev_read;
17177+ BOOL notInContext = FALSE;
17178+ IWineD3DSwapChainImpl *mySwapChain = NULL;
17179+ IWineD3DSwapChainImpl *targetSwapChain = NULL;
17180
17181- ENTER_GL();
17182-
17183+ ENTER_GL();
17184+
17185 /**
17186- * for render->surface copy begin to begin of allocatedMemory
17187- * unlock can be more easy
17188- */
17189+ * for render->surface copy begin to begin of allocatedMemory
17190+ * unlock can be more easy
17191+ */
17192+
17193+ TRACE("locking a render target\n");
17194+ /* Render targets are 'ALWAYS' in the default context, so shouldn't have any memory allocated to them by default */
17195+ if(This->resource.allocatedMemory == NULL)
17196+ This->resource.allocatedMemory = HeapAlloc(GetProcessHeap() ,0 ,This->pow2Size);
17197+ This->activeLock = TRUE; /*When this flag is set to true, loading the surface again won't free THis->resource.allocatedMemory*/
17198 pLockedRect->pBits = This->resource.allocatedMemory;
17199
17200 glFlush();
17201@@ -289,43 +400,83 @@
17202 glGetIntegerv(GL_PACK_SWAP_BYTES, &prev_store);
17203 vcheckGLcall("glIntegerv");
17204
17205- if (iface == This->resource.wineD3DDevice->backBuffer) {
17206+/* if (iface == This->resource.wineD3DDevice->backBuffer) {
17207 glReadBuffer(GL_BACK);
17208 } else if (iface == This->resource.wineD3DDevice->frontBuffer || iface == This->resource.wineD3DDevice->renderTarget) {
17209 glReadBuffer(GL_FRONT);
17210 } else if (iface == This->resource.wineD3DDevice->depthStencilBuffer) {
17211 ERR("Stencil Buffer lock unsupported for now\n");
17212- }
17213+ } */
17214 vcheckGLcall("glReadBuffer");
17215
17216 {
17217 long j;
17218 GLenum format = D3DFmt2GLFmt(This->resource.wineD3DDevice, This->resource.format);
17219 GLenum type = D3DFmt2GLType(This->resource.wineD3DDevice, This->resource.format);
17220- for (j = This->lockedRect.top; j < This->lockedRect.bottom - This->lockedRect.top; ++j) {
17221- glReadPixels(This->lockedRect.left,
17222- This->lockedRect.bottom - j - 1,
17223- This->lockedRect.right - This->lockedRect.left,
17224- 1,
17225- format,
17226- type,
17227- (char *)pLockedRect->pBits + (pLockedRect->Pitch * (j-This->lockedRect.top)));
17228- vcheckGLcall("glReadPixels");
17229+ #if 0
17230+ /* Bizarly it's takes 120 millseconds to get an 800x600 region a line at a time, but only 10 to get the whole lot every time,
17231+ * This is on an ATI9600, and may be format dependant, anyhow this hack makes this demo dx9_2d_demo_game
17232+ * run ten times faster!
17233+ * ************************************/
17234+ BOOL ati_performance_hack = FALSE;
17235+ ati_performance_hack = (This->lockedRect.bottom - This->lockedRect.top > 10) || (This->lockedRect.right - This->lockedRect.left > 10)? TRUE: FALSE;
17236+ #endif
17237+ if((This->lockedRect.left ==0 && This->lockedRect.top ==0 &&
17238+ This->lockedRect.right == This->currentDesc.Width
17239+ && This->lockedRect.bottom == This->currentDesc.Height)){
17240+ glReadPixels(0, 0,
17241+ This->currentDesc.Width,
17242+ This->currentDesc.Height,
17243+ format,
17244+ type,
17245+ (char *)pLockedRect->pBits);
17246+ }else if(This->lockedRect.left ==0 && This->lockedRect.right == This->currentDesc.Width){
17247+ glReadPixels(0,
17248+ This->lockedRect.top,
17249+ This->currentDesc.Width,
17250+ This->currentDesc.Height,
17251+ format,
17252+ type,
17253+ (char *)pLockedRect->pBits);
17254+ } else{
17255+ for (j = This->lockedRect.top; j < This->lockedRect.bottom - This->lockedRect.top; ++j) {
17256+ glReadPixels(This->lockedRect.left,
17257+ This->lockedRect.bottom - j - 1,
17258+ This->lockedRect.right - This->lockedRect.left,
17259+ 1,
17260+ format,
17261+ type,
17262+ (char *)pLockedRect->pBits + (pLockedRect->Pitch * (j-This->lockedRect.top)));
17263+
17264+ }
17265 }
17266+ vcheckGLcall("glReadPixels");
17267+ /*TODO: switch back to the precious context if necessasary */
17268+ TRACE("Resetting buffer\n");
17269+ glReadBuffer(prev_read);
17270+ vcheckGLcall("glReadBuffer");
17271 }
17272
17273- glReadBuffer(prev_read);
17274- vcheckGLcall("glReadBuffer");
17275-
17276 LEAVE_GL();
17277-
17278- } else {
17279+/* } else {
17280 FIXME("unsupported locking to Rendering surface surf@%p usage(%lu)\n", This, This->resource.usage);
17281- }
17282+ } */
17283
17284 } else if (D3DUSAGE_DEPTHSTENCIL & This->resource.usage) { /* stencil surfaces */
17285-
17286- FIXME("TODO stencil depth surface locking surf@%p usage(%lu)\n", This, This->resource.usage);
17287+ if(! messages & 1){
17288+ FIXME("TODO stencil depth surface locking surf%p usage(%lu)\n", This, This->resource.usage);
17289+ /*
17290+
17291+ glReadPixels(This->lockedRect.left,
17292+ This->lockedRect.bottom - j - 1,
17293+ This->lockedRect.right - This->lockedRect.left,
17294+ 1,
17295+ GL_STENCIL_INDEX or GL_DEPTH_COMPONENT
17296+
17297+ )
17298+ */
17299+ messages |=1;
17300+ }
17301
17302 } else {
17303 FIXME("unsupported locking to surface surf@%p usage(%lu)\n", This, This->resource.usage);
17304@@ -334,13 +485,15 @@
17305 if (Flags & (D3DLOCK_NO_DIRTY_UPDATE | D3DLOCK_READONLY)) {
17306 /* Don't dirtify */
17307 } else {
17308- IWineD3DBaseTexture *pBaseTexture;
17309+ IWineD3DBaseTexture *pBaseTexture = NULL;
17310+ HRESULT hr = D3D_OK;
17311+
17312+ TRACE("Dirty rec on lock\n");
17313 /**
17314- * Dirtify on lock
17315- * as seen in msdn docs
17316- */
17317+ * Dirtify on lock
17318+ * as seen in msdn docs
17319+ */
17320 IWineD3DSurface_AddDirtyRect(iface, &This->lockedRect);
17321-
17322 /** Dirtify Container if needed */
17323 if (D3D_OK == IWineD3DSurface_GetContainer(iface, &IID_IWineD3DBaseTexture, (void **)&pBaseTexture) && pBaseTexture != NULL) {
17324 TRACE("Making container dirty\n");
17325@@ -352,54 +505,75 @@
17326 }
17327
17328 TRACE("returning memory@%p, pitch(%d) dirtyfied(%d)\n", pLockedRect->pBits, pLockedRect->Pitch, This->Dirty);
17329-
17330+ if (TRACE_ON(d3d_timings))
17331+ TRACE_(d3d_timings)("(%p) starttime %ld, total time %ld\n", This, startTime , GetTickCount() -startTime);
17332 This->locked = TRUE;
17333 return D3D_OK;
17334 }
17335
17336-HRESULT WINAPI IWineD3DSurfaceImpl_UnlockRect(IWineD3DSurface *iface) {
17337+HRESULT WINAPI IWineD3DSurfaceImpl_UnlockRect(IWineD3DSurface* iface) {
17338+ IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface;
17339+ IWineD3DDeviceImpl *myDevice = This->resource.wineD3DDevice;
17340 GLint skipBytes = 0;
17341- IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface;
17342+ static int messages =0;
17343+ DWORD startTime = 0;
17344+ const char *buffername = "";
17345+ IWineD3DSwapChainImpl *swapchain = NULL;
17346+
17347+ if (TRACE_ON(d3d_timings))
17348+ startTime = GetTickCount(); /* Use windows calls for this */
17349
17350 if (FALSE == This->locked) {
17351 ERR("trying to Unlock an unlocked surf@%p\n", This);
17352 return D3DERR_INVALIDCALL;
17353 }
17354
17355+#if 0
17356 if (iface== This->resource.wineD3DDevice->backBuffer || iface == This->resource.wineD3DDevice->frontBuffer ||
17357 iface == This->resource.wineD3DDevice->depthStencilBuffer || iface == This->resource.wineD3DDevice->renderTarget) {
17358 if (iface == This->resource.wineD3DDevice->backBuffer) {
17359- TRACE("(%p, backBuffer) : dirtyfied(%d)\n", This, This->Dirty);
17360+ buffername = "backBuffer";
17361 } else if (iface == This->resource.wineD3DDevice->frontBuffer) {
17362- TRACE("(%p, frontBuffer) : dirtyfied(%d)\n", This, This->Dirty);
17363+ buffername = "frontBuffer";
17364 } else if (iface == This->resource.wineD3DDevice->depthStencilBuffer) {
17365- TRACE("(%p, stencilBuffer) : dirtyfied(%d)\n", This, This->Dirty);
17366+ buffername = "depthStencilBuffer";
17367 } else if (iface == This->resource.wineD3DDevice->renderTarget) {
17368- TRACE("(%p, renderTarget) : dirtyfied(%d)\n", This, This->Dirty);
17369- }
17370- } else {
17371- TRACE("(%p) : dirtyfied(%d)\n", This, This->Dirty);
17372+ buffername = "renderTarget";
17373 }
17374+ if(swapchain != NULL){
17375+ IWineD3DSwapChain_Release((IWineD3DSwapChain *)swapchain);
17376+ }
17377+#endif
17378+ TRACE("(%p %s) : dirtyfied(%d)\n", This, buffername, This->Dirty);
17379
17380- if (FALSE == This->Dirty) {
17381+ if (FALSE == This->Dirty) {
17382 TRACE("(%p) : Not Dirtified so nothing to do, return now\n", This);
17383 goto unlock_end;
17384 }
17385
17386 if (0 == This->resource.usage) { /* classic surface */
17387 /**
17388- * nothing to do
17389- * waiting to reload the surface via IDirect3DDevice8::UpdateTexture
17390- */
17391+ * nothing to do
17392+ * waiting to reload the surface via IDirect3DDevice8::UpdateTexture when the texture is preloaded
17393+ */
17394 } else if (D3DUSAGE_RENDERTARGET & This->resource.usage) { /* render surfaces */
17395-
17396- if (iface == This->resource.wineD3DDevice->backBuffer || iface == This->resource.wineD3DDevice->frontBuffer || iface == This->resource.wineD3DDevice->renderTarget) {
17397+
17398+ /****************************
17399+ * TODO: Render targets are 'special' and
17400+ * ?some? locking needs to be passed onto the context manager
17401+ * this would enable the use of auxilary buffers, pbuffers
17402+ * render-to-texture, shared, cached contexts etc...
17403+ * ****************************/
17404+
17405+ IWineD3DSwapChainImpl *implSwapChain;
17406+ IWineD3DDevice_GetSwapChain((IWineD3DDevice *)myDevice, 0, (IWineD3DSwapChain **)&implSwapChain);
17407+ if (iface == implSwapChain->backBuffer || iface == implSwapChain->frontBuffer || iface == myDevice->renderTarget) {
17408 GLint prev_store;
17409 GLenum prev_draw;
17410 GLint prev_rasterpos[4];
17411-
17412+
17413 ENTER_GL();
17414-
17415+
17416 glFlush();
17417 vcheckGLcall("glFlush");
17418 glGetIntegerv(GL_DRAW_BUFFER, &prev_draw);
17419@@ -410,67 +584,72 @@
17420 vcheckGLcall("glIntegerv");
17421 glPixelZoom(1.0, -1.0);
17422 vcheckGLcall("glPixelZoom");
17423-
17424+
17425 /* glDrawPixels transforms the raster position as though it was a vertex -
17426- we want to draw at screen position 0,0 - Set up ortho (rhw) mode as
17427- per drawprim (and leave set - it will sort itself out due to last_was_rhw */
17428- if (!This->resource.wineD3DDevice->last_was_rhw) {
17429-
17430+ we want to draw at screen position 0,0 - Set up ortho (rhw) mode as
17431+ per drawprim (and leave set - it will sort itself out due to last_was_rhw
17432+ TODO: this needs to be per-context! possibly migrate to the context manager?
17433+ it would keep all the code like this \/\/\/\/ in the same place too
17434+ */
17435+ if (!myDevice->last_was_rhw) {
17436+
17437 double X, Y, height, width, minZ, maxZ;
17438- This->resource.wineD3DDevice->last_was_rhw = TRUE;
17439-
17440+ myDevice->last_was_rhw = TRUE;
17441+
17442 /* Transformed already into viewport coordinates, so we do not need transform
17443- matrices. Reset all matrices to identity and leave the default matrix in world
17444- mode. */
17445+ matrices. Reset all matrices to identity and leave the default matrix in world
17446+ mode. */
17447 glMatrixMode(GL_MODELVIEW);
17448 checkGLcall("glMatrixMode");
17449 glLoadIdentity();
17450 checkGLcall("glLoadIdentity");
17451-
17452+
17453 glMatrixMode(GL_PROJECTION);
17454 checkGLcall("glMatrixMode");
17455 glLoadIdentity();
17456 checkGLcall("glLoadIdentity");
17457-
17458+
17459 /* Set up the viewport to be full viewport */
17460- X = This->resource.wineD3DDevice->stateBlock->viewport.X;
17461- Y = This->resource.wineD3DDevice->stateBlock->viewport.Y;
17462- height = This->resource.wineD3DDevice->stateBlock->viewport.Height;
17463- width = This->resource.wineD3DDevice->stateBlock->viewport.Width;
17464- minZ = This->resource.wineD3DDevice->stateBlock->viewport.MinZ;
17465- maxZ = This->resource.wineD3DDevice->stateBlock->viewport.MaxZ;
17466+ X = myDevice->stateBlock->viewport.X;
17467+ Y = myDevice->stateBlock->viewport.Y;
17468+ height = myDevice->stateBlock->viewport.Height;
17469+ width = myDevice->stateBlock->viewport.Width;
17470+ minZ = myDevice->stateBlock->viewport.MinZ;
17471+ maxZ = myDevice->stateBlock->viewport.MaxZ;
17472 TRACE("Calling glOrtho with %f, %f, %f, %f\n", width, height, -minZ, -maxZ);
17473- glOrtho(X, X + width, Y + height, Y, -minZ, -maxZ);
17474- checkGLcall("glOrtho");
17475-
17476+ glOrtho(X, X + width, Y + height, Y, -minZ, -maxZ);
17477+ checkGLcall("glOrtho");
17478+
17479 /* Window Coord 0 is the middle of the first pixel, so translate by half
17480- a pixel (See comment above glTranslate below) */
17481+ a pixel (See comment above glTranslate below) */
17482 glTranslatef(0.5, 0.5, 0);
17483 checkGLcall("glTranslatef(0.5, 0.5, 0)");
17484 }
17485-
17486+
17487+#if 0
17488 if (iface == This->resource.wineD3DDevice->backBuffer) {
17489 glDrawBuffer(GL_BACK);
17490 } else if (iface == This->resource.wineD3DDevice->frontBuffer || iface == This->resource.wineD3DDevice->renderTarget) {
17491 glDrawBuffer(GL_FRONT);
17492 }
17493- vcheckGLcall("glDrawBuffer");
17494-
17495+
17496+ vcheckGLcall("glDrawBuffer");
17497+#endif
17498 /* If not fullscreen, we need to skip a number of bytes to find the next row of data */
17499 glGetIntegerv(GL_UNPACK_ROW_LENGTH, &skipBytes);
17500 glPixelStorei(GL_UNPACK_ROW_LENGTH, This->currentDesc.Width);
17501-
17502+
17503 /* And back buffers are not blended */
17504 glDisable(GL_BLEND);
17505-
17506 glRasterPos3i(This->lockedRect.left, This->lockedRect.top, 1);
17507 vcheckGLcall("glRasterPos2f");
17508 switch (This->resource.format) {
17509+
17510 case WINED3DFMT_R5G6B5:
17511 {
17512- glDrawPixels(This->lockedRect.right - This->lockedRect.left, (This->lockedRect.bottom - This->lockedRect.top)-1,
17513+ glDrawPixels(This->lockedRect.right - This->lockedRect.left, (This->lockedRect.bottom - This->lockedRect.top)-1,
17514 GL_RGB, GL_UNSIGNED_SHORT_5_6_5, This->resource.allocatedMemory);
17515- vcheckGLcall("glDrawPixels");
17516+ vcheckGLcall("glDrawPixels");
17517 }
17518 break;
17519 case WINED3DFMT_R8G8B8:
17520@@ -481,7 +660,7 @@
17521 }
17522 break;
17523 case WINED3DFMT_X8R8G8B8: /* FIXME: there's no alpha change with D3DFMT_X8R8G8B8 but were using GL_BGRA */
17524- case WINED3DFMT_A8R8G8B8:
17525+ case D3DFMT_A8R8G8B8:
17526 {
17527 glPixelStorei(GL_PACK_SWAP_BYTES, TRUE);
17528 vcheckGLcall("glPixelStorei");
17529@@ -495,33 +674,39 @@
17530 default:
17531 FIXME("Unsupported Format %u in locking func\n", This->resource.format);
17532 }
17533-
17534 glPixelZoom(1.0,1.0);
17535 vcheckGLcall("glPixelZoom");
17536 glDrawBuffer(prev_draw);
17537 vcheckGLcall("glDrawBuffer");
17538 glRasterPos3iv(&prev_rasterpos[0]);
17539 vcheckGLcall("glRasterPos3iv");
17540-
17541+
17542 /* Reset to previous pack row length / blending state */
17543 glPixelStorei(GL_UNPACK_ROW_LENGTH, skipBytes);
17544- if (This->resource.wineD3DDevice->stateBlock->renderState[D3DRS_ALPHABLENDENABLE]) glEnable(GL_BLEND);
17545-
17546- LEAVE_GL();
17547-
17548- /** restore clean dirty state */
17549- IWineD3DSurface_CleanDirtyRect(iface);
17550+ if (myDevice->stateBlock->renderState[D3DRS_ALPHABLENDENABLE]) glEnable(GL_BLEND);
17551+
17552+ LEAVE_GL();
17553+
17554+ /** restore clean dirty stateD3DFMT_A8R8G8B8 */
17555+ IWineD3DSurface_CleanDirtyRect(iface);
17556
17557- } else {
17558+ } else {
17559 FIXME("unsupported unlocking to Rendering surface surf@%p usage(%lu)\n", This, This->resource.usage);
17560- }
17561-
17562+ }
17563+ IWineD3DSwapChain_Release((IWineD3DSwapChain *)implSwapChain);
17564+
17565 } else if (D3DUSAGE_DEPTHSTENCIL & This->resource.usage) { /* stencil surfaces */
17566-
17567- if (iface == This->resource.wineD3DDevice->depthStencilBuffer) {
17568- FIXME("TODO stencil depth surface unlocking surf@%p usage(%lu)\n", This, This->resource.usage);
17569+
17570+ if (iface == myDevice->depthStencilBuffer) {
17571+ if(!messages &1){
17572+ FIXME("TODO stencil depth surface unlocking surf@%p usage(%lu)\n", This, This->resource.usage);
17573+ messages |=1;
17574+ }
17575 } else {
17576- FIXME("unsupported unlocking to StencilDepth surface surf@%p usage(%lu)\n", This, This->resource.usage);
17577+ if(!(messages & 2)){
17578+ FIXME("unsupported unlocking to StencilDepth surface surf@%p usage(%lu)\n", This, This->resource.usage);
17579+ messages |=2;
17580+ }
17581 }
17582
17583 } else {
17584@@ -531,29 +716,42 @@
17585 unlock_end:
17586 This->locked = FALSE;
17587 memset(&This->lockedRect, 0, sizeof(RECT));
17588+ if (TRACE_ON(d3d_timings))
17589+ TRACE_(d3d_timings)("(%p) starttime %ld, total time %ld\n", This, startTime , GetTickCount() -startTime);
17590+
17591 return D3D_OK;
17592 }
17593
17594-HRESULT WINAPI IWineD3DSurfaceImpl_GetDC(IWineD3DSurface *iface, HDC *pHDC) {
17595+HRESULT WINAPI IWineD3DSurfaceImpl_GetDC(IWineD3DSurface * iface, HDC* phdc) {
17596 IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface;
17597- FIXME("No support for GetDC yet for surface %p\n", This);
17598+ FIXME("(%p) : stub\n", This);
17599 return D3DERR_INVALIDCALL;
17600 }
17601
17602-HRESULT WINAPI IWineD3DSurfaceImpl_ReleaseDC(IWineD3DSurface *iface, HDC hDC) {
17603+HRESULT WINAPI IWineD3DSurfaceImpl_ReleaseDC(IWineD3DSurface * iface, HDC hdc) {
17604 IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface;
17605- FIXME("No support for ReleaseDC yet for surface %p\n", This);
17606+ FIXME("(%p) : stub\n", This);
17607 return D3DERR_INVALIDCALL;
17608 }
17609
17610+HRESULT WINAPI IWineD3DSurfaceImpl_SaveSnapshot(IWineD3DSurface *iface, const char* filename);
17611 /* ******************************************************
17612 IWineD3DSurface Internal (No mapping to directx api) parts follow
17613 ****************************************************** */
17614 HRESULT WINAPI IWineD3DSurfaceImpl_LoadTexture(IWineD3DSurface *iface, GLenum gl_target, GLenum gl_level) {
17615- IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface;
17616-
17617+ IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface;
17618+ IWineD3DDeviceImpl *myDevice = This->resource.wineD3DDevice;
17619+ /*TODO: Obay the textures pool and move some textures over to video ram (if possible)*/
17620 if (This->inTexture)
17621 return D3D_OK;
17622+ /*
17623+ Resources are placed in system RAM and do not need to be recreated when a device is lost. These resources are not bound by device size or format restrictions. Because of this, these resources cannot be accessed by the Direct3D device nor set as textures or render targets. However, these resources can always be created, locked, and copied.
17624+ */
17625+ if (This->resource.pool == D3DPOOL_SCRATCH || This->resource.pool == D3DPOOL_SYSTEMMEM) /*never store scratch or system mem textures in the video ram*/
17626+ {
17627+ FIXME("(%p) Opperation not supported for scratch or SYSTEMMEM textures\n",This);
17628+ return D3DERR_INVALIDCALL;
17629+ }
17630
17631 if (This->inPBuffer) {
17632 ENTER_GL();
17633@@ -565,22 +763,45 @@
17634 This->resource.format == WINED3DFMT_DXT5)
17635 FIXME("Format %d not supported\n", This->resource.format);
17636 else {
17637- glCopyTexImage2D(gl_target,
17638+ /*It's possible that glPixelSoom is supported? */
17639+ #if 1
17640+ #if 0/* usefull for debugging, generate a colourdImage instead of glCopyTexImage2D */
17641+ unsigned char *whiteImage = NULL;
17642+ whiteImage = malloc(This->currentDesc.Width * This->currentDesc.Height*4);
17643+ memset(whiteImage, 200, This->currentDesc.Width* This->currentDesc.Height*4);
17644+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
17645+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
17646+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA,
17647+ This->currentDesc.Width, This->currentDesc.Height,
17648+ 0, GL_RGBA, GL_UNSIGNED_BYTE, whiteImage);
17649+ free(whiteImage);
17650+ #else
17651+ /*
17652+
17653+ NOTE: The pixels in the rectangle are processed exactly as if glCopyPixels had been called. This means we need to set and restore pixelZoom &co.
17654+
17655+ */
17656+ glCopyTexImage2D(GL_TEXTURE_2D, //gl_target,
17657 0,
17658- D3DFmt2GLIntFmt(This->resource.wineD3DDevice,
17659+ D3DFmt2GLIntFmt(myDevice,
17660 This->resource.format),
17661 0,
17662 0,
17663 This->currentDesc.Width,
17664 This->currentDesc.Height,
17665 0);
17666+ #endif
17667+ checkGLcall("glCopyTexImage2D");
17668+
17669+#endif
17670+
17671 TRACE("Updating target %d\n", gl_target);
17672 This->inTexture = TRUE;
17673 }
17674 LEAVE_GL();
17675 return D3D_OK;
17676 }
17677-
17678+
17679 if ((This->resource.format == WINED3DFMT_P8 || This->resource.format == WINED3DFMT_A8P8) &&
17680 !GL_SUPPORT(EXT_PALETTED_TEXTURE)) {
17681 /**
17682@@ -588,7 +809,7 @@
17683 * so software emulation code begin
17684 */
17685 UINT i;
17686- PALETTEENTRY* pal = This->resource.wineD3DDevice->palettes[This->resource.wineD3DDevice->currentPalette];
17687+ PALETTEENTRY* pal = myDevice->palettes[myDevice->currentPalette];
17688 VOID* surface = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, This->currentDesc.Width * This->currentDesc.Height * sizeof(DWORD));
17689 BYTE* dst = (BYTE*) surface;
17690 BYTE* src = (BYTE*) This->resource.allocatedMemory;
17691@@ -609,27 +830,30 @@
17692 TRACE("Calling glTexImage2D %x i=%d, intfmt=%x, w=%d, h=%d,0=%d, glFmt=%x, glType=%x, Mem=%p\n",
17693 gl_target,
17694 gl_level,
17695- GL_RGBA,
17696+ GL_RGB,
17697 This->currentDesc.Width,
17698 This->currentDesc.Height,
17699 0,
17700 GL_RGBA,
17701 GL_UNSIGNED_BYTE,
17702- surface);
17703- glTexImage2D(gl_target,
17704- gl_level,
17705- GL_RGBA,
17706+ surface);
17707+ glTexImage2D(gl_target, /*Should always be GL_TEXTURE_2D*/
17708+ gl_level,
17709+ GL_RGB, /*This was GL_RGBA but the alpha channel has caused problems elsewhere*/
17710 This->currentDesc.Width,
17711 This->currentDesc.Height,
17712- 0,
17713+ 0/*border*/,
17714 GL_RGBA,
17715 GL_UNSIGNED_BYTE,
17716 surface);
17717 checkGLcall("glTexImage2D");
17718- HeapFree(GetProcessHeap(), 0, surface);
17719-
17720- LEAVE_GL();
17721-
17722+ LEAVE_GL();
17723+ #ifdef MANAGED_D3D_MEMORY
17724+ #if 0 /*TODO: dynamic locking of palleted textures isn't supported at the moment, so don't release the system memory*/
17725+ HeapFree(GetProcessHeap(),0,This->resource.allocatedMemory);
17726+ This->resource.allocatedMemory = NULL;
17727+ #endif
17728+ #endif
17729 return D3D_OK;
17730 }
17731
17732@@ -648,7 +872,6 @@
17733 This->resource.allocatedMemory);
17734
17735 ENTER_GL();
17736-
17737 GL_EXTCALL(glCompressedTexImage2DARB)(gl_target,
17738 gl_level,
17739 D3DFmt2GLIntFmt(This->resource.wineD3DDevice, This->resource.format),
17740@@ -658,49 +881,115 @@
17741 This->resource.size,
17742 This->resource.allocatedMemory);
17743 checkGLcall("glCommpressedTexTexImage2D");
17744+ LEAVE_GL();
17745+ #ifdef MANAGED_D3D_MEMORY
17746+ if(This->activeLock == FALSE){
17747+ HeapFree(GetProcessHeap(),0,This->resource.allocatedMemory);
17748+ This->resource.allocatedMemory = NULL;
17749+ globalChangeSysRam(-This->resource.size);
17750+ }
17751+ #endif
17752+
17753+
17754
17755- LEAVE_GL();
17756 } else {
17757 FIXME("Using DXT1/3/5 without advertized support\n");
17758 }
17759 } else {
17760-
17761- TRACE("Calling glTexImage2D %x i=%d, d3dfmt=%s, intfmt=%x, w=%d, h=%d,0=%d, glFmt=%x, glType=%x, Mem=%p\n",
17762- gl_target,
17763- gl_level,
17764+
17765+ if(gl_target != GL_TEXTURE_2D){
17766+ FIXME("gl_target must be GL_TEXTURE_2D\n");
17767+ }
17768+ /* TODO: http://oss.sgi.com/projects/ogl-sample/registry/ARB/texture_non_power_of_two.txt if supported and opengl 2.0
17769+ and this too GL_NV_texture_rectangle (but the implementation I've done seems better than GL_NV_texture_rectangle (e.g. mipmaps are supported)
17770+ http://www.msi.unilim.fr/~porquet/glexts/GL_NV_texture_rectangle.txt.html
17771+
17772+ */
17773+ if(This->nonpow2 == TRUE){
17774+ TRACE("non power of two support\n");
17775+ ENTER_GL();
17776+ TRACE("(%p) Calling 2 glTexImage2D %x i=%d, d3dfmt=%s, intfmt=%x, w=%d, h=%d,0=%d, glFmt=%x, glType=%x, Mem=%p\n", This,
17777+ gl_target,
17778+ gl_level,
17779 debug_d3dformat(This->resource.format),
17780 D3DFmt2GLIntFmt(This->resource.wineD3DDevice, This->resource.format),
17781- This->currentDesc.Width,
17782- This->currentDesc.Height,
17783- 0,
17784+ This->pow2Width,
17785+ This->pow2Height,
17786+ 0,
17787+ D3DFmt2GLFmt(myDevice, This->resource.format),
17788+ D3DFmt2GLType(myDevice, This->resource.format),
17789+ NULL);
17790+
17791+
17792+ glTexImage2D(gl_target,
17793+ gl_level,
17794+ D3DFmt2GLIntFmt(myDevice, This->resource.format),
17795+ This->pow2Width,
17796+ This->pow2Height,
17797+ 0/*border*/,
17798+ D3DFmt2GLFmt(myDevice, This->resource.format),
17799+ D3DFmt2GLType(myDevice, This->resource.format),
17800+ NULL);
17801+
17802+
17803+ checkGLcall("glTexImage2D");
17804+ if(This->resource.allocatedMemory != NULL){
17805+ TRACE("(%p) Calling glTexSubImage2D w(%d) h(%d) mem(%p)\n", This, This->currentDesc.Width, This->currentDesc.Height, This->resource.allocatedMemory);
17806+ /* And map the non-power two data into the top left corner */
17807+ glTexSubImage2D(
17808+ gl_target,
17809+ gl_level,
17810+ 0 /* xoffset */,
17811+ 0 /* ysoffset */ ,
17812+ This->currentDesc.Width,
17813+ This->currentDesc.Height,
17814+ D3DFmt2GLFmt(myDevice, This->resource.format),
17815+ D3DFmt2GLType(myDevice, This->resource.format),
17816+ This->resource.allocatedMemory
17817+ );
17818+ checkGLcall("glTexSubImage2D");
17819+ }
17820+
17821+ LEAVE_GL();
17822+
17823+
17824+ }else{
17825+
17826+ TRACE("Calling 2 glTexImage2D %x i=%d, d3dfmt=%s, intfmt=%x, w=%d, h=%d,0=%d, glFmt=%x, glType=%x, Mem=%p\n",
17827+ gl_target,
17828+ gl_level,
17829+ debug_d3dformat(This->resource.format),
17830+ D3DFmt2GLIntFmt(myDevice, This->resource.format),
17831+ This->currentDesc.Width,
17832+ This->currentDesc.Height,
17833+ 0,
17834 D3DFmt2GLFmt(This->resource.wineD3DDevice, This->resource.format),
17835 D3DFmt2GLType(This->resource.wineD3DDevice, This->resource.format),
17836 This->resource.allocatedMemory);
17837-
17838- ENTER_GL();
17839-
17840- glTexImage2D(gl_target,
17841- gl_level,
17842+
17843+ ENTER_GL();
17844+ glTexImage2D(gl_target,
17845+ gl_level,
17846 D3DFmt2GLIntFmt(This->resource.wineD3DDevice, This->resource.format),
17847- This->currentDesc.Width,
17848- This->currentDesc.Height,
17849- 0,
17850+ This->currentDesc.Width,
17851+ This->currentDesc.Height,
17852+ 0/*border*/,
17853 D3DFmt2GLFmt(This->resource.wineD3DDevice, This->resource.format),
17854 D3DFmt2GLType(This->resource.wineD3DDevice, This->resource.format),
17855 This->resource.allocatedMemory);
17856- checkGLcall("glTexImage2D");
17857-
17858- LEAVE_GL();
17859+ checkGLcall("glTexImage2D");
17860+ LEAVE_GL();
17861+ }
17862
17863-#if 0
17864+#if 0 /* Take a snapshot!*/
17865 {
17866 static unsigned int gen = 0;
17867- char buffer[4096];
17868- ++gen;
17869- if ((gen % 10) == 0) {
17870+ char buffer[4096];
17871+ if ((gen % 10) == 0) {
17872 snprintf(buffer, sizeof(buffer), "/tmp/surface%p_type%u_level%u_%u.ppm", This, gl_target, gl_level, gen);
17873- IWineD3DSurfaceImpl_SaveSnapshot((LPDIRECT3DSURFACE8) This, buffer);
17874+ IWineD3DSurfaceImpl_SaveSnapshot((IWineD3DSurface*) This, (const char*) buffer);
17875 }
17876+ ++gen;
17877 /*
17878 * debugging crash code
17879 if (gen == 250) {
17880@@ -710,6 +999,14 @@
17881 */
17882 }
17883 #endif
17884+
17885+ #ifdef MANAGED_D3D_MEMORY
17886+ if(This->activeLock == FALSE){
17887+ HeapFree(GetProcessHeap(),0,This->resource.allocatedMemory);
17888+ This->resource.allocatedMemory = NULL;
17889+ globalChangeSysRam(-This->resource.size);
17890+ }
17891+ #endif
17892 }
17893
17894 return D3D_OK;
17895@@ -717,10 +1014,19 @@
17896
17897 #include <errno.h>
17898 #include <stdio.h>
17899+
17900 HRESULT WINAPI IWineD3DSurfaceImpl_SaveSnapshot(IWineD3DSurface *iface, const char* filename) {
17901 FILE* f = NULL;
17902 ULONG i;
17903 IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface;
17904+ /*FIXME:
17905+ Textures my not be stored in ->allocateMemory and a GlTexture
17906+ so we should lock the surface before saving a snapshot, or atleast check that
17907+ */
17908+ if(NULL == This->resource.allocatedMemory){
17909+ FIXME("(%p) This surface needs to be locked before a snapshot can be taken\n", This);
17910+ return D3D_OK;
17911+ }
17912
17913 f = fopen(filename, "w+");
17914 if (NULL == f) {
17915@@ -796,24 +1102,24 @@
17916 return D3D_OK;
17917 }
17918
17919-HRESULT WINAPI IWineD3DSurfaceImpl_CleanDirtyRect(IWineD3DSurface *iface) {
17920- IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface;
17921- This->Dirty = FALSE;
17922- This->dirtyRect.left = This->currentDesc.Width;
17923- This->dirtyRect.top = This->currentDesc.Height;
17924- This->dirtyRect.right = 0;
17925- This->dirtyRect.bottom = 0;
17926- TRACE("(%p) : Dirty?%d, Rect:(%ld,%ld,%ld,%ld)\n", This, This->Dirty, This->dirtyRect.left,
17927- This->dirtyRect.top, This->dirtyRect.right, This->dirtyRect.bottom);
17928- return D3D_OK;
17929+
17930+HRESULT WINAPI IWineD3DSurfaceImpl_CleanDirtyRect(IWineD3DSurface* iface) {
17931+ IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface;
17932+ This->Dirty = FALSE;
17933+ This->dirtyRect.left = This->currentDesc.Width;
17934+ This->dirtyRect.top = This->currentDesc.Height;
17935+ This->dirtyRect.right = 0;
17936+ This->dirtyRect.bottom = 0;
17937+ return D3D_OK;
17938 }
17939
17940 /**
17941 * Slightly inefficient way to handle multiple dirty rects but it works :)
17942 */
17943-extern HRESULT WINAPI IWineD3DSurfaceImpl_AddDirtyRect(IWineD3DSurface *iface, CONST RECT* pDirtyRect) {
17944+HRESULT WINAPI IWineD3DSurfaceImpl_AddDirtyRect(IWineD3DSurface* iface, CONST RECT* pDirtyRect) {
17945 IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface;
17946 This->Dirty = TRUE;
17947+ /*FIXME: Possibly handle multiple clipping rects instead of growing the main dirty rect?*/
17948 if (NULL != pDirtyRect) {
17949 This->dirtyRect.left = min(This->dirtyRect.left, pDirtyRect->left);
17950 This->dirtyRect.top = min(This->dirtyRect.top, pDirtyRect->top);
17951@@ -822,7 +1128,7 @@
17952 } else {
17953 This->dirtyRect.left = 0;
17954 This->dirtyRect.top = 0;
17955- This->dirtyRect.right = This->currentDesc.Width;
17956+ This->dirtyRect.right = This->currentDesc.Width;
17957 This->dirtyRect.bottom = This->currentDesc.Height;
17958 }
17959 TRACE("(%p) : Dirty?%d, Rect:(%ld,%ld,%ld,%ld)\n", This, This->Dirty, This->dirtyRect.left,
17960@@ -851,7 +1157,7 @@
17961 /* IUnknown */
17962 IWineD3DSurfaceImpl_QueryInterface,
17963 IWineD3DSurfaceImpl_AddRef,
17964- IWineD3DSurfaceImpl_Release,
17965+ IWineD3DSurfaceImpl_Release,
17966 /* IWineD3DResource */
17967 IWineD3DSurfaceImpl_GetParent,
17968 IWineD3DSurfaceImpl_GetDevice,
17969@@ -861,8 +1167,8 @@
17970 IWineD3DSurfaceImpl_SetPriority,
17971 IWineD3DSurfaceImpl_GetPriority,
17972 IWineD3DSurfaceImpl_PreLoad,
17973- IWineD3DSurfaceImpl_GetType,
17974- /* IWineD3DSurface */
17975+ IWineD3DSurfaceImpl_GetType,
17976+ /* IWineD3DSurface */
17977 IWineD3DSurfaceImpl_GetContainer,
17978 IWineD3DSurfaceImpl_GetDesc,
17979 IWineD3DSurfaceImpl_LockRect,
17980@@ -875,5 +1181,5 @@
17981 IWineD3DSurfaceImpl_LoadTexture,
17982 IWineD3DSurfaceImpl_SaveSnapshot,
17983 IWineD3DSurfaceImpl_SetContainer,
17984- IWineD3DSurfaceImpl_SetPBufferState
17985+ IWineD3DSurfaceImpl_SetPBufferState
17986 };
17987diff -urN wine.20050419/dlls/wined3d/swapchain.c wine.20050419.dx9/dlls/wined3d/swapchain.c
17988--- wine.20050419/dlls/wined3d/swapchain.c 1969-12-31 17:00:00.000000000 -0700
17989+++ wine.20050419.dx9/dlls/wined3d/swapchain.c 2005-04-20 05:52:05.000000000 -0600
17990@@ -0,0 +1,463 @@
17991+/*
17992+ *IDirect3DSwapChain9 implementation
17993+ *
17994+ *Copyright 2002-2003 Jason Edmeades
17995+ * Raphael Junqueira
17996+ * 2005 Oliver Stieber
17997+ *
17998+ *This library is free software; you can redistribute it and/or
17999+ *modify it under the terms of the GNU Lesser General Public
18000+ *License as published by the Free Software Foundation; either
18001+ *version 2.1 of the License, or (at your option) any later version.
18002+ *
18003+ *This library is distributed in the hope that it will be useful,
18004+ *but WITHOUT ANY WARRANTY; without even the implied warranty of
18005+ *MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18006+ *Lesser General Public License for more details.
18007+ *
18008+ *You should have received a copy of the GNU Lesser General Public
18009+ *License along with this library; if not, write to the Free Software
18010+ *Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18011+ */
18012+
18013+#include "config.h"
18014+#include "wined3d_private.h"
18015+
18016+
18017+/* TODO: move to shared header (or context manager )*/
18018+/* x11drv GDI escapes */
18019+#define X11DRV_ESCAPE 6789
18020+enum x11drv_escape_codes
18021+{
18022+ X11DRV_GET_DISPLAY, /* get X11 display for a DC */
18023+ X11DRV_GET_DRAWABLE, /* get current drawable for a DC */
18024+ X11DRV_GET_FONT, /* get current X font for a DC */
18025+};
18026+
18027+/* retrieve the X display to use on a given DC */
18028+inline static Display *get_display( HDC hdc )
18029+{
18030+ Display *display;
18031+ enum x11drv_escape_codes escape = X11DRV_GET_DISPLAY;
18032+
18033+ if (!ExtEscape( hdc, X11DRV_ESCAPE, sizeof(escape), (LPCSTR)&escape,
18034+ sizeof(display), (LPSTR)&display )) display = NULL;
18035+ return display;
18036+}
18037+
18038+
18039+
18040+
18041+/*TODO: some of the additional parameters may be required to
18042+ set the gamma ramp (for some weird reason microsoft have left swap gammaramp in device
18043+ but it operates on a swapchain, it may be a good idea to move it to IWineD3DSwapChain for IWineD3D)*/
18044+
18045+
18046+WINE_DEFAULT_DEBUG_CHANNEL(d3d);
18047+WINE_DECLARE_DEBUG_CHANNEL(d3d_fps);
18048+
18049+
18050+/* IDirect3DSwapChain IUnknown parts follow: */
18051+
18052+
18053+ULONG WINAPI IWineD3DSwapChainImpl_AddRef(IWineD3DSwapChain *iface) {
18054+ IWineD3DSwapChainImpl *This = (IWineD3DSwapChainImpl *)iface;
18055+ DWORD refCount = InterlockedIncrement(&This->ref);
18056+ TRACE("(%p) : AddRef increasing from %ld\n", This, refCount - 1);
18057+ return refCount;
18058+}
18059+
18060+HRESULT WINAPI IWineD3DSwapChainImpl_QueryInterface(IWineD3DSwapChain *iface, REFIID riid, LPVOID *ppobj)
18061+{
18062+ IWineD3DSwapChainImpl *This = (IWineD3DSwapChainImpl *)iface;
18063+ TRACE("(%p)->(%s,%p) \n",This,debugstr_guid(riid),ppobj);
18064+ if (IsEqualGUID(riid, &IID_IUnknown)
18065+ || IsEqualGUID(riid, &IID_IWineD3DSwapChain)){
18066+ IWineD3DSwapChainImpl_AddRef(iface);
18067+ if(ppobj == NULL){
18068+ ERR("Query interface called but now data allocated\n");
18069+ return E_NOINTERFACE;
18070+ }
18071+ *ppobj = This;
18072+ return D3D_OK;
18073+ }
18074+ return E_NOINTERFACE;
18075+}
18076+
18077+
18078+ULONG WINAPI IWineD3DSwapChainImpl_Release(IWineD3DSwapChain *iface) {
18079+ IWineD3DSwapChainImpl *This = (IWineD3DSwapChainImpl *)iface;
18080+ DWORD refCount;
18081+ refCount = InterlockedDecrement(&This->ref);
18082+ TRACE("(%p) : ReleaseRef to %ld\n", This, refCount);
18083+ if (refCount == 0) {
18084+ IUnknown* bufferParent;
18085+ IWineD3DSurface_GetParent(This->frontBuffer, &bufferParent);
18086+ IUnknown_Release(bufferParent); /* once for the get parent */
18087+ if(IUnknown_Release(bufferParent) > 0){
18088+ FIXME("(%p) Something's still holding the front buffer\n",This);
18089+ }
18090+
18091+ IWineD3DSurface_GetParent(This->backBuffer, &bufferParent);
18092+ IUnknown_Release(bufferParent); /* once for the get parent */
18093+ if(IUnknown_Release(bufferParent) > 0){
18094+ FIXME("(%p) Something's still holding the back buffer\n",This);
18095+ }
18096+ /* Clean up the context */
18097+ /* check that we are the current context first */
18098+ if(glXGetCurrentContext() == This->glCtx){
18099+ glXMakeCurrent(This->display, None, NULL);
18100+ }
18101+ glXDestroyContext(This->display, This->glCtx);
18102+ /* IUnknown_Release(This->parent); This should only apply to the primary swapchain,
18103+ all others are crated by the caller, so releasing the parent should cause
18104+ the child to be released, not the other way around!
18105+ */
18106+ /* TODO: notify the device that this swapchain doesn't exist any more */
18107+ HeapFree(GetProcessHeap(), 0, This);
18108+ }
18109+ return refCount;
18110+}
18111+
18112+HRESULT WINAPI IWineD3DSwapChainImpl_GetParent(IWineD3DSwapChain *iface, IUnknown ** ppParent){
18113+ IWineD3DSwapChainImpl *This = (IWineD3DSwapChainImpl *)iface;
18114+ *ppParent = This->parent;
18115+ IUnknown_AddRef(*ppParent);
18116+ TRACE("(%p) returning %p\n", This , *ppParent);
18117+ return D3D_OK;
18118+}
18119+
18120+/*IWineD3DSwapChain parts follow: */
18121+HRESULT WINAPI IWineD3DSwapChainImpl_Present(IWineD3DSwapChain *iface, CONST RECT *pSourceRect, CONST RECT *pDestRect, HWND hDestWindowOverride, CONST RGNDATA *pDirtyRegion, DWORD dwFlags) {
18122+ IWineD3DSwapChainImpl *This = (IWineD3DSwapChainImpl *)iface;
18123+
18124+ ENTER_GL();
18125+
18126+ if (pSourceRect || pDestRect) FIXME("Unhandled present options %p/%p\n", pSourceRect, pDestRect);
18127+ /* TODO: If only source rect or dest rect are supplied then clip the window to match */
18128+ TRACE("preseting display %p, drawable %ld\n", This->display, This->drawable);
18129+
18130+ /* Don't call checkGLcall, as glGetError is not applicable here */
18131+ if (hDestWindowOverride && This->win_handle != hDestWindowOverride) {
18132+ /* Set this swapchain up to point to the new destination.. */
18133+ #ifdef USE_CONTEXT_MANAGER
18134+ /* TODO: use a context mamager */
18135+ #endif
18136+
18137+ /* FIXME: Never access */
18138+ IWineD3DSwapChainImpl *swapChainImpl;
18139+ IWineD3DDevice_GetSwapChain((IWineD3DDevice *)This->wineD3DDevice, 0 , (IWineD3DSwapChain **)&swapChainImpl);
18140+ FIXME("Unable to render to a destination window %d\n", (int)hDestWindowOverride );
18141+ if(This == swapChainImpl){
18142+ /* FIXME: this will be fixed by moving to a context management system */
18143+ FIXME("Cannot change the target of the implicite swapchain\n");
18144+ }else{
18145+ HDC hDc;
18146+ XVisualInfo template;
18147+ int num;
18148+ Display *oldDisplay = This->display;
18149+ GLXContext oldContext = This->glCtx;
18150+ IUnknown* tmp;
18151+ GLXContext currentContext;
18152+ Drawable currentDrawable;
18153+ hDc = GetDC(hDestWindowOverride);
18154+ This->win_handle = hDestWindowOverride;
18155+ This->win = (Window)GetPropA( hDestWindowOverride, "__wine_x11_whole_window" );
18156+
18157+ TRACE("Creating a new context for the window %p \n", hDestWindowOverride);
18158+ ENTER_GL();
18159+ TRACE("Desctroying context %p %p\n", This->display, This->render_ctx);
18160+
18161+
18162+
18163+ LEAVE_GL();
18164+ ENTER_GL();
18165+
18166+ This->display = get_display(hDc);
18167+ TRACE("Got display%p for %p %p\n", This->display, hDc, hDestWindowOverride);
18168+ ReleaseDC(hDestWindowOverride, hDc);
18169+ template.visualid = (VisualID)GetPropA(GetDesktopWindow(), "__wine_x11_visual_id");
18170+ This->visInfo = XGetVisualInfo(This->display, VisualIDMask, &template, &num);
18171+ if (NULL == This->visInfo) {
18172+ ERR("cannot really get XVisual\n");
18173+ LEAVE_GL();
18174+ return D3DERR_NOTAVAILABLE;
18175+ }
18176+ /* Now we have problems? well not really we just need to know what the implicite context is */
18177+ /* now destroy the old context and create a new one (we should really copy the buffers over, and do the whole make current thing! */
18178+ /* destroy the active context?*/
18179+ TRACE("Creating new context for %p %p %p\n",This->display, This->visInfo, swapChainImpl->glCtx);
18180+ This->glCtx = glXCreateContext(This->display, This->visInfo, swapChainImpl->glCtx, GL_TRUE);
18181+
18182+ if (NULL == This->glCtx) {
18183+ ERR("cannot create glxContext\n");
18184+ }
18185+ This->drawable = This->win;
18186+ This->render_ctx = This->glCtx;
18187+ /* SEtup some default states TODO: apply the stateblock to the new context */
18188+ /** save current context and drawable **/
18189+ currentContext = glXGetCurrentContext();
18190+ currentDrawable = glXGetCurrentDrawable();
18191+
18192+ if (glXMakeCurrent(This->display, This->win, This->glCtx) == False) {
18193+ ERR("Error in setting current context (display %p context %p drawable %ld)!\n", This->display, This->glCtx, This->win);
18194+ }
18195+
18196+ checkGLcall("glXMakeCurrent");
18197+
18198+ /* Clear the screen */
18199+ glClearColor(0.0, 0.0, 0.0, 0.0);
18200+ checkGLcall("glClearColor");
18201+ glClearIndex(0);
18202+ glClearDepth(1);
18203+ glClearStencil(0);
18204+
18205+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_ACCUM_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
18206+ checkGLcall("glClear");
18207+
18208+ glColor3f(1.0, 1.0, 1.0);
18209+ checkGLcall("glColor3f");
18210+
18211+ glEnable(GL_LIGHTING);
18212+ checkGLcall("glEnable");
18213+
18214+ glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, GL_TRUE);
18215+ checkGLcall("glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, GL_TRUE);");
18216+
18217+ glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT);
18218+ checkGLcall("glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT);");
18219+
18220+ glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL, GL_SEPARATE_SPECULAR_COLOR);
18221+ checkGLcall("glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL, GL_SEPARATE_SPECULAR_COLOR);");
18222+
18223+ /* If this swapchain is currently the active context then make this swapchain active */
18224+ if(IWineD3DSurface_GetContainer((IWineD3DSurface *)This->wineD3DDevice->renderTarget, &IID_IWineD3DSwapChain, (void **)&tmp) == D3D_OK){
18225+ if(tmp != (IUnknown *)This){
18226+ glXMakeCurrent(This->display, currentDrawable, currentContext);
18227+ checkGLcall("glXMakeCurrent");
18228+ }
18229+ IUnknown_Release(tmp);
18230+ }else{
18231+ /* reset the context */
18232+ glXMakeCurrent(This->display, currentDrawable, currentContext);
18233+ checkGLcall("glXMakeCurrent");
18234+ }
18235+ /* delete the old contxt*/
18236+ glXDestroyContext(oldDisplay, oldContext); /* Should this happen on an active context? seems a bad idea */
18237+ LEAVE_GL();
18238+ }
18239+ IWineD3DSwapChain_Release((IWineD3DSwapChain *)swapChainImpl);
18240+
18241+ }
18242+
18243+
18244+ /* TODO: The slow way, save the data to memory, create a new context for the destination window, transfer the data cleanup, it may be a good idea to the move this swapchain over to the using the target winows context so that it runs faster in feature. */
18245+
18246+ glXSwapBuffers(This->display, This->drawable); /* TODO: cycle through the swapchain buffers */
18247+
18248+ TRACE("glXSwapBuffers called, Starting new frame\n");
18249+ /* FPS support */
18250+ if (TRACE_ON(d3d_fps))
18251+ {
18252+ static long prev_time, frames;
18253+
18254+ DWORD time = GetTickCount();
18255+ frames++;
18256+ /* every 1.5 seconds */
18257+ if (time - prev_time > 1500) {
18258+ TRACE_(d3d_fps)("@ approx %.2ffps\n", 1000.0*frames/(time - prev_time));
18259+ prev_time = time;
18260+ frames = 0;
18261+ }
18262+ }
18263+
18264+#if defined(FRAME_DEBUGGING)
18265+{
18266+ if (GetFileAttributesA("C:\\D3DTRACE") != INVALID_FILE_ATTRIBUTES) {
18267+ if (!isOn) {
18268+ isOn = TRUE;
18269+ FIXME("Enabling D3D Trace\n");
18270+ __WINE_SET_DEBUGGING(__WINE_DBCL_TRACE, __wine_dbch_d3d, 1);
18271+#if defined(SHOW_FRAME_MAKEUP)
18272+ FIXME("Singe Frame snapshots Starting\n");
18273+ isDumpingFrames = TRUE;
18274+ glClear(GL_COLOR_BUFFER_BIT);
18275+#endif
18276+
18277+#if defined(SINGLE_FRAME_DEBUGGING)
18278+ } else {
18279+#if defined(SHOW_FRAME_MAKEUP)
18280+ FIXME("Singe Frame snapshots Finishing\n");
18281+ isDumpingFrames = FALSE;
18282+#endif
18283+ FIXME("Singe Frame trace complete\n");
18284+ DeleteFileA("C:\\D3DTRACE");
18285+ __WINE_SET_DEBUGGING(__WINE_DBCL_TRACE, __wine_dbch_d3d, 0);
18286+#endif
18287+ }
18288+ } else {
18289+ if (isOn) {
18290+ isOn = FALSE;
18291+#if defined(SHOW_FRAME_MAKEUP)
18292+ FIXME("Single Frame snapshots Finishing\n");
18293+ isDumpingFrames = FALSE;
18294+#endif
18295+ FIXME("Disabling D3D Trace\n");
18296+ __WINE_SET_DEBUGGING(__WINE_DBCL_TRACE, __wine_dbch_d3d, 0);
18297+ }
18298+ }
18299+}
18300+#endif
18301+
18302+ LEAVE_GL();
18303+ /* Although this is not strictly required, a simple demo showed this does occur
18304+ on (at least non-debug) d3d */
18305+ if (This->presentParms.SwapEffect & D3DSWAPEFFECT_DISCARD) {
18306+
18307+ TRACE("Clearing\n");
18308+
18309+ IWineD3DDevice_Clear((IWineD3DDevice*)This->wineD3DDevice, 0, NULL, D3DCLEAR_STENCIL|D3DCLEAR_ZBUFFER|D3DCLEAR_TARGET, 0x00, 1.0, 0);
18310+
18311+ }
18312+ TRACE("returning\n");
18313+ return D3D_OK;
18314+}
18315+
18316+HRESULT WINAPI IWineD3DSwapChainImpl_GetFrontBufferData(IWineD3DSwapChain *iface, IWineD3DSurface *pDestSurface) {
18317+ IWineD3DSwapChainImpl *This = (IWineD3DSwapChainImpl *)iface;
18318+ IWineD3DSurfaceImpl *surface = (IWineD3DSurfaceImpl *)pDestSurface;
18319+ GLenum format;
18320+ GLenum type;
18321+
18322+ TRACE("(%p) : iface(%p) pDestSurface(%p) \n", This, iface, pDestSurface);
18323+ ENTER_GL();
18324+
18325+ /* check to see if it's the backbuffer or the frontbuffer being requested (to make sureteh data is upto date) */
18326+ format = D3DFmt2GLFmt(This->wineD3DDevice, surface->resource.format);
18327+ type = D3DFmt2GLType(This->wineD3DDevice, surface->resource.format);
18328+ glReadBuffer(GL_FRONT);
18329+ glReadPixels(0,
18330+ 0,
18331+ surface->currentDesc.Width,
18332+ surface->currentDesc.Height,
18333+ format,
18334+ type,
18335+ surface->resource.allocatedMemory);
18336+ LEAVE_GL();
18337+ return D3D_OK;
18338+}
18339+
18340+HRESULT WINAPI IWineD3DSwapChainImpl_GetBackBuffer(IWineD3DSwapChain *iface, UINT iBackBuffer, D3DBACKBUFFER_TYPE Type, IWineD3DSurface **ppBackBuffer) {
18341+
18342+ IWineD3DSwapChainImpl *This = (IWineD3DSwapChainImpl *)iface;
18343+
18344+ *ppBackBuffer = (IWineD3DSurface *) This->backBuffer;
18345+ TRACE("(%p) : BackBuf %d Type %d returning %p\n", This, iBackBuffer, Type, *ppBackBuffer);
18346+
18347+ if (iBackBuffer > This->presentParms.BackBufferCount - 1) {
18348+ FIXME("Only one backBuffer currently supported\n");
18349+ return D3DERR_INVALIDCALL;
18350+ }
18351+
18352+ /* Note inc ref on returned surface */
18353+ IWineD3DSurface_AddRef(*ppBackBuffer);
18354+ return D3D_OK;
18355+
18356+}
18357+
18358+HRESULT WINAPI IWineD3DSwapChainImpl_GetRasterStatus(IWineD3DSwapChain *iface, D3DRASTER_STATUS*pRasterStatus) {
18359+ IWineD3DSwapChainImpl *This = (IWineD3DSwapChainImpl *)iface;
18360+ pRasterStatus->InVBlank = TRUE;
18361+ pRasterStatus->ScanLine = 0;
18362+ FIXME("(%p) : stub\n", This);
18363+ return D3D_OK;
18364+}
18365+
18366+HRESULT WINAPI IWineD3DSwapChainImpl_GetDisplayMode(IWineD3DSwapChain *iface, D3DDISPLAYMODE*pMode) {
18367+ IWineD3DSwapChainImpl *This = (IWineD3DSwapChainImpl *)iface;
18368+ HDC hdc;
18369+ int bpp = 0;
18370+
18371+ pMode->Width = GetSystemMetrics(SM_CXSCREEN);
18372+ pMode->Height = GetSystemMetrics(SM_CYSCREEN);
18373+ pMode->RefreshRate = 85; /*FIXME: How to identify? */
18374+
18375+ hdc = CreateDCA("DISPLAY", NULL, NULL, NULL);
18376+ bpp = GetDeviceCaps(hdc, BITSPIXEL);
18377+ DeleteDC(hdc);
18378+
18379+ switch (bpp) {
18380+ case 8: pMode->Format = D3DFMT_R8G8B8; break;
18381+ case 16: pMode->Format = D3DFMT_R5G6B5; break;
18382+ case 24: /*pMode->Format = D3DFMT_R8G8B8; break; */
18383+ case 32: pMode->Format = D3DFMT_A8R8G8B8; break;
18384+ default:
18385+ FIXME("Unrecognized display mode format\n");
18386+ pMode->Format = D3DFMT_UNKNOWN;
18387+ }
18388+
18389+ TRACE("(%p) : returning w(%d) h(%d) rr(%d) fmt(%u,%s)\n", This, pMode->Width, pMode->Height, pMode->RefreshRate,
18390+ pMode->Format, debug_d3dformat(pMode->Format));
18391+ return D3D_OK;
18392+}
18393+
18394+HRESULT WINAPI IWineD3DSwapChainImpl_GetDevice(IWineD3DSwapChain *iface, IWineD3DDevice**ppDevice) {
18395+ IWineD3DSwapChainImpl *This = (IWineD3DSwapChainImpl *)iface;
18396+
18397+ *ppDevice = (IWineD3DDevice *) This->wineD3DDevice;
18398+
18399+ /* Note Calling this method will increase the internal reference count
18400+ on the IDirect3DDevice9 interface. */
18401+ IWineD3DDevice_AddRef(*ppDevice);
18402+ TRACE("(%p) : returning %p\n", This, *ppDevice);
18403+ return D3D_OK;
18404+}
18405+
18406+HRESULT WINAPI IWineD3DSwapChainImpl_GetPresentParameters(IWineD3DSwapChain *iface, D3DPRESENT_PARAMETERS *pPresentationParameters) {
18407+ IWineD3DSwapChainImpl *This = (IWineD3DSwapChainImpl *)iface;
18408+ FIXME("(%p) : copy\n", This);
18409+ memcpy(pPresentationParameters, &This->presentParms, sizeof(D3DPRESENT_PARAMETERS));
18410+ return D3D_OK;
18411+}
18412+
18413+HRESULT WINAPI IWineD3DSwapChainImpl_SetGammaRamp(IWineD3DSwapChain *iface, DWORD Flags, CONST D3DGAMMARAMP *pRamp){
18414+
18415+ IWineD3DSwapChainImpl *This = (IWineD3DSwapChainImpl *)iface;
18416+ HDC hDC;
18417+ TRACE("(%p) : pRamp@%p flags(%ld) \n", This, pRamp, Flags);
18418+ hDC = GetDC(This->win_handle);
18419+ SetDeviceGammaRamp(hDC, (LPVOID)pRamp);
18420+ ReleaseDC(This->win_handle, hDC);
18421+ return D3D_OK;
18422+
18423+}
18424+
18425+HRESULT WINAPI IWineD3DSwapChainImpl_GetGammaRamp(IWineD3DSwapChain *iface, D3DGAMMARAMP *pRamp){
18426+
18427+ IWineD3DSwapChainImpl *This = (IWineD3DSwapChainImpl *)iface;
18428+ HDC hDC;
18429+ TRACE("(%p) : pRamp@%p\n", This, pRamp);
18430+ hDC = GetDC(This->win_handle);
18431+ GetDeviceGammaRamp(hDC, pRamp);
18432+ ReleaseDC(This->win_handle, hDC);
18433+ return D3D_OK;
18434+
18435+}
18436+
18437+
18438+IWineD3DSwapChainVtbl IWineD3DSwapChain_Vtbl =
18439+{
18440+ IWineD3DSwapChainImpl_QueryInterface,
18441+ IWineD3DSwapChainImpl_AddRef,
18442+ IWineD3DSwapChainImpl_Release,
18443+ IWineD3DSwapChainImpl_GetParent,
18444+ IWineD3DSwapChainImpl_GetDevice,
18445+ IWineD3DSwapChainImpl_Present,
18446+ IWineD3DSwapChainImpl_GetFrontBufferData,
18447+ IWineD3DSwapChainImpl_GetBackBuffer,
18448+ IWineD3DSwapChainImpl_GetRasterStatus,
18449+ IWineD3DSwapChainImpl_GetDisplayMode,
18450+ IWineD3DSwapChainImpl_GetPresentParameters,
18451+ IWineD3DSwapChainImpl_SetGammaRamp,
18452+ IWineD3DSwapChainImpl_GetGammaRamp
18453+};
18454diff -urN wine.20050419/dlls/wined3d/texture.c wine.20050419.dx9/dlls/wined3d/texture.c
18455--- wine.20050419/dlls/wined3d/texture.c 2005-03-29 12:01:00.000000000 -0700
18456+++ wine.20050419.dx9/dlls/wined3d/texture.c 2005-04-20 04:42:58.000000000 -0600
18457@@ -23,7 +23,9 @@
18458 #include "config.h"
18459 #include "wined3d_private.h"
18460
18461-WINE_DEFAULT_DEBUG_CHANNEL(d3d);
18462+WINE_DEFAULT_DEBUG_CHANNEL(d3d_texture);
18463+WINE_DECLARE_DEBUG_CHANNEL(d3d_ref);
18464+/*TODO: replace impl usage with iface usage */
18465 #define GLINFO_LOCATION ((IWineD3DImpl *)(((IWineD3DDeviceImpl *)This->resource.wineD3DDevice)->wineD3D))->gl_info
18466
18467 /* *******************************************
18468@@ -46,9 +48,9 @@
18469
18470 ULONG WINAPI IWineD3DTextureImpl_AddRef(IWineD3DTexture *iface) {
18471 IWineD3DTextureImpl *This = (IWineD3DTextureImpl *)iface;
18472- TRACE("(%p) : AddRef increasing from %ld\n", This, This->resource.ref);
18473- IUnknown_AddRef(This->resource.parent);
18474- return InterlockedIncrement(&This->resource.ref);
18475+ ULONG ref = InterlockedIncrement(&This->resource.ref);
18476+ TRACE_(d3d_ref)( "(%p) : AddRef increasing from %ld to %ld\n", This, ref - 1, ref);
18477+ return ref;
18478 }
18479
18480 ULONG WINAPI IWineD3DTextureImpl_Release(IWineD3DTexture *iface) {
18481@@ -57,6 +59,7 @@
18482 TRACE("(%p) : Releasing from %ld\n", This, This->resource.ref);
18483 ref = InterlockedDecrement(&This->resource.ref);
18484 if (ref == 0) {
18485+ int texturecount = globalStoreReleaseTexture((IWineD3DBaseTexture *)This);
18486 int i;
18487 for (i = 0; i < This->baseTexture.levels; i++) {
18488 if (This->surfaces[i] != NULL) {
18489@@ -108,7 +111,7 @@
18490 unsigned int i;
18491 IWineD3DTextureImpl *This = (IWineD3DTextureImpl *)iface;
18492
18493- TRACE("(%p) : About to load texture\n", This);
18494+ TRACE("(%p) : About to load texture %p\n", This, This->surfaces);
18495 IWineD3DTexture_BindTexture(iface);
18496
18497 ENTER_GL();
18498@@ -163,7 +166,7 @@
18499
18500 /* Internal function, No d3d mapping */
18501 BOOL WINAPI IWineD3DTextureImpl_SetDirty(IWineD3DTexture *iface, BOOL dirty) {
18502- return IWineD3DBaseTextureImpl_SetDirty((IWineD3DBaseTexture *)iface, TRUE);
18503+ return IWineD3DBaseTextureImpl_SetDirty((IWineD3DBaseTexture *)iface,dirty);
18504 }
18505
18506 BOOL WINAPI IWineD3DTextureImpl_GetDirty(IWineD3DTexture *iface) {
18507@@ -198,7 +201,7 @@
18508
18509 if (Level < This->baseTexture.levels) {
18510 TRACE("(%p) Level (%d)\n", This, Level);
18511- return IWineD3DSurface_GetDesc((IWineD3DSurface *) This->surfaces[Level], pDesc);
18512+ return IWineD3DSurface_GetDesc(This->surfaces[Level], pDesc);
18513 }
18514 FIXME("(%p) level(%d) overflow Levels(%d)\n", This, Level, This->baseTexture.levels);
18515 return D3DERR_INVALIDCALL;
18516@@ -206,11 +209,17 @@
18517
18518 HRESULT WINAPI IWineD3DTextureImpl_GetSurfaceLevel(IWineD3DTexture *iface, UINT Level, IWineD3DSurface** ppSurfaceLevel) {
18519 IWineD3DTextureImpl *This = (IWineD3DTextureImpl *)iface;
18520- *ppSurfaceLevel = (IWineD3DSurface *) This->surfaces[Level];
18521+
18522+ if (Level < This->baseTexture.levels) {
18523+ *ppSurfaceLevel = This->surfaces[Level];
18524 IWineD3DSurface_AddRef((IWineD3DSurface *) This->surfaces[Level]);
18525 TRACE("(%p) : returning %p for level %d\n", This, *ppSurfaceLevel, Level);
18526 return D3D_OK;
18527 }
18528+ FIXME("(%p) level(%d) overflow Levels(%d)\n", This, Level, This->baseTexture.levels);
18529+ *ppSurfaceLevel = NULL; /* Just to be on the safe side.. */
18530+ return D3DERR_INVALIDCALL;
18531+}
18532
18533 HRESULT WINAPI IWineD3DTextureImpl_LockRect(IWineD3DTexture *iface, UINT Level, D3DLOCKED_RECT *pLockedRect,
18534 CONST RECT *pRect, DWORD Flags) {
18535@@ -219,7 +228,7 @@
18536
18537 if (Level < This->baseTexture.levels) {
18538
18539- hr = IWineD3DSurface_LockRect((IWineD3DSurface *) This->surfaces[Level], pLockedRect, pRect, Flags);
18540+ hr = IWineD3DSurface_LockRect(This->surfaces[Level], pLockedRect, pRect, Flags);
18541 TRACE("(%p) Level (%d) success(%lu)\n", This, Level, hr);
18542 } else {
18543 FIXME("(%p) level(%d) overflow Levels(%d)\n", This, Level, This->baseTexture.levels);
18544@@ -233,7 +242,7 @@
18545 IWineD3DTextureImpl *This = (IWineD3DTextureImpl *)iface;
18546
18547 if (Level < This->baseTexture.levels) {
18548- hr = IWineD3DSurface_UnlockRect((IWineD3DSurface *) This->surfaces[Level]);
18549+ hr = IWineD3DSurface_UnlockRect(This->surfaces[Level]);
18550 TRACE("(%p) Level (%d) success(%lu)\n", This, Level, hr);
18551 } else {
18552 FIXME("(%p) level(%d) overflow Levels(%d)\n", This, Level, This->baseTexture.levels);
18553@@ -246,7 +255,7 @@
18554 IWineD3DTextureImpl *This = (IWineD3DTextureImpl *)iface;
18555 This->baseTexture.dirty = TRUE;
18556 TRACE("(%p) : dirtyfication of surface Level (0)\n", This);
18557- return IWineD3DSurface_AddDirtyRect((IWineD3DSurface *)This->surfaces[0], pDirtyRect);
18558+ return IWineD3DSurface_AddDirtyRect(This->surfaces[0], pDirtyRect);
18559 }
18560
18561 IWineD3DTextureVtbl IWineD3DTexture_Vtbl =
18562diff -urN wine.20050419/dlls/wined3d/utils.c wine.20050419.dx9/dlls/wined3d/utils.c
18563--- wine.20050419/dlls/wined3d/utils.c 2005-03-03 06:57:15.000000000 -0700
18564+++ wine.20050419.dx9/dlls/wined3d/utils.c 2005-04-20 01:52:56.000000000 -0600
18565@@ -233,8 +233,8 @@
18566 D3DSTATE_TO_STR(WINED3DRS_COLORWRITEENABLE );
18567 D3DSTATE_TO_STR(WINED3DRS_TWEENFACTOR );
18568 D3DSTATE_TO_STR(WINED3DRS_BLENDOP );
18569- D3DSTATE_TO_STR(WINED3DRS_POSITIONORDER );
18570- D3DSTATE_TO_STR(WINED3DRS_NORMALORDER );
18571+ D3DSTATE_TO_STR(WINED3DRS_POSITIONDEGREE );
18572+ D3DSTATE_TO_STR(WINED3DRS_NORMALDEGREE );
18573 #undef D3DSTATE_TO_STR
18574 default:
18575 FIXME("Unrecognized %lu render state!\n", state);
18576@@ -256,6 +256,7 @@
18577 D3DSTATE_TO_STR(D3DTSS_BUMPENVMAT10 );
18578 D3DSTATE_TO_STR(D3DTSS_BUMPENVMAT11 );
18579 D3DSTATE_TO_STR(D3DTSS_TEXCOORDINDEX );
18580+ #if 0 /*FIXME: d3d8*/
18581 D3DSTATE_TO_STR(D3DTSS_ADDRESSU );
18582 D3DSTATE_TO_STR(D3DTSS_ADDRESSV );
18583 D3DSTATE_TO_STR(D3DTSS_BORDERCOLOR );
18584@@ -265,6 +266,7 @@
18585 D3DSTATE_TO_STR(D3DTSS_MIPMAPLODBIAS );
18586 D3DSTATE_TO_STR(D3DTSS_MAXMIPLEVEL );
18587 D3DSTATE_TO_STR(D3DTSS_MAXANISOTROPY );
18588+ #endif
18589 D3DSTATE_TO_STR(D3DTSS_BUMPENVLSCALE );
18590 D3DSTATE_TO_STR(D3DTSS_BUMPENVLOFFSET );
18591 D3DSTATE_TO_STR(D3DTSS_TEXTURETRANSFORMFLAGS );
18592@@ -1564,8 +1566,8 @@
18593 if (retVal == 0) {
18594 switch (fmt) {
18595 /* Paletted */
18596- case WINED3DFMT_P8: retVal = GL_COLOR_INDEX8_EXT; break;
18597- case WINED3DFMT_A8P8: retVal = GL_COLOR_INDEX8_EXT; break;
18598+ case WINED3DFMT_P8: retVal = GL_COLOR_INDEX; break;
18599+ case WINED3DFMT_A8P8: retVal = GL_COLOR_INDEX; break;
18600 /* Luminance */
18601 case WINED3DFMT_L8: retVal = GL_LUMINANCE8; break;
18602 case WINED3DFMT_A8L8: retVal = GL_LUMINANCE8_ALPHA8; break;
18603@@ -1580,11 +1582,11 @@
18604 case WINED3DFMT_R5G6B5: retVal = GL_RGB5; break; /* fixme: internal format 6 for g? */
18605 case WINED3DFMT_R8G8B8: retVal = GL_RGB8; break;
18606 case WINED3DFMT_A1R5G5B5: retVal = GL_RGB5_A1; break;
18607- case WINED3DFMT_X1R5G5B5: retVal = GL_RGB5_A1; break;
18608+ case WINED3DFMT_X1R5G5B5: retVal = GL_RGB5; break;
18609 case WINED3DFMT_A4R4G4B4: retVal = GL_RGBA4; break;
18610 case WINED3DFMT_X4R4G4B4: retVal = GL_RGBA4; break;
18611 case WINED3DFMT_A8R8G8B8: retVal = GL_RGBA8; break;
18612- case WINED3DFMT_X8R8G8B8: retVal = GL_RGBA8; break;
18613+ case WINED3DFMT_X8R8G8B8: retVal = GL_RGB; break;
18614 /* to see */
18615 case WINED3DFMT_A8: retVal = GL_ALPHA8; break;
18616 default:
18617@@ -1592,6 +1594,7 @@
18618 retVal = GL_RGB8;
18619 }
18620 }
18621+
18622 TRACE("fmt2glintFmt for fmt(%u,%s) = %x\n", fmt, debug_d3dformat(fmt), retVal);
18623 return retVal;
18624 }
18625@@ -1624,7 +1627,7 @@
18626 case WINED3DFMT_V16U16: retVal = GL_COLOR_INDEX; break;
18627 case WINED3DFMT_L6V5U5: retVal = GL_COLOR_INDEX; break;
18628 case WINED3DFMT_X8L8V8U8: retVal = GL_COLOR_INDEX; break;
18629- /* color buffer */
18630+ /* Color buffer */
18631 case WINED3DFMT_R3G3B2: retVal = GL_BGR; break;
18632 case WINED3DFMT_R5G6B5: retVal = GL_RGB; break;
18633 case WINED3DFMT_R8G8B8: retVal = GL_RGB; break;
18634@@ -1666,8 +1669,8 @@
18635 case WINED3DFMT_P8: retVal = GL_UNSIGNED_BYTE; break;
18636 case WINED3DFMT_A8P8: retVal = GL_UNSIGNED_BYTE; break;
18637 /* Luminance */
18638- case WINED3DFMT_L8: retVal = GL_UNSIGNED_BYTE; break;
18639- case WINED3DFMT_A8L8: retVal = GL_UNSIGNED_BYTE; break;
18640+ case WINED3DFMT_L8: retVal = GL_UNSIGNED_BYTE; break;/*Does openGL support luminance and UNSIGNED_BYTE? */
18641+ case WINED3DFMT_A8L8: retVal = GL_UNSIGNED_BYTE; break;/* I thought it had to be a float */
18642 case WINED3DFMT_A4L4: retVal = GL_UNSIGNED_BYTE; break;
18643 /* Bump */
18644 case WINED3DFMT_V8U8: retVal = GL_UNSIGNED_BYTE; break;
18645@@ -1687,6 +1690,7 @@
18646 /* to see */
18647 case WINED3DFMT_A8: retVal = GL_ALPHA; break;
18648 default:
18649+
18650 FIXME("Unhandled fmt(%u,%s)\n", fmt, debug_d3dformat(fmt));
18651 retVal = GL_UNSIGNED_BYTE;
18652 }
18653@@ -1700,7 +1704,7 @@
18654 SHORT retVal;
18655
18656 switch (fmt) {
18657- /* color buffer */
18658+ /* Color buffer */
18659 case WINED3DFMT_R3G3B2: retVal = 1; break;
18660 case WINED3DFMT_R5G6B5: retVal = 2; break;
18661 case WINED3DFMT_R8G8B8: retVal = 3; break;
18662@@ -1713,7 +1717,7 @@
18663 /* Paletted */
18664 case WINED3DFMT_P8: retVal = 1; break;
18665 case WINED3DFMT_A8P8: retVal = 2; break;
18666- /* depth/stencil buffer */
18667+ /* Depth/stencil buffer */
18668 case WINED3DFMT_D16_LOCKABLE: retVal = 2; break;
18669 case WINED3DFMT_D16: retVal = 2; break;
18670 case WINED3DFMT_D32: retVal = 4; break;
18671@@ -1750,4 +1754,140 @@
18672 TRACE("bytes/Pxl for fmt(%u,%s) = %d\n", fmt, debug_d3dformat(fmt), retVal);
18673 return retVal;
18674 }
18675+/*Convertes a D3D format into a OPenGL configuration format*/
18676+int D3DFmtMakeGlCfg(D3DFORMAT BackBufferFormat, D3DFORMAT StencilBufferFormat, int *attribs, int* nAttribs, BOOL alternate){
18677+ #define PUSH1(att) attribs[(*nAttribs)++] = (att);
18678+ #define PUSH2(att,value) attribs[(*nAttribs)++] = (att); attribs[(*nAttribs)++] = (value);
18679+ /*We need to do some Card specific stuff in here at some point,
18680+ D3D now support floating point format buffers, and their are a number of different OpelGl ways on managing thease e.g.
18681+ GLX_ATI_pixel_format_float
18682+ */
18683+ switch (BackBufferFormat) {
18684+ /* color buffer */
18685+ case WINED3DFMT_P8:
18686+ PUSH2(GLX_RENDER_TYPE, GLX_COLOR_INDEX_BIT);
18687+ PUSH2(GLX_BUFFER_SIZE, 8);
18688+ PUSH2(GLX_DOUBLEBUFFER, TRUE);
18689+ break;
18690+
18691+ case WINED3DFMT_R3G3B2:
18692+ PUSH2(GLX_RENDER_TYPE, GLX_RGBA_BIT);
18693+ PUSH2(GLX_RED_SIZE, 3);
18694+ PUSH2(GLX_GREEN_SIZE, 3);
18695+ PUSH2(GLX_BLUE_SIZE, 2);
18696+ break;
18697+
18698+ case WINED3DFMT_A1R5G5B5:
18699+ PUSH2(GLX_ALPHA_SIZE, 1);
18700+ case WINED3DFMT_X1R5G5B5:
18701+ PUSH2(GLX_RED_SIZE, 5);
18702+ PUSH2(GLX_GREEN_SIZE, 5);
18703+ PUSH2(GLX_BLUE_SIZE, 5);
18704+ break;
18705+
18706+ case WINED3DFMT_R5G6B5:
18707+ PUSH2(GLX_RED_SIZE, 5);
18708+ PUSH2(GLX_GREEN_SIZE, 6);
18709+ PUSH2(GLX_BLUE_SIZE, 5);
18710+ break;
18711+
18712+ case WINED3DFMT_A4R4G4B4:
18713+ PUSH2(GLX_ALPHA_SIZE, 4);
18714+ case WINED3DFMT_X4R4G4B4:
18715+ PUSH2(GLX_RED_SIZE, 4);
18716+ PUSH2(GLX_GREEN_SIZE, 4);
18717+ PUSH2(GLX_BLUE_SIZE, 4);
18718+ break;
18719+
18720+ case WINED3DFMT_A8R8G8B8:
18721+ PUSH2(GLX_ALPHA_SIZE, 8);
18722+ case WINED3DFMT_R8G8B8:
18723+ case WINED3DFMT_X8R8G8B8:
18724+ PUSH2(GLX_RED_SIZE, 8);
18725+ PUSH2(GLX_GREEN_SIZE, 8);
18726+ PUSH2(GLX_BLUE_SIZE, 8);
18727+ break;
18728+
18729+ default:
18730+ break;
18731+ }
18732+ if(!alternate){
18733+ switch (StencilBufferFormat) {
18734+ case WINED3DFMT_D16_LOCKABLE:
18735+ case WINED3DFMT_D16:
18736+ PUSH2(GLX_DEPTH_SIZE, 16);
18737+ break;
18738+
18739+ case WINED3DFMT_D15S1:
18740+ PUSH2(GLX_DEPTH_SIZE, 15);
18741+ PUSH2(GLX_STENCIL_SIZE, 1);
18742+ /*Does openGl support a 1bit stencil?, I've seen it used elsewhere
18743+ e.g. http://www.ks.uiuc.edu/Research/vmd/doxygen/OpenGLDisplayDevice_8C-source.html*/
18744+ break;
18745+
18746+ case WINED3DFMT_D24X8:
18747+ PUSH2(GLX_DEPTH_SIZE, 24);
18748+ break;
18749+
18750+ case WINED3DFMT_D24X4S4:
18751+ PUSH2(GLX_DEPTH_SIZE, 24);
18752+ PUSH2(GLX_STENCIL_SIZE, 4);
18753+ break;
18754+
18755+ case WINED3DFMT_D24S8:
18756+ PUSH2(GLX_DEPTH_SIZE, 24);
18757+ PUSH2(GLX_STENCIL_SIZE, 8);
18758+ break;
18759+
18760+ case WINED3DFMT_D32:
18761+ PUSH2(GLX_DEPTH_SIZE, 32);
18762+ break;
18763+
18764+ default:
18765+ break;
18766+ }
18767+
18768+ }else{ /* it the device doesn't support the 'exact' format, try something close */
18769+ switch (StencilBufferFormat) {
18770+ case WINED3DFMT_D16_LOCKABLE:
18771+ case WINED3DFMT_D16:
18772+ PUSH2(GLX_DEPTH_SIZE, 1);
18773+ break;
18774+
18775+ case WINED3DFMT_D15S1:
18776+ PUSH2(GLX_DEPTH_SIZE, 1);
18777+ PUSH2(GLX_STENCIL_SIZE, 1);
18778+ /*Does openGl support a 1bit stencil?, I've seen it used elsewhere
18779+ e.g. http://www.ks.uiuc.edu/Research/vmd/doxygen/OpenGLDisplayDevice_8C-source.html*/
18780+ break;
18781+
18782+ case WINED3DFMT_D24X8:
18783+ PUSH2(GLX_DEPTH_SIZE, 1);
18784+ break;
18785+
18786+ case WINED3DFMT_D24X4S4:
18787+ PUSH2(GLX_DEPTH_SIZE, 1);
18788+ PUSH2(GLX_STENCIL_SIZE, 1);
18789+ break;
18790+
18791+ case WINED3DFMT_D24S8:
18792+ PUSH2(GLX_DEPTH_SIZE, 1);
18793+ PUSH2(GLX_STENCIL_SIZE, 1);
18794+ break;
18795+
18796+ case WINED3DFMT_D32:
18797+ PUSH2(GLX_DEPTH_SIZE, 1);
18798+ break;
18799+
18800+ default:
18801+ break;
18802+ }
18803+
18804+
18805+ }
18806+
18807+ return *nAttribs;
18808+}
18809+
18810 #undef GLINFO_LOCATION
18811+
18812diff -urN wine.20050419/dlls/wined3d/vertexbuffer.c wine.20050419.dx9/dlls/wined3d/vertexbuffer.c
18813--- wine.20050419/dlls/wined3d/vertexbuffer.c 2005-03-29 12:01:00.000000000 -0700
18814+++ wine.20050419.dx9/dlls/wined3d/vertexbuffer.c 2005-04-20 04:05:16.000000000 -0600
18815@@ -4,6 +4,7 @@
18816 * Copyright 2002-2004 Jason Edmeades
18817 * Copyright 2003-2004 Raphael Junqueira
18818 * Copyright 2004 Christian Costa
18819+ * Copyright 2005 Oliver Stieber
18820 *
18821 * This library is free software; you can redistribute it and/or
18822 * modify it under the terms of the GNU Lesser General Public
18823@@ -24,6 +25,7 @@
18824 #include "wined3d_private.h"
18825
18826 WINE_DEFAULT_DEBUG_CHANNEL(d3d);
18827+WINE_DECLARE_DEBUG_CHANNEL(d3d_ref);
18828 #define GLINFO_LOCATION ((IWineD3DImpl *)(((IWineD3DDeviceImpl *)This->resource.wineD3DDevice)->wineD3D))->gl_info
18829
18830 /* *******************************************
18831@@ -103,18 +105,44 @@
18832 /* ******************************************************
18833 IWineD3DVertexBuffer IWineD3DVertexBuffer parts follow
18834 ****************************************************** */
18835+/* We should be using ARB_Vertex_Buffer_Objects for vertex buffers
18836+see..
18837+http://steinsoft.net/index.php?site=Programming/Code%20Snippets/OpenGL/no11
18838+
18839+http://oss.sgi.com/projects/ogl-sample/registry/ARB/vertex_buffer_object.txt
18840+
18841+http://oss.sgi.com/projects/ogl-sample/registry/EXT/compiled_vertex_array.txt
18842+(GL_EXT_compiled_vertex_array is very simila)
18843+
18844+
18845+http://jdobry.webpark.cz/opengl/opengl_maximum_performance.html
18846+*/
18847 HRESULT WINAPI IWineD3DVertexBufferImpl_Lock(IWineD3DVertexBuffer *iface, UINT OffsetToLock, UINT SizeToLock, BYTE** ppbData, DWORD Flags) {
18848 IWineD3DVertexBufferImpl *This = (IWineD3DVertexBufferImpl *)iface;
18849- TRACE("(%p) : returning memory of %p (base:%p,offset:%u)\n", This, This->resource.allocatedMemory + OffsetToLock, This->resource.allocatedMemory, OffsetToLock);
18850+ TRACE("(%p) : returning memory of %p (base:%p,offset:%u, SizeToLock%u flags%ld)\n",
18851+ This, This->resource.allocatedMemory + OffsetToLock, This->resource.allocatedMemory, OffsetToLock, SizeToLock, Flags);
18852 /* TODO: check Flags compatibility with This->currentDesc.Usage (see MSDN) */
18853+
18854+ #if 0 /* TODO: EXT_compiled_vertex_array */
18855+ void UnlockArraysEXT (void)
18856+ #endif
18857 *ppbData = This->resource.allocatedMemory + OffsetToLock;
18858+
18859 return D3D_OK;
18860 }
18861 HRESULT WINAPI IWineD3DVertexBufferImpl_Unlock(IWineD3DVertexBuffer *iface) {
18862 IWineD3DVertexBufferImpl *This = (IWineD3DVertexBufferImpl *)iface;
18863+
18864+ #if 0 /* TODO: EXT_compiled_vertex_array
18865+ It looks like opengl lock may be differnt from D3D lock, inthat a lock prevents access instead of granting it
18866+ */
18867+ void LockArraysEXT (begining, all)
18868+ #endif
18869 TRACE("(%p) : stub\n", This);
18870 return D3D_OK;
18871 }
18872+
18873+
18874 HRESULT WINAPI IWineD3DVertexBufferImpl_GetDesc(IWineD3DVertexBuffer *iface, D3DVERTEXBUFFER_DESC *pDesc) {
18875 IWineD3DVertexBufferImpl *This = (IWineD3DVertexBufferImpl *)iface;
18876
18877diff -urN wine.20050419/dlls/wined3d/vertexdeclaration.c wine.20050419.dx9/dlls/wined3d/vertexdeclaration.c
18878--- wine.20050419/dlls/wined3d/vertexdeclaration.c 2005-03-02 06:44:58.000000000 -0700
18879+++ wine.20050419.dx9/dlls/wined3d/vertexdeclaration.c 2005-04-20 01:52:56.000000000 -0600
18880@@ -769,7 +769,7 @@
18881 TRACE("(%p) : Releasing from %ld\n", This, This->ref);
18882 ref = InterlockedDecrement(&This->ref);
18883 if (ref == 0) {
18884- HeapFree(GetProcessHeap(), 0, This->pDeclaration8);
18885+ /*HeapFree(GetProcessHeap(), 0, This->pDeclaration8);*/
18886 HeapFree(GetProcessHeap(), 0, This->pDeclaration9);
18887 HeapFree(GetProcessHeap(), 0, This);
18888 }
18889@@ -780,6 +780,15 @@
18890 IWineD3DVertexDeclaration parts follow
18891 ******************************************* */
18892
18893+HRESULT WINAPI IWineD3DVertexDeclarationImpl_GetParent(IWineD3DVertexDeclaration *iface, IUnknown** parent){
18894+ IWineD3DVertexDeclarationImpl *This = (IWineD3DVertexDeclarationImpl *)iface;
18895+
18896+ *parent= (IUnknown*) parent;
18897+ IUnknown_AddRef(*parent);
18898+ TRACE("(%p) : returning %p\n", This, *parent);
18899+ return D3D_OK;
18900+}
18901+
18902 HRESULT WINAPI IWineD3DVertexDeclarationImpl_GetDevice(IWineD3DVertexDeclaration *iface, IWineD3DDevice** ppDevice) {
18903 IWineD3DVertexDeclarationImpl *This = (IWineD3DVertexDeclarationImpl *)iface;
18904 TRACE("(%p) : returning %p\n", This, This->wineD3DDevice);
18905@@ -832,6 +841,7 @@
18906 IWineD3DVertexDeclarationImpl_QueryInterface,
18907 IWineD3DVertexDeclarationImpl_AddRef,
18908 IWineD3DVertexDeclarationImpl_Release,
18909+ IWineD3DVertexDeclarationImpl_GetParent,
18910 IWineD3DVertexDeclarationImpl_GetDevice,
18911 IWineD3DVertexDeclarationImpl_GetDeclaration,
18912 };
18913diff -urN wine.20050419/dlls/wined3d/vertexshader.c wine.20050419.dx9/dlls/wined3d/vertexshader.c
18914--- wine.20050419/dlls/wined3d/vertexshader.c 2005-03-02 05:16:11.000000000 -0700
18915+++ wine.20050419.dx9/dlls/wined3d/vertexshader.c 2005-04-20 01:52:56.000000000 -0600
18916@@ -847,6 +847,72 @@
18917 return D3D_OK;
18918 }
18919
18920+inline static VOID IWineD3DVertexShaderImpl_ParseProgram(IWineD3DVertexShaderImpl* vshader, CONST DWORD* pFunction, int useHW) {
18921+ const DWORD* pToken = pFunction;
18922+ const SHADER_OPCODE* curOpcode = NULL;
18923+ DWORD len = 0;
18924+ DWORD i;
18925+
18926+ if (NULL != pToken) {
18927+ while (D3DVS_END() != *pToken) {
18928+ if (vshader_is_version_token(*pToken)) { /** version */
18929+ TRACE("vs.%lu.%lu\n", (*pToken >> 8) & 0x0F, (*pToken & 0x0F));
18930+ ++pToken;
18931+ ++len;
18932+ continue;
18933+ }
18934+ if (vshader_is_comment_token(*pToken)) { /** comment */
18935+ DWORD comment_len = (*pToken & D3DSI_COMMENTSIZE_MASK) >> D3DSI_COMMENTSIZE_SHIFT;
18936+ ++pToken;
18937+ /*TRACE("comment[%ld] ;%s\n", comment_len, (char*)pToken);*/
18938+ pToken += comment_len;
18939+ len += comment_len + 1;
18940+ continue;
18941+ }
18942+ curOpcode = vshader_program_get_opcode(*pToken);
18943+ ++pToken;
18944+ ++len;
18945+ if (NULL == curOpcode) {
18946+ /* unkown current opcode ... */
18947+ while (*pToken & 0x80000000) {
18948+ TRACE("unrecognized opcode: %08lx\n", *pToken);
18949+ ++pToken;
18950+ ++len;
18951+ }
18952+ } else {
18953+ TRACE("%s ", curOpcode->name);
18954+ if (curOpcode->num_params > 0) {
18955+ vshader_program_dump_param(*pToken, 0);
18956+ ++pToken;
18957+ ++len;
18958+ for (i = 1; i < curOpcode->num_params; ++i) {
18959+ TRACE(", ");
18960+ vshader_program_dump_param(*pToken, 1);
18961+ ++pToken;
18962+ ++len;
18963+ }
18964+ }
18965+ TRACE("\n");
18966+ }
18967+ }
18968+ vshader->functionLength = (len + 1) * sizeof(DWORD);
18969+ } else {
18970+ vshader->functionLength = 1; /* no Function defined use fixed function vertex processing */
18971+ }
18972+
18973+ /* Generate HW shader in needed */
18974+ if (useHW && NULL != pFunction) {
18975+ IWineD3DVertexShaderImpl_GenerateProgramArbHW(vshader, pFunction);
18976+ }
18977+
18978+ /* copy the function ... because it will certainly be released by application */
18979+ if (NULL != pFunction) {
18980+ vshader->function = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, vshader->functionLength);
18981+ memcpy(vshader->function, pFunction, vshader->functionLength);
18982+ } else {
18983+ vshader->function = NULL;
18984+ }
18985+}
18986 #endif
18987
18988 /* *******************************************
18989@@ -855,7 +921,13 @@
18990 HRESULT WINAPI IWineD3DVertexShaderImpl_QueryInterface(IWineD3DVertexShader *iface, REFIID riid, LPVOID *ppobj)
18991 {
18992 IWineD3DVertexShaderImpl *This = (IWineD3DVertexShaderImpl *)iface;
18993- FIXME("(%p) :stub\n",This);
18994+ TRACE("(%p)->(%s,%p)\n",This,debugstr_guid(riid),ppobj);
18995+ if (IsEqualGUID(riid, &IID_IUnknown)
18996+ || IsEqualGUID(riid, &IID_IWineD3DVertexShader)) {
18997+ IUnknown_AddRef(iface);
18998+ *ppobj = This;
18999+ return D3D_OK;
19000+ }
19001 return E_NOINTERFACE;
19002 }
19003
19004diff -urN wine.20050419/dlls/wined3d/volumetexture.c wine.20050419.dx9/dlls/wined3d/volumetexture.c
19005--- wine.20050419/dlls/wined3d/volumetexture.c 2005-03-29 12:01:00.000000000 -0700
19006+++ wine.20050419.dx9/dlls/wined3d/volumetexture.c 2005-04-20 01:52:56.000000000 -0600
19007@@ -214,12 +214,14 @@
19008 HRESULT WINAPI IWineD3DVolumeTextureImpl_LockBox(IWineD3DVolumeTexture *iface, UINT Level, D3DLOCKED_BOX* pLockedVolume, CONST D3DBOX* pBox, DWORD Flags) {
19009 HRESULT hr;
19010 IWineD3DVolumeTextureImpl *This = (IWineD3DVolumeTextureImpl *)iface;
19011-
19012+ FIXME("hello\n");
19013 if (Level < This->baseTexture.levels) {
19014+ FIXME("hello volume lockbox\n");
19015 hr = IWineD3DVolume_LockBox((IWineD3DVolume *)This->volumes[Level], pLockedVolume, pBox, Flags);
19016 TRACE("(%p) Level (%d) success(%lu)\n", This, Level, hr);
19017
19018 } else {
19019+ FIXME("hello not doing volume lockbox\n");
19020 FIXME("(%p) level(%d) overflow Levels(%d)\n", This, Level, This->baseTexture.levels);
19021 return D3DERR_INVALIDCALL;
19022 }
19023diff -urN wine.20050419/dlls/wined3d/wined3d_main.c wine.20050419.dx9/dlls/wined3d/wined3d_main.c
19024--- wine.20050419/dlls/wined3d/wined3d_main.c 2005-03-02 06:44:58.000000000 -0700
19025+++ wine.20050419.dx9/dlls/wined3d/wined3d_main.c 2005-04-20 01:52:56.000000000 -0600
19026@@ -33,6 +33,177 @@
19027 int vs_mode = VS_HW; /* Hardware by default */
19028 int ps_mode = PS_NONE; /* Disabled by default */
19029
19030+WineD3DGlobalStatistics *wineD3DGlobalStatistics = NULL;
19031+
19032+
19033+CRITICAL_SECTION textureStoreCriticalSection;
19034+
19035+int globalStoreTexture(IWineD3DBaseTexture *texture){
19036+ TextureChain* textureChain;
19037+ int result = -1;
19038+ if(wineD3DGlobalStatistics== NULL){
19039+ WARN("Attempting to add a texture to the global store, but there is no global store\n");
19040+ return result;
19041+ }
19042+ EnterCriticalSection(&textureStoreCriticalSection);
19043+ /* add a new texture to the frot of the linked list */
19044+ textureChain = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(TextureChain));
19045+ textureChain->texture = texture;
19046+
19047+ /* Get the old head */
19048+ textureChain->next = wineD3DGlobalStatistics->textures;
19049+
19050+ wineD3DGlobalStatistics->textures = textureChain;
19051+ result = ++wineD3DGlobalStatistics->textureCount;
19052+ TRACE("Added texture (%d) %p with element %p pointing to %p\n", result, texture, textureChain, textureChain->next);
19053+ LeaveCriticalSection(&textureStoreCriticalSection);
19054+ return result;
19055+}
19056+
19057+long globalChangeGlRam(long glram){
19058+ /* FIXME: replace this function with object tracking */
19059+ int result;
19060+
19061+ EnterCriticalSection(&textureStoreCriticalSection); /* this is overkill really, but I suppose it should be thread safe */
19062+ wineD3DGlobalStatistics->glsurfaceram += glram;
19063+ wineD3DGlobalStatistics->totalsurfaceram += glram;
19064+ TRACE("Adjusted gl ram by %ld to %d\n", glram, wineD3DGlobalStatistics->glsurfaceram);
19065+ result = wineD3DGlobalStatistics->glsurfaceram;
19066+ LeaveCriticalSection(&textureStoreCriticalSection);
19067+ return result;
19068+
19069+}
19070+
19071+long globalChangeSysRam(long sysram){
19072+ int result;
19073+ EnterCriticalSection(&textureStoreCriticalSection);
19074+
19075+ wineD3DGlobalStatistics->systemsurfaceram += sysram;
19076+ wineD3DGlobalStatistics->totalsurfaceram += sysram;
19077+ result = wineD3DGlobalStatistics->glsurfaceram;
19078+ LeaveCriticalSection(&textureStoreCriticalSection);
19079+ return result;
19080+
19081+}
19082+
19083+int globalStoreReleaseTexture(IWineD3DBaseTexture *texture){
19084+
19085+ int result;
19086+ int i;
19087+ TextureChain* textureChain = NULL;
19088+ TextureChain* previousTextureChain = NULL;
19089+
19090+ TRACE("Releasing texture %p\n", texture);
19091+ if(wineD3DGlobalStatistics== NULL){
19092+ WARN("Attempting to add a texture to the global store, but there is no global store\n");
19093+ return -1;
19094+ }
19095+
19096+ EnterCriticalSection(&textureStoreCriticalSection);
19097+ textureChain = wineD3DGlobalStatistics->textures;
19098+ /* I could keep a hash table to speed things up a bit (or keep the linked list sorted?) */
19099+
19100+ for(i = 0 ; i<wineD3DGlobalStatistics->textureCount ; i++){
19101+ if(textureChain == NULL) break;
19102+ if(textureChain->texture == texture) break;
19103+ previousTextureChain = textureChain;
19104+ textureChain = textureChain->next;
19105+ }
19106+
19107+ if(textureChain == NULL){
19108+ FIXME("Attempted to remove texture %p that hasn't been stored\n", texture);
19109+ LeaveCriticalSection(&textureStoreCriticalSection);
19110+ result = wineD3DGlobalStatistics->textureCount;
19111+ return result;
19112+ }else{
19113+ TRACE("Found texture (%d) %p with element %p pointing to %p (previous %p)\n", i, textureChain->texture, textureChain, textureChain->next, previousTextureChain);
19114+ }
19115+ /* make sure we don't leave a hole in the list */
19116+ if(previousTextureChain != NULL){
19117+ previousTextureChain->next = textureChain->next;
19118+ }else{
19119+ wineD3DGlobalStatistics->textures = textureChain->next;
19120+ }
19121+
19122+ result = wineD3DGlobalStatistics->textureCount--;
19123+ LeaveCriticalSection(&textureStoreCriticalSection);
19124+ return result;
19125+}
19126+
19127+
19128+int globalStoreSurface(IWineD3DSurface *surface){
19129+ int result = -1;
19130+ SurfaceChain* surfaceChain;
19131+
19132+ if(wineD3DGlobalStatistics== NULL){
19133+ WARN("Attempting to add a surface to the global store, but there is no global store\n");
19134+ return result;
19135+ }
19136+ EnterCriticalSection(&textureStoreCriticalSection);
19137+
19138+ /* add a new texture to the frot of the linked list */
19139+ surfaceChain = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(SurfaceChain));
19140+ surfaceChain->surface = surface;
19141+
19142+ /* Get the old head */
19143+ surfaceChain->next = wineD3DGlobalStatistics->surfaces;
19144+
19145+ wineD3DGlobalStatistics->surfaces = surfaceChain;
19146+ result = ++wineD3DGlobalStatistics->surfaceCount;
19147+ TRACE("Added surface (%d) %p with element %p pointing to %p\n", result, surface, surfaceChain, surfaceChain->next);
19148+ LeaveCriticalSection(&textureStoreCriticalSection);
19149+ return result;
19150+
19151+}
19152+
19153+int globalStoreReleaseSurface(IWineD3DSurface *surface){
19154+
19155+ int result = -1;
19156+ int i;
19157+ SurfaceChain* surfaceChain = NULL;
19158+ SurfaceChain* previousSurfaceChain = NULL;
19159+
19160+ TRACE("Releasing surface %p\n", surface);
19161+ if(wineD3DGlobalStatistics== NULL){
19162+ WARN("Attempting to add a surface to the global store, but there is no global store\n");
19163+ return result;
19164+ }
19165+
19166+ EnterCriticalSection(&textureStoreCriticalSection);
19167+
19168+ surfaceChain = wineD3DGlobalStatistics->surfaces;
19169+ /* I could keep a hash table to speed things up a bit (or keep the linked list sorted?) */
19170+
19171+ for(i = 0 ; i<wineD3DGlobalStatistics->surfaceCount ; i++){
19172+ if(surfaceChain == NULL) break;
19173+ if(surfaceChain->surface == surface) break;
19174+ previousSurfaceChain = surfaceChain;
19175+ surfaceChain = surfaceChain->next;
19176+ }
19177+
19178+ if(surfaceChain == NULL){
19179+ FIXME("Attempted to remove surface %p that hasn't been stored\n", surface);
19180+ LeaveCriticalSection(&textureStoreCriticalSection);
19181+ result = wineD3DGlobalStatistics->surfaceCount;
19182+ return result;
19183+ }else{
19184+ TRACE("Found surface (%d) %p with element %p pointing to %p (previous %p)\n", i, surfaceChain->surface, surfaceChain, surfaceChain->next, previousSurfaceChain);
19185+ }
19186+
19187+ /* make sure we don't leave a hole in the list */
19188+ if(previousSurfaceChain != NULL){
19189+ previousSurfaceChain->next = surfaceChain->next;
19190+ }else{
19191+ wineD3DGlobalStatistics->surfaces = surfaceChain->next;
19192+ }
19193+
19194+ result = wineD3DGlobalStatistics->surfaceCount--;
19195+ LeaveCriticalSection(&textureStoreCriticalSection);
19196+ return result;
19197+}
19198+
19199+
19200+
19201 IWineD3D* WINAPI WineDirect3DCreate(UINT SDKVersion, UINT dxVersion, IUnknown *parent) {
19202 IWineD3DImpl* object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IWineD3DImpl));
19203 object->lpVtbl = &IWineD3D_Vtbl;
19204@@ -40,7 +211,20 @@
19205 object->ref = 1;
19206 object->parent = parent;
19207
19208- TRACE("Created WineD3D object @ %p for d3d%d support\n", object, dxVersion);
19209+
19210+ /* Create a critical section for a dll global data store */
19211+ InitializeCriticalSectionAndSpinCount(&object->wined3dCriticalSection, 0x80000400);
19212+
19213+ EnterCriticalSection(&textureStoreCriticalSection);
19214+ /*Create a structure for storing global data in*/
19215+ if(wineD3DGlobalStatistics == NULL){
19216+ FIXME("Createing global statistics store\n");
19217+ wineD3DGlobalStatistics = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*wineD3DGlobalStatistics));
19218+
19219+ }
19220+ LeaveCriticalSection(&textureStoreCriticalSection);
19221+
19222+ TRACE("Created WineD3D object @ %p for d3d%d support, parent is %p\n", object, dxVersion, parent);
19223
19224 return (IWineD3D *)object;
19225 }
19226@@ -56,6 +240,7 @@
19227 DWORD size = sizeof(buffer);
19228 HKEY hkey = 0;
19229
19230+
19231 DisableThreadLibraryCalls(hInstDLL);
19232
19233 mod = GetModuleHandleA( "x11drv.dll" );
19234@@ -64,6 +249,8 @@
19235 wine_tsx11_lock_ptr = (void *)GetProcAddress( mod, "wine_tsx11_lock" );
19236 wine_tsx11_unlock_ptr = (void *)GetProcAddress( mod, "wine_tsx11_unlock" );
19237 }
19238+ /* Create a critical section for a dll global data store */
19239+ InitializeCriticalSectionAndSpinCount(&textureStoreCriticalSection, 0x80000400);
19240 if ( !RegOpenKeyA( HKEY_LOCAL_MACHINE, "Software\\Wine\\Direct3D", &hkey) )
19241 {
19242 if ( !RegQueryValueExA( hkey, "VertexShaderMode", 0, NULL, buffer, &size) )
19243diff -urN wine.20050419/dlls/wined3d/wined3d_private.h wine.20050419.dx9/dlls/wined3d/wined3d_private.h
19244--- wine.20050419/dlls/wined3d/wined3d_private.h 2005-03-29 12:01:00.000000000 -0700
19245+++ wine.20050419.dx9/dlls/wined3d/wined3d_private.h 2005-04-20 03:18:03.000000000 -0600
19246@@ -4,6 +4,7 @@
19247 * Copyright 2002-2003 The wine-d3d team
19248 * Copyright 2002-2003 Raphael Junqueira
19249 * Copyright 2004 Jason Edmeades
19250+ * Copyright 2005 Oliver Stieber
19251 *
19252 * This library is free software; you can redistribute it and/or
19253 * modify it under the terms of the GNU Lesser General Public
19254@@ -41,6 +42,47 @@
19255 #include "wine/wined3d_interface.h"
19256 #include "wine/wined3d_gl.h"
19257
19258+
19259+/* Device caps */
19260+#define MAX_PALETTES 256
19261+#define MAX_STREAMS 16
19262+#define MAX_ACTIVE_LIGHTS 8
19263+#define MAX_CLIPPLANES D3DMAXUSERCLIPPLANES
19264+#define MAX_LEVELS 256
19265+
19266+
19267+
19268+/*Swap chains*/
19269+#define MAX_SWAPCHAINS 256
19270+/*TODO: this is an arbitrary limit sice I don't think
19271+that there is an intrinsic limit to the number
19272+of swapchains though, it may be better to change tihs to
19273+a linked list at some point but a linked list makes
19274+things harder to debug so I'm leaving it as a flat array of
19275+MAX_SWAPCHAINS for now.
19276+*/
19277+/*
19278+Switch on this define to switch over to useing swapchains instead of jsut the device
19279+
19280+*/
19281+#define USE_SWAP_CHAINS 1
19282+/* Used for CreateStateBlock */
19283+#define NUM_SAVEDPIXELSTATES_R 38
19284+#define NUM_SAVEDPIXELSTATES_T 27
19285+#define NUM_SAVEDPIXELSTATES_S 0
19286+#define NUM_SAVEDVERTEXSTATES_R 33
19287+#define NUM_SAVEDVERTEXSTATES_T 2
19288+#define NUM_SAVEDVERTEXSTATES_S 0
19289+
19290+extern DWORD SavedPixelStates_R[NUM_SAVEDPIXELSTATES_R];
19291+extern DWORD SavedPixelStates_T[NUM_SAVEDPIXELSTATES_T];
19292+extern DWORD SavedPixelStates_S[NUM_SAVEDPIXELSTATES_S];
19293+extern DWORD SavedVertexStates_R[NUM_SAVEDVERTEXSTATES_R];
19294+extern DWORD SavedVertexStates_T[NUM_SAVEDVERTEXSTATES_T];
19295+extern DWORD SavedVertexStates_S[NUM_SAVEDVERTEXSTATES_S];
19296+
19297+
19298+
19299 extern int vs_mode;
19300 #define VS_NONE 0
19301 #define VS_HW 1
19302@@ -50,6 +92,13 @@
19303 #define PS_NONE 0
19304 #define PS_HW 1
19305
19306+/* Memory and object tracking */
19307+typedef struct WineD3DGlobalStatistics WineD3DGlobalStatistics;
19308+
19309+extern WineD3DGlobalStatistics* wineD3DGlobalStatistics;
19310+
19311+
19312+
19313 /* X11 locking */
19314
19315 extern void (*wine_tsx11_lock_ptr)(void);
19316@@ -58,6 +107,9 @@
19317 /* As GLX relies on X, this is needed */
19318 extern int num_lock;
19319
19320+
19321+
19322+
19323 #if 0
19324 #define ENTER_GL() ++num_lock; if (num_lock > 1) FIXME("Recursive use of GL lock to: %d\n", num_lock); wine_tsx11_lock_ptr()
19325 #define LEAVE_GL() if (num_lock != 1) FIXME("Recursive use of GL lock: %d\n", num_lock); --num_lock; wine_tsx11_unlock_ptr()
19326@@ -120,6 +172,39 @@
19327 #define GLTEXTURECUBEMAP GL_TEXTURE_CUBE_MAP_ARB
19328 #endif
19329
19330+
19331+
19332+
19333+/* Debugging helpers */
19334+
19335+#define dumpMatrixFIXME(lpmatrix) \
19336+FIXME("Matrix: %f %f %f %f \n", lpmatrix->DUMMYUNIONNAME.DUMMYSTRUCTNAME._11, \
19337+lpmatrix->DUMMYUNIONNAME.DUMMYSTRUCTNAME._12, lpmatrix->DUMMYUNIONNAME.DUMMYSTRUCTNAME._13, lpmatrix->DUMMYUNIONNAME.DUMMYSTRUCTNAME._14); \
19338+ FIXME(" %f %f %f %f\n", lpmatrix->DUMMYUNIONNAME.DUMMYSTRUCTNAME._21, \
19339+ lpmatrix->DUMMYUNIONNAME.DUMMYSTRUCTNAME._22, lpmatrix->DUMMYUNIONNAME.DUMMYSTRUCTNAME._23, \
19340+ lpmatrix->DUMMYUNIONNAME.DUMMYSTRUCTNAME._24); \
19341+ FIXME(" %f %f %f %f\n", lpmatrix->DUMMYUNIONNAME.DUMMYSTRUCTNAME._31, \
19342+ lpmatrix->DUMMYUNIONNAME.DUMMYSTRUCTNAME._32, lpmatrix->DUMMYUNIONNAME.DUMMYSTRUCTNAME._33, \
19343+ lpmatrix->DUMMYUNIONNAME.DUMMYSTRUCTNAME._34); \
19344+ FIXME(" %f %f %f %f\n", lpmatrix->DUMMYUNIONNAME.DUMMYSTRUCTNAME._41, \
19345+ lpmatrix->DUMMYUNIONNAME.DUMMYSTRUCTNAME._42, lpmatrix->DUMMYUNIONNAME.DUMMYSTRUCTNAME._43, \
19346+ lpmatrix->DUMMYUNIONNAME.DUMMYSTRUCTNAME._44); \
19347+
19348+#define dumpMatrixTRACE(lpmatrix) \
19349+ TRACE("Transform: %f %f %f %f \n", lpmatrix->DUMMYUNIONNAME.DUMMYSTRUCTNAME._11, \
19350+ lpmatrix->DUMMYUNIONNAME.DUMMYSTRUCTNAME._12, lpmatrix->DUMMYUNIONNAME.DUMMYSTRUCTNAME._13, \
19351+ lpmatrix->DUMMYUNIONNAME.DUMMYSTRUCTNAME._14); \
19352+ TRACE(" %f %f %f %f\n", lpmatrix->DUMMYUNIONNAME.DUMMYSTRUCTNAME._21, \
19353+ lpmatrix->DUMMYUNIONNAME.DUMMYSTRUCTNAME._22, lpmatrix->DUMMYUNIONNAME.DUMMYSTRUCTNAME._23, \
19354+ lpmatrix->DUMMYUNIONNAME.DUMMYSTRUCTNAME._24); \
19355+ TRACE(" %f %f %f %f\n", lpmatrix->DUMMYUNIONNAME.DUMMYSTRUCTNAME._31, \
19356+ lpmatrix->DUMMYUNIONNAME.DUMMYSTRUCTNAME._32, lpmatrix->DUMMYUNIONNAME.DUMMYSTRUCTNAME._33, \
19357+ lpmatrix->DUMMYUNIONNAME.DUMMYSTRUCTNAME._34); \
19358+ TRACE(" %f %f %f %f\n", lpmatrix->DUMMYUNIONNAME.DUMMYSTRUCTNAME._41, \
19359+ lpmatrix->DUMMYUNIONNAME.DUMMYSTRUCTNAME._42, lpmatrix->DUMMYUNIONNAME.DUMMYSTRUCTNAME._43, \
19360+ lpmatrix->DUMMYUNIONNAME.DUMMYSTRUCTNAME._44); \
19361+
19362+
19363 /* DirectX Device Limits */
19364 /* --------------------- */
19365 #define MAX_LEVELS 256 /* Maximum number of mipmap levels. Guessed at 256 */
19366@@ -183,8 +268,22 @@
19367 #define REAPPLY_ALL 0xFFFF
19368
19369 /* Advance declaration of structures to satisfy compiler */
19370+typedef struct IWineD3DBaseTextureImpl IWineD3DBaseTextureImpl;
19371 typedef struct IWineD3DStateBlockImpl IWineD3DStateBlockImpl;
19372 typedef struct IWineD3DSurfaceImpl IWineD3DSurfaceImpl;
19373+typedef struct IWineD3DSwapChainImpl IWineD3DSwapChainImpl;
19374+
19375+
19376+
19377+
19378+/*Tracking*/
19379+
19380+int globalStoreTexture(IWineD3DBaseTexture* texture);
19381+int globalStoreReleaseTexture(IWineD3DBaseTexture* texture);
19382+int globalStoreSurface(IWineD3DSurface* surface);
19383+int globalStoreReleaseSurface(IWineD3DSurface* surface);
19384+long globalChangeGlRam(long glram);
19385+long globalChangeSysRam(long sysram);
19386
19387 /* Global variables */
19388 extern const float identity[16];
19389@@ -241,6 +340,9 @@
19390 extern LONG primCounter;
19391 #endif
19392
19393+
19394+
19395+
19396 /*****************************************************************************
19397 * Prototypes
19398 */
19399@@ -321,6 +423,9 @@
19400 /* GL Information */
19401 BOOL isGLInfoValid;
19402 WineD3D_GL_Info gl_info;
19403+
19404+ /* a per instance critical section */
19405+ CRITICAL_SECTION wined3dCriticalSection;
19406 } IWineD3DImpl;
19407
19408 extern IWineD3DVtbl IWineD3D_Vtbl;
19409@@ -339,13 +444,16 @@
19410 IWineD3D *wineD3D;
19411
19412 /* X and GL Information */
19413+ #ifndef USE_SWAP_CHAINS /*TODO: move over to swapchains*/
19414 HWND win_handle;
19415 Window win;
19416- Display *display;
19417 GLXContext glCtx;
19418 XVisualInfo *visInfo;
19419 GLXContext render_ctx;
19420+ Display *display;
19421 Drawable drawable;
19422+ #endif
19423+
19424 GLint maxConcurrentLights;
19425
19426 /* Optimization */
19427@@ -367,8 +475,14 @@
19428
19429 /* State block related */
19430 BOOL isRecordingState;
19431+ /*TODO: replace with iface usage (maybe?) */
19432+ #if 0
19433+ IWineD3DStateBlock *stateBlock;
19434+ IWineD3DStateBlock *updateStateBlock;
19435+ #else
19436 IWineD3DStateBlockImpl *stateBlock;
19437 IWineD3DStateBlockImpl *updateStateBlock;
19438+ #endif
19439
19440 /* Internal use fields */
19441 D3DDEVICE_CREATION_PARAMETERS createParms;
19442@@ -377,10 +491,30 @@
19443 D3DDEVTYPE devType;
19444
19445 /* Render Target Support */
19446- IWineD3DSurface *frontBuffer;
19447- IWineD3DSurface *backBuffer;
19448- IWineD3DSurface *depthStencilBuffer;
19449+ #if 0 /* TODO: replace this with some stores, basicly move the code over from globalstoreadd...
19450+ It may be a good idea to store all device instances too so that a debug application can examine whats going on */
19451+ ILinkedListStore *swapchainStore;
19452+ ILinkedListStore *surfaceStore;
19453+ ILinkedListStore *textureStore;
19454+ #else
19455+ IWineD3DSwapChain *swapchains[MAX_SWAPCHAINS]; /*no-one wil ever need more that MAX_SWAPCHAINS swapchains,
19456+ I don't think that ther is an intrinsic limit
19457+ to the number of swapchains though so maybe
19458+ a linked list would be better?*/
19459+ int numberOfSwapChains;
19460
19461+ #endif
19462+
19463+ /*
19464+ apparently this is bound to the device not the swapchain
19465+ multiple windows with depthSencilBuffers are going to be interesting.
19466+ */
19467+ IWineD3DSurface *depthStencilBuffer;
19468+
19469+ /* FIXME: (MS DX9 Docs) The device can now support multiple render targets.
19470+ The number of render targets supported by a device is contained in the
19471+ NumSimultaneousRTs member of D3DCAPS9. See Multiple Render Targets. */
19472+
19473 IWineD3DSurface *renderTarget;
19474 IWineD3DSurface *stencilBufferTarget;
19475
19476@@ -483,14 +617,14 @@
19477
19478 } IWineD3DBaseTextureClass;
19479
19480-typedef struct IWineD3DBaseTextureImpl
19481+struct IWineD3DBaseTextureImpl
19482 {
19483 /* IUnknown & WineD3DResource Information */
19484 IWineD3DBaseTextureVtbl *lpVtbl;
19485 IWineD3DResourceClass resource;
19486 IWineD3DBaseTextureClass baseTexture;
19487
19488-} IWineD3DBaseTextureImpl;
19489+};
19490
19491 extern IWineD3DBaseTextureVtbl IWineD3DBaseTexture_Vtbl;
19492
19493@@ -588,11 +722,10 @@
19494 } WINED3DSURFACET_DESC;
19495
19496 /*****************************************************************************
19497- * IWineD3DSurface implementation structure
19498+ * IWineD3DTSurface implementation structure (extends IWineD3DResourceImpl)
19499 */
19500 struct IWineD3DSurfaceImpl
19501 {
19502- /* IUnknown & IWineD3DResource Information */
19503 IWineD3DSurfaceVtbl *lpVtbl;
19504 IWineD3DResourceClass resource;
19505
19506@@ -603,20 +736,37 @@
19507 UINT textureName;
19508 UINT bytesPerPixel;
19509
19510+ /*Other things not in D3DSURFACE_DESC*/
19511 BOOL lockable;
19512 BOOL discard;
19513 BOOL locked;
19514
19515+ /*TODO: move this off into a management class(maybe!)*/
19516+ BOOL nonpow2;
19517+
19518+ UINT pow2Width;
19519+ UINT pow2Height;
19520+ UINT pow2Size;
19521+
19522+ /* precalculated x and y scalings for texture coords */
19523+ float pow2scalingFactorX; /* = (Width / pow2Width ) */
19524+ float pow2scalingFactorY; /* = (Height / pow2Height) */
19525+
19526 RECT lockedRect;
19527 RECT dirtyRect;
19528 BOOL Dirty;
19529-
19530+ /*TODO: move this off into a context manager
19531+ IUnknown *contextManagerData;
19532+ */
19533+ BOOL activeLock;/*Performance. Is locking activly being used on this surface*/
19534 BOOL inTexture;
19535 BOOL inPBuffer;
19536+
19537 };
19538
19539 extern IWineD3DSurfaceVtbl IWineD3DSurface_Vtbl;
19540
19541+
19542 /*****************************************************************************
19543 * IWineD3DVertexDeclaration implementation structure
19544 */
19545@@ -626,8 +776,13 @@
19546 DWORD ref; /* Note: Ref counting not required */
19547
19548 IUnknown *parent;
19549- /** precomputed fvf if simple declaration */
19550+ /*TODO: replace with iface usage */
19551+ #if 0
19552+ IWineD3DDevice *wineD3DDevice;
19553+ #else
19554 IWineD3DDeviceImpl *wineD3DDevice;
19555+ #endif
19556+ /** precomputed fvf if simple declaration */
19557 DWORD fvf[MAX_STREAMS];
19558 DWORD allFVF;
19559
19560@@ -653,13 +808,16 @@
19561 BOOL indices;
19562 BOOL material;
19563 BOOL fvf;
19564- BOOL stream_source[MAX_STREAMS];
19565+
19566+ BOOL streamSource[MAX_STREAMS];
19567+ BOOL streamFreq[MAX_STREAMS];
19568 BOOL textures[8];
19569- BOOL transform[HIGHEST_TRANSFORMSTATE];
19570+ BOOL transform[HIGHEST_TRANSFORMSTATE +1 ];
19571 BOOL viewport;
19572- BOOL renderState[WINEHIGHEST_RENDER_STATE];
19573- BOOL textureState[8][HIGHEST_TEXTURE_STATE];
19574+ BOOL renderState[WINEHIGHEST_RENDER_STATE + 1];
19575+ BOOL textureState[8][HIGHEST_TEXTURE_STATE +1];
19576 BOOL clipplane[MAX_CLIPPLANES];
19577+ BOOL samplerState[16/*MAX_SAMPLERS*/][HIGHEST_SAMPLER_STATE + 1];
19578 BOOL vertexDecl;
19579 BOOL pixelShader;
19580 BOOL vertexShader;
19581@@ -673,7 +831,12 @@
19582
19583 /* IWineD3DStateBlock information */
19584 IUnknown *parent;
19585+ /*TODO: replace with iface usage */
19586+ #if 0
19587+ IWineD3DDevice *wineD3DDevice;
19588+ #else
19589 IWineD3DDeviceImpl *wineD3DDevice;
19590+ #endif
19591 D3DSTATEBLOCKTYPE blockType;
19592
19593 /* Array indicating whether things have been set or changed */
19594@@ -689,16 +852,18 @@
19595
19596 /* Stream Source */
19597 BOOL streamIsUP;
19598- UINT stream_stride[MAX_STREAMS];
19599- UINT stream_offset[MAX_STREAMS];
19600- IWineD3DVertexBuffer *stream_source[MAX_STREAMS];
19601+ UINT streamStride[MAX_STREAMS];
19602+ UINT streamOffset[MAX_STREAMS];
19603+ IWineD3DVertexBuffer *streamSource[MAX_STREAMS];
19604+ UINT streamFreq[MAX_STREAMS];
19605+ UINT streamFlags[MAX_STREAMS]; /*0 | D3DSTREAMSOURCE_INSTANCEDATA | D3DSTREAMSOURCE_INDEXEDDATA */
19606
19607 /* Indices */
19608 IWineD3DIndexBuffer* pIndexData;
19609 UINT baseVertexIndex; /* Note: only used for d3d8 */
19610
19611 /* Transform */
19612- D3DMATRIX transforms[HIGHEST_TRANSFORMSTATE];
19613+ D3DMATRIX transforms[HIGHEST_TRANSFORMSTATE + 1];
19614
19615 /* Lights */
19616 PLIGHTINFOEL *lights; /* NOTE: active GL lights must be front of the chain */
19617@@ -713,24 +878,30 @@
19618 /* Material */
19619 WINED3DMATERIAL material;
19620
19621+ /* Pixel Shader */
19622+ void *pixelShader; /* TODO: Replace void * with IWineD3DPixelShader * */
19623+
19624 /* Indexed Vertex Blending */
19625 D3DVERTEXBLENDFLAGS vertex_blend;
19626 FLOAT tween_factor;
19627
19628 /* RenderState */
19629- DWORD renderState[WINEHIGHEST_RENDER_STATE];
19630+ DWORD renderState[WINEHIGHEST_RENDER_STATE +1 ];
19631
19632 /* Texture */
19633- IWineD3DBaseTexture *textures[8];
19634- int textureDimensions[8];
19635+ IWineD3DBaseTexture *textures[9];
19636+ int textureDimensions[17/*MAX_STREAMS*/];/*increased to accomodate samplerStates too*/
19637
19638 /* Texture State Stage */
19639- DWORD textureState[8][HIGHEST_TEXTURE_STATE];
19640+ DWORD textureState[9][HIGHEST_TEXTURE_STATE + 1];
19641+ /* Sampler States */
19642+ DWORD samplerState[17/*MAX_STREAMS*/][HIGHEST_SAMPLER_STATE + 1];/*I think this can be combined with textureState*/
19643
19644 };
19645
19646 extern IWineD3DStateBlockVtbl IWineD3DStateBlock_Vtbl;
19647
19648+
19649 /*****************************************************************************
19650 * IWineD3DQueryImpl implementation structure (extends IUnknown)
19651 */
19652@@ -756,7 +927,82 @@
19653
19654 extern IWineD3DQueryVtbl IWineD3DQuery_Vtbl;
19655
19656+
19657 /*****************************************************************************
19658+ * IWineD3DSwapChainImpl implementation structure (extends IUnknown)
19659+ */
19660+
19661+
19662+struct IWineD3DSwapChainImpl
19663+{
19664+ /*IUnknown part*/
19665+ IWineD3DSwapChainVtbl *lpVtbl;
19666+ DWORD ref; /* Note: Ref counting not required */
19667+
19668+ IUnknown *parent;
19669+ /*TODO: replace with iface usage */
19670+#if 0
19671+ IWineD3DDevice *wineD3DDevice;
19672+#else
19673+ IWineD3DDeviceImpl *wineD3DDevice;
19674+#endif
19675+ /* IWineD3DSwapChain fields */
19676+ IWineD3DSurface *backBuffer;
19677+ IWineD3DSurface *frontBuffer;
19678+ BOOL wantsDepthStencilBuffer;
19679+ D3DPRESENT_PARAMETERS presentParms;
19680+
19681+ /* TODO: move everything upto drawable off into a context manager
19682+ and store the 'data' in the contextManagerData interface.
19683+ IUnknown *contextManagerData;
19684+ */
19685+
19686+ HWND win_handle;
19687+ Window win;
19688+ Display *display;
19689+
19690+ GLXContext glCtx;
19691+ XVisualInfo *visInfo;
19692+ GLXContext render_ctx;
19693+ /* This has been left in device for now, but needs moving off into a rendertarget mamangement class and seperated out from swapchains and devices. */
19694+ Drawable drawable;
19695+};
19696+
19697+extern IWineD3DSwapChainVtbl IWineD3DSwapChain_Vtbl;
19698+
19699+
19700+/*Global object infomration*/
19701+typedef struct TextureChain {
19702+ IWineD3DBaseTexture *texture;
19703+ struct TextureChain *previous;
19704+ struct TextureChain *next;
19705+} TextureChain;
19706+
19707+typedef struct SurfaceChain {
19708+ IWineD3DSurface *surface;
19709+ struct SurfaceChain *previous;
19710+ struct SurfaceChain *next;
19711+} SurfaceChain;
19712+
19713+/*Structure for holding information on all direct3d objects
19714+usefull for making sure tracking is ok and when release is called on a device!
19715+and probably quite handy for debuggin and dumping states out
19716+*/
19717+struct WineD3DGlobalStatistics {
19718+ int textureCount;
19719+ int surfaceCount;
19720+ int activeSurfaces;
19721+ int gltextures;
19722+ int systemsurfaceram; /*The about of heap memory allocated for textures*/
19723+ int totalsurfaceram;/*The amount of memory in total allocated for textrues*/
19724+ int glsurfaceram; /*The aproximate amount of glTexture memory allocated for textures*/
19725+ TextureChain *textures;/*global texture store*/
19726+ SurfaceChain *surfaces;/*global surface store*/
19727+};
19728+
19729+
19730+/*****************************************************************************
19731+
19732 * Utility function prototypes
19733 */
19734
19735@@ -781,6 +1027,20 @@
19736 GLenum D3DFmt2GLType(IWineD3DDeviceImpl *This, D3DFORMAT fmt);
19737 GLint D3DFmt2GLIntFmt(IWineD3DDeviceImpl* This, D3DFORMAT fmt);
19738
19739+GLenum D3DFmt2GLDepthFmt(D3DFORMAT fmt);
19740+GLenum D3DFmt2GLDepthType(D3DFORMAT fmt);
19741+
19742+int D3DFmtMakeGlCfg(D3DFORMAT BackBufferFormat, D3DFORMAT StencilBufferFormat, int *attribs, int* nAttribs, BOOL alternate);
19743+
19744+int D3DPrimitiveListGetVertexSize(D3DPRIMITIVETYPE PrimitiveType, int iNumPrim);
19745+int D3DPrimitive2GLenum(D3DPRIMITIVETYPE PrimitiveType);
19746+int D3DFVFGetSize(D3DFORMAT fvf);
19747+
19748+int SOURCEx_RGB_EXT(DWORD arg);
19749+int OPERANDx_RGB_EXT(DWORD arg);
19750+int SOURCEx_ALPHA_EXT(DWORD arg);
19751+int OPERANDx_ALPHA_EXT(DWORD arg);
19752+
19753 /*****************************************************************************
19754 * To enable calling of inherited functions, requires prototypes
19755 *
19756@@ -831,6 +1091,8 @@
19757 /*** class static members ***/
19758 void IWineD3DBaseTextureImpl_CleanUp(IWineD3DBaseTexture *iface);
19759
19760+/* STUBS for pixel and vertex shader interfaces*/
19761+
19762 /*****************************************************************************
19763 * IDirect3DVertexShader implementation structure
19764 */
19765@@ -840,13 +1102,18 @@
19766 DWORD ref; /* Note: Ref counting not required */
19767
19768 IUnknown *parent;
19769+ /*TODO: replace with iface usage */
19770+ #if 0
19771+ IWineD3DDevice *wineD3DDevice;
19772+ #else
19773 IWineD3DDeviceImpl *wineD3DDevice;
19774+ #endif
19775
19776 /* IWineD3DVertexShaderImpl*/
19777 CONST DWORD *function;
19778 UINT functionLength;
19779-
19780 #if 0 /* needs reworking */
19781+
19782 DWORD usage;
19783 DWORD version;
19784 /* run time datas */
19785@@ -866,13 +1133,16 @@
19786 DWORD ref; /* Note: Ref counting not required */
19787
19788 IUnknown *parent;
19789+ /*TODO: replace with iface usage */
19790+ #if 0
19791+ IWineD3DDevice *wineD3DDevice;
19792+ #else
19793 IWineD3DDeviceImpl *wineD3DDevice;
19794-
19795+ #endif
19796
19797 /* IWineD3DPixelShaderImpl*/
19798 CONST DWORD *function;
19799 UINT functionLength;
19800-
19801 #if 0 /* needs reworking */
19802 UINT functionLength;
19803 DWORD version;
19804@@ -884,4 +1154,23 @@
19805 } IWineD3DPixelShaderImpl;
19806
19807 extern IWineD3DPixelShaderVtbl IWineD3DPixelShader_Vtbl;
19808+
19809+#if 0 /*TODO: private interfaces &co for this.. */
19810+typedef struct ILinkedListStoreImpl {
19811+ /* IUnknown parts*/
19812+ IWineD3DPixelShaderVtbl *lpVtbl;
19813+ DWORD ref; /* Note: Ref counting not required */
19814+
19815+ /* ILinkedListStore members */
19816+ BOOL threadSafe;
19817+
19818+ /* critical section, (can be supplied by the caller to keep the number of critical sections down?) */
19819+ CRITICAL_SECTION *CriticalSection;
19820+ ForwardOnlyLinkedList *linkedList;/*global texture store*/
19821+
19822+
19823+} ILinkedListStoreImpl;
19824+
19825+extern ILinkedListStoreVtbl ILinkedListStore_Vtbl;
19826+#endif
19827 #endif
19828diff -urN wine.20050419/include/d3d9.h wine.20050419.dx9/include/d3d9.h
19829--- wine.20050419/include/d3d9.h 2004-10-04 22:38:15.000000000 -0600
19830+++ wine.20050419.dx9/include/d3d9.h 2005-04-20 01:52:56.000000000 -0600
19831@@ -26,8 +26,12 @@
19832
19833 #include <objbase.h>
19834
19835+#define D3D_SDK_VERSION (32 | 0x80000000)
19836+#define D3D9b_SDK_VERSION (31 | 0x80000000)
19837+
19838 #include <d3d9types.h>
19839 #include <d3d9caps.h>
19840+#include <gdi.h>
19841
19842 /*****************************************************************************
19843 * Behavior Flags for IDirect3D8::CreateDevice
19844@@ -40,6 +44,7 @@
19845 #define D3DCREATE_MIXED_VERTEXPROCESSING 0x00000080L
19846 #define D3DCREATE_DISABLE_DRIVER_MANAGEMENT 0x00000100L
19847 #define D3DCREATE_ADAPTERGROUP_DEVICE 0x00000200L
19848+#define D3DCREATE_MANAGED
19849
19850 /*****************************************************************************
19851 * Flags for SetPrivateData
19852diff -urN wine.20050419/include/d3d9caps.h wine.20050419.dx9/include/d3d9caps.h
19853--- wine.20050419/include/d3d9caps.h 2003-06-20 15:28:34.000000000 -0600
19854+++ wine.20050419.dx9/include/d3d9caps.h 2005-04-20 01:52:56.000000000 -0600
19855@@ -25,8 +25,8 @@
19856 */
19857 #define D3DCAPS_READ_SCANLINE 0x20000
19858
19859-#define D3DCURSORCAPS_COLOR 1
19860-#define D3DCURSORCAPS_LOWRES 2
19861+#define D3DCURSORCAPS_COLOR 0x00000001L
19862+#define D3DCURSORCAPS_LOWRES 0x00000002L
19863
19864
19865 #define D3DDEVCAPS2_STREAMOFFSET 0x00000001L
19866@@ -179,14 +179,15 @@
19867 #define D3DPTFILTERCAPS_MAGFPYRAMIDALQUAD 0x08000000
19868 #define D3DPTFILTERCAPS_MAGFGAUSSIANQUAD 0x10000000
19869
19870-#define D3DSTENCILCAPS_KEEP 0x01
19871-#define D3DSTENCILCAPS_ZERO 0x02
19872-#define D3DSTENCILCAPS_REPLACE 0x04
19873-#define D3DSTENCILCAPS_INCRSAT 0x08
19874-#define D3DSTENCILCAPS_DECRSAT 0x10
19875-#define D3DSTENCILCAPS_INVERT 0x20
19876-#define D3DSTENCILCAPS_INCR 0x40
19877-#define D3DSTENCILCAPS_DECR 0x80
19878+#define D3DSTENCILCAPS_KEEP 0x00000001L
19879+#define D3DSTENCILCAPS_ZERO 0x00000002L
19880+#define D3DSTENCILCAPS_REPLACE 0x00000004L
19881+#define D3DSTENCILCAPS_INCRSAT 0x00000008L
19882+#define D3DSTENCILCAPS_DECRSAT 0x00000010L
19883+#define D3DSTENCILCAPS_INVERT 0x00000020L
19884+#define D3DSTENCILCAPS_INCR 0x00000040L
19885+#define D3DSTENCILCAPS_DECR 0x00000080L
19886+#define D3DSTENCILCAPS_TWOSIDED 0x00000100L
19887
19888 #define D3DTEXOPCAPS_DISABLE 0x0000001
19889 #define D3DTEXOPCAPS_SELECTARG1 0x0000002
19890@@ -326,7 +327,8 @@
19891
19892 DWORD LineCaps;
19893
19894- DWORD MaxTextureWidth, MaxTextureHeight;
19895+ DWORD MaxTextureWidth;
19896+ DWORD MaxTextureHeight;
19897 DWORD MaxVolumeExtent;
19898
19899 DWORD MaxTextureRepeat;
19900@@ -364,13 +366,13 @@
19901 DWORD MaxVertexShaderConst;
19902
19903 DWORD PixelShaderVersion;
19904- float MaxPixelShaderValue;
19905+ float PixelShader1xMaxValue;
19906
19907 /* DX 9 */
19908 DWORD DevCaps2;
19909
19910 float MaxNpatchTessellationLevel;
19911- DWORD Reserved5;
19912+ DWORD Reserved5; /*undocumented*/
19913
19914 UINT MasterAdapterOrdinal;
19915 UINT AdapterOrdinalInGroup;
19916@@ -385,6 +387,8 @@
19917 DWORD MaxPShaderInstructionsExecuted;
19918 DWORD MaxVertexShader30InstructionSlots;
19919 DWORD MaxPixelShader30InstructionSlots;
19920+ DWORD Reserved2;/*Not in the microsoft headers but documented*/
19921+ DWORD Reserved3;
19922
19923 } D3DCAPS9;
19924
19925diff -urN wine.20050419/include/d3d9types.h wine.20050419.dx9/include/d3d9types.h
19926--- wine.20050419/include/d3d9types.h 2005-03-03 06:57:15.000000000 -0700
19927+++ wine.20050419.dx9/include/d3d9types.h 2005-04-20 01:52:56.000000000 -0600
19928@@ -209,6 +209,23 @@
19929
19930
19931
19932+
19933+/*Constants used by D3DPRESENT_PARAMETERS. when creating a device or swapchain*/
19934+
19935+#define D3DPRESENTFLAG_LOCKABLE_BACKBUFFER 0x00000001 /*Create a lockable backbuffer*/
19936+#define D3DPRESENTFLAG_DISCARD_DEPTHSTENCIL 0x00000002 /*Discard Z buffer */
19937+#define D3DPRESENTFLAG_DEVICECLIP 0x00000004 /*Clip the window blited into the client area 2k + xp only*/
19938+#define D3DPRESENTFLAG_VIDEO 0x00000010 /*backbuffer 'may' contain video data*/
19939+
19940+
19941+
19942+#define D3DPRESENT_BACK_BUFFERS_MAX 3L
19943+#define D3DPRESENT_RATE_DEFAULT 0x00000000
19944+
19945+
19946+
19947+
19948+
19949 /****************************
19950 * Vertex Shaders Declaration
19951 */
19952@@ -228,6 +245,7 @@
19953 D3DDECLUSAGE_FOG = 11,
19954 D3DDECLUSAGE_DEPTH = 12,
19955 D3DDECLUSAGE_SAMPLE = 13
19956+
19957 } D3DDECLUSAGE;
19958
19959 /* MSDN is quite confussing at this point...
19960@@ -811,6 +829,7 @@
19961 D3DFMT_D16_LOCKABLE = 70,
19962 D3DFMT_D32 = 71,
19963 D3DFMT_D15S1 = 73,
19964+ D3DFMT_D24S8 = 75,
19965 D3DFMT_D24X8 = 77,
19966 D3DFMT_D24X4S4 = 79,
19967 D3DFMT_D16 = 80,
19968@@ -875,16 +894,6 @@
19969 D3DMULTISAMPLE_FORCE_DWORD = 0xffffffff
19970 } D3DMULTISAMPLE_TYPE;
19971
19972-#if 0
19973-typedef enum _D3DORDERTYPE {
19974- D3DORDER_LINEAR = 1,
19975- D3DORDER_QUADRATIC = 2,
19976- D3DORDER_CUBIC = 3,
19977- D3DORDER_QUINTIC = 5,
19978-
19979- D3DORDER_FORCE_DWORD = 0x7fffffff
19980-} D3DORDERTYPE;
19981-#endif
19982 typedef enum _D3DPATCHEDGESTYLE {
19983 D3DPATCHEDGE_DISCRETE = 0,
19984 D3DPATCHEDGE_CONTINUOUS = 1,
19985@@ -1135,17 +1144,6 @@
19986 D3DTSS_BUMPENVMAT10 = 9,
19987 D3DTSS_BUMPENVMAT11 = 10,
19988 D3DTSS_TEXCOORDINDEX = 11,
19989-#if 1 /* TODO: remove once samplerstates are implemented. */
19990- D3DTSS_ADDRESSU = 13,
19991- D3DTSS_ADDRESSV = 14,
19992- D3DTSS_BORDERCOLOR = 15,
19993- D3DTSS_MAGFILTER = 16,
19994- D3DTSS_MINFILTER = 17,
19995- D3DTSS_MIPFILTER = 18,
19996- D3DTSS_MIPMAPLODBIAS = 19,
19997- D3DTSS_MAXMIPLEVEL = 20,
19998- D3DTSS_MAXANISOTROPY = 21,
19999-#endif
20000 D3DTSS_BUMPENVLSCALE = 22,
20001 D3DTSS_BUMPENVLOFFSET = 23,
20002 D3DTSS_TEXTURETRANSFORMFLAGS = 24,
20003@@ -1241,7 +1239,7 @@
20004
20005 GUID DeviceIdentifier;
20006
20007- DWORD WHQLLevel;
20008+ DWORD WHQLLevel;/*d3d9.h D3DENUM_WHQL_LEVEL*/
20009 } D3DADAPTER_IDENTIFIER9;
20010
20011 typedef struct _D3DBOX {
20012diff -urN wine.20050419/include/d3dx9.h wine.20050419.dx9/include/d3dx9.h
20013--- wine.20050419/include/d3dx9.h 1969-12-31 17:00:00.000000000 -0700
20014+++ wine.20050419.dx9/include/d3dx9.h 2005-04-20 01:52:56.000000000 -0600
20015@@ -0,0 +1,86 @@
20016+/*
20017+ * Copyright (C) 2005 Oliver Stieber
20018+ *
20019+ * This library is free software; you can redistribute it and/or
20020+ * modify it under the terms of the GNU Lesser General Public
20021+ * License as published by the Free Software Foundation; either
20022+ * version 2.1 of the License, or (at your option) any later version.
20023+ *
20024+ * This library is distributed in the hope that it will be useful,
20025+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
20026+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20027+ * Lesser General Public License for more details.
20028+ *
20029+ * You should have received a copy of the GNU Lesser General Public
20030+ * License along with this library; if not, write to the Free Software
20031+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20032+ */
20033+
20034+
20035+#ifndef __WINE_D3DX9_H
20036+#define __WINE_D3DX9_H
20037+
20038+
20039+
20040+
20041+
20042+
20043+
20044+/*** Defines ***/
20045+#define D3DX_DEFAULT ((UINT) -1)
20046+#define D3DX_DEFAULT_NONPOW2 ((UINT) -2)
20047+#define D3DX_DEFAULT_FLOAT FLT_MAX
20048+#define D3DFMT_FROM_FILE
20049+#define D3DX_FROM_FILE
20050+
20051+#if 0
20052+#ifndef D3DXINLINE
20053+#ifdef _MSC_VER
20054+ #if (_MSC_VER >= 1200)
20055+ #define D3DXINLINE __forceinline
20056+ #else
20057+ #define D3DXINLINE __inline
20058+ #endif
20059+#else
20060+ #ifdef __cplusplus
20061+ #define D3DXINLINE inline
20062+ #else
20063+ #define D3DXINLINE
20064+ #endif
20065+#endif
20066+#endif
20067+#endif
20068+
20069+
20070+/*** Includes ***/
20071+#include <d3d9.h>
20072+#include <d3dx9math.h>
20073+#include <d3dx9core.h>
20074+#if 0
20075+#include <d3dx9mesh.h>
20076+#include <d3dx9tex.h>
20077+#include <d3dx9shader.h>
20078+#include <d3dx9effect.h>
20079+#include <d3dx9shape.h>
20080+#include <d3dx9anim.h>
20081+#endif
20082+/*** Errors ***/
20083+/*I don't know where this lives yet*/
20084+
20085+#define _FACDD 0x876
20086+#define MAKE_DDHRESULT( code ) MAKE_HRESULT( 1, _FACDD, code )
20087+
20088+
20089+
20090+typedef enum _D3DXERR {
20091+ D3DXERR_CANNOTMODIFYINDEXBUFFER = 1, // (1 << 31)|(0x876 << 16)|2900 ,
20092+ D3DXERR_INVALIDMESH = MAKE_DDHRESULT(2901) ,
20093+ D3DXERR_CANNOTATTRSORT = MAKE_DDHRESULT(2902) ,
20094+ D3DXERR_SKINNINGNOTSUPPORTED = MAKE_DDHRESULT(2903) ,
20095+ D3DXERR_TOOMANYINFLUENCES = MAKE_DDHRESULT(2904) ,
20096+ D3DXERR_INVALIDDATA = MAKE_DDHRESULT(2905) ,
20097+ D3DXERR_LOADEDMESHASNODATA = MAKE_DDHRESULT(2906) ,
20098+ D3DXERR_DUPLICATENAMEDFRAGMENT = MAKE_DDHRESULT(2907) ,
20099+}D3DXERR;
20100+
20101+#endif /* __WINE_D3DX9_H */
20102diff -urN wine.20050419/include/d3dx9core.h wine.20050419.dx9/include/d3dx9core.h
20103--- wine.20050419/include/d3dx9core.h 1969-12-31 17:00:00.000000000 -0700
20104+++ wine.20050419.dx9/include/d3dx9core.h 2005-04-20 01:52:56.000000000 -0600
20105@@ -0,0 +1,607 @@
20106+
20107+/*
20108+ * Copyright (C) 2005 Oliver Stieber
20109+ *
20110+ * This library is free software; you can redistribute it and/or
20111+ * modify it under the terms of the GNU Lesser General Public
20112+ * License as published by the Free Software Foundation; either
20113+ * version 2.1 of the License, or (at your option) any later version.
20114+ *
20115+ * This library is distributed in the hope that it will be useful,
20116+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
20117+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20118+ * Lesser General Public License for more details.
20119+ *
20120+ * You should have received a copy of the GNU Lesser General Public
20121+ * License along with this library; if not, write to the Free Software
20122+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20123+ */
20124+
20125+#ifndef __WINE_D3DX9CORE_H
20126+#define __WINE_D3DX9CORE_H
20127+
20128+#include <objbase.h>
20129+
20130+#include <d3dx9.h>
20131+/*** Version info ***/
20132+
20133+
20134+/*FIXME: move to d3d9mesh.h ?*/
20135+#define D3DX_VERSION 0x0902
20136+#define D3DX_SDK_VERSION 22
20137+
20138+
20139+
20140+#if 0
20141+#ifdef __cplusplus
20142+extern "C" {
20143+#endif
20144+BOOL WINAPI D3DXCheckVersion(UINT D3DSdkVersion, UINT D3DXSdkVersion);
20145+UINT WINAPI D3DXGetDriverLevel(LPDIRECT3DDEVICE9 pDevice);
20146+#ifdef __cplusplus
20147+}
20148+#endif
20149+#endif
20150+
20151+
20152+#ifdef __cplusplus
20153+extern "C" {
20154+#endif
20155+
20156+HRESULT WINAPI D3DXCreateTextureFromFile(LPDIRECT3DDEVICE9 pDevice, LPSTR pSrcFile, LPDIRECT3DTEXTURE9 *ppTexture);
20157+
20158+#ifdef __cplusplus
20159+}
20160+#endif
20161+
20162+
20163+
20164+
20165+
20166+
20167+/*****************************************************************************
20168+ * GUIDs
20169+ */
20170+
20171+/* {932E6A7E-C68E-45dd-A7BF-53D19C86DB1F} */
20172+DEFINE_GUID(IID_ID3DXBuffer, 0x932e6a7e, 0xc68e, 0x45dd, 0xa7, 0xbf, 0x53, 0xd1, 0x9c, 0x86, 0xdb, 0x1f);
20173+
20174+
20175+/* {4AAE6B4D-D15F-4909-B09F-8D6AA34AC06B} */
20176+DEFINE_GUID( IID_ID3DXFont, 0x4aae6b4d, 0xd15f, 0x4909, 0xb0, 0x9f, 0x8d, 0x6a, 0xa3, 0x4a, 0xc0, 0x6b);
20177+
20178+/* {B07EC84A-8D35-4e86-A9A0-8DFF21D71075} */
20179+DEFINE_GUID( IID_ID3DXSprite, 0xb07ec84a, 0x8d35, 0x4e86, 0xa9, 0xa0, 0x8d, 0xff, 0x21, 0xd7, 0x10, 0x75);
20180+
20181+/*****************************************************************************
20182+ * typedefs
20183+ */
20184+typedef struct ID3DXBuffer ID3DXBuffer, *LPD3DXBUFFER;
20185+typedef struct ID3DXFont ID3DXFont, *LPD3DXFONT;
20186+typedef struct ID3DXSprite ID3DXSprite, *LPD3DXSPRITE;
20187+
20188+
20189+
20190+
20191+
20192+
20193+/*****************************************************************************
20194+ * #defines and error codes
20195+ */
20196+#define D3DXASM_DEBUG 1
20197+#define D3DXASM_SKIPVALIDATION 2
20198+
20199+#define _FACD3D 0x876
20200+#define MAKE_D3DXHRESULT( code ) MAKE_HRESULT( 1, _FACD3D, code )
20201+
20202+/*
20203+ * Direct3D Errors
20204+ */
20205+ #if 0
20206+#define D3DXERR_CANNOTATTRSORT MAKE_D3DXHRESULT(2158)
20207+#define D3DXERR_CANNOTMODIFYINDEXBUFFER MAKE_D3DXHRESULT(2159)
20208+#define D3DXERR_INVALIDMESH MAKE_D3DXHRESULT(2160)
20209+#define D3DXERR_SKINNINGNOTSUPPORTED MAKE_D3DXHRESULT(2161)
20210+#define D3DXERR_TOOMANYINFLUENCES MAKE_D3DXHRESULT(2162)
20211+#define D3DXERR_INVALIDDATA MAKE_D3DXHRESULT(2163)
20212+#endif
20213+#define D3DXSPRITE_DONOTSAVESTATE
20214+#define D3DXSPRITE_DONOTMODIFY_RENDERSTATE
20215+#define D3DXSPRITE_OBJECTSPACE
20216+#define D3DXSPRITE_BILLBOARD
20217+#define D3DXSPRITE_ALPHABLEND
20218+#define D3DXSPRITE_SORT_TEXTURE
20219+#define D3DXSPRITE_SORT_DEPTH_FRONTTOBACK
20220+#define D3DXSPRITE_SORT_DEPTH_BACKTOFRONT
20221+
20222+
20223+
20224+
20225+
20226+
20227+/*
20228+ * Macros
20229+ */
20230+#define D3DSINCOSCONST1 -1.5500992e-006f, -2.1701389e-005f, 0.0026041667f, 0.00026041668f
20231+#if 0
20232+#define D3DSINCOSCONST2 -0.020833334f , -0.12500000f , 1.0f , 0.50000000f
20233+#endif
20234+/*FIXME: move over to d3dx9math.h*/
20235+
20236+
20237+#if 0
20238+/*** 16-Bit Floating Point Numbers ***/
20239+#define D3DX_16F_DIG 3
20240+#define D3DX_16F_EPSILON 4.8875809e-4f
20241+#define D3DX_16F_MANT_DIG 11
20242+#define D3DX_16F_MAX 6.5519996e+4f
20243+#define D3DX_16F_MAX_10_EXP 4
20244+#define D3DX_16F_MAX_EXP 15
20245+#define D3DX_16F_MIN 6.1035156e-5f
20246+#define D3DX_16F_MIN_10_EXP (-4)
20247+#define D3DX_16F_MIN_EXP (-12)
20248+#define D3DX_16F_RADIX 2
20249+#define D3DX_16F_ROUNDS 1
20250+#define D3DX_1BYPI ((FLOAT) 0.318309886f)
20251+#define D3DX_PI ((FLOAT) 3.141592654f)
20252+
20253+/*** PRT Constants ***/
20254+#define D3DXSH_MINORDER 2
20255+#define D3DXSH_MAXORDER 6
20256+
20257+#endif
20258+
20259+
20260+/*FIXME: move over to d3dx9shader.h */
20261+#define D3DXTX_VERSION(_Major,_Minor) (('T' << 24) | ('X' << 16) | ((_Major) << 8) | (_Minor))
20262+
20263+#define D3DXSHADER_AVOID_FLOW_CONTROL
20264+#define D3DXSHADER_DEBUG
20265+#define D3DXSHADER_FORCE_PS_SOFTWARE_NOOPT
20266+#define D3DXSHADER_FORCE_VS_SOFTWARE_NOOPT
20267+#define D3DXSHADER_NO_PRESHADER
20268+#define D3DXSHADER_PACKMATRIX_COLUMNMAJOR
20269+#define D3DXSHADER_PACKMATRIX_ROWMAJOR
20270+#define D3DXSHADER_PARTIALPRECISION
20271+#define D3DXSHADER_PREFER_FLOW_CONTROL
20272+#define D3DXSHADER_SKIPOPTIMIZATION
20273+#define D3DXSHADER_SKIPVALIDATION
20274+/******/
20275+#define D3DXSHADER_DEBUG
20276+#define D3DXSHADER_FORCE_PS_SOFTWARE_NOOPT
20277+#define D3DXSHADER_FORCE_VS_SOFTWARE_NOOPT
20278+#define D3DXSHADER_SKIPVALIDATION
20279+
20280+/*FIXME: move to d3dx9tex.h*/
20281+#define D3DX_CHANNEL_RED
20282+#define D3DX_CHANNEL_BLUE
20283+#define D3DX_CHANNEL_GREEN
20284+#define D3DX_CHANNEL_ALPHA
20285+#define D3DX_CHANNEL_LUMINANCE
20286+
20287+
20288+#define D3DX_FILTER_NONE
20289+#define D3DX_FILTER_POINT
20290+#define D3DX_FILTER_LINEAR
20291+#define D3DX_FILTER_TRIANGLE
20292+#define D3DX_FILTER_BOX
20293+#define D3DX_FILTER_MIRROR_U
20294+#define D3DX_FILTER_MIRROR_V
20295+#define D3DX_FILTER_MIRROR_W
20296+#define D3DX_FILTER_MIRROR
20297+#define D3DX_FILTER_DITHER
20298+#define D3DX_FILTER_SRGB_IN
20299+#define D3DX_FILTER_SRGB_OUT
20300+#define D3DX_FILTER_SRGB
20301+
20302+#define D3DX_NORMALMAP_MIRROR_U
20303+#define D3DX_NORMALMAP_MIRROR_V
20304+#define D3DX_NORMALMAP_MIRROR
20305+#define D3DX_NORMALMAP_INVERTSIGN
20306+#define D3DX_NORMALMAP_COMPUTE_OCCLUSION
20307+
20308+
20309+
20310+#if 0
20311+typedef struct D3DXMESHDATA {
20312+
20313+ D3DXMESHDATATYPE Type;
20314+
20315+ union
20316+ {
20317+ LPD3DXMESH pMesh;
20318+ LPD3DXMESH pPMesh;
20319+ LPD3DXPATCHMESH pPatchMesh;
20320+ }
20321+
20322+} D3DXMESHDATA, *LPD3DXMESHDATA;
20323+#endif
20324+typedef enum _D3DXMESH {
20325+ D3DXMESH_32BIT = 0x001,
20326+ D3DXMESH_DONOTCLIP = 0x002,
20327+ D3DXMESH_POINTS = 0x004,
20328+ D3DXMESH_RTPATCHES = 0x008,
20329+ D3DXMESH_NPATCHES = 0x4000,
20330+ D3DXMESH_VB_SYSTEMMEM = 0x010,
20331+ D3DXMESH_VB_MANAGED = 0x020,
20332+ D3DXMESH_VB_WRITEONLY = 0x040,
20333+ D3DXMESH_VB_DYNAMIC = 0x080,
20334+ D3DXMESH_VB_SOFTWAREPROCESSING = 0x8000,
20335+ D3DXMESH_IB_SYSTEMMEM = 0x100,
20336+ D3DXMESH_IB_MANAGED = 0x200,
20337+ D3DXMESH_IB_WRITEONLY = 0x400,
20338+ D3DXMESH_IB_DYNAMIC = 0x800,
20339+ D3DXMESH_IB_SOFTWAREPROCESSING = 0x10000,
20340+ D3DXMESH_VB_SHARE = 0x1000,
20341+ D3DXMESH_USEHWONLY = 0x2000,
20342+ D3DXMESH_SYSTEMMEM = 0x110,
20343+ D3DXMESH_MANAGED = 0x220,
20344+ D3DXMESH_WRITEONLY = 0x440,
20345+ D3DXMESH_DYNAMIC = 0x880,
20346+ D3DXMESH_SOFTWAREPROCESSING = 0x18000
20347+} D3DXMESH;
20348+#if 0
20349+HRESULT D3DXLoadMeshFromX(
20350+ LPCTSTR pFilename,
20351+ DWORD Options,
20352+ LPDIRECT3DDEVICE9 pDevice,
20353+ LPD3DXBUFFER* ppAdjacency,
20354+ LPD3DXBUFFER* ppMaterials,
20355+ LPD3DXBUFFER* ppEffectInstances,
20356+ DWORD* pNumMaterials,
20357+ LPD3DXMESH* ppMesh
20358+);
20359+#endif
20360+
20361+
20362+/*FIXME: move to d3dx9anim.h */
20363+
20364+typedef enum _D3DXCALLBACK_SEARCH_FLAGS {
20365+ D3DXCALLBACK_SEARCH_EXCLUDING_INITIAL_POSITION = 1,
20366+ D3DXCALLBACK_SEARCH_BEHIND_INITIAL_POSITION = 2,
20367+
20368+ D3DXCALLBACK_FORCE_DWORD = 0x7fffffff
20369+} D3DXCALLBACK_SEARCH_FLAGS;
20370+
20371+typedef enum _D3DXCOMPRESSION_FLAGS {
20372+ D3DXCOMPRESS_DEFAULT = 0,
20373+ D3DXCOMPRESS_FORCE_DWORD = 0x7fffffff
20374+} D3DXCOMPRESSION_FLAGS;
20375+
20376+typedef enum _D3DXEVENT_TYPE {
20377+ D3DXEVENT_TRACKSPEED = 0,
20378+ D3DXEVENT_TRACKWEIGHT = 1,
20379+ D3DXEVENT_TRACKPOSITION = 2,
20380+ D3DXEVENT_TRACKENABLE = 3,
20381+ D3DXEVENT_PRIORITYBLEND = 4,
20382+
20383+ D3DXEVENT_FORCE_DWORD = 0x7fffffff
20384+} D3DXEVENT_TYPE;
20385+
20386+
20387+/*FIXME: move to d3dx9mesh.h*/
20388+
20389+typedef enum _D3DXCLEANTYPE {
20390+ D3DXCLEAN_BACKFACING = 1,
20391+ D3DXCLEAN_BOWTIES = 2,
20392+ D3DXCLEAN_SKINNING = D3DXCLEAN_BACKFACING,
20393+ D3DXCLEAN_OPTIMIZATION = D3DXCLEAN_BACKFACING,
20394+ D3DXCLEAN_SIMPLIFICATION = D3DXCLEAN_BACKFACING | D3DXCLEAN_BOWTIES
20395+} D3DXCLEANTYPE;
20396+
20397+typedef enum _D3DXEFFECTDEFAULTTYPE {
20398+ D3DXEDT_STRING = 1,
20399+ D3DXEDT_FLOATS = 2,
20400+ D3DXEDT_DWORD = 3,
20401+
20402+ D3DXEDT_FORCE_DWORD = 0x7fffffff
20403+} D3DXEFFECTDEFAULTTYPE;
20404+
20405+
20406+
20407+/*****************************************************************************
20408+ * ID3DXBuffer interface
20409+ */
20410+#define INTERFACE ID3DXBuffer
20411+DECLARE_INTERFACE_(ID3DXBuffer,IUnknown)
20412+{
20413+ /*** IUnknown methods ***/
20414+ STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID riid, void** ppvObject) PURE;
20415+ STDMETHOD_(ULONG,AddRef)(THIS) PURE;
20416+ STDMETHOD_(ULONG,Release)(THIS) PURE;
20417+ /*** ID3DXBuffer methods ***/
20418+ STDMETHOD_(LPVOID,GetBufferPointer)(THIS) PURE;
20419+ STDMETHOD_(DWORD,GetBufferSize)(THIS) PURE;
20420+};
20421+#undef INTERFACE
20422+
20423+#if !defined(__cplusplus) || defined(CINTERFACE)
20424+/*** IUnknown methods ***/
20425+#define ID3DXBuffer_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
20426+#define ID3DXBuffer_AddRef(p) (p)->lpVtbl->AddRef(p)
20427+#define ID3DXBuffer_Release(p) (p)->lpVtbl->Release(p)
20428+/*** ID3DXBuffer methods ***/
20429+#define ID3DXBuffer_GetBufferPointer(p) (p)->lpVtbl->GetBufferPointer(p)
20430+#define ID3DXBuffer_GetBufferSize(p) (p)->lpVtbl->GetBufferSize(p)
20431+#endif
20432+#if 1
20433+/*****************************************************************************
20434+ * ID3DXFont interface
20435+ */
20436+#define INTERFACE ID3DXFont
20437+DECLARE_INTERFACE_(ID3DXFont,IUnknown)
20438+{
20439+ /*** IUnknown methods ***/
20440+ STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID riid, void** ppvObject) PURE;
20441+ STDMETHOD_(ULONG,AddRef)(THIS) PURE;
20442+ STDMETHOD_(ULONG,Release)(THIS) PURE;
20443+ /*** ID3DXFont methods ***/
20444+ STDMETHOD(GetDevice)(THIS_ LPDIRECT3DDEVICE9* ppDevice) PURE;
20445+ STDMETHOD(GetLogFont)(THIS_ PLOGFONTA pLogFont) PURE;
20446+ STDMETHOD(Begin)(THIS) PURE;
20447+ STDMETHOD_(INT, DrawTextA)(THIS_ LPCSTR pString, INT Count, LPRECT pRect, DWORD Format, D3DCOLOR Color) PURE;
20448+ STDMETHOD_(INT, DrawTextW)(THIS_ LPCWSTR pString, INT Count, LPRECT pRect, DWORD Format, D3DCOLOR Color) PURE;
20449+ STDMETHOD(End)(THIS) PURE;
20450+ STDMETHOD(OnLostDevice)(THIS) PURE;
20451+ STDMETHOD(OnResetDevice)(THIS) PURE;
20452+};
20453+#undef INTERFACE
20454+
20455+#if !defined(__cplusplus) || defined(CINTERFACE)
20456+/*** IUnknown methods ***/
20457+#define ID3DXFont_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
20458+#define ID3DXFont_AddRef(p) (p)->lpVtbl->AddRef(p)
20459+#define ID3DXFont_Release(p) (p)->lpVtbl->Release(p)
20460+/*** ID3DXFont methods ***/
20461+#define ID3DXFont_GetDevice(p,a) (p)->lpVtbl->GetDevice(p,a)
20462+#define ID3DXFont_GetLogFont(p,a) (p)->lpVtbl->GetLogFont(p,a)
20463+#define ID3DXFont_Begin(p) (p)->lpVtbl->Begin(p)
20464+#define ID3DXFont_DrawTextA(p,a,b,c,d,e)(p)->lpVtbl->DrawText(p,a,b,c,d,e)
20465+#define ID3DXFont_DrawTextW(p,a,b,c,d,e)(p)->lpVtbl->DrawText(p,a,b,c,d,e)
20466+#define ID3DXFont_End(p) (p)->lpVtbl->End(p)
20467+
20468+#define ID3DXFont_OnLostDevice(p) (p)->lpVtbl->OnLostDevice(p)
20469+#define ID3DXFont_OnResetDevice(p) (p)->lpVtbl->OnResetDevice(p)
20470+#endif
20471+
20472+
20473+
20474+#ifndef DrawText
20475+#ifdef UNICODE
20476+#define DrawText DrawTextW
20477+#else
20478+#define DrawText DrawTextA
20479+#endif
20480+#endif
20481+#endif
20482+
20483+#define INTERFACE ID3DXSprite
20484+DECLARE_INTERFACE_(ID3DXSprite, IUnknown)
20485+{
20486+ /** IUnknown **/
20487+ STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE;
20488+ STDMETHOD_(ULONG, AddRef)(THIS) PURE;
20489+ STDMETHOD_(ULONG, Release)(THIS) PURE;
20490+
20491+ /** ID3DXSprite **/
20492+ STDMETHOD(GetDevice)(THIS_ LPDIRECT3DDEVICE9* ppDevice) PURE;
20493+ STDMETHOD(Begin)(THIS) PURE;
20494+ STDMETHOD(Draw)(THIS_ LPDIRECT3DTEXTURE9 pSrcTexture, CONST RECT* pSrcRect, CONST D3DXVECTOR2* pScaling, CONST D3DXVECTOR2* pRotationCenter, FLOAT Rotation, CONST D3DXVECTOR2* pTranslation, D3DCOLOR Color) PURE;
20495+ STDMETHOD(DrawTransform)(THIS_ LPDIRECT3DTEXTURE9 pSrcTexture, CONST RECT* pSrcRect, CONST D3DXMATRIX* pTransform, D3DCOLOR Color) PURE;
20496+ STDMETHOD(End)(THIS) PURE;
20497+ STDMETHOD(OnLostDevice)(THIS) PURE;
20498+ STDMETHOD(OnResetDevice)(THIS) PURE;
20499+};
20500+#undef INTERFACE
20501+
20502+
20503+
20504+#if !defined(__cplusplus) || defined(CINTERFACE)
20505+/*** IUnknown methods ***/
20506+#define ID3DXSprite_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
20507+#define ID3DXSprite_AddRef(p) (p)->lpVtbl->AddRef(p)
20508+#define ID3DXSprite_Release(p) (p)->lpVtbl->Release(p)
20509+/*** ID3DXSprite methods ***/
20510+#define ID3DXSprite_GetDevice(p,a) (p)->lpVtbl->GetDevice(p,a)
20511+#define ID3DXSprite_Begin(p) (p)->lpVtbl->Begin(p)
20512+#define ID3DXSprite_DrawTransform(p,a,b,c,d) (p)->lpVtbl->DrawText(p,a,b,c,d)
20513+#define ID3DXSprite_End(p) (p)->lpVtbl->End(p)
20514+#define ID3DXSprite_OnLostDevice(p) (p)->lpVtbl->OnLostDevice(p)
20515+#define ID3DXSprite_OnResetDevice(p) (p)->lpVtbl->OnResetDevice(p)
20516+#endif
20517+
20518+
20519+
20520+
20521+
20522+typedef struct D3DXFONT_DESCA {
20523+ INT Height;
20524+ UINT Width;
20525+ UINT Weight;
20526+ UINT MipLevels;
20527+ BOOL Italic;
20528+ BYTE CharSet;
20529+ BYTE OutputPrecision;
20530+ BYTE Quality;
20531+ BYTE PitchAndFamily;
20532+ LPCSTR FaceName[LF_FACESIZE];
20533+} D3DXFONT_DESCA;
20534+
20535+typedef struct D3DXFONT_DESCW {
20536+ INT Height;
20537+ UINT Width;
20538+ UINT Weight;
20539+ UINT MipLevels;
20540+ BOOL Italic;
20541+ BYTE CharSet;
20542+ BYTE OutputPrecision;
20543+ BYTE Quality;
20544+ BYTE PitchAndFamily;
20545+ LPCWSTR FaceName[LF_FACESIZE];
20546+} D3DXFONT_DESCW;
20547+
20548+
20549+
20550+
20551+#ifdef UNICODE
20552+typedef D3DXFONT_DESCW D3DXFONT_DESC;
20553+typedef D3DXFONT_DESC* LPD3DXFONT_DESC;
20554+#else
20555+typedef D3DXFONT_DESCA D3DXFONT_DESC;
20556+typedef D3DXFONT_DESC* LPD3DXFONT_DESC;
20557+#endif
20558+
20559+
20560+
20561+
20562+
20563+// {0B8D1536-9EEC-49b0-A5AD-93CF63AFB7C6}
20564+DEFINE_GUID( IID_ID3DXFont,
20565+0xb8d1536, 0x9eec, 0x49b0, 0xa5, 0xad, 0x93, 0xcf, 0x63, 0xaf, 0xb7, 0xc6);
20566+
20567+
20568+#undef INTERFACE
20569+#if 0
20570+#define INTERFACE ID3DXFont
20571+
20572+DECLARE_INTERFACE_(ID3DXFont, IUnknown)
20573+{
20574+ // IUnknown
20575+ STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE;
20576+ STDMETHOD_(ULONG, AddRef)(THIS) PURE;
20577+ STDMETHOD_(ULONG, Release)(THIS) PURE;
20578+
20579+ // ID3DXFont
20580+ STDMETHOD(GetDevice)(THIS_ LPDIRECT3DDEVICE9 *ppDevice) PURE;
20581+ STDMETHOD(GetDescA)(THIS_ D3DXFONT_DESCA *pDesc) PURE;
20582+ STDMETHOD(GetDescW)(THIS_ D3DXFONT_DESCW *pDesc) PURE;
20583+
20584+ STDMETHOD_(HDC, GetDC)(THIS) PURE;
20585+ STDMETHOD(GetGlyphData)(THIS_ UINT Glyph, LPDIRECT3DTEXTURE9 *ppTexture, RECT *pBlackBox, POINT *pCellInc) PURE;
20586+
20587+ STDMETHOD(PreloadCharacters)(THIS_ UINT First, UINT Last) PURE;
20588+ STDMETHOD(PreloadGlyphs)(THIS_ UINT First, UINT Last) PURE;
20589+ STDMETHOD(PreloadTextA)(THIS_ LPCSTR pString, INT Count) PURE;
20590+ STDMETHOD(PreloadTextW)(THIS_ LPCWSTR pString, INT Count) PURE;
20591+
20592+ STDMETHOD_(INT, DrawTextA)(THIS_ LPD3DXSPRITE pSprite, LPCSTR pString, INT Count, LPRECT pRect, DWORD Format, D3DCOLOR Color) PURE;
20593+ STDMETHOD_(INT, DrawTextW)(THIS_ LPD3DXSPRITE pSprite, LPCWSTR pString, INT Count, LPRECT pRect, DWORD Format, D3DCOLOR Color) PURE;
20594+
20595+ STDMETHOD(OnLostDevice)(THIS) PURE;
20596+ STDMETHOD(OnResetDevice)(THIS) PURE;
20597+
20598+#ifdef __cplusplus
20599+#ifdef UNICODE
20600+ HRESULT GetDesc(D3DXFONT_DESCW *pDesc) { return GetDescW(pDesc); }
20601+ HRESULT PreloadText(LPCWSTR pString, INT Count) { return PreloadTextW(pString, Count); }
20602+#else
20603+ HRESULT GetDesc(D3DXFONT_DESCA *pDesc) { return GetDescA(pDesc); }
20604+ HRESULT PreloadText(LPCSTR pString, INT Count) { return PreloadTextA(pString, Count); }
20605+#endif
20606+#endif //__cplusplus
20607+};
20608+#endif
20609+
20610+#ifndef DrawText
20611+#ifdef UNICODE
20612+#define DrawText DrawTextW
20613+#else
20614+#define DrawText DrawTextA
20615+#endif
20616+#endif
20617+
20618+
20619+#ifdef __cplusplus
20620+extern "C" {
20621+#endif //__cplusplus
20622+
20623+
20624+HRESULT WINAPI
20625+ D3DXCreateFontA(
20626+ LPDIRECT3DDEVICE9 pDevice,
20627+ UINT Height,
20628+ UINT Width,
20629+ UINT Weight,
20630+ UINT MipLevels,
20631+ BOOL Italic,
20632+ DWORD CharSet,
20633+ DWORD OutputPrecision,
20634+ DWORD Quality,
20635+ DWORD PitchAndFamily,
20636+ LPCSTR pFaceName,
20637+ LPD3DXFONT* ppFont);
20638+
20639+HRESULT WINAPI
20640+ D3DXCreateFontW(
20641+ LPDIRECT3DDEVICE9 pDevice,
20642+ UINT Height,
20643+ UINT Width,
20644+ UINT Weight,
20645+ UINT MipLevels,
20646+ BOOL Italic,
20647+ DWORD CharSet,
20648+ DWORD OutputPrecision,
20649+ DWORD Quality,
20650+ DWORD PitchAndFamily,
20651+ LPCWSTR pFaceName,
20652+ LPD3DXFONT* ppFont);
20653+
20654+#ifdef UNICODE
20655+#define D3DXCreateFont D3DXCreateFontW
20656+#else
20657+#define D3DXCreateFont D3DXCreateFontA
20658+#endif
20659+
20660+
20661+HRESULT WINAPI
20662+ D3DXCreateFontIndirectA(
20663+ LPDIRECT3DDEVICE9 pDevice,
20664+ CONST D3DXFONT_DESCA* pDesc,
20665+ LPD3DXFONT* ppFont);
20666+
20667+HRESULT WINAPI
20668+ D3DXCreateFontIndirectW(
20669+ LPDIRECT3DDEVICE9 pDevice,
20670+ CONST D3DXFONT_DESCW* pDesc,
20671+ LPD3DXFONT* ppFont);
20672+
20673+#ifdef UNICODE
20674+#define D3DXCreateFontIndirect D3DXCreateFontIndirectW
20675+#else
20676+#define D3DXCreateFontIndirect D3DXCreateFontIndirectA
20677+#endif
20678+
20679+
20680+#ifdef __cplusplus
20681+}
20682+#endif //__cplusplus
20683+
20684+
20685+
20686+/*************************************************************************************
20687+ * Define entrypoints
20688+ */
20689+HRESULT WINAPI D3DXCreateBuffer(DWORD NumBytes, LPD3DXBUFFER* ppBuffer);
20690+#if 0
20691+HRESULT WINAPI D3DXCreateFont(LPDIRECT3DDEVICE9 pDevice , HFONT hFont, LPD3DXFONT* ppFont);
20692+#endif
20693+HRESULT WINAPI D3DXCreateSprite(LPDIRECT3DDEVICE9 pDevice, HFONT hFont, LPD3DXSPRITE* ppSprite);
20694+
20695+
20696+UINT WINAPI D3DXGetFVFVertexSize(DWORD FVF);
20697+HRESULT WINAPI D3DXAssembleShader(LPCVOID pSrcData, UINT SrcDataLen, DWORD Flags,
20698+ LPD3DXBUFFER* ppConstants,
20699+ LPD3DXBUFFER* ppCompiledShader,
20700+ LPD3DXBUFFER* ppCompilationErrors);
20701+HRESULT WINAPI D3DXAssembleShaderFromFileA(LPSTR pSrcFile, DWORD Flags,
20702+ LPD3DXBUFFER* ppConstants,
20703+ LPD3DXBUFFER* ppCompiledShader,
20704+ LPD3DXBUFFER* ppCompilationErrors);
20705+HRESULT WINAPI D3DXAssembleShaderFromFileW(LPSTR pSrcFile, DWORD Flags,
20706+ LPD3DXBUFFER* ppConstants,
20707+ LPD3DXBUFFER* ppCompiledShader,
20708+ LPD3DXBUFFER* ppCompilationErrors);
20709+
20710+#endif /* __WINE_D3DX9CORE_H */
20711+
20712+
20713diff -urN wine.20050419/include/d3dx9math.h wine.20050419.dx9/include/d3dx9math.h
20714--- wine.20050419/include/d3dx9math.h 1969-12-31 17:00:00.000000000 -0700
20715+++ wine.20050419.dx9/include/d3dx9math.h 2005-04-20 01:52:56.000000000 -0600
20716@@ -0,0 +1,1219 @@
20717+
20718+/*
20719+ * Copyright (C) 2005 Oliver Stieber
20720+ *
20721+ * This library is free software; you can redistribute it and/or
20722+ * modify it under the terms of the GNU Lesser General Public
20723+ * License as published by the Free Software Foundation; either
20724+ * version 2.1 of the License, or (at your option) any later version.
20725+ *
20726+ * This library is distributed in the hope that it will be useful,
20727+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
20728+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20729+ * Lesser General Public License for more details.
20730+ *
20731+ * You should have received a copy of the GNU Lesser General Public
20732+ * License along with this library; if not, write to the Free Software
20733+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20734+ */
20735+
20736+
20737+#ifndef __WINE_D3DX9MATH_H
20738+#define __WINE_D3DX9MATH_H
20739+
20740+#define D3DX_PI ((FLOAT) 3.141592654f)
20741+#define D3DX_1BYPI ((FLOAT) 0.318309886f)
20742+
20743+#define D3DXToRadian( degree ) ((degree) * (D3DX_PI / 180.0f))
20744+#define D3DXToDegree( radian ) ((radian) * (180.0f / D3DX_PI))
20745+
20746+
20747+/* *************************************
20748+*
20749+* 16 bit floating point numbers
20750+*
20751+************************************** */
20752+
20753+#define D3DX_16F_DIG 3
20754+#define D3DX_16F_EPSILON 4.8875809e-4f
20755+#define D3DX_16F_MANT_DIG 11
20756+#define D3DX_16F_MAX 6.550400e+004
20757+#define D3DX_16F_MAX_10_EXP 4
20758+#define D3DX_16F_MAX_EXP 15
20759+#define D3DX_16F_MIN 6.1035156e-5f
20760+#define D3DX_16F_MIN_10_EXP (-4)
20761+#define D3DX_16F_MIN_EXP (-12)
20762+#define D3DX_16F_RADIX 2
20763+#define D3DX_16F_ROUNDS 1
20764+
20765+
20766+
20767+/*** PRT Constants ***/
20768+#define D3DXSH_MINORDER 2
20769+#define D3DXSH_MAXORDER 6
20770+
20771+
20772+
20773+typedef struct D3DXFLOAT16
20774+{
20775+#ifdef __cplusplus
20776+public:
20777+ D3DXFLOAT16() {};
20778+ D3DXFLOAT16( FLOAT );
20779+ D3DXFLOAT16( CONST D3DXFLOAT16& );
20780+
20781+ operator FLOAT ();
20782+
20783+ BOOL operator == ( CONST D3DXFLOAT16& ) const;
20784+ BOOL operator != ( CONST D3DXFLOAT16& ) const;
20785+
20786+protected:
20787+#endif //__cplusplus
20788+ WORD value;
20789+} D3DXFLOAT16, *LPD3DXFLOAT16;
20790+
20791+
20792+
20793+/* *************************************
20794+*
20795+* Vectors
20796+*
20797+************************************** */
20798+
20799+typedef struct D3DXVECTOR2
20800+{
20801+#ifdef __cplusplus
20802+public:
20803+ D3DXVECTOR2() {};
20804+ D3DXVECTOR2( CONST FLOAT * );
20805+ D3DXVECTOR2( CONST D3DXFLOAT16 * );
20806+ D3DXVECTOR2( FLOAT x, FLOAT y );
20807+
20808+ operator FLOAT* ();
20809+ operator CONST FLOAT* () const;
20810+
20811+ D3DXVECTOR2& operator += ( CONST D3DXVECTOR2& );
20812+ D3DXVECTOR2& operator -= ( CONST D3DXVECTOR2& );
20813+ D3DXVECTOR2& operator *= ( FLOAT );
20814+ D3DXVECTOR2& operator /= ( FLOAT );
20815+
20816+ D3DXVECTOR2 operator + () const;
20817+ D3DXVECTOR2 operator - () const;
20818+
20819+ D3DXVECTOR2 operator + ( CONST D3DXVECTOR2& ) const;
20820+ D3DXVECTOR2 operator - ( CONST D3DXVECTOR2& ) const;
20821+ D3DXVECTOR2 operator * ( FLOAT ) const;
20822+ D3DXVECTOR2 operator / ( FLOAT ) const;
20823+
20824+ friend D3DXVECTOR2 operator * ( FLOAT, CONST D3DXVECTOR2& );
20825+
20826+ BOOL operator == ( CONST D3DXVECTOR2& ) const;
20827+ BOOL operator != ( CONST D3DXVECTOR2& ) const;
20828+
20829+
20830+public:
20831+#endif /* __cplusplus */
20832+ FLOAT x, y;
20833+} D3DXVECTOR2, *LPD3DXVECTOR2;
20834+
20835+
20836+typedef struct D3DXVECTOR2_16F
20837+{
20838+#ifdef __cplusplus
20839+public:
20840+ D3DXVECTOR2_16F() {};
20841+ D3DXVECTOR2_16F( CONST FLOAT * );
20842+ D3DXVECTOR2_16F( CONST D3DXFLOAT16 * );
20843+ D3DXVECTOR2_16F( CONST D3DXFLOAT16 &x, CONST D3DXFLOAT16 &y );
20844+
20845+ operator D3DXFLOAT16* ();
20846+ operator CONST D3DXFLOAT16* () const;
20847+
20848+ BOOL operator == ( CONST D3DXVECTOR2_16F& ) const;
20849+ BOOL operator != ( CONST D3DXVECTOR2_16F& ) const;
20850+
20851+public:
20852+#endif /* __cplusplus */
20853+ D3DXFLOAT16 x, y;
20854+
20855+} D3DXVECTOR2_16F, *LPD3DXVECTOR2_16F;
20856+
20857+
20858+#ifdef __cplusplus
20859+typedef struct D3DXVECTOR3 : public D3DVECTOR
20860+{
20861+public:
20862+ D3DXVECTOR3() {};
20863+ D3DXVECTOR3( CONST FLOAT * );
20864+ D3DXVECTOR3( CONST D3DVECTOR& );
20865+ D3DXVECTOR3( CONST D3DXFLOAT16 * );
20866+ D3DXVECTOR3( FLOAT x, FLOAT y, FLOAT z );
20867+
20868+ // casting
20869+ operator FLOAT* ();
20870+ operator CONST FLOAT* () const;
20871+
20872+ D3DXVECTOR3& operator += ( CONST D3DXVECTOR3& );
20873+ D3DXVECTOR3& operator -= ( CONST D3DXVECTOR3& );
20874+ D3DXVECTOR3& operator *= ( FLOAT );
20875+ D3DXVECTOR3& operator /= ( FLOAT );
20876+
20877+ D3DXVECTOR3 operator + () const;
20878+ D3DXVECTOR3 operator - () const;
20879+
20880+ D3DXVECTOR3 operator + ( CONST D3DXVECTOR3& ) const;
20881+ D3DXVECTOR3 operator - ( CONST D3DXVECTOR3& ) const;
20882+ D3DXVECTOR3 operator * ( FLOAT ) const;
20883+ D3DXVECTOR3 operator / ( FLOAT ) const;
20884+
20885+ friend D3DXVECTOR3 operator * ( FLOAT, CONST struct D3DXVECTOR3& );
20886+
20887+ BOOL operator == ( CONST D3DXVECTOR3& ) const;
20888+ BOOL operator != ( CONST D3DXVECTOR3& ) const;
20889+
20890+} D3DXVECTOR3, *LPD3DXVECTOR3;
20891+
20892+#else
20893+typedef struct _D3DVECTOR D3DXVECTOR3, *LPD3DXVECTOR3;
20894+#endif /* __cplusplus */
20895+
20896+
20897+typedef struct D3DXVECTOR3_16F
20898+{
20899+#ifdef __cplusplus
20900+public:
20901+ D3DXVECTOR3_16F() {};
20902+ D3DXVECTOR3_16F( CONST FLOAT * );
20903+ D3DXVECTOR3_16F( CONST D3DVECTOR& );
20904+ D3DXVECTOR3_16F( CONST D3DXFLOAT16 * );
20905+ D3DXVECTOR3_16F( CONST D3DXFLOAT16 &x, CONST D3DXFLOAT16 &y, CONST D3DXFLOAT16 &z );
20906+
20907+ operator D3DXFLOAT16* ();
20908+ operator CONST D3DXFLOAT16* () const;
20909+
20910+ BOOL operator == ( CONST D3DXVECTOR3_16F& ) const;
20911+ BOOL operator != ( CONST D3DXVECTOR3_16F& ) const;
20912+
20913+public:
20914+#endif /* __cplusplus */
20915+ D3DXFLOAT16 x, y, z;
20916+
20917+} D3DXVECTOR3_16F, *LPD3DXVECTOR3_16F;
20918+
20919+typedef struct D3DXVECTOR4
20920+{
20921+#ifdef __cplusplus
20922+public:
20923+ D3DXVECTOR4() {};
20924+ D3DXVECTOR4( CONST FLOAT* );
20925+ D3DXVECTOR4( CONST D3DXFLOAT16 * );
20926+ D3DXVECTOR4( FLOAT x, FLOAT y, FLOAT z, FLOAT w );
20927+
20928+ // casting
20929+ operator FLOAT* ();
20930+ operator CONST FLOAT* () const;
20931+
20932+ // assignment operators
20933+ D3DXVECTOR4& operator += ( CONST D3DXVECTOR4& );
20934+ D3DXVECTOR4& operator -= ( CONST D3DXVECTOR4& );
20935+ D3DXVECTOR4& operator *= ( FLOAT );
20936+ D3DXVECTOR4& operator /= ( FLOAT );
20937+
20938+ // unary operators
20939+ D3DXVECTOR4 operator + () const;
20940+ D3DXVECTOR4 operator - () const;
20941+
20942+ // binary operators
20943+ D3DXVECTOR4 operator + ( CONST D3DXVECTOR4& ) const;
20944+ D3DXVECTOR4 operator - ( CONST D3DXVECTOR4& ) const;
20945+ D3DXVECTOR4 operator * ( FLOAT ) const;
20946+ D3DXVECTOR4 operator / ( FLOAT ) const;
20947+
20948+ friend D3DXVECTOR4 operator * ( FLOAT, CONST D3DXVECTOR4& );
20949+
20950+ BOOL operator == ( CONST D3DXVECTOR4& ) const;
20951+ BOOL operator != ( CONST D3DXVECTOR4& ) const;
20952+
20953+public:
20954+#endif //__cplusplus
20955+ FLOAT x, y, z, w;
20956+} D3DXVECTOR4, *LPD3DXVECTOR4;
20957+
20958+
20959+typedef struct D3DXVECTOR4_16F
20960+{
20961+#ifdef __cplusplus
20962+public:
20963+ D3DXVECTOR4_16F() {};
20964+ D3DXVECTOR4_16F( CONST FLOAT * );
20965+ D3DXVECTOR4_16F( CONST D3DXFLOAT16 * );
20966+ D3DXVECTOR4_16F( CONST D3DXFLOAT16& x, CONST D3DXFLOAT16& y, CONST D3DXFLOAT16& z, CONST D3DXFLOAT16& w );
20967+
20968+ // casting
20969+ operator D3DXFLOAT16* ();
20970+ operator CONST D3DXFLOAT16* () const;
20971+
20972+ // binary operators
20973+ BOOL operator == ( CONST D3DXVECTOR4_16F& ) const;
20974+ BOOL operator != ( CONST D3DXVECTOR4_16F& ) const;
20975+
20976+public:
20977+#endif //__cplusplus
20978+ D3DXFLOAT16 x, y, z, w;
20979+
20980+} D3DXVECTOR4_16F, *LPD3DXVECTOR4_16F;
20981+
20982+
20983+
20984+/* *************************************
20985+*
20986+* Martix
20987+*
20988+************************************** */
20989+
20990+#ifdef __cplusplus
20991+typedef struct D3DXMATRIX : public D3DMATRIX
20992+{
20993+public:
20994+ D3DXMATRIX() {};
20995+ D3DXMATRIX( CONST FLOAT * );
20996+ D3DXMATRIX( CONST D3DMATRIX& );
20997+ D3DXMATRIX( CONST D3DXFLOAT16 * );
20998+ D3DXMATRIX( FLOAT _11, FLOAT _12, FLOAT _13, FLOAT _14,
20999+ FLOAT _21, FLOAT _22, FLOAT _23, FLOAT _24,
21000+ FLOAT _31, FLOAT _32, FLOAT _33, FLOAT _34,
21001+ FLOAT _41, FLOAT _42, FLOAT _43, FLOAT _44 );
21002+
21003+
21004+ // access grants
21005+ FLOAT& operator () ( UINT Row, UINT Col );
21006+ FLOAT operator () ( UINT Row, UINT Col ) const;
21007+
21008+ // casting operators
21009+ operator FLOAT* ();
21010+ operator CONST FLOAT* () const;
21011+
21012+ // assignment operators
21013+ D3DXMATRIX& operator *= ( CONST D3DXMATRIX& );
21014+ D3DXMATRIX& operator += ( CONST D3DXMATRIX& );
21015+ D3DXMATRIX& operator -= ( CONST D3DXMATRIX& );
21016+ D3DXMATRIX& operator *= ( FLOAT );
21017+ D3DXMATRIX& operator /= ( FLOAT );
21018+
21019+ // unary operators
21020+ D3DXMATRIX operator + () const;
21021+ D3DXMATRIX operator - () const;
21022+
21023+ // binary operators
21024+ D3DXMATRIX operator * ( CONST D3DXMATRIX& ) const;
21025+ D3DXMATRIX operator + ( CONST D3DXMATRIX& ) const;
21026+ D3DXMATRIX operator - ( CONST D3DXMATRIX& ) const;
21027+ D3DXMATRIX operator * ( FLOAT ) const;
21028+ D3DXMATRIX operator / ( FLOAT ) const;
21029+
21030+ friend D3DXMATRIX operator * ( FLOAT, CONST D3DXMATRIX& );
21031+
21032+ BOOL operator == ( CONST D3DXMATRIX& ) const;
21033+ BOOL operator != ( CONST D3DXMATRIX& ) const;
21034+
21035+} D3DXMATRIX, *LPD3DXMATRIX;
21036+
21037+#else //!__cplusplus
21038+typedef struct _D3DMATRIX D3DXMATRIX, *LPD3DXMATRIX;
21039+#endif //!__cplusplus
21040+
21041+#ifdef __cplusplus
21042+typedef struct _D3DXMATRIXA16 : public D3DXMATRIX
21043+{
21044+ _D3DXMATRIXA16() {}
21045+ _D3DXMATRIXA16( CONST FLOAT * );
21046+ _D3DXMATRIXA16( CONST D3DMATRIX& );
21047+ _D3DXMATRIXA16( CONST D3DXFLOAT16 * );
21048+ _D3DXMATRIXA16( FLOAT _11, FLOAT _12, FLOAT _13, FLOAT _14,
21049+ FLOAT _21, FLOAT _22, FLOAT _23, FLOAT _24,
21050+ FLOAT _31, FLOAT _32, FLOAT _33, FLOAT _34,
21051+ FLOAT _41, FLOAT _42, FLOAT _43, FLOAT _44 );
21052+
21053+ // new operators
21054+ void* operator new ( size_t );
21055+ void* operator new[] ( size_t );
21056+
21057+ // delete operators
21058+ void operator delete ( void* ); // These are NOT virtual; Do not
21059+ void operator delete[] ( void* ); // cast to D3DXMATRIX and delete.
21060+
21061+ // assignment operators
21062+ _D3DXMATRIXA16& operator = ( CONST D3DXMATRIX& );
21063+
21064+} _D3DXMATRIXA16;
21065+
21066+#else //!__cplusplus
21067+typedef D3DXMATRIX _D3DXMATRIXA16;
21068+#endif //!__cplusplus
21069+
21070+#if _MSC_VER >= 1300 // VC7
21071+#define D3DX_ALIGN16 __declspec(align(16))
21072+#else
21073+#define D3DX_ALIGN16 // Earlier compiler may not understand this, do nothing.
21074+#endif
21075+
21076+typedef D3DX_ALIGN16 _D3DXMATRIXA16 D3DXMATRIXA16, *LPD3DXMATRIXA16;
21077+
21078+
21079+
21080+
21081+typedef struct D3DXQUATERNION
21082+{
21083+#ifdef __cplusplus
21084+public:
21085+ D3DXQUATERNION() {}
21086+ D3DXQUATERNION( CONST FLOAT * );
21087+ D3DXQUATERNION( CONST D3DXFLOAT16 * );
21088+ D3DXQUATERNION( FLOAT x, FLOAT y, FLOAT z, FLOAT w );
21089+
21090+ // casting
21091+ operator FLOAT* ();
21092+ operator CONST FLOAT* () const;
21093+
21094+ // assignment operators
21095+ D3DXQUATERNION& operator += ( CONST D3DXQUATERNION& );
21096+ D3DXQUATERNION& operator -= ( CONST D3DXQUATERNION& );
21097+ D3DXQUATERNION& operator *= ( CONST D3DXQUATERNION& );
21098+ D3DXQUATERNION& operator *= ( FLOAT );
21099+ D3DXQUATERNION& operator /= ( FLOAT );
21100+
21101+ // unary operators
21102+ D3DXQUATERNION operator + () const;
21103+ D3DXQUATERNION operator - () const;
21104+
21105+ // binary operators
21106+ D3DXQUATERNION operator + ( CONST D3DXQUATERNION& ) const;
21107+ D3DXQUATERNION operator - ( CONST D3DXQUATERNION& ) const;
21108+ D3DXQUATERNION operator * ( CONST D3DXQUATERNION& ) const;
21109+ D3DXQUATERNION operator * ( FLOAT ) const;
21110+ D3DXQUATERNION operator / ( FLOAT ) const;
21111+
21112+ friend D3DXQUATERNION operator * (FLOAT, CONST D3DXQUATERNION& );
21113+
21114+ BOOL operator == ( CONST D3DXQUATERNION& ) const;
21115+ BOOL operator != ( CONST D3DXQUATERNION& ) const;
21116+
21117+#endif //__cplusplus
21118+ FLOAT x, y, z, w;
21119+} D3DXQUATERNION, *LPD3DXQUATERNION;
21120+
21121+
21122+typedef struct D3DXPLANE
21123+{
21124+#ifdef __cplusplus
21125+public:
21126+ D3DXPLANE() {}
21127+ D3DXPLANE( CONST FLOAT* );
21128+ D3DXPLANE( CONST D3DXFLOAT16* );
21129+ D3DXPLANE( FLOAT a, FLOAT b, FLOAT c, FLOAT d );
21130+
21131+ // casting
21132+ operator FLOAT* ();
21133+ operator CONST FLOAT* () const;
21134+
21135+ // unary operators
21136+ D3DXPLANE operator + () const;
21137+ D3DXPLANE operator - () const;
21138+
21139+ // binary operators
21140+ BOOL operator == ( CONST D3DXPLANE& ) const;
21141+ BOOL operator != ( CONST D3DXPLANE& ) const;
21142+
21143+#endif //__cplusplus
21144+ FLOAT a, b, c, d;
21145+} D3DXPLANE, *LPD3DXPLANE;
21146+
21147+
21148+typedef struct D3DXCOLOR
21149+{
21150+#ifdef __cplusplus
21151+public:
21152+ D3DXCOLOR() {}
21153+ D3DXCOLOR( DWORD argb );
21154+ D3DXCOLOR( CONST FLOAT * );
21155+ D3DXCOLOR( CONST D3DXFLOAT16 * );
21156+ D3DXCOLOR( CONST D3DCOLORVALUE& );
21157+ D3DXCOLOR( FLOAT r, FLOAT g, FLOAT b, FLOAT a );
21158+
21159+ // casting
21160+ operator DWORD () const;
21161+
21162+ operator FLOAT* ();
21163+ operator CONST FLOAT* () const;
21164+
21165+ operator D3DCOLORVALUE* ();
21166+ operator CONST D3DCOLORVALUE* () const;
21167+
21168+ operator D3DCOLORVALUE& ();
21169+ operator CONST D3DCOLORVALUE& () const;
21170+
21171+ // assignment operators
21172+ D3DXCOLOR& operator += ( CONST D3DXCOLOR& );
21173+ D3DXCOLOR& operator -= ( CONST D3DXCOLOR& );
21174+ D3DXCOLOR& operator *= ( FLOAT );
21175+ D3DXCOLOR& operator /= ( FLOAT );
21176+
21177+ // unary operators
21178+ D3DXCOLOR operator + () const;
21179+ D3DXCOLOR operator - () const;
21180+
21181+ // binary operators
21182+ D3DXCOLOR operator + ( CONST D3DXCOLOR& ) const;
21183+ D3DXCOLOR operator - ( CONST D3DXCOLOR& ) const;
21184+ D3DXCOLOR operator * ( FLOAT ) const;
21185+ D3DXCOLOR operator / ( FLOAT ) const;
21186+
21187+ friend D3DXCOLOR operator * (FLOAT, CONST D3DXCOLOR& );
21188+
21189+ BOOL operator == ( CONST D3DXCOLOR& ) const;
21190+ BOOL operator != ( CONST D3DXCOLOR& ) const;
21191+
21192+#endif //__cplusplus
21193+ FLOAT r, g, b, a;
21194+} D3DXCOLOR, *LPD3DXCOLOR;
21195+
21196+
21197+
21198+
21199+#ifdef __cplusplus
21200+extern "C" {
21201+#endif
21202+
21203+// Converts an array 32-bit floats to 16-bit floats
21204+D3DXFLOAT16* WINAPI D3DXFloat32To16Array
21205+ ( D3DXFLOAT16 *pOut, CONST FLOAT *pIn, UINT n );
21206+
21207+// Converts an array 16-bit floats to 32-bit floats
21208+FLOAT* WINAPI D3DXFloat16To32Array
21209+ ( FLOAT *pOut, CONST D3DXFLOAT16 *pIn, UINT n );
21210+
21211+#ifdef __cplusplus
21212+}
21213+#endif
21214+
21215+FLOAT D3DXVec2Length
21216+ ( CONST D3DXVECTOR2 *pV );
21217+
21218+FLOAT D3DXVec2LengthSq
21219+ ( CONST D3DXVECTOR2 *pV );
21220+
21221+FLOAT D3DXVec2Dot
21222+ ( CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2 );
21223+
21224+// Z component of ((x1,y1,0) cross (x2,y2,0))
21225+FLOAT D3DXVec2CCW
21226+ ( CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2 );
21227+
21228+D3DXVECTOR2* D3DXVec2Add
21229+ ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2 );
21230+
21231+D3DXVECTOR2* D3DXVec2Subtract
21232+ ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2 );
21233+
21234+// Minimize each component. x = min(x1, x2), y = min(y1, y2)
21235+D3DXVECTOR2* D3DXVec2Minimize
21236+ ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2 );
21237+
21238+// Maximize each component. x = max(x1, x2), y = max(y1, y2)
21239+D3DXVECTOR2* D3DXVec2Maximize
21240+ ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2 );
21241+
21242+D3DXVECTOR2* D3DXVec2Scale
21243+ ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV, FLOAT s );
21244+
21245+// Linear interpolation. V1 + s(V2-V1)
21246+D3DXVECTOR2* D3DXVec2Lerp
21247+ ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2,
21248+ FLOAT s );
21249+
21250+// non-inline
21251+#ifdef __cplusplus
21252+extern "C" {
21253+#endif
21254+
21255+D3DXVECTOR2* WINAPI D3DXVec2Normalize
21256+ ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV );
21257+
21258+// Hermite interpolation between position V1, tangent T1 (when s == 0)
21259+// and position V2, tangent T2 (when s == 1).
21260+D3DXVECTOR2* WINAPI D3DXVec2Hermite
21261+ ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pT1,
21262+ CONST D3DXVECTOR2 *pV2, CONST D3DXVECTOR2 *pT2, FLOAT s );
21263+
21264+// CatmullRom interpolation between V1 (when s == 0) and V2 (when s == 1)
21265+D3DXVECTOR2* WINAPI D3DXVec2CatmullRom
21266+ ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV0, CONST D3DXVECTOR2 *pV1,
21267+ CONST D3DXVECTOR2 *pV2, CONST D3DXVECTOR2 *pV3, FLOAT s );
21268+
21269+// Barycentric coordinates. V1 + f(V2-V1) + g(V3-V1)
21270+D3DXVECTOR2* WINAPI D3DXVec2BaryCentric
21271+ ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2,
21272+ CONST D3DXVECTOR2 *pV3, FLOAT f, FLOAT g);
21273+
21274+// Transform (x, y, 0, 1) by matrix.
21275+D3DXVECTOR4* WINAPI D3DXVec2Transform
21276+ ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR2 *pV, CONST D3DXMATRIX *pM );
21277+
21278+// Transform (x, y, 0, 1) by matrix, project result back into w=1.
21279+D3DXVECTOR2* WINAPI D3DXVec2TransformCoord
21280+ ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV, CONST D3DXMATRIX *pM );
21281+
21282+// Transform (x, y, 0, 0) by matrix.
21283+D3DXVECTOR2* WINAPI D3DXVec2TransformNormal
21284+ ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV, CONST D3DXMATRIX *pM );
21285+
21286+// Transform Array (x, y, 0, 1) by matrix.
21287+D3DXVECTOR4* WINAPI D3DXVec2TransformArray
21288+ ( D3DXVECTOR4 *pOut, UINT OutStride, CONST D3DXVECTOR2 *pV, UINT VStride, CONST D3DXMATRIX *pM, UINT n);
21289+
21290+// Transform Array (x, y, 0, 1) by matrix, project result back into w=1.
21291+D3DXVECTOR2* WINAPI D3DXVec2TransformCoordArray
21292+ ( D3DXVECTOR2 *pOut, UINT OutStride, CONST D3DXVECTOR2 *pV, UINT VStride, CONST D3DXMATRIX *pM, UINT n );
21293+
21294+// Transform Array (x, y, 0, 0) by matrix.
21295+D3DXVECTOR2* WINAPI D3DXVec2TransformNormalArray
21296+ ( D3DXVECTOR2 *pOut, UINT OutStride, CONST D3DXVECTOR2 *pV, UINT VStride, CONST D3DXMATRIX *pM, UINT n );
21297+
21298+
21299+
21300+#ifdef __cplusplus
21301+}
21302+#endif
21303+
21304+
21305+//--------------------------
21306+// 3D Vector
21307+//--------------------------
21308+
21309+// inline
21310+
21311+FLOAT D3DXVec3Length
21312+ ( CONST D3DXVECTOR3 *pV );
21313+
21314+FLOAT D3DXVec3LengthSq
21315+ ( CONST D3DXVECTOR3 *pV );
21316+
21317+FLOAT D3DXVec3Dot
21318+ ( CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2 );
21319+
21320+D3DXVECTOR3* D3DXVec3Cross
21321+ ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2 );
21322+
21323+D3DXVECTOR3* D3DXVec3Add
21324+ ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2 );
21325+
21326+D3DXVECTOR3* D3DXVec3Subtract
21327+ ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2 );
21328+
21329+// Minimize each component. x = min(x1, x2), y = min(y1, y2), ...
21330+D3DXVECTOR3* D3DXVec3Minimize
21331+ ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2 );
21332+
21333+// Maximize each component. x = max(x1, x2), y = max(y1, y2), ...
21334+D3DXVECTOR3* D3DXVec3Maximize
21335+ ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2 );
21336+
21337+D3DXVECTOR3* D3DXVec3Scale
21338+ ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV, FLOAT s);
21339+
21340+// Linear interpolation. V1 + s(V2-V1)
21341+D3DXVECTOR3* D3DXVec3Lerp
21342+ ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2,
21343+ FLOAT s );
21344+
21345+// non-inline
21346+#ifdef __cplusplus
21347+extern "C" {
21348+#endif
21349+
21350+D3DXVECTOR3* WINAPI D3DXVec3Normalize
21351+ ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV );
21352+
21353+// Hermite interpolation between position V1, tangent T1 (when s == 0)
21354+// and position V2, tangent T2 (when s == 1).
21355+D3DXVECTOR3* WINAPI D3DXVec3Hermite
21356+ ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pT1,
21357+ CONST D3DXVECTOR3 *pV2, CONST D3DXVECTOR3 *pT2, FLOAT s );
21358+
21359+// CatmullRom interpolation between V1 (when s == 0) and V2 (when s == 1)
21360+D3DXVECTOR3* WINAPI D3DXVec3CatmullRom
21361+ ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV0, CONST D3DXVECTOR3 *pV1,
21362+ CONST D3DXVECTOR3 *pV2, CONST D3DXVECTOR3 *pV3, FLOAT s );
21363+
21364+// Barycentric coordinates. V1 + f(V2-V1) + g(V3-V1)
21365+D3DXVECTOR3* WINAPI D3DXVec3BaryCentric
21366+ ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2,
21367+ CONST D3DXVECTOR3 *pV3, FLOAT f, FLOAT g);
21368+
21369+// Transform (x, y, z, 1) by matrix.
21370+D3DXVECTOR4* WINAPI D3DXVec3Transform
21371+ ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR3 *pV, CONST D3DXMATRIX *pM );
21372+
21373+// Transform (x, y, z, 1) by matrix, project result back into w=1.
21374+D3DXVECTOR3* WINAPI D3DXVec3TransformCoord
21375+ ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV, CONST D3DXMATRIX *pM );
21376+
21377+// Transform (x, y, z, 0) by matrix. If you transforming a normal by a
21378+// non-affine matrix, the matrix you pass to this function should be the
21379+// transpose of the inverse of the matrix you would use to transform a coord.
21380+D3DXVECTOR3* WINAPI D3DXVec3TransformNormal
21381+ ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV, CONST D3DXMATRIX *pM );
21382+
21383+
21384+// Transform Array (x, y, z, 1) by matrix.
21385+D3DXVECTOR4* WINAPI D3DXVec3TransformArray
21386+ ( D3DXVECTOR4 *pOut, UINT OutStride, CONST D3DXVECTOR3 *pV, UINT VStride, CONST D3DXMATRIX *pM, UINT n );
21387+
21388+// Transform Array (x, y, z, 1) by matrix, project result back into w=1.
21389+D3DXVECTOR3* WINAPI D3DXVec3TransformCoordArray
21390+ ( D3DXVECTOR3 *pOut, UINT OutStride, CONST D3DXVECTOR3 *pV, UINT VStride, CONST D3DXMATRIX *pM, UINT n );
21391+
21392+// Transform (x, y, z, 0) by matrix. If you transforming a normal by a
21393+// non-affine matrix, the matrix you pass to this function should be the
21394+// transpose of the inverse of the matrix you would use to transform a coord.
21395+D3DXVECTOR3* WINAPI D3DXVec3TransformNormalArray
21396+ ( D3DXVECTOR3 *pOut, UINT OutStride, CONST D3DXVECTOR3 *pV, UINT VStride, CONST D3DXMATRIX *pM, UINT n );
21397+
21398+// Project vector from object space into screen space
21399+D3DXVECTOR3* WINAPI D3DXVec3Project
21400+ ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV, CONST D3DVIEWPORT9 *pViewport,
21401+ CONST D3DXMATRIX *pProjection, CONST D3DXMATRIX *pView, CONST D3DXMATRIX *pWorld);
21402+
21403+// Project vector from screen space into object space
21404+D3DXVECTOR3* WINAPI D3DXVec3Unproject
21405+ ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV, CONST D3DVIEWPORT9 *pViewport,
21406+ CONST D3DXMATRIX *pProjection, CONST D3DXMATRIX *pView, CONST D3DXMATRIX *pWorld);
21407+
21408+// Project vector Array from object space into screen space
21409+D3DXVECTOR3* WINAPI D3DXVec3ProjectArray
21410+ ( D3DXVECTOR3 *pOut, UINT OutStride,CONST D3DXVECTOR3 *pV, UINT VStride,CONST D3DVIEWPORT9 *pViewport,
21411+ CONST D3DXMATRIX *pProjection, CONST D3DXMATRIX *pView, CONST D3DXMATRIX *pWorld, UINT n);
21412+
21413+// Project vector Array from screen space into object space
21414+D3DXVECTOR3* WINAPI D3DXVec3UnprojectArray
21415+ ( D3DXVECTOR3 *pOut, UINT OutStride, CONST D3DXVECTOR3 *pV, UINT VStride, CONST D3DVIEWPORT9 *pViewport,
21416+ CONST D3DXMATRIX *pProjection, CONST D3DXMATRIX *pView, CONST D3DXMATRIX *pWorld, UINT n);
21417+
21418+
21419+#ifdef __cplusplus
21420+}
21421+#endif
21422+
21423+
21424+
21425+//--------------------------
21426+// 4D Vector
21427+//--------------------------
21428+
21429+// inline
21430+
21431+FLOAT D3DXVec4Length
21432+ ( CONST D3DXVECTOR4 *pV );
21433+
21434+FLOAT D3DXVec4LengthSq
21435+ ( CONST D3DXVECTOR4 *pV );
21436+
21437+FLOAT D3DXVec4Dot
21438+ ( CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pV2 );
21439+
21440+D3DXVECTOR4* D3DXVec4Add
21441+ ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pV2);
21442+
21443+D3DXVECTOR4* D3DXVec4Subtract
21444+ ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pV2);
21445+
21446+// Minimize each component. x = min(x1, x2), y = min(y1, y2), ...
21447+D3DXVECTOR4* D3DXVec4Minimize
21448+ ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pV2);
21449+
21450+// Maximize each component. x = max(x1, x2), y = max(y1, y2), ...
21451+D3DXVECTOR4* D3DXVec4Maximize
21452+ ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pV2);
21453+
21454+D3DXVECTOR4* D3DXVec4Scale
21455+ ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV, FLOAT s);
21456+
21457+// Linear interpolation. V1 + s(V2-V1)
21458+D3DXVECTOR4* D3DXVec4Lerp
21459+ ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pV2,
21460+ FLOAT s );
21461+
21462+// non-inline
21463+#ifdef __cplusplus
21464+extern "C" {
21465+#endif
21466+
21467+// Cross-product in 4 dimensions.
21468+D3DXVECTOR4* WINAPI D3DXVec4Cross
21469+ ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pV2,
21470+ CONST D3DXVECTOR4 *pV3);
21471+
21472+D3DXVECTOR4* WINAPI D3DXVec4Normalize
21473+ ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV );
21474+
21475+// Hermite interpolation between position V1, tangent T1 (when s == 0)
21476+// and position V2, tangent T2 (when s == 1).
21477+D3DXVECTOR4* WINAPI D3DXVec4Hermite
21478+ ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pT1,
21479+ CONST D3DXVECTOR4 *pV2, CONST D3DXVECTOR4 *pT2, FLOAT s );
21480+
21481+// CatmullRom interpolation between V1 (when s == 0) and V2 (when s == 1)
21482+D3DXVECTOR4* WINAPI D3DXVec4CatmullRom
21483+ ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV0, CONST D3DXVECTOR4 *pV1,
21484+ CONST D3DXVECTOR4 *pV2, CONST D3DXVECTOR4 *pV3, FLOAT s );
21485+
21486+// Barycentric coordinates. V1 + f(V2-V1) + g(V3-V1)
21487+D3DXVECTOR4* WINAPI D3DXVec4BaryCentric
21488+ ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pV2,
21489+ CONST D3DXVECTOR4 *pV3, FLOAT f, FLOAT g);
21490+
21491+// Transform vector by matrix.
21492+D3DXVECTOR4* WINAPI D3DXVec4Transform
21493+ ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV, CONST D3DXMATRIX *pM );
21494+
21495+// Transform vector array by matrix.
21496+D3DXVECTOR4* WINAPI D3DXVec4TransformArray
21497+ ( D3DXVECTOR4 *pOut, UINT OutStride, CONST D3DXVECTOR4 *pV, UINT VStride, CONST D3DXMATRIX *pM, UINT n );
21498+
21499+#ifdef __cplusplus
21500+}
21501+#endif
21502+
21503+
21504+//--------------------------
21505+// 4D Matrix
21506+//--------------------------
21507+
21508+// inline
21509+
21510+
21511+
21512+inline static D3DXMATRIX* D3DXMatrixIdentity ( D3DXMATRIX *pOut ){
21513+
21514+ pOut->_11 = 1;
21515+ pOut->_12 = 0;
21516+ pOut->_13 = 0;
21517+ pOut->_14 = 0;
21518+
21519+ pOut->_21 = 0;
21520+ pOut->_22 = 1;
21521+ pOut->_23 = 0;
21522+ pOut->_24 = 0;
21523+
21524+ pOut->_31 = 0;
21525+ pOut->_32 = 1;
21526+ pOut->_33 = 0;
21527+ pOut->_34 = 0;
21528+
21529+ pOut->_41 = 0;
21530+ pOut->_42 = 0;
21531+ pOut->_43 = 0;
21532+ pOut->_44 = 1;
21533+
21534+ return pOut;
21535+
21536+}
21537+
21538+inline static BOOL D3DXMatrixIsIdentity(
21539+ CONST D3DXMATRIX *pM
21540+){
21541+return (pM->_11 == 1 &&
21542+ pM->_12 == 0 &&
21543+ pM->_13 == 0 &&
21544+ pM->_14 == 0 &&
21545+ pM->_21 == 0 &&
21546+ pM->_22 == 1 &&
21547+ pM->_23 == 0 &&
21548+ pM->_24 == 0 &&
21549+ pM->_31 == 0 &&
21550+ pM->_32 == 0 &&
21551+ pM->_33 == 1 &&
21552+ pM->_34 == 0 &&
21553+ pM->_41 == 0 &&
21554+ pM->_42 == 0 &&
21555+ pM->_43 == 0 &&
21556+ pM->_44 == 1) ? TRUE:FALSE;
21557+
21558+}
21559+
21560+// non-inline
21561+#ifdef __cplusplus
21562+extern "C" {
21563+#endif
21564+
21565+FLOAT WINAPI D3DXMatrixDeterminant
21566+ ( CONST D3DXMATRIX *pM );
21567+
21568+D3DXMATRIX* WINAPI D3DXMatrixTranspose
21569+ ( D3DXMATRIX *pOut, CONST D3DXMATRIX *pM );
21570+
21571+// Matrix multiplication. The result represents the transformation M2
21572+// followed by the transformation M1. (Out = M1 * M2)
21573+D3DXMATRIX* WINAPI D3DXMatrixMultiply
21574+ ( D3DXMATRIX *pOut, CONST D3DXMATRIX *pM1, CONST D3DXMATRIX *pM2 );
21575+
21576+// Matrix multiplication, followed by a transpose. (Out = T(M1 * M2))
21577+D3DXMATRIX* WINAPI D3DXMatrixMultiplyTranspose
21578+ ( D3DXMATRIX *pOut, CONST D3DXMATRIX *pM1, CONST D3DXMATRIX *pM2 );
21579+
21580+// Calculate inverse of matrix. Inversion my fail, in which case NULL will
21581+// be returned. The determinant of pM is also returned it pfDeterminant
21582+// is non-NULL.
21583+D3DXMATRIX* WINAPI D3DXMatrixInverse
21584+ ( D3DXMATRIX *pOut, FLOAT *pDeterminant, CONST D3DXMATRIX *pM );
21585+
21586+// Build a matrix which scales by (sx, sy, sz)
21587+D3DXMATRIX* WINAPI D3DXMatrixScaling
21588+ ( D3DXMATRIX *pOut, FLOAT sx, FLOAT sy, FLOAT sz );
21589+
21590+// Build a matrix which translates by (x, y, z)
21591+D3DXMATRIX* WINAPI D3DXMatrixTranslation
21592+ ( D3DXMATRIX *pOut, FLOAT x, FLOAT y, FLOAT z );
21593+
21594+// Build a matrix which rotates around the X axis
21595+D3DXMATRIX* WINAPI D3DXMatrixRotationX
21596+ ( D3DXMATRIX *pOut, FLOAT Angle );
21597+
21598+// Build a matrix which rotates around the Y axis
21599+D3DXMATRIX* WINAPI D3DXMatrixRotationY
21600+ ( D3DXMATRIX *pOut, FLOAT Angle );
21601+
21602+// Build a matrix which rotates around the Z axis
21603+D3DXMATRIX* WINAPI D3DXMatrixRotationZ
21604+ ( D3DXMATRIX *pOut, FLOAT Angle );
21605+
21606+// Build a matrix which rotates around an arbitrary axis
21607+D3DXMATRIX* WINAPI D3DXMatrixRotationAxis
21608+ ( D3DXMATRIX *pOut, CONST D3DXVECTOR3 *pV, FLOAT Angle );
21609+
21610+// Build a matrix from a quaternion
21611+D3DXMATRIX* WINAPI D3DXMatrixRotationQuaternion
21612+ ( D3DXMATRIX *pOut, CONST D3DXQUATERNION *pQ);
21613+
21614+// Yaw around the Y axis, a pitch around the X axis,
21615+// and a roll around the Z axis.
21616+D3DXMATRIX* WINAPI D3DXMatrixRotationYawPitchRoll
21617+ ( D3DXMATRIX *pOut, FLOAT Yaw, FLOAT Pitch, FLOAT Roll );
21618+
21619+
21620+// Build transformation matrix. NULL arguments are treated as identity.
21621+// Mout = Msc-1 * Msr-1 * Ms * Msr * Msc * Mrc-1 * Mr * Mrc * Mt
21622+D3DXMATRIX* WINAPI D3DXMatrixTransformation
21623+ ( D3DXMATRIX *pOut, CONST D3DXVECTOR3 *pScalingCenter,
21624+ CONST D3DXQUATERNION *pScalingRotation, CONST D3DXVECTOR3 *pScaling,
21625+ CONST D3DXVECTOR3 *pRotationCenter, CONST D3DXQUATERNION *pRotation,
21626+ CONST D3DXVECTOR3 *pTranslation);
21627+
21628+// Build affine transformation matrix. NULL arguments are treated as identity.
21629+// Mout = Ms * Mrc-1 * Mr * Mrc * Mt
21630+D3DXMATRIX* WINAPI D3DXMatrixAffineTransformation
21631+ ( D3DXMATRIX *pOut, FLOAT Scaling, CONST D3DXVECTOR3 *pRotationCenter,
21632+ CONST D3DXQUATERNION *pRotation, CONST D3DXVECTOR3 *pTranslation);
21633+
21634+// Build a lookat matrix. (right-handed)
21635+D3DXMATRIX* WINAPI D3DXMatrixLookAtRH
21636+ ( D3DXMATRIX *pOut, CONST D3DXVECTOR3 *pEye, CONST D3DXVECTOR3 *pAt,
21637+ CONST D3DXVECTOR3 *pUp );
21638+
21639+// Build a lookat matrix. (left-handed)
21640+D3DXMATRIX* WINAPI D3DXMatrixLookAtLH
21641+ ( D3DXMATRIX *pOut, CONST D3DXVECTOR3 *pEye, CONST D3DXVECTOR3 *pAt,
21642+ CONST D3DXVECTOR3 *pUp );
21643+
21644+// Build a perspective projection matrix. (right-handed)
21645+D3DXMATRIX* WINAPI D3DXMatrixPerspectiveRH
21646+ ( D3DXMATRIX *pOut, FLOAT w, FLOAT h, FLOAT zn, FLOAT zf );
21647+
21648+// Build a perspective projection matrix. (left-handed)
21649+D3DXMATRIX* WINAPI D3DXMatrixPerspectiveLH
21650+ ( D3DXMATRIX *pOut, FLOAT w, FLOAT h, FLOAT zn, FLOAT zf );
21651+
21652+// Build a perspective projection matrix. (right-handed)
21653+D3DXMATRIX* WINAPI D3DXMatrixPerspectiveFovRH
21654+ ( D3DXMATRIX *pOut, FLOAT fovy, FLOAT Aspect, FLOAT zn, FLOAT zf );
21655+
21656+// Build a perspective projection matrix. (left-handed)
21657+D3DXMATRIX* WINAPI D3DXMatrixPerspectiveFovLH
21658+ ( D3DXMATRIX *pOut, FLOAT fovy, FLOAT Aspect, FLOAT zn, FLOAT zf );
21659+
21660+// Build a perspective projection matrix. (right-handed)
21661+D3DXMATRIX* WINAPI D3DXMatrixPerspectiveOffCenterRH
21662+ ( D3DXMATRIX *pOut, FLOAT l, FLOAT r, FLOAT b, FLOAT t, FLOAT zn,
21663+ FLOAT zf );
21664+
21665+// Build a perspective projection matrix. (left-handed)
21666+D3DXMATRIX* WINAPI D3DXMatrixPerspectiveOffCenterLH
21667+ ( D3DXMATRIX *pOut, FLOAT l, FLOAT r, FLOAT b, FLOAT t, FLOAT zn,
21668+ FLOAT zf );
21669+
21670+// Build an ortho projection matrix. (right-handed)
21671+D3DXMATRIX* WINAPI D3DXMatrixOrthoRH
21672+ ( D3DXMATRIX *pOut, FLOAT w, FLOAT h, FLOAT zn, FLOAT zf );
21673+
21674+// Build an ortho projection matrix. (left-handed)
21675+D3DXMATRIX* WINAPI D3DXMatrixOrthoLH
21676+ ( D3DXMATRIX *pOut, FLOAT w, FLOAT h, FLOAT zn, FLOAT zf );
21677+
21678+// Build an ortho projection matrix. (right-handed)
21679+D3DXMATRIX* WINAPI D3DXMatrixOrthoOffCenterRH
21680+ ( D3DXMATRIX *pOut, FLOAT l, FLOAT r, FLOAT b, FLOAT t, FLOAT zn,
21681+ FLOAT zf );
21682+
21683+// Build an ortho projection matrix. (left-handed)
21684+D3DXMATRIX* WINAPI D3DXMatrixOrthoOffCenterLH
21685+ ( D3DXMATRIX *pOut, FLOAT l, FLOAT r, FLOAT b, FLOAT t, FLOAT zn,
21686+ FLOAT zf );
21687+
21688+// Build a matrix which flattens geometry into a plane, as if casting
21689+// a shadow from a light.
21690+D3DXMATRIX* WINAPI D3DXMatrixShadow
21691+ ( D3DXMATRIX *pOut, CONST D3DXVECTOR4 *pLight,
21692+ CONST D3DXPLANE *pPlane );
21693+
21694+// Build a matrix which reflects the coordinate system about a plane
21695+D3DXMATRIX* WINAPI D3DXMatrixReflect
21696+ ( D3DXMATRIX *pOut, CONST D3DXPLANE *pPlane );
21697+
21698+#ifdef __cplusplus
21699+}
21700+#endif
21701+
21702+
21703+//--------------------------
21704+// Quaternion
21705+//--------------------------
21706+
21707+// inline
21708+
21709+FLOAT D3DXQuaternionLength
21710+ ( CONST D3DXQUATERNION *pQ );
21711+
21712+// Length squared, or "norm"
21713+FLOAT D3DXQuaternionLengthSq
21714+ ( CONST D3DXQUATERNION *pQ );
21715+
21716+FLOAT D3DXQuaternionDot
21717+ ( CONST D3DXQUATERNION *pQ1, CONST D3DXQUATERNION *pQ2 );
21718+
21719+// (0, 0, 0, 1)
21720+D3DXQUATERNION* D3DXQuaternionIdentity
21721+ ( D3DXQUATERNION *pOut );
21722+
21723+BOOL D3DXQuaternionIsIdentity
21724+ ( CONST D3DXQUATERNION *pQ );
21725+
21726+// (-x, -y, -z, w)
21727+D3DXQUATERNION* D3DXQuaternionConjugate
21728+ ( D3DXQUATERNION *pOut, CONST D3DXQUATERNION *pQ );
21729+
21730+
21731+// non-inline
21732+#ifdef __cplusplus
21733+extern "C" {
21734+#endif
21735+
21736+// Compute a quaternin's axis and angle of rotation. Expects unit quaternions.
21737+void WINAPI D3DXQuaternionToAxisAngle
21738+ ( CONST D3DXQUATERNION *pQ, D3DXVECTOR3 *pAxis, FLOAT *pAngle );
21739+
21740+// Build a quaternion from a rotation matrix.
21741+D3DXQUATERNION* WINAPI D3DXQuaternionRotationMatrix
21742+ ( D3DXQUATERNION *pOut, CONST D3DXMATRIX *pM);
21743+
21744+// Rotation about arbitrary axis.
21745+D3DXQUATERNION* WINAPI D3DXQuaternionRotationAxis
21746+ ( D3DXQUATERNION *pOut, CONST D3DXVECTOR3 *pV, FLOAT Angle );
21747+
21748+// Yaw around the Y axis, a pitch around the X axis,
21749+// and a roll around the Z axis.
21750+D3DXQUATERNION* WINAPI D3DXQuaternionRotationYawPitchRoll
21751+ ( D3DXQUATERNION *pOut, FLOAT Yaw, FLOAT Pitch, FLOAT Roll );
21752+
21753+// Quaternion multiplication. The result represents the rotation Q2
21754+// followed by the rotation Q1. (Out = Q2 * Q1)
21755+D3DXQUATERNION* WINAPI D3DXQuaternionMultiply
21756+ ( D3DXQUATERNION *pOut, CONST D3DXQUATERNION *pQ1,
21757+ CONST D3DXQUATERNION *pQ2 );
21758+
21759+D3DXQUATERNION* WINAPI D3DXQuaternionNormalize
21760+ ( D3DXQUATERNION *pOut, CONST D3DXQUATERNION *pQ );
21761+
21762+// Conjugate and re-norm
21763+D3DXQUATERNION* WINAPI D3DXQuaternionInverse
21764+ ( D3DXQUATERNION *pOut, CONST D3DXQUATERNION *pQ );
21765+
21766+// Expects unit quaternions.
21767+// if q = (cos(theta), sin(theta) * v); ln(q) = (0, theta * v)
21768+D3DXQUATERNION* WINAPI D3DXQuaternionLn
21769+ ( D3DXQUATERNION *pOut, CONST D3DXQUATERNION *pQ );
21770+
21771+// Expects pure quaternions. (w == 0) w is ignored in calculation.
21772+// if q = (0, theta * v); exp(q) = (cos(theta), sin(theta) * v)
21773+D3DXQUATERNION* WINAPI D3DXQuaternionExp
21774+ ( D3DXQUATERNION *pOut, CONST D3DXQUATERNION *pQ );
21775+
21776+// Spherical linear interpolation between Q1 (t == 0) and Q2 (t == 1).
21777+// Expects unit quaternions.
21778+D3DXQUATERNION* WINAPI D3DXQuaternionSlerp
21779+ ( D3DXQUATERNION *pOut, CONST D3DXQUATERNION *pQ1,
21780+ CONST D3DXQUATERNION *pQ2, FLOAT t );
21781+
21782+// Spherical quadrangle interpolation.
21783+// Slerp(Slerp(Q1, C, t), Slerp(A, B, t), 2t(1-t))
21784+D3DXQUATERNION* WINAPI D3DXQuaternionSquad
21785+ ( D3DXQUATERNION *pOut, CONST D3DXQUATERNION *pQ1,
21786+ CONST D3DXQUATERNION *pA, CONST D3DXQUATERNION *pB,
21787+ CONST D3DXQUATERNION *pC, FLOAT t );
21788+
21789+// Setup control points for spherical quadrangle interpolation
21790+// from Q1 to Q2. The control points are chosen in such a way
21791+// to ensure the continuity of tangents with adjacent segments.
21792+void WINAPI D3DXQuaternionSquadSetup
21793+ ( D3DXQUATERNION *pAOut, D3DXQUATERNION *pBOut, D3DXQUATERNION *pCOut,
21794+ CONST D3DXQUATERNION *pQ0, CONST D3DXQUATERNION *pQ1,
21795+ CONST D3DXQUATERNION *pQ2, CONST D3DXQUATERNION *pQ3 );
21796+
21797+// Barycentric interpolation.
21798+// Slerp(Slerp(Q1, Q2, f+g), Slerp(Q1, Q3, f+g), g/(f+g))
21799+D3DXQUATERNION* WINAPI D3DXQuaternionBaryCentric
21800+ ( D3DXQUATERNION *pOut, CONST D3DXQUATERNION *pQ1,
21801+ CONST D3DXQUATERNION *pQ2, CONST D3DXQUATERNION *pQ3,
21802+ FLOAT f, FLOAT g );
21803+
21804+#ifdef __cplusplus
21805+}
21806+#endif
21807+
21808+
21809+//--------------------------
21810+// Plane
21811+//--------------------------
21812+
21813+// inline
21814+
21815+// ax + by + cz + dw
21816+FLOAT D3DXPlaneDot
21817+ ( CONST D3DXPLANE *pP, CONST D3DXVECTOR4 *pV);
21818+
21819+// ax + by + cz + d
21820+FLOAT D3DXPlaneDotCoord
21821+ ( CONST D3DXPLANE *pP, CONST D3DXVECTOR3 *pV);
21822+
21823+// ax + by + cz
21824+FLOAT D3DXPlaneDotNormal
21825+ ( CONST D3DXPLANE *pP, CONST D3DXVECTOR3 *pV);
21826+
21827+// non-inline
21828+#ifdef __cplusplus
21829+extern "C" {
21830+#endif
21831+
21832+// Normalize plane (so that |a,b,c| == 1)
21833+D3DXPLANE* WINAPI D3DXPlaneNormalize
21834+ ( D3DXPLANE *pOut, CONST D3DXPLANE *pP);
21835+
21836+// Find the intersection between a plane and a line. If the line is
21837+// parallel to the plane, NULL is returned.
21838+D3DXVECTOR3* WINAPI D3DXPlaneIntersectLine
21839+ ( D3DXVECTOR3 *pOut, CONST D3DXPLANE *pP, CONST D3DXVECTOR3 *pV1,
21840+ CONST D3DXVECTOR3 *pV2);
21841+
21842+// Construct a plane from a point and a normal
21843+D3DXPLANE* WINAPI D3DXPlaneFromPointNormal
21844+ ( D3DXPLANE *pOut, CONST D3DXVECTOR3 *pPoint, CONST D3DXVECTOR3 *pNormal);
21845+
21846+// Construct a plane from 3 points
21847+D3DXPLANE* WINAPI D3DXPlaneFromPoints
21848+ ( D3DXPLANE *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2,
21849+ CONST D3DXVECTOR3 *pV3);
21850+
21851+// Transform a plane by a matrix. The vector (a,b,c) must be normal.
21852+// M should be the inverse transpose of the transformation desired.
21853+D3DXPLANE* WINAPI D3DXPlaneTransform
21854+ ( D3DXPLANE *pOut, CONST D3DXPLANE *pP, CONST D3DXMATRIX *pM );
21855+
21856+// Transform an array of planes by a matrix. The vectors (a,b,c) must be normal.
21857+// M should be the inverse transpose of the transformation desired.
21858+D3DXPLANE* WINAPI D3DXPlaneTransformArray
21859+ ( D3DXPLANE *pOut, UINT OutStride, CONST D3DXPLANE *pP, UINT PStride, CONST D3DXMATRIX *pM, UINT n );
21860+
21861+#ifdef __cplusplus
21862+}
21863+#endif
21864+
21865+
21866+//--------------------------
21867+// Color
21868+//--------------------------
21869+
21870+// inline
21871+
21872+// (1-r, 1-g, 1-b, a)
21873+D3DXCOLOR* D3DXColorNegative
21874+ (D3DXCOLOR *pOut, CONST D3DXCOLOR *pC);
21875+
21876+D3DXCOLOR* D3DXColorAdd
21877+ (D3DXCOLOR *pOut, CONST D3DXCOLOR *pC1, CONST D3DXCOLOR *pC2);
21878+
21879+D3DXCOLOR* D3DXColorSubtract
21880+ (D3DXCOLOR *pOut, CONST D3DXCOLOR *pC1, CONST D3DXCOLOR *pC2);
21881+
21882+D3DXCOLOR* D3DXColorScale
21883+ (D3DXCOLOR *pOut, CONST D3DXCOLOR *pC, FLOAT s);
21884+
21885+// (r1*r2, g1*g2, b1*b2, a1*a2)
21886+D3DXCOLOR* D3DXColorModulate
21887+ (D3DXCOLOR *pOut, CONST D3DXCOLOR *pC1, CONST D3DXCOLOR *pC2);
21888+
21889+// Linear interpolation of r,g,b, and a. C1 + s(C2-C1)
21890+D3DXCOLOR* D3DXColorLerp
21891+ (D3DXCOLOR *pOut, CONST D3DXCOLOR *pC1, CONST D3DXCOLOR *pC2, FLOAT s);
21892+
21893+// non-inline
21894+#ifdef __cplusplus
21895+extern "C" {
21896+#endif
21897+
21898+// Interpolate r,g,b between desaturated color and color.
21899+// DesaturatedColor + s(Color - DesaturatedColor)
21900+D3DXCOLOR* WINAPI D3DXColorAdjustSaturation
21901+ (D3DXCOLOR *pOut, CONST D3DXCOLOR *pC, FLOAT s);
21902+
21903+// Interpolate r,g,b between 50% grey and color. Grey + s(Color - Grey)
21904+D3DXCOLOR* WINAPI D3DXColorAdjustContrast
21905+ (D3DXCOLOR *pOut, CONST D3DXCOLOR *pC, FLOAT c);
21906+
21907+#ifdef __cplusplus
21908+}
21909+#endif
21910+
21911+
21912+
21913+
21914+//--------------------------
21915+// Misc
21916+//--------------------------
21917+
21918+#ifdef __cplusplus
21919+extern "C" {
21920+#endif
21921+
21922+// Calculate Fresnel term given the cosine of theta (likely obtained by
21923+// taking the dot of two normals), and the refraction index of the material.
21924+FLOAT WINAPI D3DXFresnelTerm
21925+ (FLOAT CosTheta, FLOAT RefractionIndex);
21926+
21927+#ifdef __cplusplus
21928+}
21929+#endif
21930+
21931+
21932+
21933+
21934+
21935+#endif /*__WINE_D3DX9MATH_H*/
21936diff -urN wine.20050419/include/d3dx9types.h wine.20050419.dx9/include/d3dx9types.h
21937--- wine.20050419/include/d3dx9types.h 1969-12-31 17:00:00.000000000 -0700
21938+++ wine.20050419.dx9/include/d3dx9types.h 2005-04-20 01:52:56.000000000 -0600
21939@@ -0,0 +1,207 @@
21940+/*
21941+ * Copyright (C) 2002 Raphael Junqueira
21942+ *
21943+ * This library is free software; you can redistribute it and/or
21944+ * modify it under the terms of the GNU Lesser General Public
21945+ * License as published by the Free Software Foundation; either
21946+ * version 2.1 of the License, or (at your option) any later version.
21947+ *
21948+ * This library is distributed in the hope that it will be useful,
21949+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
21950+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21951+ * Lesser General Public License for more details.
21952+ *
21953+ * You should have received a copy of the GNU Lesser General Public
21954+ * License along with this library; if not, write to the Free Software
21955+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21956+ */
21957+
21958+#ifndef __WINE_D3DX9TYPES_H
21959+#define __WINE_D3DX9TYPES_H
21960+
21961+#include <objbase.h>
21962+
21963+
21964+#include <d3d9types.h>
21965+
21966+
21967+/*****************************************************************************
21968+ * #defines and error codes
21969+ */
21970+
21971+/*
21972+ * Macros
21973+ */
21974+ #if 0
21975+#define D3DSINCOSCONST1 -1.5500992e-006f, -2.1701389e-005f, 0.0026041667f, 0.00026041668f
21976+#define D3DSINCOSCONST2 -0.020833334f , -0.12500000f , 1.0f , 0.50000000f
21977+/*FIXME: move over to d3dx9math.h*/
21978+#define D3DXToDegree( radian ) ((radian) * (180.0f / D3DX_PI))
21979+#define D3DXToRadian( degree ) ((degree) * (D3DX_PI / 180.0f))
21980+
21981+/*** 16-Bit Floating Point Numbers ***/
21982+#define D3DX_16F_DIG 3
21983+#define D3DX_16F_EPSILON 4.8875809e-4f
21984+#define D3DX_16F_MANT_DIG 11
21985+#define D3DX_16F_MAX 6.5519996e+4f
21986+#define D3DX_16F_MAX_10_EXP 4
21987+#define D3DX_16F_MAX_EXP 15
21988+#define D3DX_16F_MIN 6.1035156e-5f
21989+#define D3DX_16F_MIN_10_EXP (-4)
21990+#define D3DX_16F_MIN_EXP (-12)
21991+#define D3DX_16F_RADIX 2
21992+#define D3DX_16F_ROUNDS 1
21993+#define D3DX_1BYPI ((FLOAT) 0.318309886f)
21994+#define D3DX_PI ((FLOAT) 3.141592654f)
21995+
21996+/*** PRT Constants ***/
21997+#define D3DXSH_MINORDER 2
21998+#define D3DXSH_MAXORDER 6
21999+
22000+
22001+
22002+
22003+/*FIXME: move over to d3dx9shader.h */
22004+#define D3DXTX_VERSION(_Major,_Minor) (('T' << 24) | ('X' << 16) | ((_Major) << 8) | (_Minor))
22005+
22006+#define D3DXSHADER_AVOID_FLOW_CONTROL
22007+#define D3DXSHADER_DEBUG
22008+#define D3DXSHADER_FORCE_PS_SOFTWARE_NOOPT
22009+#define D3DXSHADER_FORCE_VS_SOFTWARE_NOOPT
22010+#define D3DXSHADER_NO_PRESHADER
22011+#define D3DXSHADER_PACKMATRIX_COLUMNMAJOR
22012+#define D3DXSHADER_PACKMATRIX_ROWMAJOR
22013+#define D3DXSHADER_PARTIALPRECISION
22014+#define D3DXSHADER_PREFER_FLOW_CONTROL
22015+#define D3DXSHADER_SKIPOPTIMIZATION
22016+#define D3DXSHADER_SKIPVALIDATION
22017+/******/
22018+#define D3DXSHADER_DEBUG
22019+#define D3DXSHADER_FORCE_PS_SOFTWARE_NOOPT
22020+#define D3DXSHADER_FORCE_VS_SOFTWARE_NOOPT
22021+#define D3DXSHADER_SKIPVALIDATION
22022+
22023+/*FIXME: move to d3dx9tex.h*/
22024+#define D3DX_CHANNEL_RED
22025+#define D3DX_CHANNEL_BLUE
22026+#define D3DX_CHANNEL_GREEN
22027+#define D3DX_CHANNEL_ALPHA
22028+#define D3DX_CHANNEL_LUMINANCE
22029+
22030+
22031+#define D3DX_FILTER_NONE
22032+#define D3DX_FILTER_POINT
22033+#define D3DX_FILTER_LINEAR
22034+#define D3DX_FILTER_TRIANGLE
22035+#define D3DX_FILTER_BOX
22036+#define D3DX_FILTER_MIRROR_U
22037+#define D3DX_FILTER_MIRROR_V
22038+#define D3DX_FILTER_MIRROR_W
22039+#define D3DX_FILTER_MIRROR
22040+#define D3DX_FILTER_DITHER
22041+#define D3DX_FILTER_SRGB_IN
22042+#define D3DX_FILTER_SRGB_OUT
22043+#define D3DX_FILTER_SRGB
22044+
22045+#define D3DX_NORMALMAP_MIRROR_U
22046+#define D3DX_NORMALMAP_MIRROR_V
22047+#define D3DX_NORMALMAP_MIRROR
22048+#define D3DX_NORMALMAP_INVERTSIGN
22049+#define D3DX_NORMALMAP_COMPUTE_OCCLUSION
22050+
22051+
22052+/*FIXME: move to d3dx9.h*/
22053+#define D3DFMT_FROM_FILE
22054+#define D3DX_DEFAULT
22055+#define D3DX_DEFAULT_NONPOW2
22056+#define D3DX_FROM_FILE
22057+
22058+#define D3DX_DEFAULT_FLOAT FLT_MAX
22059+
22060+/*FIXME: move to d3d9mesh.h*/
22061+#defnie D3DX_VERSION 0x0902
22062+#defnie D3DX_SDK_VERSION 22
22063+
22064+/*****************************************************************************
22065+ * Predeclare the interfaces
22066+ */
22067+DEFINE_GUID(IID_ID3DXBuffer, 0x1,0x1,0x4,0xB0,0xCF,0x98,0xFE,0xFD,0xFF,0x95,0x12);/* FIXME */
22068+typedef struct ID3DXBuffer ID3DXBuffer, *LPD3DXBUFFER;
22069+DEFINE_GUID(IID_ID3DXFont, 0x1,0x1,0x4,0xB0,0xCF,0x98,0xFE,0xFD,0xFF,0x95,0x13);/* FIXME */
22070+typedef struct ID3DXFont ID3DXFont, *LPD3DXFONT;
22071+
22072+/*****************************************************************************
22073+ * ID3DXBuffer interface
22074+ */
22075+#define INTERFACE ID3DXBuffer
22076+DECLARE_INTERFACE_(ID3DXBuffer,IUnknown)
22077+{
22078+ /*** IUnknown methods ***/
22079+ STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID riid, void** ppvObject) PURE;
22080+ STDMETHOD_(ULONG,AddRef)(THIS) PURE;
22081+ STDMETHOD_(ULONG,Release)(THIS) PURE;
22082+ /*** ID3DXBuffer methods ***/
22083+ STDMETHOD_(LPVOID,GetBufferPointer)(THIS) PURE;
22084+ STDMETHOD_(DWORD,GetBufferSize)(THIS) PURE;
22085+};
22086+#undef INTERFACE
22087+
22088+#if !defined(__cplusplus) || defined(CINTERFACE)
22089+/*** IUnknown methods ***/
22090+#define ID3DXBuffer_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
22091+#define ID3DXBuffer_AddRef(p) (p)->lpVtbl->AddRef(p)
22092+#define ID3DXBuffer_Release(p) (p)->lpVtbl->Release(p)
22093+/*** ID3DXBuffer methods ***/
22094+#define ID3DXBuffer_GetBufferPointer(p) (p)->lpVtbl->GetBufferPointer(p)
22095+#define ID3DXBuffer_GetBufferSize(p) (p)->lpVtbl->GetBufferSize(p)
22096+#endif
22097+
22098+/*****************************************************************************
22099+ * ID3DXFont interface
22100+ */
22101+#define INTERFACE ID3DXFont
22102+DECLARE_INTERFACE_(ID3DXFont,IUnknown)
22103+{
22104+ /*** IUnknown methods ***/
22105+ STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID riid, void** ppvObject) PURE;
22106+ STDMETHOD_(ULONG,AddRef)(THIS) PURE;
22107+ STDMETHOD_(ULONG,Release)(THIS) PURE;
22108+ /*** ID3DXFont methods ***/
22109+ STDMETHOD(Begin)(THIS) PURE;
22110+ STDMETHOD(DrawTextA)(THIS) PURE;
22111+ STDMETHOD(End)(THIS) PURE;
22112+};
22113+#undef INTERFACE
22114+
22115+#if !defined(__cplusplus) || defined(CINTERFACE)
22116+/*** IUnknown methods ***/
22117+#define ID3DXFont_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
22118+#define ID3DXFont_AddRef(p) (p)->lpVtbl->AddRef(p)
22119+#define ID3DXFont_Release(p) (p)->lpVtbl->Release(p)
22120+/*** ID3DXFont methods ***/
22121+#define ID3DXFont_Begin(p) (p)->lpVtbl->Begin(p)
22122+#define ID3DXFont_DrawTextA(p,a,b,c,d,e)(p)->lpVtbl->DrawText(p,a,b,c,d,e)
22123+#define ID3DXFont_End(p) (p)->lpVtbl->End(p)
22124+#endif
22125+
22126+/*************************************************************************************
22127+ * Define entrypoints
22128+ */
22129+HRESULT WINAPI D3DXCreateBuffer(DWORD NumBytes, LPD3DXBUFFER* ppBuffer);
22130+HRESULT WINAPI D3DXCreateFont(LPDIRECT3DDEVICE8 pDevice, HFONT hFont, LPD3DXFONT* ppFont);
22131+UINT WINAPI D3DXGetFVFVertexSize(DWORD FVF);
22132+HRESULT WINAPI D3DXAssembleShader(LPCVOID pSrcData, UINT SrcDataLen, DWORD Flags,
22133+ LPD3DXBUFFER* ppConstants,
22134+ LPD3DXBUFFER* ppCompiledShader,
22135+ LPD3DXBUFFER* ppCompilationErrors);
22136+HRESULT WINAPI D3DXAssembleShaderFromFileA(LPSTR pSrcFile, DWORD Flags,
22137+ LPD3DXBUFFER* ppConstants,
22138+ LPD3DXBUFFER* ppCompiledShader,
22139+ LPD3DXBUFFER* ppCompilationErrors);
22140+HRESULT WINAPI D3DXAssembleShaderFromFileW(LPSTR pSrcFile, DWORD Flags,
22141+ LPD3DXBUFFER* ppConstants,
22142+ LPD3DXBUFFER* ppCompiledShader,
22143+ LPD3DXBUFFER* ppCompilationErrors);
22144+
22145+ #endif
22146+#endif /* __WINE_D3DX9TYPES_H */
22147diff -urN wine.20050419/include/wine/wined3d_gl.h wine.20050419.dx9/include/wine/wined3d_gl.h
22148--- wine.20050419/include/wine/wined3d_gl.h 2005-02-08 09:52:04.000000000 -0700
22149+++ wine.20050419.dx9/include/wine/wined3d_gl.h 2005-04-20 01:52:56.000000000 -0600
22150@@ -659,6 +659,11 @@
22151 /* #define ZERO */
22152 #endif
22153
22154+/*Point sprites*/
22155+#define GL_POINT_SPRITE_ARB 0x8861
22156+/*Centre the texture on the vertex*/
22157+#define GL_COORD_REPLACE_ARB 0x8862
22158+
22159 /****************************************************
22160 * OpenGL Official Version
22161 * defines
22162diff -urN wine.20050419/include/wine/wined3d_interface.h wine.20050419.dx9/include/wine/wined3d_interface.h
22163--- wine.20050419/include/wine/wined3d_interface.h 2005-03-29 12:01:00.000000000 -0700
22164+++ wine.20050419.dx9/include/wine/wined3d_interface.h 2005-04-20 01:58:28.000000000 -0600
22165@@ -125,18 +125,12 @@
22166 # define WINED3DCLIPSTATUS D3DCLIPSTATUS8
22167 # define WINED3DMATERIAL D3DMATERIAL8
22168 # define WINED3DVIEWPORT D3DVIEWPORT8
22169-
22170- /* Subset: */
22171-# define WINED3DCAPS D3DCAPS8
22172 #else
22173 /* Identical: */
22174 # define WINED3DLIGHT D3DLIGHT9
22175 # define WINED3DCLIPSTATUS D3DCLIPSTATUS9
22176 # define WINED3DMATERIAL D3DMATERIAL9
22177 # define WINED3DVIEWPORT D3DVIEWPORT9
22178-
22179- /* Subsets: */
22180-# define WINED3DCAPS D3DCAPS9
22181 #endif
22182
22183 typedef struct IWineD3D IWineD3D;
22184@@ -155,6 +149,7 @@
22185 typedef struct IWineD3DVertexShader IWineD3DVertexShader;
22186 typedef struct IWineD3DPixelShader IWineD3DPixelShader;
22187 typedef struct IWineD3DQuery IWineD3DQuery;
22188+typedef struct IWineD3DSwapChain IWineD3DSwapChain;
22189
22190 /*****************************************************************************
22191 * Callback functions required for predefining surfaces / stencils
22192@@ -179,6 +174,17 @@
22193 IWineD3DSurface **ppSurface,
22194 HANDLE *pSharedHandle);
22195
22196+
22197+typedef HRESULT WINAPI (*D3DCB_CREATESURFACETFN) (IUnknown *pDevice,
22198+ UINT Width,
22199+ UINT Height,
22200+ D3DFORMAT Format,
22201+ DWORD Usage,
22202+ D3DPOOL Pool,
22203+ UINT Level,
22204+ IWineD3DSurface **ppSurface,
22205+ HANDLE * pSharedHandle);
22206+
22207 typedef HRESULT WINAPI (*D3DCB_CREATEDEPTHSTENCILSURFACEFN) (IUnknown *pDevice,
22208 UINT Width,
22209 UINT Height,
22210@@ -202,9 +208,11 @@
22211
22212 typedef HRESULT WINAPI (*D3DCB_CREATEADDITIONALSWAPCHAIN) (IUnknown *pDevice,
22213 WINED3DPRESENT_PARAMETERS *pPresentationParameters,
22214- void **pSwapChain
22215+ IWineD3DSwapChain** pSwapChain
22216 );
22217
22218+
22219+
22220 /*****************************************************************************
22221 * IWineD3D interface
22222 */
22223@@ -231,7 +239,7 @@
22224 STDMETHOD(CheckDeviceFormat)(THIS_ UINT Adapter, D3DDEVTYPE DeviceType, WINED3DFORMAT AdapterFormat, DWORD Usage, D3DRESOURCETYPE RType, WINED3DFORMAT CheckFormat) PURE;
22225 STDMETHOD(CheckDeviceFormatConversion)(THIS_ UINT Adapter, D3DDEVTYPE DeviceType, WINED3DFORMAT SourceFormat, WINED3DFORMAT TargetFormat) PURE;
22226 STDMETHOD(GetDeviceCaps)(THIS_ UINT Adapter, D3DDEVTYPE DeviceType, WINED3DCAPS *pCaps) PURE;
22227- STDMETHOD(CreateDevice)(THIS_ UINT Adapter, D3DDEVTYPE DeviceType,HWND hFocusWindow, DWORD BehaviorFlags, WINED3DPRESENT_PARAMETERS * pPresentationParameters, IWineD3DDevice ** ppReturnedDeviceInterface, IUnknown *parent, D3DCB_CREATERENDERTARGETFN pFn) PURE;
22228+ STDMETHOD(CreateDevice)(THIS_ UINT Adapter, D3DDEVTYPE DeviceType,HWND hFocusWindow, DWORD BehaviorFlags, WINED3DPRESENT_PARAMETERS * pPresentationParameters, IWineD3DDevice ** ppReturnedDeviceInterface, IUnknown *parent, D3DCB_CREATERENDERTARGETFN pFn, D3DCB_CREATEDEPTHSTENCILSURFACEFN pFn2, D3DCB_CREATEADDITIONALSWAPCHAIN pFn3) PURE;
22229 };
22230 #undef INTERFACE
22231
22232@@ -255,12 +263,13 @@
22233 #define IWineD3D_CheckDeviceFormat(p,a,b,c,d,e,f) (p)->lpVtbl->CheckDeviceFormat(p,a,b,c,d,e,f)
22234 #define IWineD3D_CheckDeviceFormatConversion(p,a,b,c,d) (p)->lpVtbl->CheckDeviceFormatConversion(p,a,b,c,d)
22235 #define IWineD3D_GetDeviceCaps(p,a,b,c) (p)->lpVtbl->GetDeviceCaps(p,a,b,c)
22236-#define IWineD3D_CreateDevice(p,a,b,c,d,e,f,g,h) (p)->lpVtbl->CreateDevice(p,a,b,c,d,e,f,g,h)
22237+#define IWineD3D_CreateDevice(p,a,b,c,d,e,f,g,h,j,k) (p)->lpVtbl->CreateDevice(p,a,b,c,d,e,f,g,h,j,k)
22238 #endif
22239
22240 /* Define the main WineD3D entrypoint */
22241 IWineD3D* WINAPI WineDirect3DCreate(UINT SDKVersion, UINT dxVersion, IUnknown *parent);
22242
22243+
22244 /*****************************************************************************
22245 * IWineD3DDevice interface
22246 */
22247@@ -277,12 +286,12 @@
22248 STDMETHOD(CreateIndexBuffer)(THIS_ UINT Length, DWORD Usage, WINED3DFORMAT Format, D3DPOOL Pool, IWineD3DIndexBuffer** ppIndexBuffer, HANDLE* pSharedHandle, IUnknown *parent) PURE;
22249 STDMETHOD(CreateStateBlock)(THIS_ D3DSTATEBLOCKTYPE Type, IWineD3DStateBlock **ppStateBlock, IUnknown *parent) PURE;
22250 STDMETHOD(CreateSurface)(THIS_ UINT Width, UINT Height, WINED3DFORMAT Format, BOOL Lockable, BOOL Discard, UINT Level, IWineD3DSurface** ppSurface, D3DRESOURCETYPE Type, DWORD Usage, D3DPOOL Pool, D3DMULTISAMPLE_TYPE MultiSample ,DWORD MultisampleQuality, HANDLE* pSharedHandle, IUnknown *parent) PURE;
22251- STDMETHOD(CreateTexture)(THIS_ UINT Width, UINT Height, UINT Levels, DWORD Usage, WINED3DFORMAT Format, D3DPOOL Pool, IWineD3DTexture** ppTexture, HANDLE* pSharedHandle, IUnknown *parent, D3DCB_CREATESURFACEFN pFn) PURE;
22252- STDMETHOD(CreateVolumeTexture)(THIS_ UINT Width, UINT Height, UINT Depth, UINT Levels, DWORD Usage, WINED3DFORMAT Format, D3DPOOL Pool, IWineD3DVolumeTexture** ppVolumeTexture, HANDLE* pSharedHandle, IUnknown *parent, D3DCB_CREATEVOLUMEFN pFn) PURE;
22253+ STDMETHOD(CreateTexture)(THIS_ UINT Width, UINT Height, UINT Levels, DWORD Usage, WINED3DFORMAT Format, D3DPOOL Pool, IWineD3DTexture** ppTexture, HANDLE* pSharedHandle, IUnknown *pParent, D3DCB_CREATESURFACEFN pFn) PURE;
22254+ STDMETHOD(CreateVolumeTexture)(THIS_ UINT Width, UINT Height, UINT Depth, UINT Levels, DWORD Usage, WINED3DFORMAT Format, D3DPOOL Pool, IWineD3DVolumeTexture** ppVolumeTexture, HANDLE* pSharedHandle, IUnknown *pParent, D3DCB_CREATEVOLUMEFN pFn) PURE;
22255 STDMETHOD(CreateVolume)(THIS_ UINT Width, UINT Height, UINT Depth, DWORD Usage, WINED3DFORMAT Format, D3DPOOL Pool, IWineD3DVolume** ppVolumeTexture, HANDLE* pSharedHandle, IUnknown *parent) PURE;
22256- STDMETHOD(CreateCubeTexture)(THIS_ UINT EdgeLength, UINT Levels, DWORD Usage, WINED3DFORMAT Format, D3DPOOL Pool, IWineD3DCubeTexture** ppCubeTexture, HANDLE* pSharedHandle, IUnknown *parent, D3DCB_CREATESURFACEFN pFn) PURE;
22257+ STDMETHOD(CreateCubeTexture)(THIS_ UINT EdgeLength, UINT Levels, DWORD Usage, WINED3DFORMAT Format, D3DPOOL Pool, IWineD3DCubeTexture** ppTexture, HANDLE* pSharedHandle, IUnknown *parent, D3DCB_CREATESURFACEFN pFn) PURE;
22258 STDMETHOD(CreateQuery)(THIS_ WINED3DQUERYTYPE Type, IWineD3DQuery **ppQuery, IUnknown *pParent);
22259- STDMETHOD(CreateAdditionalSwapChain)(THIS_ WINED3DPRESENT_PARAMETERS* pPresentationParameters, void** pSwapChain, IUnknown* pParent, D3DCB_CREATERENDERTARGETFN pFn, D3DCB_CREATEDEPTHSTENCILSURFACEFN pFn2);
22260+ STDMETHOD(CreateAdditionalSwapChain)(THIS_ WINED3DPRESENT_PARAMETERS* pPresentationParameters, IWineD3DSwapChain** pSwapChain, IUnknown* pParent, D3DCB_CREATERENDERTARGETFN pFn, D3DCB_CREATEDEPTHSTENCILSURFACEFN pFn2);
22261 STDMETHOD(CreateVertexDeclaration)(THIS_ CONST VOID* pDeclaration, IWineD3DVertexDeclaration** ppDecl, IUnknown* pParent) PURE;
22262 STDMETHOD(CreateVertexShader)(THIS_ CONST DWORD* pFunction, IWineD3DVertexShader** ppShader, IUnknown *pParent) PURE;
22263 STDMETHOD(CreatePixelShader)(THIS_ CONST DWORD* pFunction, IWineD3DPixelShader** ppShader, IUnknown *pParent) PURE;
22264@@ -295,7 +304,7 @@
22265 STDMETHOD(GetDisplayMode)(THIS_ UINT iSwapChain, D3DDISPLAYMODE* pMode) PURE;
22266 STDMETHOD_(UINT, GetNumberOfSwapChains)(THIS) PURE;
22267 STDMETHOD(GetRasterStatus)(THIS_ UINT iSwapChain, D3DRASTER_STATUS* pRasterStatus) PURE;
22268- STDMETHOD(GetSwapChain)(THIS_ UINT iSwapChain, void** pSwapChain) PURE;
22269+ STDMETHOD(GetSwapChain)(THIS_ UINT iSwapChain, IWineD3DSwapChain** pSwapChain) PURE;
22270 STDMETHOD(Reset)(THIS_ WINED3DPRESENT_PARAMETERS* pPresentationParameters) PURE;
22271 STDMETHOD(SetDialogBoxMode)(THIS_ BOOL bEnableDialogs) PURE;
22272 STDMETHOD(SetCursorProperties)(THIS_ UINT XHotSpot, UINT YHotSpot, IWineD3DSurface* pCursorBitmap) PURE;
22273@@ -388,9 +397,14 @@
22274 STDMETHOD(StretchRect)(THIS_ IWineD3DSurface* pSourceSurface, CONST RECT* pSourceRect, IWineD3DSurface* pDestinationSurface, CONST RECT* pDestRect, D3DTEXTUREFILTERTYPE Filter) PURE;
22275 STDMETHOD(GetRenderTargetData)(THIS_ IWineD3DSurface* pRenderTarget, IWineD3DSurface* pSurface) PURE;
22276 STDMETHOD(GetFrontBufferData)(THIS_ UINT iSwapChain,IWineD3DSurface* pSurface) PURE;
22277- /*** Internal use IWineD3Device methods ***/
22278+ /*** Internal use IWineD3DDevice methods ***/
22279 STDMETHOD_(void, SetupTextureStates)(THIS_ DWORD Stage, DWORD Flags);
22280+ #if 0 /* TODO: part of the interface cleanup work */
22281+ STDMETHOD_(void, ResourceReleased)(THIS_ IWineD3DResource *resource);
22282+ STDMETHOD_(void, SwapChainReleased)(THIS_ IWineD3DSwapChain *swapChain);
22283+ #endif
22284 };
22285+
22286 #undef INTERFACE
22287
22288 #if !defined(__cplusplus) || defined(CINTERFACE)
22289@@ -516,6 +530,10 @@
22290 #define IWineD3DDevice_GetRenderTargetData(p,a,b) (p)->lpVtbl->GetRenderTargetData(p,a,b)
22291 #define IWineD3DDevice_GetFrontBufferData(p,a,b) (p)->lpVtbl->GetFrontBufferData(p,a,b)
22292 #define IWineD3DDevice_SetupTextureStates(p,a,b) (p)->lpVtbl->SetupTextureStates(p,a,b)
22293+#if 0 /* TODO: part of the interface cleanup work */
22294+#define IWineD3DDevice_ResourceReleased(p,a) (p)->lpVtbl->ResourceReleased(p,a)
22295+#define IWineD3DDevice_SwapChainReleased(p,a) (p)->lpVtbl->SwapChainReleased(p,a)
22296+#endif
22297 #endif
22298
22299 /*****************************************************************************
22300@@ -742,7 +760,7 @@
22301 STDMETHOD_(DWORD,GetPriority)(THIS) PURE;
22302 STDMETHOD_(void,PreLoad)(THIS) PURE;
22303 STDMETHOD_(D3DRESOURCETYPE,GetType)(THIS) PURE;
22304- /*** IWineD3DBaseTexture methods ***/
22305+ /*** IWineD3DTexture methods ***/
22306 STDMETHOD_(DWORD, SetLOD)(THIS_ DWORD LODNew) PURE;
22307 STDMETHOD_(DWORD, GetLOD)(THIS) PURE;
22308 STDMETHOD_(DWORD, GetLevelCount)(THIS) PURE;
22309@@ -778,7 +796,7 @@
22310 #define IWineD3DTexture_GetPriority(p) (p)->lpVtbl->GetPriority(p)
22311 #define IWineD3DTexture_PreLoad(p) (p)->lpVtbl->PreLoad(p)
22312 #define IWineD3DTexture_GetType(p) (p)->lpVtbl->GetType(p)
22313-/*** IWineD3DTexture methods: IWineD3DBaseTexture ***/
22314+/*** IWineD3DTexture methods: IWineD3DTexture ***/
22315 #define IWineD3DTexture_SetLOD(p,a) (p)->lpVtbl->SetLOD(p,a)
22316 #define IWineD3DTexture_GetLOD(p) (p)->lpVtbl->GetLOD(p)
22317 #define IWineD3DTexture_GetLevelCount(p) (p)->lpVtbl->GetLevelCount(p)
22318@@ -798,11 +816,12 @@
22319 #define IWineD3DTexture_AddDirtyRect(p,a) (p)->lpVtbl->AddDirtyRect(p,a)
22320 #endif
22321
22322+
22323 /*****************************************************************************
22324 * IWineD3DCubeTexture interface
22325 */
22326 #define INTERFACE IWineD3DCubeTexture
22327-DECLARE_INTERFACE_(IWineD3DCubeTexture,IWineD3DBaseTexture)
22328+DECLARE_INTERFACE_(IWineD3DCubeTexture,IWineD3DTexture)
22329 {
22330 /*** IUnknown methods ***/
22331 STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID riid, void** ppvObject) PURE;
22332@@ -818,7 +837,7 @@
22333 STDMETHOD_(DWORD,GetPriority)(THIS) PURE;
22334 STDMETHOD_(void,PreLoad)(THIS) PURE;
22335 STDMETHOD_(D3DRESOURCETYPE,GetType)(THIS) PURE;
22336- /*** IWineD3DBaseTexture methods ***/
22337+ /*** IWineD3DTexture methods ***/
22338 STDMETHOD_(DWORD, SetLOD)(THIS_ DWORD LODNew) PURE;
22339 STDMETHOD_(DWORD, GetLOD)(THIS) PURE;
22340 STDMETHOD_(DWORD, GetLevelCount)(THIS) PURE;
22341@@ -854,7 +873,7 @@
22342 #define IWineD3DCubeTexture_GetPriority(p) (p)->lpVtbl->GetPriority(p)
22343 #define IWineD3DCubeTexture_PreLoad(p) (p)->lpVtbl->PreLoad(p)
22344 #define IWineD3DCubeTexture_GetType(p) (p)->lpVtbl->GetType(p)
22345-/*** IWineD3DCubeTexture methods: IWineD3DBaseTexture ***/
22346+/*** IWineD3DCubeTexture methods: IWineD3DTexture ***/
22347 #define IWineD3DCubeTexture_SetLOD(p,a) (p)->lpVtbl->SetLOD(p,a)
22348 #define IWineD3DCubeTexture_GetLOD(p) (p)->lpVtbl->GetLOD(p)
22349 #define IWineD3DCubeTexture_GetLevelCount(p) (p)->lpVtbl->GetLevelCount(p)
22350@@ -879,7 +898,7 @@
22351 * IWineD3DVolumeTexture interface
22352 */
22353 #define INTERFACE IWineD3DVolumeTexture
22354-DECLARE_INTERFACE_(IWineD3DVolumeTexture,IWineD3DBaseTexture)
22355+DECLARE_INTERFACE_(IWineD3DVolumeTexture,IWineD3DTexture)
22356 {
22357 /*** IUnknown methods ***/
22358 STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID riid, void** ppvObject) PURE;
22359@@ -895,7 +914,7 @@
22360 STDMETHOD_(DWORD,GetPriority)(THIS) PURE;
22361 STDMETHOD_(void,PreLoad)(THIS) PURE;
22362 STDMETHOD_(D3DRESOURCETYPE,GetType)(THIS) PURE;
22363- /*** IWineD3DBaseTexture methods ***/
22364+ /*** IWineD3DTexture methods ***/
22365 STDMETHOD_(DWORD, SetLOD)(THIS_ DWORD LODNew) PURE;
22366 STDMETHOD_(DWORD, GetLOD)(THIS) PURE;
22367 STDMETHOD_(DWORD, GetLevelCount)(THIS) PURE;
22368@@ -921,7 +940,7 @@
22369 #define IWineD3DVolumeTexture_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
22370 #define IWineD3DVolumeTexture_AddRef(p) (p)->lpVtbl->AddRef(p)
22371 #define IWineD3DVolumeTexture_Release(p) (p)->lpVtbl->Release(p)
22372-/*** IWineD3DVolumeTexture methods: IWineD3DResource ***/
22373+/*** IWineD3DVolumeTexture methods: IDirect3DResource9 ***/
22374 #define IWineD3DVolumeTexture_GetParent(p,a) (p)->lpVtbl->GetParent(p,a)
22375 #define IWineD3DVolumeTexture_GetDevice(p,a) (p)->lpVtbl->GetDevice(p,a)
22376 #define IWineD3DVolumeTexture_SetPrivateData(p,a,b,c,d) (p)->lpVtbl->SetPrivateData(p,a,b,c,d)
22377@@ -931,7 +950,7 @@
22378 #define IWineD3DVolumeTexture_GetPriority(p) (p)->lpVtbl->GetPriority(p)
22379 #define IWineD3DVolumeTexture_PreLoad(p) (p)->lpVtbl->PreLoad(p)
22380 #define IWineD3DVolumeTexture_GetType(p) (p)->lpVtbl->GetType(p)
22381-/*** IWineD3DVolumeTexture methods: IWineD3DBaseTexture ***/
22382+/*** IWineD3DVolumeTexture methods: IWineD3DTexture ***/
22383 #define IWineD3DVolumeTexture_SetLOD(p,a) (p)->lpVtbl->SetLOD(p,a)
22384 #define IWineD3DVolumeTexture_GetLOD(p) (p)->lpVtbl->GetLOD(p)
22385 #define IWineD3DVolumeTexture_GetLevelCount(p) (p)->lpVtbl->GetLevelCount(p)
22386@@ -951,6 +970,8 @@
22387 #define IWineD3DVolumeTexture_AddDirtyBox(p,a) (p)->lpVtbl->AddDirtyBox(p,a)
22388 #endif
22389
22390+
22391+
22392 /*****************************************************************************
22393 * IWineD3DSurface interface
22394 */
22395@@ -1089,6 +1110,7 @@
22396 STDMETHOD_(ULONG,AddRef)(THIS) PURE;
22397 STDMETHOD_(ULONG,Release)(THIS) PURE;
22398 /*** IWineD3DVertexDeclaration methods ***/
22399+ STDMETHOD(GetParent)(THIS_ IUnknown **pParent) PURE;
22400 STDMETHOD(GetDevice)(THIS_ IWineD3DDevice ** ppDevice) PURE;
22401 STDMETHOD(GetDeclaration)(THIS_ UINT iDeclVersion, VOID*, DWORD* pSize) PURE;
22402 };
22403@@ -1100,6 +1122,7 @@
22404 #define IWineD3DVertexDeclaration_AddRef(p) (p)->lpVtbl->AddRef(p)
22405 #define IWineD3DVertexDeclaration_Release(p) (p)->lpVtbl->Release(p)
22406 /*** IWineD3DVertexDeclaration methods ***/
22407+#define IWineD3DVertexDeclaration_GetParent(p,a) (p)->lpVtbl->GetParent(p,a)
22408 #define IWineD3DVertexDeclaration_GetDevice(p,a) (p)->lpVtbl->GetDevice(p,a)
22409 #define IWineD3DVertexDeclaration_GetDeclaration(p,a,b,c) (p)->lpVtbl->GetDeclaration(p,a,b,c)
22410 #endif
22411@@ -1116,6 +1139,9 @@
22412 STDMETHOD_(ULONG,Release)(THIS) PURE;
22413 /*** IWineD3DStateBlock methods ***/
22414 STDMETHOD(GetParent)(THIS_ IUnknown **pParent) PURE;
22415+ STDMETHOD(GetDevice)(THIS_ IWineD3DDevice **pDevice) PURE;
22416+ STDMETHOD(Capture)(THIS) PURE;
22417+ STDMETHOD(Apply)(THIS) PURE;
22418 STDMETHOD(InitStartupStateBlock)(THIS) PURE;
22419 };
22420 #undef INTERFACE
22421@@ -1127,6 +1153,9 @@
22422 #define IWineD3DStateBlock_Release(p) (p)->lpVtbl->Release(p)
22423 /*** IWineD3DStateBlock methods ***/
22424 #define IWineD3DStateBlock_GetParent(p,a) (p)->lpVtbl->GetParent(p,a)
22425+#define IWineD3DStateBlock_GetDevice(p,a) (p)->lpVtbl->GetDevice(p,a)
22426+#define IWineD3DStateBlock_Capture(p) (p)->lpVtbl->Capture(p)
22427+#define IWineD3DStateBlock_Apply(p) (p)->lpVtbl->Apply(p)
22428 #define IWineD3DStateBlock_InitStartupStateBlock(p) (p)->lpVtbl->InitStartupStateBlock(p)
22429 #endif
22430
22431@@ -1167,6 +1196,54 @@
22432 #endif
22433
22434 /*****************************************************************************
22435+ * IWineD3DSwapChain interface
22436+ * TODO: add gamma-ramp setting functions to make life easier
22437+ * (There kinda missing from Microsofts DirectX!)
22438+ */
22439+#define INTERFACE IWineD3DSwapChain
22440+DECLARE_INTERFACE_(IWineD3DSwapChain,IUnknown)
22441+{
22442+ /*** IUnknown methods ***/
22443+ STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID riid, void** ppvObject) PURE;
22444+ STDMETHOD_(ULONG,AddRef)(THIS) PURE;
22445+ STDMETHOD_(ULONG,Release)(THIS) PURE;
22446+ /*** IDirect3DSwapChain9 methods ***/
22447+ STDMETHOD(GetParent)(THIS_ IUnknown **pParent) PURE;
22448+ STDMETHOD(GetDevice)(THIS_ IWineD3DDevice** ppDevice) PURE;
22449+ STDMETHOD(Present)(THIS_ CONST RECT* pSourceRect, CONST RECT* pDestRect, HWND hDestWindowOverride, CONST RGNDATA* pDirtyRegion, DWORD dwFlags) PURE;
22450+ STDMETHOD(GetFrontBufferData)(THIS_ IWineD3DSurface* pDestSurface) PURE;
22451+ STDMETHOD(GetBackBuffer)(THIS_ UINT iBackBuffer, D3DBACKBUFFER_TYPE Type, IWineD3DSurface** ppBackBuffer) PURE;
22452+ STDMETHOD(GetRasterStatus)(THIS_ D3DRASTER_STATUS* pRasterStatus) PURE;
22453+ STDMETHOD(GetDisplayMode)(THIS_ D3DDISPLAYMODE* pMode) PURE;
22454+ STDMETHOD(GetPresentParameters)(THIS_ D3DPRESENT_PARAMETERS* pPresentationParameters) PURE;
22455+ STDMETHOD(SetGammaRamp)(THIS_ DWORD Flags, const D3DGAMMARAMP *pRamp) PURE;
22456+ STDMETHOD(GetGammaRamp)(THIS_ D3DGAMMARAMP *pRamp) PURE;
22457+};
22458+#undef INTERFACE
22459+
22460+#if !defined(__cplusplus) || defined(CINTERFACE)
22461+/*** IUnknown methods ***/
22462+#define IWineD3DSwapChain_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
22463+#define IWineD3DSwapChain_AddRef(p) (p)->lpVtbl->AddRef(p)
22464+#define IWineD3DSwapChain_Release(p) (p)->lpVtbl->Release(p)
22465+/*** IWineD3DSwapChain methods ***/
22466+
22467+#define IWineD3DSwapChain_GetParent(p,a) (p)->lpVtbl->GetParent(p,a)
22468+#define IWineD3DSwapChain_GetDevice(p,a) (p)->lpVtbl->GetDevice(p,a)
22469+#define IWineD3DSwapChain_Present(p,a,b,c,d,e) (p)->lpVtbl->Present(p,a,b,c,d,e)
22470+#define IWineD3DSwapChain_GetFrontBufferData(p,a) (p)->lpVtbl->GetFrontBufferData(p,a)
22471+#define IWineD3DSwapChain_GetBackBuffer(p,a,b,c) (p)->lpVtbl->GetBackBuffer(p,a,b,c)
22472+#define IWineD3DSwapChain_GetRasterStatus(p,a) (p)->lpVtbl->GetRasterStatus(p,a)
22473+#define IWineD3DSwapChain_GetDisplayMode(p,a) (p)->lpVtbl->GetDisplayMode(p,a)
22474+#define IWineD3DSwapChain_GetPresentParameters(p,a) (p)->lpVtbl->GetPresentParameters(p,a)
22475+#define IWineD3DSwapChain_SetGammaRamp(p,a,b) (p)->lpVtbl->SetGammaRamp(p,a,b)
22476+#define IWineD3DSwapChain_GetGammaRamp(p,a) (p)->lpVtbl->GetGammaRamp(p,a)
22477+#endif
22478+
22479+
22480+
22481+
22482+/*****************************************************************************
22483 * IWineD3DVertexShader interface
22484 */
22485 #define INTERFACE IWineD3DVertexShader
22486diff -urN wine.20050419/include/wine/wined3d_types.h wine.20050419.dx9/include/wine/wined3d_types.h
22487--- wine.20050419/include/wine/wined3d_types.h 2005-03-03 06:57:15.000000000 -0700
22488+++ wine.20050419.dx9/include/wine/wined3d_types.h 2005-04-20 01:52:56.000000000 -0600
22489@@ -105,6 +105,8 @@
22490 WINED3DSHADERVECTOR oDepth;
22491 } WINEPSHADEROUTPUTDATA;
22492
22493+
22494+
22495 /*****************************************************************************
22496 * WineD3D Structures to be used when d3d8 and d3d9 are incompatible
22497 */
22498@@ -537,5 +539,119 @@
22499 } WINED3DDEVINFO_VCACHE;
22500
22501
22502+/*
22503+ * The d3dcaps9 structure
22504+ */
22505+
22506+
22507+typedef struct _WINED3DVSHADERCAPS2_0 {
22508+ DWORD Caps;
22509+ INT DynamicFlowControlDepth;
22510+ INT NumTemps;
22511+ INT StaticFlowControlDepth;
22512+} WINED3DVSHADERCAPS2_0;
22513+
22514+typedef struct _WINED3DPSHADERCAPS2_0 {
22515+ DWORD Caps;
22516+ INT DynamicFlowControlDepth;
22517+ INT NumTemps;
22518+ INT StaticFlowControlDepth;
22519+ INT NumInstructionSlots;
22520+} WINED3DPSHADERCAPS2_0;
22521+
22522+typedef struct _WINED3DCAPS {
22523+ D3DDEVTYPE *DeviceType;
22524+ UINT *AdapterOrdinal;
22525+
22526+ DWORD *Caps;
22527+ DWORD *Caps2;
22528+ DWORD *Caps3;
22529+ DWORD *PresentationIntervals;
22530+
22531+ DWORD *CursorCaps;
22532+
22533+ DWORD *DevCaps;
22534+
22535+ DWORD *PrimitiveMiscCaps;
22536+ DWORD *RasterCaps;
22537+ DWORD *ZCmpCaps;
22538+ DWORD *SrcBlendCaps;
22539+ DWORD *DestBlendCaps;
22540+ DWORD *AlphaCmpCaps;
22541+ DWORD *ShadeCaps;
22542+ DWORD *TextureCaps;
22543+ DWORD *TextureFilterCaps;
22544+ DWORD *CubeTextureFilterCaps;
22545+ DWORD *VolumeTextureFilterCaps;
22546+ DWORD *TextureAddressCaps;
22547+ DWORD *VolumeTextureAddressCaps;
22548+
22549+ DWORD *LineCaps;
22550+
22551+ DWORD *MaxTextureWidth;
22552+ DWORD *MaxTextureHeight;
22553+ DWORD *MaxVolumeExtent;
22554+
22555+ DWORD *MaxTextureRepeat;
22556+ DWORD *MaxTextureAspectRatio;
22557+ DWORD *MaxAnisotropy;
22558+ float *MaxVertexW;
22559+
22560+ float *GuardBandLeft;
22561+ float *GuardBandTop;
22562+ float *GuardBandRight;
22563+ float *GuardBandBottom;
22564+
22565+ float *ExtentsAdjust;
22566+ DWORD *StencilCaps;
22567+
22568+ DWORD *FVFCaps;
22569+ DWORD *TextureOpCaps;
22570+ DWORD *MaxTextureBlendStages;
22571+ DWORD *MaxSimultaneousTextures;
22572+
22573+ DWORD *VertexProcessingCaps;
22574+ DWORD *MaxActiveLights;
22575+ DWORD *MaxUserClipPlanes;
22576+ DWORD *MaxVertexBlendMatrices;
22577+ DWORD *MaxVertexBlendMatrixIndex;
22578+
22579+ float *MaxPointSize;
22580+
22581+ DWORD *MaxPrimitiveCount;
22582+ DWORD *MaxVertexIndex;
22583+ DWORD *MaxStreams;
22584+ DWORD *MaxStreamStride;
22585+
22586+ DWORD *VertexShaderVersion;
22587+ DWORD *MaxVertexShaderConst;
22588+
22589+ DWORD *PixelShaderVersion;
22590+ float *PixelShader1xMaxValue;
22591+
22592+ /* DX 9 */
22593+ DWORD *DevCaps2;
22594+
22595+ float *MaxNpatchTessellationLevel;
22596+ DWORD *Reserved5; /*undocumented*/
22597+
22598+ UINT *MasterAdapterOrdinal;
22599+ UINT *AdapterOrdinalInGroup;
22600+ UINT *NumberOfAdaptersInGroup;
22601+ DWORD *DeclTypes;
22602+ DWORD *NumSimultaneousRTs;
22603+ DWORD *StretchRectFilterCaps;
22604+ WINED3DVSHADERCAPS2_0 *VS20Caps;
22605+ WINED3DPSHADERCAPS2_0 *PS20Caps;
22606+ DWORD *VertexTextureFilterCaps;
22607+ DWORD *MaxVShaderInstructionsExecuted;
22608+ DWORD *MaxPShaderInstructionsExecuted;
22609+ DWORD *MaxVertexShader30InstructionSlots;
22610+ DWORD *MaxPixelShader30InstructionSlots;
22611+ DWORD *Reserved2;/* Not in the microsoft headers but documented */
22612+ DWORD *Reserved3;
22613+
22614+} WINED3DCAPS;
22615+
22616
22617 #endif
This page took 3.533183 seconds and 4 git commands to generate.