I discovered that VC++ and DX11 are not compatible, but, my VS2010 and DX11 are. On chapter 3 of the book i wrote out the code, linked the libraries and include file of DX11 to VS2010. However, im getting an ungodly amount of errors all related to DX11. On top of that im also getting "System can not find file specified". Now is there a possibility that the DX11 function calls are different from DX9? If so where can i find the related code in DX11? And two, how can i fix the "System can not find file specified"?
I will include my code if there is possibility of it being a syntax issue.
EDIT:: I would like to note that when i installed DX11 i received a S1023 error.
The following is my code::
#include<d3d11.h>
#include<windows.h>
#include<time.h>
#include<iostream>
using namespace std;
//#pragma comment(lib,"d3d11.lib")
//#pragma comment(lib, "d3dx11.lib")
const string APPTITLE = "Direct3D_Windowed";
const int SCREENW = 1024;
const int SCREENH = 768;
LPDIRECT3D11 d3d = NULL;
LPDIRECT3DDEVICE11 d3ddev = NULL;
bool gameover = false;
#define KEY_DOWN(vk_code)((GetAsyncKeyState(vk_code)&0x8000)? 1 : 0)
bool Game_Init(HWND window)
{
MessageBox(window, "Game_Init", "BREAKPOINT", 0);
d3d = Direct3DCreate11(D3D_SDK_VERSION);
if(d3d = NULL)
{
MessageBox(window, "Error initializing Direct3D", "Error", MB_OK);
return 0;
}
D3DPRESENT_PARAMETERS d3dpp;
ZeroMemory(&d3dpp, sizeof(d3dpp));
d3dpp.Windowed = TRUE;
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
d3dpp.BackBufferFormat = D3DFMT_X8R8G8B8;
d3dpp.BackBufferCount = 1;
d3dpp.BackBufferWidth = SCREENW;
d3dpp.BackBufferHeight = SCREENH;
d3dpp.hDeviceWindow = window;
d3d->CreateDevice(
D3DADAPTER_DEFAULT,
D3DDEVTYPE_HAL,
window,
D3DCREATE_SOFTWARE_VERTEXPROCESSING,
&d3dpp,
&d3ddev);
if(d3ddev = NULL)
{
MessageBox(window, "Error creating Direct3D device", "Error", MB_OK);
return 0;
}
return true;
}
void Game_Run(HWND hwnd)
{
if(!d3ddev)return;
d3ddev->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0,255,0), 1.0f, 0);
if(d3ddev->BeginScene())
{
//do something
d3ddev->EndScene();
d3ddev->Present(NULL, NULL, NULL, NULL);
}
if(KEY_DOWN(VK_ESCAPE))
PostMessage(hwnd, WM_DESTROY, 0,0);
}
void Game_End(HWND hwnd)
{
MessageBox(hwnd, "Program is about to end", "Game_End", MB_OK);
if(d3ddev) d3ddev->Release();
if(d3d)d3d->Release();
}
LRESULT WINAPI WinProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch(msg)
{
case WM_DESTROY:
gameover = true;
PostQuitMessage(0);
return 0;
}
return DefWindowProc(hWnd, msg, wParam, lParam);
}
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
WNDCLASSEX wc;
wc.cbSize = sizeof(WNDCLASSEX);
wc.style = CS_HREDRAW | CS_VREDRAW;
wc.lpfnWndProc =(WNDPROC)WinProc;
wc.cbClsExtra = 0;
wc.hInstance = hInstance;
wc.hIcon = NULL;
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
wc.lpszMenuName = NULL;
wc.lpszClassName = APPTITLE.c_str();
wc.hIconSm = NULL;
RegisterClassEx(&wc);
HWND window = CreateWindow(APPTITLE.c_str(), APPTITLE.c_str(), WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, SCREENW, SCREENH, NULL, NULL, hInstance, NULL);
if(window == 0) return 0;
ShowWindow(window, nCmdShow);
UpdateWindow(window);
if(!Game_Init(window)) return 0;
MSG message;
while(!gameover)
{
if(PeekMessage(&message, NULL, 0,0, PM_REMOVE))
{
TranslateMessage(&message);
DispatchMessage(&message);
}
Game_Run(window);
}
Game_End(window);
return message.wParam;
}[/quote]
The following errors are reported::
(15) : error C2146: syntax error : missing ';' before identifier 'd3d'
(15) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
(15) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
(16) : error C2146: syntax error : missing ';' before identifier 'd3ddev'
(16) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
(16) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
(28) : error C2065: 'D3D_SDK_VERSION' : undeclared identifier
(28) : error C3861: 'Direct3DCreate11': identifier not found
(35) : error C2065: 'D3DPRESENT_PARAMETERS' : undeclared identifier
(35) : error C2146: syntax error : missing ';' before identifier 'd3dpp'
(35) : error C2065: 'd3dpp' : undeclared identifier
(36) : error C2065: 'd3dpp' : undeclared identifier
(36) : error C2065: 'd3dpp' : undeclared identifier
(36) : error C2070: ''unknown-type'': illegal sizeof operand
(37) : error C2065: 'd3dpp' : undeclared identifier
(37) : error C2228: left of '.Windowed' must have class/struct/union type is ''unknown-type''
(38) : error C2065: 'd3dpp' : undeclared identifier
(38) : error C2228: left of '.SwapEffect' must have class/struct/union type is ''unknown-type''
(38) : error C2065: 'D3DSWAPEFFECT_DISCARD' : undeclared identifier
(39) : error C2065: 'd3dpp' : undeclared identifier
(39) : error C2228: left of '.BackBufferFormat' must have class/struct/union type is ''unknown-type''
(39) : error C2065: 'D3DFMT_X8R8G8B8' : undeclared identifier
(40) : error C2065: 'd3dpp' : undeclared identifier
(40) : error C2228: left of '.BackBufferCount' must have class/struct/union type is ''unknown-type''
(41) : error C2065: 'd3dpp' : undeclared identifier(41) : error C2228: left of '.BackBufferWidth' must have class/struct/union type is ''unknown-type''
(42) : error C2065: 'd3dpp' : undeclared identifier
(42) : error C2228: left of '.BackBufferHeight' must have class/struct/union type is ''unknown-type''
(43) : error C2065: 'd3dpp' : undeclared identifier
(43) : error C2228: left of '.hDeviceWindow' must have class/struct/union type is ''unknown-type''
(45) : error C2227: left of '->CreateDevice' must point to class/struct/union/generic type type is 'int'
(46) : error C2065: 'D3DADAPTER_DEFAULT' : undeclared identifier
(47) : error C2065: 'D3DDEVTYPE_HAL' : undeclared identifier
(49) : error C2065: 'D3DCREATE_SOFTWARE_VERTEXPROCESSING' : undeclared identifier
(50) : error C2065: 'd3dpp' : undeclared identifier
(65) : error C2227: left of '->Clear' must point to class/struct/union/generic type type is 'int'
(65) : error C2065: 'D3DCLEAR_TARGET' : undeclared identifier
(65) : error C3861: 'D3DCOLOR_XRGB': identifier not found
(67) : error C2227: left of '->BeginScene' must point to class/struct/union/generic type type is 'int'
(71) : error C2227: left of '->EndScene' must point to class/struct/union/generic type type is 'int'
(73) : error C2227: left of '->Present' must point to class/struct/union/generic type type is 'int'
(87) : error C2227: left of '->Release' must point to class/struct/union/generic type type is 'int'
(88) : error C2227: left of '->Release' must point to class/struct/union/generic type type is 'int'
[/quote]