Archived

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

DirectDraw Problem

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

I''m trying to initialize my window with this DirectDraw code that i''ve used before, but I''m encountering errors with the compiler with the SetDisplayMode and CreateSurface functions. Mind you i''m now using the Visual Studio .NET compiler and not VC++ 6 anymore. Hoping someone can help!
/* Metaballs Demo */

#include <windows.h>
#include <windowsx.h>
#include <ddraw.h>

#pragma comment ( lib, "ddraw.lib" )
#define WIN32_LEAN_AND_MEAN
#define INIT_DXSTRUCT(dxs) {ZeroMemory(&dxs, sizeof(dxs)); dxs.dwSize = sizeof(dxs);}

bool bDemo_Running = true;

LPDIRECTDRAW lpdd7;
LPDIRECTDRAWSURFACE7 lpddsPrimary;
LPDIRECTDRAWSURFACE7 lpddsOffScreen;
DDSURFACEDESC2 MainSurface;

LRESULT CALLBACK WndProc( HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam )
{
	switch( Msg )
	{
	case WM_CLOSE:
	case WM_QUIT:
	case WM_DESTROY:
		{
			PostQuitMessage( 0 );
			bDemo_Running = false;
		}
		break;
	}
	return DefWindowProc( hWnd, Msg, wParam, lParam );
}

int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine,
				   int nCmdShow )
{
	HWND hWnd;
	MSG Msg;
	WNDCLASSEX WindowClass;

	WindowClass.cbSize = sizeof(WNDCLASSEX);
	WindowClass.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC | CS_DBLCLKS;
	WindowClass.lpfnWndProc = WndProc;
	WindowClass.cbClsExtra = 0;
	WindowClass.cbWndExtra = 0;
	WindowClass.hInstance = hInstance;
	WindowClass.hIcon = LoadIcon(NULL, IDI_WINLOGO);
	WindowClass.hCursor = LoadCursor(NULL, IDC_ARROW);
	WindowClass.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
	WindowClass.lpszMenuName = NULL;
	WindowClass.lpszClassName = "Metaballs";
	WindowClass.hIconSm = LoadIcon(NULL, IDI_WINLOGO);

	RegisterClassEx(&WindowClass);

	hWnd = CreateWindowEx(NULL, "Metaballs", "Metaballs Demo", WS_VISIBLE | 
						  WS_OVERLAPPEDWINDOW, 0, 0, 640, 480,
						  NULL, NULL, hInstance, NULL);
	
	ShowCursor(false);

	// Create Our DirectDraw7 Object


	DirectDrawCreateEx(NULL, (void**)&lpdd7, IID_IDirectDraw7, NULL);

	// Set Our DirectDraw Cooperation Level


	lpdd7 -> SetCooperativeLevel(hWnd, DDSCL_FULLSCREEN | DDSCL_ALLOWREBOOT | DDSCL_EXCLUSIVE);

	// Set Our Display Mode


	lpdd7 -> SetDisplayMode( 640, 480, 32, 0, 0 );

	// Initialize Our DirectDraw Surface Description Structure


	INIT_DXSTRUCT(MainSurface);
	MainSurface.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT;
	MainSurface.dwBackBufferCount = 1;
	MainSurface.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_COMPLEX |
								 DDSCAPS_FLIP;

	// Create Our Primary Surface

	
	lpdd7 -> CreateSurface(&MainSurface, &lpddsPrimary, NULL);

	// Create Our OffScreen Surface

	
	MainSurface.ddsCaps.dwCaps = DDSCAPS_BACKBUFFER;
	lpddsPrimary->GetAttachedSurface(&MainSurface.ddsCaps, &lpddsOffScreen);

	while( bDemo_Running == true )
	{
		if(PeekMessage(&Msg, NULL, 0, 0, PM_REMOVE))
		{
			TranslateMessage(&Msg);
			DispatchMessage(&Msg);
		}
	}
}
And these are the errors: IDirectDraw::SetDisplayMode: function doesnot take 5 parameters IDirectDraw::CreateSurface : cannot convert parameter 1 from DDURFACEDESC2 *__w64 to LPDDSURFACEDESC Thanks in advance!

Share this post


Link to post
Share on other sites