Skip to main content
gamedev.net
🔒 Locked

DirectX 10 Compile Errors

Started by -LeetGamer- 4 replies 1.9k views
Original Post
-LeetGamer-
-LeetGamer-
Well I bought the book "Beginning DirectX 10 Game Programming" by Wendy Jones. I have Microsoft Visual Studio 2010. When I compile this code:

[Rawr - 'source', not 'code' tags for this much code. This is not difficult. There is a sticky and everything. -Zahlman]

#include <D3D10.h>#include <D3DX10.h>// Include the Windows header file, needed for all Windows applications#include <Windows.h>#include <tchar.h>// Direct3D Global VariablesID3D10Device* pD3DDevice = NULL;IDXGISwapChain* pSwapChain = NULL;ID3D10RenderTargetView* pRenderTargetView = NULL;HINSTANCE hInstance; // Global handle to the applications instanceHWND hwnd; // Global variable to hold the window handleint width = 640;int height = 480;// Forward declarationsvoid Render ();bool InitDirect3D (HWND hwnd, int width, int height);void ShutdownDirect3D ();bool InitWindow (HINSATNCE hInstance, int width, int height);LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM);// This is winmain, the entry point for Windows applicationsint APIENTRY _tWinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow){	// Initialize the window	if (!InitWindow (hInstance, width, height))	{		MessageBox (NULL, L"Window couldn't be initialied", NULL, MB_OK);		return false;	}	// Called after creating the window	if (!InitDirect3D (mainhwnd, width, height))	{		MessageBox (NULL, L"Direct3D Initialization Failed", NULL, MB_OK);		return 0;	}	// Main message loop	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;}/************************************************************ InitWindow* Inits and Crates and main app window* Inputs - application instance - HINSATNCE			Window width - int			Window height - int* Outputs - true if successful, false if faled - bool***********************************************************/bool InitWindow (HINSTANCE hInstance, int width, int height){	WNDCLASSEX WindowClass;	// Fill in the WNDCLASSEX structure.	// This describes how the window will look to the system.	WindowClass.cbSize = sizeof (WNDCLASSEX); // The size of the structure	WindowClass.style = 0; // The class style	WindowClass.lpfnWndProc = (WNDPROC) WndProc; // The window procedure callback	WindowClass.cbClsExtra = 0; // Extra bytes to allocate for this class	WindowClass.cbWndExtra = 0; // Extra bytes to allocate for this instance	WindowClass.hInstance = hInstance; // Handle to the application instance	WindowClass.hIcon = 0; // Icon to assosiate with the application	WindowClass.hCursor = LoadCursor (NULL, IDC_ARROW); // The default cursor to use	WindowClass.hbrBackground = (HBRUSH) (COLOR_WINDOW + 1); // The background color	WindowClass.lpszManuName = NULL; // The resource name for the menu	WindowClass.lpszClassname = TEXT("DirectX Example"); // The class name being created	WindowClass.hIconSm = 0; // The handle to the small icon	RegisterClassEx (&WindowClass);	//Resize the window	RECT rect = {		0,		0,		width,		height	};	AdjustWindowRect (▭, WS_OVERLAPPEDWINDOW, FALSE);	// Create the window from the class above	hwnd = CreateWindow (TEXT ("DirectX Example"),						 TEXT ("DirectX Example"),						 WS_OVERLAPPEDWINDOW,						 480, 640,						 rect.right - rect.left,						 rect.bottom - rect.top,						 NULL, NULL,						 hInstance, NULL);	if (!hwnd)	{		MessageBox (NULL, L"Window Creation Failed", NULL, MB_OK);		return false;	}	// Display the window on the screen	ShowWindow (hwnd, SW_SHOWNORMAL);	UpdateWindow (hwnd);	return true;}/************************************************************ InitDirect3D* Initialize Direct3D* Inputs - Parent window handle - HWND				Window width - int				Window height - int* Outputs - true if successful, false if failed - bool***********************************************************/bool InitDirect3D (HWND hwnd, int width, int height){	// Create the clear the DXGI_SWAP_CHAIN_DESC structure	DXGI_SWAP_CHAIN_DESC swapChainDesc;	ZeroMemory (&swapChainDesc, sizeof (swapChainDesc));	// Fill in the needed values	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;	// Create the D3D device and the swap chain	HRESULT hr = D3D10CreateDeviceAndSwapChain (NULL,												D3D10_DRIVER_TYPE_REFERENCE,												NULL, 0,												D3D10_SDK_VERSION,												&swapChainDesc,												&pSwapChain,												&pD3DDevice);		// Error checking. Make sure the device was created	if (hr != S_OK)	{		MessageBox (NULL, L"D3D10 Device Failed", NULL, MB_OK);		return false;	}	// Get the back buffer from the swapchain	ID3D10Texture2D *pBackBuffer;	hr = pSwapChain -> GetBuffer (0, __uuidof (ID3D10Texture2D), (LPVOID*) &pBackBuffer);	if (hr != S_OK)	{		MessageBox (NULL, L"ID3D10 Texture Failed", NULL, MB_OK);		return false;	}	// Create the render target view	hr = pD3DDevice -> CreateRenderTargetView (pBackBuffer, NULL, &pRenderTargetView);	// Release the back buffer	pBackBuffer -> Release();	// Make sure the render target view was created successfully	if (hr != S_OK)	{		MessageBox (NULL, L"Render Target View Failed", NULL, MB_OK);		return false;	}	// Set the render target	pDD3Device -> OMSetRenderTarget (1, &pRenderTargetView, NULL);	// Create and set the view port	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;}/************************************************************ Render* All drawing happens in the Render function* Inputs - void* Outputs - void***********************************************************/void Render (){	if (pD3DDevice != NULL)	{		// Clear the target buffer		pD3DDevice -> ClearRenderTargetView (pRenderTargetView, D3DXCOLOR (0.0f, 0.0f, 0.0f, 0.0f));		// All drawing goes here				// Display the next item in the swap chain		pSwapChain -> Present (0, 0);	}}/************************************************************ ShutdownDirect3D* Closes down and releases the resources for Direct3D* Inputs - void* Outputs - void***********************************************************/void ShutdownDirect3D (){	// Release the render target	if (pRenderTargetView)	{		pRenderTargetView -> Release ();	}		// Release the swapchain	if (pSwapChain)	{		pSwapChain -> Release ();	}	// Release the D3D device	if (pD3DDevice)	{		pD3DDevice -> Release ();	}}/************************************************************ WndProc* The main window procedure for the application* Inputs - application window handle - HWND				message sent to the window - UINT				wParam of the message being sent - WPARAM				lParam of the message being sent - LPARAM* Outputs - LRESULT***********************************************************/LRESULT CALLBACK WndProc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam){	// Check any avalible messages from the queue	switch (msg)	{		// Allow the user to press the Escape key to close the application	case WM_KEYDOWN:		switch (wParam)		{		case VK_ESCAPE:			PostQuitMessage (0);			break;		}	case WM_DESTROY:	case WM_CLOSE:		PostQuitMessage (0);		break;	}	// Always return the message to the default window procedure for further processing	return DegWindowProc (hwnd, msg, wParam, lParam);}


I have set up the compiler correctly I think, with the lib and include folders included, but when I compile I get these 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


That file isn't even part of the DX10 library, I've never seen or used it before, any help ?

[Edited by - Zahlman on September 18, 2010 6:27:14 AM]
-LeetGamer-
-LeetGamer-
I don't really get it :P lol, here are the include things in order, Windows isn't at the top, is it supposed to be or?...

$(VCInstallDir)include
$(VCInstallDir)atlmfc\include
$(WindowsSdkDir)include
$(FrameworkSDKDir)\include

Thanks.
-LeetGamer-
-LeetGamer-
This is all that there is =/

Picture:

http://img811.imageshack.us/img811/8971/97806025.png
-LeetGamer-
-LeetGamer-
Can anyone please help me? I am also having the exact same issue with DarkGDK :(

Topic Locked

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

Sign in to reply to this topic.