I am learning DirectX from a book. I am getting an error on the code. Here is all mof
#include <Windows.h>
#include <tchar.h>
#include <DXGI.h>
HINSTANCE hInst;
HWND wndHandle;
int width = 640;
int height = 480;
bool InitWindow (HINSTANCE hInstance, int width, int height);
LRESULT CALLBACK WndProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPTSTR lpCmdLine, int nCMDShow)
{
if (!InitWindow(hInstance, width, height))
{
return false;
}
MSG msg = {0};
while (WM_QUIT != msg.message)
{
while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE) == TRUE)
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
return (int) msg.wParam;
}
bool InitWindow (HINSTANCE hInstance, int width, int height)
{
WNDCLASSEX wcex;
wcex.cbSize = sizeof(WNDCLASSEX);
wcex.style = CS_HREDRAW | CS_VREDRAW;
wcex.lpfnWndProc = (WNDPROC)WndProc;
wcex.cbClsExtra = 0;
wcex.cbWndExtra = 0;
wcex.hInstance = hInstance;
wcex.hIcon = 0;
wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
wcex.hbrBackground = (HBRUSH) (COLOR_WINDOW + 1);
wcex.lpszMenuName = NULL;
wcex.lpszClassName = TEXT("DirectXExample");
wcex.hIconSm = 0;
RegisterClassEx(&wcex);
RECT rect = {0, 0, width, height};
AdjustWindowRect(&rect, WS_OVERLAPPEDWINDOW, FALSE);
wndHandle = CreateWindow(TEXT("DirectXExample"),
TEXT("DirectXExample"),
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,
CW_USEDEFAULT,
rect.right - rect.left,
rect.bottom - rect.top,
NULL,
NULL,
hInstance,
NULL);
if (!wndHandle)
{
return false;
}
ShowWindow(wndHandle, SW_SHOW);
UpdateWindow(wndHandle);
return true;
}
LRESULT CALLBACK WndProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message)
{
case WM_KEYDOWN:
switch (wParam)
{
case VK_ESCAPE:
PostQuitMessage(0);
break;
}
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
}
return DefWindowProc (hWnd, message, wParam, lParam);
DXGI_SWAP_CHAIN_DESC swapChainDesc;
swapChainDesc.BufferDesc.Width = 640;
swapChainDesc.BufferDesc.Height = 480;
swapChainDesc.BufferDesc.RefreshRate.Numerator = 60;
swapChainDesc.BufferDesc.RefreshRate.Denominator = 1;
swapChainDesc.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
swapChainDesc.BufferDesc.ScanlineOrdering = DXGI_MODE_SCANLINE_ORDER_UNSPECIFIED;
swapChainDesc.BufferDesc.Scaling = DXGI_MODE_SCALING_UNSPECIFIED;
swapChainDesc.SampleDesc.Count = 1;
swapChainDesc.SampleDesc.Quality = 0;
swapChainDesc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
swapChainDesc.BufferCount = 1;
swapChainDesc.OutputWindow = hWnd;
swapChainDesc.Windowed = TRUE;
swapChainDesc.SwapEffect = DXGI_SWAP_EFFECT_DISCARD;
swapChainDesc.Flags = DXGI_SWAP_CHAIN_FLAG_NONPREROTATED;
HRESULT D3D10CreateDeviceAndSwapChain ( NULL,
D3D10_DRIVER_TYPE_REFERENCE,
NULL,
0,
D3D10_SDK_VERSION,
&swapChainDesc,
&swapChain,
&pD3DDevice);
}
I get an error on the "," after the NULL in the block of code at the end. It says "Expected a ')'". Here are my build errors:
Error 1 error C2065: 'D3D10_DRIVER_TYPE_REFERENCE' : undeclared identifier c:\users\michael\documents\visual studio 2012\projects\directx\winmain.cpp 134 1 DirectX
Error 2 error C2065: 'D3D10_SDK_VERSION' : undeclared identifier c:\users\michael\documents\visual studio 2012\projects\directx\winmain.cpp 137 1 DirectX
Error 3 error C2065: 'swapChain' : undeclared identifier c:\users\michael\documents\visual studio 2012\projects\directx\winmain.cpp 139 1 DirectX
Error 4 error C2065: 'pD3DDevice' : undeclared identifier c:\users\michael\documents\visual studio 2012\projects\directx\winmain.cpp 140 1 DirectX
Error 5 error C2078: too many initializers c:\users\michael\documents\visual studio 2012\projects\directx\winmain.cpp 140 1 DirectX
6 IntelliSense: expected a ')' c:\Users\Michael\Documents\Visual Studio 2012\Projects\DirectX\winmain.cpp 133 47 DirectX
Please help.