I use MSVC++ 5.0, and I just got "Tricks of The Windwos Game Programming Gurus". I installed the DXSDK, and i have directed MSVC++ to the lib/h files, but this code won't work:
Code:
#include <windows.h>
#include <windowsx.h>
#include <stdio.h>
#include <ddraw.h>
#define WIN32_LEAN_AND_MEAN
#define KEYDOWN(vk_code) ((GetAsyncKeyState(vk_code) & 0x8000) ? 1 : 0)
#define KEYUP(vk_code) ((GetAsyncKeyState(vk_code) & 0x8000) ? 0 : 1)
int Game_Init();
LPDIRECTDRAW7 lpdd7;
HDC hdc;
HWND hwnd;
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
PAINTSTRUCT ps;
switch(msg)
{
case WM_CREATE:
return 0;
break;
case WM_PAINT:
hdc = BeginPaint(hwnd,&ps);
EndPaint(hwnd,&ps);
break;
case WM_DESTROY:
case WM_CLOSE:
PostQuitMessage(0);
return 0;
break;
}
return (DefWindowProc(hwnd,msg,wParam,lParam));
}
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpcmdline, int ncmdshow)
{
WNDCLASSEX Window;
MSG msg;
Window.cbSize= sizeof(WNDCLASSEX);
Window.style= CS_DBLCLKS | CS_OWNDC | CS_HREDRAW | CS_VREDRAW;
Window.lpfnWndProc= WndProc;
Window.cbClsExtra= 0;
Window.cbWndExtra= 0;
Window.hInstance= hInstance;
Window.hIcon= LoadIcon (NULL, IDI_WINLOGO);
Window.hCursor= LoadCursor (NULL, IDC_ARROW);
Window.hbrBackground= CreateSolidBrush(RGB(255,255,255));
Window.lpszMenuName= NULL;
Window.lpszClassName= "Window";
Window.hIconSm= LoadIcon (NULL, IDI_WINLOGO);
if (!RegisterClassEx(&Window)) return 0;
hwnd = CreateWindowEx(NULL,
"Window",
"First DirectX Program",
WS_OVERLAPPED | WS_VISIBLE,
0,0,640,480,
NULL,NULL,
hInstance,
NULL);
if (!(hwnd)) return 0;
while(1)
{
if(PeekMessage(&msg,NULL,0,0,PM_REMOVE))
{
if(msg.message==WM_QUIT)
break;
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
lpdd7->Release();
lpdd7=NULL;
return(msg.wParam);
}
int Game_Init()
{
LPDIRECTDRAW lpdd;
if(FAILED(DirectDrawCreateEx(NULL, (void**)&lpdd, IID_IDirectDraw7, NULL)))
lpdd->Release();
lpdd=NULL;
return 0;
}
I get these errors:
First.obj : error LNK2001: unresolved external symbol _DirectDrawCreateEx@16
First.obj : error LNK2001: unresolved external symbol _IID_IDirectDraw7
Debug/First DirectX Program.exe : fatal error LNK1120: 2 unresolved externals
Error executing link.exe.