im trying to program in masm32 and directx (ddraw), well i have ddraw.lib from the dx sdk and i want to call DirectDrawCreateEx with the parameter iid_directdraw7, but the program throw me an exeception, not my program, it seems ddraw.dll. i dont know what is the value of the iid_directdraw7 constant. I look at ddraw.h and things dont get clear (there is not a specific value for iid_directdraw7), and searching in dx help i cant find anything about ddraw (all direct3d, directsound.., etc). :cry:
Posted on 2005-01-10 07:14:35 by Ateneo
is defined in ddraw.h (this is from PellesC)

DEFINE_GUID(CLSID_DirectDraw7,0x3c305196,0x50db,0x11d3,0x9c,0xfe,0x00,0xc0,0x4f,0xd9,0x30,0xc5);
DEFINE_GUID(IID_IDirectDraw7,0x15e65ec0,0x3b9c,0x11d2,0xb9,0x2f,0x00,0x60,0x97,0x97,0xea,0x5b);
Posted on 2005-01-10 07:43:12 by japheth
but, i have to choose a value from that?
Posted on 2005-01-10 08:08:56 by Ateneo
No, take them all ;-)
Posted on 2005-01-10 08:48:15 by japheth
How do i to, for example to call "SetCooprativeLevel" method from the pointer of the directdrawobject?
Posted on 2005-01-10 09:37:25 by Ateneo


Direct_Draw_Object_Set_Coop_FullScreen PROC
;=====================================================================
; Greedily set the coperative level so that it's in exclusive mode
;=====================================================================
mov eax,(DDSCL_EXCLUSIVE OR DDSCL_FULLSCREEN OR DDSCL_ALLOWREBOOT)
push eax

mov eax,[main_hwnd]
push eax

mov eax,[lpDD]
push eax ; DD Object

mov eax,[eax] ; vtable addr
call [eax+DDO_SetCooperativeLevel] ; call address for SetCooperativeLevel

.IF eax != DD_OK
ODV_hex <eax>
ODS1 <"Ddraw:SetCooperativeLevel:Fail">
jmp Game_Finish
.ELSE
ODS1 <"Ddraw:SetCooperativeLevel:OK">
.ENDIF

ret
ENDP
Posted on 2005-01-10 09:56:43 by BogdanOntanu
where do i get "DDO_SetCooperativeLevel" level value?
Posted on 2005-01-10 18:40:44 by Ateneo
Bassically each method in the Virtual Table is a dword. Once you know the right order of the methods (from SDK or other include files) is enough to add 4 for each method ...

The first 3 methods are always present in all interfaces.



;--------------------------------------------------
; IUNKNOWN METHODS
;--------------------------------------------------
DDO_QueryInterface EQU 0
DDO_AddRef EQU 4
DDO_Release EQU 8
;--------------------------------------------------
DDO_Compact equ 12
DDO_CreateClipper equ 16
DDO_CreatePalette equ 20
DDO_CreateSurface equ 24
DDO_DuplicateSurface equ 28
DDO_EnumDisplayModes equ 32
DDO_EnumSurfaces equ 36
DDO_FlipToGDISurface equ 40
DDO_GetCaps equ 44
DDO_GetDisplayMode equ 48
DDO_GetFourCCCodes equ 52
DDO_GetGDISurface equ 56
DDO_GetMonitorFrequency equ 60
DDO_GetScanLine equ 64
DDO_GetVerticalBlankStatus equ 68
DDO_Initialize equ 72
DDO_RestoreDisplayMode equ 76
DDO_SetCooperativeLevel equ 80
DDO_SetDisplayMode equ 84
DDO_WaitForVerticalBlank equ 88
;-------------------------------------------------
; added in the v2 interface
;-------------------------------------------------
DDO_GetAvailableVidMem equ 92
;-------------------------------------------------
; added in v4 interface
;-------------------------------------------------
DDO_GetSurfaceFromDC equ 96
DDO_RestoreAllSurfaces equ 100
DDO_TestCooperativeLevel equ 104
DDO_GetDeviceIdentifier equ 108
Posted on 2005-01-11 01:47:51 by BogdanOntanu
thanks now i got it. I have found out there a ddraw.inc file, but its rally old, does anybody know where to find an updated file?
Posted on 2005-01-11 19:24:42 by Ateneo
I have my own implementation,
www.ultrano.com/projects/uDirectDraw.zip
compiles with an OOP framework called ATC

Here's some example code:


iCall baka,IDirectDraw,QueryInterface,IID_IDirectDraw7,addr lpdd
or eax,eax
jnz _blah
icall baka,IDirectDraw,Release
pcall lpdd.SetCooperativeLevel,hwnd1,DDSCL_NORMAL or DDSCL_FPUPRESERVE
.if eax
msgbox "Videocard overloaded"
ret
.endif

ZeroMemory &ddsd,sizeof ddsd
mov ddsd.dwSize,sizeof ddsd
mov ddsd.dwFlags,DDSD_CAPS
mov ddsd.ddsCaps.dwCaps,DDSCAPS_PRIMARYSURFACE
pcall lpdd.CreateSurface,addr ddsd,addr lpDDSPrimary,0
.if eax
msgbox "Can't get access to screen"
invoke ExitProcess,0
.endif
pcall lpdd.CreateClipper,0,addr lpClipper,0
.if eax
msgbox "Video Hardware cannot draw in window-mode"
invoke ExitProcess,0
.endif
pcall lpClipper.SetHWnd,0,hwnd1
pcall lpDDSPrimary.SetClipper,lpClipper



Notice how the line here:
pcall lpdd.SetCooperativeLevel,hwnd1,DDSCL_NORMAL or DDSCL_FPUPRESERVE
makes all the code previously mentioned - much more secure for the coder.
Posted on 2005-01-12 08:24:15 by Ultrano
:-D Ultrano, I found it amusing that you called your variable baka. Must be the influence of japanese culture. :)
Posted on 2005-01-12 09:06:20 by roticv
Yes, I use it instead of "temp" . And it's much easier and faster to type "baka" too. Brings some fun in the coding too:


delete baka
foreach baka, trace "kono baka no namae wa %s desu", EDX
foreach2 baka,trace "%s's IQ is just %d",EDX,EAX
...

:-D
Posted on 2005-01-12 12:37:51 by Ultrano