Skip to main content
gamedev.net
🔒 Locked

Initializing DirectDraw problem

Started by Dez Oct 25, 2000 at 7:45 PM 3 replies 1.2k views
Original Post
Dez
Dez
Hey everyone, I''ve just started programming in DirectX and I''m trying to initialize DirectDraw so I can continue on to Direct3D. My problem is that I cannot figure out why SetCooperativeLevel isn''t being called. I''ve removed WndProc and WinMain for readability, here is my code: /***************************************************************/ #include #include #include "c:\DezTools\include\ddraw.h" #include "c:\DezTools\include\d3d.h" // WndProc Function // LPVOID g_pDD; HRESULT Initialize3DEnvironment( HWND hWnd ) { HRESULT hr; hr = DirectDrawCreateEx( NULL, (void **)&g_pDD, IID_IDirectDraw7, NULL ); if( FAILED( hr ) ) return hr; /************* PROBLEM LINE ***********************/ hr = g_pDD ->SetCooperativeLevel( hWnd, DDSCL_NORMAL); /**************************************************/ if( FAILED( hr ) ) return hr; } // WinMain Function // /***************************************************************/ When I compile, the ONLY error I get is: ...error C2065: ''SetCooperativeLevel'' : undeclared identifier Error executing cl.exe. Learning Code.obj - 1 error(s), 0 warning(s) I copied that line of code exactly from the SDK help file that came with DirectX 7. Now I''ll be honest, I just started Windows programming today (5 hours ago), and it is VERY possible that I made a mistake somewhere. But I''ve checked the ''ddraw.h'' source code for the ''SetCooperativeLevel'' macro, and it''s not a typing error, and I have included ''ddraw.h'' in my program (as you can see). I can''t figure out what I''ve done wrong with this program. I''m using DirectX 7 / VC++ 4.0 If anybody could help me, I would be very greatful. Thanks.
SiCrane
SiCrane
Are you compiling in C or C++?
I believe if you''re compiling in C you can''t use
g_pDD->SetCooperativeLevel( hWnd, DDSCL_NORMAL);
Instead you shoud use
IDirectDraw_SetCooperativeLevel(g_pDD, hWnd, DDSCL_NORMAL);
(or manually indirect off the vtable)
Dez
Dez
I tried that before I posted here, and I just tried it again. It still isn''t working.
DefaultUser
DefaultUser
Dez... Were are you from? Cali?

LPDIRECTDRAW lpDD = NULL;

lpDD->SetCooperativeLevel(bla-bla);

Forget about that buggy code, let's start all-over - from scratch. Let's go!
Dez
Dez
IT''S WORKING!!!!!!!!!!!!!!!!!

I started playing around trying that last suggestion, and it gave me a different error (I never thought I would be happy to say that

Anyway, it told me that not all control paths return a value,
i.e. - I didn''t have a return value if it worked!

Enough of me babbling... I would like to thank both SiCrane and DefaultUser for taking the time to help me out. I owe you one. Thanks.

Oh yeah, and I''m not from Cali
I live in Canada. Why do you ask?

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.