Skip to main content
GameDev.net gamedev.net
🔒 Locked

DirectDrawCreateEx problem

Started by stani Dec 15, 2000 at 4:55 PM 22 replies 2.7k views
Original Post
stani
stani
i tried to search, but the search feature is down again. My problem is as follows. I correctly installed DirectX 7.a and all that, and i''m able to seamlessly compile the samples. I added all that is needed to my own little project, including both libs, but while compiling i still get the following: warning C4024: ''DirectDrawCreateEx'' : different types for formal and actual parameter 3 now this can''t actually be true, because i''m using the exact line that all the other samples use (with minor modifications that do not affect the outcome), and they compile seamlessly. can somebody enlighten me on this? for reference, here''s my line: DirectDrawCreateEx(NULL, (VOID**)&lpDD, IID_IDirectDraw7, NULL);
stani
stani
it also tells me that flip, restore, etc are not members of IDirectDrawSurface7. anybody???
stani
stani
geez, thanks for all the great and quick responses guys. somebody point out to me if i did something wrong, is the question vague, or just nobody have any clue as to what the problem could be? i''m pretty much stuck. any help at all is appreciated. i can also post my whole code here if that would help. please please help me out on this one.
furby100
furby100
Are your library and header directories at the top of the lists?

Sorry for not replying sooner, I expected someone else to ask the question I am now, but it appears everyone expected it to happen, and so as a result, it hasn''t.



''Smile, things could get worse.''
So I smiled, and they did.


sharewaregames.20m.com

stani
stani
my lib and include dirs are at the top of the lists
my #includes are correct
i''m using the DX7 includes

i get errors like the one i mentioned above, and for every Release, Restore, GetAttachedSurface, Setthis and Setthat etc it gives me "is not a member of IDirectDraw7" or "is not a member of IdirectDrawSurface7"

the examples from the SDK compile though, dunno why

here''s my code:

#include

#include



#include


//============================================================================
// IMPLEMENTATION PRIVATE DEFINITIONS / ENUMERATIONS / SIMPLE TYPEDEFS
//============================================================================
#define SYS_APPLONGTITLE "SpriteAnimView"
#define SYS_APPWIDTH 300
#define SYS_APPHEIGHT 300
//============================================================================
// IMPLEMENTATION PRIVATE CLASS PROTOTYPES / EXTERNAL CLASS REFERENCES
//============================================================================
//============================================================================
// IMPLEMENTATION PRIVATE STRUCTURES / UTILITY CLASSES
//============================================================================
//============================================================================
// IMPLEMENTATION REQUIRED EXTERNAL REFERENCES (AVOID)
//============================================================================
//============================================================================
// IMPLEMENTATION PRIVATE DATA
//============================================================================
LPDIRECTDRAW7 lpDD = NULL;
LPDIRECTDRAWSURFACE7 lpDDSPrimary = NULL; // primary surface
LPDIRECTDRAWSURFACE7 lpDDSBack = NULL; // back buffer
DDSURFACEDESC2 ddsd;
DDSCAPS2 ddscaps;
HWND sys_hWnd;


//============================================================================
// INTERFACE DATA
//============================================================================
//============================================================================
// IMPLEMENTATION PRIVATE FUNCTION PROTOTYPES
//============================================================================
int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, \
LPSTR lpCmdLine, int nCmdShow );

LRESULT CALLBACK MainWndProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam );

// DirectDraw
int Init_DirectDraw( void );
int Shutdown_DirectDraw(void);


//============================================================================
// IMPLEMENTATION PRIVATE FUNCTIONS
//============================================================================
//============================================================================
// INTERFACE FUNCTIONS
//============================================================================
int Init_DirectDraw( void )
{
DirectDrawCreateEx( NULL,(void**) &lpDD, IID_IDirectDraw7, NULL );


lpDD->SetCooperativeLevel(sys_hWnd, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);


lpDD->SetDisplayMode(640, 480, 8);


// Create the primary surface with one back buffer.
ddsd.dwSize = sizeof(ddsd);
ddsd.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT;
ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE |
DDSCAPS_FLIP | DDSCAPS_COMPLEX;

ddsd.dwBackBufferCount = 1;

// get pointer to primary surface
lpDD->CreateSurface(&ddsd, &lpDDSPrimary, NULL);


// get pointer to back buffer
ddscaps.dwCaps = DDSCAPS_BACKBUFFER;
lpDDSPrimary->GetAttachedSurface(&ddscaps, &lpDDSBack);




return 0;
}

