[DirectX 10] Compile Errors

Started by
6 comments, last by 16bit_port 13 years, 7 months ago
I posted a thread on this site a week or two ago, I couldn't find it so I've decided to post a new one. I bought the "Beginning DirectX 10 Game Programming" by Wendy Jones and I have Microsoft Visual Studio 2010 installed. Everything runs fine until I start to use some real DirectX 10 code and not just Win32 code, here is my source:

#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!
Advertisement
Not really sure what could be the problem, but what I would do in this situation is comment out all the d3d10 code and have it running fine with the WIN32 stuff, then incrementally uncomment stuff back in to find the culprit (I would start with the d3d10 header files first).
http://connect.microsoft.com/VisualStudio/feedback/details/499940/error-c <- a similar error here.

Apparently ms is looking into this issue as well. It maybe be a good idea to make sure you're directx sdk is up to date, as well as your windows sdk.
Quote:Original post by LegendInStone
http://connect.microsoft.com/VisualStudio/feedback/details/499940/error-c

Apparently ms is looking into this issue as well. It maybe be a good idea to make sure you're directx sdk is up to date, as well as your windows sdk.


Seems like some of the users in that thread "solved" that issue. I would try what they did.

Quote:Original post by 16bit_port
Not really sure what could be the problem, but what I would do in this situation is comment out all the d3d10 code and have it running fine with the WIN32 stuff, then incrementally uncomment stuff back in to find the culprit (I would start with the d3d10 header files first).


I tried that and I commented out every line of DX10 code and I still had the errors, I think it happens when I include the DX10 header files in project options.

Quote:Original post by LegendInStone
http://connect.microsoft.com/VisualStudio/feedback/details/499940/error-c

Apparently ms is looking into this issue as well. It maybe be a good idea to make sure you're directx sdk is up to date, as well as your windows sdk.


I have the SDK that the book came with (2007 I believe) and the 2010 windows SDK. Does it matter what OS I am on? Because I friend of mine made a 2D Game in DX10 and I think he was in Vista when I am on Windows 7.

Quote:Original post by 16bit_port
Quote:Original post by LegendInStone
http://connect.microsoft.com/VisualStudio/feedback/details/499940/error-c

Apparently ms is looking into this issue as well. It maybe be a good idea to make sure you're directx sdk is up to date, as well as your windows sdk.


Seems like some of the users in that thread "solved" that issue. I would try what they did.


The only thing that looks like it will work on that page is this:

Quote:Posted by drkato on 12/3/2009 at 3:15 PM
To anyone running into this issue, check your system for a krufty version of the DirectX SDK. That will cause this problem. Mine was the SDK from 2007. I uninstalled it and the problem went away.


But if I uninstall my DX10 SDK how will I use DX10 lol :P

Off Topic Question:

Since I am just now getting into DX10 should I not learn it and start learning DX11 instead ?


Thanks for the help guys.
I would recommend uninstalling the 2007 sdk and installing a newer version. The older version might be using older headers which contain definitions which no longer exist anymore, and thus it's giving you these compile errors.

edit: also, with the new sdk you can still make d3d10 programs, though if you want to try d3d11 there are many similarities between the two.
Quote:
I have the SDK that the book came with (2007 I believe) and the 2010 windows SDK. Does it matter what OS I am on? Because I friend of mine made a 2D Game in DX10 and I think he was in Vista when I am on Windows 7.


You should use the latest one June 2010 (http://www.microsoft.com/downloads/en/details.aspx?FamilyID=3021d52b-514e-41d3-ad02-438a3ba730ba&displaylang=en). Since you're using Windows 7 it should be fine. Also, does your graphics card support DX10? Check its specs to be sure.

One of the solutions that I read was doing a clean build (ctrl+alt+f7 for VS 2010).

Quote:
Since I am just now getting into DX10 should I not learn it and start learning DX11 instead ?


I would stick with DX10 for now. There's no need to start with DX11. DX11 is pretty much DX10 (the api interfaces are like 99% similar) but with some extra features like tesselation (really advanced, so you don't need to worry about that since you're just starting out).
Quote:
I posted a thread on this site a week or two ago, I couldn't find it so I've decided to post a new one.


Here it is :
http://www.gamedev.net/community/forums/topic.asp?topic_id=582534&whichpage=1?

Go to your profile and there should be your latest threads. That's how I found your old one.

But anyway, that was just an FYI. ;)

This topic is closed to new replies.

Advertisement