#include <Windows.h>#include <tchar.h>#include <d3d10.h>#include <d3dx10.h>ID3D10Device* pD3DDevice = NULL;IDXGISwapChain* pSwapChain = NULL;ID3D10RenderTargetView* pRenderTargetView = NULL;HINSTANCE hInstance;HWND hwnd;int width = 640;int height = 480;bool InitWindow (HINSTANCE hInstance, int width, int height);bool InitDirect3D (HWND hwnd, int width, int height);LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM);void Render ();void ShutDownDirect3D ();int APIENTRY WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow){ if (!InitWindow (hInstance, width, height)) { MessageBox (NULL, L"Window Creation Failed!", NULL, MB_OK); return false; } if (!InitDirect3D (hwnd, width, height)) { MessageBox (NULL, L"Direct3D Creation Failed!", NULL, MB_OK); return 0; } MSG msg = {0}; while (WM_QUIT != msg.message) { while (PeekMessage (&msg, NULL, 0, 0, PM_REMOVE) == TRUE) { TranslateMessage (&msg); DispatchMessage (&msg); } Render (); } return (int) msg.wParam;}bool InitWindow (HINSTANCE hInstance, int width, int height){ WNDCLASSEX WindowClass; WindowClass.cbClsExtra = 0; WindowClass.cbSize = sizeof (WNDCLASSEX); WindowClass.cbWndExtra = 0; WindowClass.hbrBackground = (HBRUSH) (COLOR_WINDOW + 1); WindowClass.hCursor = LoadCursor (NULL, IDC_ARROW); WindowClass.hIcon = LoadIcon (NULL, IDI_APPLICATION); WindowClass.hIconSm = LoadIcon (NULL, IDI_APPLICATION); WindowClass.hInstance = hInstance; WindowClass.lpfnWndProc = WndProc; WindowClass.lpszClassName = L"1"; WindowClass.lpszMenuName = NULL; WindowClass.style = 0; if (!RegisterClassEx (&WindowClass)) { MessageBox (NULL, L"Window Class Registration Failed!", NULL, MB_OK); return false; } hwnd = CreateWindowEx (WS_EX_CLIENTEDGE, L"1", L"DirectX 10", WS_OVERLAPPEDWINDOW, 315, 115, width, height, NULL, NULL, hInstance, NULL); ShowWindow (hwnd, SW_SHOWNORMAL); UpdateWindow (hwnd); return true;}bool InitDirect3D (HWND, hwnd, int width, int height){ DXGI_SWAP_CHAIN_DESC swapChainDesc; ZeroMemory (&swapChainDesc, sizeof (swapChainDesc)); swapChainDesc.BufferCount = 1; swapChainDesc.BufferDesc.Width = width; swapChainDesc.BufferDesc.Height = height; swapChainDesc.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM; swapChainDesc.BufferDesc.RefreshRate.Numerator = 60; swapChainDesc.BufferDesc.RefreshRate.Denominator = 1; swapChainDesc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT; swapChainDesc.OutputWindow = hwnd; swapChainDesc.SampleDesc.Count = 1; swapChainDesc.SampleDesc.Quality = 0; swapChainDesc.Windowed = TRUE; HRESULT hr = D3D10CreateDeviceAndSwapChain (NULL, D3D10_DRIVER_TYPE_REFERENCE, NULL, 0, D3D10_SDK_VERSION, &swapChainDesc, &pSwapChain, &pD3DDevice); if (hr != S_OK) { MessageBox (NULL, L"D3D10 Device Creation Failed!", NULL, MB_OK); return false; } ID3D10Texture2D *pBackBuffer; hr = pSwapChain -> GetBuffer (0, __uuidof (ID3D10Texture2D), (LPVOID*) &pBackBuffer); if (hr != S_OK) { MessageBox (NULL, L"SwapChain Failed to Get Buffer!", NULL, MB_OK); return false; } hr = pD3DDevice -> CreateRenderTargetView (pBackBuffer, NULL, &pRenderTargetView); pBackBuffer -> Release (); if (hr != S_OK) { MessageBox (NULL, L"Render Target View Creation Failed!", NULL, MB_OK); return false; } pD3DDevice -> OMSetRenderTargets (1, &pRenderTargetView, NULL); D3D10_VIEWPORT viewPort; viewPort.Width = width; viewPort.Height = height; viewPort.MinDepth = 0.0f; viewPort.MaxDepth = 1.0f; viewPort.TopLeftX = 0; viewPort.TopLeftY = 0; pD3DDevice -> RSSetViewports (1, &viewPort); return true;}void Render (){ if (pD3DDevice != NULL) { pD3DDevice -> ClearRenderTargetView (pRenderTargetView, D3DDevice -> ClearRenderTargetView (pRenderTargetView, D3DXCOLOR (0.0f, 0.0f, 0.0f, 0.0f)); pSwapChain -> Present (0.0); }}void ShutDownDirect3D (){ if (pRenderTargetView) { pRenderTargetView -> Release (); } if (pSwapChain) { pSwapChain -> Release (); } if (pD3D10Device) { pD3D10Device -> Release (); }}LRESULT CALLBACK WndProc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam){ switch (msg) { case WM_CLOSE: DestroyWindow (hwnd); break; case WM_DESTROY: PostQuitMessage (0); break; case WM_KEYDOWN: switch (wParam) { case VK_ESCAPE: DestroyWindow (hwnd); break; } break; } return DefWindowProc (hwnd, msg, wParam, lParam);}
Now here are my errors:
1>c:\program files (x86)\microsoft sdks\windows\v7.0a\include\objidl.h(11284): error C2061: syntax error : identifier '__RPC__in_xcount_full'
1>c:\program files (x86)\microsoft sdks\windows\v7.0a\include\objidl.h(11285): error C2059: syntax error : ')'
1>c:\program files (x86)\microsoft sdks\windows\v7.0a\include\objidl.h(11285): fatal error C1903: unable to recover from previous error(s); stopping compilation
I am not doing anything with that header file. Does anyone know how to fix this, if so please explain very "noob proof" please :P
Thanks to anyone who can help in advance!