//windows main proc
int WINAPI WinMain( HINSTANCE hInstance,
// handle to current instance

HINSTANCE hPrevInstance,
// handle to previous instance

LPSTR lpCmdLine,
// pointer to command line

int nCmdShow
// show state of window

)
{
WNDCLASS wc;
MSG msg;
HWND hWnd;
HRESULT ddrval;


if( !hPrevInstance ) // if new, register class
{
wc.lpszClassName = "AppClass";
wc.lpfnWndProc = MainWndProc;
wc.style = CS_OWNDC | CS_VREDRAW | CS_HREDRAW;
wc.hInstance = hInstance;
wc.hIcon = LoadIcon( NULL, IDI_APPLICATION );
wc.hCursor = LoadCursor( NULL, IDC_ARROW );
wc.hbrBackground = (HBRUSH)( COLOR_WINDOW+1 );
wc.lpszMenuName = NULL;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;

RegisterClass( &wc );
}



// now create window
hWnd = CreateWindow( "AppClass",
SYS_APPLONGTITLE,
WS_VISIBLE | WS_CAPTION | WS_SYSMENU | WS_MAXIMIZEBOX | WS_MINIMIZEBOX | WS_BORDER,
0,
0,
SYS_APPWIDTH,
SYS_APPHEIGHT,
NULL,
NULL,
hInstance,
NULL
);

sys_hWnd = hWnd;

UpdateWindow( hInstance );

// complete initialization here
Init_DirectDraw();

//



//

// infinite loop
while (1)
{
while (PeekMessage (&msg, hWnd, 0, 0, PM_NOYIELD|PM_REMOVE))
{
if (msg.message == WM_QUIT)
{
return msg.wParam;
}
TranslateMessage (&msg);
DispatchMessage (&msg);
}
// draw next picture to the backbuffer

// flip the surfaces
ddrval = lpDDSPrimary->Flip(DDFLIP_WAIT, 0);
if(ddrval == DD_OK)
{
break;
}
if(ddrval == DDERR_SURFACELOST)
{
ddrval = lpDDSPrimary->Restore();
if(ddrval != DD_OK)
{
break;
}
}
if(ddrval != DDERR_WASSTILLDRAWING)
{
break;
}


}

}

// windows message handling procedure
LRESULT CALLBACK MainWndProc( HWND hWnd, UINT msg, WPARAM wParam,
LPARAM lParam )
{
switch ( msg ) {

case WM_DESTROY:
case WM_QUIT:
case WM_CLOSE:
Shutdown_DirectDraw();
exit( 0 );
break;

default:
return( DefWindowProc( hWnd, msg, wParam, lParam ));
}

return 0;
}



int Shutdown_DirectDraw(void)
{

if(lpDD != NULL)
{
if(lpDDSPrimary != NULL)
{
lpDDSPrimary->Release();
lpDDSPrimary = NULL;
}
if(lpDDSBack != NULL)
{
lpDDSBack->Release();
lpDDSBack = NULL;
}


// release all other attached surfaces here



lpDD->Release();
lpDD = NULL;
}
return 0;
}
stani
stani
the includes were outcommented by the board
they are ddraw.h windows.h and stdlib.h, respectively
ImmaGNUman
ImmaGNUman
DirectDrawCreateEx(NULL, (VOID**)&lpDD, IID_IDirectDraw7, NULL); should be changed to:

DirectDrawCreateEx(NULL, (VOID**)&lpDD, &IID_IDirectDraw7, NULL);

-----------------------------

A wise man once said "A person with half a clue is more dangerous than a person with or without one."

The Micro$haft BSOD T-Shirt
-----------------------------A wise man once said "A person with half a clue is more dangerous than a person with or without one."The Micro$haft BSOD T-Shirt
yq
yq
Another DirectDrawCreateEx problem. It wont auto complete. However plain DirectDrawCreate works fine. I installed the DirectX 8 sdk so it should work. Before that I had the directx 6 sdk.

furby100
furby100
Hold on a minute. What compiler are you using?



''Smile, things could get worse.''
So I smiled, and they did.


sharewaregames.20m.com

yq
yq
MS vc++6. I think i might have installed it wrong because directx6 worked fine.
stani
stani
yes ImmaGNUman, i changed it, and that one error disappeared, but the other errors still remain.

i use msvc++ 5.0 with dx7.0a, if that helps.
stani
stani
anybody?
yq
yq
Why wont it work (bangs head on desk)
furby100
furby100
Do this:

DirectDrawCreateEx(NULL, (VOID**)&lpDD, &IID_IDirectDraw7, NULL);


and when you want to call SetDisplayMode, do this:

lpDD->lpVTbl->SetDisplayMode(lpDD, 800, 600, 16, 0, 0);


Do that for all of the DX functions. I think somehow your compiler is set to C rather than C++. Try it, and if it doesn''t fix the problem, post. Post anyway, even if it does.




''Smile, things could get worse.''
So I smiled, and they did.


sharewaregames.20m.com

^cyer
^cyer
lpDD->SetDisplayMode(640, 480, 8, 0, 0); //5 parameters not 3
for other problems look at your functions more precise...

have fun
furby100
furby100
PS that answer was for stani, rather than yq. yq, it is generally considered good practice to start a new thread if you have an unrelated problem. Otherwise replies get misinterpreted. Don''t post a new question now, leave it as it is, but remember not to do it in future as it causes confusion.



''Smile, things could get worse.''
So I smiled, and they did.


sharewaregames.20m.com

furby100
furby100
Also, it would be:

