Compare commits

...

22 Commits

Author SHA1 Message Date
Magnus Olsen
e4c503afbd fixed most of the compinning errors of ddraw
but not all 

svn path=/branches/reactx/; revision=27550
2007-07-09 19:56:19 +00:00
Magnus Olsen
09a5b7dc7d delete wrong header
svn path=/branches/reactx/; revision=27549
2007-07-09 19:48:12 +00:00
Magnus Olsen
b7cfab72de remove wrong header from reactx
svn path=/branches/reactx/; revision=27548
2007-07-09 19:28:59 +00:00
Magnus Olsen
2e65336e44 paralles ddraw being build now.
svn path=/branches/reactx/; revision=27528
2007-07-08 22:30:46 +00:00
Magnus Olsen
94d9b34885 disable wine seh handling in paralles dx files
svn path=/branches/reactx/; revision=27527
2007-07-08 22:29:37 +00:00
Magnus Olsen
fa4fa3e550 using reactos pseh instead for wine seh or buildin support for seh.
svn path=/branches/reactx/; revision=27525
2007-07-08 22:08:12 +00:00
Magnus Olsen
d9be9d9ec9 paralles are not nice, they give out wrong .def file I do not think they are using thuse def file internal if u do
the dumaic link will not work in windows. 
fixed build for ddrawex as well

svn path=/branches/reactx/; revision=27520
2007-07-08 20:43:09 +00:00
Magnus Olsen
41dc570f53 fixed build of wined3d it using now paralles changes.
svn path=/branches/reactx/; revision=27512
2007-07-08 19:42:16 +00:00
Magnus Olsen
f1173c8622 remove two define in wined3d_gl.h that exists in glext.h
add have HAVE_MODE_T 1 and #define HAVE_SSIZE_T 1
but wine version is diffent size what mingw have. 

svn path=/branches/reactx/; revision=27508
2007-07-08 19:04:04 +00:00
Magnus Olsen
5eaff2f82f setup paralles include folder right in rbuild files
svn path=/branches/reactx/; revision=27502
2007-07-08 17:55:36 +00:00
Magnus Olsen
c26381c167 Copied remotely
svn path=/branches/reactx/; revision=27501
2007-07-08 17:45:48 +00:00
Magnus Olsen
1cb065d1fb Copied remotely
svn path=/branches/reactx/; revision=27500
2007-07-08 17:45:45 +00:00
Magnus Olsen
4f0b9f219a Copied remotely
svn path=/branches/reactx/; revision=27499
2007-07-08 17:45:43 +00:00
Magnus Olsen
9320319ad2 Copied remotely
svn path=/branches/reactx/; revision=27498
2007-07-08 17:45:41 +00:00
Magnus Olsen
3552902744 Created folder remotely
svn path=/branches/reactx/; revision=27497
2007-07-08 17:44:48 +00:00
Magnus Olsen
937f1bb0fe Copied remotely
svn path=/branches/reactx/; revision=27496
2007-07-08 17:43:32 +00:00
Magnus Olsen
a97e6bc4cf Created folder remotely
svn path=/branches/reactx/; revision=27495
2007-07-08 17:42:31 +00:00
Magnus Olsen
3524966a7e define WINE_NATIVEWIN32 so we activate parelles changes.
svn path=/branches/reactx/; revision=27481
2007-07-08 15:19:43 +00:00
Magnus Olsen
d9cca2589b fixing some problem with parelles rbuild files
svn path=/branches/reactx/; revision=27480
2007-07-08 15:10:33 +00:00
Magnus Olsen
88a269c6e7 fixing smaller typo in ddrawex rbuild file
svn path=/branches/reactx/; revision=27479
2007-07-08 14:58:55 +00:00
Magnus Olsen
38d42293c1 ading rbuild files to parelles
------------------------------
does not builds yet.

svn path=/branches/reactx/; revision=27478
2007-07-08 14:56:18 +00:00
Magnus Olsen
ed6c0c6fb1 experiment code
adding DirectX opengl warper that using opengl lcd driver. it is Parallels modify source code of wine d3d for it. 
can not be compile in ReactX branch yet. 

svn path=/branches/reactx/; revision=27364
2007-07-02 19:47:58 +00:00
175 changed files with 102286 additions and 2895 deletions

View File

@@ -0,0 +1,6 @@
This is a small subset of WINE project including only Direct3D
libraries. The libraries can be built using MS Visual C++ and
native Windows headers from Platform SDK and DirectX SDK.
This version is based on wine-0.9.36 snapshot. The changes made
to original WINE sources are ifdefed under WINE_NATIVEWIN32.

View File

@@ -0,0 +1,408 @@
This is release 0.9.36 of Wine, a free implementation of Windows on Unix.
What's new in this release:
- Midi support in the CoreAudio driver.
- Mixer support in the Alsa driver.
- A lot of MSI fixes.
- Implementation for most D3DRM functions.
- The usual assortment of Direct3D fixes.
- Lots of bug fixes.
Because of lags created by using mirrors, this message may reach you
before the release is available at the public sites. The sources will
be available from the following locations:
http://ibiblio.org/pub/linux/system/emulators/wine/wine-0.9.36.tar.bz2
http://prdownloads.sourceforge.net/wine/wine-0.9.36.tar.bz2
Binary packages for various distributions will be available from:
http://www.winehq.org/site/download
You will find documentation on
http://www.winehq.org/site/documentation
You can also get the current source directly from the git or CVS
repositories. Check respectively http://www.winehq.org/site/git or
http://www.winehq.org/site/cvs for details.
If you fix something, please submit a patch; instructions on how to do
this can be found at http://www.winehq.org/site/sending_patches
Wine is available thanks to the work of many people. See the file
AUTHORS in the distribution for the complete list.
----------------------------------------------------------------
Changes since 0.9.35:
Alasdair Sinclair (1):
advapi32: Fix one byte array overflow during DES unhash.
Alban Browaeys (2):
msi: Move msi_free(msiFilePath) to enable ERR message to use it before it is freed.
wininet: Fix szCacheContent in URLCacheContainer_OpenIndex.
Alexandre Julliard (19):
kernel32: Use the correct access rights when opening named pipes.
server: Add infrastructure for ioctl server request.
server: Implement the FSCTL_PIPE_DISCONNECT ioctl on the server side.
server: Move the server part of device unmounting to the ioctl processing.
server: Change the timeout handling to use NT-style 64-bit timeouts everywhere.
server: Add a specific data type for ioctl codes so they can be printed as symbols.
server: Move the FSCTL_PIPE_WAIT ioctl implementation to the server.
server: Allow specifying the status code to return on file descriptors that don't have a Unix fd.
server: Moved the FSCTL_PIPE_LISTEN implementation to the server.
server: Use the standard file descriptor wait queue for named pipe server async waits.
server: Don't give out read/write access to the named pipe device.
dbghelp: Don't print garbage chars in ERR message.
version: Avoid size_t type in traces.
server: Return a more correct fd type for anonymous files.
configure: Use AC_SEARCH_LIBS for the Solaris libs to avoid unused function checks.
winedbg: Properly handle EOF on input.
cabinet: Make sure we don't try to close an invalid file handle.
make_makefiles: Avoid duplicate .gitignore entries.
winecoreaudio: Avoid sizeof in trace.
Alexey Markachev (1):
ntdll: Fix mistake in Novosibirsk time zone.
Andrew Riedi (1):
winex11.drv: Add legacy 32-bit cursor support.
Andrew Talbot (27):
crypt32: Constify some variables.
crypt32: Constify some variables.
user32: Make function definitions and declarations agree.
slwapi: Make function definitions and declarations agree.
slwapi: Make function definitions and declarations agree.
dbghelp: Constify some variables.
uxtheme: Fix conflicting declarations.
dbghelp: Constify some variables.
dbghelp: Constify some variables.
ddraw: Constify some variables.
activeds: Exclude unused headers.
acledit: Exclude unused headers.
advpack: Exclude unused headers.
avicap32: Exclude unused header.
avifil32: Exclude unused headers.
amstream: Exclude unused headers.
dinput: Constify some variables.
dmcompos: Constify a variable.
dmusic: Constify a variable.
dmscript: Constify a variable.
dmloader: Constify some variables.
dmime: Constify some variables.
dmstyle: Constify some variables.
dmband: Constify some variables.
dnsapi: Constify some variables.
dplayx: Fix a typo.
dplayx: Constify some variables.
Aric Stewart (4):
taskmgr: Add Japanese resource.
shell32: SHGFI_EXETYPE flag should have the files returning 0 if they are DLL images.
gdi32: Make the comparison for system link font replacement not case sensitive.
usp10: Do not crash in ScriptPlace if pABC is null.
Ben Taylor (2):
configure: Fix to properly recognize functions on Solaris.
wineoss: Fix to compile on Solaris 10.
Bernd Buschinski (1):
wined3d: Fix drawStridedSlow typo.
Chia-I Wu (1):
kernel32: Fix non-terminated separator string.
Chris Robinson (2):
quartz: Create DirectSound device and buffer at filter creation and connection respectively.
quartz: Partially implement the MPEG 1 Stream Splitter filter.
Clinton Stimpson (1):
riched20: Set modify state when removing text.
Damjan Jovanovic (1):
mapi32: MAPIAdminProfiles stub.
Dan Hipschman (4):
widl: Add --prefix-* options (take 3).
rpcrt4: Add tests for RPC and widl generated code.
widl: Declare fixed-size array args as pointers to arrays.
rpcrt4: Add a testcase for RPCs with fixed-size arrays.
David Adam (15):
include: Add d3drmdef.h header.
d3drm: Implement D3DRMVectorAdd.
d3drm: Implement D3DVectorSubtract.
d3drm: Implement D3DRMVectorCrossProduct.
d3drm: Implement D3DRMVectorDotProduct.
d3drm: Implement D3DRMVectorModulus.
d3drm: Implement D3DRMVectorscale.
d3drm: Implement D3DRMVectorNormalize.
d3drm: Implement D3DRMVectorRandom.
d3drm: Implement D3DRMVectorReflect.
d3drm: Implement D3DRMQuaternionMultiply.
d3drm: Implement D3DRMVectorRotate.
d3drm: Implement D3DRMMatrixFromQuaternion.
d3drm: Implement D3DRMQuaternionFromRotation.
d3drm: Implement D3DRMQuaternionSlerp.
Detlef Riekenberg (9):
include/winspool: Declare missing function.
spoolss: Build the import library.
localspl: Implement XcvData_AddPort.
localui: Implement DeletePortUI.
localspl: DeletePort is now in localui.dll.
localui: Implement ConfigurePortUI.
localspl: ConfigurePort is now in localui.dll.
localui: Avoid crash on NULL pointer.
localui: Implement ConfigurePortUI for COMx.
Dmitry Timoshkov (7):
version: Add a VerQueryValue test, make it mostly pass under Wine.
advapi32: Thunk GetFileSecurityW to NtQuerySecurityObject.
comctl32: Fix an off by one error in ImageList_Remove.
comctl32: Use packing only for public ILHEAD structure, 2 bytes packing is enough.
comctl32: Add an image list storage test, make it pass under Wine.
comctl32: Add more image list tests, fix one problem found.
user32: Windows doesn't redraw a window if it is being just moved.
EA Durbin (1):
sxs: Add new dll stub.
Emmanuel Maillard (17):
winecoreaudio: Initial MIDI support on Mac OS X.
winecoreaudio: Implement MIDI_NotifyClient, MIDIOut_Open and MIDIOut_Close.
winecoreaudio: Implement MIDIOut_GetDevCaps and MIDIOut_GetNumDevs.
winecoreaudio: Implement MIDIOut_Prepare and MIDIOut_Unprepare.
winecoreaudio: Implement MIDIOut_Data.
winecoreaudio: Implement MIDIOut_LongData.
winecoreaudio: Implement MIDIOut_GetVolume and MIDIOut_SetVolume.
winecoreaudio: Implement MIDIOut_Reset.
winecoreaudio: Initial MIDI In support on Mac OS X.
winecoreaudio: Initial MIDI In Mach message handling.
winecoreaudio: Add MIDI In messages in MIDI_NotifyClient.
winecoreaudio: Implement MIDIIn_Open and MIDIIn_Close.
winecoreaudio: Implement MIDIIn_GetNumDevs and MIDIIn_GetDevCaps.
winecoreaudio: Implement MIDIIn_Start and MIDIIn_Stop.
winecoreaudio: Implement MIDIIn_Reset.
winecoreaudio: Implement MIDIIn_AddBuffer.
winecoreaudio: Implement MIDIIn_Prepare and MIDIIn_Unprepare.
Eric Pouech (1):
acledit: Stubbed out acledit DLL, needed by SysInternals process explorer.
Fabian Bieler (2):
d3d9/tests: Fix fog with shader test.
wined3d: Remove usesFog flag from IWineD3DVertexShaderImpl.
Francois Gouget (2):
advapi32: Fix and extend the RegQueryValueEx() tests.
advapi32/tests: Use memcmp() instead of strcmp() so that we can check 'intrazeroed' strings.
Gerald Pfeifer (1):
server: Silence compiler warning in fd_queue_async().
H. Verbeet (16):
wined3d: Add a function for dumping FBO status codes.
wined3d: Dump the FBO's attachments when its status is GL_FRAMEBUFFER_UNSUPPORTED_EXT.
wined3d: Use GL_UNSIGNED_BYTE as data type for WINED3DFMT_A8.
wined3d: Ignore SetTextureStageState on unsupported texture stages.
wined3d: Set the FBO drawbuffer using glDrawBuffer when ARB_DRAW_BUFFERS is not supported.
wined3d: Add a function to determine if a surface is the front or the backbuffer for a swapchain, and return the corresponding GLenum.
wined3d: Use surface_get_gl_buffer where appropriate.
wined3d: Properly handle the difference between GL_BACK and GL_FRONT for onscreen surfaces.
wined3d: Don't try to clear the depth stencil if there is none.
wined3d: Implement ColorFill using FBOs, if they're being used.
wined3d: Remove GL_FRAMEBUFFER_INCOMPLETE_DUPLICATE_ATTACHMENT_EXT from debug_fbostatus().
wined3d: Output pretty GL errors in checkGLcall and vcheckGLcall.
wined3d: Actually use the calculated mipmap surface sizes in IWineD3DDeviceImpl_CreateVolumeTexture.
wined3d: Improve IWineD3DVolumeImpl_LoadTexture TRACE output.
wined3d: The second parameter to glTexImage3DEXT isn't a GLenum.
wined3d: Fix the return value for IWineD3DDeviceImpl_ColorFill.
Hans Leidekker (9):
iphlpapi: Only call res_init() once per process.
msvcrt: Correct the spec file entry for _makepath.
shell32: Add a stub implementation for OpenAs_RunDLL.
urlmon: Add an implementation for CreateURLMonikerEx based on existing code for CreateURLMoniker.
msi: Install translators in the InstallODBC custom action.
msi: Install data sources in the InstallODBC custom action.
shell32: Add a stub implementation for SHMapIDListToImageListIndexAsync.
msi: Add a stub implementation for MsiEnumProductsEx{A, W}.
expand.exe: Add support for cabinet files.
Huw Davies (5):
user32: Keep track of whether the app has asked for the text buffer handle.
user32: Add a function to return the length of the text buffer.
user32: Cache the text buffer length to avoid excessive calls to strlenW.
oleaut32: Don't try to free the typeinfo if get_funcdesc fails.
oleaut32: Rewrite get_funcdesc to avoid using the funcdesc's oVft member so that it works correctly for non-dual dispinterfaces.
Hwang YunSong(황윤성) (2):
cmd: Updated Korean resource.
cmd: Updated Korean resource.
Jacek Caban (1):
hhctrl.ocx: Don't insert content item that could not be merged.
James Hawkins (9):
msi: Add tests for the concurrent installation custom action.
msi: Generalize the msi_custom_action_info struct so other custom actions can use it.
msi: Run the InstallExecute sequence if the InstallUISequnce table is empty.
msi: Add handling for the concurrent install custom action.
msi: Return MSICONDITION_NONE in MsiDatabaseIsTablePersistent if the table doesn't exist.
msi: Add the _Property table back, with tests.
msi: Add an internal MSI_ViewModify.
msi: Abstract MSI_RecordSetStream.
msi: Implement special handling for the _Streams table.
Jan Zerebecki (2):
user32: Fix to succeed reliably in test where it works by accident.
wined3d: Remove resourceStoreCriticalSection.
Jason Edmeades (2):
cmd.exe: Implement a basic 'more'.
cmd.exe: Support for DEL filename /s.
Jesse Allen (1):
wined3d: Remove fake nvidia card in GetAdapterIdentifier.
José Manuel Ferrer Ortiz (1):
winspool.drv: Add Spanish resources.
Kai Blin (1):
secur32: Move NTLM debug output to a seperate "ntlm" channel.
Ken Thomases (3):
shell32/tests: Added to-do test showing a bug with file paths with spaces.
shell32: Don't break file path at spaces in ShellExecuteEx if quoted.
shell32/tests: Test that quoting file path prevents masking at space.
Kevin Koltzau (1):
user32: Draw menu item bitmaps in the correct location when the scroll arrows are active.
Kirill K. Smirnov (3):
xcopy: Add Russian resource.
kernel32: Add partial stub for NeedCurrentDirectoryForExePath.
kernel32/tests: Add tests for NeedCurrentDirectoryForExePath.
Lei Zhang (2):
wineshelllink: Fall back to $HOME if $HOME/Desktop does not exist.
comdlg32: Initialize CommDlgExtendedError() return value for file dialogs.
Maarten Lankhorst (14):
winmm: Implement CALLBACK_WINDOW.
winmm: Pass the right message to hwnd from mixer callback.
winecfg: Update Dutch resources.
dsound: Make sure we're holding the lock on Drop And Stop.
dsound: Don't deadlock in capture because of callback.
winealsa: Drop unplayed frames instead of waiting for them.
winealsa: Clear WAVECAPS_DIRECTSOUND for capture.
winealsa: Remove disabled code.
winealsa: Introduce mixer code.
winealsa: Implement opening/closing and caps of device.
winealsa: Implement mixer controls, and add GetLineInfo.
winealsa: Implement GetLineControls in mixer.
winealsa: Implement Get/SetControlDetails in mixer.
winealsa: Unset WAVECAPS_DIRECTSOUND properly for capture.
Marcus Meissner (1):
msi: Do not mark the tables const.
Michael Kaufmann (1):
gdi32: Add a stub for CancelDC.
Michael Stefaniuc (2):
janitorial: Pass HEAP_ZERO_MEMORY as flag to HeapAlloc() instead of zeroing out the allocated memory in a later call.
winealsa: Do not check for non-NULL before HeapFree'ing a variable as the check is redundant.
Michał Wiernowolski (1):
winealsa: Improved handling of SysEx MIDI messages.
Mikołaj Zalewski (6):
winecfg: Add Polish translation.
regedit: Update Polish translation.
comctl32: toolbar: Merge TOOLBAR_GetButtonInfoA and TB_GetButtonInfoW.
comctl32: toolbar: Don't execute TB_GETBUTTONINFO if cbSize is invalid.
comctl32: toolbar: In CreateToolbarEx the default bitmap size is also 16x16.
shlwapi: Fix the handling of overflows in PathCombine[AW].
Paul Vriens (8):
crypt32/tests: Use A-version for registry functions.
ws2_32/tests: Add required parameter to CreateThread (for Win9x and WinME).
kernel32/tests: CreateRemoteThread is not implemented on win98.
kernel32/tests: GetComputerNameW is not implemented on win98.
kernel32/tests: GetLongPathNameW is not implemented on win98.
setupapi/tests: SetupDiCreateDeviceInfoListExW is not implemented on win98.
setupapi/tests: SetupCopyOEMInfA is not available on NT4.
kernel32/tests: Resource functions are not implemented on win98.
Rob Shearman (20):
msi: Add support for non-persistent strings.
msi: Move string loading and saving to string.c.
msi: Cleanup unneeded string table functions.
msi: Remove the hash table for a column when one of its values is modified since it will now be invalid.
msi: Store the column info in the MSITABLE structure.
msi: Move table creation to table.c.
msi: Create the table directly in create_table instead of requiring it to be loaded after saving.
msi: The HOLD keyword implies a temporary table, whereas database importing should lead to permanent tables, so remove the HOLD keyword.
msi: Add support for adding temporary/non-persistent data to tables.
msi: Don't add info to the _Columns table for non-persistent tables.
msi: Add a persistent flag to tables.
msi: All columns being temporary means the table is non-persistent.
msi: Add a non-persistent string instead of a persistent one if the table or row is non-persistent.
msi: Set rec to NULL after calling msiobj_release on it in msi_create_table so that we don't call msiobj_release on it again.
msi: Create the _Property table as a temporary table so that the properties aren't saved to the .msi file.
msi: Fix an off-by-one error when calculating the path and filename for the action data in the SelfRegModules action.
kernel32: Add the directory the executable was loaded from to the module search path if the module file name doesn't contain a path.
winebuild: Refer to strings used in generated stubs by symbol rather than by offset to avoid problems when the compiler aligns the strings by 2 or more bytes.
atl: Use the first entry in the object map in AtlInternalQueryInterface when IUnknown is requested.
atl: AtlModuleGetClassObject should store an intermediate pointer in obj->pCF and then query this for the requested interface.
Rolf Kalbermatter (6):
advapi32: Implement QueryServiceStatusEx.
advapi32: Make QueryServiceStatus use QueryServiceStatusEx.
advapi32: Make SERVICE_STATUS_PROCESS match the declaration in MSDN and PSDK.
advapi32: Add EnumServicesStatusExA/W stub implementation.
advapi32: Make struct service_data_t have the new SERVICE_STATUS_PROCESS struct.
advapi32: Make service_start_process return the pid to the caller.
Stefan Dösinger (15):
d3d: Enumerate palettized formats for ddraw.
d3d: Remove dependency on ddraw.h header.
d3d9: Do not allow Direct3D9::GetAdapterModeCount to be called with D3DFMT_UNKNOWN.
d3d9: Rework the converted vertex declaration management.
wined3d: Do not upload to the vbo if there's nothing to do.
wined3d: The cursor texture doesn't have GL_APPLE_client_storage backing.
wined3d: Do not allocate surfaces unless needed.
wined3d: Add a method to create a declaration from a fvf.
wined3d: Implement CreateVertexDeclarationFromFVF.
ddraw: Get rid of FVFs.
d3d: Fix ProcessVertices.
ddraw: Add a test for EnumSurfaces.
ddraw: Use EnumAttachedSurfaces to search for a render target.
ddraw: Search for texture sublevels with GetAttachedSurface.
ddraw: Use EnumAttachedSurfaces for SetColorKey.
Stefan Leichter (1):
advapi32: More tests for RegDeleteTreeA.
Tom Spear (1):
winecfg: Change WINE_ERR to WINE_TRACE since there is no real error.
Yuval Fledel (8):
include: Fix a typo in wincrypt.h.
userenv: Make GetProfileType report a normal (non-roaming) profile.
include: Introduce ntsecpkg.h.
rsaenh: Convert handle type from unsigned int to HCRYPTKEY.
include: Introduce SECPKG_INTERFACE_VERSION and extend PSECPKG_FUNCTION_TABLE accordingly.
schannel: Implement SpLsaModeInitialize and GetInfo.
schannel: Implement SpUserModeInitialize.
schannel: Tests for SpLsaModeInitialize, SpUserModeInitialize and GetInfo.
--
Alexandre Julliard
julliard@winehq.org

View File

@@ -0,0 +1,875 @@
Wine is available thanks to the work of:
Sami Aario
James Abbatiello
Michael Abd-El-Malek
Howard Abrams
Mark G. Adams
Bruno Afonso
Samir Al-Battran
Guy Albertelli
Jesse Allen
Stewart Allen
Jose Alonso
Cihan Altinay
Gustavo Junior Alves
Patrick Ammann
Markus Amsler
Bob Amstadt
C. Scott Ananian
James Dean Anderson
Russ Andersson
Torbjörn Andersson
Eric Anholt
Augusto Arcoverde da Rocha
Aaron Arvey
Dag Asheim
Fatih Aşıcı
Rémi Assailly
Jim Aston
Zimler Attila
Martin Ayotte
Viktor Babrian
Karl Backström
Bradley Baetz
Paul Bain
Warren Baird
Peter Bajusz
Tijs van Bakel
Nerijus Baliunas
Scott Bambrough
Andre Malafaya Baptista
Justin Santa Barbara
Aaron Barnes
Jean-Claude Batista
Jacek Bator
Marcel Baur
Michael Beach
Francis Beaudet
Tom Bech
David Beck
Matthew Becker
Dave Belanger
Ken Belleau
Yvon Belleau
Maxime Bellengé
Leo van den Berg
Anders Bergh
Vincent Béron
Joris Beugnies
Peter Beutner
Stephan Beuze
Georg Beyerle
Pierre Beyssac
Bobby Bingham
Ross Biro
Hartmut Birr
Marco Bizzarri
Andreas Bjerkeholt
Dennis Björklund
David Black
Zygo Blaxell
Kai Blin
Matthew Bloch
Laurent Blume
Martin Boehme
Francois Boisvert
Pim Bollen
Erik Inge Bolsø
Mike Bond
Uwe Bonnes
Andrew Borodin
Peter Bortas
Noel Borthwick
Erik Bos
Fons Botman
Sylvain Bouchard
Frederic Boulanger
Finlo Boyde
Justin Bradford
John Brezak
Alastair Bridgewater
Simon Britnell
Christian Britz
Nicolas Brouard
Marcus R. Brown
Philip Brown
Stefan Brüns
Przemyslaw Bruski
Gabriel Buades Rubio
Vitaly Budovski
Jan Van Buggenhout
Andrew Bulhak
Tobias Burnus
Nick Burns
John Burton
Bernd Buschinski
Sergei Butakov
Jonathan Buzzard
Jacek Caban
Piotr Caban
Stewart Caie
Brad Campbell
Jose Marcos López Caravaca
Michael Cardenas
Tomas Carnecky
Eddie Carpenter
Niels de Carpentier
Mike Castle
Julien Cegarra
Ron Cemer
Fabian Cenedese
Gordon Chaffee
Gael de Chalendar
Matt Chapman
Peter Chapman
Brian Chang
Antoine Chavasse
Mauro Carvalho Chehab
Jau-Horng Chen
Tisheng Chen
Rustam Chernotkach
Justin Chevrier
Jimen Ching
Hann-huei Chiou
Paul Chitescu
Kieran Clancy
Geoff Clare
Duane Clark
Matthew Clarke
Matthew Cline
Antonio Codazzi
Robert 'Admiral' Coeyman
Richard Cohen
Phil Cole
Ken Coleman
Roderick Colenbrander
Jens Collin
Kees Cook
Christian Costa
Phil Costin
Jean-Claude Cote
James Courtier-Dutton
Chuck Crayne
Stephen Crowley
Ryan Cumming
Pascal Cuoq
Bill Currie
David A. Cuthbert
Benjamin Cutler
Aric Cyr
Brian Joseph Czapiga
Ulrich Czekalla
Johan Dahlin
Wilbur N. Dale
Martin Dalecki
Gunnar Dalsnes
Fergal Daly
Qingdoa Daoo
Jean-Michel Dault
Huw D. M. Davies
Joshua Davies
Matthew Davison
Evan Deaubl
Moses DeJong
Raul Dias
Robert Dickenson
Darryl Dixon
Petar Djukic
Roman Dolejsi
Frans van Dorsselaer
Stefan Dösinger
Josh DuBois
Marcelo Duarte
Charles Duffy
Mark Dufour
EA Durbin
Zoran Dzelajlija
Jason Edmeades
Steven Edwards
Rikhardur Egilsson
Karsten Elfenbein
John Elliot
David Elliott
Steven Elliott
Dan Engel
Ralf S. Engelschall
Morten Eriksen
Jakob Eriksson
Jonathan Ernst
Nicolas Escuder
Phillip Ezolt
Chris Faherty
Carsten Fallesen
Paul Falstad
Susan Farley
Rob Farnum
David Faure
Matthias Fechner
Tim Ferguson
Raul Fernandes
Wesley Filardo
Matt Finnicum
Claus Fischer
Olaf Flebbe
Yuval Fledel
Tom Fogal
Krzysztof Foltman
Chad Fraleigh
Matthew Francis
Eric Frias
Christoph Frick
Klemens Friedl
Todd T. Fries
Alexander Frink
Michael Fritscher
Philippe Froidevaux
Mike Frysinger
Martin Fuchs
Bernd Fuhrmann
Satsuki Fujishima
Ron Gage
Louis Philippe Gagnon
Peter Galbavy
Gabriel Gambetta
Peter Ganten
Gabriel Garcia
Ramon Garcia
Jeff Garzik
Sebastian Gasiorek
Julio Cesar Gazquez
Ge van Geldorp
Klaas van Gend
Abey George
Henning Gerhardt
Brian Gerst
Matthew Ghio
Johan Gill
John Gilmore
Gabriele Giorgetti
Kristoffer Gleditsch
Christian Gmeiner
Jody Goldberg
David Golding
Markus Gömmel
Bob Goodwin
Eugeny Gorelov
Zach Gorman
Florian Goth
Alexander Gottwald
François Gouget
J A Gow
Hans de Graaff
Igor Grahek
David Grant
Brian Grayson
Jaco Greeff
Chris Green
Jason Green
Jon Griffiths
Kevin Groeneveld
Gerhard W. Gruber
Tobias Gruetzmacher
Daniel Gudbjartsson
Adam Gundy
Michael Günnewig
Ivan Gyurdiev
Albert den Haan
Jess Haas
David D. Hagood
Robert W Hall
Patrick Haller
Stefan Haller
Jake Hamby
David Hammerton
Noomen Hamza
Anssi Hannula
Charles M. Hannum
Yorick Hardy
Boaz Harrosh
Adrian Harvey
John Harvey
James Hatheway
Geoffrey Hausheer
Kalevi J Hautaniemi
Bill Hawes
Dave Hawkes
James Hawkins
Peter Hawkins
Shi Quan He
Mike Hearn
Waldek Hebisch
Lars Heete
Cameron Heide
Hagen Heiduck
Jukka Heinonen
David Hemmo
Pierre d'Herbemont
Juraj Hercek
Bernd Herd
Robert van Herk
Theodore S. Hetke
Haithem Hmida
Roger Hoang
Jochen Hoenicke
Henning Hoffmann
Jens Hoffmann
Erik Hofman
John K. Hohm
Kevin Holbrook
Nick Holloway
Alfons Hoogervorst
Aaron Hope
Enrico Horn
Casper Hornstrup
Olivier Houchard
Onno Hovers
David Howells
Jeffrey Hsu
Zhangrong Huang
Edgar Hucek
Stefan Huehner
Andrew John Hughes
Tom Hughes
Joris Huizer
Peter Hunnisett
Choe Hwanjin
Miguel de Icaza
Jukka Iivonen
Vladdy Impaler
Hiroshi Inoue
Kostya Ivanov
Serge Ivanov
Peter Ivanyi
Michael Jacobsen
Francois Jacques
Lee Jaekil
Gautam Jain
Jeroen Janssen
Oldrich Jedlicka
György 'Nog' Jeney
Jerry Jenkins
Niels Kristian Bech Jensen
Ron Jensen
Byeong-Sik Jeon
Rajeev Jhangiani
Jerry Ji
Antonio Larrosa Jiménez
Bill Jin
Jeff Johann
André Johansen
Andrew Johnston
Alexandre Julliard
Jussi Jumppanen
Bang Jun-Young
Michael Jung
Raphael Junqueira
James Juran
Achim Kaiser
Rolf Kalbermatter
Maciek Kaliszewski
Kaj Kaloinen
Alexander Kanavin
Jukka Kangas
Thorsten Kani
Pavel Kankovsky
Michael Karcher
Niclas Karlsson
Jochen Karrer
Valery Kartel
Rudolf Kastl
Michael Kaufmann
Tapio Kautto
Dan Kegel
Matthew Kehrer
Don Kelly
Thomas Kho
Vijay Kiran Kamuju
Andreas Kirschbaum
Simon Kissane
Rafael Kitover
Rein Klazes
Albrecht Kleine
Dietmar Kling
Johannes Koch
Eric Kohl
Kevin Koltzau
Jon Konrath
Ilya Konstantinov
Oleg Korda
Ilya Korniyko
Alex Korobka
Kusanagi Kouichi
András Kovács
Zoltan Kovacs
Yuri Kozlov
Milko Krachounov
Saulius Krasuckas
Jan Kratochvil
David Kredba
Marko Kreen
Greg Kreider
Phil Krylov
Junichi Kuchinishi
Vik Kumar
Anand Kumria
Gerson Kurz
Ove Kåven
Jean Labrousse
Dusan Lacko
Eric Laforest
William Lahti
Scott A. Laird
Matthew Lake
Hamza Lakhani
David Lee Lambert
Tony Lambregts
Eric Lammerts
Juan Lang
Stephen Langasek
Sean Langley
Dan Langlois
Maarten Lankhorst
Peter Berg Larsen
Thomas Brix Larsen
Alexander Larsson
Tommy Schultz Lassen
Alex Villacís Lasso
David Lassonde
Jeff Latimer
Paul Laufer
Jaekil Lee
Sander van Leeuwen
Stefan Leichter
Hans Leidekker
Peter Lemenkov
Kristiaan Lenaerts
Louis Lenders
Crestez Leonard
Karl Lessard
Pascal Lessard
Blake Leverett
Wim Lewis
Andrew Lewycky
John Li
Weisheng Li
Xiang Li
David Lichterman
Michael Lin
Per Lindström
Vitaly Lipatov
Brian Litzinger
Anderson Lizardo
Juergen Lock
Phil Lodwick
Charles Loep
Tobias Loew
Martin von Loewis
Michiel van Loon
Richard A Lough
Carlos Lozano
Jean-Bruno Luginbühl
Denis Lukianov
Alexander V. Lukyanov
Daniel Lund
Magnus Lundborg
Robert Lunnon
Jiuming Luo
Christian Lupien
Stephane Lussier
Steve Lustbader
David Luyer
Ragnvald Maartmann-Moe IV
José Marcos López
Kenneth MacDonald
Peter MacDonald
Ondrej Macek
Kester Maddock
Pierre Mageau
Michael C. Maggio
William Magro
Emmanuel Maillard
Rok Mandeljc
Vitaliy Margolen
Cyril Margorin
Daniel Marmier
Juergen Marquardt
Greg Marsden
Kris Marsh
Philip Mason
Alberto Massari
Ricardo Massaro
Matthew Mastracci
Keith Matthews
Gregg Mattinson
Jason Mawdsley
Joerg Mayer
Eugene Mayevski
Bryan Mayland
Davin McCall
Rob McClinton
Michael McCormack
David McCullough
Alastair McKinstry
Jason McMullan
Caolan McNamara
Patrick J. McNerthney
Paul McNett
Bill Medland
Marcus Meissner
Josef Meixner
Américo José Melo
Fabrice Ménard
Graham Menhennitt
Thomas Mertes
Johann Messner
David Metcalfe
Francois Methot
Travis Michielsen
Wojciech Migda
Toufic Milan
Robert Millan
Paul Millar
Dave Miller
David Miller
Donn Miller
Jeff Miller
Bruce Milner
Michal Janusz Miroslaw
Anish Mistry
Royce Mitchell III
Sagar Mittal
Peter Mladek
Steffen Moeller
Andreas Mohr
Todd Mokros
Slava Monich
James Moody
David Moore
Chris Morgan
Kai Morich
Richard Mortimer
Adam D. Moss
Jeff Muizelaar
Vasudev Mulchandani
Krishna Murthy
Rick Mutzke
Philippe De Muyter
Kimmo Myllyvirta
Zoltan Nagy
Itai Nahshon
Filip Navara
Dustin Navea
Felix Nawothnig
Jonathan Naylor
Nathan Neulinger
Christian Neumair
Jeremy Newman
Tim Newsome
Thuy Nguyen
Kristian Nielsen
Arjen Nienhuis
Jan Nieuwenhuizen
Nix N. Nix
Sami Nopanen
Leonard Norrgård
Robert North
Oleh R. Nykyforchyn
Per Nystrom
Robert O'Callahan
Damien O'Neill
Mike O'Regan
Peter Oberndorfer
Walt Ogburn
Damyan Ognyanoff
Henrik Olsen
Magnus Olsen
Roger Olson
Neil Olver
José Manuel Ferrer Ortiz
Knut St. Osmundsen
Andriy Palamarchuk
Giovanni Pancotti
Andrey Panov
Won Kyu Park
Evan G. Parry
Jon Parshall
Alex Pasadyn
Sven Paschukat
Michal Pasternak
Gerard Patel
Michael Patra
Murali Pattathe
Catalin Patulea
Doug Paul
Dimitrie O. Paun
Bernd Paysan
Victor Pelt
Brad Pepers
James Perry
Ori Pessach
Nemeth Peter
Jim Peterson
Sylvain Petreolle
Ofir Petruska
Diego Pettenò
Gerald Pfeifer
Jason Phillips
Dave Pickles
Marco Pietrobono
Ian Pilcher
Simeon Pilgrim
Martin Pilka
Laurent Pinchart
Aviad Pineles
Brian Pirie
William Poetra Yoga Hadisoesen
Gracjan Polak
Michael Poole
Eric Pouech
Robert Pouliot
Vahid Pourlotfali
Chad Powell
Joseph Pranevich
Raimonds Praude
Aneurin Price
Alex Priem
Oleg Prokhorov
Roberto Augusto Pungartnik
Francesco Di Punzio
Ivan Leo Puoti
Andrew de Quincey
Paul Quinn
Peter Quiring
Pete Ratzlaff
Ron Record
Robert Reif
Petter Reinholdtsen
Daniel Remenak
Andrew de los Reyes
Keith Reynolds
Slaven Rezic
John Richardson
Rick Richardson
Frank Richter
Simon Richter
Douglas Ridgway
Konrad Rieck
Andrew Riedi
Detlef Riekenberg
Robert Riggs
Peter Riocreux
Scott Ritchie
Matthew Robertson
Vedran Rodic
Wino Rojo
Troy Rollo
Drew Ronneberg
Andreas Rosenberg
Bernhard Rosenkraenzer
Pavel Roskin
Herbert Rosmanith
Elias Ross
Lilia Roumiantseva
Paul Rupe
Johannes Ruscheinski
Andy Rysin
Daniel Sabo
Adam Sacarny
Ivan de Saedeleer
Madhura Sahasrabudhe
Kasper Sandberg
Thomas Sandford
Constantine Sapuntzakis
Pablo Saratxaga
Kouji Sasaki
Carl van Schaik
Paul van Schayck
Daniel Schepler
Johannes E. Schindelin
Christian Schlaile
Peter Schlaile
Michael Schlüter
Ulrich Schmid
Axel Schmidt
Bernd Schmidt
Ian Schmidt
Juergen Schmied
Ingo Schneider
Victor Schneider
Kees Schoenmakers
Glenn Schrader
Waldeck Schutzer
Federico Schwindt
Wolfgang Schwotzer
Dan Scott
Tim Segall
Hajime Segawa
Pavel Semerad
Stas Sergeev
Jeremy Shaw
Robert Shearman
John Sheets
Shachar Shemesh
Santosh Siddheshwar
Yngvi Sigurjonsson
Gustavo Noronha Silva
Stephen Simmons
Dmitrij Sinukov
Willie Sippel
Daniel Skorka
Jesper Skov
Neil Skrypuch
Rick Sladkey
Sasha Slijepcevic
Kirill Smelkov
David Smith
Jeff Smith
William Smith
Juris Smotrovs
Ed Snow
Jaroslaw Piotr Sobieszek
Carl Sopchak
Alexander N. Sørnes
Liu Spider
Patrick Spinler
Serge S. Spiridonoff
Alexey Spiridonov
Sylvain St-Germain
Malte Starostik
Gavriel State
Sheri Steeves
Michael Stefaniuc
Jozef Stefanka
Nikolay Stefanov
Igor Stepin
Norman Stevens
Aric Stewart
Oliver Stieber
William Stinson
Richard Stonehouse
Dominik Strasser
Patrik Stridvall
Vadim Strizhevsky
Bertho Stultiens
John F Sturtz
Abraham Sudhakar
Supphachoke Suntiwichaya
Charles Suprin
James Sutherland
Erik Svendsen
Dylan Taft
Yoshiro Takeno
Hidenori Takeshima
Andrew Talbot
Hiroshi Tanabe
Tristan Tarrant
Andrew Taylor
Brian Teague
Petr Tesarik
Wolfgang Thaller
Jean-Philippe Theriault
Joshua Thielen
Ingmar Thiemann
Dirk Thierbach
Jean-Louis Thirot
Ken Thomases
Duncan C Thomson
Geoff Thorpe
Adrian Thurston
Goran Thyni
Steve Tibbett
Dmitry Timoshkov
Marco Timpano
Jimmy Tirtawangsa
Petr Tomasek
Jon Tombs
Linus Torvalds
Luc Tourangeau
Jeff Tranter
Gregory Trubetskoy
Lauri Tulmin
Petri Tuomola
Sergey Turchanov
Warren Turkal
Andrey Turkin
Gregory M. Turner
Lionel Ulmer
Moshe Vainer
Hleb Valoska
Hannu Valtonen
Tomas Vanek
Charles Vaughn
Michael Veksler
Henri Verbeet
Sven Verdoolaege
Martijn Vernooij
Todd Vierling
Brian Vincent
Leonardo Quijano Vincenzi
Vasily I. Volchenko
Erez Volk
Jerome Vouillon
Paul Vriens
Duc Vuong
William Waghorn
Ferenc Wagner
Ronan Waide
Daniel Walker
Martin Walker
Simon Walton
Owen Wang
Eric Warnke
Andrew Webb
Leigh Wedding
Randy Weems
Manfred Weichel
Thomas Weidenmueller
Ulrich Weigand
David Welch
Morten Welinder
Marcelo Welter
Mark Westcott
Michael Wetherell
Jeremy White
Len White
Lawson Whitney
Tom Wickline
Martin Wilck
Jan Willamowius
Carl Williams
Eric Williams
Grant Williamson
Jed Wing
Dan Wolf
Erwin Wolff
Philipp Wollermann
Ivan Wong
Brandon Woodmansee
Alex Woods
Cliff Wright
Gerold Jens Wucherpfennig
Karl Guenter Wuensch
Glenn Wurster
Mehmet Yasar
Alexander Yaworsky
Sean Young
Eric Youngdale
James Youngman
Nikita V. Youshchenko
Hwang YunSong
Mikołaj Zalewski
Simen Zamecnik
Steve Zellers
Jan Zerebecki
John Zero
Lei Zhang
Yuxi Zhang
Andrew Ziem
Nikolas Zimmermann
Alex Zorach
Nathan Zorich
Luiz Otavio L. Zorzella
Rizsanyi Zsolt
Per Ångström
Peter Åstrand

View File

@@ -0,0 +1,502 @@
GNU LESSER GENERAL PUBLIC LICENSE
Version 2.1, February 1999
Copyright (C) 1991, 1999 Free Software Foundation, Inc.
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
[This is the first released version of the Lesser GPL. It also counts
as the successor of the GNU Library Public License, version 2, hence
the version number 2.1.]
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
Licenses are intended to guarantee your freedom to share and change
free software--to make sure the software is free for all its users.
This license, the Lesser General Public License, applies to some
specially designated software packages--typically libraries--of the
Free Software Foundation and other authors who decide to use it. You
can use it too, but we suggest you first think carefully about whether
this license or the ordinary General Public License is the better
strategy to use in any particular case, based on the explanations below.
When we speak of free software, we are referring to freedom of use,
not price. Our General Public Licenses are designed to make sure that
you have the freedom to distribute copies of free software (and charge
for this service if you wish); that you receive source code or can get
it if you want it; that you can change the software and use pieces of
it in new free programs; and that you are informed that you can do
these things.
To protect your rights, we need to make restrictions that forbid
distributors to deny you these rights or to ask you to surrender these
rights. These restrictions translate to certain responsibilities for
you if you distribute copies of the library or if you modify it.
For example, if you distribute copies of the library, whether gratis
or for a fee, you must give the recipients all the rights that we gave
you. You must make sure that they, too, receive or can get the source
code. If you link other code with the library, you must provide
complete object files to the recipients, so that they can relink them
with the library after making changes to the library and recompiling
it. And you must show them these terms so they know their rights.
We protect your rights with a two-step method: (1) we copyright the
library, and (2) we offer you this license, which gives you legal
permission to copy, distribute and/or modify the library.
To protect each distributor, we want to make it very clear that
there is no warranty for the free library. Also, if the library is
modified by someone else and passed on, the recipients should know
that what they have is not the original version, so that the original
author's reputation will not be affected by problems that might be
introduced by others.
Finally, software patents pose a constant threat to the existence of
any free program. We wish to make sure that a company cannot
effectively restrict the users of a free program by obtaining a
restrictive license from a patent holder. Therefore, we insist that
any patent license obtained for a version of the library must be
consistent with the full freedom of use specified in this license.
Most GNU software, including some libraries, is covered by the
ordinary GNU General Public License. This license, the GNU Lesser
General Public License, applies to certain designated libraries, and
is quite different from the ordinary General Public License. We use
this license for certain libraries in order to permit linking those
libraries into non-free programs.
When a program is linked with a library, whether statically or using
a shared library, the combination of the two is legally speaking a
combined work, a derivative of the original library. The ordinary
General Public License therefore permits such linking only if the
entire combination fits its criteria of freedom. The Lesser General
Public License permits more lax criteria for linking other code with
the library.
We call this license the "Lesser" General Public License because it
does Less to protect the user's freedom than the ordinary General
Public License. It also provides other free software developers Less
of an advantage over competing non-free programs. These disadvantages
are the reason we use the ordinary General Public License for many
libraries. However, the Lesser license provides advantages in certain
special circumstances.
For example, on rare occasions, there may be a special need to
encourage the widest possible use of a certain library, so that it becomes
a de-facto standard. To achieve this, non-free programs must be
allowed to use the library. A more frequent case is that a free
library does the same job as widely used non-free libraries. In this
case, there is little to gain by limiting the free library to free
software only, so we use the Lesser General Public License.
In other cases, permission to use a particular library in non-free
programs enables a greater number of people to use a large body of
free software. For example, permission to use the GNU C Library in
non-free programs enables many more people to use the whole GNU
operating system, as well as its variant, the GNU/Linux operating
system.
Although the Lesser General Public License is Less protective of the
users' freedom, it does ensure that the user of a program that is
linked with the Library has the freedom and the wherewithal to run
that program using a modified version of the Library.
The precise terms and conditions for copying, distribution and
modification follow. Pay close attention to the difference between a
"work based on the library" and a "work that uses the library". The
former contains code derived from the library, whereas the latter must
be combined with the library in order to run.
GNU LESSER GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License Agreement applies to any software library or other
program which contains a notice placed by the copyright holder or
other authorized party saying it may be distributed under the terms of
this Lesser General Public License (also called "this License").
Each licensee is addressed as "you".
A "library" means a collection of software functions and/or data
prepared so as to be conveniently linked with application programs
(which use some of those functions and data) to form executables.
The "Library", below, refers to any such software library or work
which has been distributed under these terms. A "work based on the
Library" means either the Library or any derivative work under
copyright law: that is to say, a work containing the Library or a
portion of it, either verbatim or with modifications and/or translated
straightforwardly into another language. (Hereinafter, translation is
included without limitation in the term "modification".)
"Source code" for a work means the preferred form of the work for
making modifications to it. For a library, complete source code means
all the source code for all modules it contains, plus any associated
interface definition files, plus the scripts used to control compilation
and installation of the library.
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running a program using the Library is not restricted, and output from
such a program is covered only if its contents constitute a work based
on the Library (independent of the use of the Library in a tool for
writing it). Whether that is true depends on what the Library does
and what the program that uses the Library does.
1. You may copy and distribute verbatim copies of the Library's
complete source code as you receive it, in any medium, provided that
you conspicuously and appropriately publish on each copy an
appropriate copyright notice and disclaimer of warranty; keep intact
all the notices that refer to this License and to the absence of any
warranty; and distribute a copy of this License along with the
Library.
You may charge a fee for the physical act of transferring a copy,
and you may at your option offer warranty protection in exchange for a
fee.
2. You may modify your copy or copies of the Library or any portion
of it, thus forming a work based on the Library, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) The modified work must itself be a software library.
b) You must cause the files modified to carry prominent notices
stating that you changed the files and the date of any change.
c) You must cause the whole of the work to be licensed at no
charge to all third parties under the terms of this License.
d) If a facility in the modified Library refers to a function or a
table of data to be supplied by an application program that uses
the facility, other than as an argument passed when the facility
is invoked, then you must make a good faith effort to ensure that,
in the event an application does not supply such function or
table, the facility still operates, and performs whatever part of
its purpose remains meaningful.
(For example, a function in a library to compute square roots has
a purpose that is entirely well-defined independent of the
application. Therefore, Subsection 2d requires that any
application-supplied function or table used by this function must
be optional: if the application does not supply it, the square
root function must still compute square roots.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Library,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Library, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote
it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Library.
In addition, mere aggregation of another work not based on the Library
with the Library (or with a work based on the Library) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may opt to apply the terms of the ordinary GNU General Public
License instead of this License to a given copy of the Library. To do
this, you must alter all the notices that refer to this License, so
that they refer to the ordinary GNU General Public License, version 2,
instead of to this License. (If a newer version than version 2 of the
ordinary GNU General Public License has appeared, then you can specify
that version instead if you wish.) Do not make any other change in
these notices.
Once this change is made in a given copy, it is irreversible for
that copy, so the ordinary GNU General Public License applies to all
subsequent copies and derivative works made from that copy.
This option is useful when you wish to copy part of the code of
the Library into a program that is not a library.
4. You may copy and distribute the Library (or a portion or
derivative of it, under Section 2) in object code or executable form
under the terms of Sections 1 and 2 above provided that you accompany
it with the complete corresponding machine-readable source code, which
must be distributed under the terms of Sections 1 and 2 above on a
medium customarily used for software interchange.
If distribution of object code is made by offering access to copy
from a designated place, then offering equivalent access to copy the
source code from the same place satisfies the requirement to
distribute the source code, even though third parties are not
compelled to copy the source along with the object code.
5. A program that contains no derivative of any portion of the
Library, but is designed to work with the Library by being compiled or
linked with it, is called a "work that uses the Library". Such a
work, in isolation, is not a derivative work of the Library, and
therefore falls outside the scope of this License.
However, linking a "work that uses the Library" with the Library
creates an executable that is a derivative of the Library (because it
contains portions of the Library), rather than a "work that uses the
library". The executable is therefore covered by this License.
Section 6 states terms for distribution of such executables.
When a "work that uses the Library" uses material from a header file
that is part of the Library, the object code for the work may be a
derivative work of the Library even though the source code is not.
Whether this is true is especially significant if the work can be
linked without the Library, or if the work is itself a library. The
threshold for this to be true is not precisely defined by law.
If such an object file uses only numerical parameters, data
structure layouts and accessors, and small macros and small inline
functions (ten lines or less in length), then the use of the object
file is unrestricted, regardless of whether it is legally a derivative
work. (Executables containing this object code plus portions of the
Library will still fall under Section 6.)
Otherwise, if the work is a derivative of the Library, you may
distribute the object code for the work under the terms of Section 6.
Any executables containing that work also fall under Section 6,
whether or not they are linked directly with the Library itself.
6. As an exception to the Sections above, you may also combine or
link a "work that uses the Library" with the Library to produce a
work containing portions of the Library, and distribute that work
under terms of your choice, provided that the terms permit
modification of the work for the customer's own use and reverse
engineering for debugging such modifications.
You must give prominent notice with each copy of the work that the
Library is used in it and that the Library and its use are covered by
this License. You must supply a copy of this License. If the work
during execution displays copyright notices, you must include the
copyright notice for the Library among them, as well as a reference
directing the user to the copy of this License. Also, you must do one
of these things:
a) Accompany the work with the complete corresponding
machine-readable source code for the Library including whatever
changes were used in the work (which must be distributed under
Sections 1 and 2 above); and, if the work is an executable linked
with the Library, with the complete machine-readable "work that
uses the Library", as object code and/or source code, so that the
user can modify the Library and then relink to produce a modified
executable containing the modified Library. (It is understood
that the user who changes the contents of definitions files in the
Library will not necessarily be able to recompile the application
to use the modified definitions.)
b) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (1) uses at run time a
copy of the library already present on the user's computer system,
rather than copying library functions into the executable, and (2)
will operate properly with a modified version of the library, if
the user installs one, as long as the modified version is
interface-compatible with the version that the work was made with.
c) Accompany the work with a written offer, valid for at
least three years, to give the same user the materials
specified in Subsection 6a, above, for a charge no more
than the cost of performing this distribution.
d) If distribution of the work is made by offering access to copy
from a designated place, offer equivalent access to copy the above
specified materials from the same place.
e) Verify that the user has already received a copy of these
materials or that you have already sent this user a copy.
For an executable, the required form of the "work that uses the
Library" must include any data and utility programs needed for
reproducing the executable from it. However, as a special exception,
the materials to be distributed need not include anything that is
normally distributed (in either source or binary form) with the major
components (compiler, kernel, and so on) of the operating system on
which the executable runs, unless that component itself accompanies
the executable.
It may happen that this requirement contradicts the license
restrictions of other proprietary libraries that do not normally
accompany the operating system. Such a contradiction means you cannot
use both them and the Library together in an executable that you
distribute.
7. You may place library facilities that are a work based on the
Library side-by-side in a single library together with other library
facilities not covered by this License, and distribute such a combined
library, provided that the separate distribution of the work based on
the Library and of the other library facilities is otherwise
permitted, and provided that you do these two things:
a) Accompany the combined library with a copy of the same work
based on the Library, uncombined with any other library
facilities. This must be distributed under the terms of the
Sections above.
b) Give prominent notice with the combined library of the fact
that part of it is a work based on the Library, and explaining
where to find the accompanying uncombined form of the same work.
8. You may not copy, modify, sublicense, link with, or distribute
the Library except as expressly provided under this License. Any
attempt otherwise to copy, modify, sublicense, link with, or
distribute the Library is void, and will automatically terminate your
rights under this License. However, parties who have received copies,
or rights, from you under this License will not have their licenses
terminated so long as such parties remain in full compliance.
9. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Library or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Library (or any work based on the
Library), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Library or works based on it.
10. Each time you redistribute the Library (or any work based on the
Library), the recipient automatically receives a license from the
original licensor to copy, distribute, link with or modify the Library
subject to these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties with
this License.
11. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Library at all. For example, if a patent
license would not permit royalty-free redistribution of the Library by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Library.
If any portion of this section is held invalid or unenforceable under any
particular circumstance, the balance of the section is intended to apply,
and the section as a whole is intended to apply in other circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
12. If the distribution and/or use of the Library is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Library under this License may add
an explicit geographical distribution limitation excluding those countries,
so that distribution is permitted only in or among countries not thus
excluded. In such case, this License incorporates the limitation as if
written in the body of this License.
13. The Free Software Foundation may publish revised and/or new
versions of the Lesser General Public License from time to time.
Such new versions will be similar in spirit to the present version,
but may differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the Library
specifies a version number of this License which applies to it and
"any later version", you have the option of following the terms and
conditions either of that version or of any later version published by
the Free Software Foundation. If the Library does not specify a
license version number, you may choose any version ever published by
the Free Software Foundation.
14. If you wish to incorporate parts of the Library into other free
programs whose distribution conditions are incompatible with these,
write to the author to ask for permission. For software which is
copyrighted by the Free Software Foundation, write to the Free
Software Foundation; we sometimes make exceptions for this. Our
decision will be guided by the two goals of preserving the free status
of all derivatives of our free software and of promoting the sharing
and reuse of software generally.
NO WARRANTY
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Libraries
If you develop a new library, and you want it to be of the greatest
possible use to the public, we recommend making it free software that
everyone can redistribute and change. You can do so by permitting
redistribution under these terms (or, alternatively, under the terms of the
ordinary General Public License).
To apply these terms, attach the following notices to the library. It is
safest to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least the
"copyright" line and a pointer to where the full notice is found.
<one line to give the library's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Also add information on how to contact you by electronic and paper mail.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the library, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the
library `Frob' (a library for tweaking knobs) written by James Random Hacker.
<signature of Ty Coon>, 1 April 1990
Ty Coon, President of Vice
That's all there is to it!

View File

@@ -0,0 +1,17 @@
Copyright (c) 1993-2007 the Wine project authors (see the file AUTHORS
for a complete list)
Wine is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the
Free Software Foundation; either version 2.1 of the License, or (at
your option) any later version.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
A copy of the GNU Lesser General Public License is included in the
Wine distribution in the file COPYING.LIB. If you did not receive this
copy, write to the Free Software Foundation, Inc., 51 Franklin St,
Fifth Floor, Boston, MA 02110-1301, USA.

View File

@@ -0,0 +1,25 @@
Note: Wine is now distributed under the terms of the GNU Lesser
General Public License, as specified in the file LICENSE.
Older releases of Wine, up to release 20020228, were distributed under
the following license:
Copyright (c) 1993-2002 the Wine project authors (see the file AUTHORS
for a complete list)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View File

@@ -0,0 +1,196 @@
1. INTRODUCTION
Wine is a program which allows running Microsoft Windows programs
(including DOS, Windows 3.x and Win32 executables) on Unix. It
consists of a program loader which loads and executes a Microsoft
Windows binary, and a library (called Winelib) that implements Windows
API calls using their Unix or X11 equivalents. The library may also
be used for porting Win32 code into native Unix executables.
Wine is free software, released under the GNU LGPL; see the file
LICENSE for the details.
2. QUICK START
Whenever you compile from source, it is recommended to use the Wine
Installer to build and install Wine. From the top-level directory
of the Wine source (which contains this file), run:
./tools/wineinstall
Run programs as "wine program". For more information and problem
resolution, read the rest of this file, the Wine man page, and
especially the wealth of information found at http://www.winehq.org.
3. REQUIREMENTS
To compile and run Wine, you must have one of the following:
Linux version 2.0.36 or above
FreeBSD 5.3 or later
Solaris x86 2.5 or later
NetBSD-current
Mac OS X 10.4 or later
As Wine requires kernel-level thread support to run, only the operating
systems mentioned above are supported.
Other operating systems which support kernel threads may be supported
in the future.
Linux info:
While Linux 2.2.x should still work and Linux 2.0.x may still work
(older 2.0.x versions had thread-related crashes),
it's best to have a current kernel such as 2.4.x or 2.6.x.
FreeBSD info:
Wine should build on FreeBSD 4.x and FreeBSD 5.x, but versions before
FreeBSD 5.3 will generally not work properly.
More information can be found in the FreeBSD ports tree at
<ftp://ftp.freebsd.org/pub/FreeBSD/ports/ports/emulators/wine/>.
Solaris info:
You will most likely need to build Wine with the GNU toolchain
(gcc, gas, etc.). Warning : installing gas does *not* ensure that it
will be used by gcc. Recompiling gcc after installing gas or
symlinking cc, as and ld to the gnu tools is said to be necessary.
NetBSD info:
Make sure you have the USER_LDT, SYSVSHM, SYSVSEM, and SYSVMSG options
turned on in your kernel.
Mac OS X info:
You need Xcode 2.4 or later to build properly on x86.
Supported file systems:
Wine should run on most file systems. However, Wine will fail to start
if umsdos is used for the /tmp directory. A few compatibility problems have
also been reported using files accessed through Samba. Also, as NTFS
can only be used safely with readonly access for now, we recommend against
using NTFS, as Windows programs need write access almost everywhere.
In case of NTFS files, copy over to a writable location.
Basic requirements:
You need to have the X11 development include files installed
(called xlib6g-dev in Debian and XFree86-devel in Red Hat).
Build tool requirements:
On x86 Systems gcc >= 2.7.2 is required.
Versions earlier than 2.7.2.3 may have problems when certain files
are compiled with optimization, often due to problems with header file
management.
Of course you also need "make" (most likely GNU make).
You also need flex version 2.5 or later and bison.
Optional support libraries:
Run ./configure --verbose to see the optional libraries that could
be used but aren't found on your system.
4. COMPILATION
In case you chose to not use wineinstall, run the following commands
to build Wine:
./configure
make depend
make
This will build the program "wine" and numerous support libraries/binaries.
The program "wine" will load and run Windows executables.
The library "libwine" ("Winelib") can be used to compile and link
Windows source code under Unix.
To see compile configuration options, do ./configure --help.
To upgrade to a new release by using a patch file, first cd to the
top-level directory of the release (the one containing this README
file). Then do a "make clean", and patch the release with:
bunzip2 -c patch-file | patch -p1
where "patch-file" is the name of the patch file (something like
wine-0.9.x.diff.bz2). You can then re-run "./configure", and then
run "make depend && make".
5. SETUP
Once Wine has been built correctly, you can do "make install"; this
will install the wine executable, the Wine man page, and a few other
needed files.
Don't forget to uninstall any conflicting previous Wine installation
first. Try either "dpkg -r wine" or "rpm -e wine" or "make uninstall"
before installing.
See the Support area at http://www.winehq.org/ for configuration
hints.
In case of library loading errors
(e.g. "Error while loading shared libraries: libntdll.so"), make sure
to add the library path to /etc/ld.so.conf and run ldconfig as root.
6. RUNNING PROGRAMS
When invoking Wine, you may specify the entire path to the executable,
or a filename only.
For example: to run Solitaire:
wine sol (using the search Path as specified in
wine sol.exe the config file to locate the file)
wine c:\\windows\\sol.exe (using DOS filename syntax)
wine /usr/windows/sol.exe (using Unix filename syntax)
wine sol.exe /parameter1 -parameter2 parameter3
(calling program with parameters)
Wine is not yet complete, so several programs may crash. In that crash
you will be dropped into the debugger so that you can investigate and
fix the problem. For more information on how to do this, please check
the debugging section of the Wine Developer's Guide.
7. GETTING MORE INFORMATION
WWW: A great deal of information about Wine is available from WineHQ at
http://www.winehq.org/ : various Wine Guides, application database,
bug tracking. This is probably the best starting point.
FAQ: The Wine FAQ is located at http://www.winehq.org/FAQ
Usenet: You can discuss Wine-related issues and get help
on comp.emulators.ms-windows.wine.
Bugs: Report bugs to Wine Bugzilla at http://bugs.winehq.org
Please search the bugzilla database to check whether your
problem is already found before posting a bug report. You can
also post bug reports to comp.emulators.ms-windows.wine.
IRC: Online help is available at channel #WineHQ on irc.freenode.net.
GIT: The current Wine development tree is available through GIT.
Go to http://www.winehq.org/site/git for more information.
Mailing lists:
There are several mailing lists for Wine users and developers;
see http://www.winehq.org/forums for more information.
Wiki: The Wine Wiki is located at http://wiki.winehq.org
If you add something, or fix a bug, please send a patch (in 'diff -u'
format) to wine-patches@winehq.org list for inclusion in the next
release.
--
Alexandre Julliard
julliard@winehq.org

View File

@@ -0,0 +1 @@
Wine version 0.9.36

View File

@@ -0,0 +1,8 @@
<?xml version="1.0"?>
<!DOCTYPE project SYSTEM "tools/rbuild/project.dtd">
<group>
<directory name="dlls">
<xi:include href="dlls/dlls.rbuild" />
</directory>
</group>

View File

@@ -0,0 +1,170 @@
Microsoft Developer Studio Workspace File, Format Version 6.00
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
###############################################################################
Project: "d3d8"=".\dlls\d3d8\d3d8.dsp" - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
Begin Project Dependency
Project_Dep_Name wine
End Project Dependency
Begin Project Dependency
Project_Dep_Name wined3d
End Project Dependency
Begin Project Dependency
Project_Dep_Name ddraw
End Project Dependency
Begin Project Dependency
Project_Dep_Name ddrawex
End Project Dependency
Begin Project Dependency
Project_Dep_Name d3d9
End Project Dependency
}}}
###############################################################################
Project: "d3d8_test"=".\dlls\d3d8\tests\d3d8_test.dsp" - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
Begin Project Dependency
Project_Dep_Name d3d8
End Project Dependency
}}}
###############################################################################
Project: "d3d9"=".\dlls\d3d9\d3d9.dsp" - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
Begin Project Dependency
Project_Dep_Name wine
End Project Dependency
Begin Project Dependency
Project_Dep_Name wined3d
End Project Dependency
}}}
###############################################################################
Project: "d3d9_test"=".\dlls\d3d9\tests\d3d9_test.dsp" - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
Begin Project Dependency
Project_Dep_Name d3d9
End Project Dependency
}}}
###############################################################################
Project: "ddraw"=".\dlls\ddraw\ddraw.dsp" - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
Begin Project Dependency
Project_Dep_Name wine
End Project Dependency
Begin Project Dependency
Project_Dep_Name wined3d
End Project Dependency
}}}
###############################################################################
Project: "ddraw_test"=".\dlls\ddraw\tests\ddraw_test.dsp" - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
Begin Project Dependency
Project_Dep_Name ddraw
End Project Dependency
}}}
###############################################################################
Project: "ddrawex"=".\dlls\ddrawex\ddrawex.dsp" - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
Begin Project Dependency
Project_Dep_Name wine
End Project Dependency
Begin Project Dependency
Project_Dep_Name wined3d
End Project Dependency
}}}
###############################################################################
Project: "wine"=".\libs\wine\wine.dsp" - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
}}}
###############################################################################
Project: "wined3d"=".\dlls\wined3d\wined3d.dsp" - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
Begin Project Dependency
Project_Dep_Name wine
End Project Dependency
}}}
###############################################################################
Global:
Package=<5>
{{{
}}}
Package=<3>
{{{
}}}
###############################################################################

View File

@@ -0,0 +1,164 @@
/*
* IDirect3DBaseTexture8 implementation
*
* Copyright 2005 Oliver Stieber
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "config.h"
#include "d3d8_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(d3d8);
/* IDirect3DBaseTexture8 IUnknown parts follow: */
static HRESULT WINAPI IDirect3DBaseTexture8Impl_QueryInterface(LPDIRECT3DBASETEXTURE8 iface, REFIID riid, LPVOID *ppobj) {
IDirect3DBaseTexture8Impl *This = (IDirect3DBaseTexture8Impl *)iface;
TRACE("(%p) Relay\n" , This);
if (IsEqualGUID(riid, &IID_IUnknown)
|| IsEqualGUID(riid, &IID_IDirect3DResource8)
|| IsEqualGUID(riid, &IID_IDirect3DBaseTexture8)) {
IUnknown_AddRef(iface);
*ppobj = This;
return S_OK;
}
WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);
*ppobj = NULL;
return E_NOINTERFACE;
}
static ULONG WINAPI IDirect3DBaseTexture8Impl_AddRef(LPDIRECT3DBASETEXTURE8 iface) {
IDirect3DBaseTexture8Impl *This = (IDirect3DBaseTexture8Impl *)iface;
ULONG ref = InterlockedIncrement(&This->ref);
TRACE("(%p) : AddRef from %d\n", This, ref - 1);
return ref;
}
static ULONG WINAPI IDirect3DBaseTexture8Impl_Release(LPDIRECT3DBASETEXTURE8 iface) {
IDirect3DBaseTexture8Impl *This = (IDirect3DBaseTexture8Impl *)iface;
ULONG ref = InterlockedDecrement(&This->ref);
TRACE("(%p) : ReleaseRef to %d\n", This, ref);
if (ref == 0) {
IWineD3DBaseTexture_Release(This->wineD3DBaseTexture);
HeapFree(GetProcessHeap(), 0, This);
}
return ref;
}
/* IDirect3DBaseTexture8 IDirect3DResource8 Interface follow: */
static HRESULT WINAPI IDirect3DBaseTexture8Impl_GetDevice(LPDIRECT3DBASETEXTURE8 iface, IDirect3DDevice8 **ppDevice) {
IDirect3DBaseTexture8Impl *This = (IDirect3DBaseTexture8Impl *)iface;
TRACE("(%p) Relay\n" , This);
return IDirect3DResource8Impl_GetDevice((LPDIRECT3DRESOURCE8) This, ppDevice);
}
static HRESULT WINAPI IDirect3DBaseTexture8Impl_SetPrivateData(LPDIRECT3DBASETEXTURE8 iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) {
IDirect3DBaseTexture8Impl *This = (IDirect3DBaseTexture8Impl *)iface;
TRACE("(%p) Relay\n" , This);
return IWineD3DBaseTexture_SetPrivateData(This->wineD3DBaseTexture, refguid, pData, SizeOfData, Flags);
}
static HRESULT WINAPI IDirect3DBaseTexture8Impl_GetPrivateData(LPDIRECT3DBASETEXTURE8 iface, REFGUID refguid, void* pData, DWORD* pSizeOfData) {
IDirect3DBaseTexture8Impl *This = (IDirect3DBaseTexture8Impl *)iface;
TRACE("(%p) Relay\n" , This);
return IWineD3DBaseTexture_GetPrivateData(This->wineD3DBaseTexture, refguid, pData, pSizeOfData);
}
static HRESULT WINAPI IDirect3DBaseTexture8Impl_FreePrivateData(LPDIRECT3DBASETEXTURE8 iface, REFGUID refguid) {
IDirect3DBaseTexture8Impl *This = (IDirect3DBaseTexture8Impl *)iface;
TRACE("(%p) Relay\n" , This);
return IWineD3DBaseTexture_FreePrivateData(This->wineD3DBaseTexture, refguid);
}
static DWORD WINAPI IDirect3DBaseTexture8Impl_SetPriority(LPDIRECT3DBASETEXTURE8 iface, DWORD PriorityNew) {
IDirect3DBaseTexture8Impl *This = (IDirect3DBaseTexture8Impl *)iface;
TRACE("(%p) Relay\n" , This);
return IWineD3DBaseTexture_SetPriority(This->wineD3DBaseTexture, PriorityNew);
}
static DWORD WINAPI IDirect3DBaseTexture8Impl_GetPriority(LPDIRECT3DBASETEXTURE8 iface) {
IDirect3DBaseTexture8Impl *This = (IDirect3DBaseTexture8Impl *)iface;
TRACE("(%p) Relay\n" , This);
return IWineD3DBaseTexture_GetPriority(This->wineD3DBaseTexture);
}
static void WINAPI IDirect3DBaseTexture8Impl_PreLoad(LPDIRECT3DBASETEXTURE8 iface) {
IDirect3DBaseTexture8Impl *This = (IDirect3DBaseTexture8Impl *)iface;
TRACE("(%p) Relay\n" , This);
IWineD3DBaseTexture_PreLoad(This->wineD3DBaseTexture);
return;
}
static D3DRESOURCETYPE WINAPI IDirect3DBaseTexture8Impl_GetType(LPDIRECT3DBASETEXTURE8 iface) {
IDirect3DBaseTexture8Impl *This = (IDirect3DBaseTexture8Impl *)iface;
TRACE("(%p) Relay\n" , This);
return IWineD3DBaseTexture_GetType(This->wineD3DBaseTexture);
}
/* IDirect3DBaseTexture8 Interface follow: */
static DWORD WINAPI IDirect3DBaseTexture8Impl_SetLOD(LPDIRECT3DBASETEXTURE8 iface, DWORD LODNew) {
IDirect3DBaseTexture8Impl *This = (IDirect3DBaseTexture8Impl *)iface;
TRACE("(%p) Relay\n" , This);
return IWineD3DBaseTexture_SetLOD(This->wineD3DBaseTexture, LODNew);
}
static DWORD WINAPI IDirect3DBaseTexture8Impl_GetLOD(LPDIRECT3DBASETEXTURE8 iface) {
IDirect3DBaseTexture8Impl *This = (IDirect3DBaseTexture8Impl *)iface;
TRACE("(%p) Relay\n" , This);
return IWineD3DBaseTexture_GetLOD(This->wineD3DBaseTexture);
}
static DWORD WINAPI IDirect3DBaseTexture8Impl_GetLevelCount(LPDIRECT3DBASETEXTURE8 iface) {
IDirect3DBaseTexture8Impl *This = (IDirect3DBaseTexture8Impl *)iface;
TRACE("(%p) Relay\n" , This);
return IWineD3DBaseTexture_GetLevelCount(This->wineD3DBaseTexture);
}
const IDirect3DBaseTexture8Vtbl Direct3DBaseTexture8_Vtbl =
{
IDirect3DBaseTexture8Impl_QueryInterface,
IDirect3DBaseTexture8Impl_AddRef,
IDirect3DBaseTexture8Impl_Release,
IDirect3DBaseTexture8Impl_GetDevice,
IDirect3DBaseTexture8Impl_SetPrivateData,
IDirect3DBaseTexture8Impl_GetPrivateData,
IDirect3DBaseTexture8Impl_FreePrivateData,
IDirect3DBaseTexture8Impl_SetPriority,
IDirect3DBaseTexture8Impl_GetPriority,
IDirect3DBaseTexture8Impl_PreLoad,
IDirect3DBaseTexture8Impl_GetType,
IDirect3DBaseTexture8Impl_SetLOD,
IDirect3DBaseTexture8Impl_GetLOD,
IDirect3DBaseTexture8Impl_GetLevelCount
};

View File

@@ -0,0 +1,215 @@
/*
* IDirect3DCubeTexture8 implementation
*
* Copyright 2005 Oliver Stieber
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "config.h"
#include "d3d8_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(d3d8);
/* IDirect3DCubeTexture8 IUnknown parts follow: */
static HRESULT WINAPI IDirect3DCubeTexture8Impl_QueryInterface(LPDIRECT3DCUBETEXTURE8 iface, REFIID riid, LPVOID *ppobj) {
IDirect3DCubeTexture8Impl *This = (IDirect3DCubeTexture8Impl *)iface;
if (IsEqualGUID(riid, &IID_IUnknown)
|| IsEqualGUID(riid, &IID_IDirect3DResource8)
|| IsEqualGUID(riid, &IID_IDirect3DBaseTexture8)
|| IsEqualGUID(riid, &IID_IDirect3DCubeTexture8)) {
IUnknown_AddRef(iface);
*ppobj = This;
return S_OK;
}
WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);
*ppobj = NULL;
return E_NOINTERFACE;
}
static ULONG WINAPI IDirect3DCubeTexture8Impl_AddRef(LPDIRECT3DCUBETEXTURE8 iface) {
IDirect3DCubeTexture8Impl *This = (IDirect3DCubeTexture8Impl *)iface;
ULONG ref = InterlockedIncrement(&This->ref);
TRACE("(%p) : AddRef from %d\n", This, ref - 1);
return ref;
}
static ULONG WINAPI IDirect3DCubeTexture8Impl_Release(LPDIRECT3DCUBETEXTURE8 iface) {
IDirect3DCubeTexture8Impl *This = (IDirect3DCubeTexture8Impl *)iface;
ULONG ref = InterlockedDecrement(&This->ref);
TRACE("(%p) : ReleaseRef to %d\n", This, ref);
if (ref == 0) {
TRACE("Releasing child %p\n", This->wineD3DCubeTexture);
IWineD3DCubeTexture_Destroy(This->wineD3DCubeTexture, D3D8CB_DestroySurface);
IUnknown_Release(This->parentDevice);
HeapFree(GetProcessHeap(), 0, This);
}
return ref;
}
/* IDirect3DCubeTexture8 IDirect3DResource8 Interface follow: */
static HRESULT WINAPI IDirect3DCubeTexture8Impl_GetDevice(LPDIRECT3DCUBETEXTURE8 iface, IDirect3DDevice8 **ppDevice) {
IDirect3DCubeTexture8Impl *This = (IDirect3DCubeTexture8Impl *)iface;
TRACE("(%p) Relay\n" , This);
return IDirect3DResource8Impl_GetDevice((LPDIRECT3DRESOURCE8) This, ppDevice);
}
static HRESULT WINAPI IDirect3DCubeTexture8Impl_SetPrivateData(LPDIRECT3DCUBETEXTURE8 iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) {
IDirect3DCubeTexture8Impl *This = (IDirect3DCubeTexture8Impl *)iface;
TRACE("(%p) Relay\n", This);
return IWineD3DCubeTexture_SetPrivateData(This->wineD3DCubeTexture,refguid,pData,SizeOfData,Flags);
}
static HRESULT WINAPI IDirect3DCubeTexture8Impl_GetPrivateData(LPDIRECT3DCUBETEXTURE8 iface, REFGUID refguid, void *pData, DWORD *pSizeOfData) {
IDirect3DCubeTexture8Impl *This = (IDirect3DCubeTexture8Impl *)iface;
TRACE("(%p) Relay\n", This);
return IWineD3DCubeTexture_GetPrivateData(This->wineD3DCubeTexture,refguid,pData,pSizeOfData);
}
static HRESULT WINAPI IDirect3DCubeTexture8Impl_FreePrivateData(LPDIRECT3DCUBETEXTURE8 iface, REFGUID refguid) {
IDirect3DCubeTexture8Impl *This = (IDirect3DCubeTexture8Impl *)iface;
TRACE("(%p) Relay\n", This);
return IWineD3DCubeTexture_FreePrivateData(This->wineD3DCubeTexture,refguid);
}
static DWORD WINAPI IDirect3DCubeTexture8Impl_SetPriority(LPDIRECT3DCUBETEXTURE8 iface, DWORD PriorityNew) {
IDirect3DCubeTexture8Impl *This = (IDirect3DCubeTexture8Impl *)iface;
TRACE("(%p) Relay\n", This);
return IWineD3DCubeTexture_SetPriority(This->wineD3DCubeTexture, PriorityNew);
}
static DWORD WINAPI IDirect3DCubeTexture8Impl_GetPriority(LPDIRECT3DCUBETEXTURE8 iface) {
IDirect3DCubeTexture8Impl *This = (IDirect3DCubeTexture8Impl *)iface;
TRACE("(%p) Relay\n", This);
return IWineD3DCubeTexture_GetPriority(This->wineD3DCubeTexture);
}
static void WINAPI IDirect3DCubeTexture8Impl_PreLoad(LPDIRECT3DCUBETEXTURE8 iface) {
IDirect3DCubeTexture8Impl *This = (IDirect3DCubeTexture8Impl *)iface;
TRACE("(%p) Relay\n", This);
IWineD3DCubeTexture_PreLoad(This->wineD3DCubeTexture);
}
static D3DRESOURCETYPE WINAPI IDirect3DCubeTexture8Impl_GetType(LPDIRECT3DCUBETEXTURE8 iface) {
IDirect3DCubeTexture8Impl *This = (IDirect3DCubeTexture8Impl *)iface;
TRACE("(%p) Relay\n", This);
return IWineD3DCubeTexture_GetType(This->wineD3DCubeTexture);
}
/* IDirect3DCubeTexture8 IDirect3DBaseTexture8 Interface follow: */
static DWORD WINAPI IDirect3DCubeTexture8Impl_SetLOD(LPDIRECT3DCUBETEXTURE8 iface, DWORD LODNew) {
IDirect3DCubeTexture8Impl *This = (IDirect3DCubeTexture8Impl *)iface;
TRACE("(%p) Relay\n", This);
return IWineD3DCubeTexture_SetLOD(This->wineD3DCubeTexture, LODNew);
}
static DWORD WINAPI IDirect3DCubeTexture8Impl_GetLOD(LPDIRECT3DCUBETEXTURE8 iface) {
IDirect3DCubeTexture8Impl *This = (IDirect3DCubeTexture8Impl *)iface;
TRACE("(%p) Relay\n", This);
return IWineD3DCubeTexture_GetLOD((LPDIRECT3DBASETEXTURE8) This);
}
static DWORD WINAPI IDirect3DCubeTexture8Impl_GetLevelCount(LPDIRECT3DCUBETEXTURE8 iface) {
IDirect3DCubeTexture8Impl *This = (IDirect3DCubeTexture8Impl *)iface;
TRACE("(%p) Relay\n", This);
return IWineD3DCubeTexture_GetLevelCount(This->wineD3DCubeTexture);
}
/* IDirect3DCubeTexture8 Interface follow: */
static HRESULT WINAPI IDirect3DCubeTexture8Impl_GetLevelDesc(LPDIRECT3DCUBETEXTURE8 iface, UINT Level, D3DSURFACE_DESC *pDesc) {
IDirect3DCubeTexture8Impl *This = (IDirect3DCubeTexture8Impl *)iface;
WINED3DSURFACE_DESC wined3ddesc;
TRACE("(%p) Relay\n", This);
/* As d3d8 and d3d9 structures differ, pass in ptrs to where data needs to go */
wined3ddesc.Format = (WINED3DFORMAT *)&pDesc->Format;
wined3ddesc.Type = (WINED3DRESOURCETYPE *)&pDesc->Type;
wined3ddesc.Usage = &pDesc->Usage;
wined3ddesc.Pool = (WINED3DPOOL *) &pDesc->Pool;
wined3ddesc.Size = &pDesc->Size;
wined3ddesc.MultiSampleType = (WINED3DMULTISAMPLE_TYPE *) &pDesc->MultiSampleType;
wined3ddesc.MultiSampleQuality = NULL; /* DirectX9 only */
wined3ddesc.Width = &pDesc->Width;
wined3ddesc.Height = &pDesc->Height;
return IWineD3DCubeTexture_GetLevelDesc(This->wineD3DCubeTexture, Level, &wined3ddesc);
}
static HRESULT WINAPI IDirect3DCubeTexture8Impl_GetCubeMapSurface(LPDIRECT3DCUBETEXTURE8 iface, D3DCUBEMAP_FACES FaceType, UINT Level, IDirect3DSurface8 **ppCubeMapSurface) {
IDirect3DCubeTexture8Impl *This = (IDirect3DCubeTexture8Impl *)iface;
HRESULT hrc = D3D_OK;
IWineD3DSurface *mySurface = NULL;
TRACE("(%p) Relay\n", This);
hrc = IWineD3DCubeTexture_GetCubeMapSurface(This->wineD3DCubeTexture, (WINED3DCUBEMAP_FACES) FaceType, Level, &mySurface);
if (hrc == D3D_OK && NULL != ppCubeMapSurface) {
IWineD3DCubeTexture_GetParent(mySurface, (IUnknown **)ppCubeMapSurface);
IWineD3DCubeTexture_Release(mySurface);
}
return hrc;
}
static HRESULT WINAPI IDirect3DCubeTexture8Impl_LockRect(LPDIRECT3DCUBETEXTURE8 iface, D3DCUBEMAP_FACES FaceType, UINT Level, D3DLOCKED_RECT* pLockedRect, CONST RECT *pRect, DWORD Flags) {
IDirect3DCubeTexture8Impl *This = (IDirect3DCubeTexture8Impl *)iface;
TRACE("(%p) Relay\n", This);
return IWineD3DCubeTexture_LockRect(This->wineD3DCubeTexture, (WINED3DCUBEMAP_FACES) FaceType, Level, (WINED3DLOCKED_RECT *) pLockedRect, pRect, Flags);
}
static HRESULT WINAPI IDirect3DCubeTexture8Impl_UnlockRect(LPDIRECT3DCUBETEXTURE8 iface, D3DCUBEMAP_FACES FaceType, UINT Level) {
IDirect3DCubeTexture8Impl *This = (IDirect3DCubeTexture8Impl *)iface;
TRACE("(%p) Relay\n", This);
return IWineD3DCubeTexture_UnlockRect(This->wineD3DCubeTexture, (WINED3DCUBEMAP_FACES) FaceType, Level);
}
static HRESULT WINAPI IDirect3DCubeTexture8Impl_AddDirtyRect(LPDIRECT3DCUBETEXTURE8 iface, D3DCUBEMAP_FACES FaceType, CONST RECT *pDirtyRect) {
IDirect3DCubeTexture8Impl *This = (IDirect3DCubeTexture8Impl *)iface;
TRACE("(%p) Relay\n", This);
return IWineD3DCubeTexture_AddDirtyRect(This->wineD3DCubeTexture, (WINED3DCUBEMAP_FACES) FaceType, pDirtyRect);
}
const IDirect3DCubeTexture8Vtbl Direct3DCubeTexture8_Vtbl =
{
/* IUnknown */
IDirect3DCubeTexture8Impl_QueryInterface,
IDirect3DCubeTexture8Impl_AddRef,
IDirect3DCubeTexture8Impl_Release,
/* IDirect3DResource8 */
IDirect3DCubeTexture8Impl_GetDevice,
IDirect3DCubeTexture8Impl_SetPrivateData,
IDirect3DCubeTexture8Impl_GetPrivateData,
IDirect3DCubeTexture8Impl_FreePrivateData,
IDirect3DCubeTexture8Impl_SetPriority,
IDirect3DCubeTexture8Impl_GetPriority,
IDirect3DCubeTexture8Impl_PreLoad,
IDirect3DCubeTexture8Impl_GetType,
/* IDirect3DBaseTexture8 */
IDirect3DCubeTexture8Impl_SetLOD,
IDirect3DCubeTexture8Impl_GetLOD,
IDirect3DCubeTexture8Impl_GetLevelCount,
/* IDirect3DCubeTexture8 */
IDirect3DCubeTexture8Impl_GetLevelDesc,
IDirect3DCubeTexture8Impl_GetCubeMapSurface,
IDirect3DCubeTexture8Impl_LockRect,
IDirect3DCubeTexture8Impl_UnlockRect,
IDirect3DCubeTexture8Impl_AddDirtyRect
};

View File

@@ -0,0 +1,7 @@
LIBRARY "d3d8.dll"
EXPORTS
CheckFullscreen @1
ValidatePixelShader @2
ValidateVertexShader @3
DebugSetMute @4
Direct3DCreate8 @5

View File

@@ -0,0 +1,185 @@
# Microsoft Developer Studio Project File - Name="d3d8" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
CFG=d3d8 - Win32 Debug
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
!MESSAGE
!MESSAGE NMAKE /f "d3d8.mak".
!MESSAGE
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "d3d8.mak" CFG="d3d8 - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "d3d8 - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE "d3d8 - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE
# Begin Project
# PROP AllowPerConfigDependencies 0
# PROP Scc_ProjName ""
# PROP Scc_LocalPath ""
CPP=cl.exe
MTL=midl.exe
RSC=rc.exe
!IF "$(CFG)" == "d3d8 - Win32 Release"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Release"
# PROP BASE Intermediate_Dir "Release"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "Release"
# PROP Intermediate_Dir "Release"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c
# ADD CPP /nologo /MD /W3 /GX /Zi /O2 /I "$(DXSDK_DIR)\include" /I "$(MSSDK)\include" /I "..\..\include" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "__WINESRC__" /YX /FD /c
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x419 /d "NDEBUG"
# ADD RSC /l 0x409 /i "..\..\include" /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386
# ADD LINK32 advapi32.lib kernel32.lib user32.lib gdi32.lib uuid.lib dxguid.lib /nologo /subsystem:windows /dll /pdb:"../../bin/d3d8.pdb" /debug /machine:I386 /out:"../../bin/d3d8.dll"
# SUBTRACT LINK32 /pdb:none
!ELSEIF "$(CFG)" == "d3d8 - Win32 Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "Debug"
# PROP BASE Intermediate_Dir "Debug"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "Debug"
# PROP Intermediate_Dir "Debug"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /GZ /c
# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "$(DXSDK_DIR)\include" /I "$(MSSDK)\include" /I "..\..\include" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "__WINESRC__" /YX /FD /GZ /c
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x419 /d "_DEBUG"
# ADD RSC /l 0x409 /i "..\..\include" /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386 /pdbtype:sept
# ADD LINK32 advapi32.lib kernel32.lib user32.lib gdi32.lib uuid.lib dxguid.lib /nologo /subsystem:windows /dll /pdb:"../../bin/d3d8.pdb" /debug /machine:I386 /out:"../../bin/d3d8.dll" /pdbtype:sept
# SUBTRACT LINK32 /pdb:none
!ENDIF
# Begin Target
# Name "d3d8 - Win32 Release"
# Name "d3d8 - Win32 Debug"
# Begin Group "Source Files"
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
# Begin Source File
SOURCE=.\basetexture.c
# End Source File
# Begin Source File
SOURCE=.\cubetexture.c
# End Source File
# Begin Source File
SOURCE=.\d3d8.def
# End Source File
# Begin Source File
SOURCE=.\d3d8_main.c
# End Source File
# Begin Source File
SOURCE=.\device.c
# End Source File
# Begin Source File
SOURCE=.\directx.c
# End Source File
# Begin Source File
SOURCE=.\indexbuffer.c
# End Source File
# Begin Source File
SOURCE=.\pixelshader.c
# End Source File
# Begin Source File
SOURCE=.\resource.c
# End Source File
# Begin Source File
SOURCE=.\stateblock.c
# End Source File
# Begin Source File
SOURCE=.\surface.c
# End Source File
# Begin Source File
SOURCE=.\swapchain.c
# End Source File
# Begin Source File
SOURCE=.\texture.c
# End Source File
# Begin Source File
SOURCE=.\vertexbuffer.c
# End Source File
# Begin Source File
SOURCE=.\vertexdeclaration.c
# End Source File
# Begin Source File
SOURCE=.\vertexshader.c
# End Source File
# Begin Source File
SOURCE=.\volume.c
# End Source File
# Begin Source File
SOURCE=.\volumetexture.c
# End Source File
# End Group
# Begin Group "Header Files"
# PROP Default_Filter "h;hpp;hxx;hm;inl"
# Begin Source File
SOURCE=.\d3d8_private.h
# End Source File
# End Group
# Begin Group "Resource Files"
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
# Begin Source File
SOURCE=.\version.rc
# End Source File
# End Group
# End Target
# End Project

View File

@@ -0,0 +1,42 @@
<module name="d3d8" type="win32dll" entrypoint="0" installbase="system32" installname="d3d8.dll">
<importlibrary definition="d3d8.def" />
<include base="d3d8">.</include>
<include base="ReactOS">include/reactos/wine-paralles</include>
<include base="ReactOS">include/reactos/wine</include>
<define name="UNICODE" />
<define name="_UNICODE" />
<define name="__REACTOS__" />
<define name="__USE_W32API" />
<define name="_WIN32_IE">0x600</define>
<define name="_WIN32_WINNT">0x501</define>
<define name="WINVER">0x501</define>
<define name="WINE_NATIVEWIN32" />
<library>wine</library>
<library>uuid</library>
<library>ntdll</library>
<library>kernel32</library>
<library>user32</library>
<library>advapi32</library>
<library>ole32</library>
<library>winmm</library>
<library>dxguid</library>
<file>basetexture.c</file>
<file>cubetexture.c</file>
<file>d3d8_main.c</file>
<file>device.c</file>
<file>directx.c</file>
<file>indexbuffer.c</file>
<file>pixelshader.c</file>
<file>resource.c</file>
<file>stateblock.c</file>
<file>surface.c</file>
<file>swapchain.c</file>
<file>texture.c</file>
<file>vertexbuffer.c</file>
<file>vertexdeclaration.c</file>
<file>vertexshader.c</file>
<file>volume.c</file>
<file>volumetexture.c</file>
<file>version.rc</file>
</module>

View File

@@ -0,0 +1,272 @@
/*
* Direct3D 8
*
* Copyright 2005 Oliver Stieber
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*
*/
#include "config.h"
#include "initguid.h"
#include "d3d8_private.h"
#include "wine/debug.h"
typedef IWineD3D* (WINAPI *fnWineDirect3DCreate)(UINT, UINT, IUnknown *);
static HMODULE hWineD3D = (HMODULE) -1;
static fnWineDirect3DCreate pWineDirect3DCreate;
WINE_DEFAULT_DEBUG_CHANNEL(d3d8);
#ifdef WINE_NATIVEWIN32
static HMODULE hD3D8;
BOOL (WINAPI *pCheckFullscreen)();
HRESULT (WINAPI *pDebugSetMute)(void);
IDirect3D8* (WINAPI *pDirect3DCreate8)(UINT SDKVersion);
HRESULT (WINAPI *pValidateVertexShader)(
DWORD* vertexshader, DWORD* reserved1, DWORD* reserved2, int bool, DWORD* toto);
HRESULT (WINAPI *pValidatePixelShader)(
DWORD* pixelshader, DWORD* reserved1, int bool, DWORD* toto);
BOOL
IsPassthrough()
{
if (!hD3D8)
return FALSE;
if (hD3D8 != (HMODULE) -1)
return TRUE;
hD3D8 = LoadLibraryA("d3d8.sav");
if (hD3D8) {
#define getproc(x) *(FARPROC *)&p##x = GetProcAddress(hD3D8, #x)
getproc(CheckFullscreen);
getproc(DebugSetMute);
getproc(Direct3DCreate8);
getproc(ValidateVertexShader);
getproc(ValidatePixelShader);
#undef getproc
}
return hD3D8 != NULL;
}
#endif
HRESULT WINAPI D3D8GetSWInfo(void) {
FIXME("(void): stub\n");
return 0;
}
BOOL WINAPI
CheckFullscreen()
{
#ifdef WINE_NATIVEWIN32
if (IsPassthrough())
return pCheckFullscreen();
#endif
return FALSE;
}
void WINAPI DebugSetMute(void) {
#ifdef WINE_NATIVEWIN32
if (IsPassthrough())
pDebugSetMute();
#endif
/* nothing to do */
}
IDirect3D8* WINAPI Direct3DCreate8(UINT SDKVersion) {
IDirect3D8Impl* object;
#ifdef WINE_NATIVEWIN32
if (IsPassthrough())
return pDirect3DCreate8(SDKVersion);
#endif
if (hWineD3D == (HMODULE) -1)
{
hWineD3D = LoadLibraryA("wined3d");
if (hWineD3D)
pWineDirect3DCreate = (fnWineDirect3DCreate) GetProcAddress(hWineD3D, "WineDirect3DCreate");
}
if (!hWineD3D)
{
ERR("Couldn't load WineD3D - OpenGL libs not present?\n");
return NULL;
}
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3D8Impl));
object->lpVtbl = &Direct3D8_Vtbl;
object->ref = 1;
object->WineD3D = pWineDirect3DCreate(SDKVersion, 8, (IUnknown *)object);
TRACE("SDKVersion = %x, Created Direct3D object @ %p, WineObj @ %p\n", SDKVersion, object, object->WineD3D);
return (IDirect3D8*) object;
}
/***********************************************************************
* get_config_key
*
* Reads a config key from the registry. Taken from WineD3D
*
***********************************************************************/
static inline DWORD get_config_key(HKEY defkey, HKEY appkey, const char* name, char* buffer, DWORD size)
{
if (0 != appkey && !RegQueryValueExA( appkey, name, 0, NULL, (LPBYTE) buffer, &size )) return 0;
if (0 != defkey && !RegQueryValueExA( defkey, name, 0, NULL, (LPBYTE) buffer, &size )) return 0;
return ERROR_FILE_NOT_FOUND;
}
/* At process attach */
BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpv)
{
TRACE("fdwReason=%d\n", fdwReason);
if (fdwReason == DLL_PROCESS_ATTACH) {
char buffer[MAX_PATH+64];
DWORD size = sizeof(buffer);
HKEY hkey = 0;
HKEY appkey = 0;
DWORD len;
#if defined(WINE_NATIVEWIN32) && !defined(NDEBUG)
debug_init();
#endif
DisableThreadLibraryCalls(hInstDLL);
/* @@ Wine registry key: HKCU\Software\Wine\Direct3D */
if ( RegOpenKeyA( HKEY_CURRENT_USER, "Software\\Wine\\Direct3D", &hkey )
&& RegOpenKeyA( HKEY_LOCAL_MACHINE, "Software\\Wine\\Direct3D", &hkey ) )
hkey = 0;
len = GetModuleFileNameA( 0, buffer, MAX_PATH );
if (len && len < MAX_PATH)
{
char *p, *appname = buffer;
if ((p = strrchr( appname, '/' ))) appname = p + 1;
if ((p = strrchr( appname, '\\' ))) appname = p + 1;
TRACE("appname = [%s]\n", appname);
memmove(
buffer + strlen( "Software\\Wine\\AppDefaults\\" ),
appname, strlen( appname ) + 1);
memcpy(
buffer, "Software\\Wine\\AppDefaults\\",
strlen( "Software\\Wine\\AppDefaults\\" ));
strcat( buffer, "\\Direct3D" );
/* @@ Wine registry key: HKCU\Software\Wine\AppDefaults\app.exe\Direct3D */
if (RegOpenKeyA( HKEY_CURRENT_USER, buffer, &appkey )
&& RegOpenKeyA( HKEY_LOCAL_MACHINE, buffer, &appkey ))
appkey = 0;
}
if ( 0 != hkey || 0 != appkey )
{
#ifdef WINE_NATIVEWIN32
if ( !get_config_key( hkey, appkey, "Passthrough", buffer, size) )
{
if (!strcmp(buffer,"true") || !strcmp(buffer,"yes"))
{
TRACE("Passthrough mode\n");
hD3D8 = (HMODULE) -1;
}
}
#endif
}
}
else if (fdwReason == DLL_PROCESS_DETACH)
{
if (hWineD3D && hWineD3D != (HMODULE) -1)
FreeLibrary(hWineD3D);
#ifdef WINE_NATIVEWIN32
if (hD3D8 && hD3D8 != (HMODULE) -1)
FreeLibrary(hD3D8);
#endif
}
return TRUE;
}
/***********************************************************************
* ValidateVertexShader (D3D8.@)
*
* I've seen reserved1 and reserved2 always passed as 0's
* bool seems always passed as 0 or 1, but other values work as well....
* toto result?
*/
HRESULT WINAPI ValidateVertexShader(DWORD* vertexshader, DWORD* reserved1, DWORD* reserved2, int bool, DWORD* toto)
{
HRESULT ret;
#ifdef WINE_NATIVEWIN32
if (IsPassthrough())
return pValidateVertexShader(vertexshader, reserved1, reserved2, bool, toto);
#endif
FIXME("(%p %p %p %d %p): stub\n", vertexshader, reserved1, reserved2, bool, toto);
if (!vertexshader)
return E_FAIL;
if (reserved1 || reserved2)
return E_FAIL;
switch(*vertexshader) {
case 0xFFFE0101:
case 0xFFFE0100:
ret=S_OK;
break;
default:
ERR("vertexshader version mismatch\n");
ret=E_FAIL;
}
return ret;
}
/***********************************************************************
* ValidatePixelShader (D3D8.@)
*
* PARAMS
* toto result?
*/
HRESULT WINAPI ValidatePixelShader(DWORD* pixelshader, DWORD* reserved1, int bool, DWORD* toto)
{
HRESULT ret;
#ifdef WINE_NATIVEWIN32
if (IsPassthrough())
return pValidatePixelShader(pixelshader, reserved1, bool, toto);
#endif
FIXME("(%p %p %d %p): stub\n", pixelshader, reserved1, bool, toto);
if (!pixelshader)
return E_FAIL;
if (reserved1)
return E_FAIL;
switch(*pixelshader) {
case 0xFFFF0100:
case 0xFFFF0101:
case 0xFFFF0102:
case 0xFFFF0103:
case 0xFFFF0104:
ret=S_OK;
break;
default:
ERR("pixelshader version mismatch\n");
ret=E_FAIL;
}
return ret;
}

View File

@@ -0,0 +1,661 @@
/*
* Direct3D 8 private include file
*
* Copyright 2002-2004 Jason Edmeades
* Copyright 2003-2004 Raphael Junqueira
* Copyright 2004 Christian Costa
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef __WINE_D3D8_PRIVATE_H
#define __WINE_D3D8_PRIVATE_H
#include <stdarg.h>
#define NONAMELESSUNION
#define NONAMELESSSTRUCT
#define COBJMACROS
#ifndef WINE_NATIVEWIN32
# include "windef.h"
# include "winbase.h"
# include "winuser.h"
# include "wingdi.h"
#else
# include <windows.h>
#endif
#include "wine/debug.h"
#include "d3d8.h"
#include "wine/wined3d_interface.h"
/* Device caps */
#define INITIAL_SHADER_HANDLE_TABLE_SIZE 64
/* CreateVertexShader can return > 0xFFFF */
#define VS_HIGHESTFIXEDFXF 0xF0000000
/* ===========================================================================
Macros
=========================================================================== */
/* Not nice, but it lets wined3d support different versions of directx */
#define D3D8CAPSTOWINECAPS(_pD3D8Caps, _pWineCaps) \
_pWineCaps->DeviceType = (WINED3DDEVTYPE *) &_pD3D8Caps->DeviceType; \
_pWineCaps->AdapterOrdinal = &_pD3D8Caps->AdapterOrdinal; \
_pWineCaps->Caps = &_pD3D8Caps->Caps; \
_pWineCaps->Caps2 = &_pD3D8Caps->Caps2; \
_pWineCaps->Caps3 = &_pD3D8Caps->Caps3; \
_pWineCaps->PresentationIntervals = &_pD3D8Caps->PresentationIntervals; \
_pWineCaps->CursorCaps = &_pD3D8Caps->CursorCaps; \
_pWineCaps->DevCaps = &_pD3D8Caps->DevCaps; \
_pWineCaps->PrimitiveMiscCaps = &_pD3D8Caps->PrimitiveMiscCaps; \
_pWineCaps->RasterCaps = &_pD3D8Caps->RasterCaps; \
_pWineCaps->ZCmpCaps = &_pD3D8Caps->ZCmpCaps; \
_pWineCaps->SrcBlendCaps = &_pD3D8Caps->SrcBlendCaps; \
_pWineCaps->DestBlendCaps = &_pD3D8Caps->DestBlendCaps; \
_pWineCaps->AlphaCmpCaps = &_pD3D8Caps->AlphaCmpCaps; \
_pWineCaps->ShadeCaps = &_pD3D8Caps->ShadeCaps; \
_pWineCaps->TextureCaps = &_pD3D8Caps->TextureCaps; \
_pWineCaps->TextureFilterCaps = &_pD3D8Caps->TextureFilterCaps; \
_pWineCaps->CubeTextureFilterCaps = &_pD3D8Caps->CubeTextureFilterCaps; \
_pWineCaps->VolumeTextureFilterCaps = &_pD3D8Caps->VolumeTextureFilterCaps; \
_pWineCaps->TextureAddressCaps = &_pD3D8Caps->TextureAddressCaps; \
_pWineCaps->VolumeTextureAddressCaps = &_pD3D8Caps->VolumeTextureAddressCaps; \
_pWineCaps->LineCaps = &_pD3D8Caps->LineCaps; \
_pWineCaps->MaxTextureWidth = &_pD3D8Caps->MaxTextureWidth; \
_pWineCaps->MaxTextureHeight = &_pD3D8Caps->MaxTextureHeight; \
_pWineCaps->MaxVolumeExtent = &_pD3D8Caps->MaxVolumeExtent; \
_pWineCaps->MaxTextureRepeat = &_pD3D8Caps->MaxTextureRepeat; \
_pWineCaps->MaxTextureAspectRatio = &_pD3D8Caps->MaxTextureAspectRatio; \
_pWineCaps->MaxAnisotropy = &_pD3D8Caps->MaxAnisotropy; \
_pWineCaps->MaxVertexW = &_pD3D8Caps->MaxVertexW; \
_pWineCaps->GuardBandLeft = &_pD3D8Caps->GuardBandLeft; \
_pWineCaps->GuardBandTop = &_pD3D8Caps->GuardBandTop; \
_pWineCaps->GuardBandRight = &_pD3D8Caps->GuardBandRight; \
_pWineCaps->GuardBandBottom = &_pD3D8Caps->GuardBandBottom; \
_pWineCaps->ExtentsAdjust = &_pD3D8Caps->ExtentsAdjust; \
_pWineCaps->StencilCaps = &_pD3D8Caps->StencilCaps; \
_pWineCaps->FVFCaps = &_pD3D8Caps->FVFCaps; \
_pWineCaps->TextureOpCaps = &_pD3D8Caps->TextureOpCaps; \
_pWineCaps->MaxTextureBlendStages = &_pD3D8Caps->MaxTextureBlendStages; \
_pWineCaps->MaxSimultaneousTextures = &_pD3D8Caps->MaxSimultaneousTextures; \
_pWineCaps->VertexProcessingCaps = &_pD3D8Caps->VertexProcessingCaps; \
_pWineCaps->MaxActiveLights = &_pD3D8Caps->MaxActiveLights; \
_pWineCaps->MaxUserClipPlanes = &_pD3D8Caps->MaxUserClipPlanes; \
_pWineCaps->MaxVertexBlendMatrices = &_pD3D8Caps->MaxVertexBlendMatrices; \
_pWineCaps->MaxVertexBlendMatrixIndex = &_pD3D8Caps->MaxVertexBlendMatrixIndex; \
_pWineCaps->MaxPointSize = &_pD3D8Caps->MaxPointSize; \
_pWineCaps->MaxPrimitiveCount = &_pD3D8Caps->MaxPrimitiveCount; \
_pWineCaps->MaxVertexIndex = &_pD3D8Caps->MaxVertexIndex; \
_pWineCaps->MaxStreams = &_pD3D8Caps->MaxStreams; \
_pWineCaps->MaxStreamStride = &_pD3D8Caps->MaxStreamStride; \
_pWineCaps->VertexShaderVersion = &_pD3D8Caps->VertexShaderVersion; \
_pWineCaps->MaxVertexShaderConst = &_pD3D8Caps->MaxVertexShaderConst; \
_pWineCaps->PixelShaderVersion = &_pD3D8Caps->PixelShaderVersion; \
_pWineCaps->PixelShader1xMaxValue = &_pD3D8Caps->MaxPixelShaderValue;
/* Direct3D8 Interfaces: */
typedef struct IDirect3DBaseTexture8Impl IDirect3DBaseTexture8Impl;
typedef struct IDirect3DVolumeTexture8Impl IDirect3DVolumeTexture8Impl;
typedef struct IDirect3D8Impl IDirect3D8Impl;
typedef struct IDirect3DDevice8Impl IDirect3DDevice8Impl;
typedef struct IDirect3DTexture8Impl IDirect3DTexture8Impl;
typedef struct IDirect3DCubeTexture8Impl IDirect3DCubeTexture8Impl;
typedef struct IDirect3DIndexBuffer8Impl IDirect3DIndexBuffer8Impl;
typedef struct IDirect3DSurface8Impl IDirect3DSurface8Impl;
typedef struct IDirect3DSwapChain8Impl IDirect3DSwapChain8Impl;
typedef struct IDirect3DResource8Impl IDirect3DResource8Impl;
typedef struct IDirect3DVolume8Impl IDirect3DVolume8Impl;
typedef struct IDirect3DVertexBuffer8Impl IDirect3DVertexBuffer8Impl;
/** Private Interfaces: */
typedef struct IDirect3DStateBlockImpl IDirect3DStateBlockImpl;
typedef struct IDirect3DVertexShaderImpl IDirect3DVertexShaderImpl;
typedef struct IDirect3DPixelShaderImpl IDirect3DPixelShaderImpl;
typedef struct IDirect3DVertexShaderDeclarationImpl IDirect3DVertexShaderDeclarationImpl;
/* Advance declaration of structures to satisfy compiler */
typedef struct IDirect3DVertexShader8Impl IDirect3DVertexShader8Impl;
/* ===========================================================================
The interfactes themselves
=========================================================================== */
/* ---------- */
/* IDirect3D8 */
/* ---------- */
/*****************************************************************************
* Predeclare the interface implementation structures
*/
extern const IDirect3D8Vtbl Direct3D8_Vtbl;
/*****************************************************************************
* IDirect3D implementation structure
*/
struct IDirect3D8Impl
{
/* IUnknown fields */
const IDirect3D8Vtbl *lpVtbl;
LONG ref;
/* The WineD3D device */
IWineD3D *WineD3D;
};
/* ---------------- */
/* IDirect3DDevice8 */
/* ---------------- */
/*****************************************************************************
* Predeclare the interface implementation structures
*/
extern const IDirect3DDevice8Vtbl Direct3DDevice8_Vtbl;
/*****************************************************************************
* IDirect3DDevice8 implementation structure
*/
typedef void * shader_handle;
struct IDirect3DDevice8Impl
{
/* IUnknown fields */
const IDirect3DDevice8Vtbl *lpVtbl;
LONG ref;
/* But what about baseVertexIndex in state blocks? hmm... it may be a better idea to pass this to wined3d */
IWineD3DDevice *WineD3DDevice;
DWORD shader_handle_table_size;
DWORD allocated_shader_handles;
shader_handle *shader_handles;
shader_handle *free_shader_handles;
/* Avoids recursion with nested ReleaseRef to 0 */
BOOL inDestruction;
};
/* ---------------- */
/* IDirect3DVolume8 */
/* ---------------- */
/*****************************************************************************
* IDirect3DVolume8 implementation structure
*/
struct IDirect3DVolume8Impl
{
/* IUnknown fields */
const IDirect3DVolume8Vtbl *lpVtbl;
LONG ref;
/* IDirect3DVolume8 fields */
IWineD3DVolume *wineD3DVolume;
/* The volume container */
IUnknown *container;
/* If set forward refcounting to this object */
IUnknown *forwardReference;
};
/* ------------------- */
/* IDirect3DSwapChain8 */
/* ------------------- */
/*****************************************************************************
* Predeclare the interface implementation structures
*/
extern const IDirect3DSwapChain8Vtbl Direct3DSwapChain8_Vtbl;
/*****************************************************************************
* IDirect3DSwapChain8 implementation structure
*/
struct IDirect3DSwapChain8Impl
{
/* IUnknown fields */
const IDirect3DSwapChain8Vtbl *lpVtbl;
LONG ref;
/* IDirect3DSwapChain8 fields */
IWineD3DSwapChain *wineD3DSwapChain;
/* Parent reference */
LPDIRECT3DDEVICE8 parentDevice;
};
/* ----------------- */
/* IDirect3DSurface8 */
/* ----------------- */
/*****************************************************************************
* Predeclare the interface implementation structures
*/
extern const IDirect3DSurface8Vtbl Direct3DSurface8_Vtbl;
/*****************************************************************************
* IDirect3DSurface8 implementation structure
*/
struct IDirect3DSurface8Impl
{
/* IUnknown fields */
const IDirect3DSurface8Vtbl *lpVtbl;
LONG ref;
/* IDirect3DSurface8 fields */
IWineD3DSurface *wineD3DSurface;
/* Parent reference */
LPDIRECT3DDEVICE8 parentDevice;
/* The surface container */
IUnknown *container;
/* If set forward refcounting to this object */
IUnknown *forwardReference;
/* Flags an implicit surface */
BOOL isImplicit;
};
/* ------------------ */
/* IDirect3DResource8 */
/* ------------------ */
/*****************************************************************************
* Predeclare the interface implementation structures
*/
extern const IDirect3DResource8Vtbl Direct3DResource8_Vtbl;
/*****************************************************************************
* IDirect3DResource8 implementation structure
*/
struct IDirect3DResource8Impl
{
/* IUnknown fields */
const IDirect3DResource8Vtbl *lpVtbl;
LONG ref;
/* IDirect3DResource8 fields */
IWineD3DResource *wineD3DResource;
};
extern HRESULT WINAPI IDirect3DResource8Impl_GetDevice(LPDIRECT3DRESOURCE8 iface, IDirect3DDevice8** ppDevice);
/* ---------------------- */
/* IDirect3DVertexBuffer8 */
/* ---------------------- */
/*****************************************************************************
* Predeclare the interface implementation structures
*/
extern const IDirect3DVertexBuffer8Vtbl Direct3DVertexBuffer8_Vtbl;
/*****************************************************************************
* IDirect3DVertexBuffer8 implementation structure
*/
struct IDirect3DVertexBuffer8Impl
{
/* IUnknown fields */
const IDirect3DVertexBuffer8Vtbl *lpVtbl;
LONG ref;
/* IDirect3DResource8 fields */
IWineD3DVertexBuffer *wineD3DVertexBuffer;
/* Parent reference */
LPDIRECT3DDEVICE8 parentDevice;
};
/* --------------------- */
/* IDirect3DIndexBuffer8 */
/* --------------------- */
/*****************************************************************************
* Predeclare the interface implementation structures
*/
extern const IDirect3DIndexBuffer8Vtbl Direct3DIndexBuffer8_Vtbl;
/*****************************************************************************
* IDirect3DIndexBuffer8 implementation structure
*/
struct IDirect3DIndexBuffer8Impl
{
/* IUnknown fields */
const IDirect3DIndexBuffer8Vtbl *lpVtbl;
LONG ref;
/* IDirect3DResource8 fields */
IWineD3DIndexBuffer *wineD3DIndexBuffer;
/* Parent reference */
LPDIRECT3DDEVICE8 parentDevice;
};
/* --------------------- */
/* IDirect3DBaseTexture8 */
/* --------------------- */
/*****************************************************************************
* IDirect3DBaseTexture8 implementation structure
*/
struct IDirect3DBaseTexture8Impl
{
/* IUnknown fields */
const IDirect3DBaseTexture8Vtbl *lpVtbl;
LONG ref;
/* IDirect3DResource8 fields */
IWineD3DBaseTexture *wineD3DBaseTexture;
};
/* --------------------- */
/* IDirect3DCubeTexture8 */
/* --------------------- */
/*****************************************************************************
* Predeclare the interface implementation structures
*/
extern const IDirect3DCubeTexture8Vtbl Direct3DCubeTexture8_Vtbl;
/*****************************************************************************
* IDirect3DCubeTexture8 implementation structure
*/
struct IDirect3DCubeTexture8Impl
{
/* IUnknown fields */
const IDirect3DCubeTexture8Vtbl *lpVtbl;
LONG ref;
/* IDirect3DResource8 fields */
IWineD3DCubeTexture *wineD3DCubeTexture;
/* Parent reference */
LPDIRECT3DDEVICE8 parentDevice;
};
/* ----------------- */
/* IDirect3DTexture8 */
/* ----------------- */
/*****************************************************************************
* Predeclare the interface implementation structures
*/
extern const IDirect3DTexture8Vtbl Direct3DTexture8_Vtbl;
/*****************************************************************************
* IDirect3DTexture8 implementation structure
*/
struct IDirect3DTexture8Impl
{
/* IUnknown fields */
const IDirect3DTexture8Vtbl *lpVtbl;
LONG ref;
/* IDirect3DResourc8 fields */
IWineD3DTexture *wineD3DTexture;
/* Parent reference */
LPDIRECT3DDEVICE8 parentDevice;
};
/* ----------------------- */
/* IDirect3DVolumeTexture8 */
/* ----------------------- */
/*****************************************************************************
* Predeclare the interface implementation structures
*/
extern const IDirect3DVolumeTexture8Vtbl Direct3DVolumeTexture8_Vtbl;
/*****************************************************************************
* IDirect3DVolumeTexture8 implementation structure
*/
struct IDirect3DVolumeTexture8Impl
{
/* IUnknown fields */
const IDirect3DVolumeTexture8Vtbl *lpVtbl;
LONG ref;
/* IDirect3DResource8 fields */
IWineD3DVolumeTexture *wineD3DVolumeTexture;
/* Parent reference */
LPDIRECT3DDEVICE8 parentDevice;
};
/* ----------------------- */
/* IDirect3DStateBlockImpl */
/* ----------------------- */
/* TODO: Generate a valid GUIDs */
/* {83B073CE-6F30-11d9-C687-00046142C14F} */
DEFINE_GUID(IID_IDirect3DStateBlock8,
0x83b073ce, 0x6f30, 0x11d9, 0xc6, 0x87, 0x0, 0x4, 0x61, 0x42, 0xc1, 0x4f);
DEFINE_GUID(IID_IDirect3DVertexDeclaration8,
0x5dd7478d, 0xcbf3, 0x41a6, 0x8c, 0xfd, 0xfd, 0x19, 0x2b, 0x11, 0xc7, 0x90);
DEFINE_GUID(IID_IDirect3DVertexShader8,
0xefc5557e, 0x6265, 0x4613, 0x8a, 0x94, 0x43, 0x85, 0x78, 0x89, 0xeb, 0x36);
DEFINE_GUID(IID_IDirect3DPixelShader8,
0x6d3bdbdc, 0x5b02, 0x4415, 0xb8, 0x52, 0xce, 0x5e, 0x8b, 0xcc, 0xb2, 0x89);
/*****************************************************************************
* IDirect3DStateBlock8 interface
*/
#define INTERFACE IDirect3DStateBlock8
DECLARE_INTERFACE_(IDirect3DStateBlock8, IUnknown)
{
/*** IUnknown methods ***/
STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID riid, void** ppvObject) PURE;
STDMETHOD_(ULONG,AddRef)(THIS) PURE;
STDMETHOD_(ULONG,Release)(THIS) PURE;
/*** IDirect3DStateBlock9 methods ***/
STDMETHOD(GetDevice)(THIS_ struct IDirect3DDevice8** ppDevice) PURE;
STDMETHOD(Capture)(THIS) PURE;
STDMETHOD(Apply)(THIS) PURE;
};
#undef INTERFACE
/*** IUnknown methods ***/
#define IDirect3DStateBlock8_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
#define IDirect3DStateBlock8_AddRef(p) (p)->lpVtbl->AddRef(p)
#define IDirect3DStateBlock8_Release(p) (p)->lpVtbl->Release(p)
/*** IDirect3DStateBlock9 methods ***/
#define IDirect3DStateBlock8_GetDevice(p,a) (p)->lpVtbl->GetDevice(p,a)
#define IDirect3DStateBlock8_Capture(p) (p)->lpVtbl->Capture(p)
#define IDirect3DStateBlock8_Apply(p) (p)->lpVtbl->Apply(p)
/*****************************************************************************
* Predeclare the interface implementation structures
*/
extern const IDirect3DStateBlock8Vtbl Direct3DStateBlock8_Vtbl;
/*****************************************************************************
* IDirect3DStateBlock implementation structure
*/
typedef struct IDirect3DStateBlock8Impl {
/* IUnknown fields */
const IDirect3DStateBlock8Vtbl *lpVtbl;
LONG ref;
/* IDirect3DResource8 fields */
IWineD3DStateBlock *wineD3DStateBlock;
} IDirect3DStateBlock8Impl;
/*****************************************************************************
* IDirect3DVertexDeclaration8 interface
*/
#define INTERFACE IDirect3DVertexDeclaration8
DECLARE_INTERFACE_(IDirect3DVertexDeclaration8, IUnknown)
{
/*** IUnknown methods ***/
STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID riid, void** obj_ptr) PURE;
STDMETHOD_(ULONG,AddRef)(THIS) PURE;
STDMETHOD_(ULONG,Release)(THIS) PURE;
};
#undef INTERFACE
/*** IUnknown methods ***/
#define IDirect3DVertexDeclaration8_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
#define IDirect3DVertexDeclaration8_AddRef(p) (p)->lpVtbl->AddRef(p)
#define IDirect3DVertexDeclaration8_Release(p) (p)->lpVtbl->Release(p)
/*** Implementation ***/
extern const IDirect3DVertexDeclaration8Vtbl Direct3DVertexDeclaration8_Vtbl;
typedef struct {
const IDirect3DVertexDeclaration8Vtbl *lpVtbl;
LONG ref_count;
DWORD *elements;
DWORD elements_size; /* Size of elements, in bytes */
IWineD3DVertexDeclaration *wined3d_vertex_declaration;
} IDirect3DVertexDeclaration8Impl;
/*****************************************************************************
* IDirect3DVertexShader9 interface
*/
#define INTERFACE IDirect3DVertexShader8
DECLARE_INTERFACE_(IDirect3DVertexShader8, IUnknown)
{
/*** IUnknown methods ***/
STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID riid, void** ppvObject) PURE;
STDMETHOD_(ULONG,AddRef)(THIS) PURE;
STDMETHOD_(ULONG,Release)(THIS) PURE;
/*** IDirect3DVertexShader9 methods ***/
STDMETHOD(GetDevice)(THIS_ struct IDirect3DDevice8** ppDevice) PURE;
STDMETHOD(GetFunction)(THIS_ void*, UINT* pSizeOfData) PURE;
};
#undef INTERFACE
/*** IUnknown methods ***/
#define IDirect3DVertexShader8_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
#define IDirect3DVertexShader8_AddRef(p) (p)->lpVtbl->AddRef(p)
#define IDirect3DVertexShader8_Release(p) (p)->lpVtbl->Release(p)
/*** IDirect3DVertexShader8 methods ***/
#define IDirect3DVertexShader8_GetDevice(p,a) (p)->lpVtbl->GetDevice(p,a)
#define IDirect3DVertexShader8_GetFunction(p,a,b) (p)->lpVtbl->GetFunction(p,a,b)
/* ------------------------- */
/* IDirect3DVertexShader8Impl */
/* ------------------------- */
/*****************************************************************************
* IDirect3DPixelShader9 interface
*/
#define INTERFACE IDirect3DPixelShader8
DECLARE_INTERFACE_(IDirect3DPixelShader8,IUnknown)
{
/*** IUnknown methods ***/
STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID riid, void** ppvObject) PURE;
STDMETHOD_(ULONG,AddRef)(THIS) PURE;
STDMETHOD_(ULONG,Release)(THIS) PURE;
/*** IDirect3DPixelShader8 methods ***/
STDMETHOD(GetDevice)(THIS_ struct IDirect3DDevice8** ppDevice) PURE;
STDMETHOD(GetFunction)(THIS_ void*, UINT* pSizeOfData) PURE;
};
#undef INTERFACE
/*** IUnknown methods ***/
#define IDirect3DPixelShader8_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
#define IDirect3DPixelShader8_AddRef(p) (p)->lpVtbl->AddRef(p)
#define IDirect3DPixelShader8_Release(p) (p)->lpVtbl->Release(p)
/*** IDirect3DPixelShader8 methods ***/
#define IDirect3DPixelShader8_GetDevice(p,a) (p)->lpVtbl->GetDevice(p,a)
#define IDirect3DPixelShader8_GetFunction(p,a,b) (p)->lpVtbl->GetFunction(p,a,b)
/*****************************************************************************
* Predeclare the interface implementation structures
*/
extern const IDirect3DVertexShader8Vtbl Direct3DVertexShader8_Vtbl;
/*****************************************************************************
* IDirect3DVertexShader implementation structure
*/
struct IDirect3DVertexShader8Impl {
const IDirect3DVertexShader8Vtbl *lpVtbl;
LONG ref;
shader_handle *handle;
IDirect3DVertexDeclaration8 *vertex_declaration;
IWineD3DVertexShader *wineD3DVertexShader;
};
/* ------------------------ */
/* IDirect3DPixelShaderImpl */
/* ------------------------ */
/*****************************************************************************
* Predeclare the interface implementation structures
*/
extern const IDirect3DPixelShader8Vtbl Direct3DPixelShader8_Vtbl;
/*****************************************************************************
* IDirect3DPixelShader implementation structure
*/
typedef struct IDirect3DPixelShader8Impl {
const IDirect3DPixelShader8Vtbl *lpVtbl;
LONG ref;
shader_handle *handle;
/* The device, to be replaced by an IDirect3DDeviceImpl */
IWineD3DPixelShader *wineD3DPixelShader;
} IDirect3DPixelShader8Impl;
/**
* Internals functions
*
* to see how not defined it here
*/
void load_local_constants(const DWORD *d3d8_elements, IWineD3DVertexShader *wined3d_vertex_shader);
size_t convert_to_wined3d_declaration(const DWORD *d3d8_elements, DWORD *d3d8_elements_size, WINED3DVERTEXELEMENT **wined3d_elements);
/* Callbacks */
extern HRESULT WINAPI D3D8CB_CreateSurface(IUnknown *device, IUnknown *pSuperior, UINT Width, UINT Height,
WINED3DFORMAT Format, DWORD Usage, WINED3DPOOL Pool, UINT Level,
IWineD3DSurface** ppSurface, HANDLE* pSharedHandle);
extern HRESULT WINAPI D3D8CB_CreateVolume(IUnknown *pDevice, IUnknown *pSuperior, UINT Width, UINT Height, UINT Depth,
WINED3DFORMAT Format, WINED3DPOOL Pool, DWORD Usage,
IWineD3DVolume **ppVolume,
HANDLE * pSharedHandle);
extern HRESULT WINAPI D3D8CB_CreateDepthStencilSurface(IUnknown *device, IUnknown *pSuperior, UINT Width, UINT Height,
WINED3DFORMAT Format, WINED3DMULTISAMPLE_TYPE MultiSample,
DWORD MultisampleQuality, BOOL Discard,
IWineD3DSurface** ppSurface, HANDLE* pSharedHandle);
extern HRESULT WINAPI D3D8CB_CreateRenderTarget(IUnknown *device, IUnknown *pSuperior, UINT Width, UINT Height,
WINED3DFORMAT Format, WINED3DMULTISAMPLE_TYPE MultiSample,
DWORD MultisampleQuality, BOOL Lockable,
IWineD3DSurface** ppSurface, HANDLE* pSharedHandle);
extern ULONG WINAPI D3D8CB_DestroySwapChain (IWineD3DSwapChain *pSwapChain);
extern ULONG WINAPI D3D8CB_DestroyDepthStencilSurface (IWineD3DSurface *pSurface);
extern ULONG WINAPI D3D8CB_DestroyRenderTarget (IWineD3DSurface *pSurface);
extern ULONG WINAPI D3D8CB_DestroySurface(IWineD3DSurface *pSurface);
extern ULONG WINAPI D3D8CB_DestroyVolume(IWineD3DVolume *pVolume);
#endif /* __WINE_D3DX8_PRIVATE_H */

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,420 @@
/*
* IDirect3D8 implementation
*
* Copyright 2002-2004 Jason Edmeades
* Copyright 2003-2004 Raphael Junqueira
* Copyright 2004 Christian Costa
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "config.h"
#include "d3d8_private.h"
#include "wine/unicode.h"
WINE_DEFAULT_DEBUG_CHANNEL(d3d8);
/* IDirect3D IUnknown parts follow: */
static HRESULT WINAPI IDirect3D8Impl_QueryInterface(LPDIRECT3D8 iface, REFIID riid,LPVOID *ppobj)
{
IDirect3D8Impl *This = (IDirect3D8Impl *)iface;
if (IsEqualGUID(riid, &IID_IUnknown)
|| IsEqualGUID(riid, &IID_IDirect3D8)) {
IUnknown_AddRef(iface);
*ppobj = This;
return S_OK;
}
WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid),ppobj);
*ppobj = NULL;
return E_NOINTERFACE;
}
static ULONG WINAPI IDirect3D8Impl_AddRef(LPDIRECT3D8 iface) {
IDirect3D8Impl *This = (IDirect3D8Impl *)iface;
ULONG ref = InterlockedIncrement(&This->ref);
TRACE("(%p) : AddRef from %d\n", This, ref - 1);
return ref;
}
static ULONG WINAPI IDirect3D8Impl_Release(LPDIRECT3D8 iface) {
IDirect3D8Impl *This = (IDirect3D8Impl *)iface;
ULONG ref = InterlockedDecrement(&This->ref);
TRACE("(%p) : ReleaseRef to %d\n", This, ref);
if (ref == 0) {
TRACE("Releasing wined3d %p\n", This->WineD3D);
IWineD3D_Release(This->WineD3D);
HeapFree(GetProcessHeap(), 0, This);
}
return ref;
}
/* IDirect3D8 Interface follow: */
static HRESULT WINAPI IDirect3D8Impl_RegisterSoftwareDevice (LPDIRECT3D8 iface, void* pInitializeFunction) {
IDirect3D8Impl *This = (IDirect3D8Impl *)iface;
return IWineD3D_RegisterSoftwareDevice(This->WineD3D, pInitializeFunction);
}
static UINT WINAPI IDirect3D8Impl_GetAdapterCount (LPDIRECT3D8 iface) {
IDirect3D8Impl *This = (IDirect3D8Impl *)iface;
return IWineD3D_GetAdapterCount(This->WineD3D);
}
static HRESULT WINAPI IDirect3D8Impl_GetAdapterIdentifier (LPDIRECT3D8 iface,
UINT Adapter, DWORD Flags, D3DADAPTER_IDENTIFIER8* pIdentifier) {
IDirect3D8Impl *This = (IDirect3D8Impl *)iface;
WINED3DADAPTER_IDENTIFIER adapter_id;
/* dx8 and dx9 have different structures to be filled in, with incompatible
layouts so pass in pointers to the places to be filled via an internal
structure */
adapter_id.Driver = pIdentifier->Driver;
adapter_id.Description = pIdentifier->Description;
adapter_id.DeviceName = NULL; /* d3d9 only */
adapter_id.DriverVersion = &pIdentifier->DriverVersion;
adapter_id.VendorId = &pIdentifier->VendorId;
adapter_id.DeviceId = &pIdentifier->DeviceId;
adapter_id.SubSysId = &pIdentifier->SubSysId;
adapter_id.Revision = &pIdentifier->Revision;
adapter_id.DeviceIdentifier = &pIdentifier->DeviceIdentifier;
adapter_id.WHQLLevel = &pIdentifier->WHQLLevel;
return IWineD3D_GetAdapterIdentifier(This->WineD3D, Adapter, Flags, &adapter_id);
}
static UINT WINAPI IDirect3D8Impl_GetAdapterModeCount (LPDIRECT3D8 iface,UINT Adapter) {
IDirect3D8Impl *This = (IDirect3D8Impl *)iface;
return IWineD3D_GetAdapterModeCount(This->WineD3D, Adapter, 0 /* format */);
}
static HRESULT WINAPI IDirect3D8Impl_EnumAdapterModes (LPDIRECT3D8 iface, UINT Adapter, UINT Mode, D3DDISPLAYMODE* pMode) {
IDirect3D8Impl *This = (IDirect3D8Impl *)iface;
/* FIXME: USe a constant WINED3DFOTMAT_ANY, or something similar */
return IWineD3D_EnumAdapterModes(This->WineD3D, Adapter, 0 /* format */, Mode, (WINED3DDISPLAYMODE *) pMode);
}
static HRESULT WINAPI IDirect3D8Impl_GetAdapterDisplayMode (LPDIRECT3D8 iface, UINT Adapter, D3DDISPLAYMODE* pMode) {
IDirect3D8Impl *This = (IDirect3D8Impl *)iface;
return IWineD3D_GetAdapterDisplayMode(This->WineD3D, Adapter, (WINED3DDISPLAYMODE *) pMode);
}
static HRESULT WINAPI IDirect3D8Impl_CheckDeviceType (LPDIRECT3D8 iface,
UINT Adapter, D3DDEVTYPE CheckType, D3DFORMAT DisplayFormat,
D3DFORMAT BackBufferFormat, BOOL Windowed) {
IDirect3D8Impl *This = (IDirect3D8Impl *)iface;
return IWineD3D_CheckDeviceType(This->WineD3D, Adapter, CheckType, DisplayFormat,
BackBufferFormat, Windowed);
}
static HRESULT WINAPI IDirect3D8Impl_CheckDeviceFormat (LPDIRECT3D8 iface,
UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT AdapterFormat,
DWORD Usage, D3DRESOURCETYPE RType, D3DFORMAT CheckFormat) {
IDirect3D8Impl *This = (IDirect3D8Impl *)iface;
return IWineD3D_CheckDeviceFormat(This->WineD3D, Adapter, DeviceType, AdapterFormat,
Usage, RType, CheckFormat);
}
static HRESULT WINAPI IDirect3D8Impl_CheckDeviceMultiSampleType(LPDIRECT3D8 iface,
UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT SurfaceFormat,
BOOL Windowed, D3DMULTISAMPLE_TYPE MultiSampleType) {
IDirect3D8Impl *This = (IDirect3D8Impl *)iface;
return IWineD3D_CheckDeviceMultiSampleType(This->WineD3D, Adapter, DeviceType, SurfaceFormat,
Windowed, (WINED3DMULTISAMPLE_TYPE) MultiSampleType, NULL);
}
static HRESULT WINAPI IDirect3D8Impl_CheckDepthStencilMatch(LPDIRECT3D8 iface,
UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT AdapterFormat,
D3DFORMAT RenderTargetFormat, D3DFORMAT DepthStencilFormat) {
IDirect3D8Impl *This = (IDirect3D8Impl *)iface;
return IWineD3D_CheckDepthStencilMatch(This->WineD3D, Adapter, DeviceType, AdapterFormat,
RenderTargetFormat, DepthStencilFormat);
}
static HRESULT WINAPI IDirect3D8Impl_GetDeviceCaps(LPDIRECT3D8 iface, UINT Adapter, D3DDEVTYPE DeviceType, D3DCAPS8* pCaps) {
IDirect3D8Impl *This = (IDirect3D8Impl *)iface;
HRESULT hrc = D3D_OK;
WINED3DCAPS *pWineCaps;
TRACE("(%p) Relay %d %u %p\n", This, Adapter, DeviceType, pCaps);
if(NULL == pCaps){
return D3DERR_INVALIDCALL;
}
pWineCaps = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(WINED3DCAPS));
if(pWineCaps == NULL){
return D3DERR_INVALIDCALL; /*well this is what MSDN says to return*/
}
D3D8CAPSTOWINECAPS(pCaps, pWineCaps)
hrc = IWineD3D_GetDeviceCaps(This->WineD3D, Adapter, DeviceType, pWineCaps);
HeapFree(GetProcessHeap(), 0, pWineCaps);
/* D3D8 doesn't support SM 2.0 or higher, so clamp to 1.x */
if(pCaps->PixelShaderVersion > D3DPS_VERSION(1,4)){
pCaps->PixelShaderVersion = D3DPS_VERSION(1,4);
}
if(pCaps->VertexShaderVersion > D3DVS_VERSION(1,1)){
pCaps->VertexShaderVersion = D3DVS_VERSION(1,1);
}
TRACE("(%p) returning %p\n", This, pCaps);
return hrc;
}
static HMONITOR WINAPI IDirect3D8Impl_GetAdapterMonitor(LPDIRECT3D8 iface, UINT Adapter) {
IDirect3D8Impl *This = (IDirect3D8Impl *)iface;
return IWineD3D_GetAdapterMonitor(This->WineD3D, Adapter);
}
/* Internal function called back during the CreateDevice to create a render target */
HRESULT WINAPI D3D8CB_CreateRenderTarget(IUnknown *device, IUnknown *pSuperior, UINT Width, UINT Height,
WINED3DFORMAT Format, WINED3DMULTISAMPLE_TYPE MultiSample,
DWORD MultisampleQuality, BOOL Lockable,
IWineD3DSurface** ppSurface, HANDLE* pSharedHandle) {
HRESULT res = D3D_OK;
IDirect3DSurface8Impl *d3dSurface = NULL;
TRACE("(%p) call back\n", device);
res = IDirect3DDevice8_CreateRenderTarget((IDirect3DDevice8 *)device, Width, Height,
(D3DFORMAT)Format, MultiSample, Lockable,
(IDirect3DSurface8 **)&d3dSurface);
if (SUCCEEDED(res)) {
*ppSurface = d3dSurface->wineD3DSurface;
d3dSurface->container = device;
d3dSurface->isImplicit = TRUE;
/* Implicit surfaces are created with an refcount of 0 */
IUnknown_Release((IUnknown *)d3dSurface);
} else {
*ppSurface = NULL;
}
return res;
}
ULONG WINAPI D3D8CB_DestroyRenderTarget(IWineD3DSurface *pSurface) {
IDirect3DSurface8Impl* surfaceParent;
TRACE("(%p) call back\n", pSurface);
IWineD3DSurface_GetParent(pSurface, (IUnknown **) &surfaceParent);
surfaceParent->isImplicit = FALSE;
/* Surface had refcount of 0 GetParent addrefed to 1, so 1 Release is enough */
return IDirect3DSurface8_Release((IDirect3DSurface8*) surfaceParent);
}
/* Callback for creating the inplicite swapchain when the device is created */
static HRESULT WINAPI D3D8CB_CreateAdditionalSwapChain(IUnknown *device,
WINED3DPRESENT_PARAMETERS* pPresentationParameters,
IWineD3DSwapChain ** ppSwapChain){
HRESULT res = D3D_OK;
IDirect3DSwapChain8Impl *d3dSwapChain = NULL;
D3DPRESENT_PARAMETERS localParameters;
TRACE("(%p) call back\n", device);
/* Copy the presentation parameters */
localParameters.BackBufferWidth = pPresentationParameters->BackBufferWidth;
localParameters.BackBufferHeight = pPresentationParameters->BackBufferHeight;
localParameters.BackBufferFormat = pPresentationParameters->BackBufferFormat;
localParameters.BackBufferCount = pPresentationParameters->BackBufferCount;
localParameters.MultiSampleType = pPresentationParameters->MultiSampleType;
localParameters.SwapEffect = pPresentationParameters->SwapEffect;
localParameters.hDeviceWindow = pPresentationParameters->hDeviceWindow;
localParameters.Windowed = pPresentationParameters->Windowed;
localParameters.EnableAutoDepthStencil = pPresentationParameters->EnableAutoDepthStencil;
localParameters.AutoDepthStencilFormat = pPresentationParameters->AutoDepthStencilFormat;
localParameters.Flags = pPresentationParameters->Flags;
localParameters.FullScreen_RefreshRateInHz = pPresentationParameters->FullScreen_RefreshRateInHz;
localParameters.FullScreen_PresentationInterval = pPresentationParameters->PresentationInterval;
res = IDirect3DDevice8_CreateAdditionalSwapChain((IDirect3DDevice8 *)device, &localParameters, (IDirect3DSwapChain8 **)&d3dSwapChain);
/* Copy back the presentation parameters */
pPresentationParameters->BackBufferWidth = localParameters.BackBufferWidth;
pPresentationParameters->BackBufferHeight = localParameters.BackBufferHeight;
pPresentationParameters->BackBufferFormat = localParameters.BackBufferFormat;
pPresentationParameters->BackBufferCount = localParameters.BackBufferCount;
pPresentationParameters->MultiSampleType = localParameters.MultiSampleType;
pPresentationParameters->SwapEffect = localParameters.SwapEffect;
pPresentationParameters->hDeviceWindow = localParameters.hDeviceWindow;
pPresentationParameters->Windowed = localParameters.Windowed;
pPresentationParameters->EnableAutoDepthStencil = localParameters.EnableAutoDepthStencil;
pPresentationParameters->AutoDepthStencilFormat = localParameters.AutoDepthStencilFormat;
pPresentationParameters->Flags = localParameters.Flags;
pPresentationParameters->FullScreen_RefreshRateInHz = localParameters.FullScreen_RefreshRateInHz;
pPresentationParameters->PresentationInterval = localParameters.FullScreen_PresentationInterval;
if (SUCCEEDED(res)) {
*ppSwapChain = d3dSwapChain->wineD3DSwapChain;
IUnknown_Release(d3dSwapChain->parentDevice);
d3dSwapChain->parentDevice = NULL;
} else {
*ppSwapChain = NULL;
}
return res;
}
ULONG WINAPI D3D8CB_DestroySwapChain(IWineD3DSwapChain *pSwapChain) {
IUnknown* swapChainParent;
TRACE("(%p) call back\n", pSwapChain);
IWineD3DSwapChain_GetParent(pSwapChain, &swapChainParent);
IUnknown_Release(swapChainParent);
return IUnknown_Release(swapChainParent);
}
/* Internal function called back during the CreateDevice to create a render target */
HRESULT WINAPI D3D8CB_CreateDepthStencilSurface(IUnknown *device, IUnknown *pSuperior, UINT Width, UINT Height,
WINED3DFORMAT Format, WINED3DMULTISAMPLE_TYPE MultiSample,
DWORD MultisampleQuality, BOOL Discard,
IWineD3DSurface** ppSurface, HANDLE* pSharedHandle) {
HRESULT res = D3D_OK;
IDirect3DSurface8Impl *d3dSurface = NULL;
TRACE("(%p) call back\n", device);
res = IDirect3DDevice8_CreateDepthStencilSurface((IDirect3DDevice8 *)device, Width, Height,
(D3DFORMAT)Format, MultiSample, (IDirect3DSurface8 **)&d3dSurface);
if (SUCCEEDED(res)) {
*ppSurface = d3dSurface->wineD3DSurface;
d3dSurface->container = device;
d3dSurface->isImplicit = TRUE;
/* Implicit surfaces are created with an refcount of 0 */
IUnknown_Release((IUnknown *)d3dSurface);
}
return res;
}
ULONG WINAPI D3D8CB_DestroyDepthStencilSurface(IWineD3DSurface *pSurface) {
IDirect3DSurface8Impl* surfaceParent;
TRACE("(%p) call back\n", pSurface);
IWineD3DSurface_GetParent(pSurface, (IUnknown **) &surfaceParent);
surfaceParent->isImplicit = FALSE;
/* Surface had refcount of 0 GetParent addrefed to 1, so 1 Release is enough */
return IDirect3DSurface8_Release((IDirect3DSurface8*) surfaceParent);
}
static HRESULT WINAPI IDirect3D8Impl_CreateDevice(LPDIRECT3D8 iface, UINT Adapter, D3DDEVTYPE DeviceType, HWND hFocusWindow,
DWORD BehaviourFlags, D3DPRESENT_PARAMETERS* pPresentationParameters,
IDirect3DDevice8** ppReturnedDeviceInterface) {
IDirect3D8Impl *This = (IDirect3D8Impl *)iface;
IDirect3DDevice8Impl *object = NULL;
WINED3DPRESENT_PARAMETERS localParameters;
HRESULT hr;
TRACE("(%p) Relay\n", This);
/* Check the validity range of the adapter parameter */
if (Adapter >= IDirect3D8Impl_GetAdapterCount(iface)) {
*ppReturnedDeviceInterface = NULL;
return D3DERR_INVALIDCALL;
}
/* Allocate the storage for the device object */
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3DDevice8Impl));
if (NULL == object) {
FIXME("Allocation of memory failed\n");
*ppReturnedDeviceInterface = NULL;
return D3DERR_OUTOFVIDEOMEMORY;
}
object->lpVtbl = &Direct3DDevice8_Vtbl;
object->ref = 1;
object->shader_handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, INITIAL_SHADER_HANDLE_TABLE_SIZE * sizeof(shader_handle));
object->shader_handle_table_size = INITIAL_SHADER_HANDLE_TABLE_SIZE;
*ppReturnedDeviceInterface = (IDirect3DDevice8 *)object;
/* Allocate an associated WineD3DDevice object */
hr =IWineD3D_CreateDevice(This->WineD3D, Adapter, DeviceType, hFocusWindow, BehaviourFlags, &object->WineD3DDevice, (IUnknown *)object);
if (hr != D3D_OK) {
HeapFree(GetProcessHeap(), 0, object);
*ppReturnedDeviceInterface = NULL;
return hr;
}
TRACE("(%p) : Created Device %p\n", This, object);
localParameters.BackBufferWidth = pPresentationParameters->BackBufferWidth;
localParameters.BackBufferHeight = pPresentationParameters->BackBufferHeight;
localParameters.BackBufferFormat = pPresentationParameters->BackBufferFormat;
localParameters.BackBufferCount = pPresentationParameters->BackBufferCount;
localParameters.MultiSampleType = pPresentationParameters->MultiSampleType;
localParameters.MultiSampleQuality = 0; /* d3d9 only */
localParameters.SwapEffect = pPresentationParameters->SwapEffect;
localParameters.hDeviceWindow = pPresentationParameters->hDeviceWindow;
localParameters.Windowed = pPresentationParameters->Windowed;
localParameters.EnableAutoDepthStencil = pPresentationParameters->EnableAutoDepthStencil;
localParameters.AutoDepthStencilFormat = pPresentationParameters->AutoDepthStencilFormat;
localParameters.Flags = pPresentationParameters->Flags;
localParameters.FullScreen_RefreshRateInHz = pPresentationParameters->FullScreen_RefreshRateInHz;
localParameters.PresentationInterval = pPresentationParameters->FullScreen_PresentationInterval;
if(BehaviourFlags & D3DCREATE_MULTITHREADED) {
IWineD3DDevice_SetMultithreaded(object->WineD3DDevice);
}
hr = IWineD3DDevice_Init3D(object->WineD3DDevice, &localParameters, D3D8CB_CreateAdditionalSwapChain);
pPresentationParameters->BackBufferWidth = localParameters.BackBufferWidth;
pPresentationParameters->BackBufferHeight = localParameters.BackBufferHeight;
pPresentationParameters->BackBufferFormat = localParameters.BackBufferFormat;
pPresentationParameters->BackBufferCount = localParameters.BackBufferCount;
pPresentationParameters->MultiSampleType = localParameters.MultiSampleType;
pPresentationParameters->SwapEffect = localParameters.SwapEffect;
pPresentationParameters->hDeviceWindow = localParameters.hDeviceWindow;
pPresentationParameters->Windowed = localParameters.Windowed;
pPresentationParameters->EnableAutoDepthStencil = localParameters.EnableAutoDepthStencil;
pPresentationParameters->AutoDepthStencilFormat = localParameters.AutoDepthStencilFormat;
pPresentationParameters->Flags = localParameters.Flags;
pPresentationParameters->FullScreen_RefreshRateInHz = localParameters.FullScreen_RefreshRateInHz;
pPresentationParameters->FullScreen_PresentationInterval = localParameters.PresentationInterval;
if (hr != D3D_OK) {
FIXME("(%p) D3D Initialization failed for WineD3DDevice %p\n", This, object->WineD3DDevice);
HeapFree(GetProcessHeap(), 0, object);
*ppReturnedDeviceInterface = NULL;
}
return hr;
}
const IDirect3D8Vtbl Direct3D8_Vtbl =
{
/* IUnknown */
IDirect3D8Impl_QueryInterface,
IDirect3D8Impl_AddRef,
IDirect3D8Impl_Release,
/* IDirect3D8 */
IDirect3D8Impl_RegisterSoftwareDevice,
IDirect3D8Impl_GetAdapterCount,
IDirect3D8Impl_GetAdapterIdentifier,
IDirect3D8Impl_GetAdapterModeCount,
IDirect3D8Impl_EnumAdapterModes,
IDirect3D8Impl_GetAdapterDisplayMode,
IDirect3D8Impl_CheckDeviceType,
IDirect3D8Impl_CheckDeviceFormat,
IDirect3D8Impl_CheckDeviceMultiSampleType,
IDirect3D8Impl_CheckDepthStencilMatch,
IDirect3D8Impl_GetDeviceCaps,
IDirect3D8Impl_GetAdapterMonitor,
IDirect3D8Impl_CreateDevice
};

View File

@@ -0,0 +1,154 @@
/*
* IDirect3DIndexBuffer8 implementation
*
* Copyright 2005 Oliver Stieber
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "config.h"
#include "d3d8_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(d3d8);
/* IDirect3DIndexBuffer8 IUnknown parts follow: */
static HRESULT WINAPI IDirect3DIndexBuffer8Impl_QueryInterface(LPDIRECT3DINDEXBUFFER8 iface, REFIID riid, LPVOID *ppobj) {
IDirect3DIndexBuffer8Impl *This = (IDirect3DIndexBuffer8Impl *)iface;
if (IsEqualGUID(riid, &IID_IUnknown)
|| IsEqualGUID(riid, &IID_IDirect3DResource8)
|| IsEqualGUID(riid, &IID_IDirect3DIndexBuffer8)) {
IUnknown_AddRef(iface);
*ppobj = This;
return S_OK;
}
WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);
*ppobj = NULL;
return E_NOINTERFACE;
}
static ULONG WINAPI IDirect3DIndexBuffer8Impl_AddRef(LPDIRECT3DINDEXBUFFER8 iface) {
IDirect3DIndexBuffer8Impl *This = (IDirect3DIndexBuffer8Impl *)iface;
ULONG ref = InterlockedIncrement(&This->ref);
TRACE("(%p) : AddRef from %d\n", This, ref - 1);
return ref;
}
static ULONG WINAPI IDirect3DIndexBuffer8Impl_Release(LPDIRECT3DINDEXBUFFER8 iface) {
IDirect3DIndexBuffer8Impl *This = (IDirect3DIndexBuffer8Impl *)iface;
ULONG ref = InterlockedDecrement(&This->ref);
TRACE("(%p) : ReleaseRef to %d\n", This, ref);
if (ref == 0) {
IWineD3DIndexBuffer_Release(This->wineD3DIndexBuffer);
IUnknown_Release(This->parentDevice);
HeapFree(GetProcessHeap(), 0, This);
}
return ref;
}
/* IDirect3DIndexBuffer8 IDirect3DResource8 Interface follow: */
static HRESULT WINAPI IDirect3DIndexBuffer8Impl_GetDevice(LPDIRECT3DINDEXBUFFER8 iface, IDirect3DDevice8 **ppDevice) {
IDirect3DIndexBuffer8Impl *This = (IDirect3DIndexBuffer8Impl *)iface;
TRACE("(%p) Relay\n", This);
return IDirect3DResource8Impl_GetDevice((LPDIRECT3DRESOURCE8) This, ppDevice);
}
static HRESULT WINAPI IDirect3DIndexBuffer8Impl_SetPrivateData(LPDIRECT3DINDEXBUFFER8 iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) {
IDirect3DIndexBuffer8Impl *This = (IDirect3DIndexBuffer8Impl *)iface;
TRACE("(%p) Relay\n", This);
return IWineD3DIndexBuffer_SetPrivateData(This->wineD3DIndexBuffer, refguid, pData, SizeOfData, Flags);
}
static HRESULT WINAPI IDirect3DIndexBuffer8Impl_GetPrivateData(LPDIRECT3DINDEXBUFFER8 iface, REFGUID refguid, void *pData, DWORD *pSizeOfData) {
IDirect3DIndexBuffer8Impl *This = (IDirect3DIndexBuffer8Impl *)iface;
TRACE("(%p) Relay\n", This);
return IWineD3DIndexBuffer_GetPrivateData(This->wineD3DIndexBuffer, refguid, pData, pSizeOfData);
}
static HRESULT WINAPI IDirect3DIndexBuffer8Impl_FreePrivateData(LPDIRECT3DINDEXBUFFER8 iface, REFGUID refguid) {
IDirect3DIndexBuffer8Impl *This = (IDirect3DIndexBuffer8Impl *)iface;
TRACE("(%p) Relay\n", This);
return IWineD3DIndexBuffer_FreePrivateData(This->wineD3DIndexBuffer, refguid);
}
static DWORD WINAPI IDirect3DIndexBuffer8Impl_SetPriority(LPDIRECT3DINDEXBUFFER8 iface, DWORD PriorityNew) {
IDirect3DIndexBuffer8Impl *This = (IDirect3DIndexBuffer8Impl *)iface;
TRACE("(%p) Relay\n", This);
return IWineD3DIndexBuffer_SetPriority(This->wineD3DIndexBuffer, PriorityNew);
}
static DWORD WINAPI IDirect3DIndexBuffer8Impl_GetPriority(LPDIRECT3DINDEXBUFFER8 iface) {
IDirect3DIndexBuffer8Impl *This = (IDirect3DIndexBuffer8Impl *)iface;
TRACE("(%p) Relay\n", This);
return IWineD3DIndexBuffer_GetPriority(This->wineD3DIndexBuffer);
}
static void WINAPI IDirect3DIndexBuffer8Impl_PreLoad(LPDIRECT3DINDEXBUFFER8 iface) {
IDirect3DIndexBuffer8Impl *This = (IDirect3DIndexBuffer8Impl *)iface;
TRACE("(%p) Relay\n", This);
IWineD3DIndexBuffer_PreLoad(This->wineD3DIndexBuffer);
}
static D3DRESOURCETYPE WINAPI IDirect3DIndexBuffer8Impl_GetType(LPDIRECT3DINDEXBUFFER8 iface) {
IDirect3DIndexBuffer8Impl *This = (IDirect3DIndexBuffer8Impl *)iface;
TRACE("(%p) Relay\n", This);
return IWineD3DIndexBuffer_GetType(This->wineD3DIndexBuffer);
}
/* IDirect3DIndexBuffer8 Interface follow: */
static HRESULT WINAPI IDirect3DIndexBuffer8Impl_Lock(LPDIRECT3DINDEXBUFFER8 iface, UINT OffsetToLock, UINT SizeToLock, BYTE **ppbData, DWORD Flags) {
IDirect3DIndexBuffer8Impl *This = (IDirect3DIndexBuffer8Impl *)iface;
TRACE("(%p) Relay\n", This);
return IWineD3DIndexBuffer_Lock(This->wineD3DIndexBuffer, OffsetToLock, SizeToLock, ppbData, Flags);
}
static HRESULT WINAPI IDirect3DIndexBuffer8Impl_Unlock(LPDIRECT3DINDEXBUFFER8 iface) {
IDirect3DIndexBuffer8Impl *This = (IDirect3DIndexBuffer8Impl *)iface;
TRACE("(%p) Relay\n", This);
return IWineD3DIndexBuffer_Unlock(This->wineD3DIndexBuffer);
}
static HRESULT WINAPI IDirect3DIndexBuffer8Impl_GetDesc(LPDIRECT3DINDEXBUFFER8 iface, D3DINDEXBUFFER_DESC *pDesc) {
IDirect3DIndexBuffer8Impl *This = (IDirect3DIndexBuffer8Impl *)iface;
TRACE("(%p) Relay\n", This);
return IWineD3DIndexBuffer_GetDesc(This->wineD3DIndexBuffer, (WINED3DINDEXBUFFER_DESC *) pDesc);
}
const IDirect3DIndexBuffer8Vtbl Direct3DIndexBuffer8_Vtbl =
{
/* IUnknown */
IDirect3DIndexBuffer8Impl_QueryInterface,
IDirect3DIndexBuffer8Impl_AddRef,
IDirect3DIndexBuffer8Impl_Release,
/* IDirect3DResource8 */
IDirect3DIndexBuffer8Impl_GetDevice,
IDirect3DIndexBuffer8Impl_SetPrivateData,
IDirect3DIndexBuffer8Impl_GetPrivateData,
IDirect3DIndexBuffer8Impl_FreePrivateData,
IDirect3DIndexBuffer8Impl_SetPriority,
IDirect3DIndexBuffer8Impl_GetPriority,
IDirect3DIndexBuffer8Impl_PreLoad,
IDirect3DIndexBuffer8Impl_GetType,
/* IDirect3DIndexBuffer8 */
IDirect3DIndexBuffer8Impl_Lock,
IDirect3DIndexBuffer8Impl_Unlock,
IDirect3DIndexBuffer8Impl_GetDesc
};

View File

@@ -0,0 +1,95 @@
/*
* IDirect3DPixelShader8 implementation
*
* Copyright 2002-2003 Jason Edmeades
* Raphael Junqueira
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "config.h"
#include "d3d8_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(d3d8);
/* IDirect3DPixelShader8 IUnknown parts follow: */
static HRESULT WINAPI IDirect3DPixelShader8Impl_QueryInterface(IDirect3DPixelShader8 *iface, REFIID riid, LPVOID *ppobj) {
IDirect3DPixelShader8Impl *This = (IDirect3DPixelShader8Impl *)iface;
if (IsEqualGUID(riid, &IID_IUnknown)
|| IsEqualGUID(riid, &IID_IDirect3DPixelShader8)) {
IUnknown_AddRef(iface);
*ppobj = This;
return S_OK;
}
WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);
*ppobj = NULL;
return E_NOINTERFACE;
}
static ULONG WINAPI IDirect3DPixelShader8Impl_AddRef(IDirect3DPixelShader8 *iface) {
IDirect3DPixelShader8Impl *This = (IDirect3DPixelShader8Impl *)iface;
ULONG ref = InterlockedIncrement(&This->ref);
TRACE("(%p) : AddRef from %d\n", This, ref - 1);
return ref;
}
static ULONG WINAPI IDirect3DPixelShader8Impl_Release(IDirect3DPixelShader8 * iface) {
IDirect3DPixelShader8Impl *This = (IDirect3DPixelShader8Impl *)iface;
ULONG ref = InterlockedDecrement(&This->ref);
TRACE("(%p) : ReleaseRef to %d\n", This, ref);
if (ref == 0) {
IWineD3DPixelShader_Release(This->wineD3DPixelShader);
HeapFree(GetProcessHeap(), 0, This);
}
return ref;
}
/* IDirect3DPixelShader8 Interface follow: */
static HRESULT WINAPI IDirect3DPixelShader8Impl_GetDevice(IDirect3DPixelShader8 *iface, IDirect3DDevice8 **ppDevice) {
IDirect3DPixelShader8Impl *This = (IDirect3DPixelShader8Impl *)iface;
IWineD3DDevice *myDevice = NULL;
TRACE("(%p) : Relay\n", This);
IWineD3DPixelShader_GetDevice(This->wineD3DPixelShader, &myDevice);
IWineD3DDevice_GetParent(myDevice, (IUnknown **)ppDevice);
IWineD3DDevice_Release(myDevice);
TRACE("(%p) returning (%p)\n", This, *ppDevice);
return D3D_OK;
}
static HRESULT WINAPI IDirect3DPixelShader8Impl_GetFunction(IDirect3DPixelShader8 *iface, VOID *pData, UINT *pSizeOfData) {
IDirect3DPixelShader8Impl *This = (IDirect3DPixelShader8Impl *)iface;
TRACE("(%p) Relay\n", This);
return IWineD3DPixelShader_GetFunction(This->wineD3DPixelShader, pData, pSizeOfData);
}
const IDirect3DPixelShader8Vtbl Direct3DPixelShader8_Vtbl =
{
/* IUnknown */
IDirect3DPixelShader8Impl_QueryInterface,
IDirect3DPixelShader8Impl_AddRef,
IDirect3DPixelShader8Impl_Release,
/* IDirect3DPixelShader8 */
IDirect3DPixelShader8Impl_GetDevice,
IDirect3DPixelShader8Impl_GetFunction
};

View File

@@ -0,0 +1,133 @@
/*
* IDirect3DResource8 implementation
*
* Copyright 2005 Oliver Stieber
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "config.h"
#include "d3d8_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(d3d8);
/* IDirect3DResource8 IUnknown parts follow: */
static HRESULT WINAPI IDirect3DResource8Impl_QueryInterface(LPDIRECT3DRESOURCE8 iface, REFIID riid, LPVOID* ppobj) {
IDirect3DResource8Impl *This = (IDirect3DResource8Impl *)iface;
if (IsEqualGUID(riid, &IID_IUnknown)
|| IsEqualGUID(riid, &IID_IDirect3DResource8)) {
IUnknown_AddRef(iface);
*ppobj = This;
return S_OK;
}
WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);
*ppobj = NULL;
return E_NOINTERFACE;
}
static ULONG WINAPI IDirect3DResource8Impl_AddRef(LPDIRECT3DRESOURCE8 iface) {
IDirect3DResource8Impl *This = (IDirect3DResource8Impl *)iface;
ULONG ref = InterlockedIncrement(&This->ref);
TRACE("(%p) : AddRef from %d\n", This, ref - 1);
return ref;
}
static ULONG WINAPI IDirect3DResource8Impl_Release(LPDIRECT3DRESOURCE8 iface) {
IDirect3DResource8Impl *This = (IDirect3DResource8Impl *)iface;
ULONG ref = InterlockedDecrement(&This->ref);
TRACE("(%p) : ReleaseRef to %d\n", This, ref);
if (ref == 0) {
IWineD3DResource_Release(This->wineD3DResource);
HeapFree(GetProcessHeap(), 0, This);
}
return ref;
}
/* IDirect3DResource8 Interface follow: */
HRESULT WINAPI IDirect3DResource8Impl_GetDevice(LPDIRECT3DRESOURCE8 iface, IDirect3DDevice8** ppDevice) {
IDirect3DResource8Impl *This = (IDirect3DResource8Impl *)iface;
IWineD3DDevice *myDevice = NULL;
TRACE("(%p) Relay\n", This);
IWineD3DResource_GetDevice(This->wineD3DResource, &myDevice);
IWineD3DDevice_GetParent(myDevice, (IUnknown **)ppDevice);
IWineD3DDevice_Release(myDevice);
return D3D_OK;
}
static HRESULT WINAPI IDirect3DResource8Impl_SetPrivateData(LPDIRECT3DRESOURCE8 iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) {
IDirect3DResource8Impl *This = (IDirect3DResource8Impl *)iface;
TRACE("(%p) Relay\n", This);
return IWineD3DResource_SetPrivateData(This->wineD3DResource, refguid, pData, SizeOfData, Flags);
}
static HRESULT WINAPI IDirect3DResource8Impl_GetPrivateData(LPDIRECT3DRESOURCE8 iface, REFGUID refguid, void* pData, DWORD* pSizeOfData) {
IDirect3DResource8Impl *This = (IDirect3DResource8Impl *)iface;
TRACE("(%p) Relay\n", This);
return IWineD3DResource_GetPrivateData(This->wineD3DResource, refguid, pData, pSizeOfData);
}
static HRESULT WINAPI IDirect3DResource8Impl_FreePrivateData(LPDIRECT3DRESOURCE8 iface, REFGUID refguid) {
IDirect3DResource8Impl *This = (IDirect3DResource8Impl *)iface;
TRACE("(%p) Relay\n", This);
return IWineD3DResource_FreePrivateData(This->wineD3DResource, refguid);
}
static DWORD WINAPI IDirect3DResource8Impl_SetPriority(LPDIRECT3DRESOURCE8 iface, DWORD PriorityNew) {
IDirect3DResource8Impl *This = (IDirect3DResource8Impl *)iface;
TRACE("(%p) Relay\n", This);
return IWineD3DResource_SetPriority(This->wineD3DResource, PriorityNew);
}
static DWORD WINAPI IDirect3DResource8Impl_GetPriority(LPDIRECT3DRESOURCE8 iface) {
IDirect3DResource8Impl *This = (IDirect3DResource8Impl *)iface;
TRACE("(%p) Relay\n", This);
return IWineD3DResource_GetPriority(This->wineD3DResource);
}
static void WINAPI IDirect3DResource8Impl_PreLoad(LPDIRECT3DRESOURCE8 iface) {
IDirect3DResource8Impl *This = (IDirect3DResource8Impl *)iface;
TRACE("(%p) Relay\n", This);
IWineD3DResource_PreLoad(This->wineD3DResource);
return;
}
static D3DRESOURCETYPE WINAPI IDirect3DResource8Impl_GetType(LPDIRECT3DRESOURCE8 iface) {
IDirect3DResource8Impl *This = (IDirect3DResource8Impl *)iface;
TRACE("(%p) Relay\n", This);
return IWineD3DResource_GetType(This->wineD3DResource);
}
const IDirect3DResource8Vtbl Direct3DResource8_Vtbl =
{
IDirect3DResource8Impl_QueryInterface,
IDirect3DResource8Impl_AddRef,
IDirect3DResource8Impl_Release,
IDirect3DResource8Impl_GetDevice,
IDirect3DResource8Impl_SetPrivateData,
IDirect3DResource8Impl_GetPrivateData,
IDirect3DResource8Impl_FreePrivateData,
IDirect3DResource8Impl_SetPriority,
IDirect3DResource8Impl_GetPriority,
IDirect3DResource8Impl_PreLoad,
IDirect3DResource8Impl_GetType
};

View File

@@ -0,0 +1,96 @@
/*
* IDirect3DStateBlock8 implementation
*
* Copyright 2002-2003 Raphael Junqueira
* Copyright 2002-2003 Jason Edmeades
* Copyright 2005 Oliver Stieber
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "config.h"
#include "d3d8_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(d3d8);
/* NOTE: DirectX8 doesn't export a IDirect3DStateBlock8, the interface is used internally to keep d3d8 and d3d9 as simila as possible */
/* IDirect3DStateBlock8 IUnknown parts follow: */
static HRESULT WINAPI IDirect3DStateBlock8Impl_QueryInterface(IDirect3DStateBlock8 *iface, REFIID riid, LPVOID *ppobj) {
IDirect3DStateBlock8Impl *This = (IDirect3DStateBlock8Impl *)iface;
if (IsEqualGUID(riid, &IID_IUnknown)
|| IsEqualGUID(riid, &IID_IDirect3DStateBlock8)) {
IUnknown_AddRef(iface);
*ppobj = This;
return S_OK;
}
WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);
*ppobj = NULL;
return E_NOINTERFACE;
}
static ULONG WINAPI IDirect3DStateBlock8Impl_AddRef(IDirect3DStateBlock8 *iface) {
IDirect3DStateBlock8Impl *This = (IDirect3DStateBlock8Impl *)iface;
ULONG ref = InterlockedIncrement(&This->ref);
TRACE("(%p) : AddRef from %d\n", This, ref - 1);
return ref;
}
static ULONG WINAPI IDirect3DStateBlock8Impl_Release(IDirect3DStateBlock8 *iface) {
IDirect3DStateBlock8Impl *This = (IDirect3DStateBlock8Impl *)iface;
ULONG ref = InterlockedDecrement(&This->ref);
TRACE("(%p) : ReleaseRef to %d\n", This, ref);
if (ref == 0) {
IWineD3DStateBlock_Release(This->wineD3DStateBlock);
HeapFree(GetProcessHeap(), 0, This);
}
return ref;
}
/* IDirect3DStateBlock8 Interface follow: */
static HRESULT WINAPI IDirect3DStateBlock8Impl_GetDevice(IDirect3DStateBlock8 *iface, IDirect3DDevice8 **ppDevice) {
IDirect3DStateBlock8Impl *This = (IDirect3DStateBlock8Impl *)iface;
TRACE("(%p) Relay\n", This);
return IDirect3DResource8Impl_GetDevice((LPDIRECT3DRESOURCE8) This, ppDevice);
}
static HRESULT WINAPI IDirect3DStateBlock8Impl_Capture(IDirect3DStateBlock8 *iface) {
IDirect3DStateBlock8Impl *This = (IDirect3DStateBlock8Impl *)iface;
TRACE("(%p) Relay\n", This);
return IWineD3DStateBlock_Capture(This->wineD3DStateBlock);
}
static HRESULT WINAPI IDirect3DStateBlock8Impl_Apply(IDirect3DStateBlock8 *iface) {
IDirect3DStateBlock8Impl *This = (IDirect3DStateBlock8Impl *)iface;
TRACE("(%p) Relay\n", This);
return IWineD3DStateBlock_Apply(This->wineD3DStateBlock);
}
const IDirect3DStateBlock8Vtbl Direct3DStateBlock8_Vtbl =
{
/* IUnknown */
IDirect3DStateBlock8Impl_QueryInterface,
IDirect3DStateBlock8Impl_AddRef,
IDirect3DStateBlock8Impl_Release,
/* IDirect3DStateBlock8 */
IDirect3DStateBlock8Impl_GetDevice,
IDirect3DStateBlock8Impl_Capture,
IDirect3DStateBlock8Impl_Apply
};

View File

@@ -0,0 +1,175 @@
/*
* IDirect3DSurface8 implementation
*
* Copyright 2005 Oliver Stieber
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "config.h"
#include "d3d8_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(d3d8);
/* IDirect3DSurface8 IUnknown parts follow: */
static HRESULT WINAPI IDirect3DSurface8Impl_QueryInterface(LPDIRECT3DSURFACE8 iface, REFIID riid, LPVOID *ppobj) {
IDirect3DSurface8Impl *This = (IDirect3DSurface8Impl *)iface;
if (IsEqualGUID(riid, &IID_IUnknown)
|| IsEqualGUID(riid, &IID_IDirect3DResource8)
|| IsEqualGUID(riid, &IID_IDirect3DSurface8)) {
IUnknown_AddRef(iface);
*ppobj = This;
return S_OK;
}
WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);
*ppobj = NULL;
return E_NOINTERFACE;
}
static ULONG WINAPI IDirect3DSurface8Impl_AddRef(LPDIRECT3DSURFACE8 iface) {
IDirect3DSurface8Impl *This = (IDirect3DSurface8Impl *)iface;
TRACE("(%p)\n", This);
if (This->forwardReference) {
/* Forward refcounting */
TRACE("(%p) : Forwarding to %p\n", This, This->forwardReference);
return IUnknown_AddRef(This->forwardReference);
} else {
/* No container, handle our own refcounting */
ULONG ref = InterlockedIncrement(&This->ref);
if(ref == 1 && This->parentDevice) IUnknown_AddRef(This->parentDevice);
TRACE("(%p) : AddRef from %d\n", This, ref - 1);
return ref;
}
}
static ULONG WINAPI IDirect3DSurface8Impl_Release(LPDIRECT3DSURFACE8 iface) {
IDirect3DSurface8Impl *This = (IDirect3DSurface8Impl *)iface;
TRACE("(%p)\n", This);
if (This->forwardReference) {
/* Forward refcounting */
TRACE("(%p) : Forwarding to %p\n", This, This->forwardReference);
return IUnknown_Release(This->forwardReference);
} else {
/* No container, handle our own refcounting */
ULONG ref = InterlockedDecrement(&This->ref);
TRACE("(%p) : ReleaseRef to %d\n", This, ref);
if (ref == 0) {
if (This->parentDevice) IUnknown_Release(This->parentDevice);
/* Implicit surfaces are destroyed with the device, not if refcount reaches 0. */
if (!This->isImplicit) {
IWineD3DSurface_Release(This->wineD3DSurface);
HeapFree(GetProcessHeap(), 0, This);
}
}
return ref;
}
}
/* IDirect3DSurface8 IDirect3DResource8 Interface follow: */
static HRESULT WINAPI IDirect3DSurface8Impl_GetDevice(LPDIRECT3DSURFACE8 iface, IDirect3DDevice8 **ppDevice) {
IDirect3DSurface8Impl *This = (IDirect3DSurface8Impl *)iface;
return IDirect3DResource8Impl_GetDevice((LPDIRECT3DRESOURCE8) This, ppDevice);
}
static HRESULT WINAPI IDirect3DSurface8Impl_SetPrivateData(LPDIRECT3DSURFACE8 iface, REFGUID refguid, CONST void *pData, DWORD SizeOfData, DWORD Flags) {
IDirect3DSurface8Impl *This = (IDirect3DSurface8Impl *)iface;
TRACE("(%p) Relay\n", This);
return IWineD3DSurface_SetPrivateData(This->wineD3DSurface, refguid, pData, SizeOfData, Flags);
}
static HRESULT WINAPI IDirect3DSurface8Impl_GetPrivateData(LPDIRECT3DSURFACE8 iface, REFGUID refguid, void *pData, DWORD *pSizeOfData) {
IDirect3DSurface8Impl *This = (IDirect3DSurface8Impl *)iface;
TRACE("(%p) Relay\n", This);
return IWineD3DSurface_GetPrivateData(This->wineD3DSurface, refguid, pData, pSizeOfData);
}
static HRESULT WINAPI IDirect3DSurface8Impl_FreePrivateData(LPDIRECT3DSURFACE8 iface, REFGUID refguid) {
IDirect3DSurface8Impl *This = (IDirect3DSurface8Impl *)iface;
TRACE("(%p) Relay\n", This);
return IWineD3DSurface_FreePrivateData(This->wineD3DSurface, refguid);
}
/* IDirect3DSurface8 Interface follow: */
static HRESULT WINAPI IDirect3DSurface8Impl_GetContainer(LPDIRECT3DSURFACE8 iface, REFIID riid, void **ppContainer) {
IDirect3DSurface8Impl *This = (IDirect3DSurface8Impl *)iface;
HRESULT res;
TRACE("(%p) Relay\n", This);
if (!This->container) return E_NOINTERFACE;
res = IUnknown_QueryInterface(This->container, riid, ppContainer);
TRACE("(%p) : returning %p\n", This, *ppContainer);
return res;
}
static HRESULT WINAPI IDirect3DSurface8Impl_GetDesc(LPDIRECT3DSURFACE8 iface, D3DSURFACE_DESC *pDesc) {
IDirect3DSurface8Impl *This = (IDirect3DSurface8Impl *)iface;
WINED3DSURFACE_DESC wined3ddesc;
TRACE("(%p) Relay\n", This);
/* As d3d8 and d3d9 structures differ, pass in ptrs to where data needs to go */
memset(&wined3ddesc, 0, sizeof(wined3ddesc));
wined3ddesc.Format = (WINED3DFORMAT *)&pDesc->Format;
wined3ddesc.Type = (WINED3DRESOURCETYPE *)&pDesc->Type;
wined3ddesc.Usage = &pDesc->Usage;
wined3ddesc.Pool = (WINED3DPOOL *) &pDesc->Pool;
wined3ddesc.Size = &pDesc->Size;
wined3ddesc.MultiSampleType = (WINED3DMULTISAMPLE_TYPE *) &pDesc->MultiSampleType;
wined3ddesc.Width = &pDesc->Width;
wined3ddesc.Height = &pDesc->Height;
return IWineD3DSurface_GetDesc(This->wineD3DSurface, &wined3ddesc);
}
static HRESULT WINAPI IDirect3DSurface8Impl_LockRect(LPDIRECT3DSURFACE8 iface, D3DLOCKED_RECT *pLockedRect, CONST RECT *pRect, DWORD Flags) {
IDirect3DSurface8Impl *This = (IDirect3DSurface8Impl *)iface;
TRACE("(%p) Relay\n", This);
TRACE("(%p) calling IWineD3DSurface_LockRect %p %p %p %d\n", This, This->wineD3DSurface, pLockedRect, pRect, Flags);
return IWineD3DSurface_LockRect(This->wineD3DSurface, (WINED3DLOCKED_RECT *) pLockedRect, pRect, Flags);
}
static HRESULT WINAPI IDirect3DSurface8Impl_UnlockRect(LPDIRECT3DSURFACE8 iface) {
IDirect3DSurface8Impl *This = (IDirect3DSurface8Impl *)iface;
TRACE("(%p) Relay\n", This);
return IWineD3DSurface_UnlockRect(This->wineD3DSurface);
}
const IDirect3DSurface8Vtbl Direct3DSurface8_Vtbl =
{
/* IUnknown */
IDirect3DSurface8Impl_QueryInterface,
IDirect3DSurface8Impl_AddRef,
IDirect3DSurface8Impl_Release,
/* IDirect3DResource8 */
IDirect3DSurface8Impl_GetDevice,
IDirect3DSurface8Impl_SetPrivateData,
IDirect3DSurface8Impl_GetPrivateData,
IDirect3DSurface8Impl_FreePrivateData,
/* IDirect3DSurface8 */
IDirect3DSurface8Impl_GetContainer,
IDirect3DSurface8Impl_GetDesc,
IDirect3DSurface8Impl_LockRect,
IDirect3DSurface8Impl_UnlockRect
};

View File

@@ -0,0 +1,95 @@
/*
* IDirect3DSwapChain8 implementation
*
* Copyright 2005 Oliver Stieber
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "config.h"
#include "d3d8_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(d3d8);
/* IDirect3DSwapChain IUnknown parts follow: */
static HRESULT WINAPI IDirect3DSwapChain8Impl_QueryInterface(LPDIRECT3DSWAPCHAIN8 iface, REFIID riid, LPVOID* ppobj)
{
IDirect3DSwapChain8Impl *This = (IDirect3DSwapChain8Impl *)iface;
if (IsEqualGUID(riid, &IID_IUnknown)
|| IsEqualGUID(riid, &IID_IDirect3DSwapChain8)) {
IUnknown_AddRef(iface);
*ppobj = This;
return S_OK;
}
WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);
*ppobj = NULL;
return E_NOINTERFACE;
}
static ULONG WINAPI IDirect3DSwapChain8Impl_AddRef(LPDIRECT3DSWAPCHAIN8 iface) {
IDirect3DSwapChain8Impl *This = (IDirect3DSwapChain8Impl *)iface;
ULONG ref = InterlockedIncrement(&This->ref);
TRACE("(%p) : AddRef from %d\n", This, ref - 1);
return ref;
}
static ULONG WINAPI IDirect3DSwapChain8Impl_Release(LPDIRECT3DSWAPCHAIN8 iface) {
IDirect3DSwapChain8Impl *This = (IDirect3DSwapChain8Impl *)iface;
ULONG ref = InterlockedDecrement(&This->ref);
TRACE("(%p) : ReleaseRef to %d\n", This, ref);
if (ref == 0) {
IWineD3DSwapChain_Destroy(This->wineD3DSwapChain, D3D8CB_DestroyRenderTarget);
if (This->parentDevice) IUnknown_Release(This->parentDevice);
HeapFree(GetProcessHeap(), 0, This);
}
return ref;
}
/* IDirect3DSwapChain8 parts follow: */
static HRESULT WINAPI IDirect3DSwapChain8Impl_Present(LPDIRECT3DSWAPCHAIN8 iface, CONST RECT *pSourceRect, CONST RECT *pDestRect, HWND hDestWindowOverride, CONST RGNDATA *pDirtyRegion) {
IDirect3DSwapChain8Impl *This = (IDirect3DSwapChain8Impl *)iface;
TRACE("(%p) Relay\n", This);
return IWineD3DSwapChain_Present(This->wineD3DSwapChain, pSourceRect, pDestRect, hDestWindowOverride, pDirtyRegion, 0);
}
static HRESULT WINAPI IDirect3DSwapChain8Impl_GetBackBuffer(LPDIRECT3DSWAPCHAIN8 iface, UINT iBackBuffer, D3DBACKBUFFER_TYPE Type, IDirect3DSurface8** ppBackBuffer) {
IDirect3DSwapChain8Impl *This = (IDirect3DSwapChain8Impl *)iface;
HRESULT hrc = D3D_OK;
IWineD3DSurface *mySurface = NULL;
TRACE("(%p) Relay\n", This);
hrc = IWineD3DSwapChain_GetBackBuffer(This->wineD3DSwapChain, iBackBuffer, (WINED3DBACKBUFFER_TYPE )Type, &mySurface);
if (hrc == D3D_OK && NULL != mySurface) {
IWineD3DSurface_GetParent(mySurface, (IUnknown **)ppBackBuffer);
IWineD3DSurface_Release(mySurface);
}
return hrc;
}
const IDirect3DSwapChain8Vtbl Direct3DSwapChain8_Vtbl =
{
IDirect3DSwapChain8Impl_QueryInterface,
IDirect3DSwapChain8Impl_AddRef,
IDirect3DSwapChain8Impl_Release,
IDirect3DSwapChain8Impl_Present,
IDirect3DSwapChain8Impl_GetBackBuffer
};

View File

@@ -0,0 +1,119 @@
/*
* Copyright (C) 2006 Louis Lenders
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "wine/test.h"
static HRESULT (WINAPI *ValidateVertexShader)(DWORD*,DWORD*,DWORD*,int,DWORD*);
static HRESULT (WINAPI *ValidatePixelShader)(DWORD*,DWORD*,int,DWORD*);
static void test_ValidateVertexShader(void)
{
HRESULT ret;
static DWORD simple_vs[] = {0xFFFE0101, /* vs_1_1 */
0x00000009, 0xC0010000, 0x90E40000, 0xA0E40000, /* dp4 oPos.x, v0, c0 */
0x00000009, 0xC0020000, 0x90E40000, 0xA0E40001, /* dp4 oPos.y, v0, c1 */
0x00000009, 0xC0040000, 0x90E40000, 0xA0E40002, /* dp4 oPos.z, v0, c2 */
0x00000009, 0xC0080000, 0x90E40000, 0xA0E40003, /* dp4 oPos.w, v0, c3 */
0x0000FFFF};
ret=ValidateVertexShader(0,0,0,0,0);
ok(ret==E_FAIL,"ValidateVertexShader returned %x but expected E_FAIL\n",ret);
ret=ValidateVertexShader(0,0,0,1,0);
ok(ret==E_FAIL,"ValidateVertexShader returned %x but expected E_FAIL\n",ret);
ret=ValidateVertexShader(simple_vs,0,0,0,0);
ok(ret==S_OK,"ValidateVertexShader returned %x but expected S_OK\n",ret);
ret=ValidateVertexShader(simple_vs,0,0,1,0);
ok(ret==S_OK,"ValidateVertexShader returned %x but expected S_OK\n",ret);
/* seems to do some version checking */
*simple_vs=0xFFFE0100; /* vs_1_0 */
ret=ValidateVertexShader(simple_vs,0,0,0,0);
ok(ret==S_OK,"ValidateVertexShader returned %x but expected S_OK\n",ret);
*simple_vs=0xFFFE0102; /* bogus version */
ret=ValidateVertexShader(simple_vs,0,0,1,0);
ok(ret==E_FAIL,"ValidateVertexShader returned %x but expected E_FAIL\n",ret);
/* I've seen that applications pass 2nd and 3rd parameter always as 0;simple test with non-zero parameters */
*simple_vs=0xFFFE0101; /* vs_1_1 */
ret=ValidateVertexShader(simple_vs,simple_vs,0,1,0);
ok(ret==E_FAIL,"ValidateVertexShader returned %x but expected E_FAIL\n",ret);
ret=ValidateVertexShader(simple_vs,0,simple_vs,1,0);
ok(ret==E_FAIL,"ValidateVertexShader returned %x but expected E_FAIL\n",ret);
/* I've seen 4th parameter is always passed as either 0 or 1, but passing other values doesn't seem to hurt*/
ret=ValidateVertexShader(simple_vs,0,0,12345,0);
ok(ret==S_OK,"ValidateVertexShader returned %x but expected S_OK\n",ret);
/* What is 5th parameter ???? Following works ok */
ret=ValidateVertexShader(simple_vs,0,0,1,simple_vs);
ok(ret==S_OK,"ValidateVertexShader returned %x but expected S_OK\n",ret);
}
static void test_ValidatePixelShader(void)
{
HRESULT ret;
static DWORD simple_ps[] = {0xFFFF0101, /* ps_1_1 */
0x00000051, 0xA00F0001, 0x3F800000, 0x00000000, 0x00000000, 0x00000000, /* def c1 = 1.0, 0.0, 0.0, 0.0 */
0x00000042, 0xB00F0000, /* tex t0 */
0x00000008, 0x800F0000, 0xA0E40001, 0xA0E40000, /* dp3 r0, c1, c0 */
0x00000005, 0x800F0000, 0x90E40000, 0x80E40000, /* mul r0, v0, r0 */
0x00000005, 0x800F0000, 0xB0E40000, 0x80E40000, /* mul r0, t0, r0 */
0x0000FFFF}; /* END */
ret=ValidatePixelShader(0,0,0,0);
ok(ret==E_FAIL,"ValidatePixelShader returned %x but expected E_FAIL\n",ret);
ret=ValidatePixelShader(0,0,1,0);
ok(ret==E_FAIL,"ValidatePixelShader returned %x but expected E_FAIL\n",ret);
ret=ValidatePixelShader(simple_ps,0,0,0);
ok(ret==S_OK,"ValidatePixelShader returned %x but expected S_OK\n",ret);
ret=ValidatePixelShader(simple_ps,0,1,0);
ok(ret==S_OK,"ValidatePixelShader returned %x but expected S_OK\n",ret);
/* seems to do some version checking */
*simple_ps=0xFFFF0105; /* bogus version */
ret=ValidatePixelShader(simple_ps,0,1,0);
ok(ret==E_FAIL,"ValidatePixelShader returned %x but expected E_FAIL\n",ret);
/* I've seen that applications pass 2nd parameter always as 0;simple test with non-zero parameter */
*simple_ps=0xFFFF0101; /* ps_1_1 */
ret=ValidatePixelShader(simple_ps,simple_ps,1,0);
ok(ret==E_FAIL,"ValidatePixelShader returned %x but expected E_FAIL\n",ret);
/* I've seen 3rd parameter is always passed as either 0 or 1, but passing other values doesn't seem to hurt*/
ret=ValidatePixelShader(simple_ps,0,12345,0);
ok(ret==S_OK,"ValidatePixelShader returned %x but expected S_OK\n",ret);
/* What is 4th parameter ???? Following works ok */
ret=ValidatePixelShader(simple_ps,0,1,simple_ps);
ok(ret==S_OK,"ValidatePixelShader returned %x but expected S_OK\n",ret);
}
START_TEST(d3d8_main)
{
HMODULE d3d8_handle = LoadLibraryA( "d3d8.dll" );
if (!d3d8_handle)
{
skip("Could not load d3d8.dll\n");
return;
}
ValidateVertexShader = (void*)GetProcAddress (d3d8_handle, "ValidateVertexShader" );
ValidatePixelShader = (void*)GetProcAddress (d3d8_handle, "ValidatePixelShader" );
test_ValidateVertexShader();
test_ValidatePixelShader();
}

View File

@@ -0,0 +1,126 @@
# Microsoft Developer Studio Project File - Name="d3d8_test" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Console Application" 0x0103
CFG=d3d8_test - Win32 Debug
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
!MESSAGE
!MESSAGE NMAKE /f "d3d8_test.mak".
!MESSAGE
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "d3d8_test.mak" CFG="d3d8_test - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "d3d8_test - Win32 Release" (based on "Win32 (x86) Console Application")
!MESSAGE "d3d8_test - Win32 Debug" (based on "Win32 (x86) Console Application")
!MESSAGE
# Begin Project
# PROP AllowPerConfigDependencies 0
# PROP Scc_ProjName ""
# PROP Scc_LocalPath ""
CPP=xicl6.exe
RSC=rc.exe
!IF "$(CFG)" == "d3d8_test - Win32 Release"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Release"
# PROP BASE Intermediate_Dir "Release"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "Release"
# PROP Intermediate_Dir "Release"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
# ADD CPP /nologo /MD /W3 /GX /Zi /O2 /I "..\..\..\include" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
# ADD BASE RSC /l 0x419 /d "NDEBUG"
# ADD RSC /l 0x419 /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=xilink6.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
# ADD LINK32 kernel32.lib user32.lib uuid.lib dxguid.lib dxerr8.lib /nologo /subsystem:console /pdb:"../../../bin/d3d8_test.pdb" /debug /machine:I386 /out:"../../../bin/d3d8_test.exe"
!ELSEIF "$(CFG)" == "d3d8_test - Win32 Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "Debug"
# PROP BASE Intermediate_Dir "Debug"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "Debug"
# PROP Intermediate_Dir "Debug"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "..\..\..\include" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
# ADD BASE RSC /l 0x419 /d "_DEBUG"
# ADD RSC /l 0x419 /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=xilink6.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
# ADD LINK32 kernel32.lib user32.lib uuid.lib dxguid.lib dxerr8.lib /nologo /subsystem:console /pdb:"../../../bin/d3d8_test.pdb" /debug /machine:I386 /out:"../../../bin/d3d8_test.exe" /pdbtype:sept
!ENDIF
# Begin Target
# Name "d3d8_test - Win32 Release"
# Name "d3d8_test - Win32 Debug"
# Begin Group "Source Files"
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
# Begin Source File
SOURCE=.\d3d8_main.c
# End Source File
# Begin Source File
SOURCE=.\device.c
# End Source File
# Begin Source File
SOURCE=.\surface.c
# End Source File
# Begin Source File
SOURCE=.\tests.c
# End Source File
# Begin Source File
SOURCE=.\texture.c
# End Source File
# Begin Source File
SOURCE=.\visual.c
# End Source File
# Begin Source File
SOURCE=.\volume.c
# End Source File
# End Group
# Begin Group "Header Files"
# PROP Default_Filter "h;hpp;hxx;hm;inl"
# End Group
# Begin Group "Resource Files"
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
# End Group
# End Target
# End Project

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,140 @@
/*
* Copyright (C) 2006 Henri Verbeet
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#define COBJMACROS
#include <d3d8.h>
#include "wine/test.h"
static HWND create_window(void)
{
WNDCLASS wc = {0};
wc.lpfnWndProc = &DefWindowProc;
wc.lpszClassName = "d3d8_test_wc";
RegisterClass(&wc);
return CreateWindow("d3d8_test_wc", "d3d8_test",
0, 0, 0, 0, 0, 0, 0, 0, 0);
}
static IDirect3DDevice8 *init_d3d8(HMODULE d3d8_handle)
{
IDirect3D8 * (__stdcall * d3d8_create)(UINT SDKVersion) = 0;
IDirect3D8 *d3d8_ptr = 0;
IDirect3DDevice8 *device_ptr = 0;
D3DPRESENT_PARAMETERS present_parameters;
D3DDISPLAYMODE d3ddm;
HRESULT hr;
d3d8_create = (void *)GetProcAddress(d3d8_handle, "Direct3DCreate8");
ok(d3d8_create != NULL, "Failed to get address of Direct3DCreate8\n");
if (!d3d8_create) return NULL;
d3d8_ptr = d3d8_create(D3D_SDK_VERSION);
ok(d3d8_ptr != NULL, "Failed to create IDirect3D8 object\n");
if (!d3d8_ptr) return NULL;
IDirect3D8_GetAdapterDisplayMode(d3d8_ptr, D3DADAPTER_DEFAULT, &d3ddm );
ZeroMemory(&present_parameters, sizeof(present_parameters));
present_parameters.Windowed = TRUE;
present_parameters.hDeviceWindow = create_window();
present_parameters.SwapEffect = D3DSWAPEFFECT_DISCARD;
present_parameters.BackBufferFormat = d3ddm.Format;
hr = IDirect3D8_CreateDevice(d3d8_ptr, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL,
NULL, D3DCREATE_SOFTWARE_VERTEXPROCESSING, &present_parameters, &device_ptr);
if(FAILED(hr))
{
trace("could not create device, IDirect3D8_CreateDevice returned %#x\n", hr);
return NULL;
}
return device_ptr;
}
static void test_surface_get_container(IDirect3DDevice8 *device_ptr)
{
IDirect3DTexture8 *texture_ptr = 0;
IDirect3DSurface8 *surface_ptr = 0;
void *container_ptr;
HRESULT hr;
hr = IDirect3DDevice8_CreateTexture(device_ptr, 128, 128, 1, 0,
D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &texture_ptr);
ok(SUCCEEDED(hr) && texture_ptr != NULL, "CreateTexture returned: hr %#x, texture_ptr %p. "
"Expected hr %#x, texture_ptr != %p\n", hr, texture_ptr, D3D_OK, NULL);
if (!texture_ptr || FAILED(hr)) goto cleanup;
hr = IDirect3DTexture8_GetSurfaceLevel(texture_ptr, 0, &surface_ptr);
ok(SUCCEEDED(hr) && surface_ptr != NULL, "GetSurfaceLevel returned: hr %#x, surface_ptr %p. "
"Expected hr %#x, surface_ptr != %p\n", hr, surface_ptr, D3D_OK, NULL);
if (!surface_ptr || FAILED(hr)) goto cleanup;
/* These should work... */
container_ptr = (void *)0x1337c0d3;
hr = IDirect3DSurface8_GetContainer(surface_ptr, &IID_IUnknown, &container_ptr);
ok(SUCCEEDED(hr) && container_ptr == texture_ptr, "GetContainer returned: hr %#x, container_ptr %p. "
"Expected hr %#x, container_ptr %p\n", hr, container_ptr, S_OK, texture_ptr);
if (container_ptr && container_ptr != (void *)0x1337c0d3) IUnknown_Release((IUnknown *)container_ptr);
container_ptr = (void *)0x1337c0d3;
hr = IDirect3DSurface8_GetContainer(surface_ptr, &IID_IDirect3DResource8, &container_ptr);
ok(SUCCEEDED(hr) && container_ptr == texture_ptr, "GetContainer returned: hr %#x, container_ptr %p. "
"Expected hr %#x, container_ptr %p\n", hr, container_ptr, S_OK, texture_ptr);
if (container_ptr && container_ptr != (void *)0x1337c0d3) IUnknown_Release((IUnknown *)container_ptr);
container_ptr = (void *)0x1337c0d3;
hr = IDirect3DSurface8_GetContainer(surface_ptr, &IID_IDirect3DBaseTexture8, &container_ptr);
ok(SUCCEEDED(hr) && container_ptr == texture_ptr, "GetContainer returned: hr %#x, container_ptr %p. "
"Expected hr %#x, container_ptr %p\n", hr, container_ptr, S_OK, texture_ptr);
if (container_ptr && container_ptr != (void *)0x1337c0d3) IUnknown_Release((IUnknown *)container_ptr);
container_ptr = (void *)0x1337c0d3;
hr = IDirect3DSurface8_GetContainer(surface_ptr, &IID_IDirect3DTexture8, &container_ptr);
ok(SUCCEEDED(hr) && container_ptr == texture_ptr, "GetContainer returned: hr %#x, container_ptr %p. "
"Expected hr %#x, container_ptr %p\n", hr, container_ptr, S_OK, texture_ptr);
if (container_ptr && container_ptr != (void *)0x1337c0d3) IUnknown_Release((IUnknown *)container_ptr);
/* ...and this one shouldn't. This should return E_NOINTERFACE and set container_ptr to NULL */
container_ptr = (void *)0x1337c0d3;
hr = IDirect3DSurface8_GetContainer(surface_ptr, &IID_IDirect3DSurface8, &container_ptr);
ok(hr == E_NOINTERFACE && container_ptr == NULL, "GetContainer returned: hr %#x, container_ptr %p. "
"Expected hr %#x, container_ptr %p\n", hr, container_ptr, E_NOINTERFACE, NULL);
if (container_ptr && container_ptr != (void *)0x1337c0d3) IUnknown_Release((IUnknown *)container_ptr);
cleanup:
if (texture_ptr) IDirect3DTexture8_Release(texture_ptr);
if (surface_ptr) IDirect3DSurface8_Release(surface_ptr);
}
START_TEST(surface)
{
HMODULE d3d8_handle;
IDirect3DDevice8 *device_ptr;
d3d8_handle = LoadLibraryA("d3d8.dll");
if (!d3d8_handle)
{
skip("Could not load d3d8.dll\n");
return;
}
device_ptr = init_d3d8(d3d8_handle);
if (!device_ptr) return;
test_surface_get_container(device_ptr);
}

View File

@@ -0,0 +1,26 @@
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
#define STANDALONE
#include "wine/test.h"
extern void func_d3d8_main(void);
extern void func_device(void);
extern void func_surface(void);
extern void func_texture(void);
extern void func_visual(void);
extern void func_volume(void);
const struct test winetest_testlist[] =
{
{ "d3d8_main", func_d3d8_main },
{ "device", func_device },
{ "surface", func_surface },
{ "texture", func_texture },
{ "visual", func_visual },
{ "volume", func_volume },
{ 0, 0 }
};

View File

@@ -0,0 +1,150 @@
/*
* Copyright (C) 2006 Henri Verbeet
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#define COBJMACROS
#include <d3d8.h>
#include "wine/test.h"
static HWND create_window(void)
{
WNDCLASS wc = {0};
wc.lpfnWndProc = &DefWindowProc;
wc.lpszClassName = "d3d8_test_wc";
RegisterClass(&wc);
return CreateWindow("d3d8_test_wc", "d3d8_test",
0, 0, 0, 0, 0, 0, 0, 0, 0);
}
static IDirect3DDevice8 *init_d3d8(HMODULE d3d8_handle)
{
IDirect3D8 * (__stdcall * d3d8_create)(UINT SDKVersion) = 0;
IDirect3D8 *d3d8_ptr = 0;
IDirect3DDevice8 *device_ptr = 0;
D3DPRESENT_PARAMETERS present_parameters;
D3DDISPLAYMODE d3ddm;
HRESULT hr;
d3d8_create = (void *)GetProcAddress(d3d8_handle, "Direct3DCreate8");
ok(d3d8_create != NULL, "Failed to get address of Direct3DCreate8\n");
if (!d3d8_create) return NULL;
d3d8_ptr = d3d8_create(D3D_SDK_VERSION);
ok(d3d8_ptr != NULL, "Failed to create IDirect3D8 object\n");
if (!d3d8_ptr) return NULL;
IDirect3D8_GetAdapterDisplayMode(d3d8_ptr, D3DADAPTER_DEFAULT, &d3ddm );
ZeroMemory(&present_parameters, sizeof(present_parameters));
present_parameters.Windowed = TRUE;
present_parameters.hDeviceWindow = create_window();
present_parameters.SwapEffect = D3DSWAPEFFECT_DISCARD;
present_parameters.BackBufferFormat = d3ddm.Format;
hr = IDirect3D8_CreateDevice(d3d8_ptr, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL,
NULL, D3DCREATE_SOFTWARE_VERTEXPROCESSING, &present_parameters, &device_ptr);
if(FAILED(hr))
{
trace("could not create device, IDirect3D8_CreateDevice returned %#x\n", hr);
return NULL;
}
return device_ptr;
}
static void test_texture_stage_state(IDirect3DDevice8 *device_ptr, DWORD stage, D3DTEXTURESTAGESTATETYPE type, DWORD expected)
{
DWORD value;
HRESULT hr = IDirect3DDevice8_GetTextureStageState(device_ptr, stage, type, &value);
ok(SUCCEEDED(hr) && value == expected, "GetTextureStageState (stage %#x, type %#x) returned: hr %#x, value %#x. "
"Expected hr %#x, value %#x\n", stage, type, hr, value, D3D_OK, expected);
}
/* Test the default texture stage state values */
static void test_texture_stage_states(IDirect3DDevice8 *device_ptr, int num_stages)
{
int i;
for (i = 0; i < num_stages; ++i)
{
test_texture_stage_state(device_ptr, i, D3DTSS_COLOROP, i ? D3DTOP_DISABLE : D3DTOP_MODULATE);
test_texture_stage_state(device_ptr, i, D3DTSS_COLORARG1, D3DTA_TEXTURE);
test_texture_stage_state(device_ptr, i, D3DTSS_COLORARG2, D3DTA_CURRENT);
test_texture_stage_state(device_ptr, i, D3DTSS_ALPHAOP, i ? D3DTOP_DISABLE : D3DTOP_SELECTARG1);
test_texture_stage_state(device_ptr, i, D3DTSS_ALPHAARG1, D3DTA_TEXTURE);
test_texture_stage_state(device_ptr, i, D3DTSS_ALPHAARG2, D3DTA_CURRENT);
test_texture_stage_state(device_ptr, i, D3DTSS_BUMPENVMAT00, 0);
test_texture_stage_state(device_ptr, i, D3DTSS_BUMPENVMAT01, 0);
test_texture_stage_state(device_ptr, i, D3DTSS_BUMPENVMAT10, 0);
test_texture_stage_state(device_ptr, i, D3DTSS_BUMPENVMAT11, 0);
test_texture_stage_state(device_ptr, i, D3DTSS_TEXCOORDINDEX, i);
test_texture_stage_state(device_ptr, i, D3DTSS_BUMPENVLSCALE, 0);
test_texture_stage_state(device_ptr, i, D3DTSS_BUMPENVLOFFSET, 0);
test_texture_stage_state(device_ptr, i, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_DISABLE);
test_texture_stage_state(device_ptr, i, D3DTSS_COLORARG0, D3DTA_CURRENT);
test_texture_stage_state(device_ptr, i, D3DTSS_ALPHAARG0, D3DTA_CURRENT);
test_texture_stage_state(device_ptr, i, D3DTSS_RESULTARG, D3DTA_CURRENT);
}
}
static void test_cube_texture_from_pool(IDirect3DDevice8 *device_ptr, DWORD caps, D3DPOOL pool, BOOL need_cap)
{
IDirect3DCubeTexture8 *texture_ptr = NULL;
HRESULT hr;
hr = IDirect3DDevice8_CreateCubeTexture(device_ptr, 512, 1, 0, D3DFMT_X8R8G8B8, pool, &texture_ptr);
trace("pool=%d hr=0x%.8x\n", pool, hr);
if((caps & D3DPTEXTURECAPS_CUBEMAP) || !need_cap)
ok(SUCCEEDED(hr), "hr=0x%.8x\n", hr);
else
ok(hr == D3DERR_INVALIDCALL, "hr=0x%.8x\n", hr);
if(texture_ptr) IDirect3DCubeTexture8_Release(texture_ptr);
}
static void test_cube_textures(IDirect3DDevice8 *device_ptr, DWORD caps)
{
trace("texture caps: 0x%.8x\n", caps);
test_cube_texture_from_pool(device_ptr, caps, D3DPOOL_DEFAULT, TRUE);
test_cube_texture_from_pool(device_ptr, caps, D3DPOOL_MANAGED, TRUE);
test_cube_texture_from_pool(device_ptr, caps, D3DPOOL_SYSTEMMEM, TRUE);
test_cube_texture_from_pool(device_ptr, caps, D3DPOOL_SCRATCH, FALSE);
}
START_TEST(texture)
{
D3DCAPS8 caps;
HMODULE d3d8_handle;
IDirect3DDevice8 *device_ptr;
d3d8_handle = LoadLibraryA("d3d8.dll");
if (!d3d8_handle)
{
skip("Could not load d3d8.dll\n");
return;
}
device_ptr = init_d3d8(d3d8_handle);
if (!device_ptr) return;
IDirect3DDevice8_GetDeviceCaps(device_ptr, &caps);
test_texture_stage_states(device_ptr, caps.MaxTextureBlendStages);
test_cube_textures(device_ptr, caps.TextureCaps);
}

View File

@@ -0,0 +1,498 @@
/*
* Copyright (C) 2005 Henri Verbeet
* Copyright (C) 2007 Stefan D<>singer(for CodeWeavers)
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
/* See comment in dlls/d3d9/tests/visual.c for general guidelines */
#define COBJMACROS
#include <d3d8.h>
#include <dxerr8.h>
#include "wine/test.h"
static HMODULE d3d8_handle = 0;
static HWND create_window(void)
{
WNDCLASS wc = {0};
HWND ret;
wc.lpfnWndProc = &DefWindowProc;
wc.lpszClassName = "d3d8_test_wc";
RegisterClass(&wc);
ret = CreateWindow("d3d8_test_wc", "d3d8_test",
WS_MAXIMIZE | WS_VISIBLE | WS_CAPTION , 0, 0, 640, 480, 0, 0, 0, 0);
return ret;
}
static DWORD getPixelColor(IDirect3DDevice8 *device, UINT x, UINT y)
{
DWORD ret;
IDirect3DSurface8 *surf;
IDirect3DTexture8 *tex;
HRESULT hr;
D3DLOCKED_RECT lockedRect;
RECT rectToLock = {x, y, x+1, y+1};
hr = IDirect3DDevice8_CreateTexture(device, 640, 480, 1 /* Levels */, 0 /* usage */, D3DFMT_A8R8G8B8, D3DPOOL_SYSTEMMEM, &tex);
if(FAILED(hr) || !tex ) /* This is not a test */
{
trace("Can't create an offscreen plain surface to read the render target data, hr=%s\n", DXGetErrorString8(hr));
return 0xdeadbeef;
}
hr = IDirect3DTexture8_GetSurfaceLevel(tex, 0, &surf);
if(FAILED(hr) || !tex ) /* This is not a test */
{
trace("Can't get surface from texture, hr=%s\n", DXGetErrorString8(hr));
ret = 0xdeadbeee;
goto out;
}
hr = IDirect3DDevice8_GetFrontBuffer(device, surf);
if(FAILED(hr))
{
trace("Can't read the front buffer data, hr=%s\n", DXGetErrorString8(hr));
ret = 0xdeadbeed;
goto out;
}
hr = IDirect3DSurface8_LockRect(surf, &lockedRect, &rectToLock, D3DLOCK_READONLY);
if(FAILED(hr))
{
trace("Can't lock the offscreen surface, hr=%s\n", DXGetErrorString8(hr));
ret = 0xdeadbeec;
goto out;
}
/* Remove the X channel for now. DirectX and OpenGL have different ideas how to treat it apparently, and it isn't
* really important for these tests
*/
ret = ((DWORD *) lockedRect.pBits)[0] & 0x00ffffff;
hr = IDirect3DSurface8_UnlockRect(surf);
if(FAILED(hr))
{
trace("Can't unlock the offscreen surface, hr=%s\n", DXGetErrorString8(hr));
}
out:
if(surf) IDirect3DSurface8_Release(surf);
if(tex) IDirect3DTexture8_Release(tex);
return ret;
}
static IDirect3DDevice8 *init_d3d8(void)
{
IDirect3D8 * (__stdcall * d3d8_create)(UINT SDKVersion) = 0;
IDirect3D8 *d3d8_ptr = 0;
IDirect3DDevice8 *device_ptr = 0;
D3DPRESENT_PARAMETERS present_parameters;
HRESULT hr;
d3d8_create = (void *)GetProcAddress(d3d8_handle, "Direct3DCreate8");
ok(d3d8_create != NULL, "Failed to get address of Direct3DCreate8\n");
if (!d3d8_create) return NULL;
d3d8_ptr = d3d8_create(D3D_SDK_VERSION);
ok(d3d8_ptr != NULL, "Failed to create IDirect3D8 object\n");
if (!d3d8_ptr) return NULL;
ZeroMemory(&present_parameters, sizeof(present_parameters));
present_parameters.Windowed = FALSE;
present_parameters.hDeviceWindow = create_window();
present_parameters.SwapEffect = D3DSWAPEFFECT_DISCARD;
present_parameters.BackBufferWidth = 640;
present_parameters.BackBufferHeight = 480;
present_parameters.BackBufferFormat = D3DFMT_X8R8G8B8;
hr = IDirect3D8_CreateDevice(d3d8_ptr, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, present_parameters.hDeviceWindow, D3DCREATE_SOFTWARE_VERTEXPROCESSING, &present_parameters, &device_ptr);
ok(hr == D3D_OK, "IDirect3D_CreateDevice returned: %s\n", DXGetErrorString8(hr));
return device_ptr;
}
struct vertex
{
float x, y, z;
DWORD diffuse;
};
struct nvertex
{
float x, y, z;
float nx, ny, nz;
DWORD diffuse;
};
static void lighting_test(IDirect3DDevice8 *device)
{
HRESULT hr;
DWORD fvf = D3DFVF_XYZ | D3DFVF_DIFFUSE;
DWORD nfvf = D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_NORMAL;
DWORD color;
float mat[16] = { 1.0, 0.0, 0.0, 0.0,
0.0, 1.0, 0.0, 0.0,
0.0, 0.0, 1.0, 0.0,
0.0, 0.0, 0.0, 1.0 };
struct vertex unlitquad[] =
{
{-1.0, -1.0, 0.1, 0xffff0000},
{-1.0, 0.0, 0.1, 0xffff0000},
{ 0.0, 0.0, 0.1, 0xffff0000},
{ 0.0, -1.0, 0.1, 0xffff0000},
};
struct vertex litquad[] =
{
{-1.0, 0.0, 0.1, 0xff00ff00},
{-1.0, 1.0, 0.1, 0xff00ff00},
{ 0.0, 1.0, 0.1, 0xff00ff00},
{ 0.0, 0.0, 0.1, 0xff00ff00},
};
struct nvertex unlitnquad[] =
{
{ 0.0, -1.0, 0.1, 1.0, 1.0, 1.0, 0xff0000ff},
{ 0.0, 0.0, 0.1, 1.0, 1.0, 1.0, 0xff0000ff},
{ 1.0, 0.0, 0.1, 1.0, 1.0, 1.0, 0xff0000ff},
{ 1.0, -1.0, 0.1, 1.0, 1.0, 1.0, 0xff0000ff},
};
struct nvertex litnquad[] =
{
{ 0.0, 0.0, 0.1, 1.0, 1.0, 1.0, 0xffffff00},
{ 0.0, 1.0, 0.1, 1.0, 1.0, 1.0, 0xffffff00},
{ 1.0, 1.0, 0.1, 1.0, 1.0, 1.0, 0xffffff00},
{ 1.0, 0.0, 0.1, 1.0, 1.0, 1.0, 0xffffff00},
};
WORD Indices[] = {0, 1, 2, 2, 3, 0};
hr = IDirect3DDevice8_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xffffffff, 0.0, 0);
ok(hr == D3D_OK, "IDirect3DDevice8_Clear failed with %s\n", DXGetErrorString8(hr));
/* Setup some states that may cause issues */
hr = IDirect3DDevice8_SetTransform(device, D3DTS_WORLDMATRIX(0), (D3DMATRIX *) mat);
ok(hr == D3D_OK, "IDirect3DDevice8_SetTransform returned %s\n", DXGetErrorString8(hr));
hr = IDirect3DDevice8_SetTransform(device, D3DTS_VIEW, (D3DMATRIX *)mat);
ok(hr == D3D_OK, "IDirect3DDevice8_SetTransform returned %s\n", DXGetErrorString8(hr));
hr = IDirect3DDevice8_SetTransform(device, D3DTS_PROJECTION, (D3DMATRIX *) mat);
ok(hr == D3D_OK, "IDirect3DDevice8_SetTransform returned %s\n", DXGetErrorString8(hr));
hr = IDirect3DDevice8_SetRenderState(device, D3DRS_CLIPPING, FALSE);
ok(hr == D3D_OK, "IDirect3DDevice8_SetRenderState returned %s\n", DXGetErrorString8(hr));
hr = IDirect3DDevice8_SetRenderState(device, D3DRS_ZENABLE, FALSE);
ok(hr == D3D_OK, "IDirect3DDevice8_SetRenderState returned %s\n", DXGetErrorString8(hr));
hr = IDirect3DDevice8_SetRenderState(device, D3DRS_FOGENABLE, FALSE);
ok(hr == D3D_OK, "IDirect3DDevice8_SetRenderState returned %s\n", DXGetErrorString8(hr));
hr = IDirect3DDevice8_SetRenderState(device, D3DRS_STENCILENABLE, FALSE);
ok(hr == D3D_OK, "IDirect3DDevice8_SetRenderState returned %s\n", DXGetErrorString8(hr));
hr = IDirect3DDevice8_SetRenderState(device, D3DRS_ALPHATESTENABLE, FALSE);
ok(hr == D3D_OK, "IDirect3DDevice8_SetRenderState returned %s\n", DXGetErrorString8(hr));
hr = IDirect3DDevice8_SetRenderState(device, D3DRS_ALPHABLENDENABLE, FALSE);
ok(hr == D3D_OK, "IDirect3DDevice8_SetRenderState returned %s\n", DXGetErrorString8(hr));
hr = IDirect3DDevice8_SetRenderState(device, D3DRS_CULLMODE, D3DCULL_NONE);
ok(hr == D3D_OK, "IDirect3DDevice8_SetRenderState failed with %s\n", DXGetErrorString8(hr));
hr = IDirect3DDevice8_SetRenderState(device, D3DRS_COLORWRITEENABLE, D3DCOLORWRITEENABLE_RED | D3DCOLORWRITEENABLE_GREEN | D3DCOLORWRITEENABLE_BLUE);
ok(hr == D3D_OK, "IDirect3DDevice8_SetRenderState failed with %s\n", DXGetErrorString8(hr));
hr = IDirect3DDevice8_SetVertexShader(device, fvf);
ok(hr == D3D_OK, "IDirect3DDevice8_SetVertexShader returned %s\n", DXGetErrorString8(hr));
hr = IDirect3DDevice8_BeginScene(device);
ok(hr == D3D_OK, "IDirect3DDevice8_BeginScene failed with %s\n", DXGetErrorString8(hr));
if(hr == D3D_OK)
{
/* No lights are defined... That means, lit vertices should be entirely black */
hr = IDirect3DDevice8_SetRenderState(device, D3DRS_LIGHTING, FALSE);
ok(hr == D3D_OK, "IDirect3DDevice8_SetRenderState returned %s\n", DXGetErrorString8(hr));
hr = IDirect3DDevice8_DrawIndexedPrimitiveUP(device, D3DPT_TRIANGLELIST, 0 /* MinIndex */, 4 /* NumVerts */,
2 /*PrimCount */, Indices, D3DFMT_INDEX16, unlitquad, sizeof(unlitquad[0]));
ok(hr == D3D_OK, "IDirect3DDevice8_DrawIndexedPrimitiveUP failed with %s\n", DXGetErrorString8(hr));
hr = IDirect3DDevice8_SetRenderState(device, D3DRS_LIGHTING, TRUE);
ok(hr == D3D_OK, "IDirect3DDevice8_SetRenderState returned %s\n", DXGetErrorString8(hr));
hr = IDirect3DDevice8_DrawIndexedPrimitiveUP(device, D3DPT_TRIANGLELIST, 0 /* MinIndex */, 4 /* NumVerts */,
2 /*PrimCount */, Indices, D3DFMT_INDEX16, litquad, sizeof(litquad[0]));
ok(hr == D3D_OK, "IDirect3DDevice8_DrawIndexedPrimitiveUP failed with %s\n", DXGetErrorString8(hr));
hr = IDirect3DDevice8_SetVertexShader(device, nfvf);
ok(hr == D3D_OK, "IDirect3DDevice8_SetVertexShader failed with %s\n", DXGetErrorString8(hr));
hr = IDirect3DDevice8_SetRenderState(device, D3DRS_LIGHTING, FALSE);
ok(hr == D3D_OK, "IDirect3DDevice8_SetRenderState returned %s\n", DXGetErrorString8(hr));
hr = IDirect3DDevice8_DrawIndexedPrimitiveUP(device, D3DPT_TRIANGLELIST, 0 /* MinIndex */, 4 /* NumVerts */,
2 /*PrimCount */, Indices, D3DFMT_INDEX16, unlitnquad, sizeof(unlitnquad[0]));
ok(hr == D3D_OK, "IDirect3DDevice8_DrawIndexedPrimitiveUP failed with %s\n", DXGetErrorString8(hr));
hr = IDirect3DDevice8_SetRenderState(device, D3DRS_LIGHTING, TRUE);
ok(hr == D3D_OK, "IDirect3DDevice8_SetRenderState returned %s\n", DXGetErrorString8(hr));
hr = IDirect3DDevice8_DrawIndexedPrimitiveUP(device, D3DPT_TRIANGLELIST, 0 /* MinIndex */, 4 /* NumVerts */,
2 /*PrimCount */, Indices, D3DFMT_INDEX16, litnquad, sizeof(litnquad[0]));
ok(hr == D3D_OK, "IDirect3DDevice8_DrawIndexedPrimitiveUP failed with %s\n", DXGetErrorString8(hr));
IDirect3DDevice8_EndScene(device);
ok(hr == D3D_OK, "IDirect3DDevice8_EndScene failed with %s\n", DXGetErrorString8(hr));
}
IDirect3DDevice8_Present(device, NULL, NULL, NULL, NULL);
color = getPixelColor(device, 160, 360); /* lower left quad - unlit without normals */
ok(color == 0x00ff0000, "Unlit quad without normals has color %08x\n", color);
color = getPixelColor(device, 160, 120); /* upper left quad - lit without normals */
ok(color == 0x00000000, "Lit quad without normals has color %08x\n", color);
color = getPixelColor(device, 480, 360); /* lower left quad - unlit width normals */
ok(color == 0x000000ff, "Unlit quad width normals has color %08x\n", color);
color = getPixelColor(device, 480, 120); /* upper left quad - lit width normals */
ok(color == 0x00000000, "Lit quad width normals has color %08x\n", color);
hr = IDirect3DDevice8_SetRenderState(device, D3DRS_LIGHTING, FALSE);
ok(hr == D3D_OK, "IDirect3DDevice8_SetRenderState returned %s\n", DXGetErrorString8(hr));
}
static void clear_test(IDirect3DDevice8 *device)
{
/* Tests the correctness of clearing parameters */
HRESULT hr;
D3DRECT rect[2];
D3DRECT rect_negneg;
DWORD color;
hr = IDirect3DDevice8_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xffffffff, 0.0, 0);
ok(hr == D3D_OK, "IDirect3DDevice8_Clear failed with %s\n", DXGetErrorString8(hr));
/* Positive x, negative y */
rect[0].x1 = 0;
rect[0].y1 = 480;
rect[0].x2 = 320;
rect[0].y2 = 240;
/* Positive x, positive y */
rect[1].x1 = 0;
rect[1].y1 = 0;
rect[1].x2 = 320;
rect[1].y2 = 240;
/* Clear 2 rectangles with one call. Shows that a positive value is returned, but the negative rectangle
* is ignored, the positive is still cleared afterwards
*/
hr = IDirect3DDevice8_Clear(device, 2, rect, D3DCLEAR_TARGET, 0xffff0000, 0.0, 0);
ok(hr == D3D_OK, "IDirect3DDevice8_Clear failed with %s\n", DXGetErrorString8(hr));
/* negative x, negative y */
rect_negneg.x1 = 640;
rect_negneg.x1 = 240;
rect_negneg.x2 = 320;
rect_negneg.y2 = 0;
hr = IDirect3DDevice8_Clear(device, 1, &rect_negneg, D3DCLEAR_TARGET, 0xff00ff00, 0.0, 0);
ok(hr == D3D_OK, "IDirect3DDevice8_Clear failed with %s\n", DXGetErrorString8(hr));
IDirect3DDevice8_Present(device, NULL, NULL, NULL, NULL);
color = getPixelColor(device, 160, 360); /* lower left quad */
ok(color == 0x00ffffff, "Clear rectangle 3(pos, neg) has color %08x\n", color);
color = getPixelColor(device, 160, 120); /* upper left quad */
ok(color == 0x00ff0000, "Clear rectangle 1(pos, pos) has color %08x\n", color);
color = getPixelColor(device, 480, 360); /* lower right quad */
ok(color == 0x00ffffff, "Clear rectangle 4(NULL) has color %08x\n", color);
color = getPixelColor(device, 480, 120); /* upper right quad */
ok(color == 0x00ffffff, "Clear rectangle 4(neg, neg) has color %08x\n", color);
}
struct sVertex {
float x, y, z;
DWORD diffuse;
DWORD specular;
};
struct sVertexT {
float x, y, z, rhw;
DWORD diffuse;
DWORD specular;
};
static void fog_test(IDirect3DDevice8 *device)
{
HRESULT hr;
DWORD color;
float start = 0.0, end = 1.0;
/* Gets full z based fog with linear fog, no fog with specular color */
struct sVertex unstransformed_1[] = {
{-1, -1, 0.1, 0xFFFF0000, 0xFF000000 },
{-1, 0, 0.1, 0xFFFF0000, 0xFF000000 },
{ 0, 0, 0.1, 0xFFFF0000, 0xFF000000 },
{ 0, -1, 0.1, 0xFFFF0000, 0xFF000000 },
};
/* Ok, I am too lazy to deal with transform matrices */
struct sVertex unstransformed_2[] = {
{-1, 0, 1.0, 0xFFFF0000, 0xFF000000 },
{-1, 1, 1.0, 0xFFFF0000, 0xFF000000 },
{ 0, 1, 1.0, 0xFFFF0000, 0xFF000000 },
{ 0, 0, 1.0, 0xFFFF0000, 0xFF000000 },
};
/* Untransformed ones. Give them a different diffuse color to make the test look
* nicer. It also makes making sure that they are drawn correctly easier.
*/
struct sVertexT transformed_1[] = {
{320, 0, 1.0, 1.0, 0xFFFFFF00, 0xFF000000 },
{640, 0, 1.0, 1.0, 0xFFFFFF00, 0xFF000000 },
{640, 240, 1.0, 1.0, 0xFFFFFF00, 0xFF000000 },
{320, 240, 1.0, 1.0, 0xFFFFFF00, 0xFF000000 },
};
struct sVertexT transformed_2[] = {
{320, 240, 1.0, 1.0, 0xFFFFFF00, 0xFF000000 },
{640, 240, 1.0, 1.0, 0xFFFFFF00, 0xFF000000 },
{640, 480, 1.0, 1.0, 0xFFFFFF00, 0xFF000000 },
{320, 480, 1.0, 1.0, 0xFFFFFF00, 0xFF000000 },
};
WORD Indices[] = {0, 1, 2, 2, 3, 0};
hr = IDirect3DDevice8_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xffff00ff, 0.0, 0);
ok(hr == D3D_OK, "IDirect3DDevice8_Clear returned %s\n", DXGetErrorString8(hr));
/* Setup initial states: No lighting, fog on, fog color */
hr = IDirect3DDevice8_SetRenderState(device, D3DRS_LIGHTING, FALSE);
ok(hr == D3D_OK, "Turning off lighting returned %s\n", DXGetErrorString8(hr));
hr = IDirect3DDevice8_SetRenderState(device, D3DRS_FOGENABLE, TRUE);
ok(hr == D3D_OK, "Turning on fog calculations returned %s\n", DXGetErrorString8(hr));
hr = IDirect3DDevice8_SetRenderState(device, D3DRS_FOGCOLOR, 0xFF00FF00 /* A nice green */);
ok(hr == D3D_OK, "Turning on fog calculations returned %s\n", DXGetErrorString8(hr));
/* First test: Both table fog and vertex fog off */
hr = IDirect3DDevice8_SetRenderState(device, D3DRS_FOGTABLEMODE, D3DFOG_NONE);
ok(hr == D3D_OK, "Turning off table fog returned %s\n", DXGetErrorString8(hr));
hr = IDirect3DDevice8_SetRenderState(device, D3DRS_FOGVERTEXMODE, D3DFOG_NONE);
ok(hr == D3D_OK, "Turning off table fog returned %s\n", DXGetErrorString8(hr));
/* Start = 0, end = 1. Should be default, but set them */
hr = IDirect3DDevice8_SetRenderState(device, D3DRS_FOGSTART, *((DWORD *) &start));
ok(hr == D3D_OK, "Setting fog start returned %s\n", DXGetErrorString8(hr));
hr = IDirect3DDevice8_SetRenderState(device, D3DRS_FOGEND, *((DWORD *) &end));
ok(hr == D3D_OK, "Setting fog start returned %s\n", DXGetErrorString8(hr));
if(IDirect3DDevice8_BeginScene(device) == D3D_OK)
{
hr = IDirect3DDevice8_SetVertexShader(device, D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_SPECULAR);
ok( hr == D3D_OK, "SetVertexShader returned %s\n", DXGetErrorString8(hr));
/* Untransformed, vertex fog = NONE, table fog = NONE: Read the fog weighting from the specular color */
hr = IDirect3DDevice8_DrawIndexedPrimitiveUP(device, D3DPT_TRIANGLELIST, 0 /* MinIndex */, 4 /* NumVerts */,
2 /*PrimCount */, Indices, D3DFMT_INDEX16, unstransformed_1,
sizeof(unstransformed_1[0]));
ok(hr == D3D_OK, "DrawIndexedPrimitiveUP returned %s\n", DXGetErrorString8(hr));
/* That makes it use the Z value */
hr = IDirect3DDevice8_SetRenderState(device, D3DRS_FOGVERTEXMODE, D3DFOG_LINEAR);
ok(hr == D3D_OK, "Turning off table fog returned %s\n", DXGetErrorString8(hr));
/* Untransformed, vertex fog != none (or table fog != none):
* Use the Z value as input into the equation
*/
hr = IDirect3DDevice8_DrawIndexedPrimitiveUP(device, D3DPT_TRIANGLELIST, 0 /* MinIndex */, 4 /* NumVerts */,
2 /*PrimCount */, Indices, D3DFMT_INDEX16, unstransformed_2,
sizeof(unstransformed_1[0]));
ok(hr == D3D_OK, "DrawIndexedPrimitiveUP returned %s\n", DXGetErrorString8(hr));
/* transformed verts */
hr = IDirect3DDevice8_SetVertexShader(device, D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR);
ok( hr == D3D_OK, "SetVertexShader returned %s\n", DXGetErrorString8(hr));
/* Transformed, vertex fog != NONE, pixel fog == NONE: Use specular color alpha component */
hr = IDirect3DDevice8_DrawIndexedPrimitiveUP(device, D3DPT_TRIANGLELIST, 0 /* MinIndex */, 4 /* NumVerts */,
2 /*PrimCount */, Indices, D3DFMT_INDEX16, transformed_1,
sizeof(transformed_1[0]));
ok(hr == D3D_OK, "DrawIndexedPrimitiveUP returned %s\n", DXGetErrorString8(hr));
hr = IDirect3DDevice8_SetRenderState(device, D3DRS_FOGTABLEMODE, D3DFOG_LINEAR);
ok( hr == D3D_OK, "Setting fog table mode to D3DFOG_LINEAR returned %s\n", DXGetErrorString8(hr));
/* Transformed, table fog != none, vertex anything: Use Z value as input to the fog
* equation
*/
hr = IDirect3DDevice8_DrawIndexedPrimitiveUP(device, D3DPT_TRIANGLELIST, 0 /* MinIndex */, 4 /* NumVerts */,
2 /*PrimCount */, Indices, D3DFMT_INDEX16, transformed_2,
sizeof(transformed_2[0]));
hr = IDirect3DDevice8_EndScene(device);
ok(hr == D3D_OK, "EndScene returned %s\n", DXGetErrorString8(hr));
}
else
{
ok(FALSE, "BeginScene failed\n");
}
IDirect3DDevice8_Present(device, NULL, NULL, NULL, NULL);
color = getPixelColor(device, 160, 360);
ok(color == 0x00FF0000, "Untransformed vertex with no table or vertex fog has color %08x\n", color);
color = getPixelColor(device, 160, 120);
ok(color == 0x0000FF00, "Untransformed vertex with linear vertex fog has color %08x\n", color);
color = getPixelColor(device, 480, 120);
ok(color == 0x00FFFF00, "Transformed vertex with linear vertex fog has color %08x\n", color);
color = getPixelColor(device, 480, 360);
ok(color == 0x0000FF00, "Transformed vertex with linear table fog has color %08x\n", color);
/* Turn off the fog master switch to avoid confusing other tests */
hr = IDirect3DDevice8_SetRenderState(device, D3DRS_FOGENABLE, FALSE);
ok(hr == D3D_OK, "Turning off fog calculations returned %s\n", DXGetErrorString8(hr));
}
START_TEST(visual)
{
IDirect3DDevice8 *device_ptr;
HRESULT hr;
DWORD color;
d3d8_handle = LoadLibraryA("d3d8.dll");
if (!d3d8_handle)
{
skip("Could not load d3d8.dll\n");
return;
}
device_ptr = init_d3d8();
if (!device_ptr) return;
/* Check for the reliability of the returned data */
hr = IDirect3DDevice8_Clear(device_ptr, 0, NULL, D3DCLEAR_TARGET, 0xffff0000, 0.0, 0);
if(FAILED(hr))
{
trace("Clear failed, can't assure correctness of the test results, skipping\n");
goto cleanup;
}
IDirect3DDevice8_Present(device_ptr, NULL, NULL, NULL, NULL);
color = getPixelColor(device_ptr, 1, 1);
if(color !=0x00ff0000)
{
trace("Sanity check returned an incorrect color(%08x), can't assure the correctness of the tests, skipping\n", color);
goto cleanup;
}
hr = IDirect3DDevice8_Clear(device_ptr, 0, NULL, D3DCLEAR_TARGET, 0xff00ddee, 0.0, 0);
if(FAILED(hr))
{
trace("Clear failed, can't assure correctness of the test results, skipping\n");
goto cleanup;
}
IDirect3DDevice8_Present(device_ptr, NULL, NULL, NULL, NULL);
color = getPixelColor(device_ptr, 639, 479);
if(color != 0x0000ddee)
{
trace("Sanity check returned an incorrect color(%08x), can't assure the correctness of the tests, skipping\n", color);
goto cleanup;
}
/* Now run the real test */
lighting_test(device_ptr);
clear_test(device_ptr);
fog_test(device_ptr);
cleanup:
if(device_ptr) IDirect3DDevice8_Release(device_ptr);
}

View File

@@ -0,0 +1,140 @@
/*
* Copyright (C) 2006 Henri Verbeet
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#define COBJMACROS
#include <d3d8.h>
#include "wine/test.h"
static HWND create_window(void)
{
WNDCLASS wc = {0};
wc.lpfnWndProc = &DefWindowProc;
wc.lpszClassName = "d3d8_test_wc";
RegisterClass(&wc);
return CreateWindow("d3d8_test_wc", "d3d8_test",
0, 0, 0, 0, 0, 0, 0, 0, 0);
}
static IDirect3DDevice8 *init_d3d8(HMODULE d3d8_handle)
{
IDirect3D8 * (__stdcall * d3d8_create)(UINT SDKVersion) = 0;
IDirect3D8 *d3d8_ptr = 0;
IDirect3DDevice8 *device_ptr = 0;
D3DPRESENT_PARAMETERS present_parameters;
D3DDISPLAYMODE d3ddm;
HRESULT hr;
d3d8_create = (void *)GetProcAddress(d3d8_handle, "Direct3DCreate8");
ok(d3d8_create != NULL, "Failed to get address of Direct3DCreate8\n");
if (!d3d8_create) return NULL;
d3d8_ptr = d3d8_create(D3D_SDK_VERSION);
ok(d3d8_ptr != NULL, "Failed to create IDirect3D8 object\n");
if (!d3d8_ptr) return NULL;
IDirect3D8_GetAdapterDisplayMode(d3d8_ptr, D3DADAPTER_DEFAULT, &d3ddm );
ZeroMemory(&present_parameters, sizeof(present_parameters));
present_parameters.Windowed = TRUE;
present_parameters.hDeviceWindow = create_window();
present_parameters.SwapEffect = D3DSWAPEFFECT_DISCARD;
present_parameters.BackBufferFormat = d3ddm.Format;
hr = IDirect3D8_CreateDevice(d3d8_ptr, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL,
NULL, D3DCREATE_SOFTWARE_VERTEXPROCESSING, &present_parameters, &device_ptr);
if(FAILED(hr))
{
trace("could not create device, IDirect3D8_CreateDevice returned %#x\n", hr);
return NULL;
}
return device_ptr;
}
static void test_volume_get_container(IDirect3DDevice8 *device_ptr)
{
IDirect3DVolumeTexture8 *texture_ptr = 0;
IDirect3DVolume8 *volume_ptr = 0;
void *container_ptr;
HRESULT hr;
hr = IDirect3DDevice8_CreateVolumeTexture(device_ptr, 128, 128, 128, 1, 0,
D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &texture_ptr);
ok(SUCCEEDED(hr) && texture_ptr != NULL, "CreateVolumeTexture returned: hr %#x, texture_ptr %p. "
"Expected hr %#x, texture_ptr != %p\n", hr, texture_ptr, D3D_OK, NULL);
if (!texture_ptr || FAILED(hr)) goto cleanup;
hr = IDirect3DVolumeTexture8_GetVolumeLevel(texture_ptr, 0, &volume_ptr);
ok(SUCCEEDED(hr) && volume_ptr != NULL, "GetVolumeLevel returned: hr %#x, volume_ptr %p. "
"Expected hr %#x, volume_ptr != %p\n", hr, volume_ptr, D3D_OK, NULL);
if (!volume_ptr || FAILED(hr)) goto cleanup;
/* These should work... */
container_ptr = (void *)0x1337c0d3;
hr = IDirect3DVolume8_GetContainer(volume_ptr, &IID_IUnknown, &container_ptr);
ok(SUCCEEDED(hr) && container_ptr == texture_ptr, "GetContainer returned: hr %#x, container_ptr %p. "
"Expected hr %#x, container_ptr %p\n", hr, container_ptr, S_OK, texture_ptr);
if (container_ptr && container_ptr != (void *)0x1337c0d3) IUnknown_Release((IUnknown *)container_ptr);
container_ptr = (void *)0x1337c0d3;
hr = IDirect3DVolume8_GetContainer(volume_ptr, &IID_IDirect3DResource8, &container_ptr);
ok(SUCCEEDED(hr) && container_ptr == texture_ptr, "GetContainer returned: hr %#x, container_ptr %p. "
"Expected hr %#x, container_ptr %p\n", hr, container_ptr, S_OK, texture_ptr);
if (container_ptr && container_ptr != (void *)0x1337c0d3) IUnknown_Release((IUnknown *)container_ptr);
container_ptr = (void *)0x1337c0d3;
hr = IDirect3DVolume8_GetContainer(volume_ptr, &IID_IDirect3DBaseTexture8, &container_ptr);
ok(SUCCEEDED(hr) && container_ptr == texture_ptr, "GetContainer returned: hr %#x, container_ptr %p. "
"Expected hr %#x, container_ptr %p\n", hr, container_ptr, S_OK, texture_ptr);
if (container_ptr && container_ptr != (void *)0x1337c0d3) IUnknown_Release((IUnknown *)container_ptr);
container_ptr = (void *)0x1337c0d3;
hr = IDirect3DVolume8_GetContainer(volume_ptr, &IID_IDirect3DVolumeTexture8, &container_ptr);
ok(SUCCEEDED(hr) && container_ptr == texture_ptr, "GetContainer returned: hr %#x, container_ptr %p. "
"Expected hr %#x, container_ptr %p\n", hr, container_ptr, S_OK, texture_ptr);
if (container_ptr && container_ptr != (void *)0x1337c0d3) IUnknown_Release((IUnknown *)container_ptr);
/* ...and this one shouldn't. This should return E_NOINTERFACE and set container_ptr to NULL */
container_ptr = (void *)0x1337c0d3;
hr = IDirect3DVolume8_GetContainer(volume_ptr, &IID_IDirect3DVolume8, &container_ptr);
ok(hr == E_NOINTERFACE && container_ptr == NULL, "GetContainer returned: hr %#x, container_ptr %p. "
"Expected hr %#x, container_ptr %p\n", hr, container_ptr, E_NOINTERFACE, NULL);
if (container_ptr && container_ptr != (void *)0x1337c0d3) IUnknown_Release((IUnknown *)container_ptr);
cleanup:
if (texture_ptr) IDirect3DVolumeTexture8_Release(texture_ptr);
if (volume_ptr) IDirect3DVolume8_Release(volume_ptr);
}
START_TEST(volume)
{
HMODULE d3d8_handle;
IDirect3DDevice8 *device_ptr;
d3d8_handle = LoadLibraryA("d3d8.dll");
if (!d3d8_handle)
{
skip("Could not load d3d8.dll\n");
return;
}
device_ptr = init_d3d8(d3d8_handle);
if (!device_ptr) return;
test_volume_get_container(device_ptr);
}

View File

@@ -0,0 +1,213 @@
/*
* IDirect3DTexture8 implementation
*
* Copyright 2005 Oliver Stieber
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "config.h"
#include "d3d8_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(d3d8);
/* IDirect3DTexture8 IUnknown parts follow: */
static HRESULT WINAPI IDirect3DTexture8Impl_QueryInterface(LPDIRECT3DTEXTURE8 iface, REFIID riid, LPVOID *ppobj) {
IDirect3DTexture8Impl *This = (IDirect3DTexture8Impl *)iface;
if (IsEqualGUID(riid, &IID_IUnknown)
|| IsEqualGUID(riid, &IID_IDirect3DResource8)
|| IsEqualGUID(riid, &IID_IDirect3DBaseTexture8)
|| IsEqualGUID(riid, &IID_IDirect3DTexture8)) {
IUnknown_AddRef(iface);
*ppobj = This;
return S_OK;
}
WARN("(%p)->(%s,%p) not found\n", This, debugstr_guid(riid), ppobj);
*ppobj = NULL;
return E_NOINTERFACE;
}
static ULONG WINAPI IDirect3DTexture8Impl_AddRef(LPDIRECT3DTEXTURE8 iface) {
IDirect3DTexture8Impl *This = (IDirect3DTexture8Impl *)iface;
ULONG ref = InterlockedIncrement(&This->ref);
TRACE("(%p) : AddRef from %d\n", This, ref - 1);
return ref;
}
static ULONG WINAPI IDirect3DTexture8Impl_Release(LPDIRECT3DTEXTURE8 iface) {
IDirect3DTexture8Impl *This = (IDirect3DTexture8Impl *)iface;
ULONG ref = InterlockedDecrement(&This->ref);
TRACE("(%p) : ReleaseRef to %d\n", This, ref);
if (ref == 0) {
IWineD3DTexture_Destroy(This->wineD3DTexture, D3D8CB_DestroySurface);
IUnknown_Release(This->parentDevice);
HeapFree(GetProcessHeap(), 0, This);
}
return ref;
}
/* IDirect3DTexture8 IDirect3DResource8 Interface follow: */
static HRESULT WINAPI IDirect3DTexture8Impl_GetDevice(LPDIRECT3DTEXTURE8 iface, IDirect3DDevice8 **ppDevice) {
IDirect3DTexture8Impl *This = (IDirect3DTexture8Impl *)iface;
TRACE("(%p) Relay\n", This);
return IDirect3DResource8Impl_GetDevice((LPDIRECT3DRESOURCE8) This, ppDevice);
}
static HRESULT WINAPI IDirect3DTexture8Impl_SetPrivateData(LPDIRECT3DTEXTURE8 iface, REFGUID refguid, CONST void *pData, DWORD SizeOfData, DWORD Flags) {
IDirect3DTexture8Impl *This = (IDirect3DTexture8Impl *)iface;
TRACE("(%p) Relay\n", This);
return IWineD3DTexture_SetPrivateData(This->wineD3DTexture, refguid, pData, SizeOfData, Flags);
}
static HRESULT WINAPI IDirect3DTexture8Impl_GetPrivateData(LPDIRECT3DTEXTURE8 iface, REFGUID refguid, void *pData, DWORD* pSizeOfData) {
IDirect3DTexture8Impl *This = (IDirect3DTexture8Impl *)iface;
TRACE("(%p) Relay\n", This);
return IWineD3DTexture_GetPrivateData(This->wineD3DTexture, refguid, pData, pSizeOfData);
}
static HRESULT WINAPI IDirect3DTexture8Impl_FreePrivateData(LPDIRECT3DTEXTURE8 iface, REFGUID refguid) {
IDirect3DTexture8Impl *This = (IDirect3DTexture8Impl *)iface;
TRACE("(%p) Relay\n", This);
return IWineD3DTexture_FreePrivateData(This->wineD3DTexture, refguid);
}
static DWORD WINAPI IDirect3DTexture8Impl_SetPriority(LPDIRECT3DTEXTURE8 iface, DWORD PriorityNew) {
IDirect3DTexture8Impl *This = (IDirect3DTexture8Impl *)iface;
TRACE("(%p) Relay\n", This);
return IWineD3DTexture_SetPriority(This->wineD3DTexture, PriorityNew);
}
static DWORD WINAPI IDirect3DTexture8Impl_GetPriority(LPDIRECT3DTEXTURE8 iface) {
IDirect3DTexture8Impl *This = (IDirect3DTexture8Impl *)iface;
TRACE("(%p) Relay\n", This);
return IWineD3DTexture_GetPriority(This->wineD3DTexture);
}
static void WINAPI IDirect3DTexture8Impl_PreLoad(LPDIRECT3DTEXTURE8 iface) {
IDirect3DTexture8Impl *This = (IDirect3DTexture8Impl *)iface;
TRACE("(%p) Relay\n", This);
IWineD3DTexture_PreLoad(This->wineD3DTexture);
}
static D3DRESOURCETYPE WINAPI IDirect3DTexture8Impl_GetType(LPDIRECT3DTEXTURE8 iface) {
IDirect3DTexture8Impl *This = (IDirect3DTexture8Impl *)iface;
TRACE("(%p) Relay\n", This);
return IWineD3DTexture_GetType(This->wineD3DTexture);
}
/* IDirect3DTexture8 IDirect3DBaseTexture8 Interface follow: */
static DWORD WINAPI IDirect3DTexture8Impl_SetLOD(LPDIRECT3DTEXTURE8 iface, DWORD LODNew) {
IDirect3DTexture8Impl *This = (IDirect3DTexture8Impl *)iface;
TRACE("(%p) Relay\n", This);
return IWineD3DTexture_SetLOD(This->wineD3DTexture, LODNew);
}
static DWORD WINAPI IDirect3DTexture8Impl_GetLOD(LPDIRECT3DTEXTURE8 iface) {
IDirect3DTexture8Impl *This = (IDirect3DTexture8Impl *)iface;
TRACE("(%p) Relay\n", This);
return IWineD3DTexture_GetLOD(This->wineD3DTexture);
}
static DWORD WINAPI IDirect3DTexture8Impl_GetLevelCount(LPDIRECT3DTEXTURE8 iface) {
IDirect3DTexture8Impl *This = (IDirect3DTexture8Impl *)iface;
TRACE("(%p) Relay\n", This);
return IWineD3DTexture_GetLevelCount(This->wineD3DTexture);
}
/* IDirect3DTexture8 Interface follow: */
static HRESULT WINAPI IDirect3DTexture8Impl_GetLevelDesc(LPDIRECT3DTEXTURE8 iface, UINT Level, D3DSURFACE_DESC *pDesc) {
IDirect3DTexture8Impl *This = (IDirect3DTexture8Impl *)iface;
WINED3DSURFACE_DESC wined3ddesc;
TRACE("(%p) Relay\n", This);
/* As d3d8 and d3d9 structures differ, pass in ptrs to where data needs to go */
memset(&wined3ddesc, 0, sizeof(wined3ddesc));
wined3ddesc.Format = (WINED3DFORMAT *)&pDesc->Format;
wined3ddesc.Type = (WINED3DRESOURCETYPE *)&pDesc->Type;
wined3ddesc.Usage = &pDesc->Usage;
wined3ddesc.Pool = (WINED3DPOOL *) &pDesc->Pool;
wined3ddesc.Size = &pDesc->Size;
wined3ddesc.MultiSampleType = (WINED3DMULTISAMPLE_TYPE *) &pDesc->MultiSampleType;
wined3ddesc.Width = &pDesc->Width;
wined3ddesc.Height = &pDesc->Height;
return IWineD3DTexture_GetLevelDesc(This->wineD3DTexture, Level, &wined3ddesc);
}
static HRESULT WINAPI IDirect3DTexture8Impl_GetSurfaceLevel(LPDIRECT3DTEXTURE8 iface, UINT Level, IDirect3DSurface8 **ppSurfaceLevel) {
IDirect3DTexture8Impl *This = (IDirect3DTexture8Impl *)iface;
HRESULT hrc = D3D_OK;
IWineD3DSurface *mySurface = NULL;
TRACE("(%p) Relay\n", This);
hrc = IWineD3DTexture_GetSurfaceLevel(This->wineD3DTexture, Level, &mySurface);
if (hrc == D3D_OK && NULL != ppSurfaceLevel) {
IWineD3DSurface_GetParent(mySurface, (IUnknown **)ppSurfaceLevel);
IWineD3DSurface_Release(mySurface);
}
return hrc;
}
static HRESULT WINAPI IDirect3DTexture8Impl_LockRect(LPDIRECT3DTEXTURE8 iface, UINT Level, D3DLOCKED_RECT *pLockedRect, CONST RECT *pRect, DWORD Flags) {
IDirect3DTexture8Impl *This = (IDirect3DTexture8Impl *)iface;
TRACE("(%p) Relay\n", This);
return IWineD3DTexture_LockRect(This->wineD3DTexture, Level, (WINED3DLOCKED_RECT *) pLockedRect, pRect, Flags);
}
static HRESULT WINAPI IDirect3DTexture8Impl_UnlockRect(LPDIRECT3DTEXTURE8 iface, UINT Level) {
IDirect3DTexture8Impl *This = (IDirect3DTexture8Impl *)iface;
TRACE("(%p) Relay\n", This);
return IWineD3DTexture_UnlockRect(This->wineD3DTexture, Level);
}
static HRESULT WINAPI IDirect3DTexture8Impl_AddDirtyRect(LPDIRECT3DTEXTURE8 iface, CONST RECT *pDirtyRect) {
IDirect3DTexture8Impl *This = (IDirect3DTexture8Impl *)iface;
TRACE("(%p) Relay\n", This);
return IWineD3DTexture_AddDirtyRect(This->wineD3DTexture, pDirtyRect);
}
const IDirect3DTexture8Vtbl Direct3DTexture8_Vtbl =
{
/* IUnknown */
IDirect3DTexture8Impl_QueryInterface,
IDirect3DTexture8Impl_AddRef,
IDirect3DTexture8Impl_Release,
/* IDirect3DResource8 */
IDirect3DTexture8Impl_GetDevice,
IDirect3DTexture8Impl_SetPrivateData,
IDirect3DTexture8Impl_GetPrivateData,
IDirect3DTexture8Impl_FreePrivateData,
IDirect3DTexture8Impl_SetPriority,
IDirect3DTexture8Impl_GetPriority,
IDirect3DTexture8Impl_PreLoad,
IDirect3DTexture8Impl_GetType,
/* IDirect3dBaseTexture8 */
IDirect3DTexture8Impl_SetLOD,
IDirect3DTexture8Impl_GetLOD,
IDirect3DTexture8Impl_GetLevelCount,
/* IDirect3DTexture8 */
IDirect3DTexture8Impl_GetLevelDesc,
IDirect3DTexture8Impl_GetSurfaceLevel,
IDirect3DTexture8Impl_LockRect,
IDirect3DTexture8Impl_UnlockRect,
IDirect3DTexture8Impl_AddDirtyRect
};

View File

@@ -0,0 +1,26 @@
/*
* Copyright 2001 Ove Kaaven
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#define WINE_FILEDESCRIPTION_STR "Wine Direct3D"
#define WINE_FILENAME_STR "d3d8.dll"
#define WINE_FILEVERSION 5,3,1,904
#define WINE_FILEVERSION_STR "5.3.1.904"
#define WINE_PRODUCTVERSION 5,3,1,904
#define WINE_PRODUCTVERSION_STR "5.3.1.904"
#include "wine/wine_common_ver.rc"

View File

@@ -0,0 +1,167 @@
/*
* IDirect3DVertexBuffer8 implementation
*
* Copyright 2005 Oliver Stieber
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "config.h"
#include "d3d8_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(d3d8);
/* IDirect3DVertexBuffer8 IUnknown parts follow: */
static HRESULT WINAPI IDirect3DVertexBuffer8Impl_QueryInterface(LPDIRECT3DVERTEXBUFFER8 iface, REFIID riid, LPVOID *ppobj) {
IDirect3DVertexBuffer8Impl *This = (IDirect3DVertexBuffer8Impl *)iface;
if (IsEqualGUID(riid, &IID_IUnknown)
|| IsEqualGUID(riid, &IID_IDirect3DResource8)
|| IsEqualGUID(riid, &IID_IDirect3DVertexBuffer8)) {
IUnknown_AddRef(iface);
*ppobj = This;
return S_OK;
}
WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);
*ppobj = NULL;
return E_NOINTERFACE;
}
static ULONG WINAPI IDirect3DVertexBuffer8Impl_AddRef(LPDIRECT3DVERTEXBUFFER8 iface) {
IDirect3DVertexBuffer8Impl *This = (IDirect3DVertexBuffer8Impl *)iface;
ULONG ref = InterlockedIncrement(&This->ref);
TRACE("(%p) : AddRef from %d\n", This, ref - 1);
return ref;
}
static ULONG WINAPI IDirect3DVertexBuffer8Impl_Release(LPDIRECT3DVERTEXBUFFER8 iface) {
IDirect3DVertexBuffer8Impl *This = (IDirect3DVertexBuffer8Impl *)iface;
ULONG ref = InterlockedDecrement(&This->ref);
TRACE("(%p) : ReleaseRef to %d\n", This, ref);
if (ref == 0) {
IWineD3DVertexBuffer_Release(This->wineD3DVertexBuffer);
IUnknown_Release(This->parentDevice);
HeapFree(GetProcessHeap(), 0, This);
}
return ref;
}
/* IDirect3DVertexBuffer8 IDirect3DResource8 Interface follow: */
static HRESULT WINAPI IDirect3DVertexBuffer8Impl_GetDevice(LPDIRECT3DVERTEXBUFFER8 iface, IDirect3DDevice8 **ppDevice) {
IDirect3DVertexBuffer8Impl *This = (IDirect3DVertexBuffer8Impl *)iface;
TRACE("(%p) Relay\n", This);
return IDirect3DResource8Impl_GetDevice((LPDIRECT3DRESOURCE8) This, ppDevice);
}
static HRESULT WINAPI IDirect3DVertexBuffer8Impl_SetPrivateData(LPDIRECT3DVERTEXBUFFER8 iface, REFGUID refguid, CONST void *pData, DWORD SizeOfData, DWORD Flags) {
IDirect3DVertexBuffer8Impl *This = (IDirect3DVertexBuffer8Impl *)iface;
TRACE("(%p) Relay\n", This);
return IWineD3DVertexBuffer_SetPrivateData(This->wineD3DVertexBuffer, refguid, pData, SizeOfData, Flags);
}
static HRESULT WINAPI IDirect3DVertexBuffer8Impl_GetPrivateData(LPDIRECT3DVERTEXBUFFER8 iface, REFGUID refguid, void *pData, DWORD *pSizeOfData) {
IDirect3DVertexBuffer8Impl *This = (IDirect3DVertexBuffer8Impl *)iface;
TRACE("(%p) Relay\n", This);
return IWineD3DVertexBuffer_GetPrivateData(This->wineD3DVertexBuffer, refguid, pData, pSizeOfData);
}
static HRESULT WINAPI IDirect3DVertexBuffer8Impl_FreePrivateData(LPDIRECT3DVERTEXBUFFER8 iface, REFGUID refguid) {
IDirect3DVertexBuffer8Impl *This = (IDirect3DVertexBuffer8Impl *)iface;
TRACE("(%p) Relay\n", This);
return IWineD3DVertexBuffer_FreePrivateData(This->wineD3DVertexBuffer, refguid);
}
static DWORD WINAPI IDirect3DVertexBuffer8Impl_SetPriority(LPDIRECT3DVERTEXBUFFER8 iface, DWORD PriorityNew) {
IDirect3DVertexBuffer8Impl *This = (IDirect3DVertexBuffer8Impl *)iface;
TRACE("(%p) Relay\n", This);
return IWineD3DVertexBuffer_SetPriority(This->wineD3DVertexBuffer, PriorityNew);
}
static DWORD WINAPI IDirect3DVertexBuffer8Impl_GetPriority(LPDIRECT3DVERTEXBUFFER8 iface) {
IDirect3DVertexBuffer8Impl *This = (IDirect3DVertexBuffer8Impl *)iface;
TRACE("(%p) Relay\n", This);
return IWineD3DVertexBuffer_GetPriority(This->wineD3DVertexBuffer);
}
static void WINAPI IDirect3DVertexBuffer8Impl_PreLoad(LPDIRECT3DVERTEXBUFFER8 iface) {
IDirect3DVertexBuffer8Impl *This = (IDirect3DVertexBuffer8Impl *)iface;
TRACE("(%p) Relay\n", This);
IWineD3DVertexBuffer_PreLoad(This->wineD3DVertexBuffer);
return;
}
static D3DRESOURCETYPE WINAPI IDirect3DVertexBuffer8Impl_GetType(LPDIRECT3DVERTEXBUFFER8 iface) {
IDirect3DVertexBuffer8Impl *This = (IDirect3DVertexBuffer8Impl *)iface;
TRACE("(%p) Relay\n", This);
return IWineD3DVertexBuffer_GetType(This->wineD3DVertexBuffer);
}
/* IDirect3DVertexBuffer8 Interface follow: */
static HRESULT WINAPI IDirect3DVertexBuffer8Impl_Lock(LPDIRECT3DVERTEXBUFFER8 iface, UINT OffsetToLock, UINT SizeToLock, BYTE **ppbData, DWORD Flags) {
IDirect3DVertexBuffer8Impl *This = (IDirect3DVertexBuffer8Impl *)iface;
TRACE("(%p) Relay\n", This);
return IWineD3DVertexBuffer_Lock(This->wineD3DVertexBuffer, OffsetToLock, SizeToLock, ppbData, Flags);
}
static HRESULT WINAPI IDirect3DVertexBuffer8Impl_Unlock(LPDIRECT3DVERTEXBUFFER8 iface) {
IDirect3DVertexBuffer8Impl *This = (IDirect3DVertexBuffer8Impl *)iface;
TRACE("(%p) Relay\n", This);
return IWineD3DVertexBuffer_Unlock(This->wineD3DVertexBuffer);
}
static HRESULT WINAPI IDirect3DVertexBuffer8Impl_GetDesc(LPDIRECT3DVERTEXBUFFER8 iface, D3DVERTEXBUFFER_DESC *pDesc) {
IDirect3DVertexBuffer8Impl *This = (IDirect3DVertexBuffer8Impl *)iface;
TRACE("(%p) Relay\n", This);
return IWineD3DVertexBuffer_GetDesc(This->wineD3DVertexBuffer, (WINED3DVERTEXBUFFER_DESC *) pDesc);
}
const IDirect3DVertexBuffer8Vtbl Direct3DVertexBuffer8_Vtbl =
{
/* IUnknown */
IDirect3DVertexBuffer8Impl_QueryInterface,
IDirect3DVertexBuffer8Impl_AddRef,
IDirect3DVertexBuffer8Impl_Release,
/* IDirect3DResource8 */
IDirect3DVertexBuffer8Impl_GetDevice,
IDirect3DVertexBuffer8Impl_SetPrivateData,
IDirect3DVertexBuffer8Impl_GetPrivateData,
IDirect3DVertexBuffer8Impl_FreePrivateData,
IDirect3DVertexBuffer8Impl_SetPriority,
IDirect3DVertexBuffer8Impl_GetPriority,
IDirect3DVertexBuffer8Impl_PreLoad,
IDirect3DVertexBuffer8Impl_GetType,
/* IDirect3DVertexBuffer8 */
IDirect3DVertexBuffer8Impl_Lock,
IDirect3DVertexBuffer8Impl_Unlock,
IDirect3DVertexBuffer8Impl_GetDesc
};

View File

@@ -0,0 +1,350 @@
/*
* IDirect3DVertexDeclaration8 implementation
*
* Copyright 2007 Henri Verbeet
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
/* IDirect3DVertexDeclaration8 is internal to our implementation.
* It's not visible in the API. */
#include "config.h"
#include "d3d8_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(d3d8);
/* IUnknown */
static HRESULT WINAPI IDirect3DVertexDeclaration8Impl_QueryInterface(IDirect3DVertexDeclaration8 *iface, REFIID riid, void **obj_ptr)
{
TRACE("(%p)->(%s, %p)\n", iface, debugstr_guid(riid), obj_ptr);
if (IsEqualGUID(riid, &IID_IUnknown)
|| IsEqualGUID(riid, &IID_IDirect3DVertexDeclaration8))
{
IUnknown_AddRef(iface);
*obj_ptr = iface;
return S_OK;
}
*obj_ptr = NULL;
return E_NOINTERFACE;
}
static ULONG WINAPI IDirect3DVertexDeclaration8Impl_AddRef(IDirect3DVertexDeclaration8 *iface)
{
IDirect3DVertexDeclaration8Impl *This = (IDirect3DVertexDeclaration8Impl *)iface;
ULONG ref_count = InterlockedIncrement(&This->ref_count);
TRACE("(%p) : AddRef increasing to %d\n", This, ref_count);
return ref_count;
}
static ULONG WINAPI IDirect3DVertexDeclaration8Impl_Release(IDirect3DVertexDeclaration8 *iface)
{
IDirect3DVertexDeclaration8Impl *This = (IDirect3DVertexDeclaration8Impl *)iface;
ULONG ref_count = InterlockedDecrement(&This->ref_count);
TRACE("(%p) : Releasing to %d\n", This, ref_count);
if (!ref_count) {
IWineD3DVertexDeclaration_Release(This->wined3d_vertex_declaration);
HeapFree(GetProcessHeap(), 0, This->elements);
HeapFree(GetProcessHeap(), 0, This);
}
return ref_count;
}
#ifdef WINE_NATIVEWIN32
/* D3DVSDT_* are defines in MS headers */
static const char *debug_d3dvsdt_type(int d3dvsdt_type)
#else
static const char *debug_d3dvsdt_type(D3DVSDT_TYPE d3dvsdt_type)
#endif
{
switch (d3dvsdt_type)
{
#define D3DVSDT_TYPE_TO_STR(u) case u: return #u
D3DVSDT_TYPE_TO_STR(D3DVSDT_FLOAT1);
D3DVSDT_TYPE_TO_STR(D3DVSDT_FLOAT2);
D3DVSDT_TYPE_TO_STR(D3DVSDT_FLOAT3);
D3DVSDT_TYPE_TO_STR(D3DVSDT_FLOAT4);
D3DVSDT_TYPE_TO_STR(D3DVSDT_D3DCOLOR);
D3DVSDT_TYPE_TO_STR(D3DVSDT_UBYTE4);
D3DVSDT_TYPE_TO_STR(D3DVSDT_SHORT2);
D3DVSDT_TYPE_TO_STR(D3DVSDT_SHORT4);
#undef D3DVSDT_TYPE_TO_STR
default:
FIXME("Unrecognized D3DVSDT_TYPE %#x\n", d3dvsdt_type);
return "unrecognized";
}
}
#ifdef WINE_NATIVEWIN32
/* D3DVSDE_* are defines in MS headers */
static const char *debug_d3dvsde_register(int d3dvsde_register)
#else
static const char *debug_d3dvsde_register(D3DVSDE_REGISTER d3dvsde_register)
#endif
{
switch (d3dvsde_register)
{
#define D3DVSDE_REGISTER_TO_STR(u) case u: return #u
D3DVSDE_REGISTER_TO_STR(D3DVSDE_POSITION);
D3DVSDE_REGISTER_TO_STR(D3DVSDE_BLENDWEIGHT);
D3DVSDE_REGISTER_TO_STR(D3DVSDE_BLENDINDICES);
D3DVSDE_REGISTER_TO_STR(D3DVSDE_NORMAL);
D3DVSDE_REGISTER_TO_STR(D3DVSDE_PSIZE);
D3DVSDE_REGISTER_TO_STR(D3DVSDE_DIFFUSE);
D3DVSDE_REGISTER_TO_STR(D3DVSDE_SPECULAR);
D3DVSDE_REGISTER_TO_STR(D3DVSDE_TEXCOORD0);
D3DVSDE_REGISTER_TO_STR(D3DVSDE_TEXCOORD1);
D3DVSDE_REGISTER_TO_STR(D3DVSDE_TEXCOORD2);
D3DVSDE_REGISTER_TO_STR(D3DVSDE_TEXCOORD3);
D3DVSDE_REGISTER_TO_STR(D3DVSDE_TEXCOORD4);
D3DVSDE_REGISTER_TO_STR(D3DVSDE_TEXCOORD5);
D3DVSDE_REGISTER_TO_STR(D3DVSDE_TEXCOORD6);
D3DVSDE_REGISTER_TO_STR(D3DVSDE_TEXCOORD7);
D3DVSDE_REGISTER_TO_STR(D3DVSDE_POSITION2);
D3DVSDE_REGISTER_TO_STR(D3DVSDE_NORMAL2);
#undef D3DVSDE_REGISTER_TO_STR
default:
FIXME("Unrecognized D3DVSDE_REGISTER %#x\n", d3dvsde_register);
return "unrecognized";
}
}
static size_t parse_token(const DWORD* pToken)
{
const DWORD token = *pToken;
size_t tokenlen = 1;
switch ((token & D3DVSD_TOKENTYPEMASK) >> D3DVSD_TOKENTYPESHIFT) { /* maybe a macro to inverse ... */
case D3DVSD_TOKEN_NOP:
TRACE(" 0x%08x NOP()\n", token);
break;
case D3DVSD_TOKEN_STREAM:
if (token & D3DVSD_STREAMTESSMASK)
{
TRACE(" 0x%08x STREAM_TESS()\n", token);
} else {
TRACE(" 0x%08x STREAM(%u)\n", token, ((token & D3DVSD_STREAMNUMBERMASK) >> D3DVSD_STREAMNUMBERSHIFT));
}
break;
case D3DVSD_TOKEN_STREAMDATA:
if (token & 0x10000000)
{
TRACE(" 0x%08x SKIP(%u)\n", token, ((token & D3DVSD_SKIPCOUNTMASK) >> D3DVSD_SKIPCOUNTSHIFT));
} else {
DWORD type = ((token & D3DVSD_DATATYPEMASK) >> D3DVSD_DATATYPESHIFT);
DWORD reg = ((token & D3DVSD_VERTEXREGMASK) >> D3DVSD_VERTEXREGSHIFT);
TRACE(" 0x%08x REG(%s, %s)\n", token, debug_d3dvsde_register(reg), debug_d3dvsdt_type(type));
}
break;
case D3DVSD_TOKEN_TESSELLATOR:
if (token & 0x10000000)
{
DWORD type = ((token & D3DVSD_DATATYPEMASK) >> D3DVSD_DATATYPESHIFT);
DWORD reg = ((token & D3DVSD_VERTEXREGMASK) >> D3DVSD_VERTEXREGSHIFT);
TRACE(" 0x%08x TESSUV(%s) as %s\n", token, debug_d3dvsde_register(reg), debug_d3dvsdt_type(type));
} else {
DWORD type = ((token & D3DVSD_DATATYPEMASK) >> D3DVSD_DATATYPESHIFT);
DWORD regout = ((token & D3DVSD_VERTEXREGMASK) >> D3DVSD_VERTEXREGSHIFT);
DWORD regin = ((token & D3DVSD_VERTEXREGINMASK) >> D3DVSD_VERTEXREGINSHIFT);
TRACE(" 0x%08x TESSNORMAL(%s, %s) as %s\n", token, debug_d3dvsde_register(regin),
debug_d3dvsde_register(regout), debug_d3dvsdt_type(type));
}
break;
case D3DVSD_TOKEN_CONSTMEM:
{
DWORD count = ((token & D3DVSD_CONSTCOUNTMASK) >> D3DVSD_CONSTCOUNTSHIFT);
tokenlen = (4 * count) + 1;
}
break;
case D3DVSD_TOKEN_EXT:
{
DWORD count = ((token & D3DVSD_CONSTCOUNTMASK) >> D3DVSD_CONSTCOUNTSHIFT);
DWORD extinfo = ((token & D3DVSD_EXTINFOMASK) >> D3DVSD_EXTINFOSHIFT);
TRACE(" 0x%08x EXT(%u, %u)\n", token, count, extinfo);
/* todo ... print extension */
tokenlen = count + 1;
}
break;
case D3DVSD_TOKEN_END:
TRACE(" 0x%08x END()\n", token);
break;
default:
TRACE(" 0x%08x UNKNOWN\n", token);
/* argg error */
}
return tokenlen;
}
void load_local_constants(const DWORD *d3d8_elements, IWineD3DVertexShader *wined3d_vertex_shader)
{
const DWORD *token = d3d8_elements;
while (*token != D3DVSD_END())
{
if (((*token & D3DVSD_TOKENTYPEMASK) >> D3DVSD_TOKENTYPESHIFT) == D3DVSD_TOKEN_CONSTMEM)
{
DWORD count = ((*token & D3DVSD_CONSTCOUNTMASK) >> D3DVSD_CONSTCOUNTSHIFT);
DWORD constant_idx = ((*token & D3DVSD_CONSTADDRESSMASK) >> D3DVSD_CONSTADDRESSSHIFT);
HRESULT hr;
if (TRACE_ON(d3d8))
{
DWORD i;
for (i = 0; i < count; ++i)
{
TRACE("c[%u] = (%8f, %8f, %8f, %8f)\n",
constant_idx,
*(const float *)(token + i * 4 + 1),
*(const float *)(token + i * 4 + 2),
*(const float *)(token + i * 4 + 3),
*(const float *)(token + i * 4 + 4));
}
}
hr = IWineD3DVertexShader_SetLocalConstantsF(wined3d_vertex_shader, constant_idx, (const float *)token+1, count);
if (FAILED(hr)) ERR("Failed setting shader constants\n");
}
token += parse_token(token);
}
}
/* NOTE: Make sure these are in the correct numerical order. (see /include/wined3d_types.h) */
static const size_t wined3d_type_sizes[WINED3DDECLTYPE_UNUSED] = {
/*WINED3DDECLTYPE_FLOAT1*/ 1 * sizeof(float),
/*WINED3DDECLTYPE_FLOAT2*/ 2 * sizeof(float),
/*WINED3DDECLTYPE_FLOAT3*/ 3 * sizeof(float),
/*WINED3DDECLTYPE_FLOAT4*/ 4 * sizeof(float),
/*WINED3DDECLTYPE_D3DCOLOR*/ 4 * sizeof(BYTE),
/*WINED3DDECLTYPE_UBYTE4*/ 4 * sizeof(BYTE),
/*WINED3DDECLTYPE_SHORT2*/ 2 * sizeof(short int),
/*WINED3DDECLTYPE_SHORT4*/ 4 * sizeof(short int),
/*WINED3DDECLTYPE_UBYTE4N*/ 4 * sizeof(BYTE),
/*WINED3DDECLTYPE_SHORT2N*/ 2 * sizeof(short int),
/*WINED3DDECLTYPE_SHORT4N*/ 4 * sizeof(short int),
/*WINED3DDECLTYPE_USHORT2N*/ 2 * sizeof(short int),
/*WINED3DDECLTYPE_USHORT4N*/ 4 * sizeof(short int),
/*WINED3DDECLTYPE_UDEC3*/ 3 * sizeof(short int),
/*WINED3DDECLTYPE_DEC3N*/ 3 * sizeof(short int),
/*WINED3DDECLTYPE_FLOAT16_2*/ 2 * sizeof(short int),
/*WINED3DDECLTYPE_FLOAT16_4*/ 4 * sizeof(short int)
};
typedef struct {
BYTE usage;
BYTE usage_idx;
} wined3d_usage_t;
static const wined3d_usage_t wined3d_usage_lookup[] = {
/*D3DVSDE_POSITION*/ {WINED3DDECLUSAGE_POSITION, 0},
/*D3DVSDE_BLENDWEIGHT*/ {WINED3DDECLUSAGE_BLENDWEIGHT, 0},
/*D3DVSDE_BLENDINDICES*/ {WINED3DDECLUSAGE_BLENDINDICES, 0},
/*D3DVSDE_NORMAL*/ {WINED3DDECLUSAGE_NORMAL, 0},
/*D3DVSDE_PSIZE*/ {WINED3DDECLUSAGE_PSIZE, 0},
/*D3DVSDE_DIFFUSE*/ {WINED3DDECLUSAGE_COLOR, 0},
/*D3DVSDE_SPECULAR*/ {WINED3DDECLUSAGE_COLOR, 1},
/*D3DVSDE_TEXCOORD0*/ {WINED3DDECLUSAGE_TEXCOORD, 0},
/*D3DVSDE_TEXCOORD1*/ {WINED3DDECLUSAGE_TEXCOORD, 1},
/*D3DVSDE_TEXCOORD2*/ {WINED3DDECLUSAGE_TEXCOORD, 2},
/*D3DVSDE_TEXCOORD3*/ {WINED3DDECLUSAGE_TEXCOORD, 3},
/*D3DVSDE_TEXCOORD4*/ {WINED3DDECLUSAGE_TEXCOORD, 4},
/*D3DVSDE_TEXCOORD5*/ {WINED3DDECLUSAGE_TEXCOORD, 5},
/*D3DVSDE_TEXCOORD6*/ {WINED3DDECLUSAGE_TEXCOORD, 6},
/*D3DVSDE_TEXCOORD7*/ {WINED3DDECLUSAGE_TEXCOORD, 7},
/*D3DVSDE_POSITION2*/ {WINED3DDECLUSAGE_POSITION, 1},
/*D3DVSDE_NORMAL2*/ {WINED3DDECLUSAGE_NORMAL, 1},
};
/* TODO: find out where rhw (or positionT) is for declaration8 */
size_t convert_to_wined3d_declaration(const DWORD *d3d8_elements, DWORD *d3d8_elements_size, WINED3DVERTEXELEMENT **wined3d_elements)
{
const DWORD *token = d3d8_elements;
WINED3DVERTEXELEMENT *element;
D3DVSD_TOKENTYPE token_type;
unsigned int element_count = 0;
DWORD stream = 0;
int offset = 0;
TRACE("d3d8_elements %p, wined3d_elements %p\n", d3d8_elements, wined3d_elements);
/* 128 should be enough for anyone... */
*wined3d_elements = HeapAlloc(GetProcessHeap(), 0, 128 * sizeof(WINED3DVERTEXELEMENT));
while (D3DVSD_END() != *token)
{
token_type = ((*token & D3DVSD_TOKENTYPEMASK) >> D3DVSD_TOKENTYPESHIFT);
if (token_type == D3DVSD_TOKEN_STREAM && !(*token & D3DVSD_STREAMTESSMASK))
{
stream = ((*token & D3DVSD_STREAMNUMBERMASK) >> D3DVSD_STREAMNUMBERSHIFT);
offset = 0;
} else if (token_type == D3DVSD_TOKEN_STREAMDATA && !(token_type & 0x10000000)) {
DWORD type = ((*token & D3DVSD_DATATYPEMASK) >> D3DVSD_DATATYPESHIFT);
DWORD reg = ((*token & D3DVSD_VERTEXREGMASK) >> D3DVSD_VERTEXREGSHIFT);
TRACE("Adding element %d:\n", element_count);
element = *wined3d_elements + element_count++;
element->Stream = stream;
element->Method = WINED3DDECLMETHOD_DEFAULT;
element->Usage = wined3d_usage_lookup[reg].usage;
element->UsageIndex = wined3d_usage_lookup[reg].usage_idx;
element->Type = type;
element->Offset = offset;
element->Reg = reg;
offset += wined3d_type_sizes[type];
} else if (token_type == D3DVSD_TOKEN_STREAMDATA && (token_type & 0x10000000)) {
TRACE(" 0x%08x SKIP(%u)\n", token_type, ((token_type & D3DVSD_SKIPCOUNTMASK) >> D3DVSD_SKIPCOUNTSHIFT));
offset += sizeof(DWORD) * ((token_type & D3DVSD_SKIPCOUNTMASK) >> D3DVSD_SKIPCOUNTSHIFT);
}
if (element_count >= 127) {
ERR("More than 127 elements?\n");
break;
}
token += parse_token(token);
}
/* END */
element = *wined3d_elements + element_count++;
element->Stream = 0xFF;
element->Type = WINED3DDECLTYPE_UNUSED;
*d3d8_elements_size = (++token - d3d8_elements) * sizeof(DWORD);
return element_count;
}
const IDirect3DVertexDeclaration8Vtbl Direct3DVertexDeclaration8_Vtbl =
{
IDirect3DVertexDeclaration8Impl_QueryInterface,
IDirect3DVertexDeclaration8Impl_AddRef,
IDirect3DVertexDeclaration8Impl_Release
};

View File

@@ -0,0 +1,100 @@
/*
* IDirect3DVertexShader8 implementation
*
* Copyright 2002-2003 Jason Edmeades
* Raphael Junqueira
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "config.h"
#include "d3d8_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(d3d8);
/* IDirect3DVertexShader8 IUnknown parts follow: */
static HRESULT WINAPI IDirect3DVertexShader8Impl_QueryInterface(IDirect3DVertexShader8 *iface, REFIID riid, LPVOID* ppobj) {
IDirect3DVertexShader8Impl *This = (IDirect3DVertexShader8Impl *)iface;
if (IsEqualGUID(riid, &IID_IUnknown)
|| IsEqualGUID(riid, &IID_IDirect3DVertexShader8)) {
IUnknown_AddRef(iface);
*ppobj = This;
return S_OK;
}
WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);
*ppobj = NULL;
return E_NOINTERFACE;
}
static ULONG WINAPI IDirect3DVertexShader8Impl_AddRef(IDirect3DVertexShader8 *iface) {
IDirect3DVertexShader8Impl *This = (IDirect3DVertexShader8Impl *)iface;
ULONG ref = InterlockedIncrement(&This->ref);
TRACE("(%p) : AddRef from %d\n", This, ref - 1);
return ref;
}
static ULONG WINAPI IDirect3DVertexShader8Impl_Release(IDirect3DVertexShader8 *iface) {
IDirect3DVertexShader8Impl *This = (IDirect3DVertexShader8Impl *)iface;
ULONG ref = InterlockedDecrement(&This->ref);
TRACE("(%p) : ReleaseRef to %d\n", This, ref);
if (ref == 0) {
IDirect3DVertexDeclaration8_Release(This->vertex_declaration);
IWineD3DVertexShader_Release(This->wineD3DVertexShader);
HeapFree(GetProcessHeap(), 0, This);
}
return ref;
}
/* IDirect3DVertexShader8 Interface follow: */
static HRESULT WINAPI IDirect3DVertexShader8Impl_GetDevice(IDirect3DVertexShader8 *iface, IDirect3DDevice8** ppDevice) {
IDirect3DVertexShader8Impl *This = (IDirect3DVertexShader8Impl *)iface;
IWineD3DDevice *myDevice = NULL;
HRESULT hr = D3D_OK;
TRACE("(%p) : Relay\n", This);
if (D3D_OK == (hr = IWineD3DVertexShader_GetDevice(This->wineD3DVertexShader, &myDevice) && myDevice != NULL)) {
hr = IWineD3DDevice_GetParent(myDevice, (IUnknown **)ppDevice);
IWineD3DDevice_Release(myDevice);
} else {
*ppDevice = NULL;
}
TRACE("(%p) returning (%p)\n", This, *ppDevice);
return hr;
}
static HRESULT WINAPI IDirect3DVertexShader8Impl_GetFunction(IDirect3DVertexShader8 *iface, VOID* pData, UINT* pSizeOfData) {
IDirect3DVertexShader8Impl *This = (IDirect3DVertexShader8Impl *)iface;
TRACE("(%p) : Relay\n", This);
return IWineD3DVertexShader_GetFunction(This->wineD3DVertexShader, pData, pSizeOfData);
}
const IDirect3DVertexShader8Vtbl Direct3DVertexShader8_Vtbl =
{
/* IUnknown */
IDirect3DVertexShader8Impl_QueryInterface,
IDirect3DVertexShader8Impl_AddRef,
IDirect3DVertexShader8Impl_Release,
/* IDirect3DVertexShader8 */
IDirect3DVertexShader8Impl_GetDevice,
IDirect3DVertexShader8Impl_GetFunction
};

View File

@@ -0,0 +1,223 @@
/*
* IDirect3DVolume8 implementation
*
* Copyright 2005 Oliver Stieber
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "config.h"
#include "d3d8_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(d3d8);
/* IDirect3DVolume8 IUnknown parts follow: */
static HRESULT WINAPI IDirect3DVolume8Impl_QueryInterface(LPDIRECT3DVOLUME8 iface, REFIID riid, LPVOID *ppobj) {
IDirect3DVolume8Impl *This = (IDirect3DVolume8Impl *)iface;
if (IsEqualGUID(riid, &IID_IUnknown)
|| IsEqualGUID(riid, &IID_IDirect3DVolume8)) {
IUnknown_AddRef(iface);
*ppobj = This;
return S_OK;
}
WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);
*ppobj = NULL;
return E_NOINTERFACE;
}
static ULONG WINAPI IDirect3DVolume8Impl_AddRef(LPDIRECT3DVOLUME8 iface) {
IDirect3DVolume8Impl *This = (IDirect3DVolume8Impl *)iface;
TRACE("(%p)\n", This);
if (This->forwardReference) {
/* Forward to the containerParent */
TRACE("(%p) : Forwarding to %p\n", This, This->forwardReference);
return IUnknown_AddRef(This->forwardReference);
} else {
/* No container, handle our own refcounting */
ULONG ref = InterlockedIncrement(&This->ref);
TRACE("(%p) : AddRef from %d\n", This, ref - 1);
return ref;
}
}
static ULONG WINAPI IDirect3DVolume8Impl_Release(LPDIRECT3DVOLUME8 iface) {
IDirect3DVolume8Impl *This = (IDirect3DVolume8Impl *)iface;
TRACE("(%p)\n", This);
if (This->forwardReference) {
/* Forward to the containerParent */
TRACE("(%p) : Forwarding to %p\n", This, This->forwardReference);
return IUnknown_Release(This->forwardReference);
}
else {
/* No container, handle our own refcounting */
ULONG ref = InterlockedDecrement(&This->ref);
TRACE("(%p) : ReleaseRef to %d\n", This, ref);
if (ref == 0) {
IWineD3DVolume_Release(This->wineD3DVolume);
HeapFree(GetProcessHeap(), 0, This);
}
return ref;
}
}
/* IDirect3DVolume8 Interface follow: */
static HRESULT WINAPI IDirect3DVolume8Impl_GetDevice(LPDIRECT3DVOLUME8 iface, IDirect3DDevice8 **ppDevice) {
IDirect3DVolume8Impl *This = (IDirect3DVolume8Impl *)iface;
IWineD3DDevice *myDevice = NULL;
IWineD3DVolume_GetDevice(This->wineD3DVolume, &myDevice);
IWineD3DDevice_GetParent(myDevice, (IUnknown **)ppDevice);
IWineD3DDevice_Release(myDevice);
return D3D_OK;
}
static HRESULT WINAPI IDirect3DVolume8Impl_SetPrivateData(LPDIRECT3DVOLUME8 iface, REFGUID refguid, CONST void *pData, DWORD SizeOfData, DWORD Flags) {
IDirect3DVolume8Impl *This = (IDirect3DVolume8Impl *)iface;
TRACE("(%p) Relay\n", This);
return IWineD3DVolume_SetPrivateData(This->wineD3DVolume, refguid, pData, SizeOfData, Flags);
}
static HRESULT WINAPI IDirect3DVolume8Impl_GetPrivateData(LPDIRECT3DVOLUME8 iface, REFGUID refguid, void *pData, DWORD* pSizeOfData) {
IDirect3DVolume8Impl *This = (IDirect3DVolume8Impl *)iface;
TRACE("(%p) Relay\n", This);
return IWineD3DVolume_GetPrivateData(This->wineD3DVolume, refguid, pData, pSizeOfData);
}
static HRESULT WINAPI IDirect3DVolume8Impl_FreePrivateData(LPDIRECT3DVOLUME8 iface, REFGUID refguid) {
IDirect3DVolume8Impl *This = (IDirect3DVolume8Impl *)iface;
TRACE("(%p) Relay\n", This);
return IWineD3DVolume_FreePrivateData(This->wineD3DVolume, refguid);
}
static HRESULT WINAPI IDirect3DVolume8Impl_GetContainer(LPDIRECT3DVOLUME8 iface, REFIID riid, void **ppContainer) {
IDirect3DVolume8Impl *This = (IDirect3DVolume8Impl *)iface;
HRESULT res;
TRACE("(This %p, riid %s, ppContainer %p)\n", This, debugstr_guid(riid), ppContainer);
if (!This->container) return E_NOINTERFACE;
if (!ppContainer) {
ERR("Called without a valid ppContainer.\n");
}
res = IUnknown_QueryInterface(This->container, riid, ppContainer);
TRACE("Returning ppContainer %p, *ppContainer %p\n", ppContainer, *ppContainer);
return res;
}
static HRESULT WINAPI IDirect3DVolume8Impl_GetDesc(LPDIRECT3DVOLUME8 iface, D3DVOLUME_DESC *pDesc) {
IDirect3DVolume8Impl *This = (IDirect3DVolume8Impl *)iface;
WINED3DVOLUME_DESC wined3ddesc;
TRACE("(%p) Relay\n", This);
/* As d3d8 and d3d9 structures differ, pass in ptrs to where data needs to go */
wined3ddesc.Format = (WINED3DFORMAT *)&pDesc->Format;
wined3ddesc.Type = (WINED3DRESOURCETYPE *)&pDesc->Type;
wined3ddesc.Usage = &pDesc->Usage;
wined3ddesc.Pool = (WINED3DPOOL *) &pDesc->Pool;
wined3ddesc.Size = &pDesc->Size;
wined3ddesc.Width = &pDesc->Width;
wined3ddesc.Height = &pDesc->Height;
wined3ddesc.Depth = &pDesc->Depth;
return IWineD3DVolume_GetDesc(This->wineD3DVolume, &wined3ddesc);
}
static HRESULT WINAPI IDirect3DVolume8Impl_LockBox(LPDIRECT3DVOLUME8 iface, D3DLOCKED_BOX *pLockedVolume, CONST D3DBOX *pBox, DWORD Flags) {
IDirect3DVolume8Impl *This = (IDirect3DVolume8Impl *)iface;
TRACE("(%p) relay %p %p %p %d\n", This, This->wineD3DVolume, pLockedVolume, pBox, Flags);
return IWineD3DVolume_LockBox(This->wineD3DVolume, (WINED3DLOCKED_BOX *) pLockedVolume, (CONST WINED3DBOX *) pBox, Flags);
}
static HRESULT WINAPI IDirect3DVolume8Impl_UnlockBox(LPDIRECT3DVOLUME8 iface) {
IDirect3DVolume8Impl *This = (IDirect3DVolume8Impl *)iface;
TRACE("(%p) relay %p\n", This, This->wineD3DVolume);
return IWineD3DVolume_UnlockBox(This->wineD3DVolume);
}
static const IDirect3DVolume8Vtbl Direct3DVolume8_Vtbl =
{
/* IUnknown */
IDirect3DVolume8Impl_QueryInterface,
IDirect3DVolume8Impl_AddRef,
IDirect3DVolume8Impl_Release,
/* IDirect3DVolume8 */
IDirect3DVolume8Impl_GetDevice,
IDirect3DVolume8Impl_SetPrivateData,
IDirect3DVolume8Impl_GetPrivateData,
IDirect3DVolume8Impl_FreePrivateData,
IDirect3DVolume8Impl_GetContainer,
IDirect3DVolume8Impl_GetDesc,
IDirect3DVolume8Impl_LockBox,
IDirect3DVolume8Impl_UnlockBox
};
/* Internal function called back during the CreateVolumeTexture */
HRESULT WINAPI D3D8CB_CreateVolume(IUnknown *pDevice, IUnknown *pSuperior, UINT Width, UINT Height, UINT Depth,
WINED3DFORMAT Format, WINED3DPOOL Pool, DWORD Usage,
IWineD3DVolume **ppVolume,
HANDLE * pSharedHandle) {
IDirect3DVolume8Impl *object;
IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)pDevice;
HRESULT hrc = D3D_OK;
/* Allocate the storage for the device */
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3DVolume8Impl));
if (NULL == object) {
FIXME("Allocation of memory failed\n");
*ppVolume = NULL;
return D3DERR_OUTOFVIDEOMEMORY;
}
object->lpVtbl = &Direct3DVolume8_Vtbl;
object->ref = 1;
hrc = IWineD3DDevice_CreateVolume(This->WineD3DDevice, Width, Height, Depth, Usage, Format,
Pool, &object->wineD3DVolume, pSharedHandle, (IUnknown *)object);
if (hrc != D3D_OK) {
/* free up object */
FIXME("(%p) call to IWineD3DDevice_CreateVolume failed\n", This);
HeapFree(GetProcessHeap(), 0, object);
*ppVolume = NULL;
} else {
*ppVolume = (IWineD3DVolume *)object->wineD3DVolume;
object->container = pSuperior;
object->forwardReference = pSuperior;
}
TRACE("(%p) Created volume %p\n", This, *ppVolume);
return hrc;
}
ULONG WINAPI D3D8CB_DestroyVolume(IWineD3DVolume *pVolume) {
IDirect3DVolume8Impl* volumeParent;
IWineD3DVolume_GetParent(pVolume, (IUnknown **) &volumeParent);
/* GetParent's AddRef was forwarded to an object in destruction.
* Releasing it here again would cause an endless recursion. */
volumeParent->forwardReference = NULL;
return IDirect3DVolume8_Release((IDirect3DVolume8*) volumeParent);
}

View File

@@ -0,0 +1,215 @@
/*
* IDirect3DVolumeTexture8 implementation
*
* Copyright 2005 Oliver Stieber
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "config.h"
#include "d3d8_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(d3d8);
/* IDirect3DVolumeTexture8 IUnknown parts follow: */
static HRESULT WINAPI IDirect3DVolumeTexture8Impl_QueryInterface(LPDIRECT3DVOLUMETEXTURE8 iface, REFIID riid, LPVOID *ppobj) {
IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
if (IsEqualGUID(riid, &IID_IUnknown)
|| IsEqualGUID(riid, &IID_IDirect3DResource8)
|| IsEqualGUID(riid, &IID_IDirect3DBaseTexture8)
|| IsEqualGUID(riid, &IID_IDirect3DVolumeTexture8)) {
IUnknown_AddRef(iface);
*ppobj = This;
return S_OK;
}
WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);
*ppobj = NULL;
return E_NOINTERFACE;
}
static ULONG WINAPI IDirect3DVolumeTexture8Impl_AddRef(LPDIRECT3DVOLUMETEXTURE8 iface) {
IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
ULONG ref = InterlockedIncrement(&This->ref);
TRACE("(%p) : AddRef from %d\n", This, ref - 1);
return ref;
}
static ULONG WINAPI IDirect3DVolumeTexture8Impl_Release(LPDIRECT3DVOLUMETEXTURE8 iface) {
IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
ULONG ref = InterlockedDecrement(&This->ref);
TRACE("(%p) : ReleaseRef to %d\n", This, ref);
if (ref == 0) {
IWineD3DVolumeTexture_Destroy(This->wineD3DVolumeTexture, D3D8CB_DestroyVolume);
IUnknown_Release(This->parentDevice);
HeapFree(GetProcessHeap(), 0, This);
}
return ref;
}
/* IDirect3DVolumeTexture8 IDirect3DResource8 Interface follow: */
static HRESULT WINAPI IDirect3DVolumeTexture8Impl_GetDevice(LPDIRECT3DVOLUMETEXTURE8 iface, IDirect3DDevice8 **ppDevice) {
IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
TRACE("(%p) Relay\n", This);
return IDirect3DResource8Impl_GetDevice((LPDIRECT3DRESOURCE8) This, ppDevice);
}
static HRESULT WINAPI IDirect3DVolumeTexture8Impl_SetPrivateData(LPDIRECT3DVOLUMETEXTURE8 iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) {
IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
TRACE("(%p) Relay\n", This);
return IWineD3DVolumeTexture_SetPrivateData(This->wineD3DVolumeTexture, refguid, pData, SizeOfData, Flags);
}
static HRESULT WINAPI IDirect3DVolumeTexture8Impl_GetPrivateData(LPDIRECT3DVOLUMETEXTURE8 iface, REFGUID refguid, void *pData, DWORD *pSizeOfData) {
IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
TRACE("(%p) Relay\n", This);
return IWineD3DVolumeTexture_GetPrivateData(This->wineD3DVolumeTexture, refguid, pData, pSizeOfData);
}
static HRESULT WINAPI IDirect3DVolumeTexture8Impl_FreePrivateData(LPDIRECT3DVOLUMETEXTURE8 iface, REFGUID refguid) {
IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
TRACE("(%p) Relay\n", This);
return IWineD3DVolumeTexture_FreePrivateData(This->wineD3DVolumeTexture, refguid);
}
static DWORD WINAPI IDirect3DVolumeTexture8Impl_SetPriority(LPDIRECT3DVOLUMETEXTURE8 iface, DWORD PriorityNew) {
IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
TRACE("(%p) Relay\n", This);
return IWineD3DVolumeTexture_SetPriority(This->wineD3DVolumeTexture, PriorityNew);
}
static DWORD WINAPI IDirect3DVolumeTexture8Impl_GetPriority(LPDIRECT3DVOLUMETEXTURE8 iface) {
IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
TRACE("(%p) Relay\n", This);
return IWineD3DVolumeTexture_GetPriority(This->wineD3DVolumeTexture);
}
static void WINAPI IDirect3DVolumeTexture8Impl_PreLoad(LPDIRECT3DVOLUMETEXTURE8 iface) {
IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
TRACE("(%p) Relay\n", This);
IWineD3DVolumeTexture_PreLoad(This->wineD3DVolumeTexture);
}
static D3DRESOURCETYPE WINAPI IDirect3DVolumeTexture8Impl_GetType(LPDIRECT3DVOLUMETEXTURE8 iface) {
IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
TRACE("(%p) Relay\n", This);
return IWineD3DVolumeTexture_GetType(This->wineD3DVolumeTexture);
}
/* IDirect3DVolumeTexture8 IDirect3DBaseTexture8 Interface follow: */
static DWORD WINAPI IDirect3DVolumeTexture8Impl_SetLOD(LPDIRECT3DVOLUMETEXTURE8 iface, DWORD LODNew) {
IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
TRACE("(%p) Relay\n", This);
return IWineD3DVolumeTexture_SetLOD(This->wineD3DVolumeTexture, LODNew);
}
static DWORD WINAPI IDirect3DVolumeTexture8Impl_GetLOD(LPDIRECT3DVOLUMETEXTURE8 iface) {
IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
TRACE("(%p) Relay\n", This);
return IWineD3DVolumeTexture_GetLOD(This->wineD3DVolumeTexture);
}
static DWORD WINAPI IDirect3DVolumeTexture8Impl_GetLevelCount(LPDIRECT3DVOLUMETEXTURE8 iface) {
IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
TRACE("(%p) Relay\n", This);
return IWineD3DVolumeTexture_GetLevelCount(This->wineD3DVolumeTexture);
}
/* IDirect3DVolumeTexture8 Interface follow: */
static HRESULT WINAPI IDirect3DVolumeTexture8Impl_GetLevelDesc(LPDIRECT3DVOLUMETEXTURE8 iface, UINT Level, D3DVOLUME_DESC* pDesc) {
IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
WINED3DVOLUME_DESC wined3ddesc;
UINT tmpInt = -1;
TRACE("(%p) Relay\n", This);
/* As d3d8 and d3d8 structures differ, pass in ptrs to where data needs to go */
wined3ddesc.Format = (WINED3DFORMAT *)&pDesc->Format;
wined3ddesc.Type = (WINED3DRESOURCETYPE *)&pDesc->Type;
wined3ddesc.Usage = &pDesc->Usage;
wined3ddesc.Pool = (WINED3DPOOL *) &pDesc->Pool;
wined3ddesc.Size = &tmpInt;
wined3ddesc.Width = &pDesc->Width;
wined3ddesc.Height = &pDesc->Height;
wined3ddesc.Depth = &pDesc->Depth;
return IWineD3DVolumeTexture_GetLevelDesc(This->wineD3DVolumeTexture, Level, &wined3ddesc);
}
static HRESULT WINAPI IDirect3DVolumeTexture8Impl_GetVolumeLevel(LPDIRECT3DVOLUMETEXTURE8 iface, UINT Level, IDirect3DVolume8 **ppVolumeLevel) {
IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
HRESULT hrc = D3D_OK;
IWineD3DVolume *myVolume = NULL;
TRACE("(%p) Relay\n", This);
hrc = IWineD3DVolumeTexture_GetVolumeLevel(This->wineD3DVolumeTexture, Level, &myVolume);
if (hrc == D3D_OK && NULL != ppVolumeLevel) {
IWineD3DVolumeTexture_GetParent(myVolume, (IUnknown **)ppVolumeLevel);
IWineD3DVolumeTexture_Release(myVolume);
}
return hrc;
}
static HRESULT WINAPI IDirect3DVolumeTexture8Impl_LockBox(LPDIRECT3DVOLUMETEXTURE8 iface, UINT Level, D3DLOCKED_BOX *pLockedVolume, CONST D3DBOX *pBox, DWORD Flags) {
IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
TRACE("(%p) Relay %p %p %p %d\n", This, This->wineD3DVolumeTexture, pLockedVolume, pBox,Flags);
return IWineD3DVolumeTexture_LockBox(This->wineD3DVolumeTexture, Level, (WINED3DLOCKED_BOX *) pLockedVolume, (CONST WINED3DBOX *) pBox, Flags);
}
static HRESULT WINAPI IDirect3DVolumeTexture8Impl_UnlockBox(LPDIRECT3DVOLUMETEXTURE8 iface, UINT Level) {
IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
TRACE("(%p) Relay %p %d\n", This, This->wineD3DVolumeTexture, Level);
return IWineD3DVolumeTexture_UnlockBox(This->wineD3DVolumeTexture, Level);
}
static HRESULT WINAPI IDirect3DVolumeTexture8Impl_AddDirtyBox(LPDIRECT3DVOLUMETEXTURE8 iface, CONST D3DBOX *pDirtyBox) {
IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
TRACE("(%p) Relay\n", This);
return IWineD3DVolumeTexture_AddDirtyBox(This->wineD3DVolumeTexture, (CONST WINED3DBOX *) pDirtyBox);
}
const IDirect3DVolumeTexture8Vtbl Direct3DVolumeTexture8_Vtbl =
{
/* IUnknown */
IDirect3DVolumeTexture8Impl_QueryInterface,
IDirect3DVolumeTexture8Impl_AddRef,
IDirect3DVolumeTexture8Impl_Release,
/* IDirect3DResource8 */
IDirect3DVolumeTexture8Impl_GetDevice,
IDirect3DVolumeTexture8Impl_SetPrivateData,
IDirect3DVolumeTexture8Impl_GetPrivateData,
IDirect3DVolumeTexture8Impl_FreePrivateData,
IDirect3DVolumeTexture8Impl_SetPriority,
IDirect3DVolumeTexture8Impl_GetPriority,
IDirect3DVolumeTexture8Impl_PreLoad,
IDirect3DVolumeTexture8Impl_GetType,
/* IDirect3DBaseTexture8 */
IDirect3DVolumeTexture8Impl_SetLOD,
IDirect3DVolumeTexture8Impl_GetLOD,
IDirect3DVolumeTexture8Impl_GetLevelCount,
/* IDirect3DVolumeTexture8 */
IDirect3DVolumeTexture8Impl_GetLevelDesc,
IDirect3DVolumeTexture8Impl_GetVolumeLevel,
IDirect3DVolumeTexture8Impl_LockBox,
IDirect3DVolumeTexture8Impl_UnlockBox,
IDirect3DVolumeTexture8Impl_AddDirtyBox
};

View File

@@ -0,0 +1,172 @@
/*
* IDirect3DBaseTexture9 implementation
*
* Copyright 2002-2004 Jason Edmeades
* Raphael Junqueira
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "config.h"
#include "d3d9_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(d3d9);
/* IDirect3DBaseTexture9 IUnknown parts follow: */
static HRESULT WINAPI IDirect3DBaseTexture9Impl_QueryInterface(LPDIRECT3DBASETEXTURE9 iface, REFIID riid, LPVOID* ppobj) {
IDirect3DBaseTexture9Impl *This = (IDirect3DBaseTexture9Impl *)iface;
TRACE("(%p) Relay\n" , This);
if (IsEqualGUID(riid, &IID_IUnknown)
|| IsEqualGUID(riid, &IID_IDirect3DResource9)
|| IsEqualGUID(riid, &IID_IDirect3DBaseTexture9)) {
IUnknown_AddRef(iface);
*ppobj = This;
return S_OK;
}
WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);
*ppobj = NULL;
return E_NOINTERFACE;
}
static ULONG WINAPI IDirect3DBaseTexture9Impl_AddRef(LPDIRECT3DBASETEXTURE9 iface) {
IDirect3DBaseTexture9Impl *This = (IDirect3DBaseTexture9Impl *)iface;
ULONG ref = InterlockedIncrement(&This->ref);
TRACE("(%p) : AddRef from %d\n", This, ref - 1);
return ref;
}
static ULONG WINAPI IDirect3DBaseTexture9Impl_Release(LPDIRECT3DBASETEXTURE9 iface) {
IDirect3DBaseTexture9Impl *This = (IDirect3DBaseTexture9Impl *)iface;
ULONG ref = InterlockedDecrement(&This->ref);
TRACE("(%p) : ReleaseRef to %d\n", This, ref);
if (ref == 0) {
IWineD3DBaseTexture_Release(This->wineD3DBaseTexture);
HeapFree(GetProcessHeap(), 0, This);
}
return ref;
}
/* IDirect3DBaseTexture9 IDirect3DResource9 Interface follow: */
static HRESULT WINAPI IDirect3DBaseTexture9Impl_GetDevice(LPDIRECT3DBASETEXTURE9 iface, IDirect3DDevice9** ppDevice) {
IDirect3DBaseTexture9Impl *This = (IDirect3DBaseTexture9Impl *)iface;
TRACE("(%p) Relay\n" , This);
return IDirect3DResource9Impl_GetDevice((LPDIRECT3DRESOURCE9) This, ppDevice);
}
static HRESULT WINAPI IDirect3DBaseTexture9Impl_SetPrivateData(LPDIRECT3DBASETEXTURE9 iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) {
IDirect3DBaseTexture9Impl *This = (IDirect3DBaseTexture9Impl *)iface;
TRACE("(%p) Relay\n" , This);
return IWineD3DBaseTexture_SetPrivateData(This->wineD3DBaseTexture, refguid, pData, SizeOfData, Flags);
}
static HRESULT WINAPI IDirect3DBaseTexture9Impl_GetPrivateData(LPDIRECT3DBASETEXTURE9 iface, REFGUID refguid, void* pData, DWORD* pSizeOfData) {
IDirect3DBaseTexture9Impl *This = (IDirect3DBaseTexture9Impl *)iface;
TRACE("(%p) Relay\n" , This);
return IWineD3DBaseTexture_GetPrivateData(This->wineD3DBaseTexture, refguid, pData, pSizeOfData);
}
static HRESULT WINAPI IDirect3DBaseTexture9Impl_FreePrivateData(LPDIRECT3DBASETEXTURE9 iface, REFGUID refguid) {
IDirect3DBaseTexture9Impl *This = (IDirect3DBaseTexture9Impl *)iface;
TRACE("(%p) Relay\n" , This);
return IWineD3DBaseTexture_FreePrivateData(This->wineD3DBaseTexture, refguid);
}
static DWORD WINAPI IDirect3DBaseTexture9Impl_SetPriority(LPDIRECT3DBASETEXTURE9 iface, DWORD PriorityNew) {
IDirect3DBaseTexture9Impl *This = (IDirect3DBaseTexture9Impl *)iface;
TRACE("(%p) Relay\n" , This);
return IWineD3DBaseTexture_SetPriority(This->wineD3DBaseTexture, PriorityNew);
}
static DWORD WINAPI IDirect3DBaseTexture9Impl_GetPriority(LPDIRECT3DBASETEXTURE9 iface) {
IDirect3DBaseTexture9Impl *This = (IDirect3DBaseTexture9Impl *)iface;
TRACE("(%p) Relay\n" , This);
return IWineD3DBaseTexture_GetPriority(This->wineD3DBaseTexture);
}
static void WINAPI IDirect3DBaseTexture9Impl_PreLoad(LPDIRECT3DBASETEXTURE9 iface) {
IDirect3DBaseTexture9Impl *This = (IDirect3DBaseTexture9Impl *)iface;
TRACE("(%p) Relay\n" , This);
IWineD3DBaseTexture_PreLoad(This->wineD3DBaseTexture);
return ;
}
static D3DRESOURCETYPE WINAPI IDirect3DBaseTexture9Impl_GetType(LPDIRECT3DBASETEXTURE9 iface) {
IDirect3DBaseTexture9Impl *This = (IDirect3DBaseTexture9Impl *)iface;
TRACE("(%p) Relay\n" , This);
return IWineD3DBaseTexture_GetType(This->wineD3DBaseTexture);
}
/* IDirect3DBaseTexture9 Interface follow: */
static DWORD WINAPI IDirect3DBaseTexture9Impl_SetLOD(LPDIRECT3DBASETEXTURE9 iface, DWORD LODNew) {
IDirect3DBaseTexture9Impl *This = (IDirect3DBaseTexture9Impl *)iface;
TRACE("(%p) Relay\n" , This);
return IWineD3DBaseTexture_SetLOD(This->wineD3DBaseTexture, LODNew);
}
DWORD WINAPI IDirect3DBaseTexture9Impl_GetLOD(LPDIRECT3DBASETEXTURE9 iface) {
IDirect3DBaseTexture9Impl *This = (IDirect3DBaseTexture9Impl *)iface;
TRACE("(%p) Relay\n" , This);
return IWineD3DBaseTexture_GetLOD(This->wineD3DBaseTexture);
}
static DWORD WINAPI IDirect3DBaseTexture9Impl_GetLevelCount(LPDIRECT3DBASETEXTURE9 iface) {
IDirect3DBaseTexture9Impl *This = (IDirect3DBaseTexture9Impl *)iface;
TRACE("(%p) Relay\n" , This);
return IWineD3DBaseTexture_GetLevelCount(This->wineD3DBaseTexture);
}
static HRESULT WINAPI IDirect3DBaseTexture9Impl_SetAutoGenFilterType(LPDIRECT3DBASETEXTURE9 iface, D3DTEXTUREFILTERTYPE FilterType) {
IDirect3DBaseTexture9Impl *This = (IDirect3DBaseTexture9Impl *)iface;
TRACE("(%p) Relay\n" , This);
return IWineD3DBaseTexture_SetAutoGenFilterType(This->wineD3DBaseTexture, (WINED3DTEXTUREFILTERTYPE) FilterType);
}
static D3DTEXTUREFILTERTYPE WINAPI IDirect3DBaseTexture9Impl_GetAutoGenFilterType(LPDIRECT3DBASETEXTURE9 iface) {
IDirect3DBaseTexture9Impl *This = (IDirect3DBaseTexture9Impl *)iface;
TRACE("(%p) Relay\n" , This);
return (D3DTEXTUREFILTERTYPE) IWineD3DBaseTexture_GetAutoGenFilterType(This->wineD3DBaseTexture);
}
static void WINAPI IDirect3DBaseTexture9Impl_GenerateMipSubLevels(LPDIRECT3DBASETEXTURE9 iface) {
IDirect3DBaseTexture9Impl *This = (IDirect3DBaseTexture9Impl *)iface;
TRACE("(%p) Relay\n" , This);
IWineD3DBaseTexture_GenerateMipSubLevels(This->wineD3DBaseTexture);
}
const IDirect3DBaseTexture9Vtbl Direct3DBaseTexture9_Vtbl =
{
IDirect3DBaseTexture9Impl_QueryInterface,
IDirect3DBaseTexture9Impl_AddRef,
IDirect3DBaseTexture9Impl_Release,
IDirect3DBaseTexture9Impl_GetDevice,
IDirect3DBaseTexture9Impl_SetPrivateData,
IDirect3DBaseTexture9Impl_GetPrivateData,
IDirect3DBaseTexture9Impl_FreePrivateData,
IDirect3DBaseTexture9Impl_SetPriority,
IDirect3DBaseTexture9Impl_GetPriority,
IDirect3DBaseTexture9Impl_PreLoad,
IDirect3DBaseTexture9Impl_GetType,
IDirect3DBaseTexture9Impl_SetLOD,
IDirect3DBaseTexture9Impl_GetLOD,
IDirect3DBaseTexture9Impl_GetLevelCount,
IDirect3DBaseTexture9Impl_SetAutoGenFilterType,
IDirect3DBaseTexture9Impl_GetAutoGenFilterType,
IDirect3DBaseTexture9Impl_GenerateMipSubLevels
};

View File

@@ -0,0 +1,283 @@
/*
* IDirect3DCubeTexture9 implementation
*
* Copyright 2002-2005 Jason Edmeades
* Copyright 2002-2005 Raphael Junqueira
* Copyright 2005 Oliver Stieber
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "config.h"
#include "d3d9_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(d3d9);
/* IDirect3DCubeTexture9 IUnknown parts follow: */
static HRESULT WINAPI IDirect3DCubeTexture9Impl_QueryInterface(LPDIRECT3DCUBETEXTURE9 iface, REFIID riid, LPVOID* ppobj) {
IDirect3DCubeTexture9Impl *This = (IDirect3DCubeTexture9Impl *)iface;
if (IsEqualGUID(riid, &IID_IUnknown)
|| IsEqualGUID(riid, &IID_IDirect3DResource9)
|| IsEqualGUID(riid, &IID_IDirect3DBaseTexture9)
|| IsEqualGUID(riid, &IID_IDirect3DCubeTexture9)) {
IUnknown_AddRef(iface);
*ppobj = This;
return S_OK;
}
WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);
*ppobj = NULL;
return E_NOINTERFACE;
}
static ULONG WINAPI IDirect3DCubeTexture9Impl_AddRef(LPDIRECT3DCUBETEXTURE9 iface) {
IDirect3DCubeTexture9Impl *This = (IDirect3DCubeTexture9Impl *)iface;
ULONG ref = InterlockedIncrement(&This->ref);
TRACE("(%p) : AddRef from %d\n", This, ref - 1);
return ref;
}
static ULONG WINAPI IDirect3DCubeTexture9Impl_Release(LPDIRECT3DCUBETEXTURE9 iface) {
IDirect3DCubeTexture9Impl *This = (IDirect3DCubeTexture9Impl *)iface;
ULONG ref = InterlockedDecrement(&This->ref);
TRACE("(%p) : ReleaseRef to %d\n", This, ref);
if (ref == 0) {
TRACE("Releasing child %p\n", This->wineD3DCubeTexture);
IWineD3DCubeTexture_Destroy(This->wineD3DCubeTexture, D3D9CB_DestroySurface);
IUnknown_Release(This->parentDevice);
HeapFree(GetProcessHeap(), 0, This);
}
return ref;
}
/* IDirect3DCubeTexture9 IDirect3DResource9 Interface follow: */
static HRESULT WINAPI IDirect3DCubeTexture9Impl_GetDevice(LPDIRECT3DCUBETEXTURE9 iface, IDirect3DDevice9** ppDevice) {
IDirect3DCubeTexture9Impl *This = (IDirect3DCubeTexture9Impl *)iface;
TRACE("(%p) Relay\n" , This);
return IDirect3DResource9Impl_GetDevice((LPDIRECT3DRESOURCE9) This, ppDevice);
}
static HRESULT WINAPI IDirect3DCubeTexture9Impl_SetPrivateData(LPDIRECT3DCUBETEXTURE9 iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) {
IDirect3DCubeTexture9Impl *This = (IDirect3DCubeTexture9Impl *)iface;
TRACE("(%p) Relay\n", This);
return IWineD3DCubeTexture_SetPrivateData(This->wineD3DCubeTexture,refguid,pData,SizeOfData,Flags);
}
static HRESULT WINAPI IDirect3DCubeTexture9Impl_GetPrivateData(LPDIRECT3DCUBETEXTURE9 iface, REFGUID refguid, void* pData, DWORD* pSizeOfData) {
IDirect3DCubeTexture9Impl *This = (IDirect3DCubeTexture9Impl *)iface;
TRACE("(%p) Relay\n", This);
return IWineD3DCubeTexture_GetPrivateData(This->wineD3DCubeTexture,refguid,pData,pSizeOfData);
}
static HRESULT WINAPI IDirect3DCubeTexture9Impl_FreePrivateData(LPDIRECT3DCUBETEXTURE9 iface, REFGUID refguid) {
IDirect3DCubeTexture9Impl *This = (IDirect3DCubeTexture9Impl *)iface;
TRACE("(%p) Relay\n", This);
return IWineD3DCubeTexture_FreePrivateData(This->wineD3DCubeTexture,refguid);
}
static DWORD WINAPI IDirect3DCubeTexture9Impl_SetPriority(LPDIRECT3DCUBETEXTURE9 iface, DWORD PriorityNew) {
IDirect3DCubeTexture9Impl *This = (IDirect3DCubeTexture9Impl *)iface;
TRACE("(%p) Relay\n", This);
return IWineD3DCubeTexture_SetPriority(This->wineD3DCubeTexture, PriorityNew);
}
static DWORD WINAPI IDirect3DCubeTexture9Impl_GetPriority(LPDIRECT3DCUBETEXTURE9 iface) {
IDirect3DCubeTexture9Impl *This = (IDirect3DCubeTexture9Impl *)iface;
TRACE("(%p) Relay\n", This);
return IWineD3DCubeTexture_GetPriority(This->wineD3DCubeTexture);
}
static void WINAPI IDirect3DCubeTexture9Impl_PreLoad(LPDIRECT3DCUBETEXTURE9 iface) {
IDirect3DCubeTexture9Impl *This = (IDirect3DCubeTexture9Impl *)iface;
TRACE("(%p) Relay\n", This);
IWineD3DCubeTexture_PreLoad(This->wineD3DCubeTexture);
}
static D3DRESOURCETYPE WINAPI IDirect3DCubeTexture9Impl_GetType(LPDIRECT3DCUBETEXTURE9 iface) {
IDirect3DCubeTexture9Impl *This = (IDirect3DCubeTexture9Impl *)iface;
TRACE("(%p) Relay\n", This);
return IWineD3DCubeTexture_GetType(This->wineD3DCubeTexture);
}
/* IDirect3DCubeTexture9 IDirect3DBaseTexture9 Interface follow: */
static DWORD WINAPI IDirect3DCubeTexture9Impl_SetLOD(LPDIRECT3DCUBETEXTURE9 iface, DWORD LODNew) {
IDirect3DCubeTexture9Impl *This = (IDirect3DCubeTexture9Impl *)iface;
TRACE("(%p) Relay\n", This);
return IWineD3DCubeTexture_SetLOD(This->wineD3DCubeTexture, LODNew);
}
static DWORD WINAPI IDirect3DCubeTexture9Impl_GetLOD(LPDIRECT3DCUBETEXTURE9 iface) {
IDirect3DCubeTexture9Impl *This = (IDirect3DCubeTexture9Impl *)iface;
TRACE("(%p) Relay\n", This);
return IDirect3DBaseTexture9Impl_GetLOD((LPDIRECT3DBASETEXTURE9) This);
}
static DWORD WINAPI IDirect3DCubeTexture9Impl_GetLevelCount(LPDIRECT3DCUBETEXTURE9 iface) {
IDirect3DCubeTexture9Impl *This = (IDirect3DCubeTexture9Impl *)iface;
TRACE("(%p) Relay\n", This);
return IWineD3DCubeTexture_GetLevelCount(This->wineD3DCubeTexture);
}
static HRESULT WINAPI IDirect3DCubeTexture9Impl_SetAutoGenFilterType(LPDIRECT3DCUBETEXTURE9 iface, D3DTEXTUREFILTERTYPE FilterType) {
IDirect3DCubeTexture9Impl *This = (IDirect3DCubeTexture9Impl *)iface;
TRACE("(%p) Relay\n", This);
return IWineD3DCubeTexture_SetAutoGenFilterType(This->wineD3DCubeTexture, (WINED3DTEXTUREFILTERTYPE) FilterType);
}
static D3DTEXTUREFILTERTYPE WINAPI IDirect3DCubeTexture9Impl_GetAutoGenFilterType(LPDIRECT3DCUBETEXTURE9 iface) {
IDirect3DCubeTexture9Impl *This = (IDirect3DCubeTexture9Impl *)iface;
TRACE("(%p) Relay\n", This);
return (D3DTEXTUREFILTERTYPE) IWineD3DCubeTexture_GetAutoGenFilterType(This->wineD3DCubeTexture);
}
static void WINAPI IDirect3DCubeTexture9Impl_GenerateMipSubLevels(LPDIRECT3DCUBETEXTURE9 iface) {
IDirect3DCubeTexture9Impl *This = (IDirect3DCubeTexture9Impl *)iface;
TRACE("(%p) Relay\n", This);
IWineD3DCubeTexture_GenerateMipSubLevels(This->wineD3DCubeTexture);
}
/* IDirect3DCubeTexture9 Interface follow: */
static HRESULT WINAPI IDirect3DCubeTexture9Impl_GetLevelDesc(LPDIRECT3DCUBETEXTURE9 iface, UINT Level, D3DSURFACE_DESC* pDesc) {
IDirect3DCubeTexture9Impl *This = (IDirect3DCubeTexture9Impl *)iface;
WINED3DSURFACE_DESC wined3ddesc;
UINT tmpInt = -1;
TRACE("(%p) Relay\n", This);
/* As d3d8 and d3d9 structures differ, pass in ptrs to where data needs to go */
wined3ddesc.Format = (WINED3DFORMAT *)&pDesc->Format;
wined3ddesc.Type = (WINED3DRESOURCETYPE *) &pDesc->Type;
wined3ddesc.Usage = &pDesc->Usage;
wined3ddesc.Pool = (WINED3DPOOL *) &pDesc->Pool;
wined3ddesc.Size = &tmpInt;
wined3ddesc.MultiSampleType = (WINED3DMULTISAMPLE_TYPE *) &pDesc->MultiSampleType;
wined3ddesc.MultiSampleQuality = &pDesc->MultiSampleQuality;
wined3ddesc.Width = &pDesc->Width;
wined3ddesc.Height = &pDesc->Height;
return IWineD3DCubeTexture_GetLevelDesc(This->wineD3DCubeTexture, Level, &wined3ddesc);
}
static HRESULT WINAPI IDirect3DCubeTexture9Impl_GetCubeMapSurface(LPDIRECT3DCUBETEXTURE9 iface, D3DCUBEMAP_FACES FaceType, UINT Level, IDirect3DSurface9** ppCubeMapSurface) {
IDirect3DCubeTexture9Impl *This = (IDirect3DCubeTexture9Impl *)iface;
HRESULT hrc = D3D_OK;
IWineD3DSurface *mySurface = NULL;
TRACE("(%p) Relay\n", This);
hrc = IWineD3DCubeTexture_GetCubeMapSurface(This->wineD3DCubeTexture, (WINED3DCUBEMAP_FACES) FaceType, Level, &mySurface);
if (hrc == D3D_OK && NULL != ppCubeMapSurface) {
IWineD3DCubeTexture_GetParent(mySurface, (IUnknown **)ppCubeMapSurface);
IWineD3DCubeTexture_Release(mySurface);
}
return hrc;
}
static HRESULT WINAPI IDirect3DCubeTexture9Impl_LockRect(LPDIRECT3DCUBETEXTURE9 iface, D3DCUBEMAP_FACES FaceType, UINT Level, D3DLOCKED_RECT* pLockedRect, CONST RECT* pRect, DWORD Flags) {
IDirect3DCubeTexture9Impl *This = (IDirect3DCubeTexture9Impl *)iface;
TRACE("(%p) Relay\n", This);
return IWineD3DCubeTexture_LockRect(This->wineD3DCubeTexture, (WINED3DCUBEMAP_FACES) FaceType, Level, (WINED3DLOCKED_RECT *) pLockedRect, pRect, Flags);
}
static HRESULT WINAPI IDirect3DCubeTexture9Impl_UnlockRect(LPDIRECT3DCUBETEXTURE9 iface, D3DCUBEMAP_FACES FaceType, UINT Level) {
IDirect3DCubeTexture9Impl *This = (IDirect3DCubeTexture9Impl *)iface;
TRACE("(%p) Relay\n", This);
return IWineD3DCubeTexture_UnlockRect(This->wineD3DCubeTexture, (WINED3DCUBEMAP_FACES) FaceType, Level);
}
static HRESULT WINAPI IDirect3DCubeTexture9Impl_AddDirtyRect(LPDIRECT3DCUBETEXTURE9 iface, D3DCUBEMAP_FACES FaceType, CONST RECT* pDirtyRect) {
IDirect3DCubeTexture9Impl *This = (IDirect3DCubeTexture9Impl *)iface;
TRACE("(%p) Relay\n", This);
return IWineD3DCubeTexture_AddDirtyRect(This->wineD3DCubeTexture, (WINED3DCUBEMAP_FACES) FaceType, pDirtyRect);
}
static const IDirect3DCubeTexture9Vtbl Direct3DCubeTexture9_Vtbl =
{
/* IUnknown */
IDirect3DCubeTexture9Impl_QueryInterface,
IDirect3DCubeTexture9Impl_AddRef,
IDirect3DCubeTexture9Impl_Release,
/* IDirect3DResource9 */
IDirect3DCubeTexture9Impl_GetDevice,
IDirect3DCubeTexture9Impl_SetPrivateData,
IDirect3DCubeTexture9Impl_GetPrivateData,
IDirect3DCubeTexture9Impl_FreePrivateData,
IDirect3DCubeTexture9Impl_SetPriority,
IDirect3DCubeTexture9Impl_GetPriority,
IDirect3DCubeTexture9Impl_PreLoad,
IDirect3DCubeTexture9Impl_GetType,
/* IDirect3DBaseTexture9 */
IDirect3DCubeTexture9Impl_SetLOD,
IDirect3DCubeTexture9Impl_GetLOD,
IDirect3DCubeTexture9Impl_GetLevelCount,
IDirect3DCubeTexture9Impl_SetAutoGenFilterType,
IDirect3DCubeTexture9Impl_GetAutoGenFilterType,
IDirect3DCubeTexture9Impl_GenerateMipSubLevels,
IDirect3DCubeTexture9Impl_GetLevelDesc,
IDirect3DCubeTexture9Impl_GetCubeMapSurface,
IDirect3DCubeTexture9Impl_LockRect,
IDirect3DCubeTexture9Impl_UnlockRect,
IDirect3DCubeTexture9Impl_AddDirtyRect
};
/* IDirect3DDevice9 IDirect3DCubeTexture9 Methods follow: */
HRESULT WINAPI IDirect3DDevice9Impl_CreateCubeTexture(LPDIRECT3DDEVICE9 iface,
UINT EdgeLength, UINT Levels, DWORD Usage,
D3DFORMAT Format, D3DPOOL Pool,
IDirect3DCubeTexture9** ppCubeTexture, HANDLE* pSharedHandle) {
IDirect3DCubeTexture9Impl *object;
IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
HRESULT hr = D3D_OK;
TRACE("(%p) : ELen(%d) Lvl(%d) Usage(%d) fmt(%u), Pool(%d) Shared(%p)\n", This, EdgeLength, Levels, Usage, Format, Pool, pSharedHandle);
/* Allocate the storage for the device */
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
if (NULL == object) {
FIXME("(%p) allocation of CubeTexture failed\n", This);
return D3DERR_OUTOFVIDEOMEMORY;
}
object->lpVtbl = &Direct3DCubeTexture9_Vtbl;
object->ref = 1;
hr = IWineD3DDevice_CreateCubeTexture(This->WineD3DDevice, EdgeLength, Levels, Usage,
(WINED3DFORMAT)Format, (WINED3DPOOL) Pool, &object->wineD3DCubeTexture, pSharedHandle, (IUnknown*)object,
D3D9CB_CreateSurface);
if (hr != D3D_OK){
/* free up object */
FIXME("(%p) call to IWineD3DDevice_CreateCubeTexture failed\n", This);
HeapFree(GetProcessHeap(), 0, object);
} else {
IUnknown_AddRef(iface);
object->parentDevice = iface;
*ppCubeTexture = (LPDIRECT3DCUBETEXTURE9) object;
TRACE("(%p) : Created cube texture %p\n", This, object);
}
TRACE("(%p) returning %p\n",This, *ppCubeTexture);
return hr;
}

View File

@@ -0,0 +1,19 @@
LIBRARY "d3d9.dll"
EXPORTS
D3D9GetSWInfo @1
D3DPERF_BeginEvent @2
D3DPERF_EndEvent @3
D3DPERF_GetStatus @4
D3DPERF_QueryRepeatFrame @5
D3DPERF_SetMarker @6
D3DPERF_SetOptions @7
D3DPERF_SetRegion @8
DebugSetLevel @9
DebugSetMute @10
Direct3DCreate9 @11
Direct3DCreate9Ex @12
Direct3DShaderValidatorCreate9 @13
PSGPError @14
PSGPSampleTexture @15
CheckFullscreen @16

View File

@@ -0,0 +1,189 @@
# Microsoft Developer Studio Project File - Name="d3d9" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
CFG=d3d9 - Win32 Debug
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
!MESSAGE
!MESSAGE NMAKE /f "d3d9.mak".
!MESSAGE
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "d3d9.mak" CFG="d3d9 - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "d3d9 - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE "d3d9 - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE
# Begin Project
# PROP AllowPerConfigDependencies 0
# PROP Scc_ProjName ""
# PROP Scc_LocalPath ""
CPP=cl.exe
MTL=midl.exe
RSC=rc.exe
!IF "$(CFG)" == "d3d9 - Win32 Release"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Release"
# PROP BASE Intermediate_Dir "Release"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "Release"
# PROP Intermediate_Dir "Release"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c
# ADD CPP /nologo /MD /W3 /GX /Zi /O2 /I "$(DXSDK_DIR)\include" /I "$(MSSDK)\include" /I "..\..\include" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "__WINESRC__" /YX /FD /c
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x419 /d "NDEBUG"
# ADD RSC /l 0x409 /i "..\..\include" /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386
# ADD LINK32 advapi32.lib kernel32.lib user32.lib gdi32.lib uuid.lib dxguid.lib /nologo /subsystem:windows /dll /pdb:"../../bin/d3d9.pdb" /debug /machine:I386 /out:"../../bin/d3d9.dll"
# SUBTRACT LINK32 /pdb:none
!ELSEIF "$(CFG)" == "d3d9 - Win32 Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "Debug"
# PROP BASE Intermediate_Dir "Debug"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "Debug"
# PROP Intermediate_Dir "Debug"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /GZ /c
# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "$(DXSDK_DIR)\include" /I "$(MSSDK)\include" /I "..\..\include" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "__WINESRC__" /YX /FD /GZ /c
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x419 /d "_DEBUG"
# ADD RSC /l 0x409 /i "..\..\include" /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386 /pdbtype:sept
# ADD LINK32 advapi32.lib kernel32.lib user32.lib gdi32.lib uuid.lib dxguid.lib /nologo /subsystem:windows /dll /pdb:"../../bin/d3d9.pdb" /debug /machine:I386 /out:"../../bin/d3d9.dll" /pdbtype:sept
# SUBTRACT LINK32 /pdb:none
!ENDIF
# Begin Target
# Name "d3d9 - Win32 Release"
# Name "d3d9 - Win32 Debug"
# Begin Group "Source Files"
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
# Begin Source File
SOURCE=.\basetexture.c
# End Source File
# Begin Source File
SOURCE=.\cubetexture.c
# End Source File
# Begin Source File
SOURCE=.\d3d9.def
# End Source File
# Begin Source File
SOURCE=.\d3d9_main.c
# End Source File
# Begin Source File
SOURCE=.\device.c
# End Source File
# Begin Source File
SOURCE=.\directx.c
# End Source File
# Begin Source File
SOURCE=.\indexbuffer.c
# End Source File
# Begin Source File
SOURCE=.\pixelshader.c
# End Source File
# Begin Source File
SOURCE=.\query.c
# End Source File
# Begin Source File
SOURCE=.\resource.c
# End Source File
# Begin Source File
SOURCE=.\stateblock.c
# End Source File
# Begin Source File
SOURCE=.\surface.c
# End Source File
# Begin Source File
SOURCE=.\swapchain.c
# End Source File
# Begin Source File
SOURCE=.\texture.c
# End Source File
# Begin Source File
SOURCE=.\vertexbuffer.c
# End Source File
# Begin Source File
SOURCE=.\vertexdeclaration.c
# End Source File
# Begin Source File
SOURCE=.\vertexshader.c
# End Source File
# Begin Source File
SOURCE=.\volume.c
# End Source File
# Begin Source File
SOURCE=.\volumetexture.c
# End Source File
# End Group
# Begin Group "Header Files"
# PROP Default_Filter "h;hpp;hxx;hm;inl"
# Begin Source File
SOURCE=.\d3d9_private.h
# End Source File
# End Group
# Begin Group "Resource Files"
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
# Begin Source File
SOURCE=.\version.rc
# End Source File
# End Group
# End Target
# End Project

View File

@@ -0,0 +1,43 @@
<module name="d3d9" type="win32dll" entrypoint="0" installbase="system32" installname="d3d9.dll">
<importlibrary definition="d3d9.def" />
<include base="d3d9">.</include>
<include base="ReactOS">include/reactos/wine-paralles</include>
<include base="ReactOS">include/reactos/wine</include>
<define name="UNICODE" />
<define name="_UNICODE" />
<define name="__REACTOS__" />
<define name="__USE_W32API" />
<define name="_WIN32_IE">0x600</define>
<define name="_WIN32_WINNT">0x501</define>
<define name="WINVER">0x501</define>
<define name="WINE_NATIVEWIN32" />
<library>wine</library>
<library>uuid</library>
<library>ntdll</library>
<library>kernel32</library>
<library>user32</library>
<library>advapi32</library>
<library>ole32</library>
<library>winmm</library>
<library>dxguid</library>
<file>basetexture.c</file>
<file>cubetexture.c</file>
<file>d3d9_main.c</file>
<file>device.c</file>
<file>directx.c</file>
<file>indexbuffer.c</file>
<file>pixelshader.c</file>
<file>query.c</file>
<file>resource.c</file>
<file>stateblock.c</file>
<file>surface.c</file>
<file>swapchain.c</file>
<file>texture.c</file>
<file>vertexbuffer.c</file>
<file>vertexdeclaration.c</file>
<file>vertexshader.c</file>
<file>volume.c</file>
<file>volumetexture.c</file>
<file>version.rc</file>
</module>

View File

@@ -0,0 +1,305 @@
/*
* Direct3D 9
*
* Copyright 2002-2003 Jason Edmeades
* Copyright 2002-2003 Raphael Junqueira
* Copyright 2005 Oliver Stieber
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*
*/
#include "config.h"
#include "initguid.h"
#include "d3d9_private.h"
typedef IWineD3D* (WINAPI *fnWineDirect3DCreate)(UINT, UINT, IUnknown *);
static HMODULE hWineD3D = (HMODULE) -1;
static fnWineDirect3DCreate pWineDirect3DCreate;
WINE_DEFAULT_DEBUG_CHANNEL(d3d9);
static int D3DPERF_event_level = 0;
#ifdef WINE_NATIVEWIN32
static HMODULE hD3D9;
HRESULT (WINAPI *pD3D9GetSWInfo)(void);
BOOL (WINAPI *pCheckFullscreen)();
HRESULT (WINAPI *pDebugSetLevel)(void);
HRESULT (WINAPI *pDebugSetMute)(void);
IDirect3D9* (WINAPI *pDirect3DCreate9)(UINT SDKVersion);
HRESULT (WINAPI *pDirect3DCreate9Ex)(UINT SDKVersion, VOID** ppD3D);
BOOL
IsPassthrough()
{
if (!hD3D9)
return FALSE;
if (hD3D9 != (HMODULE) -1)
return TRUE;
hD3D9 = LoadLibraryA("d3d9.sav");
if (hD3D9) {
#define getproc(x) *(FARPROC *)&p##x = GetProcAddress(hD3D9, #x)
getproc(D3D9GetSWInfo);
getproc(CheckFullscreen);
getproc(DebugSetLevel);
getproc(DebugSetMute);
getproc(Direct3DCreate9);
getproc(Direct3DCreate9Ex);
#undef getproc
}
return hD3D9 != NULL;
}
#endif
HRESULT WINAPI D3D9GetSWInfo(void) {
#ifdef WINE_NATIVEWIN32
if (IsPassthrough())
return pD3D9GetSWInfo();
#endif
FIXME("(void): stub\n");
return 0;
}
BOOL WINAPI
CheckFullscreen()
{
#ifdef WINE_NATIVEWIN32
if (IsPassthrough())
return pCheckFullscreen();
#endif
return FALSE;
}
HRESULT WINAPI DebugSetLevel(void) {
#ifdef WINE_NATIVEWIN32
if (IsPassthrough())
return pDebugSetLevel();
#endif
FIXME("(void): stub\n");
return 0;
}
HRESULT WINAPI DebugSetMute(void) {
#ifdef WINE_NATIVEWIN32
if (IsPassthrough())
return pDebugSetMute();
#endif
FIXME("(void): stub\n");
return 0;
}
IDirect3D9* WINAPI Direct3DCreate9(UINT SDKVersion) {
IDirect3D9Impl* object;
#ifdef WINE_NATIVEWIN32
if (IsPassthrough())
return pDirect3DCreate9(SDKVersion);
#endif
if (hWineD3D == (HMODULE) -1)
{
hWineD3D = LoadLibraryA("wined3d");
if (hWineD3D)
pWineDirect3DCreate = (fnWineDirect3DCreate) GetProcAddress(hWineD3D, "WineDirect3DCreate");
}
if (!hWineD3D)
{
ERR("Couldn't load WineD3D - OpenGL libs not present?\n");
return NULL;
}
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3D9Impl));
object->lpVtbl = &Direct3D9_Vtbl;
object->ref = 1;
object->WineD3D = pWineDirect3DCreate(SDKVersion, 9, (IUnknown *)object);
TRACE("SDKVersion = %x, Created Direct3D object @ %p, WineObj @ %p\n", SDKVersion, object, object->WineD3D);
return (IDirect3D9*) object;
}
HRESULT WINAPI Direct3DCreate9Ex(UINT SDKVersion, VOID** ppD3D) {
#ifdef WINE_NATIVEWIN32
if (IsPassthrough())
return pDirect3DCreate9Ex(SDKVersion, ppD3D);
#endif
TRACE("SDKVersion = %x\n", SDKVersion);
/* When D3D9L features are not supported (no WDDM driver installed) */
if (ppD3D)
*ppD3D = NULL;
return D3DERR_NOTAVAILABLE;
}
HRESULT WINAPI Direct3DShaderValidatorCreate9(void) {
FIXME("(void): stub\n");
return 0;
}
HRESULT WINAPI PSGPError(void) {
FIXME("(void): stub\n");
return 0;
}
HRESULT WINAPI PSGPSampleTexture(void) {
FIXME("(void): stub\n");
return 0;
}
/***********************************************************************
* get_config_key
*
* Reads a config key from the registry. Taken from WineD3D
*
***********************************************************************/
static inline DWORD get_config_key(HKEY defkey, HKEY appkey, const char* name, char* buffer, DWORD size)
{
if (0 != appkey && !RegQueryValueExA( appkey, name, 0, NULL, (LPBYTE) buffer, &size )) return 0;
if (0 != defkey && !RegQueryValueExA( defkey, name, 0, NULL, (LPBYTE) buffer, &size )) return 0;
return ERROR_FILE_NOT_FOUND;
}
/* At process attach */
BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpv)
{
TRACE("fdwReason=%d\n", fdwReason);
if (fdwReason == DLL_PROCESS_ATTACH) {
char buffer[MAX_PATH+64];
DWORD size = sizeof(buffer);
HKEY hkey = 0;
HKEY appkey = 0;
DWORD len;
DisableThreadLibraryCalls(hInstDLL);
/* @@ Wine registry key: HKCU\Software\Wine\Direct3D */
if ( RegOpenKeyA( HKEY_CURRENT_USER, "Software\\Wine\\Direct3D", &hkey )
&& RegOpenKeyA( HKEY_LOCAL_MACHINE, "Software\\Wine\\Direct3D", &hkey ) )
hkey = 0;
len = GetModuleFileNameA( 0, buffer, MAX_PATH );
if (len && len < MAX_PATH)
{
char *p, *appname = buffer;
if ((p = strrchr( appname, '/' ))) appname = p + 1;
if ((p = strrchr( appname, '\\' ))) appname = p + 1;
TRACE("appname = [%s]\n", appname);
memmove(
buffer + strlen( "Software\\Wine\\AppDefaults\\" ),
appname, strlen( appname ) + 1);
memcpy(
buffer, "Software\\Wine\\AppDefaults\\",
strlen( "Software\\Wine\\AppDefaults\\" ));
strcat( buffer, "\\Direct3D" );
/* @@ Wine registry key: HKCU\Software\Wine\AppDefaults\app.exe\Direct3D */
if (RegOpenKeyA( HKEY_CURRENT_USER, buffer, &appkey )
&& RegOpenKeyA( HKEY_LOCAL_MACHINE, buffer, &appkey ))
appkey = 0;
}
if ( 0 != hkey || 0 != appkey )
{
#ifdef WINE_NATIVEWIN32
if ( !get_config_key( hkey, appkey, "Passthrough", buffer, size) )
{
if (!strcmp(buffer,"true") || !strcmp(buffer,"yes"))
{
TRACE("Passthrough mode\n");
hD3D9 = (HMODULE) -1;
}
}
#endif
}
}
else if (fdwReason == DLL_PROCESS_DETACH)
{
if (hWineD3D && hWineD3D != (HMODULE) -1)
FreeLibrary(hWineD3D);
#ifdef WINE_NATIVEWIN32
if (hD3D9 && hD3D9 != (HMODULE) -1)
FreeLibrary(hD3D9);
#endif
}
return TRUE;
}
/***********************************************************************
* D3DPERF_BeginEvent (D3D9.@)
*/
int WINAPI D3DPERF_BeginEvent(D3DCOLOR color, LPCWSTR name) {
FIXME("(color %#x, name %s) : stub\n", color, debugstr_w(name));
return D3DPERF_event_level++;
}
/***********************************************************************
* D3DPERF_EndEvent (D3D9.@)
*/
int WINAPI D3DPERF_EndEvent(void) {
FIXME("(void) : stub\n");
return --D3DPERF_event_level;
}
/***********************************************************************
* D3DPERF_GetStatus (D3D9.@)
*/
DWORD WINAPI D3DPERF_GetStatus(void) {
FIXME("(void) : stub\n");
return 0;
}
/***********************************************************************
* D3DPERF_SetOptions (D3D9.@)
*
*/
void WINAPI D3DPERF_SetOptions(DWORD options)
{
FIXME("(%#x) : stub\n", options);
}
/***********************************************************************
* D3DPERF_QueryRepeatFrame (D3D9.@)
*/
BOOL WINAPI D3DPERF_QueryRepeatFrame(void) {
FIXME("(void) : stub\n");
return FALSE;
}
/***********************************************************************
* D3DPERF_SetMarker (D3D9.@)
*/
void WINAPI D3DPERF_SetMarker(D3DCOLOR color, LPCWSTR name) {
FIXME("(color %#x, name %s) : stub\n", color, debugstr_w(name));
}
/***********************************************************************
* D3DPERF_SetRegion (D3D9.@)
*/
void WINAPI D3DPERF_SetRegion(D3DCOLOR color, LPCWSTR name) {
FIXME("(color %#x, name %s) : stub\n", color, debugstr_w(name));
}

View File

@@ -0,0 +1,584 @@
/*
* Direct3D 9 private include file
*
* Copyright 2002-2003 Jason Edmeades
* Copyright 2002-2003 Raphael Junqueira
* Copyright 2005 Oliver Stieber
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef __WINE_D3D9_PRIVATE_H
#define __WINE_D3D9_PRIVATE_H
#include <stdarg.h>
#define NONAMELESSUNION
#define NONAMELESSSTRUCT
#define COBJMACROS
#ifndef WINE_NATIVEWIN32
# include "windef.h"
# include "winbase.h"
# include "wingdi.h"
# include "winuser.h"
#else
# include <windows.h>
#endif
#include "wine/debug.h"
#include "d3d9.h"
#include "wine/wined3d_interface.h"
/* ===========================================================================
Internal use
=========================================================================== */
extern HRESULT vdecl_convert_fvf(
DWORD FVF,
D3DVERTEXELEMENT9** ppVertexElements);
/* ===========================================================================
Macros
=========================================================================== */
/* Not nice, but it lets wined3d support different versions of directx */
#define D3D9CAPSTOWINECAPS(_pD3D9Caps, _pWineCaps) \
_pWineCaps->DeviceType = (WINED3DDEVTYPE *) &_pD3D9Caps->DeviceType; \
_pWineCaps->AdapterOrdinal = &_pD3D9Caps->AdapterOrdinal; \
_pWineCaps->Caps = &_pD3D9Caps->Caps; \
_pWineCaps->Caps2 = &_pD3D9Caps->Caps2; \
_pWineCaps->Caps3 = &_pD3D9Caps->Caps3; \
_pWineCaps->PresentationIntervals = &_pD3D9Caps->PresentationIntervals; \
_pWineCaps->CursorCaps = &_pD3D9Caps->CursorCaps; \
_pWineCaps->DevCaps = &_pD3D9Caps->DevCaps; \
_pWineCaps->PrimitiveMiscCaps = &_pD3D9Caps->PrimitiveMiscCaps; \
_pWineCaps->RasterCaps = &_pD3D9Caps->RasterCaps; \
_pWineCaps->ZCmpCaps = &_pD3D9Caps->ZCmpCaps; \
_pWineCaps->SrcBlendCaps = &_pD3D9Caps->SrcBlendCaps; \
_pWineCaps->DestBlendCaps = &_pD3D9Caps->DestBlendCaps; \
_pWineCaps->AlphaCmpCaps = &_pD3D9Caps->AlphaCmpCaps; \
_pWineCaps->ShadeCaps = &_pD3D9Caps->ShadeCaps; \
_pWineCaps->TextureCaps = &_pD3D9Caps->TextureCaps; \
_pWineCaps->TextureFilterCaps = &_pD3D9Caps->TextureFilterCaps; \
_pWineCaps->CubeTextureFilterCaps = &_pD3D9Caps->CubeTextureFilterCaps; \
_pWineCaps->VolumeTextureFilterCaps = &_pD3D9Caps->VolumeTextureFilterCaps; \
_pWineCaps->TextureAddressCaps = &_pD3D9Caps->TextureAddressCaps; \
_pWineCaps->VolumeTextureAddressCaps = &_pD3D9Caps->VolumeTextureAddressCaps; \
_pWineCaps->LineCaps = &_pD3D9Caps->LineCaps; \
_pWineCaps->MaxTextureWidth = &_pD3D9Caps->MaxTextureWidth; \
_pWineCaps->MaxTextureHeight = &_pD3D9Caps->MaxTextureHeight; \
_pWineCaps->MaxVolumeExtent = &_pD3D9Caps->MaxVolumeExtent; \
_pWineCaps->MaxTextureRepeat = &_pD3D9Caps->MaxTextureRepeat; \
_pWineCaps->MaxTextureAspectRatio = &_pD3D9Caps->MaxTextureAspectRatio; \
_pWineCaps->MaxAnisotropy = &_pD3D9Caps->MaxAnisotropy; \
_pWineCaps->MaxVertexW = &_pD3D9Caps->MaxVertexW; \
_pWineCaps->GuardBandLeft = &_pD3D9Caps->GuardBandLeft; \
_pWineCaps->GuardBandTop = &_pD3D9Caps->GuardBandTop; \
_pWineCaps->GuardBandRight = &_pD3D9Caps->GuardBandRight; \
_pWineCaps->GuardBandBottom = &_pD3D9Caps->GuardBandBottom; \
_pWineCaps->ExtentsAdjust = &_pD3D9Caps->ExtentsAdjust; \
_pWineCaps->StencilCaps = &_pD3D9Caps->StencilCaps; \
_pWineCaps->FVFCaps = &_pD3D9Caps->FVFCaps; \
_pWineCaps->TextureOpCaps = &_pD3D9Caps->TextureOpCaps; \
_pWineCaps->MaxTextureBlendStages = &_pD3D9Caps->MaxTextureBlendStages; \
_pWineCaps->MaxSimultaneousTextures = &_pD3D9Caps->MaxSimultaneousTextures; \
_pWineCaps->VertexProcessingCaps = &_pD3D9Caps->VertexProcessingCaps; \
_pWineCaps->MaxActiveLights = &_pD3D9Caps->MaxActiveLights; \
_pWineCaps->MaxUserClipPlanes = &_pD3D9Caps->MaxUserClipPlanes; \
_pWineCaps->MaxVertexBlendMatrices = &_pD3D9Caps->MaxVertexBlendMatrices; \
_pWineCaps->MaxVertexBlendMatrixIndex = &_pD3D9Caps->MaxVertexBlendMatrixIndex; \
_pWineCaps->MaxPointSize = &_pD3D9Caps->MaxPointSize; \
_pWineCaps->MaxPrimitiveCount = &_pD3D9Caps->MaxPrimitiveCount; \
_pWineCaps->MaxVertexIndex = &_pD3D9Caps->MaxVertexIndex; \
_pWineCaps->MaxStreams = &_pD3D9Caps->MaxStreams; \
_pWineCaps->MaxStreamStride = &_pD3D9Caps->MaxStreamStride; \
_pWineCaps->VertexShaderVersion = &_pD3D9Caps->VertexShaderVersion; \
_pWineCaps->MaxVertexShaderConst = &_pD3D9Caps->MaxVertexShaderConst; \
_pWineCaps->PixelShaderVersion = &_pD3D9Caps->PixelShaderVersion; \
_pWineCaps->PixelShader1xMaxValue = &_pD3D9Caps->PixelShader1xMaxValue; \
_pWineCaps->DevCaps2 = &_pD3D9Caps->DevCaps2; \
_pWineCaps->MaxNpatchTessellationLevel = &_pD3D9Caps->MaxNpatchTessellationLevel; \
_pWineCaps->MasterAdapterOrdinal = &_pD3D9Caps->MasterAdapterOrdinal; \
_pWineCaps->AdapterOrdinalInGroup = &_pD3D9Caps->AdapterOrdinalInGroup; \
_pWineCaps->NumberOfAdaptersInGroup = &_pD3D9Caps->NumberOfAdaptersInGroup; \
_pWineCaps->DeclTypes = &_pD3D9Caps->DeclTypes; \
_pWineCaps->NumSimultaneousRTs = &_pD3D9Caps->NumSimultaneousRTs; \
_pWineCaps->StretchRectFilterCaps = &_pD3D9Caps->StretchRectFilterCaps; \
_pWineCaps->VS20Caps.Caps = &_pD3D9Caps->VS20Caps.Caps; \
_pWineCaps->VS20Caps.DynamicFlowControlDepth = &_pD3D9Caps->VS20Caps.DynamicFlowControlDepth; \
_pWineCaps->VS20Caps.NumTemps = &_pD3D9Caps->VS20Caps.NumTemps; \
_pWineCaps->VS20Caps.NumTemps = &_pD3D9Caps->VS20Caps.NumTemps; \
_pWineCaps->VS20Caps.StaticFlowControlDepth = &_pD3D9Caps->VS20Caps.StaticFlowControlDepth; \
_pWineCaps->PS20Caps.Caps = &_pD3D9Caps->PS20Caps.Caps; \
_pWineCaps->PS20Caps.DynamicFlowControlDepth = &_pD3D9Caps->PS20Caps.DynamicFlowControlDepth; \
_pWineCaps->PS20Caps.NumTemps = &_pD3D9Caps->PS20Caps.NumTemps; \
_pWineCaps->PS20Caps.StaticFlowControlDepth = &_pD3D9Caps->PS20Caps.StaticFlowControlDepth; \
_pWineCaps->PS20Caps.NumInstructionSlots = &_pD3D9Caps->PS20Caps.NumInstructionSlots; \
_pWineCaps->VertexTextureFilterCaps = &_pD3D9Caps->VertexTextureFilterCaps; \
_pWineCaps->MaxVShaderInstructionsExecuted = &_pD3D9Caps->MaxVShaderInstructionsExecuted; \
_pWineCaps->MaxPShaderInstructionsExecuted = &_pD3D9Caps->MaxPShaderInstructionsExecuted; \
_pWineCaps->MaxVertexShader30InstructionSlots = &_pD3D9Caps->MaxVertexShader30InstructionSlots; \
_pWineCaps->MaxPixelShader30InstructionSlots = &_pD3D9Caps->MaxPixelShader30InstructionSlots;
/* ===========================================================================
D3D9 interfactes
=========================================================================== */
/* ---------- */
/* IDirect3D9 */
/* ---------- */
/*****************************************************************************
* Predeclare the interface implementation structures
*/
extern const IDirect3D9Vtbl Direct3D9_Vtbl;
/*****************************************************************************
* IDirect3D implementation structure
*/
typedef struct IDirect3D9Impl
{
/* IUnknown fields */
const IDirect3D9Vtbl *lpVtbl;
LONG ref;
/* The WineD3D device */
IWineD3D *WineD3D;
} IDirect3D9Impl;
/* ---------------- */
/* IDirect3DDevice9 */
/* ---------------- */
/*****************************************************************************
* Predeclare the interface implementation structures
*/
extern const IDirect3DDevice9Vtbl Direct3DDevice9_Vtbl;
/*****************************************************************************
* IDirect3DDevice9 implementation structure
*/
typedef struct IDirect3DDevice9Impl
{
/* IUnknown fields */
const IDirect3DDevice9Vtbl *lpVtbl;
LONG ref;
/* IDirect3DDevice9 fields */
IWineD3DDevice *WineD3DDevice;
/* Avoids recursion with nested ReleaseRef to 0 */
BOOL inDestruction;
IDirect3DVertexDeclaration9 **convertedDecls;
unsigned int numConvertedDecls, declArraySize;
} IDirect3DDevice9Impl;
/* IDirect3DDevice9: */
extern HRESULT WINAPI IDirect3DDevice9Impl_GetDirect3D(LPDIRECT3DDEVICE9 iface, IDirect3D9** ppD3D9);
extern HRESULT WINAPI IDirect3DDevice9Impl_CreateAdditionalSwapChain(LPDIRECT3DDEVICE9 iface, D3DPRESENT_PARAMETERS* pPresentationParameters, IDirect3DSwapChain9** pSwapChain);
extern HRESULT WINAPI IDirect3DDevice9Impl_GetSwapChain(LPDIRECT3DDEVICE9 iface, UINT iSwapChain, IDirect3DSwapChain9** pSwapChain);
extern UINT WINAPI IDirect3DDevice9Impl_GetNumberOfSwapChains(LPDIRECT3DDEVICE9 iface);
extern HRESULT WINAPI IDirect3DDevice9Impl_CreateTexture(LPDIRECT3DDEVICE9 iface, UINT Width, UINT Height, UINT Levels, DWORD Usage, D3DFORMAT Format, D3DPOOL Pool, IDirect3DTexture9** ppTexture, HANDLE* pSharedHandle);
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);
extern HRESULT WINAPI IDirect3DDevice9Impl_CreateCubeTexture(LPDIRECT3DDEVICE9 iface, UINT EdgeLength, UINT Levels, DWORD Usage, D3DFORMAT Format, D3DPOOL Pool, IDirect3DCubeTexture9** ppCubeTexture, HANDLE* pSharedHandle);
extern HRESULT WINAPI IDirect3DDevice9Impl_CreateVertexBuffer(LPDIRECT3DDEVICE9 iface, UINT Length, DWORD Usage, DWORD FVF, D3DPOOL Pool, IDirect3DVertexBuffer9** ppVertexBuffer, HANDLE* pSharedHandle);
extern HRESULT WINAPI IDirect3DDevice9Impl_CreateIndexBuffer(LPDIRECT3DDEVICE9 iface, UINT Length, DWORD Usage, D3DFORMAT Format, D3DPOOL Pool, IDirect3DIndexBuffer9** ppIndexBuffer, HANDLE* pSharedHandle);
extern HRESULT WINAPI IDirect3DDevice9Impl_CreateStateBlock(LPDIRECT3DDEVICE9 iface, D3DSTATEBLOCKTYPE Type, IDirect3DStateBlock9** ppSB);
extern HRESULT WINAPI IDirect3DDevice9Impl_BeginStateBlock(LPDIRECT3DDEVICE9 iface);
extern HRESULT WINAPI IDirect3DDevice9Impl_EndStateBlock(LPDIRECT3DDEVICE9 iface, IDirect3DStateBlock9** ppSB);
extern HRESULT WINAPI IDirect3DDevice9Impl_CreateVertexDeclaration(LPDIRECT3DDEVICE9 iface, CONST D3DVERTEXELEMENT9* pVertexElements, IDirect3DVertexDeclaration9** ppDecl);
extern HRESULT WINAPI IDirect3DDevice9Impl_SetVertexDeclaration(LPDIRECT3DDEVICE9 iface, IDirect3DVertexDeclaration9* pDecl);
extern HRESULT WINAPI IDirect3DDevice9Impl_GetVertexDeclaration(LPDIRECT3DDEVICE9 iface, IDirect3DVertexDeclaration9** ppDecl);
extern HRESULT WINAPI IDirect3DDevice9Impl_SetFVF(LPDIRECT3DDEVICE9 iface, DWORD FVF);
extern HRESULT WINAPI IDirect3DDevice9Impl_GetFVF(LPDIRECT3DDEVICE9 iface, DWORD* pFVF);
extern HRESULT WINAPI IDirect3DDevice9Impl_CreateVertexShader(LPDIRECT3DDEVICE9 iface, CONST DWORD* pFunction, IDirect3DVertexShader9** ppShader);
extern HRESULT WINAPI IDirect3DDevice9Impl_SetVertexShader(LPDIRECT3DDEVICE9 iface, IDirect3DVertexShader9* pShader);
extern HRESULT WINAPI IDirect3DDevice9Impl_GetVertexShader(LPDIRECT3DDEVICE9 iface, IDirect3DVertexShader9** ppShader);
extern HRESULT WINAPI IDirect3DDevice9Impl_SetVertexShaderConstantF(LPDIRECT3DDEVICE9 iface, UINT StartRegister, CONST float* pConstantData, UINT Vector4fCount);
extern HRESULT WINAPI IDirect3DDevice9Impl_GetVertexShaderConstantF(LPDIRECT3DDEVICE9 iface, UINT StartRegister, float* pConstantData, UINT Vector4fCount);
extern HRESULT WINAPI IDirect3DDevice9Impl_SetVertexShaderConstantI(LPDIRECT3DDEVICE9 iface, UINT StartRegister, CONST int* pConstantData, UINT Vector4iCount);
extern HRESULT WINAPI IDirect3DDevice9Impl_GetVertexShaderConstantI(LPDIRECT3DDEVICE9 iface, UINT StartRegister, int* pConstantData, UINT Vector4iCount);
extern HRESULT WINAPI IDirect3DDevice9Impl_SetVertexShaderConstantB(LPDIRECT3DDEVICE9 iface, UINT StartRegister, CONST BOOL* pConstantData, UINT BoolCount);
extern HRESULT WINAPI IDirect3DDevice9Impl_GetVertexShaderConstantB(LPDIRECT3DDEVICE9 iface, UINT StartRegister, BOOL* pConstantData, UINT BoolCount);
extern HRESULT WINAPI IDirect3DDevice9Impl_SetStreamSource(LPDIRECT3DDEVICE9 iface, UINT StreamNumber, IDirect3DVertexBuffer9* pStreamData, UINT OffsetInBytes, UINT Stride);
extern HRESULT WINAPI IDirect3DDevice9Impl_GetStreamSource(LPDIRECT3DDEVICE9 iface, UINT StreamNumber, IDirect3DVertexBuffer9** ppStreamData, UINT* OffsetInBytes, UINT* pStride);
extern HRESULT WINAPI IDirect3DDevice9Impl_CreatePixelShader(LPDIRECT3DDEVICE9 iface, CONST DWORD* pFunction, IDirect3DPixelShader9** ppShader);
extern HRESULT WINAPI IDirect3DDevice9Impl_SetPixelShader(LPDIRECT3DDEVICE9 iface, IDirect3DPixelShader9* pShader);
extern HRESULT WINAPI IDirect3DDevice9Impl_GetPixelShader(LPDIRECT3DDEVICE9 iface, IDirect3DPixelShader9** ppShader);
extern HRESULT WINAPI IDirect3DDevice9Impl_SetPixelShaderConstantF(LPDIRECT3DDEVICE9 iface, UINT StartRegister, CONST float* pConstantData, UINT Vector4fCount);
extern HRESULT WINAPI IDirect3DDevice9Impl_GetPixelShaderConstantF(LPDIRECT3DDEVICE9 iface, UINT StartRegister, float* pConstantData, UINT Vector4fCount);
extern HRESULT WINAPI IDirect3DDevice9Impl_SetPixelShaderConstantI(LPDIRECT3DDEVICE9 iface, UINT StartRegister, CONST int* pConstantData, UINT Vector4iCount);
extern HRESULT WINAPI IDirect3DDevice9Impl_GetPixelShaderConstantI(LPDIRECT3DDEVICE9 iface, UINT StartRegister, int* pConstantData, UINT Vector4iCount);
extern HRESULT WINAPI IDirect3DDevice9Impl_SetPixelShaderConstantB(LPDIRECT3DDEVICE9 iface, UINT StartRegister, CONST BOOL* pConstantData, UINT BoolCount);
extern HRESULT WINAPI IDirect3DDevice9Impl_GetPixelShaderConstantB(LPDIRECT3DDEVICE9 iface, UINT StartRegister, BOOL* pConstantData, UINT BoolCount);
extern HRESULT WINAPI IDirect3DDevice9Impl_CreateQuery(LPDIRECT3DDEVICE9 iface, D3DQUERYTYPE Type, IDirect3DQuery9** ppQuery);
/* ---------------- */
/* IDirect3DVolume9 */
/* ---------------- */
/*****************************************************************************
* IDirect3DVolume9 implementation structure
*/
typedef struct IDirect3DVolume9Impl
{
/* IUnknown fields */
const IDirect3DVolume9Vtbl *lpVtbl;
LONG ref;
/* IDirect3DVolume9 fields */
IWineD3DVolume *wineD3DVolume;
/* The volume container */
IUnknown *container;
/* If set forward refcounting to this object */
IUnknown *forwardReference;
} IDirect3DVolume9Impl;
/* ------------------- */
/* IDirect3DSwapChain9 */
/* ------------------- */
/*****************************************************************************
* IDirect3DSwapChain9 implementation structure
*/
typedef struct IDirect3DSwapChain9Impl
{
/* IUnknown fields */
const IDirect3DSwapChain9Vtbl *lpVtbl;
LONG ref;
/* IDirect3DSwapChain9 fields */
IWineD3DSwapChain *wineD3DSwapChain;
/* Parent reference */
LPDIRECT3DDEVICE9 parentDevice;
/* Flags an implicit swap chain */
BOOL isImplicit;
} IDirect3DSwapChain9Impl;
/* ------------------ */
/* IDirect3DResource9 */
/* ------------------ */
/*****************************************************************************
* IDirect3DResource9 implementation structure
*/
typedef struct IDirect3DResource9Impl
{
/* IUnknown fields */
const IDirect3DResource9Vtbl *lpVtbl;
LONG ref;
/* IDirect3DResource9 fields */
IWineD3DResource *wineD3DResource;
} IDirect3DResource9Impl;
extern HRESULT WINAPI IDirect3DResource9Impl_GetDevice(LPDIRECT3DRESOURCE9 iface, IDirect3DDevice9** ppDevice);
/* ----------------- */
/* IDirect3DSurface9 */
/* ----------------- */
/*****************************************************************************
* Predeclare the interface implementation structures
*/
extern const IDirect3DSurface9Vtbl Direct3DSurface9_Vtbl;
/*****************************************************************************
* IDirect3DSurface9 implementation structure
*/
typedef struct IDirect3DSurface9Impl
{
/* IUnknown fields */
const IDirect3DSurface9Vtbl *lpVtbl;
LONG ref;
/* IDirect3DResource9 fields */
IWineD3DSurface *wineD3DSurface;
/* Parent reference */
LPDIRECT3DDEVICE9 parentDevice;
/* The surface container */
IUnknown *container;
/* If set forward refcounting to this object */
IUnknown *forwardReference;
/* Flags an implicit surface */
BOOL isImplicit;
} IDirect3DSurface9Impl;
/* ---------------------- */
/* IDirect3DVertexBuffer9 */
/* ---------------------- */
/*****************************************************************************
* IDirect3DVertexBuffer9 implementation structure
*/
typedef struct IDirect3DVertexBuffer9Impl
{
/* IUnknown fields */
const IDirect3DVertexBuffer9Vtbl *lpVtbl;
LONG ref;
/* IDirect3DResource9 fields */
IWineD3DVertexBuffer *wineD3DVertexBuffer;
/* Parent reference */
LPDIRECT3DDEVICE9 parentDevice;
} IDirect3DVertexBuffer9Impl;
/* --------------------- */
/* IDirect3DIndexBuffer9 */
/* --------------------- */
/*****************************************************************************
* IDirect3DIndexBuffer9 implementation structure
*/
typedef struct IDirect3DIndexBuffer9Impl
{
/* IUnknown fields */
const IDirect3DIndexBuffer9Vtbl *lpVtbl;
LONG ref;
/* IDirect3DResource9 fields */
IWineD3DIndexBuffer *wineD3DIndexBuffer;
/* Parent reference */
LPDIRECT3DDEVICE9 parentDevice;
} IDirect3DIndexBuffer9Impl;
/* --------------------- */
/* IDirect3DBaseTexture9 */
/* --------------------- */
/*****************************************************************************
* IDirect3DBaseTexture9 implementation structure
*/
typedef struct IDirect3DBaseTexture9Impl
{
/* IUnknown fields */
const IDirect3DBaseTexture9Vtbl *lpVtbl;
LONG ref;
/* IDirect3DResource9 fields */
IWineD3DBaseTexture *wineD3DBaseTexture;
} IDirect3DBaseTexture9Impl;
extern DWORD WINAPI IDirect3DBaseTexture9Impl_GetLOD(LPDIRECT3DBASETEXTURE9 iface);
/* --------------------- */
/* IDirect3DCubeTexture9 */
/* --------------------- */
/*****************************************************************************
* IDirect3DCubeTexture9 implementation structure
*/
typedef struct IDirect3DCubeTexture9Impl
{
/* IUnknown fields */
const IDirect3DCubeTexture9Vtbl *lpVtbl;
LONG ref;
/* IDirect3DResource9 fields */
IWineD3DCubeTexture *wineD3DCubeTexture;
/* Parent reference */
LPDIRECT3DDEVICE9 parentDevice;
} IDirect3DCubeTexture9Impl;
/* ----------------- */
/* IDirect3DTexture9 */
/* ----------------- */
/*****************************************************************************
* IDirect3DTexture9 implementation structure
*/
typedef struct IDirect3DTexture9Impl
{
/* IUnknown fields */
const IDirect3DTexture9Vtbl *lpVtbl;
LONG ref;
/* IDirect3DResource9 fields */
IWineD3DTexture *wineD3DTexture;
/* Parent reference */
LPDIRECT3DDEVICE9 parentDevice;
} IDirect3DTexture9Impl;
/* ----------------------- */
/* IDirect3DVolumeTexture9 */
/* ----------------------- */
/*****************************************************************************
* IDirect3DVolumeTexture9 implementation structure
*/
typedef struct IDirect3DVolumeTexture9Impl
{
/* IUnknown fields */
const IDirect3DVolumeTexture9Vtbl *lpVtbl;
LONG ref;
/* IDirect3DResource9 fields */
IWineD3DVolumeTexture *wineD3DVolumeTexture;
/* Parent reference */
LPDIRECT3DDEVICE9 parentDevice;
} IDirect3DVolumeTexture9Impl;
/* ----------------------- */
/* IDirect3DStateBlock9 */
/* ----------------------- */
/*****************************************************************************
* IDirect3DStateBlock9 implementation structure
*/
typedef struct IDirect3DStateBlock9Impl {
/* IUnknown fields */
const IDirect3DStateBlock9Vtbl *lpVtbl;
LONG ref;
/* IDirect3DStateBlock9 fields */
IWineD3DStateBlock *wineD3DStateBlock;
/* Parent reference */
LPDIRECT3DDEVICE9 parentDevice;
} IDirect3DStateBlock9Impl;
/* --------------------------- */
/* IDirect3DVertexDeclaration9 */
/* --------------------------- */
/*****************************************************************************
* IDirect3DVertexDeclaration implementation structure
*/
typedef struct IDirect3DVertexDeclaration9Impl {
/* IUnknown fields */
const IDirect3DVertexDeclaration9Vtbl *lpVtbl;
LONG ref;
D3DVERTEXELEMENT9 *elements;
size_t element_count;
/* IDirect3DVertexDeclaration9 fields */
IWineD3DVertexDeclaration *wineD3DVertexDeclaration;
DWORD convFVF;
/* Parent reference */
LPDIRECT3DDEVICE9 parentDevice;
} IDirect3DVertexDeclaration9Impl;
void IDirect3DVertexDeclaration9Impl_Destroy(LPDIRECT3DVERTEXDECLARATION9 iface);
/* ---------------------- */
/* IDirect3DVertexShader9 */
/* ---------------------- */
/*****************************************************************************
* IDirect3DVertexShader implementation structure
*/
typedef struct IDirect3DVertexShader9Impl {
/* IUnknown fields */
const IDirect3DVertexShader9Vtbl *lpVtbl;
LONG ref;
/* IDirect3DVertexShader9 fields */
IWineD3DVertexShader *wineD3DVertexShader;
/* Parent reference */
LPDIRECT3DDEVICE9 parentDevice;
} IDirect3DVertexShader9Impl;
/* --------------------- */
/* IDirect3DPixelShader9 */
/* --------------------- */
/*****************************************************************************
* IDirect3DPixelShader implementation structure
*/
typedef struct IDirect3DPixelShader9Impl {
/* IUnknown fields */
const IDirect3DPixelShader9Vtbl *lpVtbl;
LONG ref;
/* IDirect3DPixelShader9 fields */
IWineD3DPixelShader *wineD3DPixelShader;
/* Parent reference */
LPDIRECT3DDEVICE9 parentDevice;
} IDirect3DPixelShader9Impl;
/* --------------- */
/* IDirect3DQuery9 */
/* --------------- */
/*****************************************************************************
* IDirect3DPixelShader implementation structure
*/
typedef struct IDirect3DQuery9Impl {
/* IUnknown fields */
const IDirect3DQuery9Vtbl *lpVtbl;
LONG ref;
/* IDirect3DQuery9 fields */
IWineD3DQuery *wineD3DQuery;
/* Parent reference */
LPDIRECT3DDEVICE9 parentDevice;
} IDirect3DQuery9Impl;
/* Callbacks */
extern HRESULT WINAPI D3D9CB_CreateSurface(IUnknown *device, IUnknown *pSuperior, UINT Width, UINT Height,
WINED3DFORMAT Format, DWORD Usage, WINED3DPOOL Pool, UINT Level,
IWineD3DSurface** ppSurface, HANDLE* pSharedHandle);
extern HRESULT WINAPI D3D9CB_CreateVolume(IUnknown *pDevice, IUnknown *pSuperior, UINT Width, UINT Height, UINT Depth,
WINED3DFORMAT Format, WINED3DPOOL Pool, DWORD Usage,
IWineD3DVolume **ppVolume,
HANDLE * pSharedHandle);
extern HRESULT WINAPI D3D9CB_CreateDepthStencilSurface(IUnknown *device, IUnknown *pSuperior, UINT Width, UINT Height,
WINED3DFORMAT Format, WINED3DMULTISAMPLE_TYPE MultiSample,
DWORD MultisampleQuality, BOOL Discard,
IWineD3DSurface** ppSurface, HANDLE* pSharedHandle);
extern HRESULT WINAPI D3D9CB_CreateRenderTarget(IUnknown *device, IUnknown *pSuperior, UINT Width, UINT Height,
WINED3DFORMAT Format, WINED3DMULTISAMPLE_TYPE MultiSample,
DWORD MultisampleQuality, BOOL Lockable,
IWineD3DSurface** ppSurface, HANDLE* pSharedHandle);
extern ULONG WINAPI D3D9CB_DestroySwapChain (IWineD3DSwapChain *pSwapChain);
extern ULONG WINAPI D3D9CB_DestroyDepthStencilSurface (IWineD3DSurface *pSurface);
extern ULONG WINAPI D3D9CB_DestroyRenderTarget (IWineD3DSurface *pSurface);
extern ULONG WINAPI D3D9CB_DestroySurface(IWineD3DSurface *pSurface);
extern ULONG WINAPI D3D9CB_DestroyVolume(IWineD3DVolume *pVolume);
#endif /* __WINE_D3D9_PRIVATE_H */

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,434 @@
/*
* IDirect3D9 implementation
*
* Copyright 2002 Jason Edmeades
* Copyright 2005 Oliver Stieber
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "config.h"
#include "d3d9_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(d3d9);
/* IDirect3D9 IUnknown parts follow: */
static HRESULT WINAPI IDirect3D9Impl_QueryInterface(LPDIRECT3D9 iface, REFIID riid, LPVOID* ppobj)
{
IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
if (IsEqualGUID(riid, &IID_IUnknown)
|| IsEqualGUID(riid, &IID_IDirect3D9)) {
IUnknown_AddRef(iface);
*ppobj = This;
return S_OK;
}
WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);
*ppobj = NULL;
return E_NOINTERFACE;
}
static ULONG WINAPI IDirect3D9Impl_AddRef(LPDIRECT3D9 iface) {
IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
ULONG ref = InterlockedIncrement(&This->ref);
TRACE("(%p) : AddRef from %d\n", This, ref - 1);
return ref;
}
static ULONG WINAPI IDirect3D9Impl_Release(LPDIRECT3D9 iface) {
IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
ULONG ref = InterlockedDecrement(&This->ref);
TRACE("(%p) : ReleaseRef to %d\n", This, ref);
if (ref == 0) {
IWineD3D_Release(This->WineD3D);
HeapFree(GetProcessHeap(), 0, This);
}
return ref;
}
/* IDirect3D9 Interface follow: */
static HRESULT WINAPI IDirect3D9Impl_RegisterSoftwareDevice(LPDIRECT3D9 iface, void* pInitializeFunction) {
IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
return IWineD3D_RegisterSoftwareDevice(This->WineD3D, pInitializeFunction);
}
static UINT WINAPI IDirect3D9Impl_GetAdapterCount(LPDIRECT3D9 iface) {
IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
return IWineD3D_GetAdapterCount(This->WineD3D);
}
static HRESULT WINAPI IDirect3D9Impl_GetAdapterIdentifier(LPDIRECT3D9 iface, UINT Adapter, DWORD Flags, D3DADAPTER_IDENTIFIER9* pIdentifier) {
IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
WINED3DADAPTER_IDENTIFIER adapter_id;
/* dx8 and dx9 have different structures to be filled in, with incompatible
layouts so pass in pointers to the places to be filled via an internal
structure */
adapter_id.Driver = pIdentifier->Driver;
adapter_id.Description = pIdentifier->Description;
adapter_id.DeviceName = pIdentifier->DeviceName;
adapter_id.DriverVersion = &pIdentifier->DriverVersion;
adapter_id.VendorId = &pIdentifier->VendorId;
adapter_id.DeviceId = &pIdentifier->DeviceId;
adapter_id.SubSysId = &pIdentifier->SubSysId;
adapter_id.Revision = &pIdentifier->Revision;
adapter_id.DeviceIdentifier = &pIdentifier->DeviceIdentifier;
adapter_id.WHQLLevel = &pIdentifier->WHQLLevel;
return IWineD3D_GetAdapterIdentifier(This->WineD3D, Adapter, Flags, &adapter_id);
}
static UINT WINAPI IDirect3D9Impl_GetAdapterModeCount(LPDIRECT3D9 iface, UINT Adapter, D3DFORMAT Format) {
IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
/* Others than that not supported by d3d9, but reported by wined3d for ddraw. Filter them out */
if(Format != D3DFMT_X8R8G8B8 && Format != D3DFMT_R5G6B5) {
return 0;
}
return IWineD3D_GetAdapterModeCount(This->WineD3D, Adapter, Format);
}
static HRESULT WINAPI IDirect3D9Impl_EnumAdapterModes(LPDIRECT3D9 iface, UINT Adapter, D3DFORMAT Format, UINT Mode, D3DDISPLAYMODE* pMode) {
IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
/* We can't pass this to WineD3D, otherwise it'll think it came from D3D8 or DDraw.
It's supposed to fail anyway, so no harm returning failure. */
if(Format != WINED3DFMT_X8R8G8B8 && Format != WINED3DFMT_R5G6B5)
return D3DERR_INVALIDCALL;
return IWineD3D_EnumAdapterModes(This->WineD3D, Adapter, Format, Mode, (WINED3DDISPLAYMODE *) pMode);
}
static HRESULT WINAPI IDirect3D9Impl_GetAdapterDisplayMode(LPDIRECT3D9 iface, UINT Adapter, D3DDISPLAYMODE* pMode) {
IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
return IWineD3D_GetAdapterDisplayMode(This->WineD3D, Adapter, (WINED3DDISPLAYMODE *) pMode);
}
static HRESULT WINAPI IDirect3D9Impl_CheckDeviceType(LPDIRECT3D9 iface,
UINT Adapter, D3DDEVTYPE CheckType, D3DFORMAT DisplayFormat,
D3DFORMAT BackBufferFormat, BOOL Windowed) {
IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
return IWineD3D_CheckDeviceType(This->WineD3D, Adapter, CheckType, DisplayFormat,
BackBufferFormat, Windowed);
}
static HRESULT WINAPI IDirect3D9Impl_CheckDeviceFormat(LPDIRECT3D9 iface,
UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT AdapterFormat,
DWORD Usage, D3DRESOURCETYPE RType, D3DFORMAT CheckFormat) {
IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
return IWineD3D_CheckDeviceFormat(This->WineD3D, Adapter, DeviceType, AdapterFormat,
Usage, RType, CheckFormat);
}
static HRESULT WINAPI IDirect3D9Impl_CheckDeviceMultiSampleType(LPDIRECT3D9 iface,
UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT SurfaceFormat,
BOOL Windowed, D3DMULTISAMPLE_TYPE MultiSampleType, DWORD* pQualityLevels) {
IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
return IWineD3D_CheckDeviceMultiSampleType(This->WineD3D, Adapter, DeviceType, SurfaceFormat,
Windowed, MultiSampleType, pQualityLevels);
}
static HRESULT WINAPI IDirect3D9Impl_CheckDepthStencilMatch(LPDIRECT3D9 iface,
UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT AdapterFormat,
D3DFORMAT RenderTargetFormat, D3DFORMAT DepthStencilFormat) {
IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
return IWineD3D_CheckDepthStencilMatch(This->WineD3D, Adapter, DeviceType, AdapterFormat,
RenderTargetFormat, DepthStencilFormat);
}
static HRESULT WINAPI IDirect3D9Impl_CheckDeviceFormatConversion(LPDIRECT3D9 iface, UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT SourceFormat, D3DFORMAT TargetFormat) {
IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
return IWineD3D_CheckDeviceFormatConversion(This->WineD3D, Adapter, DeviceType, SourceFormat,
TargetFormat);
}
static HRESULT WINAPI IDirect3D9Impl_GetDeviceCaps(LPDIRECT3D9 iface, UINT Adapter, D3DDEVTYPE DeviceType, D3DCAPS9* pCaps) {
IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
HRESULT hrc = D3D_OK;
WINED3DCAPS *pWineCaps;
TRACE("(%p) Relay %d %u %p\n", This, Adapter, DeviceType, pCaps);
if(NULL == pCaps){
return D3DERR_INVALIDCALL;
}
pWineCaps = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(WINED3DCAPS));
if(pWineCaps == NULL){
return D3DERR_INVALIDCALL; /*well this is what MSDN says to return*/
}
D3D9CAPSTOWINECAPS(pCaps, pWineCaps)
hrc = IWineD3D_GetDeviceCaps(This->WineD3D, Adapter, DeviceType, pWineCaps);
HeapFree(GetProcessHeap(), 0, pWineCaps);
/* Some functionality is implemented in d3d9.dll, not wined3d.dll. Add the needed caps */
pCaps->DevCaps2 |= D3DDEVCAPS2_CAN_STRETCHRECT_FROM_TEXTURES;
TRACE("(%p) returning %p\n", This, pCaps);
return hrc;
}
static HMONITOR WINAPI IDirect3D9Impl_GetAdapterMonitor(LPDIRECT3D9 iface, UINT Adapter) {
IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
return IWineD3D_GetAdapterMonitor(This->WineD3D, Adapter);
}
/* Internal function called back during the CreateDevice to create a render target */
HRESULT WINAPI D3D9CB_CreateRenderTarget(IUnknown *device, IUnknown *pSuperior, UINT Width, UINT Height,
WINED3DFORMAT Format, WINED3DMULTISAMPLE_TYPE MultiSample,
DWORD MultisampleQuality, BOOL Lockable,
IWineD3DSurface** ppSurface, HANDLE* pSharedHandle) {
HRESULT res = D3D_OK;
IDirect3DSurface9Impl *d3dSurface = NULL;
TRACE("(%p) call back\n", device);
res = IDirect3DDevice9_CreateRenderTarget((IDirect3DDevice9 *)device, Width, Height,
(D3DFORMAT)Format, MultiSample, MultisampleQuality, Lockable,
(IDirect3DSurface9 **)&d3dSurface, pSharedHandle);
if (SUCCEEDED(res)) {
*ppSurface = d3dSurface->wineD3DSurface;
d3dSurface->container = pSuperior;
d3dSurface->isImplicit = TRUE;
/* Implicit surfaces are created with an refcount of 0 */
IUnknown_Release((IUnknown *)d3dSurface);
} else {
*ppSurface = NULL;
}
return res;
}
ULONG WINAPI D3D9CB_DestroyRenderTarget(IWineD3DSurface *pSurface) {
IDirect3DSurface9Impl* surfaceParent;
TRACE("(%p) call back\n", pSurface);
IWineD3DSurface_GetParent(pSurface, (IUnknown **) &surfaceParent);
surfaceParent->isImplicit = FALSE;
/* Surface had refcount of 0 GetParent addrefed to 1, so 1 Release is enough */
return IDirect3DSurface9_Release((IDirect3DSurface9*) surfaceParent);
}
static HRESULT WINAPI D3D9CB_CreateAdditionalSwapChain(IUnknown *device,
WINED3DPRESENT_PARAMETERS* pPresentationParameters,
IWineD3DSwapChain ** ppSwapChain) {
HRESULT res = D3D_OK;
IDirect3DSwapChain9Impl *d3dSwapChain = NULL;
D3DPRESENT_PARAMETERS localParameters;
TRACE("(%p) call back\n", device);
/* Copy the presentation parameters */
localParameters.BackBufferWidth = pPresentationParameters->BackBufferWidth;
localParameters.BackBufferHeight = pPresentationParameters->BackBufferHeight;
localParameters.BackBufferFormat = pPresentationParameters->BackBufferFormat;
localParameters.BackBufferCount = pPresentationParameters->BackBufferCount;
localParameters.MultiSampleType = pPresentationParameters->MultiSampleType;
localParameters.MultiSampleQuality = pPresentationParameters->MultiSampleQuality;
localParameters.SwapEffect = pPresentationParameters->SwapEffect;
localParameters.hDeviceWindow = pPresentationParameters->hDeviceWindow;
localParameters.Windowed = pPresentationParameters->Windowed;
localParameters.EnableAutoDepthStencil = pPresentationParameters->EnableAutoDepthStencil;
localParameters.AutoDepthStencilFormat = pPresentationParameters->AutoDepthStencilFormat;
localParameters.Flags = pPresentationParameters->Flags;
localParameters.FullScreen_RefreshRateInHz = pPresentationParameters->FullScreen_RefreshRateInHz;
localParameters.PresentationInterval = pPresentationParameters->PresentationInterval;
res = IDirect3DDevice9_CreateAdditionalSwapChain((IDirect3DDevice9 *)device, &localParameters, (IDirect3DSwapChain9 **)&d3dSwapChain);
if (SUCCEEDED(res)) {
*ppSwapChain = d3dSwapChain->wineD3DSwapChain;
d3dSwapChain->isImplicit = TRUE;
/* Implicit swap chains are created with an refcount of 0 */
IUnknown_Release((IUnknown *)d3dSwapChain);
} else {
*ppSwapChain = NULL;
}
/* Copy back the presentation parameters */
pPresentationParameters->BackBufferWidth = localParameters.BackBufferWidth;
pPresentationParameters->BackBufferHeight = localParameters.BackBufferHeight;
pPresentationParameters->BackBufferFormat = localParameters.BackBufferFormat;
pPresentationParameters->BackBufferCount = localParameters.BackBufferCount;
pPresentationParameters->MultiSampleType = localParameters.MultiSampleType;
pPresentationParameters->MultiSampleQuality = localParameters.MultiSampleQuality;
pPresentationParameters->SwapEffect = localParameters.SwapEffect;
pPresentationParameters->hDeviceWindow = localParameters.hDeviceWindow;
pPresentationParameters->Windowed = localParameters.Windowed;
pPresentationParameters->EnableAutoDepthStencil = localParameters.EnableAutoDepthStencil;
pPresentationParameters->AutoDepthStencilFormat = localParameters.AutoDepthStencilFormat;
pPresentationParameters->Flags = localParameters.Flags;
pPresentationParameters->FullScreen_RefreshRateInHz = localParameters.FullScreen_RefreshRateInHz;
pPresentationParameters->PresentationInterval = localParameters.PresentationInterval;
return res;
}
ULONG WINAPI D3D9CB_DestroySwapChain(IWineD3DSwapChain *pSwapChain) {
IDirect3DSwapChain9Impl* swapChainParent;
TRACE("(%p) call back\n", pSwapChain);
IWineD3DSwapChain_GetParent(pSwapChain,(IUnknown **) &swapChainParent);
swapChainParent->isImplicit = FALSE;
/* Swap chain had refcount of 0 GetParent addrefed to 1, so 1 Release is enough */
return IDirect3DSwapChain9_Release((IDirect3DSwapChain9*) swapChainParent);
}
/* Internal function called back during the CreateDevice to create a render target */
HRESULT WINAPI D3D9CB_CreateDepthStencilSurface(IUnknown *device, IUnknown *pSuperior, UINT Width, UINT Height,
WINED3DFORMAT Format, WINED3DMULTISAMPLE_TYPE MultiSample,
DWORD MultisampleQuality, BOOL Discard,
IWineD3DSurface** ppSurface, HANDLE* pSharedHandle) {
HRESULT res = D3D_OK;
IDirect3DSurface9Impl *d3dSurface = NULL;
TRACE("(%p) call back\n", device);
res = IDirect3DDevice9_CreateDepthStencilSurface((IDirect3DDevice9 *)device, Width, Height,
(D3DFORMAT)Format, MultiSample, MultisampleQuality, Discard,
(IDirect3DSurface9 **)&d3dSurface, pSharedHandle);
if (SUCCEEDED(res)) {
*ppSurface = d3dSurface->wineD3DSurface;
d3dSurface->container = device;
d3dSurface->isImplicit = TRUE;
/* Implicit surfaces are created with an refcount of 0 */
IUnknown_Release((IUnknown *)d3dSurface);
}
return res;
}
ULONG WINAPI D3D9CB_DestroyDepthStencilSurface(IWineD3DSurface *pSurface) {
IDirect3DSurface9Impl* surfaceParent;
TRACE("(%p) call back\n", pSurface);
IWineD3DSurface_GetParent(pSurface, (IUnknown **) &surfaceParent);
surfaceParent->isImplicit = FALSE;
/* Surface had refcount of 0 GetParent addrefed to 1, so 1 Release is enough */
return IDirect3DSurface9_Release((IDirect3DSurface9*) surfaceParent);
}
static HRESULT WINAPI IDirect3D9Impl_CreateDevice(LPDIRECT3D9 iface, UINT Adapter, D3DDEVTYPE DeviceType,
HWND hFocusWindow, DWORD BehaviourFlags,
D3DPRESENT_PARAMETERS* pPresentationParameters,
IDirect3DDevice9** ppReturnedDeviceInterface) {
IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
IDirect3DDevice9Impl *object = NULL;
WINED3DPRESENT_PARAMETERS localParameters;
HRESULT hr;
TRACE("(%p) Relay\n", This);
/* Check the validity range of the adapter parameter */
if (Adapter >= IDirect3D9Impl_GetAdapterCount(iface)) {
*ppReturnedDeviceInterface = NULL;
return D3DERR_INVALIDCALL;
}
/* Allocate the storage for the device object */
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3DDevice9Impl));
if (NULL == object) {
FIXME("Allocation of memory failed\n");
*ppReturnedDeviceInterface = NULL;
return D3DERR_OUTOFVIDEOMEMORY;
}
object->lpVtbl = &Direct3DDevice9_Vtbl;
object->ref = 1;
*ppReturnedDeviceInterface = (IDirect3DDevice9 *)object;
/* Allocate an associated WineD3DDevice object */
hr =IWineD3D_CreateDevice(This->WineD3D, Adapter, DeviceType, hFocusWindow, BehaviourFlags, &object->WineD3DDevice, (IUnknown *)object);
if (hr != D3D_OK) {
HeapFree(GetProcessHeap(), 0, object);
*ppReturnedDeviceInterface = NULL;
return hr;
}
TRACE("(%p) : Created Device %p\n", This, object);
localParameters.BackBufferWidth = pPresentationParameters->BackBufferWidth;
localParameters.BackBufferHeight = pPresentationParameters->BackBufferHeight;
localParameters.BackBufferFormat = pPresentationParameters->BackBufferFormat;
localParameters.BackBufferCount = pPresentationParameters->BackBufferCount;
localParameters.MultiSampleType = pPresentationParameters->MultiSampleType;
localParameters.MultiSampleQuality = pPresentationParameters->MultiSampleQuality;
localParameters.SwapEffect = pPresentationParameters->SwapEffect;
localParameters.hDeviceWindow = pPresentationParameters->hDeviceWindow;
localParameters.Windowed = pPresentationParameters->Windowed;
localParameters.EnableAutoDepthStencil = pPresentationParameters->EnableAutoDepthStencil;
localParameters.AutoDepthStencilFormat = pPresentationParameters->AutoDepthStencilFormat;
localParameters.Flags = pPresentationParameters->Flags;
localParameters.FullScreen_RefreshRateInHz = pPresentationParameters->FullScreen_RefreshRateInHz;
localParameters.PresentationInterval = pPresentationParameters->PresentationInterval;
if(BehaviourFlags & D3DCREATE_MULTITHREADED) {
IWineD3DDevice_SetMultithreaded(object->WineD3DDevice);
}
hr = IWineD3DDevice_Init3D(object->WineD3DDevice, &localParameters, D3D9CB_CreateAdditionalSwapChain);
pPresentationParameters->BackBufferWidth = localParameters.BackBufferWidth;
pPresentationParameters->BackBufferHeight = localParameters.BackBufferHeight;
pPresentationParameters->BackBufferFormat = localParameters.BackBufferFormat;
pPresentationParameters->BackBufferCount = localParameters.BackBufferCount;
pPresentationParameters->MultiSampleType = localParameters.MultiSampleType;
pPresentationParameters->MultiSampleQuality = localParameters.MultiSampleQuality;
pPresentationParameters->SwapEffect = localParameters.SwapEffect;
pPresentationParameters->hDeviceWindow = localParameters.hDeviceWindow;
pPresentationParameters->Windowed = localParameters.Windowed;
pPresentationParameters->EnableAutoDepthStencil = localParameters.EnableAutoDepthStencil;
pPresentationParameters->AutoDepthStencilFormat = localParameters.AutoDepthStencilFormat;
pPresentationParameters->Flags = localParameters.Flags;
pPresentationParameters->FullScreen_RefreshRateInHz = localParameters.FullScreen_RefreshRateInHz;
pPresentationParameters->PresentationInterval = localParameters.PresentationInterval;
if (hr != D3D_OK) {
FIXME("(%p) D3D Initialization failed for WineD3DDevice %p\n", This, object->WineD3DDevice);
HeapFree(GetProcessHeap(), 0, object);
*ppReturnedDeviceInterface = NULL;
}
/* Initialize the converted declaration array. This creates a valid pointer and when adding decls HeapReAlloc
* can be used without further checking
*/
object->convertedDecls = HeapAlloc(GetProcessHeap(), 0, 0);
return hr;
}
const IDirect3D9Vtbl Direct3D9_Vtbl =
{
/* IUnknown */
IDirect3D9Impl_QueryInterface,
IDirect3D9Impl_AddRef,
IDirect3D9Impl_Release,
/* IDirect3D9 */
IDirect3D9Impl_RegisterSoftwareDevice,
IDirect3D9Impl_GetAdapterCount,
IDirect3D9Impl_GetAdapterIdentifier,
IDirect3D9Impl_GetAdapterModeCount,
IDirect3D9Impl_EnumAdapterModes,
IDirect3D9Impl_GetAdapterDisplayMode,
IDirect3D9Impl_CheckDeviceType,
IDirect3D9Impl_CheckDeviceFormat,
IDirect3D9Impl_CheckDeviceMultiSampleType,
IDirect3D9Impl_CheckDepthStencilMatch,
IDirect3D9Impl_CheckDeviceFormatConversion,
IDirect3D9Impl_GetDeviceCaps,
IDirect3D9Impl_GetAdapterMonitor,
IDirect3D9Impl_CreateDevice
};

View File

@@ -0,0 +1,191 @@
/*
* IDirect3DIndexBuffer9 implementation
*
* Copyright 2002-2004 Jason Edmeades
* Raphael Junqueira
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "config.h"
#include "d3d9_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(d3d9);
/* IDirect3DIndexBuffer9 IUnknown parts follow: */
static HRESULT WINAPI IDirect3DIndexBuffer9Impl_QueryInterface(LPDIRECT3DINDEXBUFFER9 iface, REFIID riid, LPVOID* ppobj) {
IDirect3DIndexBuffer9Impl *This = (IDirect3DIndexBuffer9Impl *)iface;
if (IsEqualGUID(riid, &IID_IUnknown)
|| IsEqualGUID(riid, &IID_IDirect3DResource9)
|| IsEqualGUID(riid, &IID_IDirect3DIndexBuffer9)) {
IUnknown_AddRef(iface);
*ppobj = This;
return S_OK;
}
WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);
*ppobj = NULL;
return E_NOINTERFACE;
}
static ULONG WINAPI IDirect3DIndexBuffer9Impl_AddRef(LPDIRECT3DINDEXBUFFER9 iface) {
IDirect3DIndexBuffer9Impl *This = (IDirect3DIndexBuffer9Impl *)iface;
ULONG ref = InterlockedIncrement(&This->ref);
TRACE("(%p) : AddRef from %d\n", This, ref - 1);
return ref;
}
static ULONG WINAPI IDirect3DIndexBuffer9Impl_Release(LPDIRECT3DINDEXBUFFER9 iface) {
IDirect3DIndexBuffer9Impl *This = (IDirect3DIndexBuffer9Impl *)iface;
ULONG ref = InterlockedDecrement(&This->ref);
TRACE("(%p) : ReleaseRef to %d\n", This, ref);
if (ref == 0) {
IWineD3DIndexBuffer_Release(This->wineD3DIndexBuffer);
IUnknown_Release(This->parentDevice);
HeapFree(GetProcessHeap(), 0, This);
}
return ref;
}
/* IDirect3DIndexBuffer9 IDirect3DResource9 Interface follow: */
static HRESULT WINAPI IDirect3DIndexBuffer9Impl_GetDevice(LPDIRECT3DINDEXBUFFER9 iface, IDirect3DDevice9** ppDevice) {
IDirect3DIndexBuffer9Impl *This = (IDirect3DIndexBuffer9Impl *)iface;
TRACE("(%p) Relay\n", This);
return IDirect3DResource9Impl_GetDevice((LPDIRECT3DRESOURCE9) This, ppDevice);
}
static HRESULT WINAPI IDirect3DIndexBuffer9Impl_SetPrivateData(LPDIRECT3DINDEXBUFFER9 iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) {
IDirect3DIndexBuffer9Impl *This = (IDirect3DIndexBuffer9Impl *)iface;
TRACE("(%p) Relay\n", This);
return IWineD3DIndexBuffer_SetPrivateData(This->wineD3DIndexBuffer, refguid, pData, SizeOfData, Flags);
}
static HRESULT WINAPI IDirect3DIndexBuffer9Impl_GetPrivateData(LPDIRECT3DINDEXBUFFER9 iface, REFGUID refguid, void* pData, DWORD* pSizeOfData) {
IDirect3DIndexBuffer9Impl *This = (IDirect3DIndexBuffer9Impl *)iface;
TRACE("(%p) Relay\n", This);
return IWineD3DIndexBuffer_GetPrivateData(This->wineD3DIndexBuffer, refguid, pData, pSizeOfData);
}
static HRESULT WINAPI IDirect3DIndexBuffer9Impl_FreePrivateData(LPDIRECT3DINDEXBUFFER9 iface, REFGUID refguid) {
IDirect3DIndexBuffer9Impl *This = (IDirect3DIndexBuffer9Impl *)iface;
TRACE("(%p) Relay\n", This);
return IWineD3DIndexBuffer_FreePrivateData(This->wineD3DIndexBuffer, refguid);
}
static DWORD WINAPI IDirect3DIndexBuffer9Impl_SetPriority(LPDIRECT3DINDEXBUFFER9 iface, DWORD PriorityNew) {
IDirect3DIndexBuffer9Impl *This = (IDirect3DIndexBuffer9Impl *)iface;
TRACE("(%p) Relay\n", This);
return IWineD3DIndexBuffer_SetPriority(This->wineD3DIndexBuffer, PriorityNew);
}
static DWORD WINAPI IDirect3DIndexBuffer9Impl_GetPriority(LPDIRECT3DINDEXBUFFER9 iface) {
IDirect3DIndexBuffer9Impl *This = (IDirect3DIndexBuffer9Impl *)iface;
TRACE("(%p) Relay\n", This);
return IWineD3DIndexBuffer_GetPriority(This->wineD3DIndexBuffer);
}
static void WINAPI IDirect3DIndexBuffer9Impl_PreLoad(LPDIRECT3DINDEXBUFFER9 iface) {
IDirect3DIndexBuffer9Impl *This = (IDirect3DIndexBuffer9Impl *)iface;
TRACE("(%p) Relay\n", This);
IWineD3DIndexBuffer_PreLoad(This->wineD3DIndexBuffer);
}
static D3DRESOURCETYPE WINAPI IDirect3DIndexBuffer9Impl_GetType(LPDIRECT3DINDEXBUFFER9 iface) {
IDirect3DIndexBuffer9Impl *This = (IDirect3DIndexBuffer9Impl *)iface;
TRACE("(%p) Relay\n", This);
return IWineD3DIndexBuffer_GetType(This->wineD3DIndexBuffer);
}
/* IDirect3DIndexBuffer9 Interface follow: */
static HRESULT WINAPI IDirect3DIndexBuffer9Impl_Lock(LPDIRECT3DINDEXBUFFER9 iface, UINT OffsetToLock, UINT SizeToLock, void** ppbData, DWORD Flags) {
IDirect3DIndexBuffer9Impl *This = (IDirect3DIndexBuffer9Impl *)iface;
TRACE("(%p) Relay\n", This);
return IWineD3DIndexBuffer_Lock(This->wineD3DIndexBuffer, OffsetToLock, SizeToLock, (BYTE **)ppbData, Flags);
}
static HRESULT WINAPI IDirect3DIndexBuffer9Impl_Unlock(LPDIRECT3DINDEXBUFFER9 iface) {
IDirect3DIndexBuffer9Impl *This = (IDirect3DIndexBuffer9Impl *)iface;
TRACE("(%p) Relay\n", This);
return IWineD3DIndexBuffer_Unlock(This->wineD3DIndexBuffer);
}
static HRESULT WINAPI IDirect3DIndexBuffer9Impl_GetDesc(LPDIRECT3DINDEXBUFFER9 iface, D3DINDEXBUFFER_DESC *pDesc) {
IDirect3DIndexBuffer9Impl *This = (IDirect3DIndexBuffer9Impl *)iface;
TRACE("(%p) Relay\n", This);
return IWineD3DIndexBuffer_GetDesc(This->wineD3DIndexBuffer, (WINED3DINDEXBUFFER_DESC *) pDesc);
}
static const IDirect3DIndexBuffer9Vtbl Direct3DIndexBuffer9_Vtbl =
{
/* IUnknown */
IDirect3DIndexBuffer9Impl_QueryInterface,
IDirect3DIndexBuffer9Impl_AddRef,
IDirect3DIndexBuffer9Impl_Release,
/* IDirect3DResource9 */
IDirect3DIndexBuffer9Impl_GetDevice,
IDirect3DIndexBuffer9Impl_SetPrivateData,
IDirect3DIndexBuffer9Impl_GetPrivateData,
IDirect3DIndexBuffer9Impl_FreePrivateData,
IDirect3DIndexBuffer9Impl_SetPriority,
IDirect3DIndexBuffer9Impl_GetPriority,
IDirect3DIndexBuffer9Impl_PreLoad,
IDirect3DIndexBuffer9Impl_GetType,
/* IDirect3DIndexBuffer9 */
IDirect3DIndexBuffer9Impl_Lock,
IDirect3DIndexBuffer9Impl_Unlock,
IDirect3DIndexBuffer9Impl_GetDesc
};
/* IDirect3DDevice9 IDirect3DIndexBuffer9 Methods follow: */
HRESULT WINAPI IDirect3DDevice9Impl_CreateIndexBuffer(LPDIRECT3DDEVICE9 iface,
UINT Length, DWORD Usage, D3DFORMAT Format, D3DPOOL Pool,
IDirect3DIndexBuffer9** ppIndexBuffer, HANDLE* pSharedHandle) {
IDirect3DIndexBuffer9Impl *object;
IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
HRESULT hrc = D3D_OK;
TRACE("(%p) Relay\n", This);
/* Allocate the storage for the device */
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
if (NULL == object) {
FIXME("Allocation of memory failed, returning D3DERR_OUTOFVIDEOMEMORY\n");
return D3DERR_OUTOFVIDEOMEMORY;
}
object->lpVtbl = &Direct3DIndexBuffer9_Vtbl;
object->ref = 1;
TRACE("Calling wined3d create index buffer\n");
hrc = IWineD3DDevice_CreateIndexBuffer(This->WineD3DDevice, Length, Usage & WINED3DUSAGE_MASK, Format, (WINED3DPOOL) Pool, &object->wineD3DIndexBuffer, pSharedHandle, (IUnknown *)object);
if (hrc != D3D_OK) {
/* free up object */
FIXME("(%p) call to IWineD3DDevice_CreateIndexBuffer failed\n", This);
HeapFree(GetProcessHeap(), 0, object);
} else {
IUnknown_AddRef(iface);
object->parentDevice = iface;
*ppIndexBuffer = (LPDIRECT3DINDEXBUFFER9) object;
TRACE("(%p) : Created index buffer %p\n", This, object);
}
return hrc;
}

View File

@@ -0,0 +1,203 @@
/*
* IDirect3DPixelShader9 implementation
*
* Copyright 2002-2003 Jason Edmeades
* Raphael Junqueira
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "config.h"
#include "d3d9_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(d3d9);
/* IDirect3DPixelShader9 IUnknown parts follow: */
static HRESULT WINAPI IDirect3DPixelShader9Impl_QueryInterface(LPDIRECT3DPIXELSHADER9 iface, REFIID riid, LPVOID* ppobj) {
IDirect3DPixelShader9Impl *This = (IDirect3DPixelShader9Impl *)iface;
if (IsEqualGUID(riid, &IID_IUnknown)
|| IsEqualGUID(riid, &IID_IDirect3DPixelShader9)) {
IUnknown_AddRef(iface);
*ppobj = This;
return S_OK;
}
WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);
*ppobj = NULL;
return E_NOINTERFACE;
}
static ULONG WINAPI IDirect3DPixelShader9Impl_AddRef(LPDIRECT3DPIXELSHADER9 iface) {
IDirect3DPixelShader9Impl *This = (IDirect3DPixelShader9Impl *)iface;
ULONG ref = InterlockedIncrement(&This->ref);
TRACE("(%p) : AddRef from %d\n", This, ref - 1);
return ref;
}
static ULONG WINAPI IDirect3DPixelShader9Impl_Release(LPDIRECT3DPIXELSHADER9 iface) {
IDirect3DPixelShader9Impl *This = (IDirect3DPixelShader9Impl *)iface;
ULONG ref = InterlockedDecrement(&This->ref);
TRACE("(%p) : ReleaseRef to %d\n", This, ref);
if (ref == 0) {
IWineD3DPixelShader_Release(This->wineD3DPixelShader);
IUnknown_Release(This->parentDevice);
HeapFree(GetProcessHeap(), 0, This);
}
return ref;
}
/* IDirect3DPixelShader9 Interface follow: */
static HRESULT WINAPI IDirect3DPixelShader9Impl_GetDevice(LPDIRECT3DPIXELSHADER9 iface, IDirect3DDevice9** ppDevice) {
IDirect3DPixelShader9Impl *This = (IDirect3DPixelShader9Impl *)iface;
IWineD3DDevice *myDevice = NULL;
TRACE("(%p) : Relay\n", This);
IWineD3DPixelShader_GetDevice(This->wineD3DPixelShader, &myDevice);
IWineD3DDevice_GetParent(myDevice, (IUnknown **)ppDevice);
IWineD3DDevice_Release(myDevice);
TRACE("(%p) returning (%p)\n", This, *ppDevice);
return D3D_OK;
}
static HRESULT WINAPI IDirect3DPixelShader9Impl_GetFunction(LPDIRECT3DPIXELSHADER9 iface, VOID* pData, UINT* pSizeOfData) {
IDirect3DPixelShader9Impl *This = (IDirect3DPixelShader9Impl *)iface;
TRACE("(%p) Relay\n", This);
return IWineD3DPixelShader_GetFunction(This->wineD3DPixelShader, pData, pSizeOfData);
}
static const IDirect3DPixelShader9Vtbl Direct3DPixelShader9_Vtbl =
{
/* IUnknown */
IDirect3DPixelShader9Impl_QueryInterface,
IDirect3DPixelShader9Impl_AddRef,
IDirect3DPixelShader9Impl_Release,
/* IDirect3DPixelShader9 */
IDirect3DPixelShader9Impl_GetDevice,
IDirect3DPixelShader9Impl_GetFunction
};
/* IDirect3DDevice9 IDirect3DPixelShader9 Methods follow: */
HRESULT WINAPI IDirect3DDevice9Impl_CreatePixelShader(LPDIRECT3DDEVICE9 iface, CONST DWORD* pFunction, IDirect3DPixelShader9** ppShader) {
IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
IDirect3DPixelShader9Impl *object;
HRESULT hrc = D3D_OK;
TRACE("(%p) Relay\n", This);
if (ppShader == NULL) {
TRACE("(%p) Invalid call\n", This);
return D3DERR_INVALIDCALL;
}
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
if (NULL == object) {
FIXME("Allocation of memory failed, returning D3DERR_OUTOFVIDEOMEMORY\n");
return E_OUTOFMEMORY;
}
object->ref = 1;
object->lpVtbl = &Direct3DPixelShader9_Vtbl;
hrc = IWineD3DDevice_CreatePixelShader(This->WineD3DDevice, pFunction, &object->wineD3DPixelShader , (IUnknown *)object);
if (hrc != D3D_OK) {
/* free up object */
FIXME("(%p) call to IWineD3DDevice_CreatePixelShader failed\n", This);
HeapFree(GetProcessHeap(), 0 , object);
} else {
IUnknown_AddRef(iface);
object->parentDevice = iface;
*ppShader = (IDirect3DPixelShader9*) object;
TRACE("(%p) : Created pixel shader %p\n", This, object);
}
TRACE("(%p) : returning %p\n", This, *ppShader);
return hrc;
}
HRESULT WINAPI IDirect3DDevice9Impl_SetPixelShader(LPDIRECT3DDEVICE9 iface, IDirect3DPixelShader9* pShader) {
IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
IDirect3DPixelShader9Impl *shader = (IDirect3DPixelShader9Impl *)pShader;
TRACE("(%p) Relay\n", This);
IWineD3DDevice_SetPixelShader(This->WineD3DDevice, shader == NULL ? NULL :shader->wineD3DPixelShader);
return D3D_OK;
}
HRESULT WINAPI IDirect3DDevice9Impl_GetPixelShader(LPDIRECT3DDEVICE9 iface, IDirect3DPixelShader9** ppShader) {
IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
IWineD3DPixelShader *object;
HRESULT hrc = D3D_OK;
TRACE("(%p) Relay\n", This);
if (ppShader == NULL) {
TRACE("(%p) Invalid call\n", This);
return D3DERR_INVALIDCALL;
}
hrc = IWineD3DDevice_GetPixelShader(This->WineD3DDevice, &object);
if (hrc == D3D_OK && object != NULL) {
hrc = IWineD3DPixelShader_GetParent(object, (IUnknown **)ppShader);
IWineD3DPixelShader_Release(object);
} else {
*ppShader = NULL;
}
TRACE("(%p) : returning %p\n", This, *ppShader);
return hrc;
}
HRESULT WINAPI IDirect3DDevice9Impl_SetPixelShaderConstantF(LPDIRECT3DDEVICE9 iface, UINT Register, CONST float* pConstantData, UINT Vector4fCount) {
IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
TRACE("(%p) Relay\n", This);
return IWineD3DDevice_SetPixelShaderConstantF(This->WineD3DDevice, Register, pConstantData, Vector4fCount);
}
HRESULT WINAPI IDirect3DDevice9Impl_GetPixelShaderConstantF(LPDIRECT3DDEVICE9 iface, UINT Register, float* pConstantData, UINT Vector4fCount) {
IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
TRACE("(%p) Relay\n", This);
return IWineD3DDevice_GetPixelShaderConstantF(This->WineD3DDevice, Register, pConstantData, Vector4fCount);
}
HRESULT WINAPI IDirect3DDevice9Impl_SetPixelShaderConstantI(LPDIRECT3DDEVICE9 iface, UINT Register, CONST int* pConstantData, UINT Vector4iCount) {
IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
TRACE("(%p) Relay\n", This);
return IWineD3DDevice_SetPixelShaderConstantI(This->WineD3DDevice, Register, pConstantData, Vector4iCount);
}
HRESULT WINAPI IDirect3DDevice9Impl_GetPixelShaderConstantI(LPDIRECT3DDEVICE9 iface, UINT Register, int* pConstantData, UINT Vector4iCount) {
IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
TRACE("(%p) Relay\n", This);
return IWineD3DDevice_GetPixelShaderConstantI(This->WineD3DDevice, Register, pConstantData, Vector4iCount);
}
HRESULT WINAPI IDirect3DDevice9Impl_SetPixelShaderConstantB(LPDIRECT3DDEVICE9 iface, UINT Register, CONST BOOL* pConstantData, UINT BoolCount) {
IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
TRACE("(%p) Relay\n", This);
return IWineD3DDevice_SetPixelShaderConstantB(This->WineD3DDevice, Register, pConstantData, BoolCount);
}
HRESULT WINAPI IDirect3DDevice9Impl_GetPixelShaderConstantB(LPDIRECT3DDEVICE9 iface, UINT Register, BOOL* pConstantData, UINT BoolCount) {
IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
TRACE("(%p) Relay\n", This);
return IWineD3DDevice_GetPixelShaderConstantB(This->WineD3DDevice, Register, pConstantData, BoolCount);
}

View File

@@ -0,0 +1,157 @@
/*
* IDirect3DQuery9 implementation
*
* Copyright 2002-2003 Raphael Junqueira
* Copyright 2002-2003 Jason Edmeades
* Copyright 2005 Oliver Stieber
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "config.h"
#include "d3d9_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(d3d9);
/* IDirect3DQuery9 IUnknown parts follow: */
static HRESULT WINAPI IDirect3DQuery9Impl_QueryInterface(LPDIRECT3DQUERY9 iface, REFIID riid, LPVOID* ppobj) {
IDirect3DQuery9Impl *This = (IDirect3DQuery9Impl *)iface;
TRACE("(%p) Relay\n", This);
if (IsEqualGUID(riid, &IID_IUnknown)
|| IsEqualGUID(riid, &IID_IDirect3DQuery9)) {
IUnknown_AddRef(iface);
*ppobj = This;
return S_OK;
}
WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);
*ppobj = NULL;
return E_NOINTERFACE;
}
static ULONG WINAPI IDirect3DQuery9Impl_AddRef(LPDIRECT3DQUERY9 iface) {
IDirect3DQuery9Impl *This = (IDirect3DQuery9Impl *)iface;
ULONG ref = InterlockedIncrement(&This->ref);
TRACE("(%p) : AddRef from %d\n", This, ref - 1);
return ref;
}
static ULONG WINAPI IDirect3DQuery9Impl_Release(LPDIRECT3DQUERY9 iface) {
IDirect3DQuery9Impl *This = (IDirect3DQuery9Impl *)iface;
ULONG ref = InterlockedDecrement(&This->ref);
TRACE("(%p) : ReleaseRef to %d\n", This, ref);
if (ref == 0) {
IUnknown_Release(This->parentDevice);
HeapFree(GetProcessHeap(), 0, This);
}
return ref;
}
/* IDirect3DQuery9 Interface follow: */
static HRESULT WINAPI IDirect3DQuery9Impl_GetDevice(LPDIRECT3DQUERY9 iface, IDirect3DDevice9** ppDevice) {
IDirect3DQuery9Impl *This = (IDirect3DQuery9Impl *)iface;
IWineD3DDevice* pDevice;
HRESULT hr;
TRACE("(%p) Relay\n", This);
hr = IWineD3DQuery_GetDevice(This->wineD3DQuery, &pDevice);
if(hr != D3D_OK){
*ppDevice = NULL;
}else{
hr = IWineD3DDevice_GetParent(pDevice, (IUnknown **)ppDevice);
IWineD3DDevice_Release(pDevice);
}
return hr;
}
static D3DQUERYTYPE WINAPI IDirect3DQuery9Impl_GetType(LPDIRECT3DQUERY9 iface) {
IDirect3DQuery9Impl *This = (IDirect3DQuery9Impl *)iface;
TRACE("(%p) Relay\n", This);
return IWineD3DQuery_GetType(This->wineD3DQuery);
}
static DWORD WINAPI IDirect3DQuery9Impl_GetDataSize(LPDIRECT3DQUERY9 iface) {
IDirect3DQuery9Impl *This = (IDirect3DQuery9Impl *)iface;
TRACE("(%p) Relay\n", This);
return IWineD3DQuery_GetDataSize(This->wineD3DQuery);
}
static HRESULT WINAPI IDirect3DQuery9Impl_Issue(LPDIRECT3DQUERY9 iface, DWORD dwIssueFlags) {
IDirect3DQuery9Impl *This = (IDirect3DQuery9Impl *)iface;
TRACE("(%p) Relay\n", This);
return IWineD3DQuery_Issue(This->wineD3DQuery, dwIssueFlags);
}
static HRESULT WINAPI IDirect3DQuery9Impl_GetData(LPDIRECT3DQUERY9 iface, void* pData, DWORD dwSize, DWORD dwGetDataFlags) {
IDirect3DQuery9Impl *This = (IDirect3DQuery9Impl *)iface;
TRACE("(%p) Relay\n", This);
return IWineD3DQuery_GetData(This->wineD3DQuery, pData, dwSize, dwGetDataFlags);
}
static const IDirect3DQuery9Vtbl Direct3DQuery9_Vtbl =
{
IDirect3DQuery9Impl_QueryInterface,
IDirect3DQuery9Impl_AddRef,
IDirect3DQuery9Impl_Release,
IDirect3DQuery9Impl_GetDevice,
IDirect3DQuery9Impl_GetType,
IDirect3DQuery9Impl_GetDataSize,
IDirect3DQuery9Impl_Issue,
IDirect3DQuery9Impl_GetData
};
/* IDirect3DDevice9 IDirect3DQuery9 Methods follow: */
HRESULT WINAPI IDirect3DDevice9Impl_CreateQuery(LPDIRECT3DDEVICE9 iface, D3DQUERYTYPE Type, IDirect3DQuery9** ppQuery) {
IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
IDirect3DQuery9Impl *object = NULL;
HRESULT hr = D3D_OK;
TRACE("(%p) Relay\n", This);
if (!ppQuery)
return IWineD3DDevice_CreateQuery(This->WineD3DDevice, Type, NULL, NULL);
/* Allocate the storage for the device */
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3DQuery9Impl));
if (NULL == object) {
FIXME("Allocation of memory failed, returning D3DERR_OUTOFVIDEOMEMORY\n");
return D3DERR_OUTOFVIDEOMEMORY;
}
object->lpVtbl = &Direct3DQuery9_Vtbl;
object->ref = 1;
hr = IWineD3DDevice_CreateQuery(This->WineD3DDevice, Type, &object->wineD3DQuery, (IUnknown *)object);
if (FAILED(hr)) {
/* free up object */
FIXME("(%p) call to IWineD3DDevice_CreateQuery failed\n", This);
HeapFree(GetProcessHeap(), 0, object);
} else {
IUnknown_AddRef(iface);
object->parentDevice = iface;
*ppQuery = (LPDIRECT3DQUERY9) object;
TRACE("(%p) : Created query %p\n", This , object);
}
TRACE("(%p) : returning %x\n", This, hr);
return hr;
}

View File

@@ -0,0 +1,135 @@
/*
* IDirect3DResource9 implementation
*
* Copyright 2002-2004 Jason Edmeades
* Raphael Junqueira
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "config.h"
#include "d3d9_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(d3d9);
/* IDirect3DResource9 IUnknown parts follow: */
static HRESULT WINAPI IDirect3DResource9Impl_QueryInterface(LPDIRECT3DRESOURCE9 iface, REFIID riid, LPVOID* ppobj) {
IDirect3DResource9Impl *This = (IDirect3DResource9Impl *)iface;
if (IsEqualGUID(riid, &IID_IUnknown)
|| IsEqualGUID(riid, &IID_IDirect3DResource9)) {
IUnknown_AddRef(iface);
*ppobj = This;
return S_OK;
}
WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);
*ppobj = NULL;
return E_NOINTERFACE;
}
static ULONG WINAPI IDirect3DResource9Impl_AddRef(LPDIRECT3DRESOURCE9 iface) {
IDirect3DResource9Impl *This = (IDirect3DResource9Impl *)iface;
ULONG ref = InterlockedIncrement(&This->ref);
TRACE("(%p) : AddRef from %d\n", This, ref - 1);
return ref;
}
static ULONG WINAPI IDirect3DResource9Impl_Release(LPDIRECT3DRESOURCE9 iface) {
IDirect3DResource9Impl *This = (IDirect3DResource9Impl *)iface;
ULONG ref = InterlockedDecrement(&This->ref);
TRACE("(%p) : ReleaseRef to %d\n", This, ref);
if (ref == 0) {
IWineD3DResource_Release(This->wineD3DResource);
HeapFree(GetProcessHeap(), 0, This);
}
return ref;
}
/* IDirect3DResource9 Interface follow: */
HRESULT WINAPI IDirect3DResource9Impl_GetDevice(LPDIRECT3DRESOURCE9 iface, IDirect3DDevice9** ppDevice) {
IDirect3DResource9Impl *This = (IDirect3DResource9Impl *)iface;
IWineD3DDevice *myDevice = NULL;
TRACE("(%p) Relay\n", This);
IWineD3DResource_GetDevice(This->wineD3DResource, &myDevice);
IWineD3DDevice_GetParent(myDevice, (IUnknown **)ppDevice);
IWineD3DDevice_Release(myDevice);
return D3D_OK;
}
static HRESULT WINAPI IDirect3DResource9Impl_SetPrivateData(LPDIRECT3DRESOURCE9 iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) {
IDirect3DResource9Impl *This = (IDirect3DResource9Impl *)iface;
TRACE("(%p) Relay\n", This);
return IWineD3DResource_SetPrivateData(This->wineD3DResource, refguid, pData, SizeOfData, Flags);
}
static HRESULT WINAPI IDirect3DResource9Impl_GetPrivateData(LPDIRECT3DRESOURCE9 iface, REFGUID refguid, void* pData, DWORD* pSizeOfData) {
IDirect3DResource9Impl *This = (IDirect3DResource9Impl *)iface;
TRACE("(%p) Relay\n", This);
return IWineD3DResource_GetPrivateData(This->wineD3DResource, refguid, pData, pSizeOfData);
}
static HRESULT WINAPI IDirect3DResource9Impl_FreePrivateData(LPDIRECT3DRESOURCE9 iface, REFGUID refguid) {
IDirect3DResource9Impl *This = (IDirect3DResource9Impl *)iface;
TRACE("(%p) Relay\n", This);
return IWineD3DResource_FreePrivateData(This->wineD3DResource, refguid);
}
static DWORD WINAPI IDirect3DResource9Impl_SetPriority(LPDIRECT3DRESOURCE9 iface, DWORD PriorityNew) {
IDirect3DResource9Impl *This = (IDirect3DResource9Impl *)iface;
TRACE("(%p) Relay\n", This);
return IWineD3DResource_SetPriority(This->wineD3DResource, PriorityNew);
}
static DWORD WINAPI IDirect3DResource9Impl_GetPriority(LPDIRECT3DRESOURCE9 iface) {
IDirect3DResource9Impl *This = (IDirect3DResource9Impl *)iface;
TRACE("(%p) Relay\n", This);
return IWineD3DResource_GetPriority(This->wineD3DResource);
}
static void WINAPI IDirect3DResource9Impl_PreLoad(LPDIRECT3DRESOURCE9 iface) {
IDirect3DResource9Impl *This = (IDirect3DResource9Impl *)iface;
TRACE("(%p) Relay\n", This);
IWineD3DResource_PreLoad(This->wineD3DResource);
return;
}
static D3DRESOURCETYPE WINAPI IDirect3DResource9Impl_GetType(LPDIRECT3DRESOURCE9 iface) {
IDirect3DResource9Impl *This = (IDirect3DResource9Impl *)iface;
TRACE("(%p) Relay\n", This);
return IWineD3DResource_GetType(This->wineD3DResource);
}
const IDirect3DResource9Vtbl Direct3DResource9_Vtbl =
{
IDirect3DResource9Impl_QueryInterface,
IDirect3DResource9Impl_AddRef,
IDirect3DResource9Impl_Release,
IDirect3DResource9Impl_GetDevice,
IDirect3DResource9Impl_SetPrivateData,
IDirect3DResource9Impl_GetPrivateData,
IDirect3DResource9Impl_FreePrivateData,
IDirect3DResource9Impl_SetPriority,
IDirect3DResource9Impl_GetPriority,
IDirect3DResource9Impl_PreLoad,
IDirect3DResource9Impl_GetType
};

View File

@@ -0,0 +1,161 @@
/*
* IDirect3DStateBlock9 implementation
*
* Copyright 2002-2003 Raphael Junqueira
* Copyright 2002-2003 Jason Edmeades
* Copyright 2005 Oliver Stieber
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "config.h"
#include "d3d9_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(d3d9);
/* IDirect3DStateBlock9 IUnknown parts follow: */
static HRESULT WINAPI IDirect3DStateBlock9Impl_QueryInterface(LPDIRECT3DSTATEBLOCK9 iface, REFIID riid, LPVOID* ppobj) {
IDirect3DStateBlock9Impl *This = (IDirect3DStateBlock9Impl *)iface;
if (IsEqualGUID(riid, &IID_IUnknown)
|| IsEqualGUID(riid, &IID_IDirect3DStateBlock9)) {
IUnknown_AddRef(iface);
*ppobj = This;
return S_OK;
}
WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);
*ppobj = NULL;
return E_NOINTERFACE;
}
static ULONG WINAPI IDirect3DStateBlock9Impl_AddRef(LPDIRECT3DSTATEBLOCK9 iface) {
IDirect3DStateBlock9Impl *This = (IDirect3DStateBlock9Impl *)iface;
ULONG ref = InterlockedIncrement(&This->ref);
TRACE("(%p) : AddRef from %d\n", This, ref - 1);
return ref;
}
static ULONG WINAPI IDirect3DStateBlock9Impl_Release(LPDIRECT3DSTATEBLOCK9 iface) {
IDirect3DStateBlock9Impl *This = (IDirect3DStateBlock9Impl *)iface;
ULONG ref = InterlockedDecrement(&This->ref);
TRACE("(%p) : ReleaseRef to %d\n", This, ref);
if (ref == 0) {
IWineD3DStateBlock_Release(This->wineD3DStateBlock);
IUnknown_Release(This->parentDevice);
HeapFree(GetProcessHeap(), 0, This);
}
return ref;
}
/* IDirect3DStateBlock9 Interface follow: */
static HRESULT WINAPI IDirect3DStateBlock9Impl_GetDevice(LPDIRECT3DSTATEBLOCK9 iface, IDirect3DDevice9** ppDevice) {
IDirect3DStateBlock9Impl *This = (IDirect3DStateBlock9Impl *)iface;
TRACE("(%p) Relay\n", This);
return IDirect3DResource9Impl_GetDevice((LPDIRECT3DRESOURCE9) This, ppDevice);
}
static HRESULT WINAPI IDirect3DStateBlock9Impl_Capture(LPDIRECT3DSTATEBLOCK9 iface) {
IDirect3DStateBlock9Impl *This = (IDirect3DStateBlock9Impl *)iface;
TRACE("(%p) Relay\n", This);
return IWineD3DStateBlock_Capture(This->wineD3DStateBlock);
}
static HRESULT WINAPI IDirect3DStateBlock9Impl_Apply(LPDIRECT3DSTATEBLOCK9 iface) {
IDirect3DStateBlock9Impl *This = (IDirect3DStateBlock9Impl *)iface;
TRACE("(%p) Relay\n", This);
return IWineD3DStateBlock_Apply(This->wineD3DStateBlock);
}
static const IDirect3DStateBlock9Vtbl Direct3DStateBlock9_Vtbl =
{
/* IUnknown */
IDirect3DStateBlock9Impl_QueryInterface,
IDirect3DStateBlock9Impl_AddRef,
IDirect3DStateBlock9Impl_Release,
/* IDirect3DStateBlock9 */
IDirect3DStateBlock9Impl_GetDevice,
IDirect3DStateBlock9Impl_Capture,
IDirect3DStateBlock9Impl_Apply
};
/* IDirect3DDevice9 IDirect3DStateBlock9 Methods follow: */
HRESULT WINAPI IDirect3DDevice9Impl_CreateStateBlock(LPDIRECT3DDEVICE9 iface, D3DSTATEBLOCKTYPE Type, IDirect3DStateBlock9** ppStateBlock) {
IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
IDirect3DStateBlock9Impl* object;
HRESULT hrc = D3D_OK;
TRACE("(%p) Relay\n", This);
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3DStateBlock9Impl));
if (NULL == object) return E_OUTOFMEMORY;
object->lpVtbl = &Direct3DStateBlock9_Vtbl;
object->ref = 1;
hrc = IWineD3DDevice_CreateStateBlock(This->WineD3DDevice, (WINED3DSTATEBLOCKTYPE)Type, &object->wineD3DStateBlock, (IUnknown*)object);
if(hrc != D3D_OK){
FIXME("(%p) Call to IWineD3DDevice_CreateStateBlock failed.\n", This);
HeapFree(GetProcessHeap(), 0, object);
} else {
IUnknown_AddRef(iface);
object->parentDevice = iface;
*ppStateBlock = (IDirect3DStateBlock9*)object;
TRACE("(%p) : Created stateblock %p\n", This, object);
}
TRACE("(%p) returning token (ptr to stateblock) of %p\n", This, object);
return hrc;
}
HRESULT WINAPI IDirect3DDevice9Impl_BeginStateBlock(LPDIRECT3DDEVICE9 iface) {
IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
TRACE("(%p) Relay\n", This);
return IWineD3DDevice_BeginStateBlock(This->WineD3DDevice);
}
HRESULT WINAPI IDirect3DDevice9Impl_EndStateBlock(LPDIRECT3DDEVICE9 iface, IDirect3DStateBlock9** ppSB) {
IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
HRESULT hr;
IWineD3DStateBlock* wineD3DStateBlock;
IDirect3DStateBlock9Impl* object;
TRACE("(%p) Relay\n", This);
/* Tell wineD3D to endstatablock before anything else (in case we run out
* of memory later and cause locking problems)
*/
hr=IWineD3DDevice_EndStateBlock(This->WineD3DDevice,&wineD3DStateBlock);
if(hr!= D3D_OK){
FIXME("IWineD3DDevice_EndStateBlock returned an error\n");
return hr;
}
/* allocate a new IDirectD3DStateBlock */
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY ,sizeof(IDirect3DStateBlock9Impl));
if (!object) return E_OUTOFMEMORY;
object->ref = 1;
object->lpVtbl = &Direct3DStateBlock9_Vtbl;
object->wineD3DStateBlock = wineD3DStateBlock;
IUnknown_AddRef(iface);
object->parentDevice = iface;
*ppSB=(IDirect3DStateBlock9*)object;
TRACE("(%p)Returning %p %p\n", This, *ppSB, wineD3DStateBlock);
return D3D_OK;
}

View File

@@ -0,0 +1,227 @@
/*
* IDirect3DSurface9 implementation
*
* Copyright 2002-2005 Jason Edmeades
* Raphael Junqueira
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "config.h"
#include "d3d9_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(d3d9);
/* IDirect3DSurface9 IUnknown parts follow: */
static HRESULT WINAPI IDirect3DSurface9Impl_QueryInterface(LPDIRECT3DSURFACE9 iface, REFIID riid, LPVOID* ppobj) {
IDirect3DSurface9Impl *This = (IDirect3DSurface9Impl *)iface;
if (IsEqualGUID(riid, &IID_IUnknown)
|| IsEqualGUID(riid, &IID_IDirect3DResource9)
|| IsEqualGUID(riid, &IID_IDirect3DSurface9)) {
IUnknown_AddRef(iface);
*ppobj = This;
return S_OK;
}
WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);
*ppobj = NULL;
return E_NOINTERFACE;
}
static ULONG WINAPI IDirect3DSurface9Impl_AddRef(LPDIRECT3DSURFACE9 iface) {
IDirect3DSurface9Impl *This = (IDirect3DSurface9Impl *)iface;
TRACE("(%p)\n", This);
if (This->forwardReference) {
/* Forward refcounting */
TRACE("(%p) : Forwarding to %p\n", This, This->forwardReference);
return IUnknown_AddRef(This->forwardReference);
} else {
/* No container, handle our own refcounting */
ULONG ref = InterlockedIncrement(&This->ref);
if(ref == 1 && This->parentDevice) IUnknown_AddRef(This->parentDevice);
TRACE("(%p) : AddRef from %d\n", This, ref - 1);
return ref;
}
}
static ULONG WINAPI IDirect3DSurface9Impl_Release(LPDIRECT3DSURFACE9 iface) {
IDirect3DSurface9Impl *This = (IDirect3DSurface9Impl *)iface;
TRACE("(%p)\n", This);
if (This->forwardReference) {
/* Forward to the containerParent */
TRACE("(%p) : Forwarding to %p\n", This, This->forwardReference);
return IUnknown_Release(This->forwardReference);
} else {
/* No container, handle our own refcounting */
ULONG ref = InterlockedDecrement(&This->ref);
TRACE("(%p) : ReleaseRef to %d\n", This, ref);
if (ref == 0) {
if (This->parentDevice) IUnknown_Release(This->parentDevice);
if (!This->isImplicit) {
IWineD3DSurface_Release(This->wineD3DSurface);
HeapFree(GetProcessHeap(), 0, This);
}
}
return ref;
}
}
/* IDirect3DSurface9 IDirect3DResource9 Interface follow: */
static HRESULT WINAPI IDirect3DSurface9Impl_GetDevice(LPDIRECT3DSURFACE9 iface, IDirect3DDevice9** ppDevice) {
IDirect3DSurface9Impl *This = (IDirect3DSurface9Impl *)iface;
return IDirect3DResource9Impl_GetDevice((LPDIRECT3DRESOURCE9) This, ppDevice);
}
static HRESULT WINAPI IDirect3DSurface9Impl_SetPrivateData(LPDIRECT3DSURFACE9 iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) {
IDirect3DSurface9Impl *This = (IDirect3DSurface9Impl *)iface;
TRACE("(%p) Relay\n", This);
return IWineD3DSurface_SetPrivateData(This->wineD3DSurface, refguid, pData, SizeOfData, Flags);
}
static HRESULT WINAPI IDirect3DSurface9Impl_GetPrivateData(LPDIRECT3DSURFACE9 iface, REFGUID refguid, void* pData, DWORD* pSizeOfData) {
IDirect3DSurface9Impl *This = (IDirect3DSurface9Impl *)iface;
TRACE("(%p) Relay\n", This);
return IWineD3DSurface_GetPrivateData(This->wineD3DSurface, refguid, pData, pSizeOfData);
}
static HRESULT WINAPI IDirect3DSurface9Impl_FreePrivateData(LPDIRECT3DSURFACE9 iface, REFGUID refguid) {
IDirect3DSurface9Impl *This = (IDirect3DSurface9Impl *)iface;
TRACE("(%p) Relay\n", This);
return IWineD3DSurface_FreePrivateData(This->wineD3DSurface, refguid);
}
static DWORD WINAPI IDirect3DSurface9Impl_SetPriority(LPDIRECT3DSURFACE9 iface, DWORD PriorityNew) {
IDirect3DSurface9Impl *This = (IDirect3DSurface9Impl *)iface;
TRACE("(%p) Relay\n", This);
return IWineD3DSurface_SetPriority(This->wineD3DSurface, PriorityNew);
}
static DWORD WINAPI IDirect3DSurface9Impl_GetPriority(LPDIRECT3DSURFACE9 iface) {
IDirect3DSurface9Impl *This = (IDirect3DSurface9Impl *)iface;
TRACE("(%p) Relay\n", This);
return IWineD3DSurface_GetPriority(This->wineD3DSurface);
}
static void WINAPI IDirect3DSurface9Impl_PreLoad(LPDIRECT3DSURFACE9 iface) {
IDirect3DSurface9Impl *This = (IDirect3DSurface9Impl *)iface;
TRACE("(%p) Relay\n", This);
IWineD3DSurface_PreLoad(This->wineD3DSurface);
return ;
}
static D3DRESOURCETYPE WINAPI IDirect3DSurface9Impl_GetType(LPDIRECT3DSURFACE9 iface) {
IDirect3DSurface9Impl *This = (IDirect3DSurface9Impl *)iface;
TRACE("(%p) Relay\n", This);
return IWineD3DSurface_GetType(This->wineD3DSurface);
}
/* IDirect3DSurface9 Interface follow: */
static HRESULT WINAPI IDirect3DSurface9Impl_GetContainer(LPDIRECT3DSURFACE9 iface, REFIID riid, void** ppContainer) {
IDirect3DSurface9Impl *This = (IDirect3DSurface9Impl *)iface;
HRESULT res;
TRACE("(This %p, riid %s, ppContainer %p)\n", This, debugstr_guid(riid), ppContainer);
if (!This->container) return E_NOINTERFACE;
if (!ppContainer) {
ERR("Called without a valid ppContainer\n");
}
res = IUnknown_QueryInterface(This->container, riid, ppContainer);
TRACE("Returning ppContainer %p, *ppContainer %p\n", ppContainer, *ppContainer);
return res;
}
static HRESULT WINAPI IDirect3DSurface9Impl_GetDesc(LPDIRECT3DSURFACE9 iface, D3DSURFACE_DESC* pDesc) {
IDirect3DSurface9Impl *This = (IDirect3DSurface9Impl *)iface;
WINED3DSURFACE_DESC wined3ddesc;
UINT tmpInt = -1;
TRACE("(%p) Relay\n", This);
/* As d3d8 and d3d9 structures differ, pass in ptrs to where data needs to go */
wined3ddesc.Format = (WINED3DFORMAT *)&pDesc->Format;
wined3ddesc.Type = (WINED3DRESOURCETYPE *)&pDesc->Type;
wined3ddesc.Usage = &pDesc->Usage;
wined3ddesc.Pool = (WINED3DPOOL *) &pDesc->Pool;
wined3ddesc.Size = &tmpInt;
wined3ddesc.MultiSampleType = (WINED3DMULTISAMPLE_TYPE *) &pDesc->MultiSampleType;
wined3ddesc.MultiSampleQuality = &pDesc->MultiSampleQuality;
wined3ddesc.Width = &pDesc->Width;
wined3ddesc.Height = &pDesc->Height;
return IWineD3DSurface_GetDesc(This->wineD3DSurface, &wined3ddesc);
}
static HRESULT WINAPI IDirect3DSurface9Impl_LockRect(LPDIRECT3DSURFACE9 iface, D3DLOCKED_RECT* pLockedRect, CONST RECT* pRect, DWORD Flags) {
IDirect3DSurface9Impl *This = (IDirect3DSurface9Impl *)iface;
TRACE("(%p) Relay\n", This);
TRACE("(%p) calling IWineD3DSurface_LockRect %p %p %p %d\n", This, This->wineD3DSurface, pLockedRect, pRect, Flags);
return IWineD3DSurface_LockRect(This->wineD3DSurface, (WINED3DLOCKED_RECT *) pLockedRect, pRect, Flags);
}
static HRESULT WINAPI IDirect3DSurface9Impl_UnlockRect(LPDIRECT3DSURFACE9 iface) {
IDirect3DSurface9Impl *This = (IDirect3DSurface9Impl *)iface;
TRACE("(%p) Relay\n", This);
return IWineD3DSurface_UnlockRect(This->wineD3DSurface);
}
static HRESULT WINAPI IDirect3DSurface9Impl_GetDC(LPDIRECT3DSURFACE9 iface, HDC* phdc) {
IDirect3DSurface9Impl *This = (IDirect3DSurface9Impl *)iface;
TRACE("(%p) Relay\n", This);
return IWineD3DSurface_GetDC(This->wineD3DSurface, phdc);
}
static HRESULT WINAPI IDirect3DSurface9Impl_ReleaseDC(LPDIRECT3DSURFACE9 iface, HDC hdc) {
IDirect3DSurface9Impl *This = (IDirect3DSurface9Impl *)iface;
TRACE("(%p) Relay\n", This);
return IWineD3DSurface_ReleaseDC(This->wineD3DSurface, hdc);
}
const IDirect3DSurface9Vtbl Direct3DSurface9_Vtbl =
{
/* IUnknown */
IDirect3DSurface9Impl_QueryInterface,
IDirect3DSurface9Impl_AddRef,
IDirect3DSurface9Impl_Release,
/* IDirect3DResource9 */
IDirect3DSurface9Impl_GetDevice,
IDirect3DSurface9Impl_SetPrivateData,
IDirect3DSurface9Impl_GetPrivateData,
IDirect3DSurface9Impl_FreePrivateData,
IDirect3DSurface9Impl_SetPriority,
IDirect3DSurface9Impl_GetPriority,
IDirect3DSurface9Impl_PreLoad,
IDirect3DSurface9Impl_GetType,
/* IDirect3DSurface9 */
IDirect3DSurface9Impl_GetContainer,
IDirect3DSurface9Impl_GetDesc,
IDirect3DSurface9Impl_LockRect,
IDirect3DSurface9Impl_UnlockRect,
IDirect3DSurface9Impl_GetDC,
IDirect3DSurface9Impl_ReleaseDC
};

View File

@@ -0,0 +1,259 @@
/*
* IDirect3DSwapChain9 implementation
*
* Copyright 2002-2003 Jason Edmeades
* Raphael Junqueira
* Copyright 2005 Oliver Stieber
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "config.h"
#include "d3d9_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(d3d9);
/* IDirect3DSwapChain IUnknown parts follow: */
static HRESULT WINAPI IDirect3DSwapChain9Impl_QueryInterface(LPDIRECT3DSWAPCHAIN9 iface, REFIID riid, LPVOID* ppobj)
{
IDirect3DSwapChain9Impl *This = (IDirect3DSwapChain9Impl *)iface;
if (IsEqualGUID(riid, &IID_IUnknown)
|| IsEqualGUID(riid, &IID_IDirect3DSwapChain9)) {
IUnknown_AddRef(iface);
*ppobj = This;
return S_OK;
}
WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);
*ppobj = NULL;
return E_NOINTERFACE;
}
static ULONG WINAPI IDirect3DSwapChain9Impl_AddRef(LPDIRECT3DSWAPCHAIN9 iface) {
IDirect3DSwapChain9Impl *This = (IDirect3DSwapChain9Impl *)iface;
ULONG ref = InterlockedIncrement(&This->ref);
TRACE("(%p) : AddRef from %d\n", This, ref - 1);
if(ref == 1 && This->parentDevice) IUnknown_AddRef(This->parentDevice);
return ref;
}
static ULONG WINAPI IDirect3DSwapChain9Impl_Release(LPDIRECT3DSWAPCHAIN9 iface) {
IDirect3DSwapChain9Impl *This = (IDirect3DSwapChain9Impl *)iface;
ULONG ref = InterlockedDecrement(&This->ref);
TRACE("(%p) : ReleaseRef to %d\n", This, ref);
if (ref == 0) {
if (This->parentDevice) IUnknown_Release(This->parentDevice);
if (!This->isImplicit) {
IWineD3DSwapChain_Destroy(This->wineD3DSwapChain, D3D9CB_DestroyRenderTarget);
HeapFree(GetProcessHeap(), 0, This);
}
}
return ref;
}
/* IDirect3DSwapChain9 parts follow: */
static HRESULT WINAPI IDirect3DSwapChain9Impl_Present(LPDIRECT3DSWAPCHAIN9 iface, CONST RECT* pSourceRect, CONST RECT* pDestRect, HWND hDestWindowOverride, CONST RGNDATA* pDirtyRegion, DWORD dwFlags) {
IDirect3DSwapChain9Impl *This = (IDirect3DSwapChain9Impl *)iface;
TRACE("(%p) Relay\n", This);
return IWineD3DSwapChain_Present(This->wineD3DSwapChain, pSourceRect, pDestRect, hDestWindowOverride, pDirtyRegion, dwFlags);
}
static HRESULT WINAPI IDirect3DSwapChain9Impl_GetFrontBufferData(LPDIRECT3DSWAPCHAIN9 iface, IDirect3DSurface9* pDestSurface) {
IDirect3DSwapChain9Impl *This = (IDirect3DSwapChain9Impl *)iface;
TRACE("(%p) Relay\n", This);
return IWineD3DSwapChain_GetFrontBufferData(This->wineD3DSwapChain, ((IDirect3DSurface9Impl *)pDestSurface)->wineD3DSurface);
}
static HRESULT WINAPI IDirect3DSwapChain9Impl_GetBackBuffer(LPDIRECT3DSWAPCHAIN9 iface, UINT iBackBuffer, D3DBACKBUFFER_TYPE Type, IDirect3DSurface9** ppBackBuffer) {
IDirect3DSwapChain9Impl *This = (IDirect3DSwapChain9Impl *)iface;
HRESULT hrc = D3D_OK;
IWineD3DSurface *mySurface = NULL;
TRACE("(%p) Relay\n", This);
hrc = IWineD3DSwapChain_GetBackBuffer(This->wineD3DSwapChain, iBackBuffer, (WINED3DBACKBUFFER_TYPE) Type, &mySurface);
if (hrc == D3D_OK && NULL != mySurface) {
IWineD3DSurface_GetParent(mySurface, (IUnknown **)ppBackBuffer);
IWineD3DSurface_Release(mySurface);
}
/* Do not touch the **ppBackBuffer pointer otherwise! (see device test) */
return hrc;
}
static HRESULT WINAPI IDirect3DSwapChain9Impl_GetRasterStatus(LPDIRECT3DSWAPCHAIN9 iface, D3DRASTER_STATUS* pRasterStatus) {
IDirect3DSwapChain9Impl *This = (IDirect3DSwapChain9Impl *)iface;
TRACE("(%p) Relay\n", This);
return IWineD3DSwapChain_GetRasterStatus(This->wineD3DSwapChain, (WINED3DRASTER_STATUS *) pRasterStatus);
}
static HRESULT WINAPI IDirect3DSwapChain9Impl_GetDisplayMode(LPDIRECT3DSWAPCHAIN9 iface, D3DDISPLAYMODE* pMode) {
IDirect3DSwapChain9Impl *This = (IDirect3DSwapChain9Impl *)iface;
TRACE("(%p) Relay\n", This);
return IWineD3DSwapChain_GetDisplayMode(This->wineD3DSwapChain, (WINED3DDISPLAYMODE *) pMode);
}
static HRESULT WINAPI IDirect3DSwapChain9Impl_GetDevice(LPDIRECT3DSWAPCHAIN9 iface, IDirect3DDevice9** ppDevice) {
IDirect3DSwapChain9Impl *This = (IDirect3DSwapChain9Impl *)iface;
HRESULT hrc = D3D_OK;
IWineD3DDevice *device = NULL;
TRACE("(%p) Relay\n", This);
hrc = IWineD3DSwapChain_GetDevice(This->wineD3DSwapChain, &device);
if (hrc == D3D_OK && NULL != device) {
IWineD3DDevice_GetParent(device, (IUnknown **)ppDevice);
IWineD3DDevice_Release(device);
}
return hrc;
}
static HRESULT WINAPI IDirect3DSwapChain9Impl_GetPresentParameters(LPDIRECT3DSWAPCHAIN9 iface, D3DPRESENT_PARAMETERS* pPresentationParameters) {
IDirect3DSwapChain9Impl *This = (IDirect3DSwapChain9Impl *)iface;
WINED3DPRESENT_PARAMETERS winePresentParameters;
HRESULT hr;
TRACE("(%p)->(%p): Relay\n", This, pPresentationParameters);
hr = IWineD3DSwapChain_GetPresentParameters(This->wineD3DSwapChain, &winePresentParameters);
pPresentationParameters->BackBufferWidth = winePresentParameters.BackBufferWidth;
pPresentationParameters->BackBufferHeight = winePresentParameters.BackBufferHeight;
pPresentationParameters->BackBufferFormat = winePresentParameters.BackBufferFormat;
pPresentationParameters->BackBufferCount = winePresentParameters.BackBufferCount;
pPresentationParameters->MultiSampleType = winePresentParameters.MultiSampleType;
pPresentationParameters->MultiSampleQuality = winePresentParameters.MultiSampleQuality;
pPresentationParameters->SwapEffect = winePresentParameters.SwapEffect;
pPresentationParameters->hDeviceWindow = winePresentParameters.hDeviceWindow;
pPresentationParameters->Windowed = winePresentParameters.Windowed;
pPresentationParameters->EnableAutoDepthStencil = winePresentParameters.EnableAutoDepthStencil;
pPresentationParameters->Flags = winePresentParameters.Flags;
pPresentationParameters->FullScreen_RefreshRateInHz = winePresentParameters.FullScreen_RefreshRateInHz;
pPresentationParameters->PresentationInterval = winePresentParameters.PresentationInterval;
return hr;
}
static const IDirect3DSwapChain9Vtbl Direct3DSwapChain9_Vtbl =
{
IDirect3DSwapChain9Impl_QueryInterface,
IDirect3DSwapChain9Impl_AddRef,
IDirect3DSwapChain9Impl_Release,
IDirect3DSwapChain9Impl_Present,
IDirect3DSwapChain9Impl_GetFrontBufferData,
IDirect3DSwapChain9Impl_GetBackBuffer,
IDirect3DSwapChain9Impl_GetRasterStatus,
IDirect3DSwapChain9Impl_GetDisplayMode,
IDirect3DSwapChain9Impl_GetDevice,
IDirect3DSwapChain9Impl_GetPresentParameters
};
/* IDirect3DDevice9 IDirect3DSwapChain9 Methods follow: */
HRESULT WINAPI IDirect3DDevice9Impl_CreateAdditionalSwapChain(LPDIRECT3DDEVICE9 iface, D3DPRESENT_PARAMETERS* pPresentationParameters, IDirect3DSwapChain9** pSwapChain) {
IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
IDirect3DSwapChain9Impl* object;
HRESULT hrc = D3D_OK;
WINED3DPRESENT_PARAMETERS localParameters;
TRACE("(%p) Relay\n", This);
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
if (NULL == object) {
FIXME("Allocation of memory failed, returning D3DERR_OUTOFVIDEOMEMORY\n");
return D3DERR_OUTOFVIDEOMEMORY;
}
object->ref = 1;
object->lpVtbl = &Direct3DSwapChain9_Vtbl;
/* The back buffer count is set to one if it's 0 */
if(pPresentationParameters->BackBufferCount == 0) {
pPresentationParameters->BackBufferCount = 1;
}
/* Allocate an associated WineD3DDevice object */
localParameters.BackBufferWidth = pPresentationParameters->BackBufferWidth;
localParameters.BackBufferHeight = pPresentationParameters->BackBufferHeight;
localParameters.BackBufferFormat = pPresentationParameters->BackBufferFormat;
localParameters.BackBufferCount = pPresentationParameters->BackBufferCount;
localParameters.MultiSampleType = pPresentationParameters->MultiSampleType;
localParameters.MultiSampleQuality = pPresentationParameters->MultiSampleQuality;
localParameters.SwapEffect = pPresentationParameters->SwapEffect;
localParameters.hDeviceWindow = pPresentationParameters->hDeviceWindow;
localParameters.Windowed = pPresentationParameters->Windowed;
localParameters.EnableAutoDepthStencil = pPresentationParameters->EnableAutoDepthStencil;
localParameters.AutoDepthStencilFormat = pPresentationParameters->AutoDepthStencilFormat;
localParameters.Flags = pPresentationParameters->Flags;
localParameters.FullScreen_RefreshRateInHz = pPresentationParameters->FullScreen_RefreshRateInHz;
localParameters.PresentationInterval = pPresentationParameters->PresentationInterval;
hrc = IWineD3DDevice_CreateAdditionalSwapChain(This->WineD3DDevice, &localParameters, &object->wineD3DSwapChain, (IUnknown*)object, D3D9CB_CreateRenderTarget, D3D9CB_CreateDepthStencilSurface);
pPresentationParameters->BackBufferWidth = localParameters.BackBufferWidth;
pPresentationParameters->BackBufferHeight = localParameters.BackBufferHeight;
pPresentationParameters->BackBufferFormat = localParameters.BackBufferFormat;
pPresentationParameters->BackBufferCount = localParameters.BackBufferCount;
pPresentationParameters->MultiSampleType = localParameters.MultiSampleType;
pPresentationParameters->MultiSampleQuality = localParameters.MultiSampleQuality;
pPresentationParameters->SwapEffect = localParameters.SwapEffect;
pPresentationParameters->hDeviceWindow = localParameters.hDeviceWindow;
pPresentationParameters->Windowed = localParameters.Windowed;
pPresentationParameters->EnableAutoDepthStencil = localParameters.EnableAutoDepthStencil;
pPresentationParameters->AutoDepthStencilFormat = localParameters.AutoDepthStencilFormat;
pPresentationParameters->Flags = localParameters.Flags;
pPresentationParameters->FullScreen_RefreshRateInHz = localParameters.FullScreen_RefreshRateInHz;
pPresentationParameters->PresentationInterval = localParameters.PresentationInterval;
if (hrc != D3D_OK) {
FIXME("(%p) call to IWineD3DDevice_CreateAdditionalSwapChain failed\n", This);
HeapFree(GetProcessHeap(), 0 , object);
} else {
IUnknown_AddRef(iface);
object->parentDevice = iface;
*pSwapChain = (IDirect3DSwapChain9 *)object;
TRACE("(%p) : Created swapchain %p\n", This, *pSwapChain);
}
TRACE("(%p) returning %p\n", This, *pSwapChain);
return hrc;
}
HRESULT WINAPI IDirect3DDevice9Impl_GetSwapChain(LPDIRECT3DDEVICE9 iface, UINT iSwapChain, IDirect3DSwapChain9** pSwapChain) {
IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
HRESULT hrc = D3D_OK;
IWineD3DSwapChain *swapchain = NULL;
TRACE("(%p) Relay\n", This);
hrc = IWineD3DDevice_GetSwapChain(This->WineD3DDevice, iSwapChain, &swapchain);
if (hrc == D3D_OK && NULL != swapchain) {
IWineD3DSwapChain_GetParent(swapchain, (IUnknown **)pSwapChain);
IWineD3DSwapChain_Release(swapchain);
} else {
*pSwapChain = NULL;
}
return hrc;
}
UINT WINAPI IDirect3DDevice9Impl_GetNumberOfSwapChains(LPDIRECT3DDEVICE9 iface) {
IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
TRACE("(%p) Relay\n", This);
return IWineD3DDevice_GetNumberOfSwapChains(This->WineD3DDevice);
}

View File

@@ -0,0 +1,140 @@
# Microsoft Developer Studio Project File - Name="d3d9_test" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Console Application" 0x0103
CFG=d3d9_test - Win32 Debug
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
!MESSAGE
!MESSAGE NMAKE /f "d3d9_test.mak".
!MESSAGE
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "d3d9_test.mak" CFG="d3d9_test - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "d3d9_test - Win32 Release" (based on "Win32 (x86) Console Application")
!MESSAGE "d3d9_test - Win32 Debug" (based on "Win32 (x86) Console Application")
!MESSAGE
# Begin Project
# PROP AllowPerConfigDependencies 0
# PROP Scc_ProjName ""
# PROP Scc_LocalPath ""
CPP=cl.exe
RSC=rc.exe
!IF "$(CFG)" == "d3d9_test - Win32 Release"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Release"
# PROP BASE Intermediate_Dir "Release"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "Release"
# PROP Intermediate_Dir "Release"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
# ADD CPP /nologo /MD /W3 /GX /Zi /O2 /I "..\..\..\include" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
# ADD BASE RSC /l 0x419 /d "NDEBUG"
# ADD RSC /l 0x419 /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
# ADD LINK32 kernel32.lib user32.lib uuid.lib dxguid.lib dxerr8.lib /nologo /subsystem:console /pdb:"../../../bin/d3d9_test.pdb" /debug /machine:I386 /out:"../../../bin/d3d9_test.exe"
# SUBTRACT LINK32 /pdb:none
!ELSEIF "$(CFG)" == "d3d9_test - Win32 Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "Debug"
# PROP BASE Intermediate_Dir "Debug"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "Debug"
# PROP Intermediate_Dir "Debug"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "..\..\..\include" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
# ADD BASE RSC /l 0x419 /d "_DEBUG"
# ADD RSC /l 0x419 /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
# ADD LINK32 kernel32.lib user32.lib uuid.lib dxguid.lib dxerr8.lib /nologo /subsystem:console /pdb:"../../../bin/d3d9_test.pdb" /debug /machine:I386 /out:"../../../bin/d3d9_test.exe" /pdbtype:sept
# SUBTRACT LINK32 /pdb:none
!ENDIF
# Begin Target
# Name "d3d9_test - Win32 Release"
# Name "d3d9_test - Win32 Debug"
# Begin Group "Source Files"
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
# Begin Source File
SOURCE=.\device.c
# End Source File
# Begin Source File
SOURCE=.\query.c
# End Source File
# Begin Source File
SOURCE=.\shader.c
# End Source File
# Begin Source File
SOURCE=.\stateblock.c
# End Source File
# Begin Source File
SOURCE=.\surface.c
# End Source File
# Begin Source File
SOURCE=.\testlist.c
# End Source File
# Begin Source File
SOURCE=.\texture.c
# End Source File
# Begin Source File
SOURCE=.\vertexdeclaration.c
# End Source File
# Begin Source File
SOURCE=.\visual.c
# End Source File
# Begin Source File
SOURCE=.\volume.c
# End Source File
# End Group
# Begin Group "Header Files"
# PROP Default_Filter "h;hpp;hxx;hm;inl"
# End Group
# Begin Group "Resource Files"
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
# End Group
# End Target
# End Project

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,169 @@
/*
* Copyright (C) 2006-2007 Stefan D<>singer(For CodeWeavers)
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#define COBJMACROS
#include <d3d9.h>
#include <dxerr9.h>
#include "wine/test.h"
static IDirect3D9 *(WINAPI *pDirect3DCreate9)(UINT);
struct queryInfo
{
D3DQUERYTYPE type; /* Query to test */
BOOL foundSupported; /* If at least one windows driver has been found supporting this query */
BOOL foundUnsupported; /* If at least one windows driver has been found which does not support this query */
};
/* When running running this test on windows reveals any differences regarding known supported / unsupported queries,
* change this table.
*
* When marking a query known supported or known unsupported please write one card which supports / does not support
* the query.
*/
static struct queryInfo queries[] =
{
{D3DQUERYTYPE_VCACHE, TRUE /* geforce 6600 */, TRUE /* geforce 2 mx */ },
{D3DQUERYTYPE_RESOURCEMANAGER, FALSE, TRUE /* geforce 2 mx */ },
{D3DQUERYTYPE_VERTEXSTATS, FALSE, TRUE /* geforce 2 mx */ },
{D3DQUERYTYPE_EVENT, TRUE /* geforce 2 mx */, TRUE /* ati mach64 */ },
{D3DQUERYTYPE_OCCLUSION, TRUE /* radeon M9 */, TRUE /* geforce 2 mx */ },
{D3DQUERYTYPE_TIMESTAMP, TRUE /* geforce 6600 */, TRUE /* geforce 2 mx */ },
{D3DQUERYTYPE_TIMESTAMPDISJOINT, TRUE /* geforce 6600 */, TRUE /* geforce 2 mx */ },
{D3DQUERYTYPE_TIMESTAMPFREQ, TRUE /* geforce 6600 */, TRUE /* geforce 2 mx */ },
{D3DQUERYTYPE_PIPELINETIMINGS, FALSE, TRUE /* geforce 2 mx */ },
{D3DQUERYTYPE_INTERFACETIMINGS, FALSE, TRUE /* geforce 2 mx */ },
{D3DQUERYTYPE_VERTEXTIMINGS, FALSE, TRUE /* geforce 2 mx */ },
{D3DQUERYTYPE_PIXELTIMINGS, FALSE, TRUE /* geforce 2 mx */ },
{D3DQUERYTYPE_BANDWIDTHTIMINGS, FALSE, TRUE /* geforce 2 mx */ },
{D3DQUERYTYPE_CACHEUTILIZATION, FALSE, TRUE /* geforce 2 mx */ },
};
static const char *queryName(D3DQUERYTYPE type)
{
switch(type)
{
case D3DQUERYTYPE_VCACHE: return "D3DQUERYTYPE_VCACHE";
case D3DQUERYTYPE_RESOURCEMANAGER: return "D3DQUERYTYPE_RESOURCEMANAGER";
case D3DQUERYTYPE_VERTEXSTATS: return "D3DQUERYTYPE_VERTEXSTATS";
case D3DQUERYTYPE_EVENT: return "D3DQUERYTYPE_EVENT";
case D3DQUERYTYPE_OCCLUSION: return "D3DQUERYTYPE_OCCLUSION";
case D3DQUERYTYPE_TIMESTAMP: return "D3DQUERYTYPE_TIMESTAMP";
case D3DQUERYTYPE_TIMESTAMPDISJOINT: return "D3DQUERYTYPE_TIMESTAMPDISJOINT";
case D3DQUERYTYPE_TIMESTAMPFREQ: return "D3DQUERYTYPE_TIMESTAMPFREQ";
case D3DQUERYTYPE_PIPELINETIMINGS: return "D3DQUERYTYPE_PIPELINETIMINGS";
case D3DQUERYTYPE_INTERFACETIMINGS: return "D3DQUERYTYPE_INTERFACETIMINGS";
case D3DQUERYTYPE_VERTEXTIMINGS: return "D3DQUERYTYPE_VERTEXTIMINGS";
case D3DQUERYTYPE_PIXELTIMINGS: return "D3DQUERYTYPE_PIXELTIMINGS";
case D3DQUERYTYPE_BANDWIDTHTIMINGS: return "D3DQUERYTYPE_BANDWIDTHTIMINGS";
case D3DQUERYTYPE_CACHEUTILIZATION: return "D3DQUERYTYPE_CACHEUTILIZATION";
default: return "Unexpected query type";
}
}
static void test_query_support(IDirect3D9 *pD3d, HWND hwnd)
{
HRESULT hr;
IDirect3DDevice9 *pDevice = NULL;
D3DPRESENT_PARAMETERS d3dpp;
D3DDISPLAYMODE d3ddm;
int i;
IDirect3DQuery9 *pQuery = NULL;
BOOL supported;
IDirect3D9_GetAdapterDisplayMode( pD3d, D3DADAPTER_DEFAULT, &d3ddm );
ZeroMemory( &d3dpp, sizeof(d3dpp) );
d3dpp.Windowed = TRUE;
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
d3dpp.BackBufferFormat = d3ddm.Format;
hr = IDirect3D9_CreateDevice( pD3d, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hwnd,
D3DCREATE_SOFTWARE_VERTEXPROCESSING, &d3dpp, &pDevice );
ok(SUCCEEDED(hr), "Failed to create IDirect3D9Device (%s)\n", DXGetErrorString9(hr));
if (FAILED(hr)) goto cleanup;
for(i = 0; i < sizeof(queries) / sizeof(queries[0]); i++)
{
hr = IDirect3DDevice9_CreateQuery(pDevice, queries[i].type, NULL);
ok(hr == D3D_OK || D3DERR_NOTAVAILABLE,
"IDirect3DDevice9_CreateQuery returned unexpected return value %s for query %s\n", DXGetErrorString9(hr), queryName(queries[i].type));
supported = (hr == D3D_OK ? TRUE : FALSE);
trace("query %s is %s\n", queryName(queries[i].type), supported ? "supported" : "not supported");
ok(!(supported == TRUE && queries[i].foundSupported == FALSE),
"Query %s is supported on this system, but was not found supported before\n",
queryName(queries[i].type));
ok(!(supported == FALSE && queries[i].foundUnsupported == FALSE),
"Query %s is not supported on this system, but was found to be supported on all other systems tested before\n",
queryName(queries[i].type));
hr = IDirect3DDevice9_CreateQuery(pDevice, queries[i].type, &pQuery);
ok(hr == D3D_OK || D3DERR_NOTAVAILABLE,
"IDirect3DDevice9_CreateQuery returned unexpected return value %s for query %s\n", DXGetErrorString9(hr), queryName(queries[i].type));
ok(!(supported && !pQuery), "Query %s was claimed to be supported, but can't be created\n", queryName(queries[i].type));
ok(!(!supported && pQuery), "Query %s was claimed not to be supported, but can be created\n", queryName(queries[i].type));
if(pQuery)
{
IDirect3DQuery9_Release(pQuery);
pQuery = NULL;
}
}
cleanup:
if(pDevice) IDirect3DDevice9_Release(pDevice);
}
START_TEST(query)
{
HMODULE d3d9_handle = LoadLibraryA( "d3d9.dll" );
if (!d3d9_handle)
{
skip("Could not load d3d9.dll\n");
return;
}
pDirect3DCreate9 = (void *)GetProcAddress( d3d9_handle, "Direct3DCreate9" );
ok(pDirect3DCreate9 != NULL, "Failed to get address of Direct3DCreate9\n");
if (pDirect3DCreate9)
{
IDirect3D9 *pD3d = NULL;
HWND hwnd = NULL;
pD3d = pDirect3DCreate9( D3D_SDK_VERSION );
if(!pD3d)
{
skip("Failed to create Direct3D9 object, not running tests\n");
return;
}
hwnd = CreateWindow( "static", "d3d9_test", WS_OVERLAPPEDWINDOW, 100, 100, 160, 160, NULL, NULL, NULL, NULL );
if(!hwnd)
{
skip("Failed to create window\n");
IDirect3D9_Release(pD3d);
return;
}
test_query_support(pD3d, hwnd);
DestroyWindow(hwnd);
IDirect3D9_Release(pD3d);
}
}

View File

@@ -0,0 +1,234 @@
/*
* Copyright (C) 2005 Henri Verbeet
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#define COBJMACROS
#include <d3d9.h>
#include "wine/test.h"
static HMODULE d3d9_handle = 0;
static HWND create_window(void)
{
WNDCLASS wc = {0};
wc.lpfnWndProc = &DefWindowProc;
wc.lpszClassName = "d3d9_test_wc";
RegisterClass(&wc);
return CreateWindow("d3d9_test_wc", "d3d9_test",
0, 0, 0, 0, 0, 0, 0, 0, 0);
}
static IDirect3DDevice9 *init_d3d9(void)
{
IDirect3D9 * (__stdcall * d3d9_create)(UINT SDKVersion) = 0;
IDirect3D9 *d3d9_ptr = 0;
IDirect3DDevice9 *device_ptr = 0;
D3DPRESENT_PARAMETERS present_parameters;
HRESULT hres;
d3d9_create = (void *)GetProcAddress(d3d9_handle, "Direct3DCreate9");
ok(d3d9_create != NULL, "Failed to get address of Direct3DCreate9\n");
if (!d3d9_create) return NULL;
d3d9_ptr = d3d9_create(D3D_SDK_VERSION);
ok(d3d9_ptr != NULL, "Failed to create IDirect3D9 object\n");
if (!d3d9_ptr) return NULL;
ZeroMemory(&present_parameters, sizeof(present_parameters));
present_parameters.Windowed = TRUE;
present_parameters.hDeviceWindow = create_window();
present_parameters.SwapEffect = D3DSWAPEFFECT_DISCARD;
hres = IDirect3D9_CreateDevice(d3d9_ptr, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, NULL, D3DCREATE_SOFTWARE_VERTEXPROCESSING, &present_parameters, &device_ptr);
if(FAILED(hres))
{
trace("could not create device, IDirect3D9_CreateDevice returned %#x\n", hres);
return NULL;
}
return device_ptr;
}
static int get_refcount(IUnknown *object)
{
IUnknown_AddRef(object);
return IUnknown_Release(object);
}
static void test_get_set_vertex_shader(IDirect3DDevice9 *device_ptr)
{
static DWORD simple_vs[] = {0xFFFE0101, /* vs_1_1 */
0x0000001F, 0x80000000, 0x900F0000, /* dcl_position0 v0 */
0x00000009, 0xC0010000, 0x90E40000, 0xA0E40000, /* dp4 oPos.x, v0, c0 */
0x00000009, 0xC0020000, 0x90E40000, 0xA0E40001, /* dp4 oPos.y, v0, c1 */
0x00000009, 0xC0040000, 0x90E40000, 0xA0E40002, /* dp4 oPos.z, v0, c2 */
0x00000009, 0xC0080000, 0x90E40000, 0xA0E40003, /* dp4 oPos.w, v0, c3 */
0x0000FFFF}; /* END */
IDirect3DVertexShader9 *shader_ptr = 0;
IDirect3DVertexShader9 *current_shader_ptr = 0;
HRESULT hret = 0;
int shader_refcount = 0;
int i = 0;
hret = IDirect3DDevice9_CreateVertexShader(device_ptr, simple_vs, &shader_ptr);
ok(hret == D3D_OK && shader_ptr != NULL, "CreateVertexShader returned: hret 0x%x, shader_ptr %p. "
"Expected hret 0x%x, shader_ptr != %p. Aborting.\n", hret, shader_ptr, D3D_OK, NULL);
if (hret != D3D_OK || shader_ptr == NULL) return;
/* SetVertexShader should not touch the shader's refcount. */
i = get_refcount((IUnknown *)shader_ptr);
hret = IDirect3DDevice9_SetVertexShader(device_ptr, shader_ptr);
shader_refcount = get_refcount((IUnknown *)shader_ptr);
ok(hret == D3D_OK && shader_refcount == i, "SetVertexShader returned: hret 0x%x, refcount %d. "
"Expected hret 0x%x, refcount %d.\n", hret, shader_refcount, D3D_OK, i);
/* GetVertexShader should increase the shader's refcount by one. */
i = shader_refcount+1;
hret = IDirect3DDevice9_GetVertexShader(device_ptr, &current_shader_ptr);
shader_refcount = get_refcount((IUnknown *)shader_ptr);
ok(hret == D3D_OK && shader_refcount == i && current_shader_ptr == shader_ptr,
"GetVertexShader returned: hret 0x%x, current_shader_ptr %p refcount %d. "
"Expected hret 0x%x, current_shader_ptr %p, refcount %d.\n", hret, current_shader_ptr, shader_refcount, D3D_OK, shader_ptr, i);
}
static void test_vertex_shader_constant(IDirect3DDevice9 *device_ptr, DWORD consts)
{
float c[4] = { 0.0, 0.0, 0.0, 0.0 };
float d[16] = { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 };
HRESULT hr;
/* A simple check that the stuff works at all */
hr = IDirect3DDevice9_SetVertexShaderConstantF(device_ptr, 0, c, 1);
ok(hr == D3D_OK, "IDirect3DDevice9_SetVertexShaderConstantF returned 0x%08x\n", hr);
/* Test corner cases: Write to const MAX - 1, MAX, MAX + 1, and writing 4 consts from
* MAX - 1
*/
hr = IDirect3DDevice9_SetVertexShaderConstantF(device_ptr, consts - 1, c, 1);
ok(hr == D3D_OK, "IDirect3DDevice9_SetVertexShaderConstantF returned 0x%08x\n", hr);
hr = IDirect3DDevice9_SetVertexShaderConstantF(device_ptr, consts + 0, c, 1);
ok(hr == D3DERR_INVALIDCALL, "IDirect3DDevice9_SetVertexShaderConstantF returned 0x%08x\n", hr);
hr = IDirect3DDevice9_SetVertexShaderConstantF(device_ptr, consts + 1, c, 1);
ok(hr == D3DERR_INVALIDCALL, "IDirect3DDevice9_SetVertexShaderConstantF returned 0x%08x\n", hr);
hr = IDirect3DDevice9_SetVertexShaderConstantF(device_ptr, consts - 1, d, 4);
ok(hr == D3DERR_INVALIDCALL, "IDirect3DDevice9_SetVertexShaderConstantF returned 0x%08x\n", hr);
/* Constant -1 */
hr = IDirect3DDevice9_SetVertexShaderConstantF(device_ptr, -1, c, 1);
ok(hr == D3DERR_INVALIDCALL, "IDirect3DDevice9_SetVertexShaderConstantF returned 0x%08x\n", hr);
}
static void test_get_set_pixel_shader(IDirect3DDevice9 *device_ptr)
{
static DWORD simple_ps[] = {0xFFFF0101, /* ps_1_1 */
0x00000051, 0xA00F0001, 0x3F800000, 0x00000000, 0x00000000, 0x00000000, /* def c1 = 1.0, 0.0, 0.0, 0.0 */
0x00000042, 0xB00F0000, /* tex t0 */
0x00000008, 0x800F0000, 0xA0E40001, 0xA0E40000, /* dp3 r0, c1, c0 */
0x00000005, 0x800F0000, 0x90E40000, 0x80E40000, /* mul r0, v0, r0 */
0x00000005, 0x800F0000, 0xB0E40000, 0x80E40000, /* mul r0, t0, r0 */
0x0000FFFF}; /* END */
IDirect3DPixelShader9 *shader_ptr = 0;
IDirect3DPixelShader9 *current_shader_ptr = 0;
HRESULT hret = 0;
int shader_refcount = 0;
int i = 0;
hret = IDirect3DDevice9_CreatePixelShader(device_ptr, simple_ps, &shader_ptr);
ok(hret == D3D_OK && shader_ptr != NULL, "CreatePixelShader returned: hret 0x%x, shader_ptr %p. "
"Expected hret 0x%x, shader_ptr != %p. Aborting.\n", hret, shader_ptr, D3D_OK, NULL);
if (hret != D3D_OK || shader_ptr == NULL) return;
/* SetPixelsShader should not touch the shader's refcount. */
i = get_refcount((IUnknown *)shader_ptr);
hret = IDirect3DDevice9_SetPixelShader(device_ptr, shader_ptr);
shader_refcount = get_refcount((IUnknown *)shader_ptr);
ok(hret == D3D_OK && shader_refcount == i, "SetPixelShader returned: hret 0x%x, refcount %d. "
"Expected hret 0x%x, refcount %d.\n", hret, shader_refcount, D3D_OK, i);
/* GetPixelShader should increase the shader's refcount by one. */
i = shader_refcount+1;
hret = IDirect3DDevice9_GetPixelShader(device_ptr, &current_shader_ptr);
shader_refcount = get_refcount((IUnknown *)shader_ptr);
ok(hret == D3D_OK && shader_refcount == i && current_shader_ptr == shader_ptr,
"GetPixelShader returned: hret 0x%x, current_shader_ptr %p refcount %d. "
"Expected hret 0x%x, current_shader_ptr %p, refcount %d.\n", hret, current_shader_ptr, shader_refcount, D3D_OK, shader_ptr, i);
}
static void test_pixel_shader_constant(IDirect3DDevice9 *device_ptr)
{
float c[4] = { 0.0, 0.0, 0.0, 0.0 };
float d[16] = { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 };
HRESULT hr;
DWORD consts = 0;
/* A simple check that the stuff works at all */
hr = IDirect3DDevice9_SetPixelShaderConstantF(device_ptr, 0, c, 1);
ok(hr == D3D_OK, "IDirect3DDevice9_SetVertexShaderConstantF returned 0x%08x\n", hr);
/* Is there really no max pixel shader constant value??? Test how far I can go */
while(SUCCEEDED(IDirect3DDevice9_SetPixelShaderConstantF(device_ptr, consts++, c, 1)));
consts = consts - 1;
trace("SetPixelShaderConstantF was able to set %d shader constants\n", consts);
/* Test corner cases: writing 4 consts from MAX - 1, everything else is pointless
* given the way the constant limit was found out
*/
hr = IDirect3DDevice9_SetPixelShaderConstantF(device_ptr, consts - 1, d, 4);
ok(hr == D3DERR_INVALIDCALL, "IDirect3DDevice9_SetPixelShaderConstantF returned 0x%08x\n", hr);
/* Constant -1 */
hr = IDirect3DDevice9_SetPixelShaderConstantF(device_ptr, -1, c, 1);
ok(hr == D3DERR_INVALIDCALL, "IDirect3DDevice9_SetPixelShaderConstantF returned 0x%08x\n", hr);
}
START_TEST(shader)
{
D3DCAPS9 caps;
IDirect3DDevice9 *device_ptr;
d3d9_handle = LoadLibraryA("d3d9.dll");
if (!d3d9_handle)
{
skip("Could not load d3d9.dll\n");
return;
}
device_ptr = init_d3d9();
if (!device_ptr) return;
IDirect3DDevice9_GetDeviceCaps(device_ptr, &caps);
if (caps.VertexShaderVersion & 0xffff)
{
test_get_set_vertex_shader(device_ptr);
test_vertex_shader_constant(device_ptr, caps.MaxVertexShaderConst);
}
else skip("No vertex shader support\n");
if (caps.PixelShaderVersion & 0xffff)
{
test_get_set_pixel_shader(device_ptr);
/* No max pixel shader constant value??? */
test_pixel_shader_constant(device_ptr);
}
else skip("No pixel shader support\n");
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,248 @@
/*
* Copyright 2006-2007 Henri Verbeet
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#define COBJMACROS
#include <d3d9.h>
#include <dxerr9.h>
#include "wine/test.h"
static HWND create_window(void)
{
WNDCLASS wc = {0};
wc.lpfnWndProc = &DefWindowProc;
wc.lpszClassName = "d3d9_test_wc";
RegisterClass(&wc);
return CreateWindow("d3d9_test_wc", "d3d9_test",
0, 0, 0, 0, 0, 0, 0, 0, 0);
}
static IDirect3DDevice9 *init_d3d9(HMODULE d3d9_handle)
{
IDirect3D9 * (__stdcall * d3d9_create)(UINT SDKVersion) = 0;
IDirect3D9 *d3d9_ptr = 0;
IDirect3DDevice9 *device_ptr = 0;
D3DPRESENT_PARAMETERS present_parameters;
HRESULT hr;
d3d9_create = (void *)GetProcAddress(d3d9_handle, "Direct3DCreate9");
ok(d3d9_create != NULL, "Failed to get address of Direct3DCreate9\n");
if (!d3d9_create) return NULL;
d3d9_ptr = d3d9_create(D3D_SDK_VERSION);
ok(d3d9_ptr != NULL, "Failed to create IDirect3D9 object\n");
if (!d3d9_ptr) return NULL;
ZeroMemory(&present_parameters, sizeof(present_parameters));
present_parameters.Windowed = TRUE;
present_parameters.hDeviceWindow = create_window();
present_parameters.SwapEffect = D3DSWAPEFFECT_DISCARD;
hr = IDirect3D9_CreateDevice(d3d9_ptr, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL,
NULL, D3DCREATE_SOFTWARE_VERTEXPROCESSING, &present_parameters, &device_ptr);
if(FAILED(hr))
{
trace("could not create device, IDirect3D9_CreateDevice returned %#x\n", hr);
return NULL;
}
return device_ptr;
}
static void test_surface_get_container(IDirect3DDevice9 *device_ptr)
{
IDirect3DTexture9 *texture_ptr = 0;
IDirect3DSurface9 *surface_ptr = 0;
void *container_ptr;
HRESULT hr;
hr = IDirect3DDevice9_CreateTexture(device_ptr, 128, 128, 1, 0,
D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &texture_ptr, 0);
ok(SUCCEEDED(hr) && texture_ptr != NULL, "CreateTexture returned: hr %#x, texture_ptr %p. "
"Expected hr %#x, texture_ptr != %p\n", hr, texture_ptr, D3D_OK, NULL);
if (!texture_ptr || FAILED(hr)) goto cleanup;
hr = IDirect3DTexture9_GetSurfaceLevel(texture_ptr, 0, &surface_ptr);
ok(SUCCEEDED(hr) && surface_ptr != NULL, "GetSurfaceLevel returned: hr %#x, surface_ptr %p. "
"Expected hr %#x, surface_ptr != %p\n", hr, surface_ptr, D3D_OK, NULL);
if (!surface_ptr || FAILED(hr)) goto cleanup;
/* These should work... */
container_ptr = (void *)0x1337c0d3;
hr = IDirect3DSurface9_GetContainer(surface_ptr, &IID_IUnknown, &container_ptr);
ok(SUCCEEDED(hr) && container_ptr == texture_ptr, "GetContainer returned: hr %#x, container_ptr %p. "
"Expected hr %#x, container_ptr %p\n", hr, container_ptr, S_OK, texture_ptr);
if (container_ptr && container_ptr != (void *)0x1337c0d3) IUnknown_Release((IUnknown *)container_ptr);
container_ptr = (void *)0x1337c0d3;
hr = IDirect3DSurface9_GetContainer(surface_ptr, &IID_IDirect3DResource9, &container_ptr);
ok(SUCCEEDED(hr) && container_ptr == texture_ptr, "GetContainer returned: hr %#x, container_ptr %p. "
"Expected hr %#x, container_ptr %p\n", hr, container_ptr, S_OK, texture_ptr);
if (container_ptr && container_ptr != (void *)0x1337c0d3) IUnknown_Release((IUnknown *)container_ptr);
container_ptr = (void *)0x1337c0d3;
hr = IDirect3DSurface9_GetContainer(surface_ptr, &IID_IDirect3DBaseTexture9, &container_ptr);
ok(SUCCEEDED(hr) && container_ptr == texture_ptr, "GetContainer returned: hr %#x, container_ptr %p. "
"Expected hr %#x, container_ptr %p\n", hr, container_ptr, S_OK, texture_ptr);
if (container_ptr && container_ptr != (void *)0x1337c0d3) IUnknown_Release((IUnknown *)container_ptr);
container_ptr = (void *)0x1337c0d3;
hr = IDirect3DSurface9_GetContainer(surface_ptr, &IID_IDirect3DTexture9, &container_ptr);
ok(SUCCEEDED(hr) && container_ptr == texture_ptr, "GetContainer returned: hr %#x, container_ptr %p. "
"Expected hr %#x, container_ptr %p\n", hr, container_ptr, S_OK, texture_ptr);
if (container_ptr && container_ptr != (void *)0x1337c0d3) IUnknown_Release((IUnknown *)container_ptr);
/* ...and this one shouldn't. This should return E_NOINTERFACE and set container_ptr to NULL */
container_ptr = (void *)0x1337c0d3;
hr = IDirect3DSurface9_GetContainer(surface_ptr, &IID_IDirect3DSurface9, &container_ptr);
ok(hr == E_NOINTERFACE && container_ptr == NULL, "GetContainer returned: hr %#x, container_ptr %p. "
"Expected hr %#x, container_ptr %p\n", hr, container_ptr, E_NOINTERFACE, NULL);
if (container_ptr && container_ptr != (void *)0x1337c0d3) IUnknown_Release((IUnknown *)container_ptr);
cleanup:
if (texture_ptr) IDirect3DTexture9_Release(texture_ptr);
if (surface_ptr) IDirect3DSurface9_Release(surface_ptr);
}
static void test_surface_alignment(IDirect3DDevice9 *device_ptr)
{
IDirect3DSurface9 *surface_ptr = 0;
HRESULT hr;
int i;
/* Test a sysmem surface as those aren't affected by the hardware's np2 restrictions */
hr = IDirect3DDevice9_CreateOffscreenPlainSurface(device_ptr, 5, 5, D3DFMT_R5G6B5, D3DPOOL_SYSTEMMEM, &surface_ptr, 0);
ok(hr == D3D_OK, "IDirect3DDevice9_CreateOffscreenPlainSurface returned %08x\n", hr);
if(surface_ptr)
{
D3DLOCKED_RECT lockedRect;
hr = IDirect3DSurface9_LockRect(surface_ptr, &lockedRect, NULL, 0);
ok(hr == D3D_OK, "IDirect3DSurface9_LockRect returned %08x\n", hr);
ok(!(lockedRect.Pitch & 3), "Surface pitch %d is not 32-bit aligned\n", lockedRect.Pitch);
/* Some applications also depend on the exact pitch, rather than just
* the alignment.
*/
ok(lockedRect.Pitch == 12, "Got pitch %d, expected 12\n", lockedRect.Pitch);
hr = IDirect3DSurface9_UnlockRect(surface_ptr);
IDirect3DSurface9_Release(surface_ptr);
}
for (i = 0; i < 5; i++)
{
IDirect3DTexture9 *pTexture;
int j, pitch;
hr = IDirect3DDevice9_CreateTexture(device_ptr, 64, 64, 0, 0, MAKEFOURCC('D', 'X', 'T', '1'+i),
D3DPOOL_MANAGED, &pTexture, NULL);
ok(SUCCEEDED(hr), "IDirect3DDevice9_CreateTexture: %s\n", DXGetErrorString9(hr));
if (FAILED(hr)) continue;
for (j = IDirect3DBaseTexture9_GetLevelCount(pTexture) - 1; j >= 0; j--)
{
D3DLOCKED_RECT rc;
D3DSURFACE_DESC descr;
IDirect3DTexture9_GetLevelDesc(pTexture, j, &descr);
hr = IDirect3DTexture9_LockRect(pTexture, j, &rc, NULL, 0);
ok(SUCCEEDED(hr), "IDirect3DTexture9_LockRect: %s\n", DXGetErrorString9(hr));
IDirect3DTexture9_UnlockRect(pTexture, j);
pitch = ((descr.Width + 3) >> 2) << 3;
if (i > 0) pitch <<= 1;
ok(rc.Pitch == pitch, "Wrong pitch for DXT%d lvl[%d (%dx%d)]: expected %d got %d\n",
i + 1, j, descr.Width, descr.Height, pitch, rc.Pitch);
}
IUnknown_Release( pTexture );
}
}
/* Since the DXT formats are based on 4x4 blocks, locking works slightly
* different than with regular formats. This patch verifies we return the
* correct memory offsets */
static void test_lockrect_offset(IDirect3DDevice9 *device)
{
IDirect3DSurface9 *surface = 0;
const RECT rect = {60, 60, 68, 68};
D3DLOCKED_RECT locked_rect;
unsigned int expected_offset;
unsigned int offset;
unsigned int i;
BYTE *base;
HRESULT hr;
const struct {
D3DFORMAT fmt;
const char *name;
unsigned int block_width;
unsigned int block_height;
unsigned int block_size;
} dxt_formats[] = {
{D3DFMT_DXT1, "D3DFMT_DXT1", 4, 4, 8},
{D3DFMT_DXT2, "D3DFMT_DXT2", 4, 4, 16},
{D3DFMT_DXT3, "D3DFMT_DXT3", 4, 4, 16},
{D3DFMT_DXT4, "D3DFMT_DXT4", 4, 4, 16},
{D3DFMT_DXT5, "D3DFMT_DXT5", 4, 4, 16},
};
for (i = 0; i < (sizeof(dxt_formats) / sizeof(*dxt_formats)); ++i) {
hr = IDirect3DDevice9_CreateOffscreenPlainSurface(device, 128, 128, dxt_formats[i].fmt, D3DPOOL_SCRATCH, &surface, 0);
ok(SUCCEEDED(hr), "CreateOffscreenPlainSurface failed (%08x)\n", hr);
hr = IDirect3DSurface9_LockRect(surface, &locked_rect, NULL, 0);
ok(SUCCEEDED(hr), "LockRect failed (%08x)\n", hr);
base = locked_rect.pBits;
hr = IDirect3DSurface9_UnlockRect(surface);
ok(SUCCEEDED(hr), "UnlockRect failed (%08x)\n", hr);
hr = IDirect3DSurface9_LockRect(surface, &locked_rect, &rect, 0);
ok(SUCCEEDED(hr), "LockRect failed (%08x)\n", hr);
offset = (BYTE *)locked_rect.pBits - base;
expected_offset = (rect.top / dxt_formats[i].block_height) * locked_rect.Pitch
+ (rect.left / dxt_formats[i].block_width) * dxt_formats[i].block_size;
ok(offset == expected_offset, "Got offset %u, expected offset %u for format %s\n", offset, expected_offset, dxt_formats[i].name);
hr = IDirect3DSurface9_UnlockRect(surface);
ok(SUCCEEDED(hr), "UnlockRect failed (%08x)\n", hr);
IDirect3DSurface9_Release(surface);
}
}
START_TEST(surface)
{
HMODULE d3d9_handle;
IDirect3DDevice9 *device_ptr;
d3d9_handle = LoadLibraryA("d3d9.dll");
if (!d3d9_handle)
{
skip("Could not load d3d9.dll\n");
return;
}
device_ptr = init_d3d9(d3d9_handle);
if (!device_ptr) return;
test_surface_get_container(device_ptr);
test_surface_alignment(device_ptr);
test_lockrect_offset(device_ptr);
}

View File

@@ -0,0 +1,31 @@
/* Automatically generated file; DO NOT EDIT!! */
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#define STANDALONE
#include "wine/test.h"
extern void func_device(void);
extern void func_query(void);
extern void func_shader(void);
extern void func_stateblock(void);
extern void func_surface(void);
extern void func_texture(void);
extern void func_vertexdeclaration(void);
extern void func_visual(void);
extern void func_volume(void);
const struct test winetest_testlist[] =
{
{ "device", func_device },
{ "query", func_query },
{ "shader", func_shader },
{ "stateblock", func_stateblock },
{ "surface", func_surface },
{ "texture", func_texture },
{ "vertexdeclaration", func_vertexdeclaration },
{ "visual", func_visual },
{ "volume", func_volume },
{ 0, 0 }
};

View File

@@ -0,0 +1,149 @@
/*
* Copyright (C) 2006 Henri Verbeet
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#define COBJMACROS
#include <d3d9.h>
#include "wine/test.h"
static HWND create_window(void)
{
WNDCLASS wc = {0};
wc.lpfnWndProc = &DefWindowProc;
wc.lpszClassName = "d3d9_test_wc";
RegisterClass(&wc);
return CreateWindow("d3d9_test_wc", "d3d9_test",
0, 0, 0, 0, 0, 0, 0, 0, 0);
}
static IDirect3DDevice9 *init_d3d9(HMODULE d3d9_handle)
{
IDirect3D9 * (__stdcall * d3d9_create)(UINT SDKVersion) = 0;
IDirect3D9 *d3d9_ptr = 0;
IDirect3DDevice9 *device_ptr = 0;
D3DPRESENT_PARAMETERS present_parameters;
HRESULT hr;
d3d9_create = (void *)GetProcAddress(d3d9_handle, "Direct3DCreate9");
ok(d3d9_create != NULL, "Failed to get address of Direct3DCreate9\n");
if (!d3d9_create) return NULL;
d3d9_ptr = d3d9_create(D3D_SDK_VERSION);
ok(d3d9_ptr != NULL, "Failed to create IDirect3D9 object\n");
if (!d3d9_ptr) return NULL;
ZeroMemory(&present_parameters, sizeof(present_parameters));
present_parameters.Windowed = TRUE;
present_parameters.hDeviceWindow = create_window();
present_parameters.SwapEffect = D3DSWAPEFFECT_DISCARD;
hr = IDirect3D9_CreateDevice(d3d9_ptr, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL,
NULL, D3DCREATE_SOFTWARE_VERTEXPROCESSING, &present_parameters, &device_ptr);
if(FAILED(hr))
{
trace("could not create device, IDirect3D9_CreateDevice returned %#x\n", hr);
return NULL;
}
return device_ptr;
}
static void test_texture_stage_state(IDirect3DDevice9 *device_ptr, DWORD stage, D3DTEXTURESTAGESTATETYPE type, DWORD expected)
{
DWORD value;
HRESULT hr = IDirect3DDevice9_GetTextureStageState(device_ptr, stage, type, &value);
ok(SUCCEEDED(hr) && value == expected, "GetTextureStageState (stage %#x, type %#x) returned: hr %#x, value %#x. "
"Expected hr %#x, value %#x\n", stage, type, hr, value, D3D_OK, expected);
}
/* Test the default texture stage state values */
static void test_texture_stage_states(IDirect3DDevice9 *device_ptr, int num_stages)
{
int i;
for (i = 0; i < num_stages; ++i)
{
test_texture_stage_state(device_ptr, i, D3DTSS_COLOROP, i ? D3DTOP_DISABLE : D3DTOP_MODULATE);
test_texture_stage_state(device_ptr, i, D3DTSS_COLORARG1, D3DTA_TEXTURE);
test_texture_stage_state(device_ptr, i, D3DTSS_COLORARG2, D3DTA_CURRENT);
test_texture_stage_state(device_ptr, i, D3DTSS_ALPHAOP, i ? D3DTOP_DISABLE : D3DTOP_SELECTARG1);
test_texture_stage_state(device_ptr, i, D3DTSS_ALPHAARG1, D3DTA_TEXTURE);
test_texture_stage_state(device_ptr, i, D3DTSS_ALPHAARG2, D3DTA_CURRENT);
test_texture_stage_state(device_ptr, i, D3DTSS_BUMPENVMAT00, 0);
test_texture_stage_state(device_ptr, i, D3DTSS_BUMPENVMAT01, 0);
test_texture_stage_state(device_ptr, i, D3DTSS_BUMPENVMAT10, 0);
test_texture_stage_state(device_ptr, i, D3DTSS_BUMPENVMAT11, 0);
test_texture_stage_state(device_ptr, i, D3DTSS_TEXCOORDINDEX, i);
test_texture_stage_state(device_ptr, i, D3DTSS_BUMPENVLSCALE, 0);
test_texture_stage_state(device_ptr, i, D3DTSS_BUMPENVLOFFSET, 0);
test_texture_stage_state(device_ptr, i, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_DISABLE);
test_texture_stage_state(device_ptr, i, D3DTSS_COLORARG0, D3DTA_CURRENT);
test_texture_stage_state(device_ptr, i, D3DTSS_ALPHAARG0, D3DTA_CURRENT);
test_texture_stage_state(device_ptr, i, D3DTSS_RESULTARG, D3DTA_CURRENT);
test_texture_stage_state(device_ptr, i, D3DTSS_CONSTANT, 0);
test_texture_stage_state(device_ptr, i, D3DTSS_FORCE_DWORD, 0);
}
}
static void test_cube_texture_from_pool(IDirect3DDevice9 *device_ptr, DWORD caps, D3DPOOL pool, BOOL need_cap)
{
IDirect3DCubeTexture9 *texture_ptr = NULL;
HRESULT hr;
hr = IDirect3DDevice9_CreateCubeTexture(device_ptr, 512, 1, 0, D3DFMT_X8R8G8B8, pool, &texture_ptr, NULL);
trace("pool=%d hr=0x%.8x\n", pool, hr);
if((caps & D3DPTEXTURECAPS_CUBEMAP) || !need_cap)
ok(SUCCEEDED(hr), "hr=0x%.8x\n", hr);
else
ok(hr == D3DERR_INVALIDCALL, "hr=0x%.8x\n", hr);
if(texture_ptr) IDirect3DCubeTexture9_Release(texture_ptr);
}
static void test_cube_textures(IDirect3DDevice9 *device_ptr, DWORD caps)
{
trace("texture caps: 0x%.8x\n", caps);
test_cube_texture_from_pool(device_ptr, caps, D3DPOOL_DEFAULT, TRUE);
test_cube_texture_from_pool(device_ptr, caps, D3DPOOL_MANAGED, TRUE);
test_cube_texture_from_pool(device_ptr, caps, D3DPOOL_SYSTEMMEM, TRUE);
test_cube_texture_from_pool(device_ptr, caps, D3DPOOL_SCRATCH, FALSE);
}
START_TEST(texture)
{
D3DCAPS9 caps;
HMODULE d3d9_handle;
IDirect3DDevice9 *device_ptr;
d3d9_handle = LoadLibraryA("d3d9.dll");
if (!d3d9_handle)
{
skip("Could not load d3d9.dll\n");
return;
}
device_ptr = init_d3d9(d3d9_handle);
if (!device_ptr) return;
IDirect3DDevice9_GetDeviceCaps(device_ptr, &caps);
test_texture_stage_states(device_ptr, caps.MaxTextureBlendStages);
test_cube_textures(device_ptr, caps.TextureCaps);
}

View File

@@ -0,0 +1,773 @@
/*
* Copyright (C) 2005 Henri Verbeet
* Copyright (C) 2006 Ivan Gyurdiev
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#define COBJMACROS
#include <d3d9.h>
#include "wine/test.h"
static HMODULE d3d9_handle = 0;
#define VDECL_CHECK(fcall) \
if(fcall != S_OK) \
trace(" Test failed on line #%d\n", __LINE__);
static HWND create_window(void)
{
WNDCLASS wc = {0};
wc.lpfnWndProc = &DefWindowProc;
wc.lpszClassName = "d3d9_test_wc";
RegisterClass(&wc);
return CreateWindow("d3d9_test_wc", "d3d9_test",
0, 0, 0, 0, 0, 0, 0, 0, 0);
}
static IDirect3DDevice9 *init_d3d9(void)
{
IDirect3D9 * (__stdcall * d3d9_create)(UINT SDKVersion) = 0;
IDirect3D9 *d3d9_ptr = 0;
IDirect3DDevice9 *device_ptr = 0;
D3DPRESENT_PARAMETERS present_parameters;
HRESULT hres;
d3d9_create = (void *)GetProcAddress(d3d9_handle, "Direct3DCreate9");
ok(d3d9_create != NULL, "Failed to get address of Direct3DCreate9\n");
if (!d3d9_create) return NULL;
d3d9_ptr = d3d9_create(D3D_SDK_VERSION);
ok(d3d9_ptr != NULL, "Failed to create IDirect3D9 object\n");
if (!d3d9_ptr) return NULL;
ZeroMemory(&present_parameters, sizeof(present_parameters));
present_parameters.Windowed = TRUE;
present_parameters.hDeviceWindow = create_window();
present_parameters.SwapEffect = D3DSWAPEFFECT_DISCARD;
hres = IDirect3D9_CreateDevice(d3d9_ptr, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, NULL, D3DCREATE_SOFTWARE_VERTEXPROCESSING, &present_parameters, &device_ptr);
if(FAILED(hres))
{
trace("could not create device, IDirect3D9_CreateDevice returned %#x\n", hres);
return NULL;
}
return device_ptr;
}
static int get_refcount(IUnknown *object)
{
IUnknown_AddRef(object);
return IUnknown_Release(object);
}
static inline void print_elements(
D3DVERTEXELEMENT9 *elements) {
D3DVERTEXELEMENT9 last = D3DDECL_END();
D3DVERTEXELEMENT9 *ptr = elements;
int count = 0;
while (memcmp(ptr, &last, sizeof(D3DVERTEXELEMENT9))) {
trace(
"[Element %d] Stream = %d, Offset = %d, Type = %d, Method = %d, Usage = %d, UsageIndex = %d\n",
count, ptr->Stream, ptr->Offset, ptr->Type, ptr->Method, ptr->Usage, ptr->UsageIndex);
ptr++;
count++;
}
}
static int compare_elements(
IDirect3DVertexDeclaration9 *decl,
const D3DVERTEXELEMENT9 *expected_elements) {
HRESULT hr;
unsigned int i, size;
D3DVERTEXELEMENT9 last = D3DDECL_END();
D3DVERTEXELEMENT9 *elements = NULL;
/* How many elements are there? */
hr = IDirect3DVertexDeclaration9_GetDeclaration( decl, NULL, &size );
ok(SUCCEEDED(hr), "GetDeclaration returned %#x, expected %#x\n", hr, D3D_OK);
if (FAILED(hr)) goto fail;
/* Allocate buffer */
elements = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(D3DVERTEXELEMENT9) * size);
ok (elements != NULL, "Out of memory, aborting test\n");
if (elements == NULL) goto fail;
/* Get the elements */
hr = IDirect3DVertexDeclaration9_GetDeclaration( decl, elements, &size);
ok(SUCCEEDED(hr), "GetDeclaration returned %#x, expected %#x\n", hr, D3D_OK);
if (FAILED(hr)) goto fail;
/* Compare one by one */
for (i = 0; i < size; i++) {
int status;
int end1 = memcmp(&elements[i], &last, sizeof(D3DVERTEXELEMENT9));
int end2 = memcmp(&expected_elements[i], &last, sizeof(D3DVERTEXELEMENT9));
status = ((end1 && !end2) || (!end1 && end2));
ok (!status, "Mismatch in size, test declaration is %s than expected\n",
(end1 && !end2) ? "shorter" : "longer");
if (status) { print_elements(elements); goto fail; }
status = memcmp(&elements[i], &expected_elements[i], sizeof(D3DVERTEXELEMENT9));
ok (!status, "Mismatch in element %d\n", i);
if (status) { print_elements(elements); goto fail; }
}
HeapFree(GetProcessHeap(), 0, elements);
return S_OK;
fail:
HeapFree(GetProcessHeap(), 0, elements);
return E_FAIL;
}
static IDirect3DVertexDeclaration9 *test_create_vertex_declaration(IDirect3DDevice9 *device_ptr, D3DVERTEXELEMENT9 *vertex_decl)
{
IDirect3DVertexDeclaration9 *decl_ptr = 0;
HRESULT hret = 0;
hret = IDirect3DDevice9_CreateVertexDeclaration(device_ptr, vertex_decl, &decl_ptr);
ok(hret == D3D_OK && decl_ptr != NULL, "CreateVertexDeclaration returned: hret 0x%x, decl_ptr %p. "
"Expected hret 0x%x, decl_ptr != %p. Aborting.\n", hret, decl_ptr, D3D_OK, NULL);
return decl_ptr;
}
static void test_get_set_vertex_declaration(IDirect3DDevice9 *device_ptr, IDirect3DVertexDeclaration9 *decl_ptr)
{
IDirect3DVertexDeclaration9 *current_decl_ptr = 0;
HRESULT hret = 0;
int decl_refcount = 0;
int i = 0;
/* SetVertexDeclaration should not touch the declaration's refcount. */
i = get_refcount((IUnknown *)decl_ptr);
hret = IDirect3DDevice9_SetVertexDeclaration(device_ptr, decl_ptr);
decl_refcount = get_refcount((IUnknown *)decl_ptr);
ok(hret == D3D_OK && decl_refcount == i, "SetVertexDeclaration returned: hret 0x%x, refcount %d. "
"Expected hret 0x%x, refcount %d.\n", hret, decl_refcount, D3D_OK, i);
/* GetVertexDeclaration should increase the declaration's refcount by one. */
i = decl_refcount+1;
hret = IDirect3DDevice9_GetVertexDeclaration(device_ptr, &current_decl_ptr);
decl_refcount = get_refcount((IUnknown *)decl_ptr);
ok(hret == D3D_OK && decl_refcount == i && current_decl_ptr == decl_ptr,
"GetVertexDeclaration returned: hret 0x%x, current_decl_ptr %p refcount %d. "
"Expected hret 0x%x, current_decl_ptr %p, refcount %d.\n", hret, current_decl_ptr, decl_refcount, D3D_OK, decl_ptr, i);
}
static void test_get_declaration(IDirect3DVertexDeclaration9 *decl_ptr, D3DVERTEXELEMENT9 *vertex_decl, UINT expected_num_elements)
{
int i;
UINT num_elements = 0;
D3DVERTEXELEMENT9 *decl = 0;
HRESULT hret = 0;
/* First test only getting the number of elements */
num_elements = 0x1337c0de;
hret = IDirect3DVertexDeclaration9_GetDeclaration(decl_ptr, NULL, &num_elements);
ok(hret == D3D_OK && num_elements == expected_num_elements,
"GetDeclaration returned: hret 0x%x, num_elements %d. "
"Expected hret 0x%x, num_elements %d.\n", hret, num_elements, D3D_OK, expected_num_elements);
num_elements = 0;
hret = IDirect3DVertexDeclaration9_GetDeclaration(decl_ptr, NULL, &num_elements);
ok(hret == D3D_OK && num_elements == expected_num_elements,
"GetDeclaration returned: hret 0x%x, num_elements %d. "
"Expected hret 0x%x, num_elements %d.\n", hret, num_elements, D3D_OK, expected_num_elements);
/* Also test the returned data */
decl = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(D3DVERTEXELEMENT9) * expected_num_elements);
num_elements = 0x1337c0de;
hret = IDirect3DVertexDeclaration9_GetDeclaration(decl_ptr, decl, &num_elements);
ok(hret == D3D_OK && num_elements == expected_num_elements,
"GetDeclaration returned: hret 0x%x, num_elements %d. "
"Expected hret 0x%x, num_elements %d.\n", hret, num_elements, D3D_OK, expected_num_elements);
i = memcmp(decl, vertex_decl, sizeof(vertex_decl));
ok (!i, "Original and returned vertexdeclarations are not the same\n");
ZeroMemory(decl, sizeof(D3DVERTEXELEMENT9) * expected_num_elements);
num_elements = 0;
hret = IDirect3DVertexDeclaration9_GetDeclaration(decl_ptr, decl, &num_elements);
ok(hret == D3D_OK && num_elements == expected_num_elements,
"GetDeclaration returned: hret 0x%x, num_elements %d. "
"Expected hret 0x%x, num_elements %d.\n", hret, num_elements, D3D_OK, expected_num_elements);
i = memcmp(decl, vertex_decl, sizeof(vertex_decl));
ok (!i, "Original and returned vertexdeclarations are not the same\n");
HeapFree(GetProcessHeap(), 0, decl);
}
/* FIXME: also write a test, which shows that attempting to set
* an invalid vertex declaration returns E_FAIL */
static HRESULT test_fvf_to_decl(
IDirect3DDevice9* device,
IDirect3DVertexDeclaration9* default_decl,
DWORD test_fvf,
const D3DVERTEXELEMENT9 expected_elements[],
char object_should_change)
{
HRESULT hr;
IDirect3DVertexDeclaration9 *result_decl = NULL;
/* Set a default declaration to make sure it is changed */
hr = IDirect3DDevice9_SetVertexDeclaration ( device, default_decl );
ok (SUCCEEDED(hr), "SetVertexDeclaration returned %#x, expected %#x\n", hr, D3D_OK);
if (FAILED(hr)) goto fail;
/* Set an FVF */
hr = IDirect3DDevice9_SetFVF( device, test_fvf);
ok(SUCCEEDED(hr), "SetFVF returned %#x, expected %#x\n", hr, D3D_OK);
if (FAILED(hr)) goto fail;
/* Check if the declaration object changed underneath */
hr = IDirect3DDevice9_GetVertexDeclaration ( device, &result_decl);
ok(SUCCEEDED(hr), "GetVertexDeclaration returned %#x, expected %#x\n", hr, D3D_OK);
if (FAILED(hr)) goto fail;
if (object_should_change) {
ok(result_decl != default_decl, "result declaration matches original\n");
if (result_decl == default_decl) goto fail;
} else {
ok(result_decl == default_decl, "result declaration does not match original\n");
if (result_decl != default_decl) goto fail;
}
/* Declaration content/size test */
ok(result_decl != NULL, "result declaration was null\n");
if (result_decl == NULL)
goto fail;
else if (compare_elements(result_decl, expected_elements) != S_OK)
goto fail;
if (result_decl) IUnknown_Release( result_decl );
return S_OK;
fail:
if (result_decl) IUnknown_Release( result_decl );
return E_FAIL;
}
static HRESULT test_decl_to_fvf(
IDirect3DDevice9* device,
DWORD default_fvf,
CONST D3DVERTEXELEMENT9 test_decl[],
DWORD test_fvf)
{
HRESULT hr;
IDirect3DVertexDeclaration9 *vdecl = NULL;
DWORD result_fvf = 0xdeadbeef;
/* Set a default FVF of SPECULAR and DIFFUSE to make sure it is changed back to 0 */
hr = IDirect3DDevice9_SetFVF( device, default_fvf);
ok(SUCCEEDED(hr), "SetFVF returned %#x, expected %#x\n", hr, D3D_OK);
if (FAILED(hr)) goto fail;
/* Create a testing declaration */
hr = IDirect3DDevice9_CreateVertexDeclaration( device, test_decl, &vdecl );
ok(SUCCEEDED(hr), "CreateVertexDeclaration returned %#x, expected %#x\n", hr, D3D_OK);
if (FAILED(hr)) goto fail;
/* Set the declaration */
hr = IDirect3DDevice9_SetVertexDeclaration ( device, vdecl );
ok (SUCCEEDED(hr), "SetVertexDeclaration returned %#x, expected %#x\n", hr, D3D_OK);
if (FAILED(hr)) goto fail;
/* Check the FVF */
hr = IDirect3DDevice9_GetFVF( device, &result_fvf);
ok(SUCCEEDED(hr), "GetFVF returned %#x, expected %#x\n", hr, D3D_OK);
if (FAILED(hr)) goto fail;
todo_wine {
ok(test_fvf == result_fvf, "result FVF was: %#x, expected: %#x\n", result_fvf, test_fvf);
}
if (test_fvf != result_fvf) goto fail;
IDirect3DDevice9_SetVertexDeclaration ( device, NULL );
if (vdecl) IUnknown_Release( vdecl );
return S_OK;
fail:
IDirect3DDevice9_SetVertexDeclaration ( device, NULL );
if (vdecl) IUnknown_Release( vdecl );
return E_FAIL;
}
static void test_fvf_decl_conversion(IDirect3DDevice9 *pDevice)
{
HRESULT hr;
unsigned int i;
IDirect3DVertexDeclaration9* default_decl = NULL;
DWORD default_fvf = D3DFVF_SPECULAR | D3DFVF_DIFFUSE;
D3DVERTEXELEMENT9 default_elements[] =
{ { 0, 0, D3DDECLTYPE_D3DCOLOR, 0, D3DDECLUSAGE_COLOR, 0 },
{ 0, 4, D3DDECLTYPE_D3DCOLOR, 0, D3DDECLUSAGE_COLOR, 1 }, D3DDECL_END() };
/* Create a default declaration and FVF that does not match any of the tests */
hr = IDirect3DDevice9_CreateVertexDeclaration( pDevice, default_elements, &default_decl );
ok(SUCCEEDED(hr), "CreateVertexDeclaration returned %#x, expected %#x\n", hr, D3D_OK);
if (FAILED(hr)) goto cleanup;
/* Test conversions from vertex declaration to an FVF.
* For some reason those seem to occur only for POSITION/POSITIONT,
* Otherwise the FVF is forced to 0 - maybe this is configuration specific */
{
CONST D3DVERTEXELEMENT9 test_buffer[] =
{ { 0, 0, D3DDECLTYPE_FLOAT3, 0, D3DDECLUSAGE_POSITION, 0 }, D3DDECL_END() };
VDECL_CHECK(test_decl_to_fvf(pDevice, default_fvf, test_buffer, D3DFVF_XYZ));
}
{
CONST D3DVERTEXELEMENT9 test_buffer[] =
{ { 0, 0, D3DDECLTYPE_FLOAT4, 0, D3DDECLUSAGE_POSITIONT, 0 }, D3DDECL_END() };
VDECL_CHECK(test_decl_to_fvf(pDevice, default_fvf, test_buffer, D3DFVF_XYZRHW));
}
for (i = 0; i < 4; i++) {
CONST D3DVERTEXELEMENT9 test_buffer[] =
{ { 0, 0, D3DDECLTYPE_FLOAT1+i, 0, D3DDECLUSAGE_BLENDWEIGHT, 0}, D3DDECL_END() };
VDECL_CHECK(test_decl_to_fvf(pDevice, default_fvf, test_buffer, 0));
}
{
CONST D3DVERTEXELEMENT9 test_buffer[] =
{ { 0, 0, D3DDECLTYPE_UBYTE4, 0, D3DDECLUSAGE_BLENDINDICES, 0}, D3DDECL_END() };
VDECL_CHECK(test_decl_to_fvf(pDevice, default_fvf, test_buffer, 0));
}
{
CONST D3DVERTEXELEMENT9 test_buffer[] =
{ { 0, 0, D3DDECLTYPE_FLOAT3, 0, D3DDECLUSAGE_NORMAL, 0 }, D3DDECL_END() };
VDECL_CHECK(test_decl_to_fvf(pDevice, default_fvf, test_buffer, 0));
}
{
CONST D3DVERTEXELEMENT9 test_buffer[] =
{ { 0, 0, D3DDECLTYPE_FLOAT1, 0, D3DDECLUSAGE_PSIZE, 0 }, D3DDECL_END() };
VDECL_CHECK(test_decl_to_fvf(pDevice, default_fvf, test_buffer, 0));
}
{
CONST D3DVERTEXELEMENT9 test_buffer[] =
{ { 0, 0, D3DDECLTYPE_D3DCOLOR, 0, D3DDECLUSAGE_COLOR, 0 }, D3DDECL_END() };
VDECL_CHECK(test_decl_to_fvf(pDevice, default_fvf, test_buffer, 0));
}
{
CONST D3DVERTEXELEMENT9 test_buffer[] =
{ { 0, 0, D3DDECLTYPE_D3DCOLOR, 0, D3DDECLUSAGE_COLOR, 1 }, D3DDECL_END() };
VDECL_CHECK(test_decl_to_fvf(pDevice, default_fvf, test_buffer, 0));
}
/* Make sure textures of different sizes work */
{
CONST D3DVERTEXELEMENT9 test_buffer[] =
{ { 0, 0, D3DDECLTYPE_FLOAT1, 0, D3DDECLUSAGE_TEXCOORD, 0 }, D3DDECL_END() };
VDECL_CHECK(test_decl_to_fvf(pDevice, default_fvf, test_buffer, 0));
}
{
CONST D3DVERTEXELEMENT9 test_buffer[] =
{ { 0, 0, D3DDECLTYPE_FLOAT2, 0, D3DDECLUSAGE_TEXCOORD, 0 }, D3DDECL_END() };
VDECL_CHECK(test_decl_to_fvf(pDevice, default_fvf, test_buffer, 0));
}
{
CONST D3DVERTEXELEMENT9 test_buffer[] =
{ { 0, 0, D3DDECLTYPE_FLOAT3, 0, D3DDECLUSAGE_TEXCOORD, 0 }, D3DDECL_END() };
VDECL_CHECK(test_decl_to_fvf(pDevice, default_fvf, test_buffer, 0));
}
{
CONST D3DVERTEXELEMENT9 test_buffer[] =
{ { 0, 0, D3DDECLTYPE_FLOAT4, 0, D3DDECLUSAGE_TEXCOORD, 0 }, D3DDECL_END() };
VDECL_CHECK(test_decl_to_fvf(pDevice, default_fvf, test_buffer, 0));
}
/* Make sure the TEXCOORD index works correctly - try several textures */
{
CONST D3DVERTEXELEMENT9 test_buffer[] =
{ { 0, 0, D3DDECLTYPE_FLOAT1, 0, D3DDECLUSAGE_TEXCOORD, 0 },
{ 0, 4, D3DDECLTYPE_FLOAT3, 0, D3DDECLUSAGE_TEXCOORD, 1 },
{ 0, 16, D3DDECLTYPE_FLOAT2, 0, D3DDECLUSAGE_TEXCOORD, 2 },
{ 0, 24, D3DDECLTYPE_FLOAT4, 0, D3DDECLUSAGE_TEXCOORD, 3 }, D3DDECL_END() };
VDECL_CHECK(test_decl_to_fvf(pDevice, default_fvf, test_buffer, 0));
}
/* No FVF mapping available */
{
CONST D3DVERTEXELEMENT9 test_buffer[] =
{ { 0, 0, D3DDECLTYPE_FLOAT3, 0, D3DDECLUSAGE_POSITION, 1 }, D3DDECL_END() };
VDECL_CHECK(test_decl_to_fvf(pDevice, default_fvf, test_buffer, 0));
}
{
CONST D3DVERTEXELEMENT9 test_buffer[] =
{ { 0, 0, D3DDECLTYPE_FLOAT3, 0, D3DDECLUSAGE_NORMAL, 1 }, D3DDECL_END() };
VDECL_CHECK(test_decl_to_fvf(pDevice, default_fvf, test_buffer, 0));
}
/* Try empty declaration */
{
CONST D3DVERTEXELEMENT9 test_buffer[] = { D3DDECL_END() };
VDECL_CHECK(test_decl_to_fvf(pDevice, default_fvf, test_buffer, 0));
}
/* Now try a combination test */
{
CONST D3DVERTEXELEMENT9 test_buffer[] =
{ { 0, 0, D3DDECLTYPE_FLOAT3, 0, D3DDECLUSAGE_POSITIONT, 0 },
{ 0, 12, D3DDECLTYPE_FLOAT3, 0, D3DDECLUSAGE_NORMAL, 0 },
{ 0, 24, D3DDECLTYPE_FLOAT1, 0, D3DDECLUSAGE_PSIZE, 0 },
{ 0, 28, D3DDECLTYPE_D3DCOLOR, 0, D3DDECLUSAGE_COLOR, 1 },
{ 0, 32, D3DDECLTYPE_FLOAT1, 0, D3DDECLUSAGE_TEXCOORD, 0 },
{ 0, 44, D3DDECLTYPE_FLOAT4, 0, D3DDECLUSAGE_TEXCOORD, 1 }, D3DDECL_END() };
VDECL_CHECK(test_decl_to_fvf(pDevice, default_fvf, test_buffer, 0));
}
/* Test conversions from FVF to a vertex declaration
* These seem to always occur internally. A new declaration object is created if necessary */
{
CONST D3DVERTEXELEMENT9 test_buffer[] =
{ { 0, 0, D3DDECLTYPE_FLOAT3, 0, D3DDECLUSAGE_POSITION, 0 }, D3DDECL_END() };
VDECL_CHECK(test_fvf_to_decl(pDevice, default_decl, D3DFVF_XYZ, test_buffer, 1));
}
{
CONST D3DVERTEXELEMENT9 test_buffer[] =
{ { 0, 0, D3DDECLTYPE_FLOAT4, 0, D3DDECLUSAGE_POSITIONT, 0 }, D3DDECL_END() };
VDECL_CHECK(test_fvf_to_decl(pDevice, default_decl, D3DFVF_XYZRHW, test_buffer, 1));
}
{
CONST D3DVERTEXELEMENT9 test_buffer[] =
{ { 0, 0, D3DDECLTYPE_FLOAT3, 0, D3DDECLUSAGE_POSITION, 0 },
{ 0, 12, D3DDECLTYPE_FLOAT4, 0, D3DDECLUSAGE_BLENDWEIGHT, 0 },
{ 0, 28, D3DDECLTYPE_UBYTE4, 0, D3DDECLUSAGE_BLENDINDICES, 0 }, D3DDECL_END() };
VDECL_CHECK(test_fvf_to_decl(pDevice, default_decl,
D3DFVF_XYZB5 | D3DFVF_LASTBETA_UBYTE4, test_buffer, 1));
}
{
CONST D3DVERTEXELEMENT9 test_buffer[] =
{ { 0, 0, D3DDECLTYPE_FLOAT3, 0, D3DDECLUSAGE_POSITION, 0 },
{ 0, 12, D3DDECLTYPE_FLOAT4, 0, D3DDECLUSAGE_BLENDWEIGHT, 0 },
{ 0, 28, D3DDECLTYPE_D3DCOLOR, 0, D3DDECLUSAGE_BLENDINDICES, 0 }, D3DDECL_END() };
VDECL_CHECK(test_fvf_to_decl(pDevice, default_decl,
D3DFVF_XYZB5 | D3DFVF_LASTBETA_D3DCOLOR, test_buffer, 1));
}
{
CONST D3DVERTEXELEMENT9 test_buffer[] =
{ { 0, 0, D3DDECLTYPE_FLOAT3, 0, D3DDECLUSAGE_POSITION, 0 },
{ 0, 12, D3DDECLTYPE_FLOAT4, 0, D3DDECLUSAGE_BLENDWEIGHT, 0 },
{ 0, 28, D3DDECLTYPE_FLOAT1, 0, D3DDECLUSAGE_BLENDINDICES, 0 }, D3DDECL_END() };
VDECL_CHECK(test_fvf_to_decl(pDevice, default_decl, D3DFVF_XYZB5, test_buffer, 1));
}
{
CONST D3DVERTEXELEMENT9 test_buffer[] =
{ { 0, 0, D3DDECLTYPE_FLOAT3, 0, D3DDECLUSAGE_POSITION, 0 },
{ 0, 12, D3DDECLTYPE_FLOAT1, 0, D3DDECLUSAGE_BLENDWEIGHT, 0 }, D3DDECL_END() };
VDECL_CHECK(test_fvf_to_decl(pDevice, default_decl, D3DFVF_XYZB1, test_buffer, 1));
}
{
CONST D3DVERTEXELEMENT9 test_buffer[] =
{ { 0, 0, D3DDECLTYPE_FLOAT3, 0, D3DDECLUSAGE_POSITION, 0 },
{ 0, 12, D3DDECLTYPE_UBYTE4, 0, D3DDECLUSAGE_BLENDINDICES, 0 }, D3DDECL_END() };
VDECL_CHECK(test_fvf_to_decl(pDevice, default_decl,
D3DFVF_XYZB1 | D3DFVF_LASTBETA_UBYTE4, test_buffer, 1));
}
{
CONST D3DVERTEXELEMENT9 test_buffer[] =
{ { 0, 0, D3DDECLTYPE_FLOAT3, 0, D3DDECLUSAGE_POSITION, 0 },
{ 0, 12, D3DDECLTYPE_D3DCOLOR, 0, D3DDECLUSAGE_BLENDINDICES, 0 }, D3DDECL_END() };
VDECL_CHECK(test_fvf_to_decl(pDevice, default_decl,
D3DFVF_XYZB1 | D3DFVF_LASTBETA_D3DCOLOR, test_buffer, 1));
}
{
CONST D3DVERTEXELEMENT9 test_buffer[] =
{ { 0, 0, D3DDECLTYPE_FLOAT3, 0, D3DDECLUSAGE_POSITION, 0 },
{ 0, 12, D3DDECLTYPE_FLOAT2, 0, D3DDECLUSAGE_BLENDWEIGHT, 0 }, D3DDECL_END() };
VDECL_CHECK(test_fvf_to_decl(pDevice, default_decl, D3DFVF_XYZB2, test_buffer, 1));
}
{
CONST D3DVERTEXELEMENT9 test_buffer[] =
{ { 0, 0, D3DDECLTYPE_FLOAT3, 0, D3DDECLUSAGE_POSITION, 0 },
{ 0, 12, D3DDECLTYPE_FLOAT1, 0, D3DDECLUSAGE_BLENDWEIGHT, 0 },
{ 0, 16, D3DDECLTYPE_UBYTE4, 0, D3DDECLUSAGE_BLENDINDICES, 0 }, D3DDECL_END() };
VDECL_CHECK(test_fvf_to_decl(pDevice, default_decl,
D3DFVF_XYZB2 | D3DFVF_LASTBETA_UBYTE4, test_buffer, 1));
}
{
CONST D3DVERTEXELEMENT9 test_buffer[] =
{ { 0, 0, D3DDECLTYPE_FLOAT3, 0, D3DDECLUSAGE_POSITION, 0 },
{ 0, 12, D3DDECLTYPE_D3DCOLOR, 0, D3DDECLUSAGE_BLENDWEIGHT, 0 },
{ 0, 16, D3DDECLTYPE_UBYTE4, 0, D3DDECLUSAGE_BLENDINDICES, 0 }, D3DDECL_END() };
VDECL_CHECK(test_fvf_to_decl(pDevice, default_decl,
D3DFVF_XYZB2 | D3DFVF_LASTBETA_D3DCOLOR, test_buffer, 1));
}
{
CONST D3DVERTEXELEMENT9 test_buffer[] =
{ { 0, 0, D3DDECLTYPE_FLOAT3, 0, D3DDECLUSAGE_POSITION, 0 },
{ 0, 12, D3DDECLTYPE_FLOAT3, 0, D3DDECLUSAGE_BLENDWEIGHT, 0 }, D3DDECL_END() };
VDECL_CHECK(test_fvf_to_decl(pDevice, default_decl, D3DFVF_XYZB3, test_buffer, 1));
}
{
CONST D3DVERTEXELEMENT9 test_buffer[] =
{ { 0, 0, D3DDECLTYPE_FLOAT3, 0, D3DDECLUSAGE_POSITION, 0 },
{ 0, 12, D3DDECLTYPE_FLOAT2, 0, D3DDECLUSAGE_BLENDWEIGHT, 0 },
{ 0, 20, D3DDECLTYPE_UBYTE4, 0, D3DDECLUSAGE_BLENDINDICES, 0 }, D3DDECL_END() };
VDECL_CHECK(test_fvf_to_decl(pDevice, default_decl,
D3DFVF_XYZB3 | D3DFVF_LASTBETA_UBYTE4, test_buffer, 1));
}
{
CONST D3DVERTEXELEMENT9 test_buffer[] =
{ { 0, 0, D3DDECLTYPE_FLOAT3, 0, D3DDECLUSAGE_POSITION, 0 },
{ 0, 12, D3DDECLTYPE_FLOAT2, 0, D3DDECLUSAGE_BLENDWEIGHT, 0 },
{ 0, 20, D3DDECLTYPE_D3DCOLOR, 0, D3DDECLUSAGE_BLENDINDICES, 0 }, D3DDECL_END() };
VDECL_CHECK(test_fvf_to_decl(pDevice, default_decl,
D3DFVF_XYZB3 | D3DFVF_LASTBETA_D3DCOLOR, test_buffer, 1));
}
{
CONST D3DVERTEXELEMENT9 test_buffer[] =
{ { 0, 0, D3DDECLTYPE_FLOAT3, 0, D3DDECLUSAGE_POSITION, 0 },
{ 0, 12, D3DDECLTYPE_FLOAT4, 0, D3DDECLUSAGE_BLENDWEIGHT, 0 }, D3DDECL_END() };
VDECL_CHECK(test_fvf_to_decl(pDevice, default_decl, D3DFVF_XYZB4, test_buffer, 1));
}
{
CONST D3DVERTEXELEMENT9 test_buffer[] =
{ { 0, 0, D3DDECLTYPE_FLOAT3, 0, D3DDECLUSAGE_POSITION, 0 },
{ 0, 12, D3DDECLTYPE_FLOAT3, 0, D3DDECLUSAGE_BLENDWEIGHT, 0 },
{ 0, 24, D3DDECLTYPE_UBYTE4, 0, D3DDECLUSAGE_BLENDINDICES, 0 }, D3DDECL_END() };
VDECL_CHECK(test_fvf_to_decl(pDevice, default_decl,
D3DFVF_XYZB4 | D3DFVF_LASTBETA_UBYTE4, test_buffer, 1));
}
{
CONST D3DVERTEXELEMENT9 test_buffer[] =
{ { 0, 0, D3DDECLTYPE_FLOAT3, 0, D3DDECLUSAGE_POSITION, 0 },
{ 0, 12, D3DDECLTYPE_FLOAT3, 0, D3DDECLUSAGE_BLENDWEIGHT, 0 },
{ 0, 24, D3DDECLTYPE_D3DCOLOR, 0, D3DDECLUSAGE_BLENDINDICES, 0 }, D3DDECL_END() };
VDECL_CHECK(test_fvf_to_decl(pDevice, default_decl,
D3DFVF_XYZB4 | D3DFVF_LASTBETA_D3DCOLOR, test_buffer, 1));
}
{
CONST D3DVERTEXELEMENT9 test_buffer[] =
{ { 0, 0, D3DDECLTYPE_FLOAT3, 0, D3DDECLUSAGE_NORMAL, 0 }, D3DDECL_END() };
VDECL_CHECK(test_fvf_to_decl(pDevice, default_decl, D3DFVF_NORMAL, test_buffer, 1));
}
{
CONST D3DVERTEXELEMENT9 test_buffer[] =
{ { 0, 0, D3DDECLTYPE_FLOAT1, 0, D3DDECLUSAGE_PSIZE, 0 }, D3DDECL_END() };
VDECL_CHECK(test_fvf_to_decl(pDevice, default_decl, D3DFVF_PSIZE, test_buffer, 1));
}
{
CONST D3DVERTEXELEMENT9 test_buffer[] =
{ { 0, 0, D3DDECLTYPE_D3DCOLOR, 0, D3DDECLUSAGE_COLOR, 0 }, D3DDECL_END() };
VDECL_CHECK(test_fvf_to_decl(pDevice, default_decl, D3DFVF_DIFFUSE, test_buffer, 1));
}
{
CONST D3DVERTEXELEMENT9 test_buffer[] =
{ { 0, 0, D3DDECLTYPE_D3DCOLOR, 0, D3DDECLUSAGE_COLOR, 1 }, D3DDECL_END() };
VDECL_CHECK(test_fvf_to_decl(pDevice, default_decl, D3DFVF_SPECULAR, test_buffer, 1));
}
/* Make sure textures of different sizes work */
{
CONST D3DVERTEXELEMENT9 test_buffer[] =
{ { 0, 0, D3DDECLTYPE_FLOAT1, 0, D3DDECLUSAGE_TEXCOORD, 0 }, D3DDECL_END() };
VDECL_CHECK(test_fvf_to_decl(pDevice, default_decl,
D3DFVF_TEXCOORDSIZE1(0) | D3DFVF_TEX1, test_buffer, 1));
}
{
CONST D3DVERTEXELEMENT9 test_buffer[] =
{ { 0, 0, D3DDECLTYPE_FLOAT2, 0, D3DDECLUSAGE_TEXCOORD, 0 }, D3DDECL_END() };
VDECL_CHECK(test_fvf_to_decl(pDevice, default_decl,
D3DFVF_TEXCOORDSIZE2(0) | D3DFVF_TEX1, test_buffer, 1));
}
{
CONST D3DVERTEXELEMENT9 test_buffer[] =
{ { 0, 0, D3DDECLTYPE_FLOAT3, 0, D3DDECLUSAGE_TEXCOORD, 0 }, D3DDECL_END() };
VDECL_CHECK(test_fvf_to_decl(pDevice, default_decl,
D3DFVF_TEXCOORDSIZE3(0) | D3DFVF_TEX1, test_buffer, 1));
}
{
CONST D3DVERTEXELEMENT9 test_buffer[] =
{ { 0, 0, D3DDECLTYPE_FLOAT4, 0, D3DDECLUSAGE_TEXCOORD, 0 }, D3DDECL_END() };
VDECL_CHECK(test_fvf_to_decl(pDevice, default_decl,
D3DFVF_TEXCOORDSIZE4(0) | D3DFVF_TEX1, test_buffer, 1));
}
/* Make sure the TEXCOORD index works correctly - try several textures */
{
CONST D3DVERTEXELEMENT9 test_buffer[] =
{ { 0, 0, D3DDECLTYPE_FLOAT1, 0, D3DDECLUSAGE_TEXCOORD, 0 },
{ 0, 4, D3DDECLTYPE_FLOAT3, 0, D3DDECLUSAGE_TEXCOORD, 1 },
{ 0, 16, D3DDECLTYPE_FLOAT2, 0, D3DDECLUSAGE_TEXCOORD, 2 },
{ 0, 24, D3DDECLTYPE_FLOAT4, 0, D3DDECLUSAGE_TEXCOORD, 3 }, D3DDECL_END() };
VDECL_CHECK(test_fvf_to_decl(pDevice, default_decl,
D3DFVF_TEXCOORDSIZE1(0) | D3DFVF_TEXCOORDSIZE3(1) | D3DFVF_TEXCOORDSIZE2(2) |
D3DFVF_TEXCOORDSIZE4(3) | D3DFVF_TEX4, test_buffer, 1));
}
/* Now try a combination test */
{
CONST D3DVERTEXELEMENT9 test_buffer[] =
{ { 0, 0, D3DDECLTYPE_FLOAT3, 0, D3DDECLUSAGE_POSITION, 0 },
{ 0, 12, D3DDECLTYPE_FLOAT4, 0, D3DDECLUSAGE_BLENDWEIGHT, 0 },
{ 0, 28, D3DDECLTYPE_D3DCOLOR, 0, D3DDECLUSAGE_COLOR, 0 },
{ 0, 32, D3DDECLTYPE_D3DCOLOR, 0, D3DDECLUSAGE_COLOR, 1 },
{ 0, 36, D3DDECLTYPE_FLOAT2, 0, D3DDECLUSAGE_TEXCOORD, 0 },
{ 0, 44, D3DDECLTYPE_FLOAT3, 0, D3DDECLUSAGE_TEXCOORD, 1 }, D3DDECL_END() };
VDECL_CHECK(test_fvf_to_decl(pDevice, default_decl, D3DFVF_XYZB4 | D3DFVF_SPECULAR | D3DFVF_DIFFUSE |
D3DFVF_TEXCOORDSIZE2(0) | D3DFVF_TEXCOORDSIZE3(1) | D3DFVF_TEX2, test_buffer, 1));
}
/* Setting the FVF to 0 should result in no change to the default decl */
VDECL_CHECK(test_fvf_to_decl(pDevice, default_decl, 0, default_elements, 0));
cleanup:
IDirect3DDevice9_SetVertexDeclaration ( pDevice, NULL );
if ( default_decl ) IUnknown_Release (default_decl);
}
/* Check whether a declaration converted from FVF is shared.
* Check whether refcounts behave as expected */
static void test_fvf_decl_management(
IDirect3DDevice9* device) {
HRESULT hr;
IDirect3DVertexDeclaration9* result_decl1 = NULL;
IDirect3DVertexDeclaration9* result_decl2 = NULL;
IDirect3DVertexDeclaration9* result_decl3 = NULL;
IDirect3DVertexDeclaration9* result_decl4 = NULL;
int ref1, ref2, ref3, ref4;
DWORD test_fvf1 = D3DFVF_XYZRHW;
DWORD test_fvf2 = D3DFVF_NORMAL;
CONST D3DVERTEXELEMENT9 test_elements1[] =
{ { 0, 0, D3DDECLTYPE_FLOAT4, 0, D3DDECLUSAGE_POSITIONT, 0 }, D3DDECL_END() };
CONST D3DVERTEXELEMENT9 test_elements2[] =
{ { 0, 0, D3DDECLTYPE_FLOAT3, 0, D3DDECLUSAGE_NORMAL, 0 }, D3DDECL_END() };
/* Clear down any current vertex declaration */
hr = IDirect3DDevice9_SetVertexDeclaration ( device, NULL );
ok (SUCCEEDED(hr), "SetVertexDeclaration returned %#x, expected %#x\n", hr, D3D_OK);
if (FAILED(hr)) return;
/* Conversion */
hr = IDirect3DDevice9_SetFVF( device, test_fvf1);
ok(SUCCEEDED(hr), "SetFVF returned %#x, expected %#x\n", hr, D3D_OK);
if (FAILED(hr)) return;
/* Get converted decl (#1) */
hr = IDirect3DDevice9_GetVertexDeclaration ( device, &result_decl1);
ok(SUCCEEDED(hr), "GetVertexDeclaration returned %#x, expected %#x\n", hr, D3D_OK);
if (FAILED(hr)) return;
/* Get converted decl again (#2) */
hr = IDirect3DDevice9_GetVertexDeclaration ( device, &result_decl2);
ok(SUCCEEDED(hr), "GetVertexDeclaration returned %#x, expected %#x\n", hr, D3D_OK);
if (FAILED(hr)) return;
/* Conversion */
hr = IDirect3DDevice9_SetFVF( device, test_fvf2);
ok(SUCCEEDED(hr), "SetFVF returned %#x, expected %#x\n", hr, D3D_OK);
if (FAILED(hr)) return;
/* The contents should correspond to the first conversion */
VDECL_CHECK(compare_elements(result_decl1, test_elements1));
/* Get converted decl (#3) */
hr = IDirect3DDevice9_GetVertexDeclaration ( device, &result_decl3);
ok(SUCCEEDED(hr), "GetVertexDeclaration returned %#x, expected %#x\n", hr, D3D_OK);
if (FAILED(hr)) return;
/* The object should be the same */
ok (result_decl1 == result_decl2, "Declaration object changes on the second Get() call\n");
ok (result_decl2 != result_decl3, "Declaration object did not change during conversion\n");
/* The contents should correspond to the second conversion */
VDECL_CHECK(compare_elements(result_decl3, test_elements2));
/* Re-Check if the first decl was overwritten by the new Get() */
VDECL_CHECK(compare_elements(result_decl1, test_elements1));
hr = IDirect3DDevice9_SetFVF( device, test_fvf1);
ok(SUCCEEDED(hr), "SetFVF returned %#x, expected %#x\n", hr, D3D_OK);
if (FAILED(hr)) return;
hr = IDirect3DDevice9_GetVertexDeclaration ( device, &result_decl4);
ok(SUCCEEDED(hr), "GetVertexDeclaration returned %#x, expected %#x\n", hr, D3D_OK);
if (FAILED(hr)) return;
ok(result_decl4 == result_decl1, "Setting an already used FVF over results in a different vertexdeclaration\n");
ref1 = get_refcount((IUnknown*) result_decl1);
ref2 = get_refcount((IUnknown*) result_decl2);
ref3 = get_refcount((IUnknown*) result_decl3);
ref4 = get_refcount((IUnknown*) result_decl4);
ok (ref1 == 3, "Refcount #1 is %d, expected 3\n", ref1);
ok (ref2 == 3, "Refcount #2 is %d, expected 3\n", ref2);
ok (ref3 == 1, "Refcount #3 is %d, expected 1\n", ref3);
ok (ref4 == 3, "Refcount #4 is %d, expected 3\n", ref4);
/* Clear down any current vertex declaration */
hr = IDirect3DDevice9_SetVertexDeclaration ( device, NULL );
ok (SUCCEEDED(hr), "SetVertexDeclaration returned %#x, expected %#x\n", hr, D3D_OK);
if (FAILED(hr)) return;
IDirect3DVertexDeclaration9_Release(result_decl1);
IDirect3DVertexDeclaration9_Release(result_decl2);
IDirect3DVertexDeclaration9_Release(result_decl3);
IDirect3DVertexDeclaration9_Release(result_decl4);
return;
}
START_TEST(vertexdeclaration)
{
static D3DVERTEXELEMENT9 simple_decl[] = {
{ 0, 0, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0 },
D3DDECL_END()};
UINT simple_decl_num_elements = sizeof(simple_decl) / sizeof(*simple_decl);
IDirect3DDevice9 *device_ptr = 0;
IDirect3DVertexDeclaration9 *decl_ptr = 0;
d3d9_handle = LoadLibraryA("d3d9.dll");
if (!d3d9_handle)
{
skip("Could not load d3d9.dll\n");
return;
}
device_ptr = init_d3d9();
if (!device_ptr)
{
skip("Failed to initialise d3d9\n");
return;
}
decl_ptr = test_create_vertex_declaration(device_ptr, simple_decl);
if (!decl_ptr)
{
skip("Failed to create a vertex declaration\n");
return;
}
test_get_set_vertex_declaration(device_ptr, decl_ptr);
test_get_declaration(decl_ptr, simple_decl, simple_decl_num_elements);
test_fvf_decl_conversion(device_ptr);
test_fvf_decl_management(device_ptr);
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,137 @@
/*
* Copyright (C) 2006 Henri Verbeet
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#define COBJMACROS
#include <d3d9.h>
#include "wine/test.h"
static HWND create_window(void)
{
WNDCLASS wc = {0};
wc.lpfnWndProc = &DefWindowProc;
wc.lpszClassName = "d3d9_test_wc";
RegisterClass(&wc);
return CreateWindow("d3d9_test_wc", "d3d9_test",
0, 0, 0, 0, 0, 0, 0, 0, 0);
}
static IDirect3DDevice9 *init_d3d9(HMODULE d3d9_handle)
{
IDirect3D9 * (__stdcall * d3d9_create)(UINT SDKVersion) = 0;
IDirect3D9 *d3d9_ptr = 0;
IDirect3DDevice9 *device_ptr = 0;
D3DPRESENT_PARAMETERS present_parameters;
HRESULT hr;
d3d9_create = (void *)GetProcAddress(d3d9_handle, "Direct3DCreate9");
ok(d3d9_create != NULL, "Failed to get address of Direct3DCreate9\n");
if (!d3d9_create) return NULL;
d3d9_ptr = d3d9_create(D3D_SDK_VERSION);
ok(d3d9_ptr != NULL, "Failed to create IDirect3D9 object\n");
if (!d3d9_ptr) return NULL;
ZeroMemory(&present_parameters, sizeof(present_parameters));
present_parameters.Windowed = TRUE;
present_parameters.hDeviceWindow = create_window();
present_parameters.SwapEffect = D3DSWAPEFFECT_DISCARD;
hr = IDirect3D9_CreateDevice(d3d9_ptr, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL,
NULL, D3DCREATE_SOFTWARE_VERTEXPROCESSING, &present_parameters, &device_ptr);
if(FAILED(hr))
{
trace("could not create device, IDirect3D9_CreateDevice returned %#x\n", hr);
return NULL;
}
return device_ptr;
}
static void test_volume_get_container(IDirect3DDevice9 *device_ptr)
{
IDirect3DVolumeTexture9 *texture_ptr = 0;
IDirect3DVolume9 *volume_ptr = 0;
void *container_ptr;
HRESULT hr;
hr = IDirect3DDevice9_CreateVolumeTexture(device_ptr, 128, 128, 128, 1, 0,
D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &texture_ptr, 0);
ok(SUCCEEDED(hr) && texture_ptr != NULL, "CreateVolumeTexture returned: hr %#x, texture_ptr %p. "
"Expected hr %#x, texture_ptr != %p\n", hr, texture_ptr, D3D_OK, NULL);
if (!texture_ptr || FAILED(hr)) goto cleanup;
hr = IDirect3DVolumeTexture9_GetVolumeLevel(texture_ptr, 0, &volume_ptr);
ok(SUCCEEDED(hr) && volume_ptr != NULL, "GetVolumeLevel returned: hr %#x, volume_ptr %p. "
"Expected hr %#x, volume_ptr != %p\n", hr, volume_ptr, D3D_OK, NULL);
if (!volume_ptr || FAILED(hr)) goto cleanup;
/* These should work... */
container_ptr = (void *)0x1337c0d3;
hr = IDirect3DVolume9_GetContainer(volume_ptr, &IID_IUnknown, &container_ptr);
ok(SUCCEEDED(hr) && container_ptr == texture_ptr, "GetContainer returned: hr %#x, container_ptr %p. "
"Expected hr %#x, container_ptr %p\n", hr, container_ptr, S_OK, texture_ptr);
if (container_ptr && container_ptr != (void *)0x1337c0d3) IUnknown_Release((IUnknown *)container_ptr);
container_ptr = (void *)0x1337c0d3;
hr = IDirect3DVolume9_GetContainer(volume_ptr, &IID_IDirect3DResource9, &container_ptr);
ok(SUCCEEDED(hr) && container_ptr == texture_ptr, "GetContainer returned: hr %#x, container_ptr %p. "
"Expected hr %#x, container_ptr %p\n", hr, container_ptr, S_OK, texture_ptr);
if (container_ptr && container_ptr != (void *)0x1337c0d3) IUnknown_Release((IUnknown *)container_ptr);
container_ptr = (void *)0x1337c0d3;
hr = IDirect3DVolume9_GetContainer(volume_ptr, &IID_IDirect3DBaseTexture9, &container_ptr);
ok(SUCCEEDED(hr) && container_ptr == texture_ptr, "GetContainer returned: hr %#x, container_ptr %p. "
"Expected hr %#x, container_ptr %p\n", hr, container_ptr, S_OK, texture_ptr);
if (container_ptr && container_ptr != (void *)0x1337c0d3) IUnknown_Release((IUnknown *)container_ptr);
container_ptr = (void *)0x1337c0d3;
hr = IDirect3DVolume9_GetContainer(volume_ptr, &IID_IDirect3DVolumeTexture9, &container_ptr);
ok(SUCCEEDED(hr) && container_ptr == texture_ptr, "GetContainer returned: hr %#x, container_ptr %p. "
"Expected hr %#x, container_ptr %p\n", hr, container_ptr, S_OK, texture_ptr);
if (container_ptr && container_ptr != (void *)0x1337c0d3) IUnknown_Release((IUnknown *)container_ptr);
/* ...and this one shouldn't. This should return E_NOINTERFACE and set container_ptr to NULL */
container_ptr = (void *)0x1337c0d3;
hr = IDirect3DVolume9_GetContainer(volume_ptr, &IID_IDirect3DVolume9, &container_ptr);
ok(hr == E_NOINTERFACE && container_ptr == NULL, "GetContainer returned: hr %#x, container_ptr %p. "
"Expected hr %#x, container_ptr %p\n", hr, container_ptr, E_NOINTERFACE, NULL);
if (container_ptr && container_ptr != (void *)0x1337c0d3) IUnknown_Release((IUnknown *)container_ptr);
cleanup:
if (texture_ptr) IDirect3DVolumeTexture9_Release(texture_ptr);
if (volume_ptr) IDirect3DVolume9_Release(volume_ptr);
}
START_TEST(volume)
{
HMODULE d3d9_handle;
IDirect3DDevice9 *device_ptr;
d3d9_handle = LoadLibraryA("d3d9.dll");
if (!d3d9_handle)
{
skip("Could not load d3d9.dll\n");
return;
}
device_ptr = init_d3d9(d3d9_handle);
if (!device_ptr) return;
test_volume_get_container(device_ptr);
}

View File

@@ -0,0 +1,275 @@
/*
* IDirect3DTexture9 implementation
*
* Copyright 2002-2005 Jason Edmeades
* Copyright 2002-2005 Raphael Junqueira
* Copyright 2005 Oliver Stieber
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "config.h"
#include "d3d9_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(d3d9);
/* IDirect3DTexture9 IUnknown parts follow: */
static HRESULT WINAPI IDirect3DTexture9Impl_QueryInterface(LPDIRECT3DTEXTURE9 iface, REFIID riid, LPVOID* ppobj) {
IDirect3DTexture9Impl *This = (IDirect3DTexture9Impl *)iface;
if (IsEqualGUID(riid, &IID_IUnknown)
|| IsEqualGUID(riid, &IID_IDirect3DResource9)
|| IsEqualGUID(riid, &IID_IDirect3DBaseTexture9)
|| IsEqualGUID(riid, &IID_IDirect3DTexture9)) {
IUnknown_AddRef(iface);
*ppobj = This;
return S_OK;
}
WARN("(%p)->(%s,%p) not found\n", This, debugstr_guid(riid), ppobj);
*ppobj = NULL;
return E_NOINTERFACE;
}
static ULONG WINAPI IDirect3DTexture9Impl_AddRef(LPDIRECT3DTEXTURE9 iface) {
IDirect3DTexture9Impl *This = (IDirect3DTexture9Impl *)iface;
ULONG ref = InterlockedIncrement(&This->ref);
TRACE("(%p) : AddRef from %d\n", This, ref - 1);
return ref;
}
static ULONG WINAPI IDirect3DTexture9Impl_Release(LPDIRECT3DTEXTURE9 iface) {
IDirect3DTexture9Impl *This = (IDirect3DTexture9Impl *)iface;
ULONG ref = InterlockedDecrement(&This->ref);
TRACE("(%p) : ReleaseRef to %d\n", This, ref);
if (ref == 0) {
IWineD3DTexture_Destroy(This->wineD3DTexture, D3D9CB_DestroySurface);
IUnknown_Release(This->parentDevice);
HeapFree(GetProcessHeap(), 0, This);
}
return ref;
}
/* IDirect3DTexture9 IDirect3DResource9 Interface follow: */
static HRESULT WINAPI IDirect3DTexture9Impl_GetDevice(LPDIRECT3DTEXTURE9 iface, IDirect3DDevice9** ppDevice) {
IDirect3DTexture9Impl *This = (IDirect3DTexture9Impl *)iface;
TRACE("(%p) Relay\n", This);
return IDirect3DResource9Impl_GetDevice((LPDIRECT3DRESOURCE9) This, ppDevice);
}
static HRESULT WINAPI IDirect3DTexture9Impl_SetPrivateData(LPDIRECT3DTEXTURE9 iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) {
IDirect3DTexture9Impl *This = (IDirect3DTexture9Impl *)iface;
TRACE("(%p) Relay\n", This);
return IWineD3DTexture_SetPrivateData(This->wineD3DTexture, refguid, pData, SizeOfData, Flags);
}
static HRESULT WINAPI IDirect3DTexture9Impl_GetPrivateData(LPDIRECT3DTEXTURE9 iface, REFGUID refguid, void* pData, DWORD* pSizeOfData) {
IDirect3DTexture9Impl *This = (IDirect3DTexture9Impl *)iface;
TRACE("(%p) Relay\n", This);
return IWineD3DTexture_GetPrivateData(This->wineD3DTexture, refguid, pData, pSizeOfData);
}
static HRESULT WINAPI IDirect3DTexture9Impl_FreePrivateData(LPDIRECT3DTEXTURE9 iface, REFGUID refguid) {
IDirect3DTexture9Impl *This = (IDirect3DTexture9Impl *)iface;
TRACE("(%p) Relay\n", This);
return IWineD3DTexture_FreePrivateData(This->wineD3DTexture, refguid);
}
static DWORD WINAPI IDirect3DTexture9Impl_SetPriority(LPDIRECT3DTEXTURE9 iface, DWORD PriorityNew) {
IDirect3DTexture9Impl *This = (IDirect3DTexture9Impl *)iface;
TRACE("(%p) Relay\n", This);
return IWineD3DTexture_SetPriority(This->wineD3DTexture, PriorityNew);
}
static DWORD WINAPI IDirect3DTexture9Impl_GetPriority(LPDIRECT3DTEXTURE9 iface) {
IDirect3DTexture9Impl *This = (IDirect3DTexture9Impl *)iface;
TRACE("(%p) Relay\n", This);
return IWineD3DTexture_GetPriority(This->wineD3DTexture);
}
static void WINAPI IDirect3DTexture9Impl_PreLoad(LPDIRECT3DTEXTURE9 iface) {
IDirect3DTexture9Impl *This = (IDirect3DTexture9Impl *)iface;
TRACE("(%p) Relay\n", This);
IWineD3DTexture_PreLoad(This->wineD3DTexture);
}
static D3DRESOURCETYPE WINAPI IDirect3DTexture9Impl_GetType(LPDIRECT3DTEXTURE9 iface) {
IDirect3DTexture9Impl *This = (IDirect3DTexture9Impl *)iface;
TRACE("(%p) Relay\n", This);
return IWineD3DTexture_GetType(This->wineD3DTexture);
}
/* IDirect3DTexture9 IDirect3DBaseTexture9 Interface follow: */
static DWORD WINAPI IDirect3DTexture9Impl_SetLOD(LPDIRECT3DTEXTURE9 iface, DWORD LODNew) {
IDirect3DTexture9Impl *This = (IDirect3DTexture9Impl *)iface;
TRACE("(%p) Relay\n", This);
return IWineD3DTexture_SetLOD(This->wineD3DTexture, LODNew);
}
static DWORD WINAPI IDirect3DTexture9Impl_GetLOD(LPDIRECT3DTEXTURE9 iface) {
IDirect3DTexture9Impl *This = (IDirect3DTexture9Impl *)iface;
TRACE("(%p) Relay\n", This);
return IWineD3DTexture_GetLOD(This->wineD3DTexture);
}
static DWORD WINAPI IDirect3DTexture9Impl_GetLevelCount(LPDIRECT3DTEXTURE9 iface) {
IDirect3DTexture9Impl *This = (IDirect3DTexture9Impl *)iface;
TRACE("(%p) Relay\n", This);
return IWineD3DTexture_GetLevelCount(This->wineD3DTexture);
}
static HRESULT WINAPI IDirect3DTexture9Impl_SetAutoGenFilterType(LPDIRECT3DTEXTURE9 iface, D3DTEXTUREFILTERTYPE FilterType) {
IDirect3DTexture9Impl *This = (IDirect3DTexture9Impl *)iface;
TRACE("(%p) Relay\n", This);
return IWineD3DTexture_SetAutoGenFilterType(This->wineD3DTexture, (WINED3DTEXTUREFILTERTYPE) FilterType);
}
static D3DTEXTUREFILTERTYPE WINAPI IDirect3DTexture9Impl_GetAutoGenFilterType(LPDIRECT3DTEXTURE9 iface) {
IDirect3DTexture9Impl *This = (IDirect3DTexture9Impl *)iface;
TRACE("(%p) Relay\n", This);
return (D3DTEXTUREFILTERTYPE) IWineD3DTexture_GetAutoGenFilterType(This->wineD3DTexture);
}
static void WINAPI IDirect3DTexture9Impl_GenerateMipSubLevels(LPDIRECT3DTEXTURE9 iface) {
IDirect3DTexture9Impl *This = (IDirect3DTexture9Impl *)iface;
TRACE("(%p) Relay\n", This);
IWineD3DTexture_GenerateMipSubLevels(This->wineD3DTexture);
}
/* IDirect3DTexture9 Interface follow: */
static HRESULT WINAPI IDirect3DTexture9Impl_GetLevelDesc(LPDIRECT3DTEXTURE9 iface, UINT Level, D3DSURFACE_DESC* pDesc) {
IDirect3DTexture9Impl *This = (IDirect3DTexture9Impl *)iface;
WINED3DSURFACE_DESC wined3ddesc;
UINT tmpInt = -1;
TRACE("(%p) Relay\n", This);
/* As d3d8 and d3d9 structures differ, pass in ptrs to where data needs to go */
wined3ddesc.Format = (WINED3DFORMAT *)&pDesc->Format;
wined3ddesc.Type = (WINED3DRESOURCETYPE *)&pDesc->Type;
wined3ddesc.Usage = &pDesc->Usage;
wined3ddesc.Pool = (WINED3DPOOL *) &pDesc->Pool;
wined3ddesc.Size = &tmpInt; /* required for d3d8 */
wined3ddesc.MultiSampleType = (WINED3DMULTISAMPLE_TYPE *) &pDesc->MultiSampleType;
wined3ddesc.MultiSampleQuality = &pDesc->MultiSampleQuality;
wined3ddesc.Width = &pDesc->Width;
wined3ddesc.Height = &pDesc->Height;
return IWineD3DTexture_GetLevelDesc(This->wineD3DTexture, Level, &wined3ddesc);
}
static HRESULT WINAPI IDirect3DTexture9Impl_GetSurfaceLevel(LPDIRECT3DTEXTURE9 iface, UINT Level, IDirect3DSurface9** ppSurfaceLevel) {
IDirect3DTexture9Impl *This = (IDirect3DTexture9Impl *)iface;
HRESULT hrc = D3D_OK;
IWineD3DSurface *mySurface = NULL;
TRACE("(%p) Relay\n", This);
hrc = IWineD3DTexture_GetSurfaceLevel(This->wineD3DTexture, Level, &mySurface);
if (hrc == D3D_OK && NULL != ppSurfaceLevel) {
IWineD3DSurface_GetParent(mySurface, (IUnknown **)ppSurfaceLevel);
IWineD3DSurface_Release(mySurface);
}
return hrc;
}
static HRESULT WINAPI IDirect3DTexture9Impl_LockRect(LPDIRECT3DTEXTURE9 iface, UINT Level, D3DLOCKED_RECT* pLockedRect, CONST RECT* pRect, DWORD Flags) {
IDirect3DTexture9Impl *This = (IDirect3DTexture9Impl *)iface;
TRACE("(%p) Relay\n", This);
return IWineD3DTexture_LockRect(This->wineD3DTexture, Level, (WINED3DLOCKED_RECT *) pLockedRect, pRect, Flags);
}
static HRESULT WINAPI IDirect3DTexture9Impl_UnlockRect(LPDIRECT3DTEXTURE9 iface, UINT Level) {
IDirect3DTexture9Impl *This = (IDirect3DTexture9Impl *)iface;
TRACE("(%p) Relay\n", This);
return IWineD3DTexture_UnlockRect(This->wineD3DTexture, Level);
}
static HRESULT WINAPI IDirect3DTexture9Impl_AddDirtyRect(LPDIRECT3DTEXTURE9 iface, CONST RECT* pDirtyRect) {
IDirect3DTexture9Impl *This = (IDirect3DTexture9Impl *)iface;
TRACE("(%p) Relay\n", This);
return IWineD3DTexture_AddDirtyRect(This->wineD3DTexture, pDirtyRect);
}
static const IDirect3DTexture9Vtbl Direct3DTexture9_Vtbl =
{
/* IUnknown */
IDirect3DTexture9Impl_QueryInterface,
IDirect3DTexture9Impl_AddRef,
IDirect3DTexture9Impl_Release,
/* IDirect3DResource9 */
IDirect3DTexture9Impl_GetDevice,
IDirect3DTexture9Impl_SetPrivateData,
IDirect3DTexture9Impl_GetPrivateData,
IDirect3DTexture9Impl_FreePrivateData,
IDirect3DTexture9Impl_SetPriority,
IDirect3DTexture9Impl_GetPriority,
IDirect3DTexture9Impl_PreLoad,
IDirect3DTexture9Impl_GetType,
/* IDirect3dBaseTexture9 */
IDirect3DTexture9Impl_SetLOD,
IDirect3DTexture9Impl_GetLOD,
IDirect3DTexture9Impl_GetLevelCount,
IDirect3DTexture9Impl_SetAutoGenFilterType,
IDirect3DTexture9Impl_GetAutoGenFilterType,
IDirect3DTexture9Impl_GenerateMipSubLevels,
/* IDirect3DTexture9 */
IDirect3DTexture9Impl_GetLevelDesc,
IDirect3DTexture9Impl_GetSurfaceLevel,
IDirect3DTexture9Impl_LockRect,
IDirect3DTexture9Impl_UnlockRect,
IDirect3DTexture9Impl_AddDirtyRect
};
/* IDirect3DDevice9 IDirect3DTexture9 Methods follow: */
HRESULT WINAPI IDirect3DDevice9Impl_CreateTexture(LPDIRECT3DDEVICE9 iface, UINT Width, UINT Height, UINT Levels, DWORD Usage,
D3DFORMAT Format, D3DPOOL Pool, IDirect3DTexture9** ppTexture, HANDLE* pSharedHandle) {
IDirect3DTexture9Impl *object;
IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
HRESULT hrc = D3D_OK;
TRACE("(%p) : W(%d) H(%d), Lvl(%d) d(%d), Fmt(%u), Pool(%d)\n", This, Width, Height, Levels, Usage, Format, Pool);
/* Allocate the storage for the device */
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3DTexture9Impl));
if (NULL == object) {
FIXME("Allocation of memory failed, returning D3DERR_OUTOFVIDEOMEMORY\n");
return D3DERR_OUTOFVIDEOMEMORY;
}
object->lpVtbl = &Direct3DTexture9_Vtbl;
object->ref = 1;
hrc = IWineD3DDevice_CreateTexture(This->WineD3DDevice, Width, Height, Levels, Usage & WINED3DUSAGE_MASK,
(WINED3DFORMAT)Format, (WINED3DPOOL) Pool, &object->wineD3DTexture, pSharedHandle, (IUnknown *)object, D3D9CB_CreateSurface);
if (FAILED(hrc)) {
/* free up object */
FIXME("(%p) call to IWineD3DDevice_CreateTexture failed\n", This);
HeapFree(GetProcessHeap(), 0, object);
} else {
IUnknown_AddRef(iface);
object->parentDevice = iface;
*ppTexture= (LPDIRECT3DTEXTURE9) object;
TRACE("(%p) Created Texture %p, %p\n", This, object, object->wineD3DTexture);
}
return hrc;
}

View File

@@ -0,0 +1,26 @@
/*
* Copyright 2001 Ove Kaaven
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#define WINE_FILEDESCRIPTION_STR "Wine Direct3D"
#define WINE_FILENAME_STR "d3d9.dll"
#define WINE_FILEVERSION 5,3,1,904
#define WINE_FILEVERSION_STR "5.3.1.904"
#define WINE_PRODUCTVERSION 5,3,1,904
#define WINE_PRODUCTVERSION_STR "5.3.1.904"
#include "wine/wine_common_ver.rc"

View File

@@ -0,0 +1,191 @@
/*
* IDirect3DVertexBuffer9 implementation
*
* Copyright 2002-2004 Jason Edmeades
* Copyright 2002-2004 Raphael Junqueira
* Copyright 2005 Oliver Stieber
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "config.h"
#include "d3d9_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(d3d9);
/* IDirect3DVertexBuffer9 IUnknown parts follow: */
static HRESULT WINAPI IDirect3DVertexBuffer9Impl_QueryInterface(LPDIRECT3DVERTEXBUFFER9 iface, REFIID riid, LPVOID* ppobj) {
IDirect3DVertexBuffer9Impl *This = (IDirect3DVertexBuffer9Impl *)iface;
if (IsEqualGUID(riid, &IID_IUnknown)
|| IsEqualGUID(riid, &IID_IDirect3DResource9)
|| IsEqualGUID(riid, &IID_IDirect3DVertexBuffer9)) {
IUnknown_AddRef(iface);
*ppobj = This;
return S_OK;
}
WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);
*ppobj = NULL;
return E_NOINTERFACE;
}
static ULONG WINAPI IDirect3DVertexBuffer9Impl_AddRef(LPDIRECT3DVERTEXBUFFER9 iface) {
IDirect3DVertexBuffer9Impl *This = (IDirect3DVertexBuffer9Impl *)iface;
ULONG ref = InterlockedIncrement(&This->ref);
TRACE("(%p) : AddRef from %d\n", This, ref - 1);
return ref;
}
static ULONG WINAPI IDirect3DVertexBuffer9Impl_Release(LPDIRECT3DVERTEXBUFFER9 iface) {
IDirect3DVertexBuffer9Impl *This = (IDirect3DVertexBuffer9Impl *)iface;
ULONG ref = InterlockedDecrement(&This->ref);
TRACE("(%p) : ReleaseRef to %d\n", This, ref);
if (ref == 0) {
IWineD3DVertexBuffer_Release(This->wineD3DVertexBuffer);
IUnknown_Release(This->parentDevice);
HeapFree(GetProcessHeap(), 0, This);
}
return ref;
}
/* IDirect3DVertexBuffer9 IDirect3DResource9 Interface follow: */
static HRESULT WINAPI IDirect3DVertexBuffer9Impl_GetDevice(LPDIRECT3DVERTEXBUFFER9 iface, IDirect3DDevice9** ppDevice) {
IDirect3DVertexBuffer9Impl *This = (IDirect3DVertexBuffer9Impl *)iface;
TRACE("(%p) Relay\n", This);
return IDirect3DResource9Impl_GetDevice((LPDIRECT3DRESOURCE9) This, ppDevice);
}
static HRESULT WINAPI IDirect3DVertexBuffer9Impl_SetPrivateData(LPDIRECT3DVERTEXBUFFER9 iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) {
IDirect3DVertexBuffer9Impl *This = (IDirect3DVertexBuffer9Impl *)iface;
TRACE("(%p) Relay\n", This);
return IWineD3DVertexBuffer_SetPrivateData(This->wineD3DVertexBuffer, refguid, pData, SizeOfData, Flags);
}
static HRESULT WINAPI IDirect3DVertexBuffer9Impl_GetPrivateData(LPDIRECT3DVERTEXBUFFER9 iface, REFGUID refguid, void* pData, DWORD* pSizeOfData) {
IDirect3DVertexBuffer9Impl *This = (IDirect3DVertexBuffer9Impl *)iface;
TRACE("(%p) Relay\n", This);
return IWineD3DVertexBuffer_GetPrivateData(This->wineD3DVertexBuffer, refguid, pData, pSizeOfData);
}
static HRESULT WINAPI IDirect3DVertexBuffer9Impl_FreePrivateData(LPDIRECT3DVERTEXBUFFER9 iface, REFGUID refguid) {
IDirect3DVertexBuffer9Impl *This = (IDirect3DVertexBuffer9Impl *)iface;
TRACE("(%p) Relay\n", This);
return IWineD3DVertexBuffer_FreePrivateData(This->wineD3DVertexBuffer, refguid);
}
static DWORD WINAPI IDirect3DVertexBuffer9Impl_SetPriority(LPDIRECT3DVERTEXBUFFER9 iface, DWORD PriorityNew) {
IDirect3DVertexBuffer9Impl *This = (IDirect3DVertexBuffer9Impl *)iface;
TRACE("(%p) Relay\n", This);
return IWineD3DVertexBuffer_SetPriority(This->wineD3DVertexBuffer, PriorityNew);
}
static DWORD WINAPI IDirect3DVertexBuffer9Impl_GetPriority(LPDIRECT3DVERTEXBUFFER9 iface) {
IDirect3DVertexBuffer9Impl *This = (IDirect3DVertexBuffer9Impl *)iface;
TRACE("(%p) Relay\n", This);
return IWineD3DVertexBuffer_GetPriority(This->wineD3DVertexBuffer);
}
static void WINAPI IDirect3DVertexBuffer9Impl_PreLoad(LPDIRECT3DVERTEXBUFFER9 iface) {
IDirect3DVertexBuffer9Impl *This = (IDirect3DVertexBuffer9Impl *)iface;
TRACE("(%p) Relay\n", This);
IWineD3DVertexBuffer_PreLoad(This->wineD3DVertexBuffer);
return ;
}
static D3DRESOURCETYPE WINAPI IDirect3DVertexBuffer9Impl_GetType(LPDIRECT3DVERTEXBUFFER9 iface) {
IDirect3DVertexBuffer9Impl *This = (IDirect3DVertexBuffer9Impl *)iface;
TRACE("(%p) Relay\n", This);
return IWineD3DVertexBuffer_GetType(This->wineD3DVertexBuffer);
}
/* IDirect3DVertexBuffer9 Interface follow: */
static HRESULT WINAPI IDirect3DVertexBuffer9Impl_Lock(LPDIRECT3DVERTEXBUFFER9 iface, UINT OffsetToLock, UINT SizeToLock, void** ppbData, DWORD Flags) {
IDirect3DVertexBuffer9Impl *This = (IDirect3DVertexBuffer9Impl *)iface;
TRACE("(%p) Relay\n", This);
return IWineD3DVertexBuffer_Lock(This->wineD3DVertexBuffer, OffsetToLock, SizeToLock, (BYTE **)ppbData, Flags);
}
static HRESULT WINAPI IDirect3DVertexBuffer9Impl_Unlock(LPDIRECT3DVERTEXBUFFER9 iface) {
IDirect3DVertexBuffer9Impl *This = (IDirect3DVertexBuffer9Impl *)iface;
TRACE("(%p) Relay\n", This);
return IWineD3DVertexBuffer_Unlock(This->wineD3DVertexBuffer);
}
static HRESULT WINAPI IDirect3DVertexBuffer9Impl_GetDesc(LPDIRECT3DVERTEXBUFFER9 iface, D3DVERTEXBUFFER_DESC* pDesc) {
IDirect3DVertexBuffer9Impl *This = (IDirect3DVertexBuffer9Impl *)iface;
TRACE("(%p) Relay\n", This);
return IWineD3DVertexBuffer_GetDesc(This->wineD3DVertexBuffer, (WINED3DVERTEXBUFFER_DESC *) pDesc);
}
static const IDirect3DVertexBuffer9Vtbl Direct3DVertexBuffer9_Vtbl =
{
/* IUnknown */
IDirect3DVertexBuffer9Impl_QueryInterface,
IDirect3DVertexBuffer9Impl_AddRef,
IDirect3DVertexBuffer9Impl_Release,
/* IDirect3DResource9 */
IDirect3DVertexBuffer9Impl_GetDevice,
IDirect3DVertexBuffer9Impl_SetPrivateData,
IDirect3DVertexBuffer9Impl_GetPrivateData,
IDirect3DVertexBuffer9Impl_FreePrivateData,
IDirect3DVertexBuffer9Impl_SetPriority,
IDirect3DVertexBuffer9Impl_GetPriority,
IDirect3DVertexBuffer9Impl_PreLoad,
IDirect3DVertexBuffer9Impl_GetType,
/* IDirect3DVertexBuffer9 */
IDirect3DVertexBuffer9Impl_Lock,
IDirect3DVertexBuffer9Impl_Unlock,
IDirect3DVertexBuffer9Impl_GetDesc
};
/* IDirect3DDevice9 IDirect3DVertexBuffer9 Methods follow: */
HRESULT WINAPI IDirect3DDevice9Impl_CreateVertexBuffer(LPDIRECT3DDEVICE9 iface,
UINT Size, DWORD Usage, DWORD FVF, D3DPOOL Pool,
IDirect3DVertexBuffer9** ppVertexBuffer, HANDLE* pSharedHandle) {
IDirect3DVertexBuffer9Impl *object;
IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
HRESULT hrc = D3D_OK;
/* Allocate the storage for the device */
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3DVertexBuffer9Impl));
if (NULL == object) {
FIXME("Allocation of memory failed, returning D3DERR_OUTOFVIDEOMEMORY\n");
return D3DERR_OUTOFVIDEOMEMORY;
}
object->lpVtbl = &Direct3DVertexBuffer9_Vtbl;
object->ref = 1;
hrc = IWineD3DDevice_CreateVertexBuffer(This->WineD3DDevice, Size, Usage & WINED3DUSAGE_MASK, FVF, (WINED3DPOOL) Pool, &(object->wineD3DVertexBuffer), pSharedHandle, (IUnknown *)object);
if (hrc != D3D_OK) {
/* free up object */
FIXME("(%p) call to IWineD3DDevice_CreateVertexBuffer failed\n", This);
HeapFree(GetProcessHeap(), 0, object);
} else {
IUnknown_AddRef(iface);
object->parentDevice = iface;
TRACE("(%p) : Created vertex buffer %p\n", This, object);
*ppVertexBuffer = (LPDIRECT3DVERTEXBUFFER9) object;
}
return hrc;
}

View File

@@ -0,0 +1,408 @@
/*
* IDirect3DVertexDeclaration9 implementation
*
* Copyright 2002-2003 Raphael Junqueira
* Jason Edmeades
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "config.h"
#include "d3d9_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(d3d9);
typedef struct _D3DDECLTYPE_INFO {
D3DDECLTYPE d3dType;
int size;
int typesize;
} D3DDECLTYPE_INFO;
static D3DDECLTYPE_INFO const d3d_dtype_lookup[D3DDECLTYPE_UNUSED] = {
{D3DDECLTYPE_FLOAT1, 1, sizeof(float)},
{D3DDECLTYPE_FLOAT2, 2, sizeof(float)},
{D3DDECLTYPE_FLOAT3, 3, sizeof(float)},
{D3DDECLTYPE_FLOAT4, 4, sizeof(float)},
{D3DDECLTYPE_D3DCOLOR, 4, sizeof(BYTE)},
{D3DDECLTYPE_UBYTE4, 4, sizeof(BYTE)},
{D3DDECLTYPE_SHORT2, 2, sizeof(short int)},
{D3DDECLTYPE_SHORT4, 4, sizeof(short int)},
{D3DDECLTYPE_UBYTE4N, 4, sizeof(BYTE)},
{D3DDECLTYPE_SHORT2N, 2, sizeof(short int)},
{D3DDECLTYPE_SHORT4N, 4, sizeof(short int)},
{D3DDECLTYPE_USHORT2N, 2, sizeof(short int)},
{D3DDECLTYPE_USHORT4N, 4, sizeof(short int)},
{D3DDECLTYPE_UDEC3, 3, sizeof(short int)},
{D3DDECLTYPE_DEC3N, 3, sizeof(short int)},
{D3DDECLTYPE_FLOAT16_2, 2, sizeof(short int)},
{D3DDECLTYPE_FLOAT16_4, 4, sizeof(short int)}};
#define D3D_DECL_SIZE(type) d3d_dtype_lookup[type].size
#define D3D_DECL_TYPESIZE(type) d3d_dtype_lookup[type].typesize
HRESULT vdecl_convert_fvf(
DWORD fvf,
D3DVERTEXELEMENT9** ppVertexElements) {
unsigned int idx, idx2;
unsigned int offset;
BOOL has_pos = (fvf & D3DFVF_POSITION_MASK) != 0;
BOOL has_blend = (fvf & D3DFVF_XYZB5) > D3DFVF_XYZRHW;
BOOL has_blend_idx = has_blend &&
(((fvf & D3DFVF_XYZB5) == D3DFVF_XYZB5) ||
(fvf & D3DFVF_LASTBETA_D3DCOLOR) ||
(fvf & D3DFVF_LASTBETA_UBYTE4));
BOOL has_normal = (fvf & D3DFVF_NORMAL) != 0;
BOOL has_psize = (fvf & D3DFVF_PSIZE) != 0;
BOOL has_diffuse = (fvf & D3DFVF_DIFFUSE) != 0;
BOOL has_specular = (fvf & D3DFVF_SPECULAR) !=0;
DWORD num_textures = (fvf & D3DFVF_TEXCOUNT_MASK) >> D3DFVF_TEXCOUNT_SHIFT;
DWORD texcoords = (fvf & 0x00FF0000) >> 16;
D3DVERTEXELEMENT9 end_element = D3DDECL_END();
D3DVERTEXELEMENT9 *elements = NULL;
unsigned int size;
DWORD num_blends = 1 + (((fvf & D3DFVF_XYZB5) - D3DFVF_XYZB1) >> 1);
if (has_blend_idx) num_blends--;
/* Compute declaration size */
size = has_pos + (has_blend && num_blends > 0) + has_blend_idx + has_normal +
has_psize + has_diffuse + has_specular + num_textures + 1;
/* convert the declaration */
elements = HeapAlloc(GetProcessHeap(), 0, size * sizeof(D3DVERTEXELEMENT9));
if (!elements)
return D3DERR_OUTOFVIDEOMEMORY;
memcpy(&elements[size-1], &end_element, sizeof(D3DVERTEXELEMENT9));
idx = 0;
if (has_pos) {
if (!has_blend && (fvf & D3DFVF_XYZRHW)) {
elements[idx].Type = D3DDECLTYPE_FLOAT4;
elements[idx].Usage = D3DDECLUSAGE_POSITIONT;
}
else {
elements[idx].Type = D3DDECLTYPE_FLOAT3;
elements[idx].Usage = D3DDECLUSAGE_POSITION;
}
elements[idx].UsageIndex = 0;
idx++;
}
if (has_blend && (num_blends > 0)) {
if (((fvf & D3DFVF_XYZB5) == D3DFVF_XYZB2) && (fvf & D3DFVF_LASTBETA_D3DCOLOR))
elements[idx].Type = D3DDECLTYPE_D3DCOLOR;
else
elements[idx].Type = D3DDECLTYPE_FLOAT1 + num_blends - 1;
elements[idx].Usage = D3DDECLUSAGE_BLENDWEIGHT;
elements[idx].UsageIndex = 0;
idx++;
}
if (has_blend_idx) {
if (fvf & D3DFVF_LASTBETA_UBYTE4 ||
(((fvf & D3DFVF_XYZB5) == D3DFVF_XYZB2) && (fvf & D3DFVF_LASTBETA_D3DCOLOR)))
elements[idx].Type = D3DDECLTYPE_UBYTE4;
else if (fvf & D3DFVF_LASTBETA_D3DCOLOR)
elements[idx].Type = D3DDECLTYPE_D3DCOLOR;
else
elements[idx].Type = D3DDECLTYPE_FLOAT1;
elements[idx].Usage = D3DDECLUSAGE_BLENDINDICES;
elements[idx].UsageIndex = 0;
idx++;
}
if (has_normal) {
elements[idx].Type = D3DDECLTYPE_FLOAT3;
elements[idx].Usage = D3DDECLUSAGE_NORMAL;
elements[idx].UsageIndex = 0;
idx++;
}
if (has_psize) {
elements[idx].Type = D3DDECLTYPE_FLOAT1;
elements[idx].Usage = D3DDECLUSAGE_PSIZE;
elements[idx].UsageIndex = 0;
idx++;
}
if (has_diffuse) {
elements[idx].Type = D3DDECLTYPE_D3DCOLOR;
elements[idx].Usage = D3DDECLUSAGE_COLOR;
elements[idx].UsageIndex = 0;
idx++;
}
if (has_specular) {
elements[idx].Type = D3DDECLTYPE_D3DCOLOR;
elements[idx].Usage = D3DDECLUSAGE_COLOR;
elements[idx].UsageIndex = 1;
idx++;
}
for (idx2 = 0; idx2 < num_textures; idx2++) {
unsigned int numcoords = (texcoords >> (idx2*2)) & 0x03;
switch (numcoords) {
case D3DFVF_TEXTUREFORMAT1:
elements[idx].Type = D3DDECLTYPE_FLOAT1;
break;
case D3DFVF_TEXTUREFORMAT2:
elements[idx].Type = D3DDECLTYPE_FLOAT2;
break;
case D3DFVF_TEXTUREFORMAT3:
elements[idx].Type = D3DDECLTYPE_FLOAT3;
break;
case D3DFVF_TEXTUREFORMAT4:
elements[idx].Type = D3DDECLTYPE_FLOAT4;
break;
}
elements[idx].Usage = D3DDECLUSAGE_TEXCOORD;
elements[idx].UsageIndex = idx2;
idx++;
}
/* Now compute offsets, and initialize the rest of the fields */
for (idx = 0, offset = 0; idx < size-1; idx++) {
elements[idx].Stream = 0;
elements[idx].Method = D3DDECLMETHOD_DEFAULT;
elements[idx].Offset = offset;
offset += D3D_DECL_SIZE(elements[idx].Type) * D3D_DECL_TYPESIZE(elements[idx].Type);
}
*ppVertexElements = elements;
return D3D_OK;
}
/* IDirect3DVertexDeclaration9 IUnknown parts follow: */
static HRESULT WINAPI IDirect3DVertexDeclaration9Impl_QueryInterface(LPDIRECT3DVERTEXDECLARATION9 iface, REFIID riid, LPVOID* ppobj) {
IDirect3DVertexDeclaration9Impl *This = (IDirect3DVertexDeclaration9Impl *)iface;
if (IsEqualGUID(riid, &IID_IUnknown)
|| IsEqualGUID(riid, &IID_IDirect3DVertexDeclaration9)) {
IUnknown_AddRef(iface);
*ppobj = This;
return S_OK;
}
WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);
*ppobj = NULL;
return E_NOINTERFACE;
}
static ULONG WINAPI IDirect3DVertexDeclaration9Impl_AddRef(LPDIRECT3DVERTEXDECLARATION9 iface) {
IDirect3DVertexDeclaration9Impl *This = (IDirect3DVertexDeclaration9Impl *)iface;
ULONG ref = InterlockedIncrement(&This->ref);
TRACE("(%p) : AddRef from %d\n", This, ref - 1);
if(ref == 1) {
IUnknown_AddRef(This->parentDevice);
}
return ref;
}
void IDirect3DVertexDeclaration9Impl_Destroy(LPDIRECT3DVERTEXDECLARATION9 iface) {
IDirect3DVertexDeclaration9Impl *This = (IDirect3DVertexDeclaration9Impl *)iface;
if(This->ref != 0) {
/* Should not happen unless wine has a bug or the application releases references it does not own */
ERR("Destroying vdecl with ref != 0\n");
}
IWineD3DVertexDeclaration_Release(This->wineD3DVertexDeclaration);
HeapFree(GetProcessHeap(), 0, This->elements);
HeapFree(GetProcessHeap(), 0, This);
}
static ULONG WINAPI IDirect3DVertexDeclaration9Impl_Release(LPDIRECT3DVERTEXDECLARATION9 iface) {
IDirect3DVertexDeclaration9Impl *This = (IDirect3DVertexDeclaration9Impl *)iface;
ULONG ref = InterlockedDecrement(&This->ref);
TRACE("(%p) : ReleaseRef to %d\n", This, ref);
if (ref == 0) {
IDirect3DDevice9 *parentDevice = This->parentDevice;
if(!This->convFVF) {
IDirect3DVertexDeclaration9Impl_Release(iface);
}
IUnknown_Release(parentDevice);
}
return ref;
}
/* IDirect3DVertexDeclaration9 Interface follow: */
static HRESULT WINAPI IDirect3DVertexDeclaration9Impl_GetDevice(LPDIRECT3DVERTEXDECLARATION9 iface, IDirect3DDevice9** ppDevice) {
IDirect3DVertexDeclaration9Impl *This = (IDirect3DVertexDeclaration9Impl *)iface;
IWineD3DDevice *myDevice = NULL;
HRESULT hr = D3D_OK;
TRACE("(%p) : Relay\n", iface);
hr = IWineD3DVertexDeclaration_GetDevice(This->wineD3DVertexDeclaration, &myDevice);
if (hr == D3D_OK && myDevice != NULL) {
hr = IWineD3DDevice_GetParent(myDevice, (IUnknown **)ppDevice);
IWineD3DDevice_Release(myDevice);
}
return hr;
}
static HRESULT WINAPI IDirect3DVertexDeclaration9Impl_GetDeclaration(LPDIRECT3DVERTEXDECLARATION9 iface, D3DVERTEXELEMENT9* pDecl, UINT* pNumElements) {
IDirect3DVertexDeclaration9Impl *This = (IDirect3DVertexDeclaration9Impl *)iface;
TRACE("(%p) : pDecl %p, pNumElements %p)\n", This, pDecl, pNumElements);
*pNumElements = This->element_count;
/* Passing a NULL pDecl is used to just retrieve the number of elements */
if (!pDecl) {
TRACE("NULL pDecl passed. Returning D3D_OK.\n");
return D3D_OK;
}
TRACE("Copying %p to %p\n", This->elements, pDecl);
CopyMemory(pDecl, This->elements, This->element_count * sizeof(D3DVERTEXELEMENT9));
return D3D_OK;
}
static const IDirect3DVertexDeclaration9Vtbl Direct3DVertexDeclaration9_Vtbl =
{
/* IUnknown */
IDirect3DVertexDeclaration9Impl_QueryInterface,
IDirect3DVertexDeclaration9Impl_AddRef,
IDirect3DVertexDeclaration9Impl_Release,
/* IDirect3DVertexDeclaration9 */
IDirect3DVertexDeclaration9Impl_GetDevice,
IDirect3DVertexDeclaration9Impl_GetDeclaration
};
static size_t convert_to_wined3d_declaration(const D3DVERTEXELEMENT9* d3d9_elements, WINED3DVERTEXELEMENT **wined3d_elements) {
const D3DVERTEXELEMENT9* element;
size_t element_count = 1;
size_t i;
TRACE("d3d9_elements %p, wined3d_elements %p\n", d3d9_elements, wined3d_elements);
element = d3d9_elements;
while (element++->Stream != 0xff && element_count++ < 128);
if (element_count == 128) {
return 0;
}
*wined3d_elements = HeapAlloc(GetProcessHeap(), 0, element_count * sizeof(WINED3DVERTEXELEMENT));
if (!*wined3d_elements) {
FIXME("Memory allocation failed\n");
return 0;
}
for (i = 0; i < element_count; ++i) {
CopyMemory(*wined3d_elements + i, d3d9_elements + i, sizeof(D3DVERTEXELEMENT9));
(*wined3d_elements)[i].Reg = -1;
}
return element_count;
}
/* IDirect3DDevice9 IDirect3DVertexDeclaration9 Methods follow: */
HRESULT WINAPI IDirect3DDevice9Impl_CreateVertexDeclaration(LPDIRECT3DDEVICE9 iface, CONST D3DVERTEXELEMENT9* pVertexElements, IDirect3DVertexDeclaration9** ppDecl) {
IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
IDirect3DVertexDeclaration9Impl *object = NULL;
WINED3DVERTEXELEMENT* wined3d_elements;
size_t element_count;
HRESULT hr = D3D_OK;
TRACE("(%p) : Relay\n", iface);
if (NULL == ppDecl) {
WARN("(%p) : Caller passed NULL As ppDecl, returning D3DERR_INVALIDCALL\n",This);
return D3DERR_INVALIDCALL;
}
element_count = convert_to_wined3d_declaration(pVertexElements, &wined3d_elements);
if (!element_count) {
FIXME("(%p) : Error parsing vertex declaration\n", This);
return D3DERR_INVALIDCALL;
}
/* Allocate the storage for the device */
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3DVertexDeclaration9Impl));
if (NULL == object) {
HeapFree(GetProcessHeap(), 0, wined3d_elements);
FIXME("Allocation of memory failed, returning D3DERR_OUTOFVIDEOMEMORY\n");
return D3DERR_OUTOFVIDEOMEMORY;
}
object->lpVtbl = &Direct3DVertexDeclaration9_Vtbl;
object->ref = 0;
object->elements = HeapAlloc(GetProcessHeap(), 0, element_count * sizeof(D3DVERTEXELEMENT9));
if (!object->elements) {
HeapFree(GetProcessHeap(), 0, wined3d_elements);
HeapFree(GetProcessHeap(), 0, object);
ERR("Memory allocation failed\n");
return D3DERR_OUTOFVIDEOMEMORY;
}
CopyMemory(object->elements, pVertexElements, element_count * sizeof(D3DVERTEXELEMENT9));
object->element_count = element_count;
hr = IWineD3DDevice_CreateVertexDeclaration(This->WineD3DDevice, &object->wineD3DVertexDeclaration, (IUnknown *)object, wined3d_elements, element_count);
HeapFree(GetProcessHeap(), 0, wined3d_elements);
if (FAILED(hr)) {
/* free up object */
FIXME("(%p) call to IWineD3DDevice_CreateVertexDeclaration failed\n", This);
HeapFree(GetProcessHeap(), 0, object->elements);
HeapFree(GetProcessHeap(), 0, object);
} else {
object->parentDevice = iface;
*ppDecl = (LPDIRECT3DVERTEXDECLARATION9) object;
IUnknown_AddRef(*ppDecl);
TRACE("(%p) : Created vertex declaration %p\n", This, object);
}
return hr;
}
HRESULT WINAPI IDirect3DDevice9Impl_SetVertexDeclaration(LPDIRECT3DDEVICE9 iface, IDirect3DVertexDeclaration9* pDecl) {
IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
IDirect3DVertexDeclaration9Impl *pDeclImpl = (IDirect3DVertexDeclaration9Impl *)pDecl;
HRESULT hr = D3D_OK;
TRACE("(%p) : Relay\n", iface);
hr = IWineD3DDevice_SetVertexDeclaration(This->WineD3DDevice, pDeclImpl == NULL ? NULL : pDeclImpl->wineD3DVertexDeclaration);
return hr;
}
HRESULT WINAPI IDirect3DDevice9Impl_GetVertexDeclaration(LPDIRECT3DDEVICE9 iface, IDirect3DVertexDeclaration9** ppDecl) {
IDirect3DDevice9Impl* This = (IDirect3DDevice9Impl*) iface;
IWineD3DVertexDeclaration* pTest = NULL;
HRESULT hr = D3D_OK;
TRACE("(%p) : Relay+\n", iface);
if (NULL == ppDecl) {
return D3DERR_INVALIDCALL;
}
*ppDecl = NULL;
hr = IWineD3DDevice_GetVertexDeclaration(This->WineD3DDevice, &pTest);
if (hr == D3D_OK && NULL != pTest) {
IWineD3DVertexDeclaration_GetParent(pTest, (IUnknown **)ppDecl);
IWineD3DVertexDeclaration_Release(pTest);
} else {
*ppDecl = NULL;
}
TRACE("(%p) : returning %p\n", This, *ppDecl);
return hr;
}

View File

@@ -0,0 +1,199 @@
/*
* IDirect3DVertexShader9 implementation
*
* Copyright 2002-2003 Jason Edmeades
* Raphael Junqueira
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "config.h"
#include "d3d9_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(d3d9);
/* IDirect3DVertexShader9 IUnknown parts follow: */
static HRESULT WINAPI IDirect3DVertexShader9Impl_QueryInterface(LPDIRECT3DVERTEXSHADER9 iface, REFIID riid, LPVOID* ppobj) {
IDirect3DVertexShader9Impl *This = (IDirect3DVertexShader9Impl *)iface;
if (IsEqualGUID(riid, &IID_IUnknown)
|| IsEqualGUID(riid, &IID_IDirect3DVertexShader9)) {
IUnknown_AddRef(iface);
*ppobj = This;
return S_OK;
}
WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);
*ppobj = NULL;
return E_NOINTERFACE;
}
static ULONG WINAPI IDirect3DVertexShader9Impl_AddRef(LPDIRECT3DVERTEXSHADER9 iface) {
IDirect3DVertexShader9Impl *This = (IDirect3DVertexShader9Impl *)iface;
ULONG ref = InterlockedIncrement(&This->ref);
TRACE("(%p) : AddRef from %d\n", This, ref - 1);
return ref;
}
static ULONG WINAPI IDirect3DVertexShader9Impl_Release(LPDIRECT3DVERTEXSHADER9 iface) {
IDirect3DVertexShader9Impl *This = (IDirect3DVertexShader9Impl *)iface;
ULONG ref = InterlockedDecrement(&This->ref);
TRACE("(%p) : ReleaseRef to %d\n", This, ref);
if (ref == 0) {
IWineD3DVertexShader_Release(This->wineD3DVertexShader);
IUnknown_Release(This->parentDevice);
HeapFree(GetProcessHeap(), 0, This);
}
return ref;
}
/* IDirect3DVertexShader9 Interface follow: */
static HRESULT WINAPI IDirect3DVertexShader9Impl_GetDevice(LPDIRECT3DVERTEXSHADER9 iface, IDirect3DDevice9** ppDevice) {
IDirect3DVertexShader9Impl *This = (IDirect3DVertexShader9Impl *)iface;
IWineD3DDevice *myDevice = NULL;
HRESULT hr = D3D_OK;
TRACE("(%p) : Relay\n", This);
if (D3D_OK == (hr = IWineD3DVertexShader_GetDevice(This->wineD3DVertexShader, &myDevice) && myDevice != NULL)) {
hr = IWineD3DDevice_GetParent(myDevice, (IUnknown **)ppDevice);
IWineD3DDevice_Release(myDevice);
} else {
*ppDevice = NULL;
}
TRACE("(%p) returning (%p)\n", This, *ppDevice);
return hr;
}
static HRESULT WINAPI IDirect3DVertexShader9Impl_GetFunction(LPDIRECT3DVERTEXSHADER9 iface, VOID* pData, UINT* pSizeOfData) {
IDirect3DVertexShader9Impl *This = (IDirect3DVertexShader9Impl *)iface;
TRACE("(%p) : Relay\n", This);
return IWineD3DVertexShader_GetFunction(This->wineD3DVertexShader, pData, pSizeOfData);
}
static const IDirect3DVertexShader9Vtbl Direct3DVertexShader9_Vtbl =
{
/* IUnknown */
IDirect3DVertexShader9Impl_QueryInterface,
IDirect3DVertexShader9Impl_AddRef,
IDirect3DVertexShader9Impl_Release,
/* IDirect3DVertexShader9 */
IDirect3DVertexShader9Impl_GetDevice,
IDirect3DVertexShader9Impl_GetFunction
};
/* IDirect3DDevice9 IDirect3DVertexShader9 Methods follow: */
HRESULT WINAPI IDirect3DDevice9Impl_CreateVertexShader(LPDIRECT3DDEVICE9 iface, CONST DWORD* pFunction, IDirect3DVertexShader9** ppShader) {
IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
HRESULT hrc = D3D_OK;
IDirect3DVertexShader9Impl *object;
/* Setup a stub object for now */
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
TRACE("(%p) : pFunction(%p), ppShader(%p)\n", This, pFunction, ppShader);
if (NULL == object) {
FIXME("Allocation of memory failed, returning D3DERR_OUTOFVIDEOMEMORY\n");
return D3DERR_OUTOFVIDEOMEMORY;
}
object->ref = 1;
object->lpVtbl = &Direct3DVertexShader9_Vtbl;
hrc= IWineD3DDevice_CreateVertexShader(This->WineD3DDevice, NULL /* declaration */, pFunction, &object->wineD3DVertexShader, (IUnknown *)object);
if (FAILED(hrc)) {
/* free up object */
FIXME("Call to IWineD3DDevice_CreateVertexShader failed\n");
HeapFree(GetProcessHeap(), 0, object);
}else{
IUnknown_AddRef(iface);
object->parentDevice = iface;
*ppShader = (IDirect3DVertexShader9 *)object;
TRACE("(%p) : Created vertex shader %p\n", This, object);
}
TRACE("(%p) : returning %p\n", This, *ppShader);
return hrc;
}
HRESULT WINAPI IDirect3DDevice9Impl_SetVertexShader(LPDIRECT3DDEVICE9 iface, IDirect3DVertexShader9* pShader) {
IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
HRESULT hrc = D3D_OK;
TRACE("(%p) : Relay\n", This);
hrc = IWineD3DDevice_SetVertexShader(This->WineD3DDevice, pShader==NULL?NULL:((IDirect3DVertexShader9Impl *)pShader)->wineD3DVertexShader);
TRACE("(%p) : returning hr(%u)\n", This, hrc);
return hrc;
}
HRESULT WINAPI IDirect3DDevice9Impl_GetVertexShader(LPDIRECT3DDEVICE9 iface, IDirect3DVertexShader9** ppShader) {
IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
IWineD3DVertexShader *pShader;
HRESULT hrc = D3D_OK;
TRACE("(%p) : Relay device@%p\n", This, This->WineD3DDevice);
hrc = IWineD3DDevice_GetVertexShader(This->WineD3DDevice, &pShader);
if(hrc == D3D_OK && pShader != NULL){
hrc = IWineD3DVertexShader_GetParent(pShader, (IUnknown **)ppShader);
IWineD3DVertexShader_Release(pShader);
} else {
WARN("(%p) : Call to IWineD3DDevice_GetVertexShader failed %u (device %p)\n", This, hrc, This->WineD3DDevice);
}
TRACE("(%p) : returning %p\n", This, *ppShader);
return hrc;
}
HRESULT WINAPI IDirect3DDevice9Impl_SetVertexShaderConstantF(LPDIRECT3DDEVICE9 iface, UINT Register, CONST float* pConstantData, UINT Vector4fCount) {
IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
TRACE("(%p) : Relay\n", This);
return IWineD3DDevice_SetVertexShaderConstantF(This->WineD3DDevice, Register, pConstantData, Vector4fCount);
}
HRESULT WINAPI IDirect3DDevice9Impl_GetVertexShaderConstantF(LPDIRECT3DDEVICE9 iface, UINT Register, float* pConstantData, UINT Vector4fCount) {
IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
TRACE("(%p) : Relay\n", This);
return IWineD3DDevice_GetVertexShaderConstantF(This->WineD3DDevice, Register, pConstantData, Vector4fCount);
}
HRESULT WINAPI IDirect3DDevice9Impl_SetVertexShaderConstantI(LPDIRECT3DDEVICE9 iface, UINT Register, CONST int* pConstantData, UINT Vector4iCount) {
IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
TRACE("(%p) : Relay\n", This);
return IWineD3DDevice_SetVertexShaderConstantI(This->WineD3DDevice, Register, pConstantData, Vector4iCount);
}
HRESULT WINAPI IDirect3DDevice9Impl_GetVertexShaderConstantI(LPDIRECT3DDEVICE9 iface, UINT Register, int* pConstantData, UINT Vector4iCount) {
IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
TRACE("(%p) : Relay\n", This);
return IWineD3DDevice_GetVertexShaderConstantI(This->WineD3DDevice, Register, pConstantData, Vector4iCount);
}
HRESULT WINAPI IDirect3DDevice9Impl_SetVertexShaderConstantB(LPDIRECT3DDEVICE9 iface, UINT Register, CONST BOOL* pConstantData, UINT BoolCount) {
IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
TRACE("(%p) : Relay\n", This);
return IWineD3DDevice_SetVertexShaderConstantB(This->WineD3DDevice, Register, pConstantData, BoolCount);
}
HRESULT WINAPI IDirect3DDevice9Impl_GetVertexShaderConstantB(LPDIRECT3DDEVICE9 iface, UINT Register, BOOL* pConstantData, UINT BoolCount) {
IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
TRACE("(%p) : Relay\n", This);
return IWineD3DDevice_GetVertexShaderConstantB(This->WineD3DDevice, Register, pConstantData, BoolCount);
}

View File

@@ -0,0 +1,224 @@
/*
* IDirect3DVolume9 implementation
*
* Copyright 2002-2005 Jason Edmeades
* Raphael Junqueira
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "config.h"
#include "d3d9_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(d3d9);
/* IDirect3DVolume9 IUnknown parts follow: */
static HRESULT WINAPI IDirect3DVolume9Impl_QueryInterface(LPDIRECT3DVOLUME9 iface, REFIID riid, LPVOID* ppobj) {
IDirect3DVolume9Impl *This = (IDirect3DVolume9Impl *)iface;
if (IsEqualGUID(riid, &IID_IUnknown)
|| IsEqualGUID(riid, &IID_IDirect3DVolume9)) {
IUnknown_AddRef(iface);
*ppobj = This;
return S_OK;
}
WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);
*ppobj = NULL;
return E_NOINTERFACE;
}
static ULONG WINAPI IDirect3DVolume9Impl_AddRef(LPDIRECT3DVOLUME9 iface) {
IDirect3DVolume9Impl *This = (IDirect3DVolume9Impl *)iface;
TRACE("(%p)\n", This);
if (This->forwardReference) {
/* Forward refcounting */
TRACE("(%p) : Forwarding to %p\n", This, This->forwardReference);
return IUnknown_AddRef(This->forwardReference);
} else {
/* No container, handle our own refcounting */
ULONG ref = InterlockedIncrement(&This->ref);
TRACE("(%p) : AddRef from %d\n", This, ref - 1);
return ref;
}
}
static ULONG WINAPI IDirect3DVolume9Impl_Release(LPDIRECT3DVOLUME9 iface) {
IDirect3DVolume9Impl *This = (IDirect3DVolume9Impl *)iface;
TRACE("(%p)\n", This);
if (This->forwardReference) {
/* Forward refcounting */
TRACE("(%p) : Forwarding to %p\n", This, This->forwardReference);
return IUnknown_Release(This->forwardReference);
} else {
/* No container, handle our own refcounting */
ULONG ref = InterlockedDecrement(&This->ref);
TRACE("(%p) : ReleaseRef to %d\n", This, ref);
if (ref == 0) {
IWineD3DVolume_Release(This->wineD3DVolume);
HeapFree(GetProcessHeap(), 0, This);
}
return ref;
}
}
/* IDirect3DVolume9 Interface follow: */
static HRESULT WINAPI IDirect3DVolume9Impl_GetDevice(LPDIRECT3DVOLUME9 iface, IDirect3DDevice9** ppDevice) {
IDirect3DVolume9Impl *This = (IDirect3DVolume9Impl *)iface;
IWineD3DDevice *myDevice = NULL;
IWineD3DVolume_GetDevice(This->wineD3DVolume, &myDevice);
IWineD3DDevice_GetParent(myDevice, (IUnknown **)ppDevice);
IWineD3DDevice_Release(myDevice);
return D3D_OK;
}
static HRESULT WINAPI IDirect3DVolume9Impl_SetPrivateData(LPDIRECT3DVOLUME9 iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) {
IDirect3DVolume9Impl *This = (IDirect3DVolume9Impl *)iface;
TRACE("(%p) Relay\n", This);
return IWineD3DVolume_SetPrivateData(This->wineD3DVolume, refguid, pData, SizeOfData, Flags);
}
static HRESULT WINAPI IDirect3DVolume9Impl_GetPrivateData(LPDIRECT3DVOLUME9 iface, REFGUID refguid, void* pData, DWORD* pSizeOfData) {
IDirect3DVolume9Impl *This = (IDirect3DVolume9Impl *)iface;
TRACE("(%p) Relay\n", This);
return IWineD3DVolume_GetPrivateData(This->wineD3DVolume, refguid, pData, pSizeOfData);
}
static HRESULT WINAPI IDirect3DVolume9Impl_FreePrivateData(LPDIRECT3DVOLUME9 iface, REFGUID refguid) {
IDirect3DVolume9Impl *This = (IDirect3DVolume9Impl *)iface;
TRACE("(%p) Relay\n", This);
return IWineD3DVolume_FreePrivateData(This->wineD3DVolume, refguid);
}
static HRESULT WINAPI IDirect3DVolume9Impl_GetContainer(LPDIRECT3DVOLUME9 iface, REFIID riid, void** ppContainer) {
IDirect3DVolume9Impl *This = (IDirect3DVolume9Impl *)iface;
HRESULT res;
TRACE("(This %p, riid %s, ppContainer %p)\n", This, debugstr_guid(riid), ppContainer);
if (!This->container) return E_NOINTERFACE;
if (!ppContainer) {
ERR("Called without a valid ppContainer.\n");
}
res = IUnknown_QueryInterface(This->container, riid, ppContainer);
TRACE("Returning ppContainer %p, *ppContainer %p\n", ppContainer, *ppContainer);
return res;
}
static HRESULT WINAPI IDirect3DVolume9Impl_GetDesc(LPDIRECT3DVOLUME9 iface, D3DVOLUME_DESC* pDesc) {
IDirect3DVolume9Impl *This = (IDirect3DVolume9Impl *)iface;
WINED3DVOLUME_DESC wined3ddesc;
UINT tmpInt = -1;
TRACE("(%p) Relay\n", This);
/* As d3d8 and d3d9 structures differ, pass in ptrs to where data needs to go */
wined3ddesc.Format = (WINED3DFORMAT *)&pDesc->Format;
wined3ddesc.Type = (WINED3DRESOURCETYPE *)&pDesc->Type;
wined3ddesc.Usage = &pDesc->Usage;
wined3ddesc.Pool = (WINED3DPOOL *) &pDesc->Pool;
wined3ddesc.Size = &tmpInt;
wined3ddesc.Width = &pDesc->Width;
wined3ddesc.Height = &pDesc->Height;
wined3ddesc.Depth = &pDesc->Depth;
return IWineD3DVolume_GetDesc(This->wineD3DVolume, &wined3ddesc);
}
static HRESULT WINAPI IDirect3DVolume9Impl_LockBox(LPDIRECT3DVOLUME9 iface, D3DLOCKED_BOX* pLockedVolume, CONST D3DBOX* pBox, DWORD Flags) {
IDirect3DVolume9Impl *This = (IDirect3DVolume9Impl *)iface;
TRACE("(%p) relay %p %p %p %d\n", This, This->wineD3DVolume, pLockedVolume, pBox, Flags);
return IWineD3DVolume_LockBox(This->wineD3DVolume, (WINED3DLOCKED_BOX *)pLockedVolume, (CONST WINED3DBOX *)pBox, Flags);
}
static HRESULT WINAPI IDirect3DVolume9Impl_UnlockBox(LPDIRECT3DVOLUME9 iface) {
IDirect3DVolume9Impl *This = (IDirect3DVolume9Impl *)iface;
TRACE("(%p) relay %p\n", This, This->wineD3DVolume);
return IWineD3DVolume_UnlockBox(This->wineD3DVolume);
}
static const IDirect3DVolume9Vtbl Direct3DVolume9_Vtbl =
{
/* IUnknown */
IDirect3DVolume9Impl_QueryInterface,
IDirect3DVolume9Impl_AddRef,
IDirect3DVolume9Impl_Release,
/* IDirect3DVolume9 */
IDirect3DVolume9Impl_GetDevice,
IDirect3DVolume9Impl_SetPrivateData,
IDirect3DVolume9Impl_GetPrivateData,
IDirect3DVolume9Impl_FreePrivateData,
IDirect3DVolume9Impl_GetContainer,
IDirect3DVolume9Impl_GetDesc,
IDirect3DVolume9Impl_LockBox,
IDirect3DVolume9Impl_UnlockBox
};
/* Internal function called back during the CreateVolumeTexture */
HRESULT WINAPI D3D9CB_CreateVolume(IUnknown *pDevice, IUnknown *pSuperior, UINT Width, UINT Height, UINT Depth,
WINED3DFORMAT Format, WINED3DPOOL Pool, DWORD Usage,
IWineD3DVolume **ppVolume,
HANDLE * pSharedHandle) {
IDirect3DVolume9Impl *object;
IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)pDevice;
HRESULT hrc = D3D_OK;
/* Allocate the storage for the device */
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3DVolume9Impl));
if (NULL == object) {
FIXME("Allocation of memory failed\n");
*ppVolume = NULL;
return D3DERR_OUTOFVIDEOMEMORY;
}
object->lpVtbl = &Direct3DVolume9_Vtbl;
object->ref = 1;
hrc = IWineD3DDevice_CreateVolume(This->WineD3DDevice, Width, Height, Depth, Usage & WINED3DUSAGE_MASK, Format,
Pool, &object->wineD3DVolume, pSharedHandle, (IUnknown *)object);
if (hrc != D3D_OK) {
/* free up object */
FIXME("(%p) call to IWineD3DDevice_CreateVolume failed\n", This);
HeapFree(GetProcessHeap(), 0, object);
*ppVolume = NULL;
} else {
*ppVolume = (IWineD3DVolume *)object->wineD3DVolume;
object->container = pSuperior;
object->forwardReference = pSuperior;
}
TRACE("(%p) Created volume %p\n", This, *ppVolume);
return hrc;
}
ULONG WINAPI D3D9CB_DestroyVolume(IWineD3DVolume *pVolume) {
IDirect3DVolume9Impl* volumeParent;
IWineD3DVolume_GetParent(pVolume, (IUnknown **) &volumeParent);
/* GetParent's AddRef was forwarded to an object in destruction.
* Releasing it here again would cause an endless recursion. */
volumeParent->forwardReference = NULL;
return IDirect3DVolume9_Release((IDirect3DVolume9*) volumeParent);
}

View File

@@ -0,0 +1,279 @@
/*
* IDirect3DVolumeTexture9 implementation
*
* Copyright 2002-2005 Jason Edmeades
* Raphael Junqueira
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "config.h"
#include "d3d9_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(d3d9);
/* IDirect3DVolumeTexture9 IUnknown parts follow: */
static HRESULT WINAPI IDirect3DVolumeTexture9Impl_QueryInterface(LPDIRECT3DVOLUMETEXTURE9 iface, REFIID riid, LPVOID* ppobj) {
IDirect3DVolumeTexture9Impl *This = (IDirect3DVolumeTexture9Impl *)iface;
if (IsEqualGUID(riid, &IID_IUnknown)
|| IsEqualGUID(riid, &IID_IDirect3DResource9)
|| IsEqualGUID(riid, &IID_IDirect3DBaseTexture9)
|| IsEqualGUID(riid, &IID_IDirect3DVolumeTexture9)) {
IUnknown_AddRef(iface);
*ppobj = This;
return S_OK;
}
WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);
*ppobj = NULL;
return E_NOINTERFACE;
}
static ULONG WINAPI IDirect3DVolumeTexture9Impl_AddRef(LPDIRECT3DVOLUMETEXTURE9 iface) {
IDirect3DVolumeTexture9Impl *This = (IDirect3DVolumeTexture9Impl *)iface;
ULONG ref = InterlockedIncrement(&This->ref);
TRACE("(%p) : AddRef from %d\n", This, ref - 1);
return ref;
}
static ULONG WINAPI IDirect3DVolumeTexture9Impl_Release(LPDIRECT3DVOLUMETEXTURE9 iface) {
IDirect3DVolumeTexture9Impl *This = (IDirect3DVolumeTexture9Impl *)iface;
ULONG ref = InterlockedDecrement(&This->ref);
TRACE("(%p) : ReleaseRef to %d\n", This, ref);
if (ref == 0) {
IWineD3DVolumeTexture_Destroy(This->wineD3DVolumeTexture, D3D9CB_DestroyVolume);
IUnknown_Release(This->parentDevice);
HeapFree(GetProcessHeap(), 0, This);
}
return ref;
}
/* IDirect3DVolumeTexture9 IDirect3DResource9 Interface follow: */
static HRESULT WINAPI IDirect3DVolumeTexture9Impl_GetDevice(LPDIRECT3DVOLUMETEXTURE9 iface, IDirect3DDevice9** ppDevice) {
IDirect3DVolumeTexture9Impl *This = (IDirect3DVolumeTexture9Impl *)iface;
TRACE("(%p) Relay\n", This);
return IDirect3DResource9Impl_GetDevice((LPDIRECT3DRESOURCE9) This, ppDevice);
}
static HRESULT WINAPI IDirect3DVolumeTexture9Impl_SetPrivateData(LPDIRECT3DVOLUMETEXTURE9 iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) {
IDirect3DVolumeTexture9Impl *This = (IDirect3DVolumeTexture9Impl *)iface;
TRACE("(%p) Relay\n", This);
return IWineD3DVolumeTexture_SetPrivateData(This->wineD3DVolumeTexture, refguid, pData, SizeOfData, Flags);
}
static HRESULT WINAPI IDirect3DVolumeTexture9Impl_GetPrivateData(LPDIRECT3DVOLUMETEXTURE9 iface, REFGUID refguid, void* pData, DWORD* pSizeOfData) {
IDirect3DVolumeTexture9Impl *This = (IDirect3DVolumeTexture9Impl *)iface;
TRACE("(%p) Relay\n", This);
return IWineD3DVolumeTexture_GetPrivateData(This->wineD3DVolumeTexture, refguid, pData, pSizeOfData);
}
static HRESULT WINAPI IDirect3DVolumeTexture9Impl_FreePrivateData(LPDIRECT3DVOLUMETEXTURE9 iface, REFGUID refguid) {
IDirect3DVolumeTexture9Impl *This = (IDirect3DVolumeTexture9Impl *)iface;
TRACE("(%p) Relay\n", This);
return IWineD3DVolumeTexture_FreePrivateData(This->wineD3DVolumeTexture, refguid);
}
static DWORD WINAPI IDirect3DVolumeTexture9Impl_SetPriority(LPDIRECT3DVOLUMETEXTURE9 iface, DWORD PriorityNew) {
IDirect3DVolumeTexture9Impl *This = (IDirect3DVolumeTexture9Impl *)iface;
TRACE("(%p) Relay\n", This);
return IWineD3DVolumeTexture_SetPriority(This->wineD3DVolumeTexture, PriorityNew);
}
static DWORD WINAPI IDirect3DVolumeTexture9Impl_GetPriority(LPDIRECT3DVOLUMETEXTURE9 iface) {
IDirect3DVolumeTexture9Impl *This = (IDirect3DVolumeTexture9Impl *)iface;
TRACE("(%p) Relay\n", This);
return IWineD3DVolumeTexture_GetPriority(This->wineD3DVolumeTexture);
}
static void WINAPI IDirect3DVolumeTexture9Impl_PreLoad(LPDIRECT3DVOLUMETEXTURE9 iface) {
IDirect3DVolumeTexture9Impl *This = (IDirect3DVolumeTexture9Impl *)iface;
TRACE("(%p) Relay\n", This);
IWineD3DVolumeTexture_PreLoad(This->wineD3DVolumeTexture);
}
static D3DRESOURCETYPE WINAPI IDirect3DVolumeTexture9Impl_GetType(LPDIRECT3DVOLUMETEXTURE9 iface) {
IDirect3DVolumeTexture9Impl *This = (IDirect3DVolumeTexture9Impl *)iface;
TRACE("(%p) Relay\n", This);
return IWineD3DVolumeTexture_GetType(This->wineD3DVolumeTexture);
}
/* IDirect3DVolumeTexture9 IDirect3DBaseTexture9 Interface follow: */
static DWORD WINAPI IDirect3DVolumeTexture9Impl_SetLOD(LPDIRECT3DVOLUMETEXTURE9 iface, DWORD LODNew) {
IDirect3DVolumeTexture9Impl *This = (IDirect3DVolumeTexture9Impl *)iface;
TRACE("(%p) Relay\n", This);
return IWineD3DVolumeTexture_SetLOD(This->wineD3DVolumeTexture, LODNew);
}
static DWORD WINAPI IDirect3DVolumeTexture9Impl_GetLOD(LPDIRECT3DVOLUMETEXTURE9 iface) {
IDirect3DVolumeTexture9Impl *This = (IDirect3DVolumeTexture9Impl *)iface;
TRACE("(%p) Relay\n", This);
return IWineD3DVolumeTexture_GetLOD(This->wineD3DVolumeTexture);
}
static DWORD WINAPI IDirect3DVolumeTexture9Impl_GetLevelCount(LPDIRECT3DVOLUMETEXTURE9 iface) {
IDirect3DVolumeTexture9Impl *This = (IDirect3DVolumeTexture9Impl *)iface;
TRACE("(%p) Relay\n", This);
return IWineD3DVolumeTexture_GetLevelCount(This->wineD3DVolumeTexture);
}
static HRESULT WINAPI IDirect3DVolumeTexture9Impl_SetAutoGenFilterType(LPDIRECT3DVOLUMETEXTURE9 iface, D3DTEXTUREFILTERTYPE FilterType) {
IDirect3DVolumeTexture9Impl *This = (IDirect3DVolumeTexture9Impl *)iface;
TRACE("(%p) Relay\n", This);
return IWineD3DVolumeTexture_SetAutoGenFilterType(This->wineD3DVolumeTexture, (WINED3DTEXTUREFILTERTYPE) FilterType);
}
static D3DTEXTUREFILTERTYPE WINAPI IDirect3DVolumeTexture9Impl_GetAutoGenFilterType(LPDIRECT3DVOLUMETEXTURE9 iface) {
IDirect3DVolumeTexture9Impl *This = (IDirect3DVolumeTexture9Impl *)iface;
TRACE("(%p) Relay\n", This);
return (D3DTEXTUREFILTERTYPE) IWineD3DVolumeTexture_GetAutoGenFilterType(This->wineD3DVolumeTexture);
}
static void WINAPI IDirect3DVolumeTexture9Impl_GenerateMipSubLevels(LPDIRECT3DVOLUMETEXTURE9 iface) {
IDirect3DVolumeTexture9Impl *This = (IDirect3DVolumeTexture9Impl *)iface;
TRACE("(%p) Relay\n", This);
IWineD3DVolumeTexture_GenerateMipSubLevels(This->wineD3DVolumeTexture);
}
/* IDirect3DVolumeTexture9 Interface follow: */
static HRESULT WINAPI IDirect3DVolumeTexture9Impl_GetLevelDesc(LPDIRECT3DVOLUMETEXTURE9 iface, UINT Level, D3DVOLUME_DESC* pDesc) {
IDirect3DVolumeTexture9Impl *This = (IDirect3DVolumeTexture9Impl *)iface;
WINED3DVOLUME_DESC wined3ddesc;
UINT tmpInt = -1;
TRACE("(%p) Relay\n", This);
/* As d3d8 and d3d9 structures differ, pass in ptrs to where data needs to go */
wined3ddesc.Format = (WINED3DFORMAT *)&pDesc->Format;
wined3ddesc.Type = (WINED3DRESOURCETYPE *)&pDesc->Type;
wined3ddesc.Usage = &pDesc->Usage;
wined3ddesc.Pool = (WINED3DPOOL *) &pDesc->Pool;
wined3ddesc.Size = &tmpInt;
wined3ddesc.Width = &pDesc->Width;
wined3ddesc.Height = &pDesc->Height;
wined3ddesc.Depth = &pDesc->Depth;
return IWineD3DVolumeTexture_GetLevelDesc(This->wineD3DVolumeTexture, Level, &wined3ddesc);
}
static HRESULT WINAPI IDirect3DVolumeTexture9Impl_GetVolumeLevel(LPDIRECT3DVOLUMETEXTURE9 iface, UINT Level, IDirect3DVolume9** ppVolumeLevel) {
IDirect3DVolumeTexture9Impl *This = (IDirect3DVolumeTexture9Impl *)iface;
HRESULT hrc = D3D_OK;
IWineD3DVolume *myVolume = NULL;
TRACE("(%p) Relay\n", This);
hrc = IWineD3DVolumeTexture_GetVolumeLevel(This->wineD3DVolumeTexture, Level, &myVolume);
if (hrc == D3D_OK && NULL != ppVolumeLevel) {
IWineD3DVolumeTexture_GetParent(myVolume, (IUnknown **)ppVolumeLevel);
IWineD3DVolumeTexture_Release(myVolume);
}
return hrc;
}
static HRESULT WINAPI IDirect3DVolumeTexture9Impl_LockBox(LPDIRECT3DVOLUMETEXTURE9 iface, UINT Level, D3DLOCKED_BOX* pLockedVolume, CONST D3DBOX* pBox, DWORD Flags) {
IDirect3DVolumeTexture9Impl *This = (IDirect3DVolumeTexture9Impl *)iface;
TRACE("(%p) Relay %p %p %p %d\n", This, This->wineD3DVolumeTexture, pLockedVolume, pBox,Flags);
return IWineD3DVolumeTexture_LockBox(This->wineD3DVolumeTexture, Level, (WINED3DLOCKED_BOX *)pLockedVolume, (CONST WINED3DBOX *)pBox, Flags);
}
static HRESULT WINAPI IDirect3DVolumeTexture9Impl_UnlockBox(LPDIRECT3DVOLUMETEXTURE9 iface, UINT Level) {
IDirect3DVolumeTexture9Impl *This = (IDirect3DVolumeTexture9Impl *)iface;
TRACE("(%p) Relay %p %d\n", This, This->wineD3DVolumeTexture, Level);
return IWineD3DVolumeTexture_UnlockBox(This->wineD3DVolumeTexture, Level);
}
static HRESULT WINAPI IDirect3DVolumeTexture9Impl_AddDirtyBox(LPDIRECT3DVOLUMETEXTURE9 iface, CONST D3DBOX* pDirtyBox) {
IDirect3DVolumeTexture9Impl *This = (IDirect3DVolumeTexture9Impl *)iface;
TRACE("(%p) Relay\n", This);
return IWineD3DVolumeTexture_AddDirtyBox(This->wineD3DVolumeTexture, (CONST WINED3DBOX *)pDirtyBox);
}
static const IDirect3DVolumeTexture9Vtbl Direct3DVolumeTexture9_Vtbl =
{
/* IUnknown */
IDirect3DVolumeTexture9Impl_QueryInterface,
IDirect3DVolumeTexture9Impl_AddRef,
IDirect3DVolumeTexture9Impl_Release,
/* IDirect3DResource9 */
IDirect3DVolumeTexture9Impl_GetDevice,
IDirect3DVolumeTexture9Impl_SetPrivateData,
IDirect3DVolumeTexture9Impl_GetPrivateData,
IDirect3DVolumeTexture9Impl_FreePrivateData,
IDirect3DVolumeTexture9Impl_SetPriority,
IDirect3DVolumeTexture9Impl_GetPriority,
IDirect3DVolumeTexture9Impl_PreLoad,
IDirect3DVolumeTexture9Impl_GetType,
/* IDirect3DBaseTexture9 */
IDirect3DVolumeTexture9Impl_SetLOD,
IDirect3DVolumeTexture9Impl_GetLOD,
IDirect3DVolumeTexture9Impl_GetLevelCount,
IDirect3DVolumeTexture9Impl_SetAutoGenFilterType,
IDirect3DVolumeTexture9Impl_GetAutoGenFilterType,
IDirect3DVolumeTexture9Impl_GenerateMipSubLevels,
/* IDirect3DVolumeTexture9 */
IDirect3DVolumeTexture9Impl_GetLevelDesc,
IDirect3DVolumeTexture9Impl_GetVolumeLevel,
IDirect3DVolumeTexture9Impl_LockBox,
IDirect3DVolumeTexture9Impl_UnlockBox,
IDirect3DVolumeTexture9Impl_AddDirtyBox
};
/* IDirect3DDevice9 IDirect3DVolumeTexture9 Methods follow: */
HRESULT WINAPI IDirect3DDevice9Impl_CreateVolumeTexture(LPDIRECT3DDEVICE9 iface,
UINT Width, UINT Height, UINT Depth, UINT Levels, DWORD Usage,
D3DFORMAT Format, D3DPOOL Pool,
IDirect3DVolumeTexture9** ppVolumeTexture, HANDLE* pSharedHandle) {
IDirect3DVolumeTexture9Impl *object;
IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
HRESULT hrc = D3D_OK;
TRACE("(%p) Relay\n", This);
/* Allocate the storage for the device */
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3DVolumeTexture9Impl));
if (NULL == object) {
FIXME("(%p) allocation of memory failed, returning D3DERR_OUTOFVIDEOMEMORY\n", This);
return D3DERR_OUTOFVIDEOMEMORY;
}
object->lpVtbl = &Direct3DVolumeTexture9_Vtbl;
object->ref = 1;
hrc = IWineD3DDevice_CreateVolumeTexture(This->WineD3DDevice, Width, Height, Depth, Levels, Usage & WINED3DUSAGE_MASK,
(WINED3DFORMAT)Format, (WINED3DPOOL) Pool, &object->wineD3DVolumeTexture, pSharedHandle,
(IUnknown *)object, D3D9CB_CreateVolume);
if (hrc != D3D_OK) {
/* free up object */
FIXME("(%p) call to IWineD3DDevice_CreateVolumeTexture failed\n", This);
HeapFree(GetProcessHeap(), 0, object);
} else {
IUnknown_AddRef(iface);
object->parentDevice = iface;
*ppVolumeTexture = (LPDIRECT3DVOLUMETEXTURE9) object;
TRACE("(%p) : Created volume texture %p\n", This, object);
}
TRACE("(%p) returning %p\n", This , *ppVolumeTexture);
return hrc;
}

View File

@@ -0,0 +1,324 @@
/* DirectDrawClipper implementation
*
* Copyright 2000 (c) Marcus Meissner
* Copyright 2000 (c) TransGaming Technologies Inc.
* Copyright 2006 (c) Stefan D<>singer
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "config.h"
#include <stdarg.h>
#include <stdlib.h>
#include <string.h>
#ifndef WINE_NATIVEWIN32
# include "windef.h"
# include "winbase.h"
# include "wingdi.h"
# include "ddraw.h"
# include "winerror.h"
#endif
#include "ddraw_private.h"
#include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(ddraw);
/*****************************************************************************
* IUnknown methods
*****************************************************************************/
/*****************************************************************************
* IDirectDrawClipper::QueryInterface
*
* Can query the IUnknown and IDirectDrawClipper interface from a
* Clipper object. The IUnknown Interface is equal to the IDirectDrawClipper
* interface. Can't create other interfaces.
*
* Arguments:
* riid: Interface id asked for
* ppvObj: Returns the pointer to the interface
*
* Return values:
* DD_OK on success
* E_NOINTERFACE if the requested interface wasn't found.
*
*****************************************************************************/
static HRESULT WINAPI IDirectDrawClipperImpl_QueryInterface(
LPDIRECTDRAWCLIPPER iface, REFIID riid, LPVOID* ppvObj
) {
IDirectDrawClipperImpl *This = (IDirectDrawClipperImpl *)iface;
if (IsEqualGUID(&IID_IUnknown, riid)
|| IsEqualGUID(&IID_IDirectDrawClipper, riid))
{
*ppvObj = ICOM_INTERFACE(This, IDirectDrawClipper);
InterlockedIncrement(&This->ref);
return S_OK;
}
else
{
return E_NOINTERFACE;
}
}
/*****************************************************************************
* IDirectDrawClipper::AddRef
*
* Increases the reference count of the interface, returns the new count
*
*****************************************************************************/
static ULONG WINAPI IDirectDrawClipperImpl_AddRef( LPDIRECTDRAWCLIPPER iface )
{
IDirectDrawClipperImpl *This = (IDirectDrawClipperImpl *)iface;
ULONG ref = InterlockedIncrement(&This->ref);
TRACE("(%p)->() incrementing from %u.\n", This, ref - 1);
return ref;
}
/*****************************************************************************
* IDirectDrawClipper::Release
*
* Decreases the reference count of the interface, returns the new count
* If the refcount is decreased to 0, the interface is destroyed.
*
*****************************************************************************/
static ULONG WINAPI IDirectDrawClipperImpl_Release(IDirectDrawClipper *iface) {
IDirectDrawClipperImpl *This = (IDirectDrawClipperImpl *)iface;
ULONG ref = InterlockedDecrement(&This->ref);
TRACE("(%p)->() decrementing from %u.\n", This, ref + 1);
if (ref == 0)
{
HeapFree(GetProcessHeap(), 0, This);
return 0;
}
else return ref;
}
/*****************************************************************************
* IDirectDrawClipper::SetHwnd
*
* Assigns a hWnd to the clipper interface.
*
* Arguments:
* Flags: Unsupported so far
* hWnd: The hWnd to set
*
* Return values:
* DD_OK on success
* DDERR_INVALIDPARAMS if Flags was != 0
*
*****************************************************************************/
static HRESULT WINAPI IDirectDrawClipperImpl_SetHwnd(
LPDIRECTDRAWCLIPPER iface, DWORD dwFlags, HWND hWnd
) {
IDirectDrawClipperImpl *This = (IDirectDrawClipperImpl *)iface;
TRACE("(%p)->(0x%08x,0x%08x)\n", This, dwFlags, (DWORD)hWnd);
if( dwFlags ) {
FIXME("dwFlags = 0x%08x, not supported.\n",dwFlags);
return DDERR_INVALIDPARAMS;
}
This->hWnd = hWnd;
return DD_OK;
}
/*****************************************************************************
* IDirectDrawClipper::GetClipList
*
* Retrieve a copy of the clip list
*
* Arguments:
* Rect: Rectangle to be used to clip the clip list or NULL for the
* entire clip list
* ClipList: structure for the resulting copy of the clip list.
* If NULL, fills Size up to the number of bytes necessary to hold
* the entire clip.
* Size: Size of resulting clip list; size of the buffer at ClipList
* or, if ClipList is NULL, receives the required size of the buffer
* in bytes
*
* RETURNS
* Either DD_OK or DDERR_*
************************************************************************/
static HRESULT WINAPI IDirectDrawClipperImpl_GetClipList(
LPDIRECTDRAWCLIPPER iface, LPRECT lpRect, LPRGNDATA lpClipList,
LPDWORD lpdwSize)
{
IDirectDrawClipperImpl *This = (IDirectDrawClipperImpl *)iface;
TRACE("(%p,%p,%p,%p)\n", This, lpRect, lpClipList, lpdwSize);
if (This->hWnd)
{
HDC hDC = GetDCEx(This->hWnd, NULL, DCX_WINDOW);
if (hDC)
{
HRGN hRgn = CreateRectRgn(0,0,0,0);
if (GetRandomRgn(hDC, hRgn, SYSRGN))
{
if (GetVersion() & 0x80000000)
{
/* map region to screen coordinates */
POINT org;
GetDCOrgEx( hDC, &org );
OffsetRgn( hRgn, org.x, org.y );
}
if (lpRect)
{
HRGN hRgnClip = CreateRectRgn(lpRect->left, lpRect->top,
lpRect->right, lpRect->bottom);
CombineRgn(hRgn, hRgn, hRgnClip, RGN_AND);
DeleteObject(hRgnClip);
}
*lpdwSize = GetRegionData(hRgn, *lpdwSize, lpClipList);
}
DeleteObject(hRgn);
ReleaseDC(This->hWnd, hDC);
}
return DD_OK;
}
else
{
static int warned = 0;
if (warned++ < 10)
FIXME("(%p,%p,%p,%p),stub!\n",This,lpRect,lpClipList,lpdwSize);
if (lpdwSize) *lpdwSize=0;
return DDERR_NOCLIPLIST;
}
}
/*****************************************************************************
* IDirectDrawClipper::SetClipList
*
* Sets or deletes (if lprgn is NULL) the clip list
*
* This implementation is a stub and returns DD_OK always to make the app
* happy.
*
* PARAMS
* lprgn Pointer to a LRGNDATA structure or NULL
* dwFlags not used, must be 0
* RETURNS
* Either DD_OK or DDERR_*
*****************************************************************************/
static HRESULT WINAPI IDirectDrawClipperImpl_SetClipList(
LPDIRECTDRAWCLIPPER iface,LPRGNDATA lprgn,DWORD dwFlag
) {
IDirectDrawClipperImpl *This = (IDirectDrawClipperImpl *)iface;
static int warned = 0;
if (warned++ < 10 || lprgn == NULL)
FIXME("(%p,%p,%d),stub!\n",This,lprgn,dwFlag);
return DD_OK;
}
/*****************************************************************************
* IDirectDrawClipper::GetHwnd
*
* Returns the hwnd assigned with SetHwnd
*
* Arguments:
* hWndPtr: Address to store the HWND at
*
* Return values:
* Always returns DD_OK;
*****************************************************************************/
static HRESULT WINAPI IDirectDrawClipperImpl_GetHWnd(
LPDIRECTDRAWCLIPPER iface, HWND* hWndPtr
) {
IDirectDrawClipperImpl *This = (IDirectDrawClipperImpl *)iface;
TRACE("(%p)->(%p)\n", This, hWndPtr);
*hWndPtr = This->hWnd;
return DD_OK;
}
/*****************************************************************************
* IDirectDrawClipper::Initialize
*
* Initializes the interface. Well, there isn't much to do for this
* implementation, but it stores the DirectDraw Interface.
*
* Arguments:
* DD: Pointer to a IDirectDraw interface
* Flags: Unsupported by now
*
* Return values:
* DD_OK on success
* DDERR_ALREADYINITIALIZED if this interface isn't initialized already
*****************************************************************************/
static HRESULT WINAPI IDirectDrawClipperImpl_Initialize(
LPDIRECTDRAWCLIPPER iface, LPDIRECTDRAW lpDD, DWORD dwFlags
) {
IDirectDrawImpl* pOwner;
IDirectDrawClipperImpl *This = (IDirectDrawClipperImpl *)iface;
TRACE("(%p)->(%p,0x%08x)\n", This, lpDD, dwFlags);
if (This->ddraw_owner != NULL) return DDERR_ALREADYINITIALIZED;
pOwner = ICOM_OBJECT(IDirectDrawImpl, IDirectDraw, lpDD);
This->ddraw_owner = pOwner;
return DD_OK;
}
/*****************************************************************************
* IDirectDrawClipper::IsClipListChanged
*
* This function is a stub
*
* Arguments:
* Changed:
*
* Return values:
* DD_OK, because it's a stub
*****************************************************************************/
static HRESULT WINAPI IDirectDrawClipperImpl_IsClipListChanged(
LPDIRECTDRAWCLIPPER iface, BOOL* lpbChanged
) {
IDirectDrawClipperImpl *This = (IDirectDrawClipperImpl *)iface;
FIXME("(%p)->(%p),stub!\n",This,lpbChanged);
/* XXX What is safest? */
*lpbChanged = FALSE;
return DD_OK;
}
/*****************************************************************************
* The VTable
*****************************************************************************/
const IDirectDrawClipperVtbl IDirectDrawClipper_Vtbl =
{
IDirectDrawClipperImpl_QueryInterface,
IDirectDrawClipperImpl_AddRef,
IDirectDrawClipperImpl_Release,
IDirectDrawClipperImpl_GetClipList,
IDirectDrawClipperImpl_GetHWnd,
IDirectDrawClipperImpl_Initialize,
IDirectDrawClipperImpl_IsClipListChanged,
IDirectDrawClipperImpl_SetClipList,
IDirectDrawClipperImpl_SetHwnd
};

View File

@@ -0,0 +1,58 @@
/* A few helpful macros for implementing COM objects.
*
* Copyright 2000 TransGaming Technologies Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef _DDCOMIMPL_H_
#define _DDCOMIMPL_H_
#include <stddef.h>
/* Generates the name for a vtable pointer for a given interface. */
/* The canonical name for a single interface is "lpVtbl". */
#define ICOM_VFIELD_MULTI_NAME2(iface) ITF_##iface
#define ICOM_VFIELD_MULTI_NAME(iface) ICOM_VFIELD_MULTI_NAME2(iface)
/* Declares a vtable pointer field in an implementation. */
#define ICOM_VFIELD_MULTI(iface) \
iface ICOM_VFIELD_MULTI_NAME(iface)
/* Returns the offset of a vtable pointer within an implementation object. */
#define ICOM_VFIELD_OFFSET(impltype, iface) \
offsetof(impltype, ICOM_VFIELD_MULTI_NAME(iface))
/* Given an interface pointer, returns the implementation pointer. */
#define ICOM_OBJECT(impltype, ifacename, ifaceptr) \
(impltype*)((ifaceptr) == NULL ? NULL \
: (char*)(ifaceptr) - ICOM_VFIELD_OFFSET(impltype,ifacename))
#define ICOM_THIS_FROM(impltype, ifacename, ifaceptr) \
impltype* This = ICOM_OBJECT(impltype, ifacename, ifaceptr)
/* Given an object and interface name, returns a pointer to that interface. */
#define ICOM_INTERFACE(implobj, iface) \
(implobj == NULL ? NULL :&((implobj)->ICOM_VFIELD_MULTI_NAME(iface)))
#define ICOM_INIT_INTERFACE(implobj, ifacename, vtblname) \
do { \
(implobj)->ICOM_VFIELD_MULTI_NAME(ifacename).lpVtbl = &(vtblname); \
} while (0)
#define COM_INTERFACE_CAST(impltype, ifnamefrom, ifnameto, ifaceptr) \
ICOM_INTERFACE(ICOM_OBJECT(impltype, ifnamefrom, ifaceptr), ifnameto)
#endif /* _DDCOMIMPL_H_ */

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,26 @@
LIBRARY "ddraw.dll"
EXPORTS
AcquireDDThreadLock @0
ReleaseDDThreadLock @0
GetSurfaceFromDC@12
GetDDSurfaceLocal@12
D3DParseUnknownCommand@8
DDGetAttachedSurfaceLcl@12
DDInternalLock@8
DDInternalUnlock@4
DSoundHelp@12
DirectDrawCreate@12
DirectDrawCreateClipper@12
DirectDrawCreateEx@16
DirectDrawEnumerateA@8
DirectDrawEnumerateW@8
DirectDrawEnumerateExA@12
DirectDrawEnumerateExW@12
DllCanUnloadNow PRIVATE
DllGetClassObject PRIVATE
; fixme ??
CheckFullscreen
CompleteCreateSysmemSurface
;GetOLEThunkData
;RegisterSpecialCase

View File

@@ -0,0 +1,189 @@
# Microsoft Developer Studio Project File - Name="ddraw" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
CFG=ddraw - Win32 Debug
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
!MESSAGE
!MESSAGE NMAKE /f "ddraw.mak".
!MESSAGE
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "ddraw.mak" CFG="ddraw - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "ddraw - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE "ddraw - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE
# Begin Project
# PROP AllowPerConfigDependencies 0
# PROP Scc_ProjName ""
# PROP Scc_LocalPath ""
CPP=cl.exe
MTL=midl.exe
RSC=rc.exe
!IF "$(CFG)" == "ddraw - Win32 Release"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Release"
# PROP BASE Intermediate_Dir "Release"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "Release"
# PROP Intermediate_Dir "Release"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c
# ADD CPP /nologo /MD /W3 /GX /Zi /O2 /I "$(DXSDK_DIR)\include" /I "$(MSSDK)\include" /I "..\..\include" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "__WINESRC__" /YX /FD /c
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x419 /d "NDEBUG"
# ADD RSC /l 0x419 /i "..\..\include" /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386
# ADD LINK32 kernel32.lib user32.lib gdi32.lib advapi32.lib ole32.lib uuid.lib dxguid.lib /nologo /subsystem:windows /dll /pdb:"../../bin/ddraw.pdb" /debug /machine:I386 /out:"../../bin/ddraw.dll"
# SUBTRACT LINK32 /pdb:none
!ELSEIF "$(CFG)" == "ddraw - Win32 Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "Debug"
# PROP BASE Intermediate_Dir "Debug"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "Debug"
# PROP Intermediate_Dir "Debug"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /GZ /c
# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "$(DXSDK_DIR)\include" /I "$(MSSDK)\include" /I "..\..\include" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "__WINESRC__" /YX /FD /GZ /c
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x419 /d "_DEBUG"
# ADD RSC /l 0x419 /i "..\..\include" /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386 /pdbtype:sept
# ADD LINK32 kernel32.lib user32.lib gdi32.lib advapi32.lib ole32.lib uuid.lib dxguid.lib /nologo /subsystem:windows /dll /pdb:"../../bin/ddraw.pdb" /debug /machine:I386 /out:"../../bin/ddraw.dll" /pdbtype:sept
# SUBTRACT LINK32 /pdb:none
!ENDIF
# Begin Target
# Name "ddraw - Win32 Release"
# Name "ddraw - Win32 Debug"
# Begin Group "Source Files"
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
# Begin Source File
SOURCE=.\clipper.c
# End Source File
# Begin Source File
SOURCE=.\ddraw.c
# End Source File
# Begin Source File
SOURCE=.\ddraw.def
# End Source File
# Begin Source File
SOURCE=.\ddraw_thunks.c
# End Source File
# Begin Source File
SOURCE=.\device.c
# End Source File
# Begin Source File
SOURCE=.\direct3d.c
# End Source File
# Begin Source File
SOURCE=.\executebuffer.c
# End Source File
# Begin Source File
SOURCE=.\gamma.c
# End Source File
# Begin Source File
SOURCE=.\light.c
# End Source File
# Begin Source File
SOURCE=.\main.c
# End Source File
# Begin Source File
SOURCE=.\material.c
# End Source File
# Begin Source File
SOURCE=.\palette.c
# End Source File
# Begin Source File
SOURCE=.\parent.c
# End Source File
# Begin Source File
SOURCE=.\regsvr.c
# End Source File
# Begin Source File
SOURCE=.\surface.c
# End Source File
# Begin Source File
SOURCE=.\surface_thunks.c
# End Source File
# Begin Source File
SOURCE=.\texture.c
# End Source File
# Begin Source File
SOURCE=.\utils.c
# End Source File
# Begin Source File
SOURCE=.\vertexbuffer.c
# End Source File
# Begin Source File
SOURCE=.\viewport.c
# End Source File
# End Group
# Begin Group "Header Files"
# PROP Default_Filter "h;hpp;hxx;hm;inl"
# End Group
# Begin Group "Resource Files"
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
# Begin Source File
SOURCE=.\version.rc
# End Source File
# End Group
# End Target
# End Project

View File

@@ -0,0 +1,52 @@
<module name="ddraw" type="win32dll" entrypoint="0" installbase="system32" installname="ddraw.dll" allowwarnings ="true">
<importlibrary definition="ddraw.def" />
<include base="ddraw">.</include>
<include base="ReactOS">include/reactos/wine-paralles</include>
<include base="ReactOS">include/reactos/wine</include>
<define name="UNICODE" />
<define name="_UNICODE" />
<define name="__REACTOS__" />
<define name="__USE_W32API" />
<define name="_WIN32_IE">0x600</define>
<define name="_WIN32_WINNT">0x501</define>
<define name="WINVER">0x501</define>
<define name="__WINESRC__" />
<library>wine</library>
<library>uuid</library>
<library>ntdll</library>
<library>kernel32</library>
<library>user32</library>
<library>gdi32</library>
<library>winspool</library>
<library>comdlg32</library>
<library>shell32</library>
<library>ole32</library>
<library>oleaut32</library>
<library>oleaut32</library>
<library>dxguid</library>
<library>msvcrt</library>
<library>advapi32</library>
<library>pseh</library>
<file>clipper.c</file>
<file>ddraw.c</file>
<file>ddraw_thunks.c</file>
<file>device.c</file>
<file>direct3d.c</file>
<file>executebuffer.c</file>
<file>gamma.c</file>
<file>light.c</file>
<file>main.c</file>
<file>material.c</file>
<file>palette.c</file>
<file>parent.c</file>
<file>regsvr.c</file>
<file>surface.c</file>
<file>surface_thunks.c </file>
<file>texture.c</file>
<file>utils.c</file>
<file>vertexbuffer.c</file>
<file>viewport.c</file>
<file>version.rc</file>
</module>

View File

@@ -0,0 +1,680 @@
/*
* Copyright 2006 Stefan D<>singer
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef __WINE_DLLS_DDRAW_DDRAW_PRIVATE_H
#define __WINE_DLLS_DDRAW_DDRAW_PRIVATE_H
/* MAY NOT CONTAIN X11 or DGA specific includes/defines/structs! */
#include <stdarg.h>
#include <stdio.h>
#ifndef WINE_NATIVEWIN32
# include "windef.h"
# include "winbase.h"
# include "wtypes.h"
# include "wingdi.h"
# include "winuser.h"
#else
# include <windows.h>
#endif
#include "ddraw.h"
#include "ddrawi.h"
#include "d3d.h"
#include "ddcomimpl.h"
#include "wine/wined3d_interface.h"
#include "wine/list.h"
/*****************************************************************************
* IParent - a helper interface
*****************************************************************************/
DEFINE_GUID(IID_IParent, 0xc20e4c88, 0x74e7, 0x4940, 0xba, 0x9f, 0x2e, 0x32, 0x3f, 0x9d, 0xc9, 0x81);
typedef struct IParent *LPPARENT, *PPARENT;
#define INTERFACE IParent
DECLARE_INTERFACE_(IParent,IUnknown)
{
/*** IUnknown methods ***/
STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID riid, void** ppvObject) PURE;
STDMETHOD_(ULONG,AddRef)(THIS) PURE;
STDMETHOD_(ULONG,Release)(THIS) PURE;
};
#undef INTERFACE
#if !defined(__cplusplus) || defined(CINTERFACE)
/*** IUnknown methods ***/
#define IParent_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
#define IParent_AddRef(p) (p)->lpVtbl->AddRef(p)
#define IParent_Release(p) (p)->lpVtbl->Release(p)
#endif
/* Typdef the interfaces */
typedef struct IDirectDrawImpl IDirectDrawImpl;
typedef struct IDirectDrawSurfaceImpl IDirectDrawSurfaceImpl;
typedef struct IDirectDrawClipperImpl IDirectDrawClipperImpl;
typedef struct IDirectDrawPaletteImpl IDirectDrawPaletteImpl;
typedef struct IDirect3DDeviceImpl IDirect3DDeviceImpl;
typedef struct IDirect3DLightImpl IDirect3DLightImpl;
typedef struct IDirect3DViewportImpl IDirect3DViewportImpl;
typedef struct IDirect3DMaterialImpl IDirect3DMaterialImpl;
typedef struct IDirect3DExecuteBufferImpl IDirect3DExecuteBufferImpl;
typedef struct IDirect3DVertexBufferImpl IDirect3DVertexBufferImpl;
typedef struct IParentImpl IParentImpl;
/* Callbacks for implicit object destruction */
extern ULONG WINAPI D3D7CB_DestroySwapChain(IWineD3DSwapChain *pSwapChain);
extern ULONG WINAPI D3D7CB_DestroyDepthStencilSurface(IWineD3DSurface *pSurface);
/*****************************************************************************
* IDirectDraw implementation structure
*****************************************************************************/
struct FvfToDecl
{
DWORD fvf;
IWineD3DVertexDeclaration *decl;
};
struct IDirectDrawImpl
{
/* IUnknown fields */
ICOM_VFIELD_MULTI(IDirectDraw7);
ICOM_VFIELD_MULTI(IDirectDraw4);
#ifndef WINE_NATIVEWIN32
ICOM_VFIELD_MULTI(IDirectDraw3);
#endif
ICOM_VFIELD_MULTI(IDirectDraw2);
ICOM_VFIELD_MULTI(IDirectDraw);
ICOM_VFIELD_MULTI(IDirect3D7);
ICOM_VFIELD_MULTI(IDirect3D3);
ICOM_VFIELD_MULTI(IDirect3D2);
ICOM_VFIELD_MULTI(IDirect3D);
/* See comment in IDirectDraw::AddRef */
LONG ref7, ref4, ref2, ref3, ref1, numIfaces;
/* WineD3D linkage */
IWineD3D *wineD3D;
IWineD3DDevice *wineD3DDevice;
IDirectDrawSurfaceImpl *DepthStencilBuffer;
BOOL d3d_initialized;
/* Misc ddraw fields */
UINT total_vidmem;
DWORD cur_scanline;
BOOL fake_vblank;
BOOL initialized;
/* DirectDraw things, which are not handled by WineD3D */
DWORD cooperative_level;
DWORD orig_width, orig_height;
DWORD orig_bpp;
DDCAPS caps;
/* D3D things */
IDirectDrawSurfaceImpl *d3d_target;
HWND d3d_window;
IDirect3DDeviceImpl *d3ddevice;
int d3dversion;
/* Various HWNDs */
HWND focuswindow;
HWND devicewindow;
/* The surface type to request */
WINED3DSURFTYPE ImplType;
/* Our private window class */
char classname[32];
WNDCLASSA wnd_class;
/* Helpers for surface creation */
IDirectDrawSurfaceImpl *tex_root;
BOOL depthstencil;
/* For the dll unload cleanup code */
struct list ddraw_list_entry;
/* The surface list - can't relay this to WineD3D
* because of IParent
*/
struct list surface_list;
LONG surfaces;
/* FVF management */
struct FvfToDecl *decls;
UINT numConvertedDecls, declArraySize;
};
/* Declare the VTables. They can be found ddraw.c */
const IDirectDraw7Vtbl IDirectDraw7_Vtbl;
const IDirectDraw4Vtbl IDirectDraw4_Vtbl;
#ifndef WINE_NATIVEWIN32
const IDirectDraw3Vtbl IDirectDraw3_Vtbl;
#endif
const IDirectDraw2Vtbl IDirectDraw2_Vtbl;
const IDirectDrawVtbl IDirectDraw1_Vtbl;
/* Helper structures */
typedef struct EnumDisplayModesCBS
{
void *context;
LPDDENUMMODESCALLBACK2 callback;
} EnumDisplayModesCBS;
typedef struct EnumSurfacesCBS
{
void *context;
LPDDENUMSURFACESCALLBACK7 callback;
LPDDSURFACEDESC2 pDDSD;
DWORD Flags;
} EnumSurfacesCBS;
/* Utility functions */
void
DDRAW_Convert_DDSCAPS_1_To_2(const DDSCAPS* pIn,
DDSCAPS2* pOut);
void
DDRAW_Convert_DDDEVICEIDENTIFIER_2_To_1(const DDDEVICEIDENTIFIER2* pIn,
DDDEVICEIDENTIFIER* pOut);
void
IDirectDrawImpl_Destroy(IDirectDrawImpl *This);
HRESULT WINAPI
IDirectDrawImpl_RecreateSurfacesCallback(IDirectDrawSurface7 *surf,
DDSURFACEDESC2 *desc,
void *Context);
IWineD3DVertexDeclaration *
IDirectDrawImpl_FindDecl(IDirectDrawImpl *This,
DWORD fvf);
void
remove_ddraw_object(IDirectDrawImpl *ddraw);
/* The default surface type */
extern WINED3DSURFTYPE DefaultSurfaceType;
/*****************************************************************************
* IDirectDrawSurface implementation structure
*****************************************************************************/
struct IDirectDrawSurfaceImpl
{
/* IUnknown fields */
ICOM_VFIELD_MULTI(IDirectDrawSurface7);
ICOM_VFIELD_MULTI(IDirectDrawSurface3);
ICOM_VFIELD_MULTI(IDirectDrawGammaControl);
ICOM_VFIELD_MULTI(IDirect3DTexture2);
ICOM_VFIELD_MULTI(IDirect3DTexture);
LONG ref;
IUnknown *ifaceToRelease;
int version;
/* Connections to other Objects */
IDirectDrawImpl *ddraw;
IWineD3DSurface *WineD3DSurface;
IWineD3DTexture *wineD3DTexture;
/* This implementation handles attaching surfaces to other surfaces */
IDirectDrawSurfaceImpl *next_attached;
IDirectDrawSurfaceImpl *first_attached;
IDirectDrawSurfaceImpl *next_complex;
IDirectDrawSurfaceImpl *first_complex;
/* Surface description, for GetAttachedSurface */
DDSURFACEDESC2 surface_desc;
/* Misc things */
DWORD uniqueness_value;
UINT mipmap_level;
WINED3DSURFTYPE ImplType;
/* For D3DDevice creation */
BOOL isRenderTarget;
/* Clipper objects */
IDirectDrawClipperImpl *clipper;
/* For the ddraw surface list */
struct list surface_list_entry;
DWORD Handle;
};
/* VTable declaration. It's located in surface.c / surface_thunks.c */
const IDirectDrawSurface7Vtbl IDirectDrawSurface7_Vtbl;
const IDirectDrawSurface3Vtbl IDirectDrawSurface3_Vtbl;
const IDirectDrawGammaControlVtbl IDirectDrawGammaControl_Vtbl;
const IDirect3DTexture2Vtbl IDirect3DTexture2_Vtbl;
const IDirect3DTextureVtbl IDirect3DTexture1_Vtbl;
/* Get the number of bytes per pixel for a given surface */
#define PFGET_BPP(pf) (pf.dwFlags&DDPF_PALETTEINDEXED8?1:((pf.dwRGBBitCount+7)/8))
#define GET_BPP(desc) PFGET_BPP(desc.ddpfPixelFormat)
/*****************************************************************************
* IParent Implementation
*****************************************************************************/
struct IParentImpl
{
/* IUnknown fields */
ICOM_VFIELD_MULTI(IParent);
LONG ref;
/* IParentImpl fields */
IUnknown *child;
};
const IParentVtbl IParent_Vtbl;
/*****************************************************************************
* IDirect3DDevice implementation
*****************************************************************************/
typedef enum
{
DDrawHandle_Unknown = 0,
DDrawHandle_Texture = 1,
DDrawHandle_Material = 2,
DDrawHandle_Matrix = 3,
DDrawHandle_StateBlock = 4
} DDrawHandleTypes;
struct HandleEntry
{
void *ptr;
DDrawHandleTypes type;
};
struct IDirect3DDeviceImpl
{
/* IUnknown */
ICOM_VFIELD_MULTI(IDirect3DDevice7);
ICOM_VFIELD_MULTI(IDirect3DDevice3);
ICOM_VFIELD_MULTI(IDirect3DDevice2);
ICOM_VFIELD_MULTI(IDirect3DDevice);
LONG ref;
/* Other object connections */
IWineD3DDevice *wineD3DDevice;
IDirectDrawImpl *ddraw;
IWineD3DIndexBuffer *indexbuffer;
IDirectDrawSurfaceImpl *target;
BOOL OffScreenTarget;
/* Viewport management */
IDirect3DViewportImpl *viewport_list;
IDirect3DViewportImpl *current_viewport;
D3DVIEWPORT7 active_viewport;
/* Light state */
DWORD material;
/* Rendering functions to wrap D3D(1-3) to D3D7 */
D3DPRIMITIVETYPE primitive_type;
DWORD vertex_type;
DWORD render_flags;
DWORD nb_vertices;
LPBYTE vertex_buffer;
DWORD vertex_size;
DWORD buffer_size;
/* Handle management */
struct HandleEntry *Handles;
DWORD numHandles;
};
/* Vtables in various versions */
const IDirect3DDevice7Vtbl IDirect3DDevice7_Vtbl;
const IDirect3DDevice3Vtbl IDirect3DDevice3_Vtbl;
const IDirect3DDevice2Vtbl IDirect3DDevice2_Vtbl;
const IDirect3DDeviceVtbl IDirect3DDevice1_Vtbl;
/* The IID */
const GUID IID_D3DDEVICE_WineD3D;
/* Helper functions */
HRESULT IDirect3DImpl_GetCaps(IWineD3D *WineD3D, D3DDEVICEDESC *Desc123, D3DDEVICEDESC7 *Desc7);
DWORD IDirect3DDeviceImpl_CreateHandle(IDirect3DDeviceImpl *This);
/* Structures */
struct EnumTextureFormatsCBS
{
LPD3DENUMTEXTUREFORMATSCALLBACK cbv2;
LPD3DENUMPIXELFORMATSCALLBACK cbv7;
void *Context;
};
/*****************************************************************************
* IDirect3D implementation
*****************************************************************************/
/* No implementation structure as this is only another interface to DirectDraw */
/* the Vtables */
const IDirect3DVtbl IDirect3D1_Vtbl;
const IDirect3D2Vtbl IDirect3D2_Vtbl;
const IDirect3D3Vtbl IDirect3D3_Vtbl;
const IDirect3D7Vtbl IDirect3D7_Vtbl;
/* Structure for EnumZBufferFormats */
struct EnumZBufferFormatsData
{
LPD3DENUMPIXELFORMATSCALLBACK Callback;
void *Context;
};
/*****************************************************************************
* IDirectDrawClipper implementation structure
*****************************************************************************/
struct IDirectDrawClipperImpl
{
/* IUnknown fields */
ICOM_VFIELD_MULTI(IDirectDrawClipper);
LONG ref;
/* IDirectDrawClipper fields */
HWND hWnd;
IDirectDrawImpl* ddraw_owner;
struct IDirectDrawClipperImpl* prev_ddraw;
struct IDirectDrawClipperImpl* next_ddraw;
};
const IDirectDrawClipperVtbl IDirectDrawClipper_Vtbl;
/*****************************************************************************
* IDirectDrawPalette implementation structure
*****************************************************************************/
struct IDirectDrawPaletteImpl
{
/* IUnknown fields */
ICOM_VFIELD_MULTI(IDirectDrawPalette);
LONG ref;
/* WineD3D uplink */
IWineD3DPalette *wineD3DPalette;
/* IDirectDrawPalette fields */
IDirectDrawImpl *ddraw_owner;
IUnknown *ifaceToRelease;
};
const IDirectDrawPaletteVtbl IDirectDrawPalette_Vtbl;
/******************************************************************************
* DirectDraw ClassFactory implementation - incomplete
******************************************************************************/
typedef struct
{
ICOM_VFIELD_MULTI(IClassFactory);
LONG ref;
HRESULT (*pfnCreateInstance)(IUnknown *pUnkOuter, REFIID iid, LPVOID *ppObj);
} IClassFactoryImpl;
/* Helper structures */
struct object_creation_info
{
const CLSID *clsid;
HRESULT (*pfnCreateInstance)(IUnknown *pUnkOuter, REFIID riid,
void **ppObj);
};
/******************************************************************************
* IDirect3DLight implementation structure - Wraps to D3D7
******************************************************************************/
struct IDirect3DLightImpl
{
ICOM_VFIELD_MULTI(IDirect3DLight);
LONG ref;
/* IDirect3DLight fields */
IDirectDrawImpl *ddraw;
/* If this light is active for one viewport, put the viewport here */
IDirect3DViewportImpl *active_viewport;
D3DLIGHT2 light;
D3DLIGHT7 light7;
DWORD dwLightIndex;
/* Chained list used for adding / removing from viewports */
IDirect3DLightImpl *next;
/* Activation function */
void (*activate)(IDirect3DLightImpl*);
void (*desactivate)(IDirect3DLightImpl*);
void (*update)(IDirect3DLightImpl*);
};
/* Vtable */
const IDirect3DLightVtbl IDirect3DLight_Vtbl;
/* Helper functions */
void light_update(IDirect3DLightImpl* This);
void light_activate(IDirect3DLightImpl* This);
void light_desactivate(IDirect3DLightImpl* This);
/******************************************************************************
* IDirect3DMaterial implementation structure - Wraps to D3D7
******************************************************************************/
struct IDirect3DMaterialImpl
{
ICOM_VFIELD_MULTI(IDirect3DMaterial3);
ICOM_VFIELD_MULTI(IDirect3DMaterial2);
ICOM_VFIELD_MULTI(IDirect3DMaterial);
LONG ref;
/* IDirect3DMaterial2 fields */
IDirectDrawImpl *ddraw;
IDirect3DDeviceImpl *active_device;
D3DMATERIAL mat;
DWORD Handle;
void (*activate)(IDirect3DMaterialImpl* this);
};
/* VTables in various versions */
const IDirect3DMaterialVtbl IDirect3DMaterial_Vtbl;
const IDirect3DMaterial2Vtbl IDirect3DMaterial2_Vtbl;
const IDirect3DMaterial3Vtbl IDirect3DMaterial3_Vtbl;
/* Helper functions */
void material_activate(IDirect3DMaterialImpl* This);
/*****************************************************************************
* IDirect3DViewport - Wraps to D3D7
*****************************************************************************/
struct IDirect3DViewportImpl
{
ICOM_VFIELD_MULTI(IDirect3DViewport3);
LONG ref;
/* IDirect3DViewport fields */
IDirectDrawImpl *ddraw;
/* If this viewport is active for one device, put the device here */
IDirect3DDeviceImpl *active_device;
DWORD num_lights;
DWORD map_lights;
int use_vp2;
union
{
D3DVIEWPORT vp1;
D3DVIEWPORT2 vp2;
} viewports;
/* Activation function */
void (*activate)(IDirect3DViewportImpl*);
/* Field used to chain viewports together */
IDirect3DViewportImpl *next;
/* Lights list */
IDirect3DLightImpl *lights;
/* Background material */
IDirect3DMaterialImpl *background;
};
/* Vtable */
const IDirect3DViewport3Vtbl IDirect3DViewport3_Vtbl;
/* Helper functions */
void viewport_activate(IDirect3DViewportImpl* This);
/*****************************************************************************
* IDirect3DExecuteBuffer - Wraps to D3D7
*****************************************************************************/
struct IDirect3DExecuteBufferImpl
{
/* IUnknown */
ICOM_VFIELD_MULTI(IDirect3DExecuteBuffer);
LONG ref;
/* IDirect3DExecuteBuffer fields */
IDirectDrawImpl *ddraw;
IDirect3DDeviceImpl *d3ddev;
D3DEXECUTEBUFFERDESC desc;
D3DEXECUTEDATA data;
/* This buffer will store the transformed vertices */
void *vertex_data;
WORD *indices;
int nb_indices;
/* This flags is set to TRUE if we allocated ourselves the
* data buffer
*/
BOOL need_free;
};
/* The VTable */
const IDirect3DExecuteBufferVtbl IDirect3DExecuteBuffer_Vtbl;
/* The execute function */
void
IDirect3DExecuteBufferImpl_Execute(IDirect3DExecuteBufferImpl *This,
IDirect3DDeviceImpl *Device,
IDirect3DViewportImpl *ViewportImpl);
/*****************************************************************************
* IDirect3DVertexBuffer
*****************************************************************************/
struct IDirect3DVertexBufferImpl
{
/*** IUnknown Methods ***/
ICOM_VFIELD_MULTI(IDirect3DVertexBuffer7);
ICOM_VFIELD_MULTI(IDirect3DVertexBuffer);
LONG ref;
/*** WineD3D and ddraw links ***/
IWineD3DVertexBuffer *wineD3DVertexBuffer;
IWineD3DVertexDeclaration *wineD3DVertexDeclaration;
IDirectDrawImpl *ddraw;
/*** Storage for D3D7 specific things ***/
DWORD Caps;
};
/* The Vtables */
const IDirect3DVertexBuffer7Vtbl IDirect3DVertexBuffer7_Vtbl;
const IDirect3DVertexBufferVtbl IDirect3DVertexBuffer1_Vtbl;
/*****************************************************************************
* Helper functions from utils.c
*****************************************************************************/
#define GET_TEXCOUNT_FROM_FVF(d3dvtVertexType) \
(((d3dvtVertexType) & D3DFVF_TEXCOUNT_MASK) >> D3DFVF_TEXCOUNT_SHIFT)
#define GET_TEXCOORD_SIZE_FROM_FVF(d3dvtVertexType, tex_num) \
(((((d3dvtVertexType) >> (16 + (2 * (tex_num)))) + 1) & 0x03) + 1)
void PixelFormat_WineD3DtoDD(DDPIXELFORMAT *DDPixelFormat, WINED3DFORMAT WineD3DFormat);
WINED3DFORMAT PixelFormat_DD2WineD3D(const DDPIXELFORMAT *DDPixelFormat);
void DDRAW_dump_surface_desc(const DDSURFACEDESC2 *lpddsd);
void DDRAW_dump_pixelformat(const DDPIXELFORMAT *PixelFormat);
void dump_D3DMATRIX(const D3DMATRIX *mat);
void DDRAW_dump_DDCAPS(const DDCAPS *lpcaps);
DWORD get_flexible_vertex_size(DWORD d3dvtVertexType);
void DDRAW_dump_DDSCAPS2(const DDSCAPS2 *in);
void DDRAW_dump_cooperativelevel(DWORD cooplevel);
/* This only needs to be here as long the processvertices functionality of
* IDirect3DExecuteBuffer isn't in WineD3D */
void multiply_matrix(LPD3DMATRIX dest, const D3DMATRIX *src1, const D3DMATRIX *src2);
/* Used for generic dumping */
typedef struct
{
DWORD val;
const char* name;
} flag_info;
#define FE(x) { x, #x }
typedef struct
{
DWORD val;
const char* name;
void (*func)(const void *);
ptrdiff_t offset;
} member_info;
/* Structure copy */
#define ME(x,f,e) { x, #x, (void (*)(const void *))(f), offsetof(STRUCT, e) }
#define DD_STRUCT_COPY_BYSIZE(to,from) \
do { \
DWORD __size = (to)->dwSize; \
DWORD __copysize = __size; \
DWORD __resetsize = __size; \
assert(to != from); \
if (__resetsize > sizeof(*to)) \
__resetsize = sizeof(*to); \
memset(to,0,__resetsize); \
if ((from)->dwSize < __size) \
__copysize = (from)->dwSize; \
memcpy(to,from,__copysize); \
(to)->dwSize = __size;/*restore size*/ \
} while (0)
#endif
HRESULT hr_ddraw_from_wined3d(HRESULT hr);

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,953 @@
/* Direct3D ExecuteBuffer
* Copyright (c) 1998-2004 Lionel ULMER
* Copyright (c) 2002-2004 Christian Costa
* Copyright (c) 2006 Stefan D<>singer
*
* This file contains the implementation of IDirect3DExecuteBuffer.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "config.h"
#include "wine/port.h"
#include <assert.h>
#include <stdarg.h>
#include <string.h>
#include <stdlib.h>
#define COBJMACROS
#define NONAMELESSUNION
//#ifndef WINE_NATIVEWIN32
# include "windef.h"
# include "winbase.h"
# include "winnls.h"
# include "winerror.h"
# include "wingdi.h"
//#endif
#include "ddraw.h"
#include "d3d.h"
#include "ddraw_private.h"
#include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(d3d7);
/*****************************************************************************
* _dump_executedata
* _dump_D3DEXECUTEBUFFERDESC
*
* Debug functions which write the executebuffer data to the console
*
*****************************************************************************/
static void _dump_executedata(const D3DEXECUTEDATA *lpData) {
DPRINTF("dwSize : %d\n", lpData->dwSize);
DPRINTF("Vertex Offset : %d Count : %d\n", lpData->dwVertexOffset, lpData->dwVertexCount);
DPRINTF("Instruction Offset : %d Length : %d\n", lpData->dwInstructionOffset, lpData->dwInstructionLength);
DPRINTF("HVertex Offset : %d\n", lpData->dwHVertexOffset);
}
static void _dump_D3DEXECUTEBUFFERDESC(const D3DEXECUTEBUFFERDESC *lpDesc) {
DPRINTF("dwSize : %d\n", lpDesc->dwSize);
DPRINTF("dwFlags : %x\n", lpDesc->dwFlags);
DPRINTF("dwCaps : %x\n", lpDesc->dwCaps);
DPRINTF("dwBufferSize : %d\n", lpDesc->dwBufferSize);
DPRINTF("lpData : %p\n", lpDesc->lpData);
}
/*****************************************************************************
* IDirect3DExecuteBufferImpl_Execute
*
* The main functionality of the execute buffer
* It transforms the vertices if necessary, and calls IDirect3DDevice7
* for drawing the vertices. It is called from
* IDirect3DDevice::Execute
*
* TODO: Perhaps some comments about the various opcodes wouldn't hurt
*
* Don't declare this static, as it's called from device.c,
* IDirect3DDevice::Execute
*
* Params:
* Device: 3D Device associated to use for drawing
* Viewport: Viewport for this operation
*
*****************************************************************************/
void
IDirect3DExecuteBufferImpl_Execute(IDirect3DExecuteBufferImpl *This,
IDirect3DDeviceImpl *lpDevice,
IDirect3DViewportImpl *lpViewport)
{
/* DWORD bs = This->desc.dwBufferSize; */
DWORD vs = This->data.dwVertexOffset;
/* DWORD vc = This->data.dwVertexCount; */
DWORD is = This->data.dwInstructionOffset;
/* DWORD il = This->data.dwInstructionLength; */
char *instr = (char *)This->desc.lpData + is;
/* Should check if the viewport was added or not to the device */
/* Activate the viewport */
lpViewport->active_device = lpDevice;
lpViewport->activate(lpViewport);
TRACE("ExecuteData :\n");
if (TRACE_ON(d3d7))
_dump_executedata(&(This->data));
while (1) {
LPD3DINSTRUCTION current = (LPD3DINSTRUCTION) instr;
BYTE size;
WORD count;
count = current->wCount;
size = current->bSize;
instr += sizeof(D3DINSTRUCTION);
switch (current->bOpcode) {
case D3DOP_POINT: {
WARN("POINT-s (%d)\n", count);
instr += count * size;
} break;
case D3DOP_LINE: {
WARN("LINE-s (%d)\n", count);
instr += count * size;
} break;
case D3DOP_TRIANGLE: {
int i;
D3DTLVERTEX *tl_vx = (D3DTLVERTEX *) This->vertex_data;
TRACE("TRIANGLE (%d)\n", count);
if (count*3>This->nb_indices) {
This->nb_indices = count * 3;
HeapFree(GetProcessHeap(),0,This->indices);
This->indices = HeapAlloc(GetProcessHeap(),0,sizeof(WORD)*This->nb_indices);
}
for (i = 0; i < count; i++) {
LPD3DTRIANGLE ci = (LPD3DTRIANGLE) instr;
#ifndef WINE_NATIVEWIN32
TRACE_(d3d7)(" v1: %d v2: %d v3: %d\n",ci->u1.v1, ci->u2.v2, ci->u3.v3);
#else
TRACE_(d3d7)(" v1: %d v2: %d v3: %d\n",ci->v1, ci->v2, ci->v3);
#endif
TRACE_(d3d7)(" Flags : ");
if (TRACE_ON(d3d7)) {
/* Wireframe */
if (ci->wFlags & D3DTRIFLAG_EDGEENABLE1)
TRACE_(d3d7)("EDGEENABLE1 ");
if (ci->wFlags & D3DTRIFLAG_EDGEENABLE2)
TRACE_(d3d7)("EDGEENABLE2 ");
if (ci->wFlags & D3DTRIFLAG_EDGEENABLE1)
TRACE_(d3d7)("EDGEENABLE3 ");
/* Strips / Fans */
if (ci->wFlags == D3DTRIFLAG_EVEN)
TRACE_(d3d7)("EVEN ");
if (ci->wFlags == D3DTRIFLAG_ODD)
TRACE_(d3d7)("ODD ");
if (ci->wFlags == D3DTRIFLAG_START)
TRACE_(d3d7)("START ");
if ((ci->wFlags > 0) && (ci->wFlags < 30))
TRACE_(d3d7)("STARTFLAT(%d) ", ci->wFlags);
TRACE_(d3d7)("\n");
}
#ifndef WINE_NATIVEWIN32
This->indices[(i * 3) ] = ci->u1.v1;
This->indices[(i * 3) + 1] = ci->u2.v2;
This->indices[(i * 3) + 2] = ci->u3.v3;
#else
This->indices[(i * 3) ] = ci->v1;
This->indices[(i * 3) + 1] = ci->v2;
This->indices[(i * 3) + 2] = ci->v3;
#endif
instr += size;
}
/* IDirect3DDevices have color keying always enabled -
* enable it before drawing. This overwrites any ALPHA*
* render state
*/
IWineD3DDevice_SetRenderState(lpDevice->wineD3DDevice,
WINED3DRS_COLORKEYENABLE,
1);
IDirect3DDevice7_DrawIndexedPrimitive(ICOM_INTERFACE(lpDevice,IDirect3DDevice7),
D3DPT_TRIANGLELIST,D3DFVF_TLVERTEX,tl_vx,0,This->indices,count*3,0);
} break;
case D3DOP_MATRIXLOAD:
WARN("MATRIXLOAD-s (%d)\n", count);
instr += count * size;
break;
case D3DOP_MATRIXMULTIPLY: {
int i;
TRACE("MATRIXMULTIPLY (%d)\n", count);
for (i = 0; i < count; i++) {
LPD3DMATRIXMULTIPLY ci = (LPD3DMATRIXMULTIPLY) instr;
LPD3DMATRIX a, b, c;
if(!ci->hDestMatrix || ci->hDestMatrix > lpDevice->numHandles ||
!ci->hSrcMatrix1 || ci->hSrcMatrix1 > lpDevice->numHandles ||
!ci->hSrcMatrix2 || ci->hSrcMatrix2 > lpDevice->numHandles) {
ERR("Handles out of bounds\n");
} else if (lpDevice->Handles[ci->hDestMatrix - 1].type != DDrawHandle_Matrix ||
lpDevice->Handles[ci->hSrcMatrix1 - 1].type != DDrawHandle_Matrix ||
lpDevice->Handles[ci->hSrcMatrix2 - 1].type != DDrawHandle_Matrix) {
ERR("Handle types invalid\n");
} else {
a = (LPD3DMATRIX) lpDevice->Handles[ci->hDestMatrix - 1].ptr;
b = (LPD3DMATRIX) lpDevice->Handles[ci->hSrcMatrix1 - 1].ptr;
c = (LPD3DMATRIX) lpDevice->Handles[ci->hSrcMatrix2 - 1].ptr;
TRACE(" Dest : %p Src1 : %p Src2 : %p\n",
a, b, c);
multiply_matrix(a,c,b);
}
instr += size;
}
} break;
case D3DOP_STATETRANSFORM: {
int i;
TRACE("STATETRANSFORM (%d)\n", count);
for (i = 0; i < count; i++) {
LPD3DSTATE ci = (LPD3DSTATE) instr;
#ifndef WINE_NATIVEWIN32
if(!ci->u2.dwArg[0]) {
ERR("Setting a NULL matrix handle, what should I do?\n");
} else if(ci->u2.dwArg[0] > lpDevice->numHandles) {
ERR("Handle %d is out of bounds\n", ci->u2.dwArg[0]);
} else if(lpDevice->Handles[ci->u2.dwArg[0] - 1].type != DDrawHandle_Matrix) {
ERR("Handle %d is not a matrix handle\n", ci->u2.dwArg[0]);
} else {
IDirect3DDevice7_SetTransform(ICOM_INTERFACE(lpDevice, IDirect3DDevice7),
ci->u1.drstRenderStateType, (LPD3DMATRIX) lpDevice->Handles[ci->u2.dwArg[0] - 1].ptr);
}
#else
if(!ci->dwArg[0]) {
ERR("Setting a NULL matrix handle, what should I do?\n");
} else if(ci->dwArg[0] > lpDevice->numHandles) {
ERR("Handle %d is out of bounds\n", ci->dwArg[0]);
} else if(lpDevice->Handles[ci->dwArg[0] - 1].type != DDrawHandle_Matrix) {
ERR("Handle %d is not a matrix handle\n", ci->dwArg[0]);
} else {
IDirect3DDevice7_SetTransform(ICOM_INTERFACE(lpDevice, IDirect3DDevice7),
ci->drstRenderStateType, (LPD3DMATRIX) lpDevice->Handles[ci->dwArg[0] - 1].ptr);
}
#endif
instr += size;
}
} break;
case D3DOP_STATELIGHT: {
int i;
TRACE("STATELIGHT (%d)\n", count);
for (i = 0; i < count; i++) {
LPD3DSTATE ci = (LPD3DSTATE) instr;
#ifndef WINE_NATIVEWIN32
TRACE("(%08x,%08x)\n",ci->u1.dlstLightStateType, ci->u2.dwArg[0]);
if (!ci->u1.dlstLightStateType && (ci->u1.dlstLightStateType > D3DLIGHTSTATE_COLORVERTEX))
ERR("Unexpected Light State Type\n");
else if (ci->u1.dlstLightStateType == D3DLIGHTSTATE_MATERIAL /* 1 */) {
IDirect3DMaterialImpl *mat = (IDirect3DMaterialImpl *) ci->u2.dwArg[0];
#else
TRACE("(%08x,%08x)\n",ci->dlstLightStateType, ci->dwArg[0]);
if (!ci->dlstLightStateType && (ci->dlstLightStateType > D3DLIGHTSTATE_COLORVERTEX))
ERR("Unexpected Light State Type\n");
else if (ci->dlstLightStateType == D3DLIGHTSTATE_MATERIAL /* 1 */) {
IDirect3DMaterialImpl *mat = (IDirect3DMaterialImpl *) ci->dwArg[0];
#endif
if (mat != NULL) {
mat->activate(mat);
} else {
FIXME(" D3DLIGHTSTATE_MATERIAL called with NULL material !!!\n");
}
}
#ifndef WINE_NATIVEWIN32
else if (ci->u1.dlstLightStateType == D3DLIGHTSTATE_COLORMODEL /* 3 */) {
switch (ci->u2.dwArg[0]) {
#else
else if (ci->dlstLightStateType == D3DLIGHTSTATE_COLORMODEL /* 3 */) {
switch (ci->dwArg[0]) {
#endif
case D3DCOLOR_MONO:
ERR("DDCOLOR_MONO should not happen!\n");
break;
case D3DCOLOR_RGB:
/* We are already in this mode */
break;
default:
ERR("Unknown color model!\n");
}
} else {
D3DRENDERSTATETYPE rs = 0;
#ifndef WINE_NATIVEWIN32
switch (ci->u1.dlstLightStateType) {
#else
switch (ci->dlstLightStateType) {
#endif
case D3DLIGHTSTATE_AMBIENT: /* 2 */
rs = D3DRENDERSTATE_AMBIENT;
break;
case D3DLIGHTSTATE_FOGMODE: /* 4 */
rs = D3DRENDERSTATE_FOGVERTEXMODE;
break;
case D3DLIGHTSTATE_FOGSTART: /* 5 */
rs = D3DRENDERSTATE_FOGSTART;
break;
case D3DLIGHTSTATE_FOGEND: /* 6 */
rs = D3DRENDERSTATE_FOGEND;
break;
case D3DLIGHTSTATE_FOGDENSITY: /* 7 */
rs = D3DRENDERSTATE_FOGDENSITY;
break;
case D3DLIGHTSTATE_COLORVERTEX: /* 8 */
rs = D3DRENDERSTATE_COLORVERTEX;
break;
default:
break;
}
#ifndef WINE_NATIVEWIN32
IDirect3DDevice7_SetRenderState(ICOM_INTERFACE(lpDevice, IDirect3DDevice7),
rs,ci->u2.dwArg[0]);
#else
IDirect3DDevice7_SetRenderState(ICOM_INTERFACE(lpDevice, IDirect3DDevice7),
rs,ci->dwArg[0]);
#endif
}
instr += size;
}
} break;
case D3DOP_STATERENDER: {
int i;
TRACE("STATERENDER (%d)\n", count);
for (i = 0; i < count; i++) {
LPD3DSTATE ci = (LPD3DSTATE) instr;
#ifndef WINE_NATIVEWIN32
IDirect3DDevice7_SetRenderState(ICOM_INTERFACE(lpDevice, IDirect3DDevice7),
ci->u1.drstRenderStateType, ci->u2.dwArg[0]);
#else
IDirect3DDevice7_SetRenderState(ICOM_INTERFACE(lpDevice, IDirect3DDevice7),
ci->drstRenderStateType, ci->dwArg[0]);
#endif
instr += size;
}
} break;
case D3DOP_PROCESSVERTICES:
{
/* TODO: Share code with IDirect3DVertexBuffer::ProcessVertices and / or
* IWineD3DDevice::ProcessVertices
*/
int i;
D3DMATRIX view_mat, world_mat, proj_mat;
TRACE("PROCESSVERTICES (%d)\n", count);
/* Get the transform and world matrix */
/* Note: D3DMATRIX is compatible with WINED3DMATRIX */
IWineD3DDevice_GetTransform(lpDevice->wineD3DDevice,
D3DTRANSFORMSTATE_VIEW,
(WINED3DMATRIX*) &view_mat);
IWineD3DDevice_GetTransform(lpDevice->wineD3DDevice,
D3DTRANSFORMSTATE_PROJECTION,
(WINED3DMATRIX*) &proj_mat);
IWineD3DDevice_GetTransform(lpDevice->wineD3DDevice,
D3DTRANSFORMSTATE_WORLD,
(WINED3DMATRIX*) &world_mat);
for (i = 0; i < count; i++) {
LPD3DPROCESSVERTICES ci = (LPD3DPROCESSVERTICES) instr;
TRACE(" Start : %d Dest : %d Count : %d\n",
ci->wStart, ci->wDest, ci->dwCount);
TRACE(" Flags : ");
if (TRACE_ON(d3d7)) {
if (ci->dwFlags & D3DPROCESSVERTICES_COPY)
TRACE("COPY ");
if (ci->dwFlags & D3DPROCESSVERTICES_NOCOLOR)
TRACE("NOCOLOR ");
if (ci->dwFlags == D3DPROCESSVERTICES_OPMASK)
TRACE("OPMASK ");
if (ci->dwFlags & D3DPROCESSVERTICES_TRANSFORM)
TRACE("TRANSFORM ");
if (ci->dwFlags == D3DPROCESSVERTICES_TRANSFORMLIGHT)
TRACE("TRANSFORMLIGHT ");
if (ci->dwFlags & D3DPROCESSVERTICES_UPDATEEXTENTS)
TRACE("UPDATEEXTENTS ");
TRACE("\n");
}
/* This is where doing Direct3D on top on OpenGL is quite difficult.
This method transforms a set of vertices using the CURRENT state
(lighting, projection, ...) but does not rasterize them.
They will only be put on screen later (with the POINT / LINE and
TRIANGLE op-codes). The problem is that you can have a triangle
with each point having been transformed using another state...
In this implementation, I will emulate only ONE thing : each
vertex can have its own "WORLD" transformation (this is used in the
TWIST.EXE demo of the 5.2 SDK). I suppose that all vertices of the
execute buffer use the same state.
If I find applications that change other states, I will try to do a
more 'fine-tuned' state emulation (but I may become quite tricky if
it changes a light position in the middle of a triangle).
In this case, a 'direct' approach (i.e. without using OpenGL, but
writing our own 3D rasterizer) would be easier. */
/* The current method (with the hypothesis that only the WORLD matrix
will change between two points) is like this :
- I transform 'manually' all the vertices with the current WORLD
matrix and store them in the vertex buffer
- during the rasterization phase, the WORLD matrix will be set to
the Identity matrix */
/* Enough for the moment */
if (ci->dwFlags == D3DPROCESSVERTICES_TRANSFORMLIGHT) {
unsigned int nb;
D3DVERTEX *src = ((LPD3DVERTEX) ((char *)This->desc.lpData + vs)) + ci->wStart;
D3DTLVERTEX *dst = ((LPD3DTLVERTEX) (This->vertex_data)) + ci->wDest;
D3DMATRIX *mat2 = &world_mat;
D3DMATRIX mat;
D3DVALUE nx,ny,nz;
D3DVIEWPORT* Viewport = &lpViewport->viewports.vp1;
if (TRACE_ON(d3d7)) {
TRACE(" Projection Matrix : (%p)\n", &proj_mat);
dump_D3DMATRIX(&proj_mat);
TRACE(" View Matrix : (%p)\n", &view_mat);
dump_D3DMATRIX(&view_mat);
TRACE(" World Matrix : (%p)\n", &world_mat);
dump_D3DMATRIX(&world_mat);
}
multiply_matrix(&mat,&view_mat,&world_mat);
multiply_matrix(&mat,&proj_mat,&mat);
for (nb = 0; nb < ci->dwCount; nb++) {
#ifndef WINE_NATIVEWIN32
/* Normals transformation */
nx = (src->u4.nx * mat2->_11) + (src->u5.ny * mat2->_21) + (src->u6.nz * mat2->_31);
ny = (src->u4.nx * mat2->_12) + (src->u5.ny * mat2->_22) + (src->u6.nz * mat2->_32);
nz = (src->u4.nx * mat2->_13) + (src->u5.ny * mat2->_23) + (src->u6.nz * mat2->_33);
/* No lighting yet */
dst->u5.color = 0xFFFFFFFF; /* Opaque white */
dst->u6.specular = 0xFF000000; /* No specular and no fog factor */
dst->u7.tu = src->u7.tu;
dst->u8.tv = src->u8.tv;
/* Now, the matrix multiplication */
dst->u1.sx = (src->u1.x * mat._11) + (src->u2.y * mat._21) + (src->u3.z * mat._31) + (1.0 * mat._41);
dst->u2.sy = (src->u1.x * mat._12) + (src->u2.y * mat._22) + (src->u3.z * mat._32) + (1.0 * mat._42);
dst->u3.sz = (src->u1.x * mat._13) + (src->u2.y * mat._23) + (src->u3.z * mat._33) + (1.0 * mat._43);
dst->u4.rhw = (src->u1.x * mat._14) + (src->u2.y * mat._24) + (src->u3.z * mat._34) + (1.0 * mat._44);
dst->u1.sx = dst->u1.sx / dst->u4.rhw * Viewport->dwWidth / 2
+ Viewport->dwX + Viewport->dwWidth / 2;
dst->u2.sy = dst->u2.sy / dst->u4.rhw * Viewport->dwHeight / 2
+ Viewport->dwY + Viewport->dwHeight / 2;
dst->u3.sz /= dst->u4.rhw;
dst->u4.rhw = 1 / dst->u4.rhw;
#else
/* Normals transformation */
nx = (src->nx * mat2->_11) + (src->ny * mat2->_21) + (src->nz * mat2->_31);
ny = (src->nx * mat2->_12) + (src->ny * mat2->_22) + (src->nz * mat2->_32);
nz = (src->nx * mat2->_13) + (src->ny * mat2->_23) + (src->nz * mat2->_33);
/* No lighting yet */
dst->color = 0xFFFFFFFF; /* Opaque white */
dst->specular = 0xFF000000; /* No specular and no fog factor */
dst->tu = src->tu;
dst->tv = src->tv;
/* Now, the matrix multiplication */
dst->sx = (src->x * mat._11) + (src->y * mat._21) + (src->z * mat._31) + (1.0 * mat._41);
dst->sy = (src->x * mat._12) + (src->y * mat._22) + (src->z * mat._32) + (1.0 * mat._42);
dst->sz = (src->x * mat._13) + (src->y * mat._23) + (src->z * mat._33) + (1.0 * mat._43);
dst->rhw = (src->x * mat._14) + (src->y * mat._24) + (src->z * mat._34) + (1.0 * mat._44);
dst->sx = dst->sx / dst->rhw * Viewport->dwWidth / 2
+ Viewport->dwX + Viewport->dwWidth / 2;
dst->sy = dst->sy / dst->rhw * Viewport->dwHeight / 2
+ Viewport->dwY + Viewport->dwHeight / 2;
dst->sz /= dst->rhw;
dst->rhw = 1 / dst->rhw;
#endif
src++;
dst++;
}
} else if (ci->dwFlags == D3DPROCESSVERTICES_TRANSFORM) {
unsigned int nb;
D3DLVERTEX *src = ((LPD3DLVERTEX) ((char *)This->desc.lpData + vs)) + ci->wStart;
D3DTLVERTEX *dst = ((LPD3DTLVERTEX) (This->vertex_data)) + ci->wDest;
D3DMATRIX mat;
D3DVIEWPORT* Viewport = &lpViewport->viewports.vp1;
if (TRACE_ON(d3d7)) {
TRACE(" Projection Matrix : (%p)\n", &proj_mat);
dump_D3DMATRIX(&proj_mat);
TRACE(" View Matrix : (%p)\n",&view_mat);
dump_D3DMATRIX(&view_mat);
TRACE(" World Matrix : (%p)\n", &mat);
dump_D3DMATRIX(&mat);
}
multiply_matrix(&mat,&view_mat,&world_mat);
multiply_matrix(&mat,&proj_mat,&mat);
for (nb = 0; nb < ci->dwCount; nb++) {
#ifndef WINE_NATIVEWIN32
dst->u5.color = src->u4.color;
dst->u6.specular = src->u5.specular;
dst->u7.tu = src->u6.tu;
dst->u8.tv = src->u7.tv;
/* Now, the matrix multiplication */
dst->u1.sx = (src->u1.x * mat._11) + (src->u2.y * mat._21) + (src->u3.z * mat._31) + (1.0 * mat._41);
dst->u2.sy = (src->u1.x * mat._12) + (src->u2.y * mat._22) + (src->u3.z * mat._32) + (1.0 * mat._42);
dst->u3.sz = (src->u1.x * mat._13) + (src->u2.y * mat._23) + (src->u3.z * mat._33) + (1.0 * mat._43);
dst->u4.rhw = (src->u1.x * mat._14) + (src->u2.y * mat._24) + (src->u3.z * mat._34) + (1.0 * mat._44);
dst->u1.sx /= dst->u4.rhw * Viewport->dvScaleX * Viewport->dwWidth / 2 + Viewport->dwX;
dst->u2.sy /= dst->u4.rhw * Viewport->dvScaleY * Viewport->dwHeight / 2 + Viewport->dwY;
dst->u3.sz /= dst->u4.rhw;
dst->u4.rhw = 1 / dst->u4.rhw;
#else
dst->color = src->color;
dst->specular = src->specular;
dst->tu = src->tu;
dst->tv = src->tv;
/* Now, the matrix multiplication */
dst->sx = (src->x * mat._11) + (src->y * mat._21) + (src->z * mat._31) + (1.0 * mat._41);
dst->sy = (src->x * mat._12) + (src->y * mat._22) + (src->z * mat._32) + (1.0 * mat._42);
dst->sz = (src->x * mat._13) + (src->y * mat._23) + (src->z * mat._33) + (1.0 * mat._43);
dst->rhw = (src->x * mat._14) + (src->y * mat._24) + (src->z * mat._34) + (1.0 * mat._44);
dst->sx /= dst->rhw * Viewport->dvScaleX * Viewport->dwWidth / 2 + Viewport->dwX;
dst->sy /= dst->rhw * Viewport->dvScaleY * Viewport->dwHeight / 2 + Viewport->dwY;
dst->sz /= dst->rhw;
dst->rhw = 1 / dst->rhw;
#endif
src++;
dst++;
}
} else if (ci->dwFlags == D3DPROCESSVERTICES_COPY) {
D3DTLVERTEX *src = ((LPD3DTLVERTEX) ((char *)This->desc.lpData + vs)) + ci->wStart;
D3DTLVERTEX *dst = ((LPD3DTLVERTEX) (This->vertex_data)) + ci->wDest;
memcpy(dst, src, ci->dwCount * sizeof(D3DTLVERTEX));
} else {
ERR("Unhandled vertex processing !\n");
}
instr += size;
}
} break;
case D3DOP_TEXTURELOAD: {
WARN("TEXTURELOAD-s (%d)\n", count);
instr += count * size;
} break;
case D3DOP_EXIT: {
TRACE("EXIT (%d)\n", count);
/* We did this instruction */
instr += size;
/* Exit this loop */
goto end_of_buffer;
} break;
case D3DOP_BRANCHFORWARD: {
int i;
TRACE("BRANCHFORWARD (%d)\n", count);
for (i = 0; i < count; i++) {
LPD3DBRANCH ci = (LPD3DBRANCH) instr;
if ((This->data.dsStatus.dwStatus & ci->dwMask) == ci->dwValue) {
if (!ci->bNegate) {
TRACE(" Branch to %d\n", ci->dwOffset);
instr = (char*)current + ci->dwOffset;
break;
}
} else {
if (ci->bNegate) {
TRACE(" Branch to %d\n", ci->dwOffset);
instr = (char*)current + ci->dwOffset;
break;
}
}
instr += size;
}
} break;
case D3DOP_SPAN: {
WARN("SPAN-s (%d)\n", count);
instr += count * size;
} break;
case D3DOP_SETSTATUS: {
int i;
TRACE("SETSTATUS (%d)\n", count);
for (i = 0; i < count; i++) {
LPD3DSTATUS ci = (LPD3DSTATUS) instr;
This->data.dsStatus = *ci;
instr += size;
}
} break;
default:
ERR("Unhandled OpCode %d !!!\n",current->bOpcode);
/* Try to save ... */
instr += count * size;
break;
}
}
end_of_buffer:
;
}
/*****************************************************************************
* IDirect3DExecuteBuffer::QueryInterface
*
* Well, a usual QueryInterface function. Don't know fur sure which
* interfaces it can Query.
*
* Params:
* riid: The interface ID queried for
* obj: Address to return the interface pointer at
*
* Returns:
* D3D_OK in case of a success (S_OK? Think it's the same)
* OLE_E_ENUM_NOMORE if the interface wasn't found.
* (E_NOINTERFACE?? Don't know what I really need)
*
*****************************************************************************/
static HRESULT WINAPI
IDirect3DExecuteBufferImpl_QueryInterface(IDirect3DExecuteBuffer *iface,
REFIID riid,
void **obj)
{
ICOM_THIS_FROM(IDirect3DExecuteBufferImpl, IDirect3DExecuteBuffer, iface);
TRACE("(%p/%p)->(%s,%p)\n", This, iface, debugstr_guid(riid), obj);
*obj = NULL;
if ( IsEqualGUID( &IID_IUnknown, riid ) ) {
IDirect3DExecuteBuffer_AddRef(ICOM_INTERFACE(This, IDirect3DExecuteBuffer));
*obj = iface;
TRACE(" Creating IUnknown interface at %p.\n", *obj);
return S_OK;
}
if ( IsEqualGUID( &IID_IDirect3DMaterial, riid ) ) {
IDirect3DExecuteBuffer_AddRef(ICOM_INTERFACE(This, IDirect3DExecuteBuffer));
*obj = ICOM_INTERFACE(This, IDirect3DExecuteBuffer);
TRACE(" Creating IDirect3DExecuteBuffer interface %p\n", *obj);
return S_OK;
}
FIXME("(%p): interface for IID %s NOT found!\n", This, debugstr_guid(riid));
return E_NOINTERFACE;
}
/*****************************************************************************
* IDirect3DExecuteBuffer::AddRef
*
* A normal AddRef method, nothing special
*
* Returns:
* The new refcount
*
*****************************************************************************/
static ULONG WINAPI
IDirect3DExecuteBufferImpl_AddRef(IDirect3DExecuteBuffer *iface)
{
ICOM_THIS_FROM(IDirect3DExecuteBufferImpl, IDirect3DExecuteBuffer, iface);
ULONG ref = InterlockedIncrement(&This->ref);
FIXME("(%p)->()incrementing from %u.\n", This, ref - 1);
return ref;
}
/*****************************************************************************
* IDirect3DExecuteBuffer::Release
*
* A normal Release method, nothing special
*
* Returns:
* The new refcount
*
*****************************************************************************/
static ULONG WINAPI
IDirect3DExecuteBufferImpl_Release(IDirect3DExecuteBuffer *iface)
{
ICOM_THIS_FROM(IDirect3DExecuteBufferImpl, IDirect3DExecuteBuffer, iface);
ULONG ref = InterlockedDecrement(&This->ref);
TRACE("(%p)->()decrementing from %u.\n", This, ref + 1);
if (!ref) {
if (This->need_free)
HeapFree(GetProcessHeap(),0,This->desc.lpData);
HeapFree(GetProcessHeap(),0,This->vertex_data);
HeapFree(GetProcessHeap(),0,This->indices);
HeapFree(GetProcessHeap(),0,This);
return 0;
}
return ref;
}
/*****************************************************************************
* IDirect3DExecuteBuffer::Initialize
*
* Initializes the Execute Buffer. This method exists for COM compliance
* Nothing to do here.
*
* Returns:
* D3D_OK
*
*****************************************************************************/
static HRESULT WINAPI
IDirect3DExecuteBufferImpl_Initialize(IDirect3DExecuteBuffer *iface,
IDirect3DDevice *lpDirect3DDevice,
D3DEXECUTEBUFFERDESC *lpDesc)
{
ICOM_THIS_FROM(IDirect3DExecuteBufferImpl, IDirect3DExecuteBuffer, iface);
TRACE("(%p)->(%p,%p) no-op....\n", This, lpDirect3DDevice, lpDesc);
return D3D_OK;
}
/*****************************************************************************
* IDirect3DExecuteBuffer::Lock
*
* Locks the buffer, so the app can write into it.
*
* Params:
* Desc: Pointer to return the buffer description. This Description contains
* a pointer to the buffer data.
*
* Returns:
* This implementation always returns D3D_OK
*
*****************************************************************************/
static HRESULT WINAPI
IDirect3DExecuteBufferImpl_Lock(IDirect3DExecuteBuffer *iface,
D3DEXECUTEBUFFERDESC *lpDesc)
{
ICOM_THIS_FROM(IDirect3DExecuteBufferImpl, IDirect3DExecuteBuffer, iface);
DWORD dwSize;
TRACE("(%p)->(%p)\n", This, lpDesc);
dwSize = lpDesc->dwSize;
memset(lpDesc, 0, dwSize);
memcpy(lpDesc, &This->desc, dwSize);
if (TRACE_ON(d3d7)) {
TRACE(" Returning description :\n");
_dump_D3DEXECUTEBUFFERDESC(lpDesc);
}
return D3D_OK;
}
/*****************************************************************************
* IDirect3DExecuteBuffer::Unlock
*
* Unlocks the buffer. We don't have anything to do here
*
* Returns:
* This implementation always returns D3D_OK
*
*****************************************************************************/
static HRESULT WINAPI
IDirect3DExecuteBufferImpl_Unlock(IDirect3DExecuteBuffer *iface)
{
ICOM_THIS_FROM(IDirect3DExecuteBufferImpl, IDirect3DExecuteBuffer, iface);
TRACE("(%p)->() no-op...\n", This);
return D3D_OK;
}
/*****************************************************************************
* IDirect3DExecuteBuffer::SetExecuteData
*
* Sets the execute data. This data is used to describe the buffer's content
*
* Params:
* Data: Pointer to a D3DEXECUTEDATA structure containing the data to
* assign
*
* Returns:
* D3D_OK on success
* DDERR_OUTOFMEMORY if the vertex buffer allocation failed
*
*****************************************************************************/
static HRESULT WINAPI
IDirect3DExecuteBufferImpl_SetExecuteData(IDirect3DExecuteBuffer *iface,
D3DEXECUTEDATA *lpData)
{
ICOM_THIS_FROM(IDirect3DExecuteBufferImpl, IDirect3DExecuteBuffer, iface);
DWORD nbvert;
TRACE("(%p)->(%p)\n", This, lpData);
memcpy(&This->data, lpData, lpData->dwSize);
/* Get the number of vertices in the execute buffer */
nbvert = This->data.dwVertexCount;
/* Prepares the transformed vertex buffer */
HeapFree(GetProcessHeap(), 0, This->vertex_data);
This->vertex_data = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, nbvert * sizeof(D3DTLVERTEX));
if (TRACE_ON(d3d7)) {
_dump_executedata(lpData);
}
return D3D_OK;
}
/*****************************************************************************
* IDirect3DExecuteBuffer::GetExecuteData
*
* Returns the data in the execute buffer
*
* Params:
* Data: Pointer to a D3DEXECUTEDATA structure used to return data
*
* Returns:
* D3D_OK on success
*
*****************************************************************************/
static HRESULT WINAPI
IDirect3DExecuteBufferImpl_GetExecuteData(IDirect3DExecuteBuffer *iface,
D3DEXECUTEDATA *lpData)
{
ICOM_THIS_FROM(IDirect3DExecuteBufferImpl, IDirect3DExecuteBuffer, iface);
DWORD dwSize;
TRACE("(%p)->(%p): stub!\n", This, lpData);
dwSize = lpData->dwSize;
memset(lpData, 0, dwSize);
memcpy(lpData, &This->data, dwSize);
if (TRACE_ON(d3d7)) {
TRACE("Returning data :\n");
_dump_executedata(lpData);
}
return DD_OK;
}
/*****************************************************************************
* IDirect3DExecuteBuffer::Validate
*
* DirectX 5 SDK: "The IDirect3DExecuteBuffer::Validate method is not
* currently implemented"
*
* Params:
* ?
*
* Returns:
* DDERR_UNSUPPORTED, because it's not implemented in Windows.
*
*****************************************************************************/
static HRESULT WINAPI
IDirect3DExecuteBufferImpl_Validate(IDirect3DExecuteBuffer *iface,
DWORD *Offset,
LPD3DVALIDATECALLBACK Func,
void *UserArg,
DWORD Reserved)
{
ICOM_THIS_FROM(IDirect3DExecuteBufferImpl, IDirect3DExecuteBuffer, iface);
TRACE("(%p)->(%p,%p,%p,%08x): Unimplemented!\n", This, Offset, Func, UserArg, Reserved);
return DDERR_UNSUPPORTED; /* Unchecked */
}
/*****************************************************************************
* IDirect3DExecuteBuffer::Optimize
*
* DirectX5 SDK: "The IDirect3DExecuteBuffer::Optimize method is not
* currently supported"
*
* Params:
* Dummy: Seems to be an unused dummy ;)
*
* Returns:
* DDERR_UNSUPPORTED, because it's not implemented in Windows.
*
*****************************************************************************/
static HRESULT WINAPI
IDirect3DExecuteBufferImpl_Optimize(IDirect3DExecuteBuffer *iface,
DWORD Dummy)
{
ICOM_THIS_FROM(IDirect3DExecuteBufferImpl, IDirect3DExecuteBuffer, iface);
TRACE("(%p)->(%08x): Unimplemented\n", This, Dummy);
return DDERR_UNSUPPORTED; /* Unchecked */
}
const IDirect3DExecuteBufferVtbl IDirect3DExecuteBuffer_Vtbl =
{
IDirect3DExecuteBufferImpl_QueryInterface,
IDirect3DExecuteBufferImpl_AddRef,
IDirect3DExecuteBufferImpl_Release,
IDirect3DExecuteBufferImpl_Initialize,
IDirect3DExecuteBufferImpl_Lock,
IDirect3DExecuteBufferImpl_Unlock,
IDirect3DExecuteBufferImpl_SetExecuteData,
IDirect3DExecuteBufferImpl_GetExecuteData,
IDirect3DExecuteBufferImpl_Validate,
IDirect3DExecuteBufferImpl_Optimize,
};

View File

@@ -0,0 +1,215 @@
/* DirectDrawGammaControl implementation
*
* Copyright 2001 TransGaming Technologies Inc.
* Copyright 2006 Stefan D<>singer
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "config.h"
#include "wine/port.h"
#include <assert.h>
#include <stdarg.h>
#include <string.h>
#include <stdlib.h>
#define COBJMACROS
//#ifndef WINE_NATIVEWIN32
# include "windef.h"
# include "winbase.h"
# include "winnls.h"
# include "winerror.h"
# include "wingdi.h"
//#endif
#include "ddraw.h"
#include "d3d.h"
#include "ddraw_private.h"
#include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(ddraw);
WINE_DECLARE_DEBUG_CHANNEL(ddraw_thunk);
/**********************************************************
* IUnknown parts follow
**********************************************************/
/**********************************************************
* IDirectDrawGammaControl::QueryInterface
*
* QueryInterface, thunks to IDirectDrawSurface
*
* Params:
* riid: Interface id queried for
* obj: Returns the interface pointer
*
* Returns:
* S_OK or E_NOINTERFACE: See IDirectDrawSurface7::QueryInterface
*
**********************************************************/
static HRESULT WINAPI
IDirectDrawGammaControlImpl_QueryInterface(IDirectDrawGammaControl *iface, REFIID riid,
void **obj)
{
ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawGammaControl, iface);
TRACE_(ddraw_thunk)("(%p)->(%s,%p): Thunking to IDirectDrawSurface7\n", This, debugstr_guid(riid), obj);
return IDirectDrawSurface7_QueryInterface(ICOM_INTERFACE(This, IDirectDrawSurface7),
riid,
obj);
}
/**********************************************************
* IDirectDrawGammaControl::AddRef
*
* Addref, thunks to IDirectDrawSurface
*
* Returns:
* The new refcount
*
**********************************************************/
static ULONG WINAPI
IDirectDrawGammaControlImpl_AddRef(IDirectDrawGammaControl *iface)
{
ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawGammaControl, iface);
TRACE_(ddraw_thunk)("(%p)->() Thunking to IDirectDrawSurface7\n", This);
return IDirectDrawSurface7_AddRef(ICOM_INTERFACE(This, IDirectDrawSurface7));
}
/**********************************************************
* IDirectDrawGammaControl::Release
*
* Release, thunks to IDirectDrawSurface
*
* Returns:
* The new refcount
*
**********************************************************/
static ULONG WINAPI
IDirectDrawGammaControlImpl_Release(IDirectDrawGammaControl *iface)
{
ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawGammaControl, iface);
TRACE_(ddraw_thunk)("(%p)->() Thunking to IDirectDrawSurface7\n", This);
return IDirectDrawSurface7_Release(ICOM_INTERFACE(This, IDirectDrawSurface7));
}
/**********************************************************
* IDirectDrawGammaControl
**********************************************************/
/**********************************************************
* IDirectDrawGammaControl::GetGammaRamp
*
* Returns the current gamma ramp for a surface
*
* Params:
* Flags: Ignored
* GammaRamp: Address to write the ramp to
*
* Returns:
* DD_OK on success
* DDERR_INVALIDPARAMS if GammaRamp is NULL
*
**********************************************************/
static HRESULT WINAPI
IDirectDrawGammaControlImpl_GetGammaRamp(IDirectDrawGammaControl *iface,
DWORD Flags,
DDGAMMARAMP *GammaRamp)
{
ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawGammaControl, iface);
TRACE("(%p)->(%08x,%p)\n", This,Flags,GammaRamp);
/* This looks sane */
if(!GammaRamp)
{
ERR("(%p) GammaRamp is NULL, returning DDERR_INVALIDPARAMS\n", This);
return DDERR_INVALIDPARAMS;
}
if(This->surface_desc.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE)
{
/* Note: DDGAMMARAMP is compatible with WINED3DGAMMARAMP */
IWineD3DDevice_GetGammaRamp(This->ddraw->wineD3DDevice,
0 /* Swapchain */,
(WINED3DGAMMARAMP *) GammaRamp);
}
else
{
ERR("(%p) Unimplemented for non-primary surfaces\n", This);
}
return DD_OK;
}
/**********************************************************
* IDirectDrawGammaControl::SetGammaRamp
*
* Sets the red, green and blue gamma ramps for
*
* Params:
* Flags: Can be DDSGR_CALIBRATE to request calibration
* GammaRamp: Structure containing the new gamma ramp
*
* Returns:
* DD_OK on success
* DDERR_INVALIDPARAMS if GammaRamp is NULL
*
**********************************************************/
static HRESULT WINAPI
IDirectDrawGammaControlImpl_SetGammaRamp(IDirectDrawGammaControl *iface,
DWORD Flags,
DDGAMMARAMP *GammaRamp)
{
ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawGammaControl, iface);
TRACE("(%p)->(%08x,%p)\n", This,Flags,GammaRamp);
/* This looks sane */
if(!GammaRamp)
{
ERR("(%p) GammaRamp is NULL, returning DDERR_INVALIDPARAMS\n", This);
return DDERR_INVALIDPARAMS;
}
if(This->surface_desc.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE)
{
/* Note: DDGAMMARAMP is compatible with WINED3DGAMMARAMP */
IWineD3DDevice_SetGammaRamp(This->ddraw->wineD3DDevice,
0 /* Swapchain */,
Flags,
(WINED3DGAMMARAMP *) GammaRamp);
}
else
{
ERR("(%p) Unimplemented for non-primary surfaces\n", This);
}
return DD_OK;
}
const IDirectDrawGammaControlVtbl IDirectDrawGammaControl_Vtbl =
{
IDirectDrawGammaControlImpl_QueryInterface,
IDirectDrawGammaControlImpl_AddRef,
IDirectDrawGammaControlImpl_Release,
IDirectDrawGammaControlImpl_GetGammaRamp,
IDirectDrawGammaControlImpl_SetGammaRamp
};

View File

@@ -0,0 +1,317 @@
/* Direct3D Light
* Copyright (c) 1998 / 2002 Lionel ULMER
* Copyright (c) 2006 Stefan D<>SINGER
*
* This file contains the implementation of Direct3DLight.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "config.h"
#include "wine/port.h"
#include <assert.h>
#include <stdarg.h>
#include <string.h>
#include <stdlib.h>
#define COBJMACROS
//#ifndef WINE_NATIVEWIN32
# include "windef.h"
# include "winbase.h"
# include "winnls.h"
# include "winerror.h"
# include "wingdi.h"
//#endif
#include "ddraw.h"
#include "d3d.h"
#include "ddraw_private.h"
#include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(d3d7);
/*****************************************************************************
* IUnknown Methods.
*****************************************************************************/
/*****************************************************************************
* IDirect3DLight::QueryInterface
*
* Queries the object for different interfaces. Unimplemented for this
* object at the moment
*
* Params:
* riid: Interface id asked for
* obj: Address to return the resulting pointer at.
*
* Returns:
* E_NOINTERFACE, because it's a stub
*****************************************************************************/
static HRESULT WINAPI
IDirect3DLightImpl_QueryInterface(IDirect3DLight *iface,
REFIID riid,
void **obp)
{
ICOM_THIS_FROM(IDirect3DLightImpl, IDirect3DLight, iface);
FIXME("(%p)->(%s,%p): stub!\n", This, debugstr_guid(riid), obp);
*obp = NULL;
return E_NOINTERFACE;
}
/*****************************************************************************
* IDirect3DLight::AddRef
*
* Increases the refcount by 1
*
* Returns:
* The new refcount
*
*****************************************************************************/
static ULONG WINAPI
IDirect3DLightImpl_AddRef(IDirect3DLight *iface)
{
ICOM_THIS_FROM(IDirect3DLightImpl, IDirect3DLight, iface);
ULONG ref = InterlockedIncrement(&This->ref);
TRACE("(%p)->() incrementing from %u.\n", This, ref - 1);
return ref;
}
/*****************************************************************************
* IDirect3DLight::Release
*
* Reduces the refcount by one. If the refcount falls to 0, the object
* is destroyed
*
* Returns:
* The new refcount
*
*****************************************************************************/
static ULONG WINAPI
IDirect3DLightImpl_Release(IDirect3DLight *iface)
{
ICOM_THIS_FROM(IDirect3DLightImpl, IDirect3DLight, iface);
ULONG ref = InterlockedDecrement(&This->ref);
TRACE("(%p)->() decrementing from %u.\n", This, ref + 1);
if (!ref) {
HeapFree(GetProcessHeap(), 0, This);
return 0;
}
return ref;
}
/*****************************************************************************
* IDirect3DLight Methods.
*****************************************************************************/
/*****************************************************************************
* IDirect3DLight::Initialize
*
* Initializes the interface. This implementation is a no-op, because
* initialization takes place at creation time
*
* Params:
* Direct3D: Pointer to an IDirect3D interface.
*
* Returns:
* D3D_OK
*
*****************************************************************************/
static HRESULT WINAPI
IDirect3DLightImpl_Initialize(IDirect3DLight *iface,
IDirect3D *lpDirect3D)
{
ICOM_THIS_FROM(IDirect3DLightImpl, IDirect3DLight, iface);
IDirectDrawImpl *d3d = ICOM_OBJECT(IDirectDrawImpl, IDirect3D, lpDirect3D);
TRACE("(%p)->(%p) no-op...\n", This, d3d);
return D3D_OK;
}
/*****************************************************************************
* IDirect3DLight::SetLight
*
* Assigns a lighting value to this object
*
* Params:
* Light: Lighting parametes to set
*
* Returns:
* D3D_OK on success
* DDERR_INVALIDPARAMS if Light is NULL
*
*****************************************************************************/
static void dump_light(const D3DLIGHT2 *light)
{
DPRINTF(" - dwSize : %d\n", light->dwSize);
}
static const float zero_value[] = {
0.0, 0.0, 0.0, 0.0
};
static HRESULT WINAPI
IDirect3DLightImpl_SetLight(IDirect3DLight *iface,
D3DLIGHT *lpLight)
{
ICOM_THIS_FROM(IDirect3DLightImpl, IDirect3DLight, iface);
LPD3DLIGHT7 light7 = &(This->light7);
TRACE("(%p)->(%p)\n", This, lpLight);
if (TRACE_ON(d3d7)) {
TRACE(" Light definition :\n");
dump_light((LPD3DLIGHT2) lpLight);
}
if ( (lpLight->dltType == 0) || (lpLight->dltType > D3DLIGHT_PARALLELPOINT) )
return DDERR_INVALIDPARAMS;
if ( lpLight->dltType == D3DLIGHT_PARALLELPOINT )
FIXME("D3DLIGHT_PARALLELPOINT no supported\n");
/* Translate D3DLIGH2 structure to D3DLIGHT7 */
light7->dltType = lpLight->dltType;
light7->dcvDiffuse = lpLight->dcvColor;
if ((((LPD3DLIGHT2)lpLight)->dwFlags & D3DLIGHT_NO_SPECULAR) != 0)
light7->dcvSpecular = lpLight->dcvColor;
else
light7->dcvSpecular = *(const D3DCOLORVALUE*)zero_value;
light7->dcvAmbient = lpLight->dcvColor;
light7->dvPosition = lpLight->dvPosition;
light7->dvDirection = lpLight->dvDirection;
light7->dvRange = lpLight->dvRange;
light7->dvFalloff = lpLight->dvFalloff;
light7->dvAttenuation0 = lpLight->dvAttenuation0;
light7->dvAttenuation1 = lpLight->dvAttenuation1;
light7->dvAttenuation2 = lpLight->dvAttenuation2;
light7->dvTheta = lpLight->dvTheta;
light7->dvPhi = lpLight->dvPhi;
memcpy(&This->light, lpLight, lpLight->dwSize);
if ((This->light.dwFlags & D3DLIGHT_ACTIVE) != 0) {
This->update(This);
}
return D3D_OK;
}
/*****************************************************************************
* IDirect3DLight::GetLight
*
* Returns the parameters currently assigned to the IDirect3DLight object
*
* Params:
* Light: Pointer to an D3DLIGHT structure to store the parameters
*
* Returns:
* D3D_OK on success
* DDERR_INVALIDPARAMS if Light is NULL
*****************************************************************************/
static HRESULT WINAPI
IDirect3DLightImpl_GetLight(IDirect3DLight *iface,
D3DLIGHT *lpLight)
{
ICOM_THIS_FROM(IDirect3DLightImpl, IDirect3DLight, iface);
TRACE("(%p/%p)->(%p)\n", This, iface, lpLight);
if (TRACE_ON(d3d7)) {
TRACE(" Returning light definition :\n");
dump_light(&This->light);
}
memcpy(lpLight, &This->light, lpLight->dwSize);
return DD_OK;
}
/*****************************************************************************
* light_update
*
* Updates the Direct3DDevice7 lighting parameters
*
*****************************************************************************/
void light_update(IDirect3DLightImpl* This)
{
IDirect3DDeviceImpl* device;
TRACE("(%p)\n", This);
if (!This->active_viewport || !This->active_viewport->active_device)
return;
device = This->active_viewport->active_device;
IDirect3DDevice7_SetLight(ICOM_INTERFACE(device,IDirect3DDevice7), This->dwLightIndex, &(This->light7));
}
/*****************************************************************************
* light_activate
*
* Uses the Direct3DDevice7::LightEnable method to active the light
*
*****************************************************************************/
void light_activate(IDirect3DLightImpl* This)
{
IDirect3DDeviceImpl* device;
TRACE("(%p)\n", This);
if (!This->active_viewport || !This->active_viewport->active_device)
return;
device = This->active_viewport->active_device;
light_update(This);
/* If was not active, activate it */
if ((This->light.dwFlags & D3DLIGHT_ACTIVE) == 0) {
IDirect3DDevice7_LightEnable(ICOM_INTERFACE(device,IDirect3DDevice7), This->dwLightIndex, TRUE);
This->light.dwFlags |= D3DLIGHT_ACTIVE;
}
}
/*****************************************************************************
*
* light_desactivate
*
* Uses the Direct3DDevice7::LightEnable method to deactivate the light
*
*****************************************************************************/
void light_desactivate(IDirect3DLightImpl* This)
{
IDirect3DDeviceImpl* device;
TRACE("(%p)\n", This);
if (!This->active_viewport || !This->active_viewport->active_device)
return;
device = This->active_viewport->active_device;
/* If was not active, activate it */
if ((This->light.dwFlags & D3DLIGHT_ACTIVE) != 0) {
IDirect3DDevice7_LightEnable(ICOM_INTERFACE(device,IDirect3DDevice7), This->dwLightIndex, FALSE);
This->light.dwFlags &= ~D3DLIGHT_ACTIVE;
}
}
const IDirect3DLightVtbl IDirect3DLight_Vtbl =
{
/*** IUnknown Methods ***/
IDirect3DLightImpl_QueryInterface,
IDirect3DLightImpl_AddRef,
IDirect3DLightImpl_Release,
/*** IDirect3DLight Methods ***/
IDirect3DLightImpl_Initialize,
IDirect3DLightImpl_SetLight,
IDirect3DLightImpl_GetLight
};

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,511 @@
/* Direct3D Material
* Copyright (c) 2002 Lionel ULMER
* Copyright (c) 2006 Stefan D<>SINGER
*
* This file contains the implementation of Direct3DMaterial.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "config.h"
#include "wine/port.h"
#include <assert.h>
#include <stdarg.h>
#include <string.h>
#include <stdlib.h>
#define COBJMACROS
#define NONAMELESSUNION
//#ifndef WINE_NATIVEWIN32
# include "windef.h"
# include "winbase.h"
# include "winnls.h"
# include "winerror.h"
# include "wingdi.h"
//#endif
#include "ddraw.h"
#include "d3d.h"
#include "ddraw_private.h"
#include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(d3d7);
WINE_DECLARE_DEBUG_CHANNEL(ddraw_thunk);
static void dump_material(const D3DMATERIAL *mat)
{
DPRINTF(" dwSize : %d\n", mat->dwSize);
}
/*****************************************************************************
* IUnknown Methods.
*****************************************************************************/
/*****************************************************************************
* IDirect3DMaterial3::QueryInterface
*
* QueryInterface for IDirect3DMaterial. Can query all IDirect3DMaterial
* versions.
*
* Params:
* riid: Interface id queried for
* obj: Address to pass the interface pointer back
*
* Returns:
* S_OK on success
* E_NOINTERFACE if the requested interface wasn't found
*
*****************************************************************************/
static HRESULT WINAPI
IDirect3DMaterialImpl_QueryInterface(IDirect3DMaterial3 *iface,
REFIID riid,
LPVOID* obp)
{
ICOM_THIS_FROM(IDirect3DMaterialImpl, IDirect3DMaterial3, iface);
TRACE("(%p)->(%s,%p)\n", This, debugstr_guid(riid), obp);
*obp = NULL;
if ( IsEqualGUID( &IID_IUnknown, riid ) ) {
IDirect3DMaterial_AddRef(ICOM_INTERFACE(This, IDirect3DMaterial));
*obp = iface;
TRACE(" Creating IUnknown interface at %p.\n", *obp);
return S_OK;
}
if ( IsEqualGUID( &IID_IDirect3DMaterial, riid ) ) {
IDirect3DMaterial_AddRef(ICOM_INTERFACE(This, IDirect3DMaterial));
*obp = ICOM_INTERFACE(This, IDirect3DMaterial);
TRACE(" Creating IDirect3DMaterial interface %p\n", *obp);
return S_OK;
}
if ( IsEqualGUID( &IID_IDirect3DMaterial2, riid ) ) {
IDirect3DMaterial_AddRef(ICOM_INTERFACE(This, IDirect3DMaterial));
*obp = ICOM_INTERFACE(This, IDirect3DMaterial2);
TRACE(" Creating IDirect3DMaterial2 interface %p\n", *obp);
return S_OK;
}
if ( IsEqualGUID( &IID_IDirect3DMaterial3, riid ) ) {
IDirect3DMaterial_AddRef(ICOM_INTERFACE(This, IDirect3DMaterial));
*obp = ICOM_INTERFACE(This, IDirect3DMaterial3);
TRACE(" Creating IDirect3DMaterial3 interface %p\n", *obp);
return S_OK;
}
FIXME("(%p): interface for IID %s NOT found!\n", This, debugstr_guid(riid));
return E_NOINTERFACE;
}
/*****************************************************************************
* IDirect3DMaterial3::AddRef
*
* Increases the refcount.
*
* Returns:
* The new refcount
*
*****************************************************************************/
static ULONG WINAPI
IDirect3DMaterialImpl_AddRef(IDirect3DMaterial3 *iface)
{
ICOM_THIS_FROM(IDirect3DMaterialImpl, IDirect3DMaterial3, iface);
ULONG ref = InterlockedIncrement(&This->ref);
TRACE("(%p)->() incrementing from %u.\n", This, ref - 1);
return ref;
}
/*****************************************************************************
* IDirect3DMaterial3::Release
*
* Reduces the refcount by one. If the refcount falls to 0, the object
* is destroyed
*
* Returns:
* The new refcount
*
*****************************************************************************/
static ULONG WINAPI
IDirect3DMaterialImpl_Release(IDirect3DMaterial3 *iface)
{
ICOM_THIS_FROM(IDirect3DMaterialImpl, IDirect3DMaterial3, iface);
ULONG ref = InterlockedDecrement(&This->ref);
TRACE("(%p)->() decrementing from %u.\n", This, ref + 1);
if (!ref)
{
if(This->Handle)
{
This->ddraw->d3ddevice->Handles[This->Handle - 1].ptr = NULL;
This->ddraw->d3ddevice->Handles[This->Handle - 1].type = DDrawHandle_Unknown;
}
HeapFree(GetProcessHeap(), 0, This);
return 0;
}
return ref;
}
/*****************************************************************************
* IDirect3DMaterial Methods
*****************************************************************************/
/*****************************************************************************
* IDirect3DMaterial::Initialize
*
* A no-op initialization
*
* Params:
* Direct3D: Pointer to a Direct3D interface
*
* Returns:
* D3D_OK
*
*****************************************************************************/
static HRESULT WINAPI
IDirect3DMaterialImpl_Initialize(IDirect3DMaterial *iface,
IDirect3D *Direct3D)
{
ICOM_THIS_FROM(IDirect3DMaterialImpl, IDirect3DMaterial, iface);
TRACE("(%p)->(%p) no-op...!\n", This, Direct3D);
return D3D_OK;
}
/*****************************************************************************
* IDirect3DMaterial::Reserve
*
* DirectX 5 sdk: "The IDirect3DMaterial2::Reserve method is not implemented"
* Odd. They seem to have mixed their interfaces.
*
* Returns:
* DDERR_UNSUPPORTED
*
*****************************************************************************/
static HRESULT WINAPI
IDirect3DMaterialImpl_Reserve(IDirect3DMaterial *iface)
{
ICOM_THIS_FROM(IDirect3DMaterialImpl, IDirect3DMaterial, iface);
TRACE("(%p)->() not implemented\n", This);
return DDERR_UNSUPPORTED;
}
/*****************************************************************************
* IDirect3DMaterial::Unreserve
*
* Not supported too
*
* Returns:
* DDERR_UNSUPPORTED
*
*****************************************************************************/
static HRESULT WINAPI
IDirect3DMaterialImpl_Unreserve(IDirect3DMaterial *iface)
{
ICOM_THIS_FROM(IDirect3DMaterialImpl, IDirect3DMaterial, iface);
TRACE("(%p)->() not implemented.\n", This);
return DDERR_UNSUPPORTED;
}
/*****************************************************************************
* IDirect3DMaterial3::SetMaterial
*
* Sets the material description
*
* Params:
* Mat: Material to set
*
* Returns:
* D3D_OK on success
* DDERR_INVALIDPARAMS if Mat is NULL
*
*****************************************************************************/
static HRESULT WINAPI
IDirect3DMaterialImpl_SetMaterial(IDirect3DMaterial3 *iface,
D3DMATERIAL *lpMat)
{
ICOM_THIS_FROM(IDirect3DMaterialImpl, IDirect3DMaterial3, iface);
TRACE("(%p)->(%p)\n", This, lpMat);
if (TRACE_ON(d3d7))
dump_material(lpMat);
/* Stores the material */
memset(&This->mat, 0, sizeof(This->mat));
memcpy(&This->mat, lpMat, lpMat->dwSize);
return DD_OK;
}
/*****************************************************************************
* IDirect3DMaterial3::GetMaterial
*
* Returns the material assigned to this interface
*
* Params:
* Mat: Pointer to a D3DMATERIAL structure to store the material description
*
* Returns:
* D3D_OK on success
* DDERR_INVALIDPARAMS if Mat is NULL
*
*****************************************************************************/
static HRESULT WINAPI
IDirect3DMaterialImpl_GetMaterial(IDirect3DMaterial3 *iface,
D3DMATERIAL *lpMat)
{
ICOM_THIS_FROM(IDirect3DMaterialImpl, IDirect3DMaterial3, iface);
DWORD dwSize;
TRACE("(%p)->(%p)\n", This, lpMat);
if (TRACE_ON(d3d7)) {
TRACE(" Returning material : ");
dump_material(&This->mat);
}
/* Copies the material structure */
dwSize = lpMat->dwSize;
memset(lpMat, 0, dwSize);
memcpy(lpMat, &This->mat, dwSize);
return DD_OK;
}
/*****************************************************************************
* IDirect3DMaterial3::GetHandle
*
* Returns a handle for the material interface. The handle is simply a
* pointer to the material implementation
*
* Params:
* Direct3DDevice3: The device this handle is assigned to
* Handle: Address to write the handle to
*
* Returns:
* D3D_OK on success
* DDERR_INVALIDPARAMS if Handle is NULL
*
*****************************************************************************/
static HRESULT WINAPI
IDirect3DMaterialImpl_GetHandle(IDirect3DMaterial3 *iface,
IDirect3DDevice3 *lpDirect3DDevice3,
D3DMATERIALHANDLE *lpHandle)
{
ICOM_THIS_FROM(IDirect3DMaterialImpl, IDirect3DMaterial3, iface);
IDirect3DDeviceImpl *device = ICOM_OBJECT(IDirect3DDeviceImpl, IDirect3DDevice3, lpDirect3DDevice3);
TRACE("(%p/%p)->(%p,%p)\n", This, iface, device, lpHandle);
This->active_device = device;
if(!This->Handle)
{
This->Handle = IDirect3DDeviceImpl_CreateHandle(device);
if(!This->Handle)
{
ERR("Error creating a handle\n");
return DDERR_INVALIDPARAMS; /* Unchecked */
}
device->Handles[This->Handle - 1].ptr = This;
device->Handles[This->Handle - 1].type = DDrawHandle_Material;
}
*lpHandle = This->Handle;
TRACE(" returning handle %08x.\n", *lpHandle);
return D3D_OK;
}
static HRESULT WINAPI
Thunk_IDirect3DMaterialImpl_2_GetHandle(LPDIRECT3DMATERIAL2 iface,
LPDIRECT3DDEVICE2 lpDirect3DDevice2,
LPD3DMATERIALHANDLE lpHandle)
{
TRACE_(ddraw_thunk)("(%p)->(%p,%p) thunking to IDirect3DMaterial3 interface.\n", iface, lpDirect3DDevice2, lpHandle);
return IDirect3DMaterial3_GetHandle(COM_INTERFACE_CAST(IDirect3DMaterialImpl, IDirect3DMaterial2, IDirect3DMaterial3, iface),
COM_INTERFACE_CAST(IDirect3DDeviceImpl, IDirect3DDevice2, IDirect3DDevice3, lpDirect3DDevice2),
lpHandle);
}
static HRESULT WINAPI
Thunk_IDirect3DMaterialImpl_1_GetHandle(LPDIRECT3DMATERIAL iface,
LPDIRECT3DDEVICE lpDirect3DDevice,
LPD3DMATERIALHANDLE lpHandle)
{
TRACE_(ddraw_thunk)("(%p)->(%p,%p) thunking to IDirect3DMaterial3 interface.\n", iface, lpDirect3DDevice, lpHandle);
return IDirect3DMaterial3_GetHandle(COM_INTERFACE_CAST(IDirect3DMaterialImpl, IDirect3DMaterial, IDirect3DMaterial3, iface),
COM_INTERFACE_CAST(IDirect3DDeviceImpl, IDirect3DDevice, IDirect3DDevice3, lpDirect3DDevice),
lpHandle);
}
static HRESULT WINAPI
Thunk_IDirect3DMaterialImpl_2_QueryInterface(LPDIRECT3DMATERIAL2 iface,
REFIID riid,
LPVOID* obp)
{
TRACE_(ddraw_thunk)("(%p)->(%s,%p) thunking to IDirect3DMaterial3 interface.\n", iface, debugstr_guid(riid), obp);
return IDirect3DMaterial3_QueryInterface(COM_INTERFACE_CAST(IDirect3DMaterialImpl, IDirect3DMaterial2, IDirect3DMaterial3, iface),
riid,
obp);
}
static HRESULT WINAPI
Thunk_IDirect3DMaterialImpl_1_QueryInterface(LPDIRECT3DMATERIAL iface,
REFIID riid,
LPVOID* obp)
{
TRACE_(ddraw_thunk)("(%p)->(%s,%p) thunking to IDirect3DMaterial3 interface.\n", iface, debugstr_guid(riid), obp);
return IDirect3DMaterial3_QueryInterface(COM_INTERFACE_CAST(IDirect3DMaterialImpl, IDirect3DMaterial, IDirect3DMaterial3, iface),
riid,
obp);
}
static ULONG WINAPI
Thunk_IDirect3DMaterialImpl_2_AddRef(LPDIRECT3DMATERIAL2 iface)
{
TRACE_(ddraw_thunk)("(%p)->() thunking to IDirect3DMaterial3 interface.\n", iface);
return IDirect3DMaterial3_AddRef(COM_INTERFACE_CAST(IDirect3DMaterialImpl, IDirect3DMaterial2, IDirect3DMaterial3, iface));
}
static ULONG WINAPI
Thunk_IDirect3DMaterialImpl_1_AddRef(LPDIRECT3DMATERIAL iface)
{
TRACE_(ddraw_thunk)("(%p)->() thunking to IDirect3DMaterial3 interface.\n", iface);
return IDirect3DMaterial3_AddRef(COM_INTERFACE_CAST(IDirect3DMaterialImpl, IDirect3DMaterial, IDirect3DMaterial3, iface));
}
static ULONG WINAPI
Thunk_IDirect3DMaterialImpl_2_Release(LPDIRECT3DMATERIAL2 iface)
{
TRACE_(ddraw_thunk)("(%p)->() thunking to IDirect3DMaterial3 interface.\n", iface);
return IDirect3DMaterial3_Release(COM_INTERFACE_CAST(IDirect3DMaterialImpl, IDirect3DMaterial2, IDirect3DMaterial3, iface));
}
static ULONG WINAPI
Thunk_IDirect3DMaterialImpl_1_Release(LPDIRECT3DMATERIAL iface)
{
TRACE_(ddraw_thunk)("(%p)->() thunking to IDirect3DMaterial3 interface.\n", iface);
return IDirect3DMaterial3_Release(COM_INTERFACE_CAST(IDirect3DMaterialImpl, IDirect3DMaterial, IDirect3DMaterial3, iface));
}
static HRESULT WINAPI
Thunk_IDirect3DMaterialImpl_2_SetMaterial(LPDIRECT3DMATERIAL2 iface,
LPD3DMATERIAL lpMat)
{
TRACE_(ddraw_thunk)("(%p)->(%p) thunking to IDirect3DMaterial3 interface.\n", iface, lpMat);
return IDirect3DMaterial3_SetMaterial(COM_INTERFACE_CAST(IDirect3DMaterialImpl, IDirect3DMaterial2, IDirect3DMaterial3, iface),
lpMat);
}
static HRESULT WINAPI
Thunk_IDirect3DMaterialImpl_1_SetMaterial(LPDIRECT3DMATERIAL iface,
LPD3DMATERIAL lpMat)
{
TRACE_(ddraw_thunk)("(%p)->(%p) thunking to IDirect3DMaterial3 interface.\n", iface, lpMat);
return IDirect3DMaterial3_SetMaterial(COM_INTERFACE_CAST(IDirect3DMaterialImpl, IDirect3DMaterial, IDirect3DMaterial3, iface),
lpMat);
}
static HRESULT WINAPI
Thunk_IDirect3DMaterialImpl_2_GetMaterial(LPDIRECT3DMATERIAL2 iface,
LPD3DMATERIAL lpMat)
{
TRACE_(ddraw_thunk)("(%p)->(%p) thunking to IDirect3DMaterial3 interface.\n", iface, lpMat);
return IDirect3DMaterial3_GetMaterial(COM_INTERFACE_CAST(IDirect3DMaterialImpl, IDirect3DMaterial2, IDirect3DMaterial3, iface),
lpMat);
}
static HRESULT WINAPI
Thunk_IDirect3DMaterialImpl_1_GetMaterial(LPDIRECT3DMATERIAL iface,
LPD3DMATERIAL lpMat)
{
TRACE_(ddraw_thunk)("(%p)->(%p) thunking to IDirect3DMaterial3 interface.\n", iface, lpMat);
return IDirect3DMaterial3_GetMaterial(COM_INTERFACE_CAST(IDirect3DMaterialImpl, IDirect3DMaterial, IDirect3DMaterial3, iface),
lpMat);
}
/*****************************************************************************
* material_activate
*
* Uses IDirect3DDevice7::SetMaterial to activate the material
*
* Params:
* This: Pointer to the material implementation to activate
*
*****************************************************************************/
void material_activate(IDirect3DMaterialImpl* This)
{
D3DMATERIAL7 d3d7mat;
TRACE("Activating material %p\n", This);
#ifndef WINE_NATIVEWIN32
d3d7mat.u.diffuse = This->mat.u.diffuse;
d3d7mat.u1.ambient = This->mat.u1.ambient;
d3d7mat.u2.specular = This->mat.u2.specular;
d3d7mat.u3.emissive = This->mat.u3.emissive;
d3d7mat.u4.power = This->mat.u4.power;
#else
d3d7mat.diffuse = This->mat.diffuse;
d3d7mat.ambient = This->mat.ambient;
d3d7mat.specular = This->mat.specular;
d3d7mat.emissive = This->mat.emissive;
d3d7mat.power = This->mat.power;
#endif
IDirect3DDevice7_SetMaterial(ICOM_INTERFACE(This->active_device, IDirect3DDevice7),
&d3d7mat);
}
const IDirect3DMaterial3Vtbl IDirect3DMaterial3_Vtbl =
{
/*** IUnknown Methods ***/
IDirect3DMaterialImpl_QueryInterface,
IDirect3DMaterialImpl_AddRef,
IDirect3DMaterialImpl_Release,
/*** IDirect3DMaterial3 Methods ***/
IDirect3DMaterialImpl_SetMaterial,
IDirect3DMaterialImpl_GetMaterial,
IDirect3DMaterialImpl_GetHandle,
};
const IDirect3DMaterial2Vtbl IDirect3DMaterial2_Vtbl =
{
/*** IUnknown Methods ***/
Thunk_IDirect3DMaterialImpl_2_QueryInterface,
Thunk_IDirect3DMaterialImpl_2_AddRef,
Thunk_IDirect3DMaterialImpl_2_Release,
/*** IDirect3DMaterial2 Methods ***/
Thunk_IDirect3DMaterialImpl_2_SetMaterial,
Thunk_IDirect3DMaterialImpl_2_GetMaterial,
Thunk_IDirect3DMaterialImpl_2_GetHandle,
};
const IDirect3DMaterialVtbl IDirect3DMaterial_Vtbl =
{
/*** IUnknown Methods ***/
Thunk_IDirect3DMaterialImpl_1_QueryInterface,
Thunk_IDirect3DMaterialImpl_1_AddRef,
Thunk_IDirect3DMaterialImpl_1_Release,
/*** IDirect3DMaterial1 Methods ***/
IDirect3DMaterialImpl_Initialize,
Thunk_IDirect3DMaterialImpl_1_SetMaterial,
Thunk_IDirect3DMaterialImpl_1_GetMaterial,
Thunk_IDirect3DMaterialImpl_1_GetHandle,
IDirect3DMaterialImpl_Reserve,
IDirect3DMaterialImpl_Unreserve
};

View File

@@ -0,0 +1,246 @@
/* DirectDraw - IDirectPalette base interface
*
* Copyright 2006 Stefan D<>singer
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "config.h"
#include "winerror.h"
#define COBJMACROS
#include <assert.h>
#include <string.h>
#include "ddraw_private.h"
#include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(ddraw);
/*****************************************************************************
* IDirectDrawPalette::QueryInterface
*
* A usual QueryInterface implementation. Can only Query IUnknown and
* IDirectDrawPalette
*
* Params:
* refiid: The interface id queried for
* obj: Address to return the interface pointer at
*
* Returns:
* S_OK on success
* E_NOINTERFACE if the requested interface wasn't found
*****************************************************************************/
static HRESULT WINAPI
IDirectDrawPaletteImpl_QueryInterface(IDirectDrawPalette *iface,
REFIID refiid,
void **obj)
{
ICOM_THIS_FROM(IDirectDrawPaletteImpl, IDirectDrawPalette, iface);
TRACE("(%p)->(%s,%p)\n",This,debugstr_guid(refiid),obj);
if (IsEqualGUID(refiid, &IID_IUnknown)
|| IsEqualGUID(refiid, &IID_IDirectDrawPalette))
{
*obj = iface;
IDirectDrawPalette_AddRef(iface);
return S_OK;
}
else
{
*obj = NULL;
return E_NOINTERFACE;
}
}
/*****************************************************************************
* IDirectDrawPaletteImpl::AddRef
*
* Increases the refcount.
*
* Returns:
* The new refcount
*
*****************************************************************************/
static ULONG WINAPI
IDirectDrawPaletteImpl_AddRef(IDirectDrawPalette *iface)
{
ICOM_THIS_FROM(IDirectDrawPaletteImpl, IDirectDrawPalette, iface);
ULONG ref = InterlockedIncrement(&This->ref);
TRACE("(%p)->() incrementing from %u.\n", This, ref - 1);
return ref;
}
/*****************************************************************************
* IDirectDrawPaletteImpl::Release
*
* Reduces the refcount. If the refcount falls to 0, the object is destroyed
*
* Returns:
* The new refcount
*
*****************************************************************************/
static ULONG WINAPI
IDirectDrawPaletteImpl_Release(IDirectDrawPalette *iface)
{
ICOM_THIS_FROM(IDirectDrawPaletteImpl, IDirectDrawPalette, iface);
ULONG ref = InterlockedDecrement(&This->ref);
TRACE("(%p)->() decrementing from %u.\n", This, ref + 1);
if (ref == 0)
{
IWineD3DPalette_Release(This->wineD3DPalette);
if(This->ifaceToRelease)
{
IUnknown_Release(This->ifaceToRelease);
}
HeapFree(GetProcessHeap(), 0, This);
}
return ref;
}
/*****************************************************************************
* IDirectDrawPalette::Initialize
*
* Initializes the palette. As we start initialized, return
* DDERR_ALREADYINITIALIZED
*
* Params:
* DD: DirectDraw interface this palette is asigned to
* Flags: Some flags, as usual
* ColorTable: The startup color table
*
* Returns:
* DDERR_ALREADYINITIALIZED
*
*****************************************************************************/
static HRESULT WINAPI
IDirectDrawPaletteImpl_Initialize(IDirectDrawPalette *iface,
IDirectDraw *DD,
DWORD Flags,
PALETTEENTRY *ColorTable)
{
TRACE("(%p)->(%p,%x,%p)\n", iface, DD, Flags, ColorTable);
return DDERR_ALREADYINITIALIZED;
}
/*****************************************************************************
* IDirectDrawPalette::GetCaps
*
* Returns the palette description
*
* Params:
* Caps: Address to store the caps at
*
* Returns:
* D3D_OK on success
* DDERR_INVALIDPARAMS if Caps is NULL
* For more details, see IWineD3DPalette::GetCaps
*
*****************************************************************************/
static HRESULT WINAPI
IDirectDrawPaletteImpl_GetCaps(IDirectDrawPalette *iface,
DWORD *Caps)
{
ICOM_THIS_FROM(IDirectDrawPaletteImpl, IDirectDrawPalette, iface);
TRACE("(%p)->(%p): Relay\n", This, Caps);
return IWineD3DPalette_GetCaps(This->wineD3DPalette, Caps);
}
/*****************************************************************************
* IDirectDrawPalette::SetEntries
*
* Sets the palette entries from a PALETTEENTRY structure. WineD3D takes
* care for updating the surface.
*
* Params:
* Flags: Flags, as usual
* Start: First palette entry to set
* Count: Number of entries to set
* PalEnt: Source entries
*
* Returns:
* D3D_OK on success
* DDERR_INVALIDPARAMS if PalEnt is NULL
* For details, see IWineD3DDevice::SetEntries
*
*****************************************************************************/
static HRESULT WINAPI
IDirectDrawPaletteImpl_SetEntries(IDirectDrawPalette *iface,
DWORD Flags,
DWORD Start,
DWORD Count,
PALETTEENTRY *PalEnt)
{
ICOM_THIS_FROM(IDirectDrawPaletteImpl, IDirectDrawPalette, iface);
TRACE("(%p)->(%x,%d,%d,%p): Relay\n", This, Flags, Start, Count, PalEnt);
if(!PalEnt)
return DDERR_INVALIDPARAMS;
return IWineD3DPalette_SetEntries(This->wineD3DPalette, Flags, Start, Count, PalEnt);
}
/*****************************************************************************
* IDirectDrawPalette::GetEntries
*
* Returns the entries stored in this interface.
*
* Params:
* Flags: Flags :)
* Start: First entry to return
* Count: The number of entries to return
* PalEnt: PALETTEENTRY structure to write the entries to
*
* Returns:
* D3D_OK on success
* DDERR_INVALIDPARAMS if PalEnt is NULL
* For details, see IWineD3DDevice::SetEntries
*
*****************************************************************************/
static HRESULT WINAPI
IDirectDrawPaletteImpl_GetEntries(IDirectDrawPalette *iface,
DWORD Flags,
DWORD Start,
DWORD Count,
PALETTEENTRY *PalEnt)
{
ICOM_THIS_FROM(IDirectDrawPaletteImpl, IDirectDrawPalette, iface);
TRACE("(%p)->(%x,%d,%d,%p): Relay\n", This, Flags, Start, Count, PalEnt);
if(!PalEnt)
return DDERR_INVALIDPARAMS;
return IWineD3DPalette_GetEntries(This->wineD3DPalette, Flags, Start, Count, PalEnt);
}
const IDirectDrawPaletteVtbl IDirectDrawPalette_Vtbl =
{
/*** IUnknown ***/
IDirectDrawPaletteImpl_QueryInterface,
IDirectDrawPaletteImpl_AddRef,
IDirectDrawPaletteImpl_Release,
/*** IDirectDrawPalette ***/
IDirectDrawPaletteImpl_GetCaps,
IDirectDrawPaletteImpl_GetEntries,
IDirectDrawPaletteImpl_Initialize,
IDirectDrawPaletteImpl_SetEntries
};

View File

@@ -0,0 +1,153 @@
/*
* IParent implementation
*
* Copyright (c) 2006 Stefan D<>singer
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*
* A universal parent interface for everything in WineD3D that doesn't have
* a DDraw counterpart
*/
#include "config.h"
#include "wine/port.h"
#include <assert.h>
#include <stdarg.h>
#include <string.h>
#include <stdlib.h>
#define COBJMACROS
//#ifndef WINE_NATIVEWIN32
# include "windef.h"
# include "winbase.h"
# include "winnls.h"
# include "winerror.h"
# include "wingdi.h"
//#endif
#include "ddraw.h"
#include "d3d.h"
#include "ddraw_private.h"
#include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(ddraw);
const GUID IID_IParent = {0xc20e4c88, 0x74e7, 0x4940, {0xba, 0x9f, 0x2e, 0x32, 0x3f, 0x9d, 0xc9, 0x81}};
/*****************************************************************************
* IUnknown methods
*****************************************************************************/
/*****************************************************************************
* IParent::Queryinterface
*
* It can't query any interfaces, and it's not used for anything. So
* it just returns E_NOINTERFACE
*
* Params:
* riid: guid of queried interface
* obj: returns a pointer to the interface
*
* Return values
* This implementation always returns E_NOINTERFACE and NULL
*
*****************************************************************************/
static HRESULT WINAPI
IParentImpl_QueryInterface(IParent *iface,
REFIID riid,
void **obj)
{
ICOM_THIS_FROM(IParentImpl, IParent, iface);
TRACE("(%p)->(%s,%p)\n", This, debugstr_guid(riid), obj);
*obj = NULL;
if ( IsEqualGUID( &IID_IUnknown, riid ) ||
IsEqualGUID( &IID_IParent, riid ) )
{
*obj = ICOM_INTERFACE(This, IParent);
IParent_AddRef(ICOM_INTERFACE(This, IParent));
return DD_OK;
}
return E_NOINTERFACE;
}
/*****************************************************************************
* IParent::AddRef
*
* Increases the refcount
*
* Params:
*
* Return values
* The new refcount
*
*****************************************************************************/
static ULONG WINAPI
IParentImpl_AddRef(IParent *iface)
{
ICOM_THIS_FROM(IParentImpl, IParent, iface);
ULONG ref = InterlockedIncrement(&This->ref);
TRACE("(%p) : AddRef from %d\n", This, ref - 1);
return ref;
}
/*****************************************************************************
* IParent::Release
*
* Releases the refcount, and destroys the object if the refcount falls to 0
* Also releases the child object, if destroyed. That's almost the whole sense
* of this interface.
*
* Params:
*
* Return values
* The new refcount
*
*****************************************************************************/
static ULONG WINAPI
IParentImpl_Release(IParent *iface)
{
ICOM_THIS_FROM(IParentImpl, IParent, iface);
ULONG ref = InterlockedDecrement(&This->ref);
TRACE("(%p) : ReleaseRef to %d\n", This, ref);
if (ref == 0)
{
TRACE("(%p) Releasing child at %p\n", This, This->child);
if(This->child)
IUnknown_Release(This->child);
HeapFree(GetProcessHeap(), 0, This);
TRACE("Released\n");
}
return ref;
}
/*****************************************************************************
* The VTable
*****************************************************************************/
const IParentVtbl IParent_Vtbl =
{
IParentImpl_QueryInterface,
IParentImpl_AddRef,
IParentImpl_Release,
};

View File

@@ -0,0 +1,501 @@
/*
* self-registerable dll functions for ddraw.dll
*
* Copyright (C) 2003 John K. Hohm
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "config.h"
#include <stdarg.h>
#include <string.h>
#ifndef WINE_NATIVEWIN32
# include "windef.h"
# include "winbase.h"
# include "winreg.h"
# include "wingdi.h"
# include "winuser.h"
# include "winerror.h"
#else
# include <windows.h>
#endif
#include "ddraw.h"
#include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(ddraw);
/*
* Near the bottom of this file are the exported DllRegisterServer and
* DllUnregisterServer, which make all this worthwhile.
*/
/***********************************************************************
* interface for self-registering
*/
struct regsvr_interface
{
IID const *iid; /* NULL for end of list */
LPCSTR name; /* can be NULL to omit */
IID const *base_iid; /* can be NULL to omit */
int num_methods; /* can be <0 to omit */
CLSID const *ps_clsid; /* can be NULL to omit */
CLSID const *ps_clsid32; /* can be NULL to omit */
};
static HRESULT register_interfaces(struct regsvr_interface const *list);
static HRESULT unregister_interfaces(struct regsvr_interface const *list);
struct regsvr_coclass
{
CLSID const *clsid; /* NULL for end of list */
LPCSTR name; /* can be NULL to omit */
LPCSTR ips; /* can be NULL to omit */
LPCSTR ips32; /* can be NULL to omit */
LPCSTR ips32_tmodel; /* can be NULL to omit */
LPCSTR clsid_str; /* can be NULL to omit */
LPCSTR progid; /* can be NULL to omit */
};
static HRESULT register_coclasses(struct regsvr_coclass const *list);
static HRESULT unregister_coclasses(struct regsvr_coclass const *list);
/***********************************************************************
* static string constants
*/
static WCHAR const interface_keyname[10] = {
'I', 'n', 't', 'e', 'r', 'f', 'a', 'c', 'e', 0 };
static WCHAR const base_ifa_keyname[14] = {
'B', 'a', 's', 'e', 'I', 'n', 't', 'e', 'r', 'f', 'a', 'c',
'e', 0 };
static WCHAR const num_methods_keyname[11] = {
'N', 'u', 'm', 'M', 'e', 't', 'h', 'o', 'd', 's', 0 };
static WCHAR const ps_clsid_keyname[15] = {
'P', 'r', 'o', 'x', 'y', 'S', 't', 'u', 'b', 'C', 'l', 's',
'i', 'd', 0 };
static WCHAR const ps_clsid32_keyname[17] = {
'P', 'r', 'o', 'x', 'y', 'S', 't', 'u', 'b', 'C', 'l', 's',
'i', 'd', '3', '2', 0 };
static WCHAR const clsid_keyname[6] = {
'C', 'L', 'S', 'I', 'D', 0 };
static WCHAR const ips_keyname[13] = {
'I', 'n', 'P', 'r', 'o', 'c', 'S', 'e', 'r', 'v', 'e', 'r',
0 };
static WCHAR const ips32_keyname[15] = {
'I', 'n', 'P', 'r', 'o', 'c', 'S', 'e', 'r', 'v', 'e', 'r',
'3', '2', 0 };
static WCHAR const progid_keyname[7] = {
'P', 'r', 'o', 'g', 'I', 'D', 0 };
static char const tmodel_valuename[] = "ThreadingModel";
/***********************************************************************
* static helper functions
*/
static LONG register_key_guid(HKEY base, WCHAR const *name, GUID const *guid);
static LONG register_key_defvalueW(HKEY base, WCHAR const *name,
WCHAR const *value);
static LONG register_key_defvalueA(HKEY base, WCHAR const *name,
char const *value);
static LONG recursive_delete_key(HKEY key);
static LONG recursive_delete_keyA(HKEY base, char const *name);
static LONG recursive_delete_keyW(HKEY base, WCHAR const *name);
/***********************************************************************
* register_interfaces
*/
static HRESULT register_interfaces(struct regsvr_interface const *list)
{
LONG res = ERROR_SUCCESS;
HKEY interface_key;
res = RegCreateKeyExW(HKEY_CLASSES_ROOT, interface_keyname, 0, NULL, 0,
KEY_READ | KEY_WRITE, NULL, &interface_key, NULL);
if (res != ERROR_SUCCESS) goto error_return;
for (; res == ERROR_SUCCESS && list->iid; ++list) {
WCHAR buf[39];
HKEY iid_key;
StringFromGUID2(list->iid, buf, 39);
res = RegCreateKeyExW(interface_key, buf, 0, NULL, 0,
KEY_READ | KEY_WRITE, NULL, &iid_key, NULL);
if (res != ERROR_SUCCESS) goto error_close_interface_key;
if (list->name) {
res = RegSetValueExA(iid_key, NULL, 0, REG_SZ,
(CONST BYTE*)(list->name),
strlen(list->name) + 1);
if (res != ERROR_SUCCESS) goto error_close_iid_key;
}
if (list->base_iid) {
res = register_key_guid(iid_key, base_ifa_keyname, list->base_iid);
if (res != ERROR_SUCCESS) goto error_close_iid_key;
}
if (0 <= list->num_methods) {
static WCHAR const fmt[3] = { '%', 'd', 0 };
HKEY key;
res = RegCreateKeyExW(iid_key, num_methods_keyname, 0, NULL, 0,
KEY_READ | KEY_WRITE, NULL, &key, NULL);
if (res != ERROR_SUCCESS) goto error_close_iid_key;
wsprintfW(buf, fmt, list->num_methods);
res = RegSetValueExW(key, NULL, 0, REG_SZ,
(CONST BYTE*)buf,
(lstrlenW(buf) + 1) * sizeof(WCHAR));
RegCloseKey(key);
if (res != ERROR_SUCCESS) goto error_close_iid_key;
}
if (list->ps_clsid) {
res = register_key_guid(iid_key, ps_clsid_keyname, list->ps_clsid);
if (res != ERROR_SUCCESS) goto error_close_iid_key;
}
if (list->ps_clsid32) {
res = register_key_guid(iid_key, ps_clsid32_keyname, list->ps_clsid32);
if (res != ERROR_SUCCESS) goto error_close_iid_key;
}
error_close_iid_key:
RegCloseKey(iid_key);
}
error_close_interface_key:
RegCloseKey(interface_key);
error_return:
return res != ERROR_SUCCESS ? HRESULT_FROM_WIN32(res) : S_OK;
}
/***********************************************************************
* unregister_interfaces
*/
static HRESULT unregister_interfaces(struct regsvr_interface const *list)
{
LONG res = ERROR_SUCCESS;
HKEY interface_key;
res = RegOpenKeyExW(HKEY_CLASSES_ROOT, interface_keyname, 0,
KEY_READ | KEY_WRITE, &interface_key);
if (res == ERROR_FILE_NOT_FOUND) return S_OK;
if (res != ERROR_SUCCESS) goto error_return;
for (; res == ERROR_SUCCESS && list->iid; ++list) {
WCHAR buf[39];
StringFromGUID2(list->iid, buf, 39);
res = recursive_delete_keyW(interface_key, buf);
}
RegCloseKey(interface_key);
error_return:
return res != ERROR_SUCCESS ? HRESULT_FROM_WIN32(res) : S_OK;
}
/***********************************************************************
* register_coclasses
*/
static HRESULT register_coclasses(struct regsvr_coclass const *list)
{
LONG res = ERROR_SUCCESS;
HKEY coclass_key;
res = RegCreateKeyExW(HKEY_CLASSES_ROOT, clsid_keyname, 0, NULL, 0,
KEY_READ | KEY_WRITE, NULL, &coclass_key, NULL);
if (res != ERROR_SUCCESS) goto error_return;
for (; res == ERROR_SUCCESS && list->clsid; ++list) {
WCHAR buf[39];
HKEY clsid_key;
StringFromGUID2(list->clsid, buf, 39);
res = RegCreateKeyExW(coclass_key, buf, 0, NULL, 0,
KEY_READ | KEY_WRITE, NULL, &clsid_key, NULL);
if (res != ERROR_SUCCESS) goto error_close_coclass_key;
if (list->name) {
res = RegSetValueExA(clsid_key, NULL, 0, REG_SZ,
(CONST BYTE*)(list->name),
strlen(list->name) + 1);
if (res != ERROR_SUCCESS) goto error_close_clsid_key;
}
if (list->ips) {
res = register_key_defvalueA(clsid_key, ips_keyname, list->ips);
if (res != ERROR_SUCCESS) goto error_close_clsid_key;
}
if (list->ips32) {
HKEY ips32_key;
res = RegCreateKeyExW(clsid_key, ips32_keyname, 0, NULL, 0,
KEY_READ | KEY_WRITE, NULL,
&ips32_key, NULL);
if (res != ERROR_SUCCESS) goto error_close_clsid_key;
res = RegSetValueExA(ips32_key, NULL, 0, REG_SZ,
(CONST BYTE*)list->ips32,
lstrlenA(list->ips32) + 1);
if (res == ERROR_SUCCESS && list->ips32_tmodel)
res = RegSetValueExA(ips32_key, tmodel_valuename, 0, REG_SZ,
(CONST BYTE*)list->ips32_tmodel,
strlen(list->ips32_tmodel) + 1);
RegCloseKey(ips32_key);
if (res != ERROR_SUCCESS) goto error_close_clsid_key;
}
if (list->clsid_str) {
res = register_key_defvalueA(clsid_key, clsid_keyname,
list->clsid_str);
if (res != ERROR_SUCCESS) goto error_close_clsid_key;
}
if (list->progid) {
HKEY progid_key;
res = register_key_defvalueA(clsid_key, progid_keyname,
list->progid);
if (res != ERROR_SUCCESS) goto error_close_clsid_key;
res = RegCreateKeyExA(HKEY_CLASSES_ROOT, list->progid, 0,
NULL, 0, KEY_READ | KEY_WRITE, NULL,
&progid_key, NULL);
if (res != ERROR_SUCCESS) goto error_close_clsid_key;
res = register_key_defvalueW(progid_key, clsid_keyname, buf);
RegCloseKey(progid_key);
if (res != ERROR_SUCCESS) goto error_close_clsid_key;
}
error_close_clsid_key:
RegCloseKey(clsid_key);
}
error_close_coclass_key:
RegCloseKey(coclass_key);
error_return:
return res != ERROR_SUCCESS ? HRESULT_FROM_WIN32(res) : S_OK;
}
/***********************************************************************
* unregister_coclasses
*/
static HRESULT unregister_coclasses(struct regsvr_coclass const *list)
{
LONG res = ERROR_SUCCESS;
HKEY coclass_key;
res = RegOpenKeyExW(HKEY_CLASSES_ROOT, clsid_keyname, 0,
KEY_READ | KEY_WRITE, &coclass_key);
if (res == ERROR_FILE_NOT_FOUND) return S_OK;
if (res != ERROR_SUCCESS) goto error_return;
for (; res == ERROR_SUCCESS && list->clsid; ++list) {
WCHAR buf[39];
StringFromGUID2(list->clsid, buf, 39);
res = recursive_delete_keyW(coclass_key, buf);
if (res != ERROR_SUCCESS) goto error_close_coclass_key;
if (list->progid) {
res = recursive_delete_keyA(HKEY_CLASSES_ROOT, list->progid);
if (res != ERROR_SUCCESS) goto error_close_coclass_key;
}
}
error_close_coclass_key:
RegCloseKey(coclass_key);
error_return:
return res != ERROR_SUCCESS ? HRESULT_FROM_WIN32(res) : S_OK;
}
/***********************************************************************
* regsvr_key_guid
*/
static LONG register_key_guid(HKEY base, WCHAR const *name, GUID const *guid)
{
WCHAR buf[39];
StringFromGUID2(guid, buf, 39);
return register_key_defvalueW(base, name, buf);
}
/***********************************************************************
* regsvr_key_defvalueW
*/
static LONG register_key_defvalueW(
HKEY base,
WCHAR const *name,
WCHAR const *value)
{
LONG res;
HKEY key;
res = RegCreateKeyExW(base, name, 0, NULL, 0,
KEY_READ | KEY_WRITE, NULL, &key, NULL);
if (res != ERROR_SUCCESS) return res;
res = RegSetValueExW(key, NULL, 0, REG_SZ, (CONST BYTE*)value,
(lstrlenW(value) + 1) * sizeof(WCHAR));
RegCloseKey(key);
return res;
}
/***********************************************************************
* regsvr_key_defvalueA
*/
static LONG register_key_defvalueA(
HKEY base,
WCHAR const *name,
char const *value)
{
LONG res;
HKEY key;
res = RegCreateKeyExW(base, name, 0, NULL, 0,
KEY_READ | KEY_WRITE, NULL, &key, NULL);
if (res != ERROR_SUCCESS) return res;
res = RegSetValueExA(key, NULL, 0, REG_SZ, (CONST BYTE*)value,
lstrlenA(value) + 1);
RegCloseKey(key);
return res;
}
/***********************************************************************
* recursive_delete_key
*/
static LONG recursive_delete_key(HKEY key)
{
LONG res;
WCHAR subkey_name[MAX_PATH];
DWORD cName;
HKEY subkey;
for (;;) {
cName = sizeof(subkey_name) / sizeof(WCHAR);
res = RegEnumKeyExW(key, 0, subkey_name, &cName,
NULL, NULL, NULL, NULL);
if (res != ERROR_SUCCESS && res != ERROR_MORE_DATA) {
res = ERROR_SUCCESS; /* presumably we're done enumerating */
break;
}
res = RegOpenKeyExW(key, subkey_name, 0,
KEY_READ | KEY_WRITE, &subkey);
if (res == ERROR_FILE_NOT_FOUND) continue;
if (res != ERROR_SUCCESS) break;
res = recursive_delete_key(subkey);
RegCloseKey(subkey);
if (res != ERROR_SUCCESS) break;
}
if (res == ERROR_SUCCESS) res = RegDeleteKeyW(key, 0);
return res;
}
/***********************************************************************
* recursive_delete_keyA
*/
static LONG recursive_delete_keyA(HKEY base, char const *name)
{
LONG res;
HKEY key;
res = RegOpenKeyExA(base, name, 0, KEY_READ | KEY_WRITE, &key);
if (res == ERROR_FILE_NOT_FOUND) return ERROR_SUCCESS;
if (res != ERROR_SUCCESS) return res;
res = recursive_delete_key(key);
RegCloseKey(key);
return res;
}
/***********************************************************************
* recursive_delete_keyW
*/
static LONG recursive_delete_keyW(HKEY base, WCHAR const *name)
{
LONG res;
HKEY key;
res = RegOpenKeyExW(base, name, 0, KEY_READ | KEY_WRITE, &key);
if (res == ERROR_FILE_NOT_FOUND) return ERROR_SUCCESS;
if (res != ERROR_SUCCESS) return res;
res = recursive_delete_key(key);
RegCloseKey(key);
return res;
}
/***********************************************************************
* coclass list
*/
static struct regsvr_coclass const coclass_list[] = {
{ &CLSID_DirectDraw,
"DirectDraw Object",
NULL,
"ddraw.dll",
"Both"
},
{ &CLSID_DirectDrawClipper,
"DirectDraw Clipper Object",
NULL,
"ddraw.dll",
"Both"
},
{ NULL } /* list terminator */
};
/***********************************************************************
* interface list
*/
static struct regsvr_interface const interface_list[] = {
{ NULL } /* list terminator */
};
/***********************************************************************
* DllRegisterServer (DDRAW.@)
*/
HRESULT WINAPI DllRegisterServer(void)
{
HRESULT hr;
TRACE("\n");
hr = register_coclasses(coclass_list);
if (SUCCEEDED(hr))
hr = register_interfaces(interface_list);
return hr;
}
/***********************************************************************
* DllUnregisterServer (DDRAW.@)
*/
HRESULT WINAPI DllUnregisterServer(void)
{
HRESULT hr;
TRACE("\n");
hr = unregister_coclasses(coclass_list);
if (SUCCEEDED(hr))
hr = unregister_interfaces(interface_list);
return hr;
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,447 @@
/* IDirectDrawSurface3 -> IDirectDrawSurface7 thunks
* Copyright 2000 TransGaming Technologies Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "config.h"
#include "wine/port.h"
#include <stdarg.h>
#ifndef WINE_NATIVEWIN32
# include "windef.h"
# include "winbase.h"
# include "wingdi.h"
# include "ddraw.h"
# include "winerror.h"
#endif
#include "ddraw_private.h"
#include "wine/debug.h"
#include "ddcomimpl.h"
#define CONVERT(pdds) COM_INTERFACE_CAST(IDirectDrawSurfaceImpl, \
IDirectDrawSurface3, \
IDirectDrawSurface7, \
(pdds))
#define CONVERT_REV(pdds) COM_INTERFACE_CAST(IDirectDrawSurfaceImpl, \
IDirectDrawSurface7, \
IDirectDrawSurface3, \
(pdds))
WINE_DEFAULT_DEBUG_CHANNEL(ddraw_thunk);
static HRESULT WINAPI
IDirectDrawSurface3Impl_QueryInterface(LPDIRECTDRAWSURFACE3 This, REFIID iid,
LPVOID *ppObj)
{
return IDirectDrawSurface7_QueryInterface(CONVERT(This), iid, ppObj);
}
static ULONG WINAPI
IDirectDrawSurface3Impl_AddRef(LPDIRECTDRAWSURFACE3 This)
{
return IDirectDrawSurface7_AddRef(CONVERT(This));
}
static ULONG WINAPI
IDirectDrawSurface3Impl_Release(LPDIRECTDRAWSURFACE3 iface)
{
ICOM_THIS_FROM( IDirectDrawSurfaceImpl, IDirectDrawSurface3, iface);
TRACE("(%p)\n", This);
return IDirectDrawSurface7_Release(CONVERT(iface));
}
static HRESULT WINAPI
IDirectDrawSurface3Impl_AddAttachedSurface(LPDIRECTDRAWSURFACE3 This,
LPDIRECTDRAWSURFACE3 pAttach)
{
return IDirectDrawSurface7_AddAttachedSurface(CONVERT(This),
CONVERT(pAttach));
}
static HRESULT WINAPI
IDirectDrawSurface3Impl_AddOverlayDirtyRect(LPDIRECTDRAWSURFACE3 This,
LPRECT pRect)
{
return IDirectDrawSurface7_AddOverlayDirtyRect(CONVERT(This), pRect);
}
static HRESULT WINAPI
IDirectDrawSurface3Impl_Blt(LPDIRECTDRAWSURFACE3 This, LPRECT prcDst,
LPDIRECTDRAWSURFACE3 pSrcSurf, LPRECT prcSrc,
DWORD dwFlags, LPDDBLTFX pFX)
{
return IDirectDrawSurface7_Blt(CONVERT(This), prcDst, CONVERT(pSrcSurf),
prcSrc, dwFlags, pFX);
}
static HRESULT WINAPI
IDirectDrawSurface3Impl_BltBatch(LPDIRECTDRAWSURFACE3 This,
LPDDBLTBATCH pBatch, DWORD dwCount,
DWORD dwFlags)
{
return IDirectDrawSurface7_BltBatch(CONVERT(This), pBatch, dwCount,
dwFlags);
}
static HRESULT WINAPI
IDirectDrawSurface3Impl_BltFast(LPDIRECTDRAWSURFACE3 This, DWORD x, DWORD y,
LPDIRECTDRAWSURFACE3 pSrcSurf, LPRECT prcSrc,
DWORD dwTrans)
{
return IDirectDrawSurface7_BltFast(CONVERT(This), x, y, CONVERT(pSrcSurf),
prcSrc, dwTrans);
}
static HRESULT WINAPI
IDirectDrawSurface3Impl_DeleteAttachedSurface(LPDIRECTDRAWSURFACE3 This,
DWORD dwFlags,
LPDIRECTDRAWSURFACE3 pAttached)
{
return IDirectDrawSurface7_DeleteAttachedSurface(CONVERT(This), dwFlags,
CONVERT(pAttached));
}
struct callback_info
{
LPDDENUMSURFACESCALLBACK callback;
LPVOID context;
};
static HRESULT CALLBACK
EnumCallback(LPDIRECTDRAWSURFACE7 iface, LPDDSURFACEDESC2 pDDSD,
LPVOID context)
{
const struct callback_info* info = context;
#if 0
/* This is an outgoing conversion so we have to do it. */
DDSURFACEDESC ddsd;
memset(&ddsd, 0, sizeof(ddsd));
ddsd.dwSize = sizeof(ddsd);
DDRAW_Convert_DDSURFACEDESC_2_To_1(pDDSD, &ddsd);
#endif
/* the LPDDSURFACEDESC2 -> LPDDSURFACEDESC coercion is safe, since
* the data format is compatible with older enum procs */
return info->callback((LPDIRECTDRAWSURFACE)CONVERT_REV(iface), (LPDDSURFACEDESC)pDDSD,
info->context);
}
static HRESULT WINAPI
IDirectDrawSurface3Impl_EnumAttachedSurfaces(LPDIRECTDRAWSURFACE3 This,
LPVOID context,
LPDDENUMSURFACESCALLBACK callback)
{
struct callback_info info;
info.callback = callback;
info.context = context;
return IDirectDrawSurface7_EnumAttachedSurfaces(CONVERT(This), &info,
EnumCallback);
}
static HRESULT WINAPI
IDirectDrawSurface3Impl_EnumOverlayZOrders(LPDIRECTDRAWSURFACE3 This,
DWORD dwFlags, LPVOID context,
LPDDENUMSURFACESCALLBACK callback)
{
struct callback_info info;
info.callback = callback;
info.context = context;
return IDirectDrawSurface7_EnumOverlayZOrders(CONVERT(This), dwFlags,
&info, EnumCallback);
}
static HRESULT WINAPI
IDirectDrawSurface3Impl_Flip(LPDIRECTDRAWSURFACE3 This,
LPDIRECTDRAWSURFACE3 pOverride, DWORD dwFlags)
{
return IDirectDrawSurface7_Flip(CONVERT(This), CONVERT(pOverride),
dwFlags);
}
static HRESULT WINAPI
IDirectDrawSurface3Impl_GetAttachedSurface(LPDIRECTDRAWSURFACE3 This,
LPDDSCAPS pCaps,
LPDIRECTDRAWSURFACE3* ppAttached)
{
DDSCAPS2 caps;
LPDIRECTDRAWSURFACE7 pAttached7;
HRESULT hr;
caps.dwCaps = pCaps->dwCaps;
caps.dwCaps2 = 0;
caps.dwCaps3 = 0;
#ifndef WINE_NATIVEWIN32
caps.dwCaps4 = 0;
#else
caps.u1.dwCaps4 = 0;
#endif
hr = IDirectDrawSurface7_GetAttachedSurface(CONVERT(This), &caps,
&pAttached7);
if (FAILED(hr)) return hr;
*ppAttached = CONVERT_REV(pAttached7);
return hr;
}
static HRESULT WINAPI
IDirectDrawSurface3Impl_GetBltStatus(LPDIRECTDRAWSURFACE3 This, DWORD dwFlags)
{
return IDirectDrawSurface7_GetBltStatus(CONVERT(This), dwFlags);
}
static HRESULT WINAPI
IDirectDrawSurface3Impl_GetCaps(LPDIRECTDRAWSURFACE3 This, LPDDSCAPS pCaps)
{
DDSCAPS2 caps;
HRESULT hr;
hr = IDirectDrawSurface7_GetCaps(CONVERT(This), &caps);
if (FAILED(hr)) return hr;
pCaps->dwCaps = caps.dwCaps;
return hr;
}
static HRESULT WINAPI
IDirectDrawSurface3Impl_GetClipper(LPDIRECTDRAWSURFACE3 This,
LPDIRECTDRAWCLIPPER* ppClipper)
{
return IDirectDrawSurface7_GetClipper(CONVERT(This), ppClipper);
}
static HRESULT WINAPI
IDirectDrawSurface3Impl_GetColorKey(LPDIRECTDRAWSURFACE3 This, DWORD dwFlags,
LPDDCOLORKEY pCKey)
{
return IDirectDrawSurface7_GetColorKey(CONVERT(This), dwFlags, pCKey);
}
static HRESULT WINAPI
IDirectDrawSurface3Impl_GetDC(LPDIRECTDRAWSURFACE3 This, HDC* phDC)
{
return IDirectDrawSurface7_GetDC(CONVERT(This), phDC);
}
static HRESULT WINAPI
IDirectDrawSurface3Impl_GetFlipStatus(LPDIRECTDRAWSURFACE3 This, DWORD dwFlags)
{
return IDirectDrawSurface7_GetFlipStatus(CONVERT(This), dwFlags);
}
static HRESULT WINAPI
IDirectDrawSurface3Impl_GetOverlayPosition(LPDIRECTDRAWSURFACE3 This, LPLONG pX,
LPLONG pY)
{
return IDirectDrawSurface7_GetOverlayPosition(CONVERT(This), pX, pY);
}
static HRESULT WINAPI
IDirectDrawSurface3Impl_GetPalette(LPDIRECTDRAWSURFACE3 This,
LPDIRECTDRAWPALETTE* ppPalette)
{
return IDirectDrawSurface7_GetPalette(CONVERT(This), ppPalette);
}
static HRESULT WINAPI
IDirectDrawSurface3Impl_GetPixelFormat(LPDIRECTDRAWSURFACE3 This,
LPDDPIXELFORMAT pPixelFormat)
{
return IDirectDrawSurface7_GetPixelFormat(CONVERT(This), pPixelFormat);
}
static HRESULT WINAPI
IDirectDrawSurface3Impl_GetSurfaceDesc(LPDIRECTDRAWSURFACE3 This,
LPDDSURFACEDESC pDDSD)
{
return IDirectDrawSurface7_GetSurfaceDesc(CONVERT(This),
(LPDDSURFACEDESC2)pDDSD);
}
static HRESULT WINAPI
IDirectDrawSurface3Impl_Initialize(LPDIRECTDRAWSURFACE3 This, LPDIRECTDRAW pDD,
LPDDSURFACEDESC pDDSD)
{
return IDirectDrawSurface7_Initialize(CONVERT(This), pDD,
(LPDDSURFACEDESC2)pDDSD);
}
static HRESULT WINAPI
IDirectDrawSurface3Impl_IsLost(LPDIRECTDRAWSURFACE3 This)
{
return IDirectDrawSurface7_IsLost(CONVERT(This));
}
static HRESULT WINAPI
IDirectDrawSurface3Impl_Lock(LPDIRECTDRAWSURFACE3 This, LPRECT pRect,
LPDDSURFACEDESC pDDSD, DWORD dwFlags, HANDLE h)
{
return IDirectDrawSurface7_Lock(CONVERT(This), pRect,
(LPDDSURFACEDESC2)pDDSD, dwFlags, h);
}
static HRESULT WINAPI
IDirectDrawSurface3Impl_ReleaseDC(LPDIRECTDRAWSURFACE3 This, HDC hDC)
{
return IDirectDrawSurface7_ReleaseDC(CONVERT(This), hDC);
}
static HRESULT WINAPI
IDirectDrawSurface3Impl_Restore(LPDIRECTDRAWSURFACE3 This)
{
return IDirectDrawSurface7_Restore(CONVERT(This));
}
static HRESULT WINAPI
IDirectDrawSurface3Impl_SetClipper(LPDIRECTDRAWSURFACE3 This,
LPDIRECTDRAWCLIPPER pClipper)
{
return IDirectDrawSurface7_SetClipper(CONVERT(This), pClipper);
}
static HRESULT WINAPI
IDirectDrawSurface3Impl_SetColorKey(LPDIRECTDRAWSURFACE3 This, DWORD dwFlags,
LPDDCOLORKEY pCKey)
{
return IDirectDrawSurface7_SetColorKey(CONVERT(This), dwFlags, pCKey);
}
static HRESULT WINAPI
IDirectDrawSurface3Impl_SetOverlayPosition(LPDIRECTDRAWSURFACE3 This, LONG x,
LONG y)
{
return IDirectDrawSurface7_SetOverlayPosition(CONVERT(This), x, y);
}
static HRESULT WINAPI
IDirectDrawSurface3Impl_SetPalette(LPDIRECTDRAWSURFACE3 This,
LPDIRECTDRAWPALETTE pPalette)
{
return IDirectDrawSurface7_SetPalette(CONVERT(This), pPalette);
}
static HRESULT WINAPI
IDirectDrawSurface3Impl_Unlock(LPDIRECTDRAWSURFACE3 This, LPVOID data)
{
/* data might not be the LPRECT of later versions, so drop it. */
return IDirectDrawSurface7_Unlock(CONVERT(This), NULL);
}
static HRESULT WINAPI
IDirectDrawSurface3Impl_UpdateOverlay(LPDIRECTDRAWSURFACE3 This, LPRECT prcSrc,
LPDIRECTDRAWSURFACE3 pDstSurf,
LPRECT prcDst, DWORD dwFlags,
LPDDOVERLAYFX pFX)
{
return IDirectDrawSurface7_UpdateOverlay(CONVERT(This), prcSrc,
CONVERT(pDstSurf), prcDst,
dwFlags, pFX);
}
static HRESULT WINAPI
IDirectDrawSurface3Impl_UpdateOverlayDisplay(LPDIRECTDRAWSURFACE3 This,
DWORD dwFlags)
{
return IDirectDrawSurface7_UpdateOverlayDisplay(CONVERT(This), dwFlags);
}
static HRESULT WINAPI
IDirectDrawSurface3Impl_UpdateOverlayZOrder(LPDIRECTDRAWSURFACE3 This,
DWORD dwFlags,
LPDIRECTDRAWSURFACE3 pSurfReference)
{
return IDirectDrawSurface7_UpdateOverlayZOrder(CONVERT(This), dwFlags,
CONVERT(pSurfReference));
}
static HRESULT WINAPI
IDirectDrawSurface3Impl_GetDDInterface(LPDIRECTDRAWSURFACE3 This, LPVOID* ppDD)
{
return IDirectDrawSurface7_GetDDInterface(CONVERT(This), ppDD);
}
static HRESULT WINAPI
IDirectDrawSurface3Impl_PageLock(LPDIRECTDRAWSURFACE3 This, DWORD dwFlags)
{
return IDirectDrawSurface7_PageLock(CONVERT(This), dwFlags);
}
static HRESULT WINAPI
IDirectDrawSurface3Impl_PageUnlock(LPDIRECTDRAWSURFACE3 This, DWORD dwFlags)
{
return IDirectDrawSurface7_PageUnlock(CONVERT(This), dwFlags);
}
static HRESULT WINAPI
IDirectDrawSurface3Impl_SetSurfaceDesc(LPDIRECTDRAWSURFACE3 This,
LPDDSURFACEDESC pDDSD, DWORD dwFlags)
{
return IDirectDrawSurface7_SetSurfaceDesc(CONVERT(This),
(LPDDSURFACEDESC2)pDDSD,
dwFlags);
}
const IDirectDrawSurface3Vtbl IDirectDrawSurface3_Vtbl =
{
IDirectDrawSurface3Impl_QueryInterface,
IDirectDrawSurface3Impl_AddRef,
IDirectDrawSurface3Impl_Release,
IDirectDrawSurface3Impl_AddAttachedSurface,
IDirectDrawSurface3Impl_AddOverlayDirtyRect,
IDirectDrawSurface3Impl_Blt,
IDirectDrawSurface3Impl_BltBatch,
IDirectDrawSurface3Impl_BltFast,
IDirectDrawSurface3Impl_DeleteAttachedSurface,
IDirectDrawSurface3Impl_EnumAttachedSurfaces,
IDirectDrawSurface3Impl_EnumOverlayZOrders,
IDirectDrawSurface3Impl_Flip,
IDirectDrawSurface3Impl_GetAttachedSurface,
IDirectDrawSurface3Impl_GetBltStatus,
IDirectDrawSurface3Impl_GetCaps,
IDirectDrawSurface3Impl_GetClipper,
IDirectDrawSurface3Impl_GetColorKey,
IDirectDrawSurface3Impl_GetDC,
IDirectDrawSurface3Impl_GetFlipStatus,
IDirectDrawSurface3Impl_GetOverlayPosition,
IDirectDrawSurface3Impl_GetPalette,
IDirectDrawSurface3Impl_GetPixelFormat,
IDirectDrawSurface3Impl_GetSurfaceDesc,
IDirectDrawSurface3Impl_Initialize,
IDirectDrawSurface3Impl_IsLost,
IDirectDrawSurface3Impl_Lock,
IDirectDrawSurface3Impl_ReleaseDC,
IDirectDrawSurface3Impl_Restore,
IDirectDrawSurface3Impl_SetClipper,
IDirectDrawSurface3Impl_SetColorKey,
IDirectDrawSurface3Impl_SetOverlayPosition,
IDirectDrawSurface3Impl_SetPalette,
IDirectDrawSurface3Impl_Unlock,
IDirectDrawSurface3Impl_UpdateOverlay,
IDirectDrawSurface3Impl_UpdateOverlayDisplay,
IDirectDrawSurface3Impl_UpdateOverlayZOrder,
IDirectDrawSurface3Impl_GetDDInterface,
IDirectDrawSurface3Impl_PageLock,
IDirectDrawSurface3Impl_PageUnlock,
IDirectDrawSurface3Impl_SetSurfaceDesc
};

View File

@@ -0,0 +1,640 @@
/*
* Some unit tests for d3d functions
*
* Copyright (C) 2005 Antoine Chavasse
* Copyright (C) 2006 Stefan D<>singer for CodeWeavers
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "config.h"
#include <assert.h>
#include "wine/test.h"
#include "ddraw.h"
#include "d3d.h"
static LPDIRECTDRAW7 lpDD = NULL;
static LPDIRECT3D7 lpD3D = NULL;
static LPDIRECTDRAWSURFACE7 lpDDS = NULL;
static LPDIRECT3DDEVICE7 lpD3DDevice = NULL;
static LPDIRECT3DVERTEXBUFFER7 lpVBufSrc = NULL;
static LPDIRECT3DVERTEXBUFFER7 lpVBufDest1 = NULL;
static LPDIRECT3DVERTEXBUFFER7 lpVBufDest2 = NULL;
/* To compare bad floating point numbers. Not the ideal way to do it,
* but it should be enough for here */
#define comparefloat(a, b) ( (((a) - (b)) < 0.0001) && (((a) - (b)) > -0.0001) )
static HRESULT (WINAPI *pDirectDrawCreateEx)(LPGUID,LPVOID*,REFIID,LPUNKNOWN);
typedef struct _VERTEX
{
float x, y, z; /* position */
} VERTEX, *LPVERTEX;
typedef struct _TVERTEX
{
float x, y, z; /* position */
float rhw;
} TVERTEX, *LPTVERTEX;
static void init_function_pointers(void)
{
HMODULE hmod = GetModuleHandleA("ddraw.dll");
pDirectDrawCreateEx = (void*)GetProcAddress(hmod, "DirectDrawCreateEx");
}
static BOOL CreateDirect3D(void)
{
HRESULT rc;
DDSURFACEDESC2 ddsd;
rc = pDirectDrawCreateEx(NULL, (void**)&lpDD,
&IID_IDirectDraw7, NULL);
ok(rc==DD_OK || rc==DDERR_NODIRECTDRAWSUPPORT, "DirectDrawCreateEx returned: %x\n", rc);
if (!lpDD) {
trace("DirectDrawCreateEx() failed with an error %x\n", rc);
return FALSE;
}
rc = IDirectDraw_SetCooperativeLevel(lpDD, NULL, DDSCL_NORMAL);
ok(rc==DD_OK, "SetCooperativeLevel returned: %x\n", rc);
rc = IDirectDraw7_QueryInterface(lpDD, &IID_IDirect3D7, (void**) &lpD3D);
if (rc == E_NOINTERFACE) return FALSE;
ok(rc==DD_OK, "QueryInterface returned: %x\n", rc);
memset(&ddsd, 0, sizeof(ddsd));
ddsd.dwSize = sizeof(ddsd);
ddsd.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT;
ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_3DDEVICE;
ddsd.dwWidth = 256;
ddsd.dwHeight = 256;
rc = IDirectDraw7_CreateSurface(lpDD, &ddsd, &lpDDS, NULL);
ok(rc==DD_OK, "CreateSurface returned: %x\n", rc);
rc = IDirect3D7_CreateDevice(lpD3D, &IID_IDirect3DTnLHalDevice, lpDDS,
&lpD3DDevice);
ok(rc==D3D_OK || rc==DDERR_NOPALETTEATTACHED || rc==E_OUTOFMEMORY, "CreateDevice returned: %x\n", rc);
if (!lpD3DDevice) {
trace("IDirect3D7::CreateDevice() failed with an error %x\n", rc);
return FALSE;
}
return TRUE;
}
static void ReleaseDirect3D(void)
{
if (lpD3DDevice != NULL)
{
IDirect3DDevice7_Release(lpD3DDevice);
lpD3DDevice = NULL;
}
if (lpDDS != NULL)
{
IDirectDrawSurface_Release(lpDDS);
lpDDS = NULL;
}
if (lpD3D != NULL)
{
IDirect3D7_Release(lpD3D);
lpD3D = NULL;
}
if (lpDD != NULL)
{
IDirectDraw_Release(lpDD);
lpDD = NULL;
}
}
static void LightTest(void)
{
HRESULT rc;
D3DLIGHT7 light;
D3DLIGHT7 defaultlight;
BOOL bEnabled = FALSE;
/* Set a few lights with funky indices. */
memset(&light, 0, sizeof(light));
light.dltType = D3DLIGHT_DIRECTIONAL;
U1(light.dcvDiffuse).r = 0.5f;
U2(light.dcvDiffuse).g = 0.6f;
U3(light.dcvDiffuse).b = 0.7f;
U2(light.dvDirection).y = 1.f;
rc = IDirect3DDevice7_SetLight(lpD3DDevice, 5, &light);
ok(rc==D3D_OK, "SetLight returned: %x\n", rc);
rc = IDirect3DDevice7_SetLight(lpD3DDevice, 10, &light);
ok(rc==D3D_OK, "SetLight returned: %x\n", rc);
rc = IDirect3DDevice7_SetLight(lpD3DDevice, 45, &light);
ok(rc==D3D_OK, "SetLight returned: %x\n", rc);
/* Try to retrieve a light beyond the indices of the lights that have
been set. */
rc = IDirect3DDevice7_GetLight(lpD3DDevice, 50, &light);
ok(rc==DDERR_INVALIDPARAMS, "GetLight returned: %x\n", rc);
rc = IDirect3DDevice7_GetLight(lpD3DDevice, 2, &light);
ok(rc==DDERR_INVALIDPARAMS, "GetLight returned: %x\n", rc);
/* Try to retrieve one of the lights that have been set */
rc = IDirect3DDevice7_GetLight(lpD3DDevice, 10, &light);
ok(rc==D3D_OK, "GetLight returned: %x\n", rc);
/* Enable a light that have been previously set. */
rc = IDirect3DDevice7_LightEnable(lpD3DDevice, 10, TRUE);
ok(rc==D3D_OK, "LightEnable returned: %x\n", rc);
/* Enable some lights that have not been previously set, and verify that
they have been initialized with proper default values. */
memset(&defaultlight, 0, sizeof(D3DLIGHT7));
defaultlight.dltType = D3DLIGHT_DIRECTIONAL;
U1(defaultlight.dcvDiffuse).r = 1.f;
U2(defaultlight.dcvDiffuse).g = 1.f;
U3(defaultlight.dcvDiffuse).b = 1.f;
U3(defaultlight.dvDirection).z = 1.f;
rc = IDirect3DDevice7_LightEnable(lpD3DDevice, 20, TRUE);
ok(rc==D3D_OK, "LightEnable returned: %x\n", rc);
memset(&light, 0, sizeof(D3DLIGHT7));
rc = IDirect3DDevice7_GetLight(lpD3DDevice, 20, &light);
ok(rc==D3D_OK, "GetLight returned: %x\n", rc);
ok(!memcmp(&light, &defaultlight, sizeof(D3DLIGHT7)),
"light data doesn't match expected default values\n" );
rc = IDirect3DDevice7_LightEnable(lpD3DDevice, 50, TRUE);
ok(rc==D3D_OK, "LightEnable returned: %x\n", rc);
memset(&light, 0, sizeof(D3DLIGHT7));
rc = IDirect3DDevice7_GetLight(lpD3DDevice, 50, &light);
ok(rc==D3D_OK, "GetLight returned: %x\n", rc);
ok(!memcmp(&light, &defaultlight, sizeof(D3DLIGHT7)),
"light data doesn't match expected default values\n" );
/* Disable one of the light that have been previously enabled. */
rc = IDirect3DDevice7_LightEnable(lpD3DDevice, 20, FALSE);
ok(rc==D3D_OK, "LightEnable returned: %x\n", rc);
/* Try to retrieve the enable status of some lights */
/* Light 20 is supposed to be disabled */
rc = IDirect3DDevice7_GetLightEnable(lpD3DDevice, 20, &bEnabled );
ok(rc==D3D_OK, "GetLightEnable returned: %x\n", rc);
ok(!bEnabled, "GetLightEnable says the light is enabled\n");
/* Light 10 is supposed to be enabled */
bEnabled = FALSE;
rc = IDirect3DDevice7_GetLightEnable(lpD3DDevice, 10, &bEnabled );
ok(rc==D3D_OK, "GetLightEnable returned: %x\n", rc);
ok(bEnabled, "GetLightEnable says the light is disabled\n");
/* Light 80 has not been set */
rc = IDirect3DDevice7_GetLightEnable(lpD3DDevice, 80, &bEnabled );
ok(rc==DDERR_INVALIDPARAMS, "GetLightEnable returned: %x\n", rc);
/* Light 23 has not been set */
rc = IDirect3DDevice7_GetLightEnable(lpD3DDevice, 23, &bEnabled );
ok(rc==DDERR_INVALIDPARAMS, "GetLightEnable returned: %x\n", rc);
/* Set some lights with invalid parameters */
memset(&light, 0, sizeof(D3DLIGHT7));
light.dltType = 0;
U1(light.dcvDiffuse).r = 1.f;
U2(light.dcvDiffuse).g = 1.f;
U3(light.dcvDiffuse).b = 1.f;
U3(light.dvDirection).z = 1.f;
rc = IDirect3DDevice7_SetLight(lpD3DDevice, 100, &light);
ok(rc==DDERR_INVALIDPARAMS, "SetLight returned: %x\n", rc);
memset(&light, 0, sizeof(D3DLIGHT7));
light.dltType = 12345;
U1(light.dcvDiffuse).r = 1.f;
U2(light.dcvDiffuse).g = 1.f;
U3(light.dcvDiffuse).b = 1.f;
U3(light.dvDirection).z = 1.f;
rc = IDirect3DDevice7_SetLight(lpD3DDevice, 101, &light);
ok(rc==DDERR_INVALIDPARAMS, "SetLight returned: %x\n", rc);
rc = IDirect3DDevice7_SetLight(lpD3DDevice, 102, NULL);
ok(rc==DDERR_INVALIDPARAMS, "SetLight returned: %x\n", rc);
memset(&light, 0, sizeof(D3DLIGHT7));
light.dltType = D3DLIGHT_SPOT;
U1(light.dcvDiffuse).r = 1.f;
U2(light.dcvDiffuse).g = 1.f;
U3(light.dcvDiffuse).b = 1.f;
U3(light.dvDirection).z = 1.f;
#ifndef WINE_NATIVEWIN32
light.dvAttenuation0 = -1.0 / 0.0; /* -INFINITY */
#else
*(long *)&light.dvAttenuation0 = 0xff800000L;
#endif
rc = IDirect3DDevice7_SetLight(lpD3DDevice, 103, &light);
ok(rc==DDERR_INVALIDPARAMS, "SetLight returned: %x\n", rc);
light.dvAttenuation0 = -1.0;
rc = IDirect3DDevice7_SetLight(lpD3DDevice, 103, &light);
ok(rc==DDERR_INVALIDPARAMS, "SetLight returned: %x\n", rc);
light.dvAttenuation0 = 0.0;
rc = IDirect3DDevice7_SetLight(lpD3DDevice, 103, &light);
ok(rc==D3D_OK, "SetLight returned: %x\n", rc);
light.dvAttenuation0 = 1.0;
rc = IDirect3DDevice7_SetLight(lpD3DDevice, 103, &light);
ok(rc==D3D_OK, "SetLight returned: %x\n", rc);
#ifndef WINE_NATIVEWIN32
light.dvAttenuation0 = 1.0 / 0.0; /* +INFINITY */
#else
*(long *)&light.dvAttenuation0 = 0x7f800000L;
#endif
rc = IDirect3DDevice7_SetLight(lpD3DDevice, 103, &light);
ok(rc==D3D_OK, "SetLight returned: %x\n", rc);
#ifndef WINE_NATIVEWIN32
light.dvAttenuation0 = 0.0 / 0.0; /* NaN */
#else
*(long *)&light.dvAttenuation0 = 0x7fC00000L;
#endif
rc = IDirect3DDevice7_SetLight(lpD3DDevice, 103, &light);
ok(rc==D3D_OK, "SetLight returned: %x\n", rc);
/* Directional light ignores attenuation */
light.dltType = D3DLIGHT_DIRECTIONAL;
light.dvAttenuation0 = -1.0;
rc = IDirect3DDevice7_SetLight(lpD3DDevice, 103, &light);
ok(rc==D3D_OK, "SetLight returned: %x\n", rc);
}
static void ProcessVerticesTest(void)
{
D3DVERTEXBUFFERDESC desc;
HRESULT rc;
VERTEX *in;
TVERTEX *out;
VERTEX *out2;
D3DVIEWPORT7 vp;
D3DMATRIX view = { 2.0, 0.0, 0.0, 0.0,
0.0, -1.0, 0.0, 0.0,
0.0, 0.0, 1.0, 0.0,
0.0, 0.0, 0.0, 3.0 };
D3DMATRIX world = { 0.0, 1.0, 0.0, 0.0,
1.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 1.0,
0.0, 1.0, 1.0, 1.0 };
D3DMATRIX proj = { 1.0, 0.0, 0.0, 1.0,
0.0, 1.0, 1.0, 0.0,
0.0, 1.0, 1.0, 0.0,
1.0, 0.0, 0.0, 1.0 };
/* Create some vertex buffers */
memset(&desc, 0, sizeof(desc));
desc.dwSize = sizeof(desc);
desc.dwCaps = 0;
desc.dwFVF = D3DFVF_XYZ;
desc.dwNumVertices = 16;
rc = IDirect3D7_CreateVertexBuffer(lpD3D, &desc, &lpVBufSrc, 0);
ok(rc==D3D_OK || rc==E_OUTOFMEMORY, "CreateVertexBuffer returned: %x\n", rc);
if (!lpVBufSrc)
{
trace("IDirect3D7::CreateVertexBuffer() failed with an error %x\n", rc);
goto out;
}
memset(&desc, 0, sizeof(desc));
desc.dwSize = sizeof(desc);
desc.dwCaps = 0;
desc.dwFVF = D3DFVF_XYZRHW;
desc.dwNumVertices = 16;
/* Msdn says that the last parameter must be 0 - check that */
rc = IDirect3D7_CreateVertexBuffer(lpD3D, &desc, &lpVBufDest1, 4);
ok(rc==D3D_OK || rc==E_OUTOFMEMORY, "CreateVertexBuffer returned: %x\n", rc);
if (!lpVBufDest1)
{
trace("IDirect3D7::CreateVertexBuffer() failed with an error %x\n", rc);
goto out;
}
memset(&desc, 0, sizeof(desc));
desc.dwSize = sizeof(desc);
desc.dwCaps = 0;
desc.dwFVF = D3DFVF_XYZ;
desc.dwNumVertices = 16;
/* Msdn says that the last parameter must be 0 - check that */
rc = IDirect3D7_CreateVertexBuffer(lpD3D, &desc, &lpVBufDest2, 12345678);
ok(rc==D3D_OK || rc==E_OUTOFMEMORY, "CreateVertexBuffer returned: %x\n", rc);
if (!lpVBufDest2)
{
trace("IDirect3D7::CreateVertexBuffer() failed with an error %x\n", rc);
goto out;
}
rc = IDirect3DVertexBuffer7_Lock(lpVBufSrc, 0, (void **) &in, NULL);
ok(rc==D3D_OK , "IDirect3DVertexBuffer::Lock returned: %x\n", rc);
if(!in) goto out;
/* Check basic transformation */
in[0].x = 0.0;
in[0].y = 0.0;
in[0].z = 0.0;
in[1].x = 1.0;
in[1].y = 1.0;
in[1].z = 1.0;
in[2].x = -1.0;
in[2].y = -1.0;
in[2].z = 0.5;
in[3].x = 0.5;
in[3].y = -0.5;
in[3].z = 0.25;
rc = IDirect3DVertexBuffer7_Unlock(lpVBufSrc);
ok(rc==D3D_OK , "IDirect3DVertexBuffer::Unlock returned: %x\n", rc);
rc = IDirect3DVertexBuffer7_ProcessVertices(lpVBufDest1, D3DVOP_TRANSFORM, 0, 4, lpVBufSrc, 0, lpD3DDevice, 0);
ok(rc==D3D_OK , "IDirect3DVertexBuffer::ProcessVertices returned: %x\n", rc);
rc = IDirect3DVertexBuffer7_ProcessVertices(lpVBufDest2, D3DVOP_TRANSFORM, 0, 4, lpVBufSrc, 0, lpD3DDevice, 0);
ok(rc==D3D_OK , "IDirect3DVertexBuffer::ProcessVertices returned: %x\n", rc);
rc = IDirect3DVertexBuffer7_Lock(lpVBufDest1, 0, (void **) &out, NULL);
ok(rc==D3D_OK , "IDirect3DVertexBuffer::Lock returned: %x\n", rc);
if(!out) goto out;
/* Check the results */
ok( comparefloat(out[0].x, 128.0 ) &&
comparefloat(out[0].y, 128.0 ) &&
comparefloat(out[0].z, 0.0 ) &&
comparefloat(out[0].rhw, 1.0 ),
"Output 0 vertex is (%f , %f , %f , %f)\n", out[0].x, out[0].y, out[0].z, out[0].rhw);
ok( comparefloat(out[1].x, 256.0 ) &&
comparefloat(out[1].y, 0.0 ) &&
comparefloat(out[1].z, 1.0 ) &&
comparefloat(out[1].rhw, 1.0 ),
"Output 1 vertex is (%f , %f , %f , %f)\n", out[1].x, out[1].y, out[1].z, out[1].rhw);
ok( comparefloat(out[2].x, 0.0 ) &&
comparefloat(out[2].y, 256.0 ) &&
comparefloat(out[2].z, 0.5 ) &&
comparefloat(out[2].rhw, 1.0 ),
"Output 2 vertex is (%f , %f , %f , %f)\n", out[2].x, out[2].y, out[2].z, out[2].rhw);
ok( comparefloat(out[3].x, 192.0 ) &&
comparefloat(out[3].y, 192.0 ) &&
comparefloat(out[3].z, 0.25 ) &&
comparefloat(out[3].rhw, 1.0 ),
"Output 3 vertex is (%f , %f , %f , %f)\n", out[3].x, out[3].y, out[3].z, out[3].rhw);
rc = IDirect3DVertexBuffer7_Unlock(lpVBufDest1);
ok(rc==D3D_OK , "IDirect3DVertexBuffer::Unlock returned: %x\n", rc);
out = NULL;
rc = IDirect3DVertexBuffer7_Lock(lpVBufDest2, 0, (void **) &out2, NULL);
ok(rc==D3D_OK , "IDirect3DVertexBuffer::Lock returned: %x\n", rc);
if(!out2) goto out;
/* Small thing without much practial meaning, but I stumbled upon it,
* so let's check for it: If the output vertex buffer has to RHW value,
* The RHW value of the last vertex is written into the next vertex
*/
ok( comparefloat(out2[4].x, 1.0 ) &&
comparefloat(out2[4].y, 0.0 ) &&
comparefloat(out2[4].z, 0.0 ),
"Output 4 vertex is (%f , %f , %f)\n", out2[4].x, out2[4].y, out2[4].z);
rc = IDirect3DVertexBuffer7_Unlock(lpVBufDest2);
ok(rc==D3D_OK , "IDirect3DVertexBuffer::Unlock returned: %x\n", rc);
out = NULL;
/* Try a more complicated viewport, same vertices */
memset(&vp, 0, sizeof(vp));
vp.dwX = 10;
vp.dwY = 5;
vp.dwWidth = 246;
vp.dwHeight = 130;
vp.dvMinZ = -2.0;
vp.dvMaxZ = 4.0;
rc = IDirect3DDevice7_SetViewport(lpD3DDevice, &vp);
ok(rc==D3D_OK, "IDirect3DDevice7_SetViewport failed with rc=%x\n", rc);
/* Process again */
rc = IDirect3DVertexBuffer7_ProcessVertices(lpVBufDest1, D3DVOP_TRANSFORM, 0, 4, lpVBufSrc, 0, lpD3DDevice, 0);
ok(rc==D3D_OK , "IDirect3DVertexBuffer::ProcessVertices returned: %x\n", rc);
rc = IDirect3DVertexBuffer7_Lock(lpVBufDest1, 0, (void **) &out, NULL);
ok(rc==D3D_OK , "IDirect3DVertexBuffer::Lock returned: %x\n", rc);
if(!out) goto out;
/* Check the results */
ok( comparefloat(out[0].x, 133.0 ) &&
comparefloat(out[0].y, 70.0 ) &&
comparefloat(out[0].z, -2.0 ) &&
comparefloat(out[0].rhw, 1.0 ),
"Output 0 vertex is (%f , %f , %f , %f)\n", out[0].x, out[0].y, out[0].z, out[0].rhw);
ok( comparefloat(out[1].x, 256.0 ) &&
comparefloat(out[1].y, 5.0 ) &&
comparefloat(out[1].z, 4.0 ) &&
comparefloat(out[1].rhw, 1.0 ),
"Output 1 vertex is (%f , %f , %f , %f)\n", out[1].x, out[1].y, out[1].z, out[1].rhw);
ok( comparefloat(out[2].x, 10.0 ) &&
comparefloat(out[2].y, 135.0 ) &&
comparefloat(out[2].z, 1.0 ) &&
comparefloat(out[2].rhw, 1.0 ),
"Output 2 vertex is (%f , %f , %f , %f)\n", out[1].x, out[1].y, out[1].z, out[1].rhw);
ok( comparefloat(out[3].x, 194.5 ) &&
comparefloat(out[3].y, 102.5 ) &&
comparefloat(out[3].z, -0.5 ) &&
comparefloat(out[3].rhw, 1.0 ),
"Output 3 vertex is (%f , %f , %f , %f)\n", out[3].x, out[3].y, out[3].z, out[3].rhw);
rc = IDirect3DVertexBuffer7_Unlock(lpVBufDest1);
ok(rc==D3D_OK , "IDirect3DVertexBuffer::Unlock returned: %x\n", rc);
out = NULL;
/* Play with some matrices. */
rc = IDirect3DDevice7_SetTransform(lpD3DDevice, D3DTRANSFORMSTATE_VIEW, &view);
ok(rc==D3D_OK, "IDirect3DDevice7_SetTransform failed\n");
rc = IDirect3DDevice7_SetTransform(lpD3DDevice, D3DTRANSFORMSTATE_PROJECTION, &proj);
ok(rc==D3D_OK, "IDirect3DDevice7_SetTransform failed\n");
rc = IDirect3DDevice7_SetTransform(lpD3DDevice, D3DTRANSFORMSTATE_WORLD, &world);
ok(rc==D3D_OK, "IDirect3DDevice7_SetTransform failed\n");
rc = IDirect3DVertexBuffer7_ProcessVertices(lpVBufDest1, D3DVOP_TRANSFORM, 0, 4, lpVBufSrc, 0, lpD3DDevice, 0);
ok(rc==D3D_OK , "IDirect3DVertexBuffer::ProcessVertices returned: %x\n", rc);
rc = IDirect3DVertexBuffer7_Lock(lpVBufDest1, 0, (void **) &out, NULL);
ok(rc==D3D_OK , "IDirect3DVertexBuffer::Lock returned: %x\n", rc);
if(!out) goto out;
/* Keep the viewport simpler, otherwise we get bad numbers to compare */
vp.dwX = 0;
vp.dwY = 0;
vp.dwWidth = 100;
vp.dwHeight = 100;
vp.dvMinZ = 1.0;
vp.dvMaxZ = 0.0;
rc = IDirect3DDevice7_SetViewport(lpD3DDevice, &vp);
ok(rc==D3D_OK, "IDirect3DDevice7_SetViewport failed\n");
/* Check the results */
ok( comparefloat(out[0].x, 256.0 ) && /* X coordinate is cut at the surface edges */
comparefloat(out[0].y, 70.0 ) &&
comparefloat(out[0].z, -2.0 ) &&
comparefloat(out[0].rhw, (1.0 / 3.0)),
"Output 0 vertex is (%f , %f , %f , %f)\n", out[0].x, out[0].y, out[0].z, out[0].rhw);
ok( comparefloat(out[1].x, 256.0 ) &&
comparefloat(out[1].y, 78.125000 ) &&
comparefloat(out[1].z, -2.750000 ) &&
comparefloat(out[1].rhw, 0.125000 ),
"Output 1 vertex is (%f , %f , %f , %f)\n", out[1].x, out[1].y, out[1].z, out[1].rhw);
ok( comparefloat(out[2].x, 256.0 ) &&
comparefloat(out[2].y, 44.000000 ) &&
comparefloat(out[2].z, 0.400000 ) &&
comparefloat(out[2].rhw, 0.400000 ),
"Output 2 vertex is (%f , %f , %f , %f)\n", out[2].x, out[2].y, out[2].z, out[2].rhw);
ok( comparefloat(out[3].x, 256.0 ) &&
comparefloat(out[3].y, 81.818184 ) &&
comparefloat(out[3].z, -3.090909 ) &&
comparefloat(out[3].rhw, 0.363636 ),
"Output 3 vertex is (%f , %f , %f , %f)\n", out[3].x, out[3].y, out[3].z, out[3].rhw);
rc = IDirect3DVertexBuffer7_Unlock(lpVBufDest1);
ok(rc==D3D_OK , "IDirect3DVertexBuffer::Unlock returned: %x\n", rc);
out = NULL;
out:
IDirect3DVertexBuffer7_Release(lpVBufSrc);
IDirect3DVertexBuffer7_Release(lpVBufDest1);
IDirect3DVertexBuffer7_Release(lpVBufDest2);
}
static void StateTest( void )
{
HRESULT rc;
/* The msdn says its undocumented, does it return an error too? */
rc = IDirect3DDevice7_SetRenderState(lpD3DDevice, D3DRENDERSTATE_ZVISIBLE, TRUE);
ok(rc == D3D_OK, "IDirect3DDevice7_SetRenderState(D3DRENDERSTATE_ZVISIBLE, TRUE) returned %08x\n", rc);
rc = IDirect3DDevice7_SetRenderState(lpD3DDevice, D3DRENDERSTATE_ZVISIBLE, FALSE);
ok(rc == D3D_OK, "IDirect3DDevice7_SetRenderState(D3DRENDERSTATE_ZVISIBLE, FALSE) returned %08x\n", rc);
}
static void SceneTest(void)
{
HRESULT hr;
/* Test an EndScene without beginscene. Should return an error */
hr = IDirect3DDevice7_EndScene(lpD3DDevice);
ok(hr == D3DERR_SCENE_NOT_IN_SCENE, "IDirect3DDevice7_EndScene returned %08x\n", hr);
/* Test a normal BeginScene / EndScene pair, this should work */
hr = IDirect3DDevice7_BeginScene(lpD3DDevice);
ok(hr == D3D_OK, "IDirect3DDevice7_BeginScene failed with %08x\n", hr);
if(SUCCEEDED(hr))
{
hr = IDirect3DDevice7_EndScene(lpD3DDevice);
ok(hr == D3D_OK, "IDirect3DDevice7_EndScene failed with %08x\n", hr);
}
/* Test another EndScene without having begun a new scene. Should return an error */
hr = IDirect3DDevice7_EndScene(lpD3DDevice);
ok(hr == D3DERR_SCENE_NOT_IN_SCENE, "IDirect3DDevice7_EndScene returned %08x\n", hr);
/* Two nested BeginScene and EndScene calls */
hr = IDirect3DDevice7_BeginScene(lpD3DDevice);
ok(hr == D3D_OK, "IDirect3DDevice7_BeginScene failed with %08x\n", hr);
hr = IDirect3DDevice7_BeginScene(lpD3DDevice);
ok(hr == D3DERR_SCENE_IN_SCENE, "IDirect3DDevice7_BeginScene returned %08x\n", hr);
hr = IDirect3DDevice7_EndScene(lpD3DDevice);
ok(hr == D3D_OK, "IDirect3DDevice7_EndScene failed with %08x\n", hr);
hr = IDirect3DDevice7_EndScene(lpD3DDevice);
ok(hr == D3DERR_SCENE_NOT_IN_SCENE, "IDirect3DDevice7_EndScene returned %08x\n", hr);
/* TODO: Verify that blitting works in the same way as in d3d9 */
}
static void LimitTest(void)
{
IDirectDrawSurface7 *pTexture = NULL;
HRESULT hr;
int i;
DDSURFACEDESC2 ddsd;
memset(&ddsd, 0, sizeof(ddsd));
ddsd.dwSize = sizeof(ddsd);
ddsd.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT;
ddsd.ddsCaps.dwCaps = DDSCAPS_TEXTURE;
ddsd.dwWidth = 16;
ddsd.dwHeight = 16;
hr = IDirectDraw7_CreateSurface(lpDD, &ddsd, &pTexture, NULL);
ok(hr==DD_OK,"CreateSurface returned: %x\n",hr);
if(!pTexture) return;
for(i = 0; i < 8; i++) {
hr = IDirect3DDevice7_SetTexture(lpD3DDevice, i, pTexture);
ok(hr == D3D_OK, "IDirect3DDevice8_SetTexture for sampler %d failed with %08x\n", i, hr);
hr = IDirect3DDevice7_SetTexture(lpD3DDevice, i, NULL);
ok(hr == D3D_OK, "IDirect3DDevice8_SetTexture for sampler %d failed with %08x\n", i, hr);
hr = IDirect3DDevice7_SetTextureStageState(lpD3DDevice, i, D3DTSS_COLOROP, D3DTOP_ADD);
ok(hr == D3D_OK, "IDirect3DDevice8_SetTextureStageState for texture %d failed with %08x\n", i, hr);
}
IDirectDrawSurface7_Release(pTexture);
}
START_TEST(d3d)
{
init_function_pointers();
if(!pDirectDrawCreateEx) {
trace("function DirectDrawCreateEx not available, skipping tests\n");
return;
}
if(!CreateDirect3D()) {
trace("Skipping tests\n");
return;
}
LightTest();
ProcessVerticesTest();
StateTest();
SceneTest();
LimitTest();
ReleaseDirect3D();
}

View File

@@ -0,0 +1,122 @@
# Microsoft Developer Studio Project File - Name="ddraw_test" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Console Application" 0x0103
CFG=ddraw_test - Win32 Debug
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
!MESSAGE
!MESSAGE NMAKE /f "ddraw_test.mak".
!MESSAGE
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "ddraw_test.mak" CFG="ddraw_test - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "ddraw_test - Win32 Release" (based on "Win32 (x86) Console Application")
!MESSAGE "ddraw_test - Win32 Debug" (based on "Win32 (x86) Console Application")
!MESSAGE
# Begin Project
# PROP AllowPerConfigDependencies 0
# PROP Scc_ProjName ""
# PROP Scc_LocalPath ""
CPP=xicl6.exe
RSC=rc.exe
!IF "$(CFG)" == "ddraw_test - Win32 Release"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Release"
# PROP BASE Intermediate_Dir "Release"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "Release"
# PROP Intermediate_Dir "Release"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
# ADD CPP /nologo /MD /W3 /GX /Zi /O2 /I "..\..\..\include" /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "__WINESRC__" /YX /FD /c
# ADD BASE RSC /l 0x419 /d "NDEBUG"
# ADD RSC /l 0x419 /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=xilink6.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
# ADD LINK32 kernel32.lib user32.lib gdi32.lib uuid.lib dxguid.lib ddraw.lib /nologo /subsystem:console /pdb:"../../../bin/ddraw_test.pdb" /debug /machine:I386 /out:"../../../bin/ddraw_test.exe"
!ELSEIF "$(CFG)" == "ddraw_test - Win32 Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "Debug"
# PROP BASE Intermediate_Dir "Debug"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "Debug"
# PROP Intermediate_Dir "Debug"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "..\..\..\include" /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "__WINESRC__" /YX /FD /GZ /c
# ADD BASE RSC /l 0x419 /d "_DEBUG"
# ADD RSC /l 0x419 /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=xilink6.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
# ADD LINK32 kernel32.lib user32.lib gdi32.lib uuid.lib dxguid.lib ddraw.lib /nologo /subsystem:console /pdb:"../../../bin/ddraw_test.pdb" /debug /machine:I386 /out:"../../../bin/ddraw_test.exe" /pdbtype:sept
!ENDIF
# Begin Target
# Name "ddraw_test - Win32 Release"
# Name "ddraw_test - Win32 Debug"
# Begin Group "Source Files"
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
# Begin Source File
SOURCE=.\d3d.c
# End Source File
# Begin Source File
SOURCE=.\ddrawmodes.c
# End Source File
# Begin Source File
SOURCE=.\dsurface.c
# End Source File
# Begin Source File
SOURCE=.\refcount.c
# End Source File
# Begin Source File
SOURCE=.\tests.c
# End Source File
# Begin Source File
SOURCE=.\visual.c
# End Source File
# End Group
# Begin Group "Header Files"
# PROP Default_Filter "h;hpp;hxx;hm;inl"
# End Group
# Begin Group "Resource Files"
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
# End Group
# End Target
# End Project

View File

@@ -0,0 +1,384 @@
/*
* Unit tests for ddraw functions
*
*
* Part of this test involves changing the screen resolution. But this is
* really disrupting if the user is doing something else and is not very nice
* to CRT screens. Plus, ideally it needs someone watching it to check that
* each mode displays correctly.
* So this is only done if the test is being run in interactive mode.
*
* Copyright (C) 2003 Sami Aario
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <assert.h>
#include "wine/test.h"
#include "ddraw.h"
static LPDIRECTDRAW lpDD = NULL;
static LPDIRECTDRAWSURFACE lpDDSPrimary = NULL;
static LPDIRECTDRAWSURFACE lpDDSBack = NULL;
static WNDCLASS wc;
static HWND hwnd;
static int modes_cnt;
static int modes_size;
static LPDDSURFACEDESC modes;
static void createwindow(void)
{
wc.style = CS_HREDRAW | CS_VREDRAW;
wc.lpfnWndProc = DefWindowProcA;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = GetModuleHandleA(0);
wc.hIcon = LoadIconA(wc.hInstance, IDI_APPLICATION);
wc.hCursor = LoadCursorA(NULL, IDC_ARROW);
wc.hbrBackground = (HBRUSH) GetStockObject(BLACK_BRUSH);
wc.lpszMenuName = NULL;
wc.lpszClassName = "TestWindowClass";
if(!RegisterClassA(&wc))
assert(0);
hwnd = CreateWindowExA(0, "TestWindowClass", "TestWindowClass",
WS_POPUP, 0, 0,
GetSystemMetrics(SM_CXSCREEN),
GetSystemMetrics(SM_CYSCREEN),
NULL, NULL, GetModuleHandleA(0), NULL);
assert(hwnd != NULL);
ShowWindow(hwnd, SW_HIDE);
UpdateWindow(hwnd);
SetFocus(hwnd);
}
static BOOL createdirectdraw(void)
{
HRESULT rc;
rc = DirectDrawCreate(NULL, &lpDD, NULL);
ok(rc==DD_OK || rc==DDERR_NODIRECTDRAWSUPPORT, "DirectDrawCreateEx returned: %x\n", rc);
if (!lpDD) {
trace("DirectDrawCreateEx() failed with an error %x\n", rc);
return FALSE;
}
return TRUE;
}
static void releasedirectdraw(void)
{
if( lpDD != NULL )
{
IDirectDraw_Release(lpDD);
lpDD = NULL;
}
}
static void adddisplaymode(LPDDSURFACEDESC lpddsd)
{
if (!modes)
modes = malloc((modes_size = 2) * sizeof(DDSURFACEDESC));
if (modes_cnt == modes_size)
modes = realloc(modes, (modes_size *= 2) * sizeof(DDSURFACEDESC));
assert(modes);
modes[modes_cnt++] = *lpddsd;
}
static void flushdisplaymodes(void)
{
free(modes);
modes = 0;
modes_cnt = modes_size = 0;
}
static HRESULT WINAPI enummodescallback(LPDDSURFACEDESC lpddsd, LPVOID lpContext)
{
trace("Width = %i, Height = %i, Refresh Rate = %i\r\n",
lpddsd->dwWidth, lpddsd->dwHeight,
U2(*lpddsd).dwRefreshRate);
adddisplaymode(lpddsd);
return DDENUMRET_OK;
}
static void enumdisplaymodes(void)
{
DDSURFACEDESC ddsd;
HRESULT rc;
ZeroMemory(&ddsd, sizeof(DDSURFACEDESC));
ddsd.dwSize = sizeof(DDSURFACEDESC);
ddsd.dwFlags = DDSD_CAPS;
ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
rc = IDirectDraw_EnumDisplayModes(lpDD,
DDEDM_STANDARDVGAMODES, &ddsd, 0, enummodescallback);
ok(rc==DD_OK || rc==E_INVALIDARG,"EnumDisplayModes returned: %x\n",rc);
}
static void setdisplaymode(int i)
{
HRESULT rc;
rc = IDirectDraw_SetCooperativeLevel(lpDD,
hwnd, DDSCL_ALLOWMODEX | DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
ok(rc==DD_OK,"SetCooperativeLevel returned: %x\n",rc);
if (modes[i].dwFlags & DDSD_PIXELFORMAT)
{
if (modes[i].ddpfPixelFormat.dwFlags & DDPF_RGB)
{
rc = IDirectDraw_SetDisplayMode(lpDD,
modes[i].dwWidth, modes[i].dwHeight,
U1(modes[i].ddpfPixelFormat).dwRGBBitCount);
ok(DD_OK==rc || DDERR_UNSUPPORTED==rc,"SetDisplayMode returned: %x\n",rc);
if (rc == DD_OK)
{
RECT r, scrn, virt;
SetRect(&virt, 0, 0, GetSystemMetrics(SM_CXVIRTUALSCREEN), GetSystemMetrics(SM_CYVIRTUALSCREEN));
OffsetRect(&virt, GetSystemMetrics(SM_XVIRTUALSCREEN), GetSystemMetrics(SM_YVIRTUALSCREEN));
SetRect(&scrn, 0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN));
trace("Mode (%dx%d) [%dx%d] (%d %d)x(%d %d)\n", modes[i].dwWidth, modes[i].dwHeight,
scrn.right, scrn.bottom, virt.left, virt.top, virt.right, virt.bottom);
ok(GetClipCursor(&r), "GetClipCursor() failed\n");
/* ddraw sets clip rect here to the screen size, even for
multiple monitors */
ok(EqualRect(&r, &scrn), "Invalid clip rect: (%d %d) x (%d %d)\n",
r.left, r.top, r.right, r.bottom);
ok(ClipCursor(NULL), "ClipCursor() failed\n");
ok(GetClipCursor(&r), "GetClipCursor() failed\n");
ok(EqualRect(&r, &virt), "Invalid clip rect: (%d %d) x (%d %d)\n",
r.left, r.top, r.right, r.bottom);
rc = IDirectDraw_RestoreDisplayMode(lpDD);
ok(DD_OK==rc,"RestoreDisplayMode returned: %x\n",rc);
}
}
}
}
static void createsurface(void)
{
DDSURFACEDESC ddsd;
DDSCAPS ddscaps;
HRESULT rc;
ddsd.dwSize = sizeof(ddsd);
ddsd.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT;
ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE |
DDSCAPS_FLIP |
DDSCAPS_COMPLEX;
ddsd.dwBackBufferCount = 1;
rc = IDirectDraw_CreateSurface(lpDD, &ddsd, &lpDDSPrimary, NULL );
ok(rc==DD_OK,"CreateSurface returned: %x\n",rc);
ddscaps.dwCaps = DDSCAPS_BACKBUFFER;
rc = IDirectDrawSurface_GetAttachedSurface(lpDDSPrimary, &ddscaps, &lpDDSBack);
ok(rc==DD_OK,"GetAttachedSurface returned: %x\n",rc);
}
static void destroysurface(void)
{
if( lpDDSPrimary != NULL )
{
IDirectDrawSurface_Release(lpDDSPrimary);
lpDDSPrimary = NULL;
}
}
static void testsurface(void)
{
const char* testMsg = "ddraw device context test";
HDC hdc;
HRESULT rc;
rc = IDirectDrawSurface_GetDC(lpDDSBack, &hdc);
ok(rc==DD_OK, "IDirectDrawSurface_GetDC returned: %x\n",rc);
SetBkColor(hdc, RGB(0, 0, 255));
SetTextColor(hdc, RGB(255, 255, 0));
TextOut(hdc, 0, 0, testMsg, lstrlen(testMsg));
IDirectDrawSurface_ReleaseDC(lpDDSBack, hdc);
ok(rc==DD_OK, "IDirectDrawSurface_ReleaseDC returned: %x\n",rc);
while (1)
{
rc = IDirectDrawSurface_Flip(lpDDSPrimary, NULL, DDFLIP_WAIT);
ok(rc==DD_OK || rc==DDERR_SURFACELOST, "IDirectDrawSurface_BltFast returned: %x\n",rc);
if (rc == DD_OK)
{
break;
}
else if (rc == DDERR_SURFACELOST)
{
rc = IDirectDrawSurface_Restore(lpDDSPrimary);
ok(rc==DD_OK, "IDirectDrawSurface_Restore returned: %x\n",rc);
}
}
}
static void testdisplaymodes(void)
{
int i;
for (i = 0; i < modes_cnt; ++i)
{
setdisplaymode(i);
createsurface();
testsurface();
destroysurface();
}
}
static void testcooperativelevels_normal(void)
{
HRESULT rc;
DDSURFACEDESC surfacedesc;
IDirectDrawSurface *surface = (IDirectDrawSurface *) 0xdeadbeef;
memset(&surfacedesc, 0, sizeof(surfacedesc));
surfacedesc.dwSize = sizeof(surfacedesc);
surfacedesc.ddpfPixelFormat.dwSize = sizeof(surfacedesc.ddpfPixelFormat);
surfacedesc.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT;
surfacedesc.dwBackBufferCount = 1;
surfacedesc.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_COMPLEX | DDSCAPS_FLIP;
/* Do some tests with DDSCL_NORMAL mode */
rc = IDirectDraw_SetCooperativeLevel(lpDD,
hwnd, DDSCL_NORMAL);
ok(rc==DD_OK,"SetCooperativeLevel(DDSCL_NORMAL) returned: %x\n",rc);
/* Try creating a double buffered primary in normal mode */
rc = IDirectDraw_CreateSurface(lpDD, &surfacedesc, &surface, NULL);
ok(rc == DDERR_NOEXCLUSIVEMODE, "IDirectDraw_CreateSurface returned %08x\n", rc);
ok(surface == NULL, "Returned surface pointer is %p\n", surface);
if(surface) IDirectDrawSurface_Release(surface);
/* Set the focus window */
rc = IDirectDraw_SetCooperativeLevel(lpDD,
hwnd, DDSCL_SETFOCUSWINDOW);
ok(rc==DD_OK,"SetCooperativeLevel(DDSCL_SETFOCUSWINDOW) returned: %x\n",rc);
/* Set the focus window a second time*/
rc = IDirectDraw_SetCooperativeLevel(lpDD,
hwnd, DDSCL_SETFOCUSWINDOW);
ok(rc==DD_OK,"SetCooperativeLevel(DDSCL_SETFOCUSWINDOW) the second time returned: %x\n",rc);
/* Test DDSCL_SETFOCUSWINDOW with the other flags. They should all fail, except of DDSCL_NOWINDOWCHANGES */
rc = IDirectDraw_SetCooperativeLevel(lpDD,
hwnd, DDSCL_NORMAL | DDSCL_SETFOCUSWINDOW);
ok(rc==DDERR_INVALIDPARAMS,"SetCooperativeLevel(DDSCL_NORMAL | DDSCL_SETFOCUSWINDOW) returned: %x\n",rc);
rc = IDirectDraw_SetCooperativeLevel(lpDD,
hwnd, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN | DDSCL_SETFOCUSWINDOW);
ok(rc==DDERR_INVALIDPARAMS,"SetCooperativeLevel(DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN | DDSCL_SETFOCUSWINDOW) returned: %x\n",rc);
/* This one succeeds */
rc = IDirectDraw_SetCooperativeLevel(lpDD,
hwnd, DDSCL_NOWINDOWCHANGES | DDSCL_SETFOCUSWINDOW);
ok(rc==DD_OK,"SetCooperativeLevel(DDSCL_NOWINDOWCHANGES | DDSCL_SETFOCUSWINDOW) returned: %x\n",rc);
rc = IDirectDraw_SetCooperativeLevel(lpDD,
hwnd, DDSCL_MULTITHREADED | DDSCL_SETFOCUSWINDOW);
ok(rc==DDERR_INVALIDPARAMS,"SetCooperativeLevel(DDSCL_MULTITHREADED | DDSCL_SETFOCUSWINDOW) returned: %x\n",rc);
rc = IDirectDraw_SetCooperativeLevel(lpDD,
hwnd, DDSCL_FPUSETUP | DDSCL_SETFOCUSWINDOW);
ok(rc==DDERR_INVALIDPARAMS,"SetCooperativeLevel(DDSCL_FPUSETUP | DDSCL_SETFOCUSWINDOW) returned: %x\n",rc);
rc = IDirectDraw_SetCooperativeLevel(lpDD,
hwnd, DDSCL_FPUPRESERVE | DDSCL_SETFOCUSWINDOW);
ok(rc==DDERR_INVALIDPARAMS,"SetCooperativeLevel(DDSCL_FPUPRESERVE | DDSCL_SETFOCUSWINDOW) returned: %x\n",rc);
rc = IDirectDraw_SetCooperativeLevel(lpDD,
hwnd, DDSCL_ALLOWREBOOT | DDSCL_SETFOCUSWINDOW);
ok(rc==DDERR_INVALIDPARAMS,"SetCooperativeLevel(DDSCL_ALLOWREBOOT | DDSCL_SETFOCUSWINDOW) returned: %x\n",rc);
rc = IDirectDraw_SetCooperativeLevel(lpDD,
hwnd, DDSCL_ALLOWMODEX | DDSCL_SETFOCUSWINDOW);
ok(rc==DDERR_INVALIDPARAMS,"SetCooperativeLevel(DDSCL_ALLOWMODEX | DDSCL_SETFOCUSWINDOW) returned: %x\n",rc);
/* Set the device window without any other flags. Should give an error */
rc = IDirectDraw_SetCooperativeLevel(lpDD,
hwnd, DDSCL_SETDEVICEWINDOW);
ok(rc==DDERR_INVALIDPARAMS,"SetCooperativeLevel(DDSCL_SETDEVICEWINDOW) returned: %x\n",rc);
/* Set device window with DDSCL_NORMAL */
rc = IDirectDraw_SetCooperativeLevel(lpDD,
hwnd, DDSCL_NORMAL | DDSCL_SETDEVICEWINDOW);
ok(rc==DD_OK,"SetCooperativeLevel(DDSCL_NORMAL | DDSCL_SETDEVICEWINDOW) returned: %x\n",rc);
/* Also set the focus window. Should give an error */
rc = IDirectDraw_SetCooperativeLevel(lpDD,
hwnd, DDSCL_ALLOWMODEX | DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN | DDSCL_SETDEVICEWINDOW | DDSCL_SETFOCUSWINDOW);
ok(rc==DDERR_INVALIDPARAMS,"SetCooperativeLevel(DDSCL_NORMAL | DDSCL_SETDEVICEWINDOW | DDSCL_SETFOCUSWINDOW) returned: %x\n",rc);
/* All done */
}
static void testcooperativelevels_exclusive(void)
{
HRESULT rc;
/* Do some tests with DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN mode */
/* Try to set exclusive mode only */
rc = IDirectDraw_SetCooperativeLevel(lpDD,
hwnd, DDSCL_EXCLUSIVE);
ok(rc==DDERR_INVALIDPARAMS,"SetCooperativeLevel(DDSCL_EXCLUSIVE) returned: %x\n",rc);
/* Full screen mode only */
rc = IDirectDraw_SetCooperativeLevel(lpDD,
hwnd, DDSCL_FULLSCREEN);
ok(rc==DDERR_INVALIDPARAMS,"SetCooperativeLevel(DDSCL_FULLSCREEN) returned: %x\n",rc);
/* Full screen mode + exclusive mode */
rc = IDirectDraw_SetCooperativeLevel(lpDD,
hwnd, DDSCL_FULLSCREEN | DDSCL_EXCLUSIVE);
ok(rc==DD_OK,"SetCooperativeLevel(DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN) returned: %x\n",rc);
/* Set the focus window. Should fail */
rc = IDirectDraw_SetCooperativeLevel(lpDD,
hwnd, DDSCL_SETFOCUSWINDOW);
ok(rc==DDERR_HWNDALREADYSET,"SetCooperativeLevel(DDSCL_SETFOCUSWINDOW) returned: %x\n",rc);
/* All done */
}
START_TEST(ddrawmodes)
{
createwindow();
if (!createdirectdraw())
return;
enumdisplaymodes();
if (winetest_interactive)
testdisplaymodes();
flushdisplaymodes();
releasedirectdraw();
createdirectdraw();
testcooperativelevels_normal();
releasedirectdraw();
createdirectdraw();
testcooperativelevels_exclusive();
releasedirectdraw();
}

View File

@@ -0,0 +1,959 @@
/*
* Unit tests for (a few) ddraw surface functions
*
* Copyright (C) 2005 Antoine Chavasse (a.chavasse@gmail.com)
* Copyright (C) 2005 Christian Costa
* Copyright 2005 Ivan Leo Puoti
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#define COBJMACROS
#include <assert.h>
#include "wine/test.h"
#include "ddraw.h"
#include "unknwn.h"
static LPDIRECTDRAW lpDD = NULL;
static BOOL CreateDirectDraw(void)
{
HRESULT rc;
rc = DirectDrawCreate(NULL, &lpDD, NULL);
ok(rc==DD_OK || rc==DDERR_NODIRECTDRAWSUPPORT, "DirectDrawCreateEx returned: %x\n", rc);
if (!lpDD) {
trace("DirectDrawCreateEx() failed with an error %x\n", rc);
return FALSE;
}
rc = IDirectDraw_SetCooperativeLevel(lpDD, NULL, DDSCL_NORMAL);
ok(rc==DD_OK,"SetCooperativeLevel returned: %x\n",rc);
return TRUE;
}
static void ReleaseDirectDraw(void)
{
if( lpDD != NULL )
{
IDirectDraw_Release(lpDD);
lpDD = NULL;
}
}
static void MipMapCreationTest(void)
{
LPDIRECTDRAWSURFACE lpDDSMipMapTest;
DDSURFACEDESC ddsd;
HRESULT rc;
/* First mipmap creation test: create a surface with DDSCAPS_COMPLEX,
DDSCAPS_MIPMAP, and DDSD_MIPMAPCOUNT. This create the number of
requested mipmap levels. */
ddsd.dwSize = sizeof(ddsd);
ddsd.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | DDSD_MIPMAPCOUNT;
ddsd.ddsCaps.dwCaps = DDSCAPS_TEXTURE | DDSCAPS_COMPLEX | DDSCAPS_MIPMAP;
U2(ddsd).dwMipMapCount = 3;
ddsd.dwWidth = 128;
ddsd.dwHeight = 32;
rc = IDirectDraw_CreateSurface(lpDD, &ddsd, &lpDDSMipMapTest, NULL);
ok(rc==DD_OK,"CreateSurface returned: %x\n",rc);
/* Check the number of created mipmaps */
memset(&ddsd, 0, sizeof(DDSURFACEDESC));
ddsd.dwSize = sizeof(ddsd);
rc = IDirectDrawSurface_GetSurfaceDesc(lpDDSMipMapTest, &ddsd);
ok(rc==DD_OK,"GetSurfaceDesc returned: %x\n",rc);
ok(ddsd.dwFlags & DDSD_MIPMAPCOUNT,
"GetSurfaceDesc returned no mipmapcount.\n");
ok(U2(ddsd).dwMipMapCount == 3, "Incorrect mipmap count: %d.\n",
U2(ddsd).dwMipMapCount);
/* Destroy the surface. */
IDirectDrawSurface_Release(lpDDSMipMapTest);
/* Second mipmap creation test: create a surface without a mipmap
count, with DDSCAPS_MIPMAP and without DDSCAPS_COMPLEX.
This creates a single mipmap level. */
memset(&ddsd, 0, sizeof(DDSURFACEDESC));
ddsd.dwSize = sizeof(ddsd);
ddsd.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT;
ddsd.ddsCaps.dwCaps = DDSCAPS_TEXTURE | DDSCAPS_MIPMAP;
ddsd.dwWidth = 128;
ddsd.dwHeight = 32;
rc = IDirectDraw_CreateSurface(lpDD, &ddsd, &lpDDSMipMapTest, NULL);
ok(rc==DD_OK,"CreateSurface returned: %x\n",rc);
/* Check the number of created mipmaps */
memset(&ddsd, 0, sizeof(DDSURFACEDESC));
ddsd.dwSize = sizeof(ddsd);
rc = IDirectDrawSurface_GetSurfaceDesc(lpDDSMipMapTest, &ddsd);
ok(rc==DD_OK,"GetSurfaceDesc returned: %x\n",rc);
ok(ddsd.dwFlags & DDSD_MIPMAPCOUNT,
"GetSurfaceDesc returned no mipmapcount.\n");
ok(U2(ddsd).dwMipMapCount == 1, "Incorrect mipmap count: %d.\n",
U2(ddsd).dwMipMapCount);
/* Destroy the surface. */
IDirectDrawSurface_Release(lpDDSMipMapTest);
/* Third mipmap creation test: create a surface with DDSCAPS_MIPMAP,
DDSCAPS_COMPLEX and without DDSD_MIPMAPCOUNT.
It's an undocumented features where a chain of mipmaps, starting from
he specified size and down to the smallest size, is automatically
created.
Anarchy Online needs this feature to work. */
memset(&ddsd, 0, sizeof(DDSURFACEDESC));
ddsd.dwSize = sizeof(ddsd);
ddsd.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT;
ddsd.ddsCaps.dwCaps = DDSCAPS_TEXTURE | DDSCAPS_COMPLEX | DDSCAPS_MIPMAP;
ddsd.dwWidth = 128;
ddsd.dwHeight = 32;
rc = IDirectDraw_CreateSurface(lpDD, &ddsd, &lpDDSMipMapTest, NULL);
ok(rc==DD_OK,"CreateSurface returned: %x\n",rc);
/* Check the number of created mipmaps */
memset(&ddsd, 0, sizeof(DDSURFACEDESC));
ddsd.dwSize = sizeof(ddsd);
rc = IDirectDrawSurface_GetSurfaceDesc(lpDDSMipMapTest, &ddsd);
ok(rc==DD_OK,"GetSurfaceDesc returned: %x\n",rc);
ok(ddsd.dwFlags & DDSD_MIPMAPCOUNT,
"GetSurfaceDesc returned no mipmapcount.\n");
ok(U2(ddsd).dwMipMapCount == 6, "Incorrect mipmap count: %d.\n",
U2(ddsd).dwMipMapCount);
/* Destroy the surface. */
IDirectDrawSurface_Release(lpDDSMipMapTest);
/* Fourth mipmap creation test: same as above with a different texture
size.
The purpose is to verify that the number of generated mipmaps is
dependent on the smallest dimension. */
memset(&ddsd, 0, sizeof(DDSURFACEDESC));
ddsd.dwSize = sizeof(ddsd);
ddsd.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT;
ddsd.ddsCaps.dwCaps = DDSCAPS_TEXTURE | DDSCAPS_COMPLEX | DDSCAPS_MIPMAP;
ddsd.dwWidth = 32;
ddsd.dwHeight = 64;
rc = IDirectDraw_CreateSurface(lpDD, &ddsd, &lpDDSMipMapTest, NULL);
ok(rc==DD_OK,"CreateSurface returned: %x\n",rc);
/* Check the number of created mipmaps */
memset(&ddsd, 0, sizeof(DDSURFACEDESC));
ddsd.dwSize = sizeof(ddsd);
rc = IDirectDrawSurface_GetSurfaceDesc(lpDDSMipMapTest, &ddsd);
ok(rc==DD_OK,"GetSurfaceDesc returned: %x\n",rc);
ok(ddsd.dwFlags & DDSD_MIPMAPCOUNT,
"GetSurfaceDesc returned no mipmapcount.\n");
ok(U2(ddsd).dwMipMapCount == 6, "Incorrect mipmap count: %d.\n",
U2(ddsd).dwMipMapCount);
/* Destroy the surface. */
IDirectDrawSurface_Release(lpDDSMipMapTest);
}
static void SrcColorKey32BlitTest(void)
{
LPDIRECTDRAWSURFACE lpSrc;
LPDIRECTDRAWSURFACE lpDst;
DDSURFACEDESC ddsd;
DDSURFACEDESC ddsd2;
DDCOLORKEY DDColorKey;
LPDWORD lpData;
HRESULT rc;
DDBLTFX fx;
ddsd2.dwSize = sizeof(ddsd2);
ddsd2.ddpfPixelFormat.dwSize = sizeof(ddsd2.ddpfPixelFormat);
ddsd.dwSize = sizeof(ddsd);
ddsd.ddpfPixelFormat.dwSize = sizeof(ddsd.ddpfPixelFormat);
ddsd.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | DDSD_PIXELFORMAT;
ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
ddsd.dwWidth = 800;
ddsd.dwHeight = 600;
ddsd.ddpfPixelFormat.dwFlags = DDPF_RGB;
U1(ddsd.ddpfPixelFormat).dwRGBBitCount = 32;
U2(ddsd.ddpfPixelFormat).dwRBitMask = 0xFF0000;
U3(ddsd.ddpfPixelFormat).dwGBitMask = 0x00FF00;
U4(ddsd.ddpfPixelFormat).dwBBitMask = 0x0000FF;
rc = IDirectDraw_CreateSurface(lpDD, &ddsd, &lpDst, NULL);
ok(rc==DD_OK,"CreateSurface returned: %x\n",rc);
ddsd.dwFlags |= DDSD_CKSRCBLT;
ddsd.ddckCKSrcBlt.dwColorSpaceLowValue = 0xFF00FF;
ddsd.ddckCKSrcBlt.dwColorSpaceHighValue = 0xFF00FF;
rc = IDirectDraw_CreateSurface(lpDD, &ddsd, &lpSrc, NULL);
ok(rc==DD_OK,"CreateSurface returned: %x\n",rc);
rc = IDirectDrawSurface_Lock(lpDst, NULL, &ddsd2, DDLOCK_WAIT, NULL);
ok(rc==DD_OK,"Lock returned: %x\n",rc);
lpData = (LPDWORD)ddsd2.lpSurface;
lpData[0] = 0xCCCCCCCC;
lpData[1] = 0xCCCCCCCC;
lpData[2] = 0xCCCCCCCC;
lpData[3] = 0xCCCCCCCC;
rc = IDirectDrawSurface_Unlock(lpDst, NULL);
ok(rc==DD_OK,"Unlock returned: %x\n",rc);
rc = IDirectDrawSurface_Lock(lpSrc, NULL, &ddsd2, DDLOCK_WAIT, NULL);
ok(rc==DD_OK,"Lock returned: %x\n",rc);
lpData = (LPDWORD)ddsd2.lpSurface;
lpData[0] = 0x77010203;
lpData[1] = 0x00010203;
lpData[2] = 0x77FF00FF;
lpData[3] = 0x00FF00FF;
rc = IDirectDrawSurface_Unlock(lpSrc, NULL);
ok(rc==DD_OK,"Unlock returned: %x\n",rc);
IDirectDrawSurface_Blt(lpDst, NULL, lpSrc, NULL, DDBLT_KEYSRC, NULL);
rc = IDirectDrawSurface_Lock(lpDst, NULL, &ddsd2, DDLOCK_WAIT, NULL);
ok(rc==DD_OK,"Lock returned: %x\n",rc);
lpData = (LPDWORD)ddsd2.lpSurface;
ok((lpData[0]==0x77010203)&&(lpData[1]==0x00010203)&&(lpData[2]==0xCCCCCCCC)&&(lpData[3]==0xCCCCCCCC),
"Destination data after blitting is not correct\n");
rc = IDirectDrawSurface_Unlock(lpDst, NULL);
ok(rc==DD_OK,"Unlock returned: %x\n",rc);
/* Also test SetColorKey */
IDirectDrawSurface_GetColorKey(lpSrc, DDCKEY_SRCBLT, &DDColorKey);
ok(DDColorKey.dwColorSpaceLowValue == 0xFF00FF && DDColorKey.dwColorSpaceHighValue == 0xFF00FF,
"GetColorKey does not return the colorkey used at surface creation\n");
DDColorKey.dwColorSpaceLowValue = 0x00FF00;
DDColorKey.dwColorSpaceHighValue = 0x00FF00;
IDirectDrawSurface_SetColorKey(lpSrc, DDCKEY_SRCBLT, &DDColorKey);
DDColorKey.dwColorSpaceLowValue = 0;
DDColorKey.dwColorSpaceHighValue = 0;
IDirectDrawSurface_GetColorKey(lpSrc, DDCKEY_SRCBLT, &DDColorKey);
ok(DDColorKey.dwColorSpaceLowValue == 0x00FF00 && DDColorKey.dwColorSpaceHighValue == 0x00FF00,
"GetColorKey does not return the colorkey set with SetColorKey\n");
ddsd.ddckCKSrcBlt.dwColorSpaceLowValue = 0;
ddsd.ddckCKSrcBlt.dwColorSpaceHighValue = 0;
IDirectDrawSurface_GetSurfaceDesc(lpSrc, &ddsd);
ok(ddsd.ddckCKSrcBlt.dwColorSpaceLowValue == 0x00FF00 && ddsd.ddckCKSrcBlt.dwColorSpaceHighValue == 0x00FF00,
"GetSurfaceDesc does not return the colorkey set with SetColorKey\n");
IDirectDrawSurface_Release(lpSrc);
IDirectDrawSurface_Release(lpDst);
/* start with a new set of surfaces to test the color keying parameters to blit */
memset(&ddsd, 0, sizeof(ddsd));
ddsd.dwSize = sizeof(ddsd);
ddsd.ddpfPixelFormat.dwSize = sizeof(ddsd.ddpfPixelFormat);
ddsd.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | DDSD_PIXELFORMAT | DDSD_CKSRCBLT | DDSD_CKDESTBLT;
ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
ddsd.dwWidth = 800;
ddsd.dwHeight = 600;
ddsd.ddpfPixelFormat.dwFlags = DDPF_RGB;
U1(ddsd.ddpfPixelFormat).dwRGBBitCount = 32;
U2(ddsd.ddpfPixelFormat).dwRBitMask = 0xFF0000;
U3(ddsd.ddpfPixelFormat).dwGBitMask = 0x00FF00;
U4(ddsd.ddpfPixelFormat).dwBBitMask = 0x0000FF;
ddsd.ddckCKDestBlt.dwColorSpaceLowValue = 0xFF0000;
ddsd.ddckCKDestBlt.dwColorSpaceHighValue = 0xFF0000;
ddsd.ddckCKSrcBlt.dwColorSpaceLowValue = 0x00FF00;
ddsd.ddckCKSrcBlt.dwColorSpaceHighValue = 0x00FF00;
rc = IDirectDraw_CreateSurface(lpDD, &ddsd, &lpDst, NULL);
ok(rc==DD_OK || rc == DDERR_NOCOLORKEYHW,"CreateSurface returned: %x\n",rc);
if(FAILED(rc))
{
skip("Failed to create surface\n");
return;
}
/* start with a new set of surfaces to test the color keying parameters to blit */
memset(&ddsd, 0, sizeof(ddsd));
ddsd.dwSize = sizeof(ddsd);
ddsd.ddpfPixelFormat.dwSize = sizeof(ddsd.ddpfPixelFormat);
ddsd.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | DDSD_PIXELFORMAT | DDSD_CKSRCBLT | DDSD_CKDESTBLT;
ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
ddsd.dwWidth = 800;
ddsd.dwHeight = 600;
ddsd.ddpfPixelFormat.dwFlags = DDPF_RGB;
U1(ddsd.ddpfPixelFormat).dwRGBBitCount = 32;
U2(ddsd.ddpfPixelFormat).dwRBitMask = 0xFF0000;
U3(ddsd.ddpfPixelFormat).dwGBitMask = 0x00FF00;
U4(ddsd.ddpfPixelFormat).dwBBitMask = 0x0000FF;
ddsd.ddckCKSrcBlt.dwColorSpaceLowValue = 0x0000FF;
ddsd.ddckCKSrcBlt.dwColorSpaceHighValue = 0x0000FF;
ddsd.ddckCKDestBlt.dwColorSpaceLowValue = 0x000000;
ddsd.ddckCKDestBlt.dwColorSpaceHighValue = 0x000000;
rc = IDirectDraw_CreateSurface(lpDD, &ddsd, &lpSrc, NULL);
ok(rc==DD_OK || rc == DDERR_NOCOLORKEYHW,"CreateSurface returned: %x\n",rc);
if(FAILED(rc))
{
skip("Failed to create surface\n");
IDirectDrawSurface_Release(lpDst);
return;
}
memset(&fx, 0, sizeof(fx));
fx.dwSize = sizeof(fx);
fx.ddckSrcColorkey.dwColorSpaceHighValue = 0x110000;
fx.ddckSrcColorkey.dwColorSpaceLowValue = 0x110000;
fx.ddckDestColorkey.dwColorSpaceHighValue = 0x001100;
fx.ddckDestColorkey.dwColorSpaceLowValue = 0x001100;
rc = IDirectDrawSurface_Lock(lpSrc, NULL, &ddsd2, DDLOCK_WAIT, NULL);
ok(rc==DD_OK,"Lock returned: %x\n",rc);
lpData = (LPDWORD)ddsd2.lpSurface;
lpData[0] = 0x000000FF; /* Applies to src blt key in src surface */
lpData[1] = 0x00000000; /* Applies to dst blt key in src surface */
lpData[2] = 0x00FF0000; /* Dst color key in dst surface */
lpData[3] = 0x0000FF00; /* Src color key in dst surface */
lpData[4] = 0x00001100; /* Src color key in ddbltfx */
lpData[5] = 0x00110000; /* Dst color key in ddbltfx */
rc = IDirectDrawSurface_Unlock(lpSrc, NULL);
ok(rc==DD_OK,"Unlock returned: %x\n",rc);
rc = IDirectDrawSurface_Lock(lpDst, NULL, &ddsd2, DDLOCK_WAIT, NULL);
ok(rc==DD_OK,"Lock returned: %x\n",rc);
lpData = (LPDWORD)ddsd2.lpSurface;
lpData[0] = 0x55555555;
lpData[1] = 0x55555555;
lpData[2] = 0x55555555;
lpData[3] = 0x55555555;
lpData[4] = 0x55555555;
lpData[5] = 0x55555555;
rc = IDirectDrawSurface_Unlock(lpDst, NULL);
ok(rc==DD_OK,"Unlock returned: %x\n",rc);
/* Test a blit without keying */
rc = IDirectDrawSurface_Blt(lpDst, NULL, lpSrc, NULL, 0, &fx);
ok(rc == DD_OK, "IDirectDrawSurface_Blt returned %08x\n", rc);
rc = IDirectDrawSurface_Lock(lpDst, NULL, &ddsd2, DDLOCK_WAIT, NULL);
ok(rc==DD_OK,"Lock returned: %x\n",rc);
lpData = (LPDWORD)ddsd2.lpSurface;
/* Should have copied src data unmodified to dst */
ok(lpData[0] == 0x000000FF &&
lpData[1] == 0x00000000 &&
lpData[2] == 0x00FF0000 &&
lpData[3] == 0x0000FF00 &&
lpData[4] == 0x00001100 &&
lpData[5] == 0x00110000, "Surface data after unkeyed blit does not match\n");
lpData[0] = 0x55555555;
lpData[1] = 0x55555555;
lpData[2] = 0x55555555;
lpData[3] = 0x55555555;
lpData[4] = 0x55555555;
lpData[5] = 0x55555555;
rc = IDirectDrawSurface_Unlock(lpDst, NULL);
ok(rc==DD_OK,"Unlock returned: %x\n",rc);
/* Src key */
rc = IDirectDrawSurface_Blt(lpDst, NULL, lpSrc, NULL, DDBLT_KEYSRC, &fx);
ok(rc == DD_OK, "IDirectDrawSurface_Blt returned %08x\n", rc);
rc = IDirectDrawSurface_Lock(lpDst, NULL, &ddsd2, DDLOCK_WAIT, NULL);
ok(rc==DD_OK,"Lock returned: %x\n",rc);
lpData = (LPDWORD)ddsd2.lpSurface;
ok(lpData[0] == 0x55555555 && /* Here the src key applied */
lpData[1] == 0x00000000 &&
lpData[2] == 0x00FF0000 &&
lpData[3] == 0x0000FF00 &&
lpData[4] == 0x00001100 &&
lpData[5] == 0x00110000, "Surface data after srckey blit does not match\n");
lpData[0] = 0x55555555;
lpData[1] = 0x55555555;
lpData[2] = 0x55555555;
lpData[3] = 0x55555555;
lpData[4] = 0x55555555;
lpData[5] = 0x55555555;
rc = IDirectDrawSurface_Unlock(lpDst, NULL);
ok(rc==DD_OK,"Unlock returned: %x\n",rc);
/* Src override */
rc = IDirectDrawSurface_Blt(lpDst, NULL, lpSrc, NULL, DDBLT_KEYSRCOVERRIDE, &fx);
ok(rc == DD_OK, "IDirectDrawSurface_Blt returned %08x\n", rc);
rc = IDirectDrawSurface_Lock(lpDst, NULL, &ddsd2, DDLOCK_WAIT, NULL);
ok(rc==DD_OK,"Lock returned: %x\n",rc);
lpData = (LPDWORD)ddsd2.lpSurface;
ok(lpData[0] == 0x000000FF &&
lpData[1] == 0x00000000 &&
lpData[2] == 0x00FF0000 &&
lpData[3] == 0x0000FF00 &&
lpData[4] == 0x00001100 &&
lpData[5] == 0x55555555, /* Override key applies here */
"Surface data after src override key blit does not match\n");
lpData[0] = 0x55555555;
lpData[1] = 0x55555555;
lpData[2] = 0x55555555;
lpData[3] = 0x55555555;
lpData[4] = 0x55555555;
lpData[5] = 0x55555555;
rc = IDirectDrawSurface_Unlock(lpDst, NULL);
ok(rc==DD_OK,"Unlock returned: %x\n",rc);
/* Src override AND src key. That is not supposed to work */
rc = IDirectDrawSurface_Blt(lpDst, NULL, lpSrc, NULL, DDBLT_KEYSRC | DDBLT_KEYSRCOVERRIDE, &fx);
ok(rc == DDERR_INVALIDPARAMS, "IDirectDrawSurface_Blt returned %08x\n", rc);
/* Verify that the destination is unchanged */
rc = IDirectDrawSurface_Lock(lpDst, NULL, &ddsd2, DDLOCK_WAIT, NULL);
ok(rc==DD_OK,"Lock returned: %x\n",rc);
lpData = (LPDWORD)ddsd2.lpSurface;
ok(lpData[0] == 0x55555555 &&
lpData[1] == 0x55555555 &&
lpData[2] == 0x55555555 &&
lpData[3] == 0x55555555 &&
lpData[4] == 0x55555555 &&
lpData[5] == 0x55555555, /* Override key applies here */
"Surface data after src key blit with override does not match\n");
lpData[0] = 0x00FF0000; /* Dest key in dst surface */
lpData[1] = 0x00FF0000; /* Dest key in dst surface */
lpData[2] = 0x00001100; /* Dest key in override */
lpData[3] = 0x00001100; /* Dest key in override */
lpData[4] = 0x00000000; /* Dest key in src surface */
lpData[5] = 0x00000000; /* Dest key in src surface */
rc = IDirectDrawSurface_Unlock(lpDst, NULL);
ok(rc==DD_OK,"Unlock returned: %x\n",rc);
/* Dest key blit */
rc = IDirectDrawSurface_Blt(lpDst, NULL, lpSrc, NULL, DDBLT_KEYDEST, &fx);
ok(rc == DD_OK, "IDirectDrawSurface_Blt returned %08x\n", rc);
rc = IDirectDrawSurface_Lock(lpDst, NULL, &ddsd2, DDLOCK_WAIT, NULL);
ok(rc==DD_OK,"Lock returned: %x\n",rc);
lpData = (LPDWORD)ddsd2.lpSurface;
/* DirectDraw uses the dest blit key from the SOURCE surface ! */
ok(lpData[0] == 0x00ff0000 &&
lpData[1] == 0x00ff0000 &&
lpData[2] == 0x00001100 &&
lpData[3] == 0x00001100 &&
lpData[4] == 0x00001100 && /* Key applies here */
lpData[5] == 0x00110000, /* Key applies here */
"Surface data after dest key blit does not match\n");
lpData[0] = 0x00FF0000; /* Dest key in dst surface */
lpData[1] = 0x00FF0000; /* Dest key in dst surface */
lpData[2] = 0x00001100; /* Dest key in override */
lpData[3] = 0x00001100; /* Dest key in override */
lpData[4] = 0x00000000; /* Dest key in src surface */
lpData[5] = 0x00000000; /* Dest key in src surface */
rc = IDirectDrawSurface_Unlock(lpDst, NULL);
ok(rc==DD_OK,"Unlock returned: %x\n",rc);
/* Dest override key blit */
rc = IDirectDrawSurface_Blt(lpDst, NULL, lpSrc, NULL, DDBLT_KEYDESTOVERRIDE, &fx);
ok(rc == DD_OK, "IDirectDrawSurface_Blt returned %08x\n", rc);
rc = IDirectDrawSurface_Lock(lpDst, NULL, &ddsd2, DDLOCK_WAIT, NULL);
ok(rc==DD_OK,"Lock returned: %x\n",rc);
lpData = (LPDWORD)ddsd2.lpSurface;
ok(lpData[0] == 0x00FF0000 &&
lpData[1] == 0x00FF0000 &&
lpData[2] == 0x00FF0000 && /* Key applies here */
lpData[3] == 0x0000FF00 && /* Key applies here */
lpData[4] == 0x00000000 &&
lpData[5] == 0x00000000,
"Surface data after dest key override blit does not match\n");
lpData[0] = 0x00FF0000; /* Dest key in dst surface */
lpData[1] = 0x00FF0000; /* Dest key in dst surface */
lpData[2] = 0x00001100; /* Dest key in override */
lpData[3] = 0x00001100; /* Dest key in override */
lpData[4] = 0x00000000; /* Dest key in src surface */
lpData[5] = 0x00000000; /* Dest key in src surface */
rc = IDirectDrawSurface_Unlock(lpDst, NULL);
ok(rc==DD_OK,"Unlock returned: %x\n",rc);
/* Dest override key blit. Supposed to fail too */
rc = IDirectDrawSurface_Blt(lpDst, NULL, lpSrc, NULL, DDBLT_KEYDEST | DDBLT_KEYDESTOVERRIDE, &fx);
ok(rc == DDERR_INVALIDPARAMS, "IDirectDrawSurface_Blt returned %08x\n", rc);
/* Check for unchanged data */
rc = IDirectDrawSurface_Lock(lpDst, NULL, &ddsd2, DDLOCK_WAIT, NULL);
ok(rc==DD_OK,"Lock returned: %x\n",rc);
lpData = (LPDWORD)ddsd2.lpSurface;
ok(lpData[0] == 0x00FF0000 &&
lpData[1] == 0x00FF0000 &&
lpData[2] == 0x00001100 && /* Key applies here */
lpData[3] == 0x00001100 && /* Key applies here */
lpData[4] == 0x00000000 &&
lpData[5] == 0x00000000,
"Surface data with dest key and dest override does not match\n");
lpData[0] = 0x00FF0000; /* Dest key in dst surface */
lpData[1] = 0x00FF0000; /* Dest key in dst surface */
lpData[2] = 0x00001100; /* Dest key in override */
lpData[3] = 0x00001100; /* Dest key in override */
lpData[4] = 0x00000000; /* Dest key in src surface */
lpData[5] = 0x00000000; /* Dest key in src surface */
rc = IDirectDrawSurface_Unlock(lpDst, NULL);
ok(rc==DD_OK,"Unlock returned: %x\n",rc);
/* Modify the source data a bit to give some more conclusive results */
rc = IDirectDrawSurface_Lock(lpSrc, NULL, &ddsd2, DDLOCK_WAIT, NULL);
ok(rc==DD_OK,"Lock returned: %x\n",rc);
lpData = (LPDWORD)ddsd2.lpSurface;
lpData[5] = 0x000000FF; /* Applies to src blt key in src surface */
rc = IDirectDrawSurface_Unlock(lpSrc, NULL);
ok(rc==DD_OK,"Unlock returned: %x\n",rc);
/* Source and destination key */
rc = IDirectDrawSurface_Blt(lpDst, NULL, lpSrc, NULL, DDBLT_KEYDEST | DDBLT_KEYSRC, &fx);
ok(rc == DD_OK, "IDirectDrawSurface_Blt returned %08x\n", rc);
rc = IDirectDrawSurface_Lock(lpDst, NULL, &ddsd2, DDLOCK_WAIT, NULL);
ok(rc==DD_OK,"Lock returned: %x\n",rc);
lpData = (LPDWORD)ddsd2.lpSurface;
ok(lpData[0] == 0x00FF0000 && /* Masked by Destination key */
lpData[1] == 0x00FF0000 && /* Masked by Destination key */
lpData[2] == 0x00001100 && /* Masked by Destination key */
lpData[3] == 0x00001100 && /* Masked by Destination key */
lpData[4] == 0x00001100 && /* Allowed by destination key, not masked by source key */
lpData[5] == 0x00000000, /* Allowed by dst key, but masked by source key */
"Surface data with src key and dest key blit does not match\n");
lpData[0] = 0x00FF0000; /* Dest key in dst surface */
lpData[1] = 0x00FF0000; /* Dest key in dst surface */
lpData[2] = 0x00001100; /* Dest key in override */
lpData[3] = 0x00001100; /* Dest key in override */
lpData[4] = 0x00000000; /* Dest key in src surface */
lpData[5] = 0x00000000; /* Dest key in src surface */
rc = IDirectDrawSurface_Unlock(lpDst, NULL);
ok(rc==DD_OK,"Unlock returned: %x\n",rc);
/* Override keys without ddbltfx parameter fail */
rc = IDirectDrawSurface_Blt(lpDst, NULL, lpSrc, NULL, DDBLT_KEYDESTOVERRIDE, NULL);
ok(rc == DDERR_INVALIDPARAMS, "IDirectDrawSurface_Blt returned %08x\n", rc);
rc = IDirectDrawSurface_Blt(lpDst, NULL, lpSrc, NULL, DDBLT_KEYSRCOVERRIDE, NULL);
ok(rc == DDERR_INVALIDPARAMS, "IDirectDrawSurface_Blt returned %08x\n", rc);
/* Try blitting without keys in the source surface*/
rc = IDirectDrawSurface_SetColorKey(lpSrc, DDCKEY_SRCBLT, NULL);
ok(rc == DD_OK, "SetColorKey returned %x\n", rc);
rc = IDirectDrawSurface_SetColorKey(lpSrc, DDCKEY_DESTBLT, NULL);
ok(rc == DD_OK, "SetColorKey returned %x\n", rc);
/* That fails now. Do not bother to check that the data is unmodified */
rc = IDirectDrawSurface_Blt(lpDst, NULL, lpSrc, NULL, DDBLT_KEYSRC, &fx);
ok(rc == DDERR_INVALIDPARAMS, "IDirectDrawSurface_Blt returned %08x\n", rc);
/* Dest key blit still works. Which key is used this time??? */
rc = IDirectDrawSurface_Blt(lpDst, NULL, lpSrc, NULL, DDBLT_KEYDEST, &fx);
ok(rc == DD_OK, "IDirectDrawSurface_Blt returned %08x\n", rc);
/* With korrectly passed override keys no key in the surface is needed.
* Again, the result was checked before, no need to do that again
*/
rc = IDirectDrawSurface_Blt(lpDst, NULL, lpSrc, NULL, DDBLT_KEYDESTOVERRIDE, &fx);
ok(rc == DD_OK, "IDirectDrawSurface_Blt returned %08x\n", rc);
rc = IDirectDrawSurface_Blt(lpDst, NULL, lpSrc, NULL, DDBLT_KEYSRCOVERRIDE, &fx);
ok(rc == DD_OK, "IDirectDrawSurface_Blt returned %08x\n", rc);
IDirectDrawSurface_Release(lpSrc);
IDirectDrawSurface_Release(lpDst);
}
static void QueryInterface(void)
{
LPDIRECTDRAWSURFACE dsurface;
DDSURFACEDESC surface;
LPVOID object;
HRESULT ret;
/* Create a surface */
ZeroMemory(&surface, sizeof(surface));
surface.dwSize = sizeof(surface);
surface.dwFlags = DDSD_WIDTH | DDSD_HEIGHT;
surface.dwHeight = 10;
surface.dwWidth = 10;
ret = IDirectDraw_CreateSurface(lpDD, &surface, &dsurface, NULL);
if(ret != DD_OK)
{
ok(FALSE, "IDirectDraw::CreateSurface failed with error %x\n", ret);
return;
}
/* Call IUnknown::QueryInterface */
ret = IDirectDrawSurface_QueryInterface(dsurface, 0, &object);
ok(ret == DDERR_INVALIDPARAMS, "IDirectDrawSurface::QueryInterface returned %x\n", ret);
IDirectDrawSurface_Release(dsurface);
}
/* The following tests test which interface is returned by IDirectDrawSurfaceX::GetDDInterface.
* It uses refcounts to test that and compares the interface addresses. Partially fits here, and
* partially in the refcount test
*/
static unsigned long getref(IUnknown *iface)
{
IUnknown_AddRef(iface);
return IUnknown_Release(iface);
}
static void GetDDInterface_1(void)
{
LPDIRECTDRAWSURFACE dsurface;
LPDIRECTDRAWSURFACE2 dsurface2;
DDSURFACEDESC surface;
HRESULT ret;
IDirectDraw2 *dd2;
IDirectDraw4 *dd4;
IDirectDraw7 *dd7;
unsigned long ref1, ref2, ref4, ref7;
void *dd;
/* Create a surface */
ZeroMemory(&surface, sizeof(surface));
surface.dwSize = sizeof(surface);
surface.dwFlags = DDSD_WIDTH | DDSD_HEIGHT;
surface.dwHeight = 10;
surface.dwWidth = 10;
ret = IDirectDraw_CreateSurface(lpDD, &surface, &dsurface, NULL);
if(ret != DD_OK)
{
ok(FALSE, "IDirectDraw::CreateSurface failed with error %x\n", ret);
return;
}
ret = IDirectDrawSurface_QueryInterface(dsurface, &IID_IDirectDrawSurface2, (void **) &dsurface2);
ok(ret == DD_OK, "IDirectDrawSurface_QueryInterface returned %08x\n", ret);
ret = IDirectDraw_QueryInterface(lpDD, &IID_IDirectDraw2, (void **) &dd2);
ok(ret == DD_OK, "IDirectDraw7_QueryInterface returned %08x\n", ret);
ret = IDirectDraw_QueryInterface(lpDD, &IID_IDirectDraw4, (void **) &dd4);
ok(ret == DD_OK, "IDirectDraw7_QueryInterface returned %08x\n", ret);
ret = IDirectDraw_QueryInterface(lpDD, &IID_IDirectDraw7, (void **) &dd7);
ok(ret == DD_OK, "IDirectDraw7_QueryInterface returned %08x\n", ret);
ref1 = getref((IUnknown *) lpDD);
ok(ref1 == 1, "IDirectDraw refcount is %ld\n", ref1);
ref2 = getref((IUnknown *) dd2);
ok(ref2 == 1, "IDirectDraw2 refcount is %ld\n", ref2);
ref4 = getref((IUnknown *) dd4);
ok(ref4 == 1, "IDirectDraw4 refcount is %ld\n", ref4);
ref7 = getref((IUnknown *) dd7);
ok(ref7 == 1, "IDirectDraw7 refcount is %ld\n", ref7);
ret = IDirectDrawSurface2_GetDDInterface(dsurface2, &dd);
ok(ret == DD_OK, "IDirectDrawSurface7_GetDDInterface returned %08x\n", ret);
ok(getref((IUnknown *) lpDD) == ref1 + 1, "IDirectDraw refcount was increased by %ld\n", getref((IUnknown *) lpDD) - ref1);
ok(getref((IUnknown *) dd2) == ref2 + 0, "IDirectDraw2 refcount was increased by %ld\n", getref((IUnknown *) dd2) - ref2);
ok(getref((IUnknown *) dd4) == ref4 + 0, "IDirectDraw4 refcount was increased by %ld\n", getref((IUnknown *) dd4) - ref4);
ok(getref((IUnknown *) dd7) == ref7 + 0, "IDirectDraw7 refcount was increased by %ld\n", getref((IUnknown *) dd7) - ref7);
ok(dd == lpDD, "Returned interface pointer is not equal to the creation interface\n");
IUnknown_Release((IUnknown *) dd);
/* try a NULL pointer */
ret = IDirectDrawSurface2_GetDDInterface(dsurface2, NULL);
ok(ret == DDERR_INVALIDPARAMS, "IDirectDrawSurface7_GetDDInterface returned %08x\n", ret);
IDirectDraw_Release(dd2);
IDirectDraw_Release(dd4);
IDirectDraw_Release(dd7);
IDirectDrawSurface2_Release(dsurface2);
IDirectDrawSurface_Release(dsurface);
}
static void GetDDInterface_2(void)
{
LPDIRECTDRAWSURFACE dsurface;
LPDIRECTDRAWSURFACE2 dsurface2;
DDSURFACEDESC surface;
HRESULT ret;
IDirectDraw2 *dd2;
IDirectDraw4 *dd4;
IDirectDraw7 *dd7;
unsigned long ref1, ref2, ref4, ref7;
void *dd;
ret = IDirectDraw_QueryInterface(lpDD, &IID_IDirectDraw2, (void **) &dd2);
ok(ret == DD_OK, "IDirectDraw7_QueryInterface returned %08x\n", ret);
ret = IDirectDraw_QueryInterface(lpDD, &IID_IDirectDraw4, (void **) &dd4);
ok(ret == DD_OK, "IDirectDraw7_QueryInterface returned %08x\n", ret);
ret = IDirectDraw_QueryInterface(lpDD, &IID_IDirectDraw7, (void **) &dd7);
ok(ret == DD_OK, "IDirectDraw7_QueryInterface returned %08x\n", ret);
/* Create a surface */
ZeroMemory(&surface, sizeof(surface));
surface.dwSize = sizeof(surface);
surface.dwFlags = DDSD_WIDTH | DDSD_HEIGHT;
surface.dwHeight = 10;
surface.dwWidth = 10;
ret = IDirectDraw2_CreateSurface(dd2, &surface, &dsurface, NULL);
if(ret != DD_OK)
{
ok(FALSE, "IDirectDraw::CreateSurface failed with error %x\n", ret);
return;
}
ret = IDirectDrawSurface_QueryInterface(dsurface, &IID_IDirectDrawSurface2, (void **) &dsurface2);
ok(ret == DD_OK, "IDirectDrawSurface_QueryInterface returned %08x\n", ret);
ref1 = getref((IUnknown *) lpDD);
ok(ref1 == 1, "IDirectDraw refcount is %ld\n", ref1);
ref2 = getref((IUnknown *) dd2);
ok(ref2 == 1, "IDirectDraw2 refcount is %ld\n", ref2);
ref4 = getref((IUnknown *) dd4);
ok(ref4 == 1, "IDirectDraw4 refcount is %ld\n", ref4);
ref7 = getref((IUnknown *) dd7);
ok(ref7 == 1, "IDirectDraw7 refcount is %ld\n", ref7);
ret = IDirectDrawSurface2_GetDDInterface(dsurface2, &dd);
ok(ret == DD_OK, "IDirectDrawSurface7_GetDDInterface returned %08x\n", ret);
ok(getref((IUnknown *) lpDD) == ref1 + 0, "IDirectDraw refcount was increased by %ld\n", getref((IUnknown *) lpDD) - ref1);
ok(getref((IUnknown *) dd2) == ref2 + 1, "IDirectDraw2 refcount was increased by %ld\n", getref((IUnknown *) dd2) - ref2);
ok(getref((IUnknown *) dd4) == ref4 + 0, "IDirectDraw4 refcount was increased by %ld\n", getref((IUnknown *) dd4) - ref4);
ok(getref((IUnknown *) dd7) == ref7 + 0, "IDirectDraw7 refcount was increased by %ld\n", getref((IUnknown *) dd7) - ref7);
ok(dd == dd2, "Returned interface pointer is not equal to the creation interface\n");
IUnknown_Release((IUnknown *) dd);
IDirectDraw_Release(dd2);
IDirectDraw_Release(dd4);
IDirectDraw_Release(dd7);
IDirectDrawSurface2_Release(dsurface2);
IDirectDrawSurface_Release(dsurface);
}
static void GetDDInterface_4(void)
{
LPDIRECTDRAWSURFACE2 dsurface2;
LPDIRECTDRAWSURFACE4 dsurface4;
DDSURFACEDESC2 surface;
HRESULT ret;
IDirectDraw2 *dd2;
IDirectDraw4 *dd4;
IDirectDraw7 *dd7;
unsigned long ref1, ref2, ref4, ref7;
void *dd;
ret = IDirectDraw_QueryInterface(lpDD, &IID_IDirectDraw2, (void **) &dd2);
ok(ret == DD_OK, "IDirectDraw7_QueryInterface returned %08x\n", ret);
ret = IDirectDraw_QueryInterface(lpDD, &IID_IDirectDraw4, (void **) &dd4);
ok(ret == DD_OK, "IDirectDraw7_QueryInterface returned %08x\n", ret);
ret = IDirectDraw_QueryInterface(lpDD, &IID_IDirectDraw7, (void **) &dd7);
ok(ret == DD_OK, "IDirectDraw7_QueryInterface returned %08x\n", ret);
/* Create a surface */
ZeroMemory(&surface, sizeof(surface));
surface.dwSize = sizeof(surface);
surface.dwFlags = DDSD_WIDTH | DDSD_HEIGHT;
surface.dwHeight = 10;
surface.dwWidth = 10;
ret = IDirectDraw4_CreateSurface(dd4, &surface, &dsurface4, NULL);
if(ret != DD_OK)
{
ok(FALSE, "IDirectDraw::CreateSurface failed with error %x\n", ret);
return;
}
ret = IDirectDrawSurface4_QueryInterface(dsurface4, &IID_IDirectDrawSurface2, (void **) &dsurface2);
ok(ret == DD_OK, "IDirectDrawSurface_QueryInterface returned %08x\n", ret);
ref1 = getref((IUnknown *) lpDD);
ok(ref1 == 1, "IDirectDraw refcount is %ld\n", ref1);
ref2 = getref((IUnknown *) dd2);
ok(ref2 == 1, "IDirectDraw2 refcount is %ld\n", ref2);
ref4 = getref((IUnknown *) dd4);
ok(ref4 == 2, "IDirectDraw4 refcount is %ld\n", ref4);
ref7 = getref((IUnknown *) dd7);
ok(ref7 == 1, "IDirectDraw7 refcount is %ld\n", ref7);
ret = IDirectDrawSurface4_GetDDInterface(dsurface4, &dd);
ok(ret == DD_OK, "IDirectDrawSurface7_GetDDInterface returned %08x\n", ret);
ok(getref((IUnknown *) lpDD) == ref1 + 0, "IDirectDraw refcount was increased by %ld\n", getref((IUnknown *) lpDD) - ref1);
ok(getref((IUnknown *) dd2) == ref2 + 0, "IDirectDraw2 refcount was increased by %ld\n", getref((IUnknown *) dd2) - ref2);
ok(getref((IUnknown *) dd4) == ref4 + 1, "IDirectDraw4 refcount was increased by %ld\n", getref((IUnknown *) dd4) - ref4);
ok(getref((IUnknown *) dd7) == ref7 + 0, "IDirectDraw7 refcount was increased by %ld\n", getref((IUnknown *) dd7) - ref7);
ok(dd == dd4, "Returned interface pointer is not equal to the creation interface\n");
IUnknown_Release((IUnknown *) dd);
/* Now test what happens if we QI the surface for some other version - It should still return the creation interface */
ret = IDirectDrawSurface2_GetDDInterface(dsurface2, &dd);
ok(ret == DD_OK, "IDirectDrawSurface7_GetDDInterface returned %08x\n", ret);
ok(getref((IUnknown *) lpDD) == ref1 + 0, "IDirectDraw refcount was increased by %ld\n", getref((IUnknown *) lpDD) - ref1);
ok(getref((IUnknown *) dd2) == ref2 + 0, "IDirectDraw2 refcount was increased by %ld\n", getref((IUnknown *) dd2) - ref2);
ok(getref((IUnknown *) dd4) == ref4 + 1, "IDirectDraw4 refcount was increased by %ld\n", getref((IUnknown *) dd4) - ref4);
ok(getref((IUnknown *) dd7) == ref7 + 0, "IDirectDraw7 refcount was increased by %ld\n", getref((IUnknown *) dd7) - ref7);
ok(dd == dd4, "Returned interface pointer is not equal to the creation interface\n");
IUnknown_Release((IUnknown *) dd);
IDirectDraw_Release(dd2);
IDirectDraw_Release(dd4);
IDirectDraw_Release(dd7);
IDirectDrawSurface4_Release(dsurface4);
IDirectDrawSurface2_Release(dsurface2);
}
static void GetDDInterface_7(void)
{
LPDIRECTDRAWSURFACE4 dsurface4;
LPDIRECTDRAWSURFACE7 dsurface7;
DDSURFACEDESC2 surface;
HRESULT ret;
IDirectDraw2 *dd2;
IDirectDraw4 *dd4;
IDirectDraw7 *dd7;
unsigned long ref1, ref2, ref4, ref7;
void *dd;
ret = IDirectDraw_QueryInterface(lpDD, &IID_IDirectDraw2, (void **) &dd2);
ok(ret == DD_OK, "IDirectDraw7_QueryInterface returned %08x\n", ret);
ret = IDirectDraw_QueryInterface(lpDD, &IID_IDirectDraw4, (void **) &dd4);
ok(ret == DD_OK, "IDirectDraw7_QueryInterface returned %08x\n", ret);
ret = IDirectDraw_QueryInterface(lpDD, &IID_IDirectDraw7, (void **) &dd7);
ok(ret == DD_OK, "IDirectDraw7_QueryInterface returned %08x\n", ret);
/* Create a surface */
ZeroMemory(&surface, sizeof(surface));
surface.dwSize = sizeof(surface);
surface.dwFlags = DDSD_WIDTH | DDSD_HEIGHT;
surface.dwHeight = 10;
surface.dwWidth = 10;
ret = IDirectDraw7_CreateSurface(dd7, &surface, &dsurface7, NULL);
if(ret != DD_OK)
{
ok(FALSE, "IDirectDraw::CreateSurface failed with error %x\n", ret);
return;
}
ret = IDirectDrawSurface7_QueryInterface(dsurface7, &IID_IDirectDrawSurface4, (void **) &dsurface4);
ok(ret == DD_OK, "IDirectDrawSurface_QueryInterface returned %08x\n", ret);
ref1 = getref((IUnknown *) lpDD);
ok(ref1 == 1, "IDirectDraw refcount is %ld\n", ref1);
ref2 = getref((IUnknown *) dd2);
ok(ref2 == 1, "IDirectDraw2 refcount is %ld\n", ref2);
ref4 = getref((IUnknown *) dd4);
ok(ref4 == 1, "IDirectDraw4 refcount is %ld\n", ref4);
ref7 = getref((IUnknown *) dd7);
ok(ref7 == 2, "IDirectDraw7 refcount is %ld\n", ref7);
ret = IDirectDrawSurface7_GetDDInterface(dsurface7, &dd);
ok(ret == DD_OK, "IDirectDrawSurface7_GetDDInterface returned %08x\n", ret);
ok(getref((IUnknown *) lpDD) == ref1 + 0, "IDirectDraw refcount was increased by %ld\n", getref((IUnknown *) lpDD) - ref1);
ok(getref((IUnknown *) dd2) == ref2 + 0, "IDirectDraw2 refcount was increased by %ld\n", getref((IUnknown *) dd2) - ref2);
ok(getref((IUnknown *) dd4) == ref4 + 0, "IDirectDraw4 refcount was increased by %ld\n", getref((IUnknown *) dd4) - ref4);
ok(getref((IUnknown *) dd7) == ref7 + 1, "IDirectDraw7 refcount was increased by %ld\n", getref((IUnknown *) dd7) - ref7);
ok(dd == dd7, "Returned interface pointer is not equal to the creation interface\n");
IUnknown_Release((IUnknown *) dd);
/* Now test what happens if we QI the surface for some other version - It should still return the creation interface */
ret = IDirectDrawSurface4_GetDDInterface(dsurface4, &dd);
ok(ret == DD_OK, "IDirectDrawSurface7_GetDDInterface returned %08x\n", ret);
ok(getref((IUnknown *) lpDD) == ref1 + 0, "IDirectDraw refcount was increased by %ld\n", getref((IUnknown *) lpDD) - ref1);
ok(getref((IUnknown *) dd2) == ref2 + 0, "IDirectDraw2 refcount was increased by %ld\n", getref((IUnknown *) dd2) - ref2);
ok(getref((IUnknown *) dd4) == ref4 + 0, "IDirectDraw4 refcount was increased by %ld\n", getref((IUnknown *) dd4) - ref4);
ok(getref((IUnknown *) dd7) == ref7 + 1, "IDirectDraw7 refcount was increased by %ld\n", getref((IUnknown *) dd7) - ref7);
ok(dd == dd7, "Returned interface pointer is not equal to the creation interface\n");
IUnknown_Release((IUnknown *) dd);
IDirectDraw_Release(dd2);
IDirectDraw_Release(dd4);
IDirectDraw_Release(dd7);
IDirectDrawSurface4_Release(dsurface4);
IDirectDrawSurface7_Release(dsurface7);
}
#define MAXEXPECTED 8 /* Can match up to 8 expected surfaces */
struct enumstruct
{
IDirectDrawSurface *expected[MAXEXPECTED];
UINT count;
};
static HRESULT WINAPI enumCB(IDirectDrawSurface *surf, DDSURFACEDESC *desc, void *ctx)
{
int i;
BOOL found = FALSE;
for(i = 0; i < MAXEXPECTED; i++)
{
if(((struct enumstruct *)ctx)->expected[i] == surf) found = TRUE;
}
ok(found, "Unexpected surface %p enumerated\n", surf);
((struct enumstruct *)ctx)->count++;
IDirectDrawSurface_Release(surf);
return DDENUMRET_OK;
}
static void EnumTest(void)
{
HRESULT rc;
DDSURFACEDESC ddsd;
IDirectDrawSurface *surface;
struct enumstruct ctx;
ddsd.dwSize = sizeof(ddsd);
ddsd.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | DDSD_MIPMAPCOUNT;
ddsd.ddsCaps.dwCaps = DDSCAPS_TEXTURE | DDSCAPS_COMPLEX | DDSCAPS_MIPMAP;
U2(ddsd).dwMipMapCount = 3;
ddsd.dwWidth = 32;
ddsd.dwHeight = 32;
rc = IDirectDraw_CreateSurface(lpDD, &ddsd, &surface, NULL);
ok(rc==DD_OK,"CreateSurface returned: %x\n",rc);
memset(&ctx, 0, sizeof(ctx));
ctx.expected[0] = surface;
rc = IDirectDrawSurface_GetAttachedSurface(ctx.expected[0], &ddsd.ddsCaps, &ctx.expected[1]);
ok(rc == DD_OK, "GetAttachedSurface returned %08x\n", rc);
rc = IDirectDrawSurface_GetAttachedSurface(ctx.expected[1], &ddsd.ddsCaps, &ctx.expected[2]);
ok(rc == DD_OK, "GetAttachedSurface returned %08x\n", rc);
rc = IDirectDrawSurface_GetAttachedSurface(ctx.expected[2], &ddsd.ddsCaps, &ctx.expected[3]);
ok(rc == DDERR_NOTFOUND, "GetAttachedSurface returned %08x\n", rc);
ctx.count = 0;
rc = IDirectDraw_EnumSurfaces(lpDD, DDENUMSURFACES_DOESEXIST | DDENUMSURFACES_ALL, &ddsd, (void *) &ctx, enumCB);
ok(rc == DD_OK, "IDirectDraw_EnumSurfaces returned %08x\n", rc);
ok(ctx.count == 3, "%d surfaces enumerated, expected 3\n", ctx.count);
IDirectDrawSurface_Release(ctx.expected[2]);
IDirectDrawSurface_Release(ctx.expected[1]);
IDirectDrawSurface_Release(surface);
}
START_TEST(dsurface)
{
if (!CreateDirectDraw())
return;
MipMapCreationTest();
SrcColorKey32BlitTest();
QueryInterface();
GetDDInterface_1();
GetDDInterface_2();
GetDDInterface_4();
GetDDInterface_7();
EnumTest();
ReleaseDirectDraw();
}

View File

@@ -0,0 +1,443 @@
/*
* Some unit tests for ddraw reference counting
*
* Copyright (C) 2006 Stefan Dösinger
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#define COBJMACROS
#include <assert.h>
#include "wine/test.h"
#include "ddraw.h"
#include "d3d.h"
#include "unknwn.h"
static HRESULT (WINAPI *pDirectDrawCreateEx)(LPGUID,LPVOID*,REFIID,LPUNKNOWN);
static void init_function_pointers(void)
{
HMODULE hmod = GetModuleHandleA("ddraw.dll");
pDirectDrawCreateEx = (void*)GetProcAddress(hmod, "DirectDrawCreateEx");
}
static unsigned long getRefcount(IUnknown *iface)
{
IUnknown_AddRef(iface);
return IUnknown_Release(iface);
}
static void test_ddraw_objects(void)
{
HRESULT hr;
unsigned long ref;
IDirectDraw7 *DDraw7;
IDirectDraw4 *DDraw4;
IDirectDraw2 *DDraw2;
IDirectDraw *DDraw1;
IDirectDrawPalette *palette;
IDirectDrawSurface7 *surface;
IDirectDrawSurface *surface1;
IDirectDrawSurface4 *surface4;
PALETTEENTRY Table[256];
DDSURFACEDESC2 ddsd;
hr = pDirectDrawCreateEx(NULL, (void **) &DDraw7, &IID_IDirectDraw7, NULL);
ok(hr == DD_OK || hr==DDERR_NODIRECTDRAWSUPPORT, "DirectDrawCreateEx returned: %x\n", hr);
if(!DDraw7)
{
trace("Couldn't create DDraw interface, skipping tests\n");
return;
}
hr = IDirectDraw7_QueryInterface(DDraw7, &IID_IDirectDraw4, (void **) &DDraw4);
ok(hr == DD_OK, "IDirectDraw7_QueryInterface returned %08x\n", hr);
hr = IDirectDraw7_QueryInterface(DDraw7, &IID_IDirectDraw2, (void **) &DDraw2);
ok(hr == DD_OK, "IDirectDraw7_QueryInterface returned %08x\n", hr);
hr = IDirectDraw7_QueryInterface(DDraw7, &IID_IDirectDraw, (void **) &DDraw1);
ok(hr == DD_OK, "IDirectDraw7_QueryInterface returned %08x\n", hr);
ref = getRefcount( (IUnknown *) DDraw7);
ok(ref == 1, "Got refcount %ld, expected 1\n", ref);
/* Fails without a cooplevel */
hr = IDirectDraw7_CreatePalette(DDraw7, DDPCAPS_ALLOW256 | DDPCAPS_8BIT, Table, &palette, NULL);
ok(hr == DDERR_NOCOOPERATIVELEVELSET, "CreatePalette returned %08x\n", hr);
/* This check is before the cooplevel check */
hr = IDirectDraw7_CreatePalette(DDraw7, DDPCAPS_ALLOW256 | DDPCAPS_8BIT, Table, &palette, (void *) 0xdeadbeef);
ok(hr == CLASS_E_NOAGGREGATION, "CreatePalette returned %08x\n", hr);
hr = IDirectDraw7_SetCooperativeLevel(DDraw7, 0, DDSCL_NORMAL);
ok(hr == DD_OK, "SetCooperativeLevel failed with %08x\n", hr);
memset(&ddsd, 0, sizeof(ddsd));
ddsd.dwSize = sizeof(ddsd);
ddsd.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | DDSD_PIXELFORMAT;
ddsd.dwWidth = 64;
ddsd.dwHeight = 64;
ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
U4(ddsd).ddpfPixelFormat.dwSize = sizeof(U4(ddsd).ddpfPixelFormat);
U4(ddsd).ddpfPixelFormat.dwFlags = DDPF_PALETTEINDEXED8 | DDPF_RGB;
U1(U4(ddsd).ddpfPixelFormat).dwRGBBitCount = 8;
hr = IDirectDraw7_CreateSurface(DDraw7, &ddsd, &surface, NULL);
ok(hr == DD_OK, "CreateSurface failed with %08x\n", hr);
/* DDraw refcount increased by 1 */
ref = getRefcount( (IUnknown *) DDraw7);
ok(ref == 2, "Got refcount %ld, expected 2\n", ref);
/* Surface refcount starts with 1 */
ref = getRefcount( (IUnknown *) surface);
ok(ref == 1, "Got refcount %ld, expected 1\n", ref);
hr = IDirectDraw7_CreatePalette(DDraw7, DDPCAPS_ALLOW256 | DDPCAPS_8BIT, Table, &palette, NULL);
ok(hr == DD_OK, "CreatePalette returned %08x\n", hr);
/* DDraw refcount increased by 1 */
ref = getRefcount( (IUnknown *) DDraw7);
ok(ref == 3, "Got refcount %ld, expected 3\n", ref);
/* Palette starts with 1 */
ref = getRefcount( (IUnknown *) palette);
ok(ref == 1, "Got refcount %ld, expected 1\n", ref);
/* Test attaching a palette to a surface */
hr = IDirectDrawSurface7_SetPalette(surface, palette);
ok(hr == DD_OK, "IDirectDrawSurface_SetPalette failed with %08x\n", hr);
/* Palette refcount increased, surface stays the same */
ref = getRefcount( (IUnknown *) palette);
ok(ref == 2, "Got refcount %ld, expected 2\n", ref);
ref = getRefcount( (IUnknown *) surface);
ok(ref == 1, "Got refcount %ld, expected 1\n", ref);
IDirectDrawSurface7_Release(surface);
/* Increased before - decrease now */
ref = getRefcount( (IUnknown *) DDraw7);
ok(ref == 2, "Got refcount %ld, expected 2\n", ref);
/* Releasing the surface detaches the palette */
ref = getRefcount( (IUnknown *) palette);
ok(ref == 1, "Got refcount %ld, expected 1\n", ref);
IDirectDrawPalette_Release(palette);
/* Increased before - decrease now */
ref = getRefcount( (IUnknown *) DDraw7);
ok(ref == 1, "Got refcount %ld, expected 1\n", ref);
/* Not all interfaces are AddRefed when a palette is created */
hr = IDirectDraw4_CreatePalette(DDraw4, DDPCAPS_ALLOW256 | DDPCAPS_8BIT, Table, &palette, NULL);
ok(hr == DD_OK, "CreatePalette returned %08x\n", hr);
ref = getRefcount( (IUnknown *) DDraw4);
ok(ref == 2, "Got refcount %ld, expected 2\n", ref);
IDirectDrawPalette_Release(palette);
/* No addref here */
hr = IDirectDraw2_CreatePalette(DDraw2, DDPCAPS_ALLOW256 | DDPCAPS_8BIT, Table, &palette, NULL);
ok(hr == DD_OK, "CreatePalette returned %08x\n", hr);
ref = getRefcount( (IUnknown *) DDraw2);
ok(ref == 1, "Got refcount %ld, expected 1\n", ref);
IDirectDrawPalette_Release(palette);
/* No addref here */
hr = IDirectDraw_CreatePalette(DDraw1, DDPCAPS_ALLOW256 | DDPCAPS_8BIT, Table, &palette, NULL);
ok(hr == DD_OK, "CreatePalette returned %08x\n", hr);
ref = getRefcount( (IUnknown *) DDraw1);
ok(ref == 1, "Got refcount %ld, expected 1\n", ref);
IDirectDrawPalette_Release(palette);
/* Similar for surfaces */
hr = IDirectDraw4_CreateSurface(DDraw4, &ddsd, &surface4, NULL);
ok(hr == DD_OK, "CreateSurface returned %08x\n", hr);
ref = getRefcount( (IUnknown *) DDraw4);
ok(ref == 2, "Got refcount %ld, expected 2\n", ref);
IDirectDrawSurface4_Release(surface4);
ddsd.dwSize = sizeof(DDSURFACEDESC);
hr = IDirectDraw2_CreateSurface(DDraw2, (DDSURFACEDESC *) &ddsd, &surface1, NULL);
ok(hr == DD_OK, "CreateSurface returned %08x\n", hr);
ref = getRefcount( (IUnknown *) DDraw2);
ok(ref == 1, "Got refcount %ld, expected 1\n", ref);
IDirectDrawSurface_Release(surface1);
hr = IDirectDraw_CreateSurface(DDraw1, (DDSURFACEDESC *) &ddsd, &surface1, NULL);
ok(hr == DD_OK, "CreateSurface returned %08x\n", hr);
ref = getRefcount( (IUnknown *) DDraw1);
ok(ref == 1, "Got refcount %ld, expected 1\n", ref);
IDirectDrawSurface_Release(surface1);
IDirectDraw7_Release(DDraw7);
IDirectDraw4_Release(DDraw4);
IDirectDraw2_Release(DDraw2);
IDirectDraw_Release(DDraw1);
}
static void test_iface_refcnt(void)
{
HRESULT hr;
IDirectDraw *DDraw1;
IDirectDraw2 *DDraw2;
IDirectDraw4 *DDraw4;
IDirectDraw7 *DDraw7;
IDirect3D7 *D3D7;
IDirect3D3 *D3D3;
IDirect3D2 *D3D2;
IDirect3D *D3D1;
long ref;
hr = pDirectDrawCreateEx(NULL, (void **) &DDraw7, &IID_IDirectDraw7, NULL);
ok(hr == DD_OK || hr==DDERR_NODIRECTDRAWSUPPORT, "DirectDrawCreateEx returned: %x\n", hr);
if(!DDraw7)
{
trace("Couldn't create DDraw interface, skipping tests\n");
return;
}
ref = getRefcount( (IUnknown *) DDraw7);
ok(ref == 1, "Initial IDirectDraw7 reference count is %ld\n", ref);
hr = IDirectDraw7_QueryInterface(DDraw7, &IID_IDirectDraw4, (void **) &DDraw4);
ok(hr == DD_OK, "IDirectDraw7_QueryInterface returned %08x\n", hr);
hr = IDirectDraw7_QueryInterface(DDraw7, &IID_IDirectDraw2, (void **) &DDraw2);
ok(hr == DD_OK, "IDirectDraw7_QueryInterf&ace returned %08x\n", hr);
hr = IDirectDraw7_QueryInterface(DDraw7, &IID_IDirectDraw, (void **) &DDraw1);
ok(hr == DD_OK, "IDirectDraw7_QueryInterface returned %08x\n", hr);
/* All interfaces now have refcount 1! */
ref = getRefcount( (IUnknown *) DDraw7);
ok(ref == 1, "IDirectDraw7 reference count is %ld\n", ref);
ref = getRefcount( (IUnknown *) DDraw7);
ok(ref == 1, "IDirectDraw7 reference count is %ld\n", ref);
ref = getRefcount( (IUnknown *) DDraw4);
ok(ref == 1, "IDirectDraw4 reference count is %ld\n", ref);
ref = getRefcount( (IUnknown *) DDraw2);
ok(ref == 1, "IDirectDraw2 reference count is %ld\n", ref);
ref = getRefcount( (IUnknown *) DDraw1);
ok(ref == 1, "IDirectDraw reference count is %ld\n", ref);
hr = IDirectDraw7_QueryInterface(DDraw7, &IID_IDirect3D7, (void **) &D3D7);
ok(hr == DD_OK, "IDirectDraw7_QueryInterface returned %08x\n", hr);
/* Apparently IDirectDrawX and IDirect3DX are linked together */
ref = getRefcount( (IUnknown *) D3D7);
ok(ref == 2, "IDirect3D7 reference count is %ld\n", ref);
ref = getRefcount( (IUnknown *) DDraw7);
ok(ref == 2, "IDirectDraw7 reference count is %ld\n", ref);
IDirectDraw7_AddRef(DDraw7);
ref = getRefcount( (IUnknown *) D3D7);
ok(ref == 3, "IDirect3D7 reference count is %ld\n", ref);
ref = getRefcount( (IUnknown *) DDraw7);
ok(ref == 3, "IDirectDraw7 reference count is %ld\n", ref);
IDirect3D7_Release(D3D7);
ref = getRefcount( (IUnknown *) D3D7);
ok(ref == 2, "IDirect3D7 reference count is %ld\n", ref);
ref = getRefcount( (IUnknown *) DDraw7);
ok(ref == 2, "IDirectDraw7 reference count is %ld\n", ref);
/* Can't get older d3d interfaces. WHY????? */
hr = IDirectDraw7_QueryInterface(DDraw4, &IID_IDirect3D3, (void **) &D3D3);
todo_wine ok(hr == E_NOINTERFACE, "IDirectDraw7_QueryInterface returned %08x\n", hr);
if(hr == DD_OK && D3D3) IDirect3D3_Release(D3D3);
hr = IDirectDraw4_QueryInterface(DDraw4, &IID_IDirect3D3, (void **) &D3D3);
todo_wine ok(hr == E_NOINTERFACE, "IDirectDraw4_QueryInterface returned %08x\n", hr);
if(hr == DD_OK && D3D3) IDirect3D3_Release(D3D3);
hr = IDirectDraw7_QueryInterface(DDraw7, &IID_IDirect3D2, (void **) &D3D2);
todo_wine ok(hr == E_NOINTERFACE, "IDirectDraw7_QueryInterface returned %08x\n", hr);
if(hr == DD_OK && D3D2) IDirect3D2_Release(D3D2);
hr = IDirectDraw2_QueryInterface(DDraw2, &IID_IDirect3D2, (void **) &D3D2);
todo_wine ok(hr == E_NOINTERFACE, "IDirectDraw2_QueryInterface returned %08x\n", hr);
if(hr == DD_OK && D3D2) IDirect3D2_Release(D3D2);
hr = IDirectDraw7_QueryInterface(DDraw7, &IID_IDirect3D, (void **) &D3D1);
todo_wine ok(hr == E_NOINTERFACE, "IDirectDraw7_QueryInterface returned %08x\n", hr);
if(hr == DD_OK && D3D1) IDirect3D_Release(D3D1);
hr = IDirectDraw_QueryInterface(DDraw1, &IID_IDirect3D, (void **) &D3D1);
todo_wine ok(hr == E_NOINTERFACE, "IDirectDraw_QueryInterface returned %08x\n", hr);
if(hr == DD_OK && D3D1) IDirect3D_Release(D3D1);
hr = IDirect3D7_QueryInterface(D3D7, &IID_IDirect3D, (void **) &D3D1);
todo_wine ok(hr == E_NOINTERFACE, "IDirect3D7_QueryInterface returned %08x\n", hr);
if(hr == DD_OK && D3D1) IDirect3D_Release(D3D1);
/* Try an AddRef, it only affects the AddRefed interface */
IDirectDraw4_AddRef(DDraw4);
ref = getRefcount( (IUnknown *) DDraw7);
ok(ref == 2, "IDirectDraw7 reference count is %ld\n", ref); /* <-- From the d3d query */
ref = getRefcount( (IUnknown *) DDraw4);
ok(ref == 2, "IDirectDraw4 reference count is %ld\n", ref); /* <-- The AddRef call */
ref = getRefcount( (IUnknown *) DDraw2);
ok(ref == 1, "IDirectDraw2 reference count is %ld\n", ref);
ref = getRefcount( (IUnknown *) DDraw1);
ok(ref == 1, "IDirectDraw reference count is %ld\n", ref);
ref = getRefcount( (IUnknown *) D3D7);
ok(ref == 2, "IDirect3D7 reference count is %ld\n", ref); /* <-- From the d3d query */
IDirectDraw4_Release(DDraw4);
/* Make sure that they are one object, not different ones */
hr = IDirectDraw4_SetCooperativeLevel(DDraw4, GetDesktopWindow(), DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
ok(hr == DD_OK, "IDirectDraw4::SetCooperativeLevel returned %08x\n", hr);
/* After an window has been set, DDSCL_SETFOCUSWINDOW should return DDERR_HWNDALREADYSET, see the mode test */
hr = IDirectDraw7_SetCooperativeLevel(DDraw7, NULL, DDSCL_SETFOCUSWINDOW);
ok(hr == DDERR_HWNDALREADYSET, "IDirectDraw7::SetCooperativeLevel returned %08x\n", hr);
/* All done, release all interfaces */
IDirectDraw7_Release(DDraw7);
IDirectDraw4_Release(DDraw4);
IDirectDraw2_Release(DDraw2);
IDirectDraw_Release(DDraw1);
IDirect3D7_Release(D3D7);
}
static void test_d3d_ifaces(void)
{
IDirectDraw *DDraw1;
IDirectDraw2 *DDraw2;
IDirectDraw4 *DDraw4;
IDirect3D *D3D1;
IDirect3D2 *D3D2;
IDirect3D3 *D3D3;
IDirect3D7 *D3D7;
HRESULT hr;
long ref;
hr = DirectDrawCreate(NULL, &DDraw1, NULL);
ok(hr == DD_OK || hr==DDERR_NODIRECTDRAWSUPPORT, "DirectDrawCreateEx returned: %x\n", hr);
if(!DDraw1)
{
trace("DirectDrawCreate failed with %08x\n", hr);
return;
}
hr = IDirectDraw_QueryInterface(DDraw1, &IID_IDirectDraw2, (void **) &DDraw2);
ok(hr == DD_OK, "IDirectDraw_QueryInterface returned %08x\n", hr);
hr = IDirectDraw_QueryInterface(DDraw1, &IID_IDirectDraw4, (void **) &DDraw4);
ok(hr == DD_OK, "IDirectDraw_QueryInterface returned %08x\n", hr);
ref = getRefcount( (IUnknown *) DDraw4);
ok(ref == 1, "IDirectDraw4 reference count is %ld\n", ref);
ref = getRefcount( (IUnknown *) DDraw2);
ok(ref == 1, "IDirectDraw2 reference count is %ld\n", ref);
ref = getRefcount( (IUnknown *) DDraw1);
ok(ref == 1, "IDirectDraw reference count is %ld\n", ref);
hr = IDirectDraw_QueryInterface(DDraw1, &IID_IDirect3D, (void **) &D3D1);
ok(hr == DD_OK, "IDirectDraw_QueryInterface returned %08x\n", hr);
ref = getRefcount( (IUnknown *) DDraw4);
ok(ref == 1, "IDirectDraw4 reference count is %ld\n", ref);
ref = getRefcount( (IUnknown *) DDraw2);
ok(ref == 1, "IDirectDraw2 reference count is %ld\n", ref);
ref = getRefcount( (IUnknown *) DDraw1);
ok(ref == 2, "IDirectDraw reference count is %ld\n", ref);
IDirect3D_Release(D3D1);
hr = IDirectDraw2_QueryInterface(DDraw2, &IID_IDirect3D2, (void **) &D3D2);
ok(hr == DD_OK, "IDirectDraw_QueryInterface returned %08x\n", hr);
ref = getRefcount( (IUnknown *) DDraw4);
ok(ref == 1, "IDirectDraw4 reference count is %ld\n", ref);
ref = getRefcount( (IUnknown *) DDraw2);
ok(ref == 1, "IDirectDraw2 reference count is %ld\n", ref);
ref = getRefcount( (IUnknown *) DDraw1);
ok(ref == 2, "IDirectDraw reference count is %ld\n", ref);
IDirect3D2_Release(D3D2);
hr = IDirectDraw4_QueryInterface(DDraw4, &IID_IDirect3D3, (void **) &D3D3);
ok(hr == DD_OK, "IDirectDraw_QueryInterface returned %08x\n", hr);
ref = getRefcount( (IUnknown *) DDraw4);
ok(ref == 1, "IDirectDraw4 reference count is %ld\n", ref);
ref = getRefcount( (IUnknown *) DDraw2);
ok(ref == 1, "IDirectDraw2 reference count is %ld\n", ref);
ref = getRefcount( (IUnknown *) DDraw1);
ok(ref == 2, "IDirectDraw reference count is %ld\n", ref);
IDirect3D3_Release(D3D3);
/* Try to AddRef the D3D3 interface that has been released already */
IDirect3D3_AddRef(D3D3);
ref = getRefcount( (IUnknown *) DDraw1);
ok(ref == 2, "IDirectDraw reference count is %ld\n", ref);
ref = getRefcount( (IUnknown *) D3D3);
ok(ref == 2, "IDirect3D3 reference count is %ld\n", ref);
/* The newer interfaces remain untouched */
ref = getRefcount( (IUnknown *) DDraw4);
ok(ref == 1, "IDirectDraw4 reference count is %ld\n", ref);
ref = getRefcount( (IUnknown *) DDraw2);
ok(ref == 1, "IDirectDraw2 reference count is %ld\n", ref);
IDirect3D3_Release(D3D3);
ref = getRefcount( (IUnknown *) DDraw1);
ok(ref == 1, "IDirectDraw reference count is %ld\n", ref);
ref = getRefcount( (IUnknown *) DDraw1);
ok(ref == 1, "IDirectDraw reference count is %ld\n", ref);
/* It is possible to query any IDirect3D interfaces from any IDirectDraw interface,
* Except IDirect3D7, it can only be returned by IDirectDraw7(which can't return older ifaces)
*/
hr = IDirectDraw_QueryInterface(DDraw2, &IID_IDirect3D, (void **) &D3D1);
ok(hr == DD_OK, "IDirectDraw2_QueryInterface returned %08x\n", hr);
IDirect3D_Release(D3D1);
hr = IDirectDraw4_QueryInterface(DDraw4, &IID_IDirect3D, (void **) &D3D1);
ok(hr == DD_OK, "IDirectDraw4_QueryInterface returned %08x\n", hr);
IDirect3D_Release(D3D1);
hr = IDirectDraw_QueryInterface(DDraw1, &IID_IDirect3D2, (void **) &D3D2);
ok(hr == DD_OK, "IDirectDraw_QueryInterface returned %08x\n", hr);
IDirect3D_Release(D3D2);
hr = IDirectDraw4_QueryInterface(DDraw4, &IID_IDirect3D2, (void **) &D3D2);
ok(hr == DD_OK, "IDirectDraw4_QueryInterface returned %08x\n", hr);
IDirect3D_Release(D3D2);
hr = IDirectDraw_QueryInterface(DDraw1, &IID_IDirect3D3, (void **) &D3D3);
ok(hr == DD_OK, "IDirectDraw_QueryInterface returned %08x\n", hr);
IDirect3D_Release(D3D3);
hr = IDirectDraw2_QueryInterface(DDraw2, &IID_IDirect3D3, (void **) &D3D3);
ok(hr == DD_OK, "IDirectDraw2_QueryInterface returned %08x\n", hr);
IDirect3D_Release(D3D3);
/* This does NOT work */
hr = IDirectDraw_QueryInterface(DDraw1, &IID_IDirect3D7, (void **) &D3D7);
todo_wine ok(hr == E_NOINTERFACE, "IDirectDraw_QueryInterface returned %08x\n", hr);
if(D3D7) IDirect3D_Release(D3D7);
hr = IDirectDraw2_QueryInterface(DDraw2, &IID_IDirect3D7, (void **) &D3D7);
todo_wine ok(hr == E_NOINTERFACE, "IDirectDraw2_QueryInterface returned %08x\n", hr);
if(D3D7) IDirect3D_Release(D3D7);
hr = IDirectDraw4_QueryInterface(DDraw4, &IID_IDirect3D7, (void **) &D3D7);
todo_wine ok(hr == E_NOINTERFACE, "IDirectDraw4_QueryInterface returned %08x\n", hr);
if(D3D7) IDirect3D_Release(D3D7);
/* Release the interfaces */
IDirectDraw4_Release(DDraw4);
IDirectDraw2_Release(DDraw2);
IDirectDraw_Release(DDraw1);
}
START_TEST(refcount)
{
init_function_pointers();
if(!pDirectDrawCreateEx)
{
trace("function DirectDrawCreateEx not available, skipping tests\n");
return;
}
test_ddraw_objects();
test_iface_refcnt();
test_d3d_ifaces();
}

Some files were not shown because too many files have changed in this diff Show More