Sign in to follow this  
Rudra

DX11 [C++] Linking libraries and outdated VS-VC++

Recommended Posts

Rudra    105
Okay so here is my dilemma. I have purchased "Beginning game Programming 3rd ed" by Jonathan S. Harbour. The book uses the Xp OS and DX9, and VC++. Im using a Win 7 and DX11 with VC++ Express edition.

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 "[i]System can not find file specified[/i]". 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::

[quote]#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::

[quote]

(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]

Share this post


Link to post
Share on other sites
SiCrane    11839
DirectX changed a lot between DirectX 9 and DirectX 11. You can't take DirectX 9 code and change it to DirectX 11 code just by changing the 9s to 11s, and there isn't a simple one to one mapping from the old functions to the new functions.

Share this post


Link to post
Share on other sites
Rudra    105
[quote name='SiCrane' timestamp='1324693439' post='4896978']
DirectX changed a lot between DirectX 9 and DirectX 11. You can't take DirectX 9 code and change it to DirectX 11 code just by changing the 9s to 11s, and there isn't a simple one to one mapping from the old functions to the new functions.
[/quote]




Thank you for the reply. My next question. What DX9 edition do i need for Windows 7. I have VC++ 2008, those tow should be compatible.

Share this post


Link to post
Share on other sites
DarkRadeon    108
just use the last DX SDK...

here are some guidelines for Direct3D 11 migration..[url="http://msdn.microsoft.com/en-us/library/ff476190(v=VS.85).aspx"]http://msdn.microsoft.com/en-us/library/ff476190(v=VS.85).aspx[/url]

Share this post


Link to post
Share on other sites
Rudra    105
[quote name='DarkRadeon' timestamp='1324790147' post='4897207']
just use the last DX SDK...

here are some guidelines for Direct3D 11 migration..[url="http://msdn.microsoft.com/en-us/library/ff476190%28v=VS.85%29.aspx"]http://msdn.microsof...0(v=VS.85).aspx[/url]


[/quote]

Ah, yes. this will be of service, thank you.

Share this post


Link to post
Share on other sites
Rudra    105
Okay, so I found that DX11 is backwards compatible for DX10 and DX9. I wrote the code in VS2010Professional, and made the neccessary include and library links. The links were linked to DX9 and the code compiled. However some issues persisted. Blow is the fresh code and the list of errors.

[quote]
#include<windows.h>
#include<d3d9.h>
#include<time.h>
#include<iostream>
using namespace std;

const string APPTITLE = "Direct3D_Windowed";
const int SCREENW = 1024;
const int SCREENH = 768;

LPDIRECT3D9 d3d = NULL;
LPDIRECT3DDEVICE9 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 = Direct3DCreate9(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]


Wheh i run the program the following is generated::

[quote]
ntdll.dll', Cannot find or open the PDB file
kernel32.dll', Cannot find or open the PDB file
KernelBase.dll', Cannot find or open the PDB file
d3d9.dll', Cannot find or open the PDB file
msvcrt.dll', Cannot find or open the PDB file
sechost.dll', Cannot find or open the PDB file
rpcrt4.dll', Cannot find or open the PDB file
sspicli.dll', Cannot find or open the PDB file
cryptbase.dll', Cannot find or open the PDB file
user32.dll', Cannot find or open the PDB file
gdi32.dll', Cannot find or open the PDB file
lpk.dll', Cannot find or open the PDB file
usp10.dll', Cannot find or open the PDB file
advapi32.dll', Cannot find or open the PDB file
version.dll', Cannot find or open the PDB file
d3d8thk.dll', Cannot find or open the PDB file
dwmapi.dll', Cannot find or open the PDB file
msvcp100d.dll', Symbols loaded.
'msvcr100d.dll', Symbols loaded.
apphelp.dll', Cannot find or open the PDB file
AcLayers.dll', Cannot find or open the PDB file
'shell32.dll', Cannot find or open the PDB file
shlwapi.dll', Cannot find or open the PDB file
ole32.dll', Cannot find or open the PDB file
oleaut32.dll', Cannot find or open the PDB file
userenv.dll', Cannot find or open the PDB file
'profapi.dll', Cannot find or open the PDB file
winspool.drv', Cannot find or open the PDB file
mpr.dll', Cannot find or open the PDB file
imm32.dll', Cannot find or open the PDB file
msctf.dll', Cannot find or open the PDB file
[/quote]
^ I get the feeling this has something to do with the output path.

When i press ctrl+F5, the output window is blank, as if it is running. But the window that the code is supposed to produce, does not appear.

So what am i doing wrong?

Share this post


Link to post
Share on other sites
SiCrane    11839
You should really check the return value of every API function you call, and when you do you should do more than return 0 when you get an error. At the very minimum for Windows API functions call GetLastError() to find out what caused the problem. In this particular case, at least one of your problems is that you didn't either 0 out or manually assign to every member of the WNDCLASSEX structure.

Share this post


Link to post
Share on other sites
Rudra    105
[quote name='SiCrane' timestamp='1325296054' post='4898330']
You should really check the return value of every API function you call, and when you do you should do more than return 0 when you get an error. At the very minimum for Windows API functions call GetLastError() to find out what caused the problem. In this particular case, at least one of your problems is that you didn't either 0 out or manually assign to every member of the WNDCLASSEX structure.
[/quote]

Thnak you for the reply. Sorry for thrednomancing. I'd like to request if at all possible that you augment my code. Im not too familiar with DirectX.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this  

  • Similar Content

    • By gsc
      Hi! I am trying to implement simple SSAO postprocess. The main source of my knowledge on this topic is that awesome tutorial.
      But unfortunately something doesn't work... And after a few long hours I need some help. Here is my hlsl shader:
      float3 randVec = _noise * 2.0f - 1.0f; // noise: vec: {[0;1], [0;1], 0} float3 tangent = normalize(randVec - normalVS * dot(randVec, normalVS)); float3 bitangent = cross(tangent, normalVS); float3x3 TBN = float3x3(tangent, bitangent, normalVS); float occlusion = 0.0; for (int i = 0; i < kernelSize; ++i) { float3 samplePos = samples[i].xyz; // samples: {[-1;1], [-1;1], [0;1]} samplePos = mul(samplePos, TBN); samplePos = positionVS.xyz + samplePos * ssaoRadius; float4 offset = float4(samplePos, 1.0f); offset = mul(offset, projectionMatrix); offset.xy /= offset.w; offset.y = -offset.y; offset.xy = offset.xy * 0.5f + 0.5f; float sampleDepth = tex_4.Sample(textureSampler, offset.xy).a; sampleDepth = vsPosFromDepth(sampleDepth, input.uv).z; const float threshold = 0.025f; float rangeCheck = abs(positionVS.z - sampleDepth) < ssaoRadius ? 1.0 : 0.0; occlusion += (sampleDepth <= samplePos.z + threshold ? 1.0 : 0.0) * rangeCheck; } occlusion = saturate(1 - (occlusion / kernelSize)); And current result: http://imgur.com/UX2X1fc
      I will really appreciate for any advice!
    • By isu diss
       I'm trying to code Rayleigh part of Nishita's model (Display Method of the Sky Color Taking into Account Multiple Scattering). I get black screen no colors. Can anyone find the issue for me?
       
      #define InnerRadius 6320000 #define OutterRadius 6420000 #define PI 3.141592653 #define Isteps 20 #define Ksteps 10 static float3 RayleighCoeffs = float3(6.55e-6, 1.73e-5, 2.30e-5); RWTexture2D<float4> SkyColors : register (u0); cbuffer CSCONSTANTBUF : register( b0 ) { float fHeight; float3 vSunDir; } float Density(float Height) { return exp(-Height/8340); } float RaySphereIntersection(float3 RayOrigin, float3 RayDirection, float3 SphereOrigin, float Radius) { float t1, t0; float3 L = SphereOrigin - RayOrigin; float tCA = dot(L, RayDirection); if (tCA < 0) return -1; float lenL = length(L); float D2 = (lenL*lenL) - (tCA*tCA); float Radius2 = (Radius*Radius); if (D2<=Radius2) { float tHC = sqrt(Radius2 - D2); t0 = tCA-tHC; t1 = tCA+tHC; } else return -1; return t1; } float RayleighPhaseFunction(float cosTheta) { return ((3/(16*PI))*(1+cosTheta*cosTheta)); } float OpticalDepth(float3 StartPosition, float3 EndPosition) { float3 Direction = normalize(EndPosition - StartPosition); float RayLength = RaySphereIntersection(StartPosition, Direction, float3(0, 0, 0), OutterRadius); float SampleLength = RayLength / Isteps; float3 tmpPos = StartPosition + 0.5 * SampleLength * Direction; float tmp; for (int i=0; i<Isteps; i++) { tmp += Density(length(tmpPos)-InnerRadius); tmpPos += SampleLength * Direction; } return tmp*SampleLength; } static float fExposure = -2; float3 HDR( float3 LDR) { return 1.0f - exp( fExposure * LDR ); } [numthreads(32, 32, 1)] //disptach 8, 8, 1 it's 256 by 256 image void ComputeSky(uint3 DTID : SV_DispatchThreadID) { float X = ((2 * DTID.x) / 255) - 1; float Y = 1 - ((2 * DTID.y) / 255); float r = sqrt(((X*X)+(Y*Y))); float Theta = r * (PI); float Phi = atan2(Y, X); static float3 Eye = float3(0, 10, 0); float ViewOD = 0, SunOD = 0, tmpDensity = 0; float3 Attenuation = 0, tmp = 0, Irgb = 0; //if (r<=1) { float3 ViewDir = normalize(float3(sin(Theta)*cos(Phi), cos(Theta),sin(Theta)*sin(Phi) )); float ViewRayLength = RaySphereIntersection(Eye, ViewDir, float3(0, 0, 0), OutterRadius); float SampleLength = ViewRayLength / Ksteps; //vSunDir = normalize(vSunDir); float cosTheta = dot(normalize(vSunDir), ViewDir); float3 tmpPos = Eye + 0.5 * SampleLength * ViewDir; for(int k=0; k<Ksteps; k++) { float SunRayLength = RaySphereIntersection(tmpPos, vSunDir, float3(0, 0, 0), OutterRadius); float3 TopAtmosphere = tmpPos + SunRayLength*vSunDir; ViewOD = OpticalDepth(Eye, tmpPos); SunOD = OpticalDepth(tmpPos, TopAtmosphere); tmpDensity = Density(length(tmpPos)-InnerRadius); Attenuation = exp(-RayleighCoeffs*(ViewOD+SunOD)); tmp += tmpDensity*Attenuation; tmpPos += SampleLength * ViewDir; } Irgb = RayleighCoeffs*RayleighPhaseFunction(cosTheta)*tmp*SampleLength; SkyColors[DTID.xy] = float4(Irgb, 1); } }  
    • By amadeus12
      I made my obj parser
      and It also calculate tagent space for normalmap.
      it seems calculation is wrong..
      any good suggestion for this?
      I can't upload my pics so I link my question.
      https://gamedev.stackexchange.com/questions/147199/how-to-debug-calculating-tangent-space
      and I uploaded my code here


      ObjLoader.cpp
      ObjLoader.h
    • By Alessandro Pozzer
      Hi guys, 

      I dont know if this is the right section, but I did not know where to post this. 
      I am implementing a day night cycle on my game engine and I was wondering if there was a nice way to interpolate properly between warm colors, such as orange (sunset) and dark blue (night) color. I am using HSL format.
      Thank  you.
    • By thefoxbard
      I am aiming to learn Windows Forms with the purpose of creating some game-related tools, but since I know absolutely nothing about Windows Forms yet, I wonder:
      Is it possible to render a Direct3D 11 viewport inside a Windows Form Application? I see a lot of game editors that have a region of the window reserved for displaying and manipulating a 3D or 2D scene. That's what I am aiming for.
      Otherwise, would you suggest another library to create a GUI for game-related tools?
       
      EDIT:
      I've found a tutorial here in gamedev that shows a solution:
      Though it's for D3D9, I'm not sure if it would work for D3D11?
       
  • Popular Now