lpDDSPrimary->lpVTbl->Release(lpDDSPrimary);

Just do that, adding an lpVTbl and having the first parameter as the calling object. What I think has happened is that there is a stray extern "C" somewhere. Check that CPLUSPLUS is defined (or maybe it''s _CPLUSPLUS, or even __CPLUSPLUS? Check in the DirectDraw header, it will have an #ifdef __CPLUSPLUS or something like that in it.)



''Smile, things could get worse.''
So I smiled, and they did.


sharewaregames.20m.com

stani
stani
thanks for the great help. i did all you guys told me to, and i also corrected the 3 params to 5.

I get still 9 errors, but also 11 warnings now! more than before! ARGH! I''ll post the compiler output here, so that you can get a clue. the code hasn''t changed except for the 3->5 params and the lpVtbl parts:


Compiling...
sprtanim.c
D:\projects\tools\SpriteAnimView\sprtanim.c(79) : warning C4022: ''function through pointer'' : pointer mismatch for actual parameter 2
D:\projects\tools\SpriteAnimView\sprtanim.c(79) : error C2198: ''function through pointer'' : too few actual parameters
D:\projects\tools\SpriteAnimView\sprtanim.c(82) : warning C4047: ''function'' : ''struct IDirectDraw7 *'' differs in levels of indirection from ''const int ''
D:\projects\tools\SpriteAnimView\sprtanim.c(82) : warning C4024: ''function through pointer'' : different types for formal and actual parameter 1
D:\projects\tools\SpriteAnimView\sprtanim.c(82) : error C2198: ''function through pointer'' : too few actual parameters
D:\projects\tools\SpriteAnimView\sprtanim.c(94) : warning C4133: ''function'' : incompatible types - from ''struct _DDSURFACEDESC2 *'' to ''struct IDirectDraw7 *''
D:\projects\tools\SpriteAnimView\sprtanim.c(94) : warning C4047: ''function'' : ''struct _DDSURFACEDESC2 *'' differs in levels of indirection from ''struct IDirectDrawSurface7 ** ''
D:\projects\tools\SpriteAnimView\sprtanim.c(94) : warning C4024: ''function through pointer'' : different types for formal and actual parameter 2
D:\projects\tools\SpriteAnimView\sprtanim.c(94) : error C2198: ''function through pointer'' : too few actual parameters
D:\projects\tools\SpriteAnimView\sprtanim.c(99) : warning C4133: ''function'' : incompatible types - from ''struct _DDSCAPS2 *'' to ''struct IDirectDrawSurface7 *''
D:\projects\tools\SpriteAnimView\sprtanim.c(99) : warning C4047: ''function'' : ''struct _DDSCAPS2 *'' differs in levels of indirection from ''struct IDirectDrawSurface7 ** ''
D:\projects\tools\SpriteAnimView\sprtanim.c(99) : warning C4024: ''function through pointer'' : different types for formal and actual parameter 2
D:\projects\tools\SpriteAnimView\sprtanim.c(99) : error C2198: ''function through pointer'' : too few actual parameters
D:\projects\tools\SpriteAnimView\sprtanim.c(183) : warning C4047: ''function'' : ''struct IDirectDrawSurface7 *'' differs in levels of indirection from ''const long ''
D:\projects\tools\SpriteAnimView\sprtanim.c(183) : warning C4024: ''function through pointer'' : different types for formal and actual parameter 1
D:\projects\tools\SpriteAnimView\sprtanim.c(183) : error C2198: ''function through pointer'' : too few actual parameters
D:\projects\tools\SpriteAnimView\sprtanim.c(190) : error C2198: ''function through pointer'' : too few actual parameters
D:\projects\tools\SpriteAnimView\sprtanim.c(235) : error C2198: ''function through pointer'' : too few actual parameters
D:\projects\tools\SpriteAnimView\sprtanim.c(240) : error C2198: ''function through pointer'' : too few actual parameters
D:\projects\tools\SpriteAnimView\sprtanim.c(249) : error C2198: ''function through pointer'' : too few actual parameters
Error executing cl.exe.

SpriteAnimView.exe - 9 error(s), 11 warning(s)

stani
stani
also, the following is in ddraw.h

#ifdef __cplusplus
extern "C" {
#endif

i don''t know if __cplusplus is being defined, but defining it by myself produced 103 errors.
Airwalker
Airwalker
Try downloading DX8 and using the classes that Microsoft wrapped Direct Draw in "ddutil.h" They work fine so far when I have used them.

As for the compiler options see if you have the options for Project Setting to
--------
Category: General
Warning Level: 3
Debug Info: Program Database for Edit and Continue
Preprocessor definitions: WIN32,_DEBUG,_WINDOWS,_MBCS
and
Project Optionsthis is what I am using for DEBUG so it might now work with DX7)
/nologo /MLd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /Fp"Debug/DirectXGraphics.pch" /YX /Fo"Debug/" /Fd"Debug/" /FD /GZ /c


It went snap...
It went snap...

Topic Locked

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

Sign in to reply to this topic.