1. DirectDrawCreate/SetCooperativeMode problems

I tried using EuCOM & TBrowser to create a wrapper for
dx7vb.dll.  My first attempt to use this failed: I
used create_com_object to create the DirectX7 object,
but when I tried to use call_interface to call the
DirectX7 objects "DirectDrawCreate" method.  This
didn't work: the VB docs show that the
"DirectDrawCreate" method is supposed to return a
DirectDraw object, but call_interface only returns an
HResult.

Okay.  Next attempt!

This time, I followed what the EuCOM Direct3d demo
did.  I opened the "ddraw.dll" .dll.  I used the
following to define the DirectDrawCreate fcn:

ddrawc = define_c_func(ddrawdll, "DirectDrawCreate",
{C_POINTER, C_POINTER, C_POINTER}, C_UINT )

to define the fcn.  First param is a ptr to a GUID, in
my case null.  The second is where they will return
the pointer to the DirectDraw object.  The third is
that "unknown" param, also always set to null.

To call this, I defined a ddraw_ptr object, and I used
acquire_mem to initialize it.  I called the fcn with 

res = c_func( ddrawc, {NULL, ddraw_ptr, NULL})

Afterwards, I initialized the ddraw object by doing a
peek4u on the ddraw_ptr.  Finally, I called
ref_com_object:

ddraw = ref_com_object( DirectDraw7_clsid_ix, ddraw )

So far, so good.

Problem is when I call SetCooperativeLevel:

res = call_interface( ddraw, DirectDraw7_disp,
DirectDraw7_SetCooperativeLevel,  {
getHandle(MainWin), DDSCL_NORMAL } )

Now, I keep getting a return value of 2147500034,
which is the error code DIERR_NOAGGREGATION.  I think
this means that it thinks, in the call to
DirectDrawCreate, I didn't set the third param to null
. . . but I did.

Has anyone else seen this?  Does anyone have a
solution for this?  Thanks!
--Animesh

new topic     » topic index » view message » categorize

2. Re: DirectDrawCreate/SetCooperativeMode problems

>Now, I keep getting a return value of 2147500034,
>which is the error code DIERR_NOAGGREGATION.  I think
>this means that it thinks, in the call to
>DirectDrawCreate, I didn't set the third param to null
>. . . but I did.

You sure about that? It seems unlikely that you would get a DirectInput 
error when calling a DirectDraw interface method. Judging from the MSDN page 
for IDirectDraw7::SetCooperativeLevel, these are the possible error codes:

DDERR_EXCLUSIVEMODEALREADYSET
DDERR_HWNDALREADYSET
DDERR_HWNDSUBCLASSED
DDERR_INVALIDOBJECT
DDERR_INVALIDPARAMS
DDERR_OUTOFMEMORY

new topic     » goto parent     » topic index » view message » categorize

3. DirectDrawCreate/SetCooperativeMode problems

I just tried this again, this time not using the
wrapper generated from TBrowse (importing dx7vb.dll). 
It still isn't working, and it is returning the same
error code at the SetCooperativeMode call.  The error
code translates, in the TBrowse-generated wrapper, to
the completely incorrect error code saying that
aggregation isn't allowed!  Can anyone tell me what
the heck is going on here?  I'm sure I'm just doing
something really really stupid and obvious sad

(FYI, I figure I could create a simple C or Delphi
wrapper DLL, but I really want to be able to access
this purely through Euphoria).

Here is the code:


without warning
include win32lib.ew
include eucom.ew
with warning
with trace

constant
  ddrawdll = open_dll("ddraw.dll"),
  ddrawc = define_c_func( ddrawdll,
"DirectDrawCreate",
                          {C_POINTER, C_POINTER,
C_POINTER},
			  C_UINT ),
  DirectDraw_classid =
"D7B70EE0-4340-11CF-B063-0020AFC2CD35",
  DirectDraw4_iid =
"9c59509a-39bd-11d1-8c4a-00c04fd930,0xc5",
  DirectDraw_classid_ix =
add_clsid(DirectDraw_classid),
  DirectDraw4_disp = add_iid(DirectDraw_classid_ix,
DirectDraw4_iid),
  
  DirectDraw4_QueryInterface = 0,
  DirectDraw4_AddRef = 1,
  DirectDraw4_Release = 2,
  DirectDraw4_Compact = 3,
  DirectDraw4_CreateClipper = 4,
  DirectDraw4_CreatePalette = 5,
  DirectDraw4_CreateSurface = 6,
  DirectDraw4_DuplicateSurface = 7,
  DirectDraw4_EnumDisplayModes = 8,
  DirectDraw4_EnumSurfaces = 9,
  DirectDraw4_FlipToGDISurface = 10,
  DirectDraw4_GetCaps = 11,
  DirectDraw4_GetDisplayMode = 12,
  DirectDraw4_GetFourCCCodes = 13,
  DirectDraw4_GetGDISurface = 14,
  DirectDraw4_GetMonitorFrequency = 15,
  DirectDraw4_GetScanLine = 16,
  DirectDraw4_GetVerticalBlankStatus = 17,
  DirectDraw4_Initialize = 18,
  DirectDraw4_RestoreDisplayMode = 19,
  DirectDraw4_SetCooperativeLevel = 20,
  DirectDraw4_SetDisplayMode = 21,
  DirectDraw4_WaitForVerticalBlank = 22,
  DirectDraw4_GetAvailableVidMem = 23,
  DirectDraw4_GetSurfaceFromDC = 24,
  DirectDraw4_RestoreAllSurfaces = 25,
  DirectDraw4_TestCooperativeLevel = 26,
  DirectDraw4_GetDeviceIdentifier = 27

atom res

function CreateDirectDraw()
  atom ddraw_ptr
  atom ddraw_obj

  ddraw_ptr = acquire_mem(0, 4)
  res = c_func( ddrawc, {NULL, ddraw_ptr, NULL})
  if res then
    res = message_box( "Couldn't initialize
DirectDraw", "Error", 0)
    release_mem(ddraw_ptr)
    release_com()
    abort(1)
  end if

  ddraw_obj = peek4u(ddraw_ptr)  
  release_mem(ddraw_ptr)
  return ref_com_object(DirectDraw_classid_ix,
ddraw_obj)
end function

constant 
  MainWin = create( Window, "DirectDraw Test", 0, 20,
20, 400, 400, 0),
  DDraw = CreateDirectDraw()

res = call_interface( DDraw, DirectDraw4_disp,
DirectDraw4_SetCooperativeLevel,
   { getHandle(MainWin), 0 } )

trace(1)
if res then
  res = message_box ( "Couldn't set cooperative level
for DirectDraw", "Error", 0)
end if

WinMain(MainWin, Normal)
release_com()



Thanks!

new topic     » goto parent     » topic index » view message » categorize

4. Re: DirectDrawCreate/SetCooperativeMode problems

After doing some snooping around, i came to the conclusion that the returned 
value stands for E_NOINTERFACE (or "No such interface"). There might be some 
problems with the values you give add_iid().. You might want to try calling 
the interface directly with call_interface_ptr, i didn't quite figure out 
how that works so it just crashed when i tried it.

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu