How to init DDraw?

Started by
8 comments, last by cyberben 23 years, 7 months ago
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
__________________________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
Advertisement
Use DirectDrawCreateEx(), why use QueryInterface()?

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




The road to success is always under construction
Goblineye EntertainmentThe road to success is always under construction
I would only use DirectDrawCreate and QueryInterface if you are writing for older versions of DirectDraw.
yeah no reason to call QueryInterface, just call DirectDrawCreateEx as tornado showed
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
__________________________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
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
__________________________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
Why don''t you try and see what happens?
I'm reminded of the day my daughter came in, looked over my shoulder at some Perl 4 code, and said, "What is that, swearing?" - Larry Wall
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.
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
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
__________________________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

This topic is closed to new replies.

Advertisement