Skip to main content
gamedev.net
🔒 Locked

stupid question ?

Started by ste1000 10 replies 2k views
Original Post
ste1000
ste1000
I''m trying (I said trying) to begin game developpement with directx (and I''m also trying to speak english...) BUT When I try to compile my c file visual c++ tells me : error c2039 : setcooperativelevel is not a member of IDirectdraw or release is not... or queryinterface is not... What should I do before turning off my computer and watch TV ? Thanks, Stupido.fr God save gamedev !
God save gamedev !
Muzzafarath
Muzzafarath
C/C++ is case sensitive. myVar is NOT the same as myvar. Change setcooperativelevel to SetCooperativeLevel, release to Release, queryinterface to QueryInterface, etc.
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
ste1000
ste1000
When I wrote setcooperativelevel, I wanted to say SetCooperativeLevel. In fact, I nearly copied the code of the tutorial into a win32 file.
And I still wonder why it doesn''t work since this error is not mentioned in the directdraw tutorial
please help
Ste1000

God save gamedev !
God save gamedev !
Ironblayde
Ironblayde
Can you post your exact code? It''s hard to tell what''s going wrong when you just describe it like that.

-Ironblayde
 Aeon Software
"Your superior intellect is no match for our puny weapons!"
Quantum
Quantum
make sure you didn''t make a stupid mistake.. this is what it should look like in your code

somewhere:

LPDIRECTDRAW lpdd;

then when you try to set the coop level:

lpdd->SetCooperativeLevel(blah);

make sure you used ->
hmm
check spelling..
thats all i can think of.
Pouya
Pouya
lol
missing semicolons, open/close brackets, double/single quotation marks, ->/. , */&
then if everything else failed. then look at the errors that compiler gave you
(i got point by that ya know)

"The more crap you put up with, the more crap you are going to get" -Pouya
"The longest recorded flight of a chicken is 13 seconds!" -?
ste1000
ste1000
ok
First, thanks to all for your answers...
But unfortunately it didn''t work

So here is my code (not the entire code but enough I think) :

LPDIRECTDRAW lpDD;
LPDIRECTDRAW lpDD2;

int DirectDrawInit(HWND hwnd)

{
HRESULT ddrval;

ddrval = DirectDrawCreate( NULL, &lpDD, NULL );
if( ddrval != DD_OK ) { return(0); }


ddrval = lpDD->QueryInterface(IID_IDirectDraw2,(LPVOID *)&lpDD2);
if( ddrval != DD_OK ) { lpDD->release(); return(0); }

lpDD->release();

ddrval = lpDD2->SetCooperativeLevel( hwnd, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN );
if( ddrval != DD_OK ) { lpDD2->Release(); return(0); }


ddrval = lpDD2->SetDisplayMode( 640, 480, 8);
if( ddrval != DD_OK ) { lpDD2->Release(); return(0); }

return(1);
}

Now just think about this :
- I got 8 errors from visual c++ 5 :
error c2039 : SetCooperativeLevel is not a member of IDirectDraw
The same errors for Release, QueryInterface, SetDisplayMode,...
- I have specified #include
- I included ddraw.h into my project files
- In classview, I can see IDirectDraw, IDirectDraw2,...
In IDirectDraw, I can see SetCooperativeLevel and SetDisplayMode for example : BUT When I try to see the functions definitions, the compiler says : "Cannot find the definition for this function : classview cannot find the function definitions until they are saved at least once "
Hope you will be able to help me
Ste1000



God save gamedev !
God save gamedev !
Poltras
Poltras
Sole thing I could point out is the fact that maybe you haven''t the libraries loaded, or your directories are wrong or missing, or you simply haven''t the file on your disk. The code seems ok, nearly nice (sorry, I''m OGl fan, and I find DX quite messy But of course that''s not the point).
The problem is around the "cannot-see-def" error... If you cannot see the definition of your classes, then it''s probably because you did something wrong. Solving it would problem wipe out the error list.
I''d guess that IDirectDraw is declared but contains nothing or something similar (he finds it but cannot tell where, or just #define #ifdef #ifndef problems... That might happens)

Have you tried it with VC6? Have you set correctly your directories in your options? Maybe it''s just cause the files are misplaced.

Programming is:
A.The art of debugging a blank sheet of paper (or an empty file).
B.A pastime similar to banging one's head against a wall, but with fewer opportunities for reward.
C.The most fun you can have with your clothes on (although clothes are not mandatory).
Now I know what I'm made of, and I'm afraid of it...
Poltras
Poltras
(( BTW, he created lpDD2 from lpDD with QueryInterface... ))

Oh yeah! When you put code, please use the source tags... It gives something like this:

    
LPDIRECTDRAW lpDD;
LPDIRECTDRAW lpDD2;

int DirectDrawInit(HWND hwnd)
{
HRESULT ddrval;

ddrval = DirectDrawCreate( NULL, &lpDD, NULL );
if( ddrval != DD_OK )
{
return(0);
}

ddrval = lpDD->QueryInterface(IID_IDirectDraw2,
(LPVOID *)&lpDD2);
if( ddrval != DD_OK )
{
lpDD->release();
return(0);
}

lpDD->release();

ddrval = lpDD2->SetCooperativeLevel( hwnd,
DDSCL_EXCLUSIVE |
DDSCL_FULLSCREEN );
if( ddrval != DD_OK )
{
lpDD2->Release();
return(0);
}


ddrval = lpDD2->SetDisplayMode( 640, 480, 8);
if( ddrval != DD_OK )
{
lpDD2->Release();
return(0);
}

return(1);
}



Oh and read a bit of Code Complete, please... Just a trick, because lines like "if( ddrval != DD_OK ) { lpDD2->Release(); return(0); }" are really hard to read. Don''t take it personnally, I just want to give you tips .


Programming is:
A.The art of debugging a blank sheet of paper (or an empty file).
B.A pastime similar to banging one's head against a wall, but with fewer opportunities for reward.
C.The most fun you can have with your clothes on (although clothes are not mandatory).
Now I know what I'm made of, and I'm afraid of it...
Pouya
Pouya
i think this is your problem:

    
LPDIRECTDRAW2 lpDD2; //note: it''s LPDIRECTDRAW2


see if it works, that''s the only mistake i could find in your code

"The more crap you put up with, the more crap you are going to get" -Pouya
"The longest recorded flight of a chicken is 13 seconds!" -?

Topic Locked

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

Sign in to reply to this topic.