Archived

This topic is now archived and is closed to further replies.

How to init DDraw?

This topic is 6378 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

Alright, I''ve been using DDraw for quite a while, but as far as I''m aware there are at least 3 ways to initialize DDraw. Which is better? DirectDrawCreate? DirectDrawCreateEx? OR QueryInterface? I was using something like this:
  ddrval = DirectDrawCreate( NULL, &t_ddraw, NULL ); if ( ddrval != DD_OK ) //Was there an error { } ddrval = t_ddraw->QueryInterface( IID_IDirectDraw7, (LPVOID*)&lpDD ); if ( ddrval != DD_OK ) //Was there an error { } ddrval = t_ddraw->Release(); if ( ddrval != DD_OK ) //Was there an error { } 
So it creates a DirectDraw object, then queries the DirectDraw7 interface. But then I''ve seen people just use the DirectDrawCreateEx? What should I use? Thanks, Ben __________________________ Mencken's Law: "For every human problem, there is a neat, simple solution; and it's always wrong."
"Computers in the future may weigh no more than 1.5 tons." - Popular Mechanics, forecasting the relentless march of science in 1949

Share on other sites
Use DirectDrawCreateEx(), why use QueryInterface()?

  LPDIRECTDRAW7 lpdds;DirectDrawCreateEx(NULL,(LPVOID*)&lpdds,IID_IDirectDraw7,NULL);

The road to success is always under construction

Share on other sites
I would only use DirectDrawCreate and QueryInterface if you are writing for older versions of DirectDraw.

Share on other sites
yeah no reason to call QueryInterface, just call DirectDrawCreateEx as tornado showed

Share on other sites
Alright thanks! I just wasn''t sure which to use, as all of them worked for me! I''m using DirectDrawCreateEx now and it worked great!
Thanks,
Ben

Share on other sites
Hey one last C++ question it has a list of libraries to link to the project. When I created my project it automatically added there libraries to the list:

kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib

So as you can see when I debug it loads wacks of DLL''s! When I was programming in assembler I only included a few and it worked fine. Would it be safe to only link Kernel32, user32, gdi32,comdlg32, shell32, abd I think advapi32 does registry stuff to right? But just that list? Cuase I''m not using databases or ole, what''s uuid do? and winspool?

Thanks,
Ben

Share on other sites
Why don''t you try and see what happens?

Share on other sites
winspool.lib is for Printing and Print Spooler Functions (like AddPort, AddPrinter, GetJob..)

uuid.lib is for UUID''s and has a lot of them stored.

Share on other sites
Actually, just becuase the .LIB is listed on the linker line, it doesn''t mean that the .DLL will be loaded at run time. The linker is smart enough to not link in a .LIB (say winspool, for example) if your program doesn''t use any functions from it.
You could compile your program and then look at the binary using "Dependency Walker" from your VC installation. It will show you a tree of all the .DLLs that your program is statically linked to (and any DLLs that they are statically linked to, etc.) as well as what particular functions are being used.

...Syzygy

Share on other sites
I did check.... yes my program is loading the DLL''s... I''m just gonna make a back up of the list then trim the list as bare as I can and add what I need till it works...
Thanks,
Ben