   HELP! ( With DirectX 11)
  Well it is a good dramatic entrace so I will beginThis is my first time prgraming with directX 11 and what do you know, SOMETHING GEOS HORRIBLY WRONG.I had written over 400 lines of code in about 1 hour (IT WAS ALOT OF WORK!!!!!!)The error it gave me when I built it was~~~~1>------ Build started: Project: WireZapp, Configuration: Debug Win32 ------1>Compiling...1>WireZapp.cpp1>c:\users\louis\documents\visual studio 2008\projects\wirezapp\wirezapp\resource.h(10) : warning C4005: 'IDOK' : macro redefinition1>   c:\program files\microsoft sdks\windows\v6.0a\include\winuser.h(9125) : see previous definition of 'IDOK'1>c:\users\louis\documents\visual studio 2008\projects\wirezapp\wirezapp\resource.h(11) : warning C4005: 'IDCANCEL' : macro redefinition1>   c:\program files\microsoft sdks\windows\v6.0a\include\winuser.h(9126) : see previous definition of 'IDCANCEL'1>c:\users\louis\documents\visual studio 2008\projects\wirezapp\wirezapp\wirezapp.cpp(22) : warning C4244: 'initializing' : conversion from 'int' to 'FLOAT', possible loss of data1>c:\users\louis\documents\visual studio 2008\projects\wirezapp\wirezapp\wirezapp.cpp(23) : warning C4244: 'initializing' : conversion from 'int' to 'FLOAT', possible loss of data1>Linking...1>WireZapp.obj : error LNK2019: unresolved external symbol _D3D11CreateDeviceAndSwapChain@48 referenced in function "long __cdecl InitDevice(void)" (?InitDevice@@YAJXZ)1>C:\Users\Louis\Documents\Visual Studio 2008\Projects\WireZapp\Debug\WireZapp.exe : fatal error LNK1120: 1 unresolved externals1>Build log was saved at "file://c:\Users\Louis\Documents\Visual Studio 2008\Projects\WireZapp\WireZapp\Debug\BuildLog.htm"1>WireZapp - 2 error(s), 4 warning(s)========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========Here is the code~~~~~~#include "stdafx.h"#include "targetver.h"#include <windows.h>#include "Resource.h"#include "WireZapp.h"#include <fstream>#include <iostream>#include <d3d11.h>#include <d3dx11.h>#include <tchar.h>#define MAX_LOADSTRING 100HINSTANCE hInst;HWND mainhWnd;int  windowWidth  = 640;int  windowHeight = 480;TCHAR szTitle[MAX_LOADSTRING];TCHAR szWindowClass[MAX_LOADSTRING];FLOAT WNDHeight = windowHeight;FLOAT WNDWidth= windowWidth;HINSTANCEg_hInst = NULL;HWNDg_hWnd = NULL;D3D_DRIVER_TYPE    g_driverType = D3D_DRIVER_TYPE_NULL;D3D_FEATURE_LEVEL  g_featureLevel = D3D_FEATURE_LEVEL_11_0;ID3D11Device* g_pd3dDevice = NULL;ID3D11DeviceContext*    g_pImmediateContext = NULL;IDXGISwapChain*    g_pSwapChain = NULL;ID3D11RenderTargetView* g_pRenderTargetView = NULL;bool InitWindow(HINSTANCE hInstance, int width, int height);LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);HRESULT InitWindow( HINSTANCE hInstance, int nCmdShow );HRESULT InitDevice();void CleanupDevice();LRESULT CALLBACK    WndProc( HWND, UINT, WPARAM, LPARAM );void Render();ATOMMyRegisterClass(HINSTANCE hInstance); //callback declarationsBOOLInitInstance(HINSTANCE, int);LRESULT CALLBACKWndProc(HWND, UINT, WPARAM, LPARAM);INT_PTR CALLBACKAbout(HWND, UINT, WPARAM, LPARAM);INT_PTR CALLBACKLoad(HWND, UINT, WPARAM, LPARAM);INT_PTR CALLBACK    New(HWND, UINT, WPARAM, LPARAM);INT_PTR CALLBACK    Flow_Graph(HWND, UINT, WPARAM, LPARAM);int WINAPI wWinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int nCmdShow ){    UNREFERENCED_PARAMETER( hPrevInstance );    UNREFERENCED_PARAMETER( lpCmdLine );    if( FAILED( InitWindow( hInstance, nCmdShow ) ) )   return 0;    if( FAILED( InitDevice() ) )    {   CleanupDevice();   return 0;    }    // Main message loop    MSG msg = {0};    while( WM_QUIT != msg.message )    {   if( PeekMessage( &msg, NULL, 0, 0, PM_REMOVE ) )   {  TranslateMessage( &msg );  DispatchMessage( &msg );   }   else   {  Render();   }    }    CleanupDevice();    return ( int )msg.wParam;}HRESULT InitWindow( HINSTANCE hInstance, int nCmdShow ){WNDCLASSEX wcex;wcex.cbSize = sizeof(WNDCLASSEX);wcex.style= CS_HREDRAW | CS_VREDRAW;wcex.lpfnWndProc= WndProc;wcex.cbClsExtra= 0;wcex.cbWndExtra= 0;wcex.hInstance= hInstance;wcex.hIcon= 0;wcex.hCursor= LoadCursor(NULL, IDC_ARROW);wcex.hbrBackground= (HBRUSH)(COLOR_WINDOW+1);wcex.lpszMenuName= MAKEINTRESOURCE(IDR_MENU1);wcex.lpszClassName= szWindowClass;wcex.hIconSm= 0;if( !RegisterClassEx(&wcex) )return FALSE;g_hInst = hInstance;    RECT rc = { 0, 0, 640, 480 };    AdjustWindowRect( &rc, WS_OVERLAPPEDWINDOW, FALSE );    g_hWnd = CreateWindow( L"GUIWindowClass", L"Wirezapp GUI", WS_OVERLAPPEDWINDOW,  CW_USEDEFAULT, CW_USEDEFAULT, rc.right - rc.left, rc.bottom - rc.top, NULL, NULL, hInstance,  NULL );    if( !g_hWnd )   return E_FAIL;    ShowWindow( g_hWnd, nCmdShow );    return S_OK;}BOOL InitInstance(HINSTANCE hInstance, int nCmdShow){   HWND hWnd;   hInst = hInstance;    hWnd = CreateWindow(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL);   if (!hWnd)   { return FALSE;   }   ShowWindow(hWnd, nCmdShow);   UpdateWindow(hWnd);   return TRUE;}LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam){int wmId, wmEvent;PAINTSTRUCT ps;HDC hdc;switch (message){case WM_COMMAND:wmId    = LOWORD(wParam);wmEvent = HIWORD(wParam); switch (wmId){case IDM_ABOUT1:MessageBox(hWnd, TEXT("WireZapp GUI Version 1.3"), TEXT("About"), MB_OK);break; case IDM_EXIT1:DestroyWindow(hWnd);break; case IDM_LOAD1:DialogBox(hInst, MAKEINTRESOURCE(IDD_LOAD), hWnd, Load);break; case IDM_NEW1:DialogBox(hInst, MAKEINTRESOURCE(IDD_NEW), hWnd, New);break; case IDM_OPEN_WINDOW1:DialogBox(hInst, MAKEINTRESOURCE(IDD_FLOW), hWnd, Flow_Graph);break;default:return DefWindowProc(hWnd, message, wParam, lParam);}break;case WM_PAINT:hdc = BeginPaint(hWnd, &ps);EndPaint(hWnd, &ps);break;case WM_DESTROY:PostQuitMessage(0);break;default:return DefWindowProc(hWnd, message, wParam, lParam);}return 0;}HRESULT InitDevice(){    HRESULT hr = S_OK;    RECT rc;    GetClientRect( g_hWnd, &rc );    UINT width = rc.right - rc.left;    UINT height = rc.bottom - rc.top;    UINT createDeviceFlags = 0;#ifdef _DEBUG    createDeviceFlags |= D3D11_CREATE_DEVICE_DEBUG;#endif    D3D_DRIVER_TYPE driverTypes[] =    {   D3D_DRIVER_TYPE_HARDWARE,   D3D_DRIVER_TYPE_WARP,   D3D_DRIVER_TYPE_REFERENCE,    };    UINT numDriverTypes = ARRAYSIZE( driverTypes );    D3D_FEATURE_LEVEL featureLevels[] =    {   D3D_FEATURE_LEVEL_11_0,   D3D_FEATURE_LEVEL_10_1,   D3D_FEATURE_LEVEL_10_0,    };UINT numFeatureLevels = ARRAYSIZE( featureLevels );    DXGI_SWAP_CHAIN_DESC sd;    ZeroMemory( &sd, sizeof( sd ) );    sd.BufferCount = 1;    sd.BufferDesc.Width = width;    sd.BufferDesc.Height = height;    sd.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;    sd.BufferDesc.RefreshRate.Numerator = 60;    sd.BufferDesc.RefreshRate.Denominator = 1;    sd.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;    sd.OutputWindow = g_hWnd;    sd.SampleDesc.Count = 1;    sd.SampleDesc.Quality = 0;    sd.Windowed = TRUE;    for( UINT driverTypeIndex = 0; driverTypeIndex < numDriverTypes; driverTypeIndex++ )    {   g_driverType = driverTypes[driverTypeIndex];   hr = D3D11CreateDeviceAndSwapChain( NULL, g_driverType, NULL, createDeviceFlags, featureLevels, numFeatureLevels,    D3D11_SDK_VERSION, &sd, &g_pSwapChain, &g_pd3dDevice, &g_featureLevel, &g_pImmediateContext );   if( SUCCEEDED( hr ) )  break;    }    if( FAILED( hr ) )   return hr;    // Create a render target view    ID3D11Texture2D* pBackBuffer = NULL;    hr = g_pSwapChain->GetBuffer( 0, __uuidof( ID3D11Texture2D ), ( LPVOID* )&pBackBuffer );    if( FAILED( hr ) )   return hr;    hr = g_pd3dDevice->CreateRenderTargetView( pBackBuffer, NULL, &g_pRenderTargetView );    pBackBuffer->Release();    if( FAILED( hr ) )   return hr;    g_pImmediateContext->OMSetRenderTargets( 1, &g_pRenderTargetView, NULL );    // Setup the viewport    D3D11_VIEWPORT vp;    vp.Width = (FLOAT)width;    vp.Height = (FLOAT)height;    vp.MinDepth = 0.0f;    vp.MaxDepth = 1.0f;    vp.TopLeftX = 0;    vp.TopLeftY = 0;    g_pImmediateContext->RSSetViewports( 1, &vp );    return S_OK;}//--------------------------------------------------------------------------------------// Render the frame//--------------------------------------------------------------------------------------void Render(){    // Just clear the backbuffer    float ClearColor[4] = { 0.0f, 0.125f, 0.3f, 1.0f }; //red,green,blue,alpha    g_pImmediateContext->ClearRenderTargetView( g_pRenderTargetView, ClearColor );    g_pSwapChain->Present( 0, 0 );}//--------------------------------------------------------------------------------------// Clean up the objects we've created//--------------------------------------------------------------------------------------void CleanupDevice(){    if( g_pImmediateContext ) g_pImmediateContext->ClearState();    if( g_pRenderTargetView ) g_pRenderTargetView->Release();    if( g_pSwapChain ) g_pSwapChain->Release();    if( g_pImmediateContext ) g_pImmediateContext->Release();    if( g_pd3dDevice ) g_pd3dDevice->Release();}INT_PTR CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam){UNREFERENCED_PARAMETER(lParam);switch (message){case WM_INITDIALOG:return (INT_PTR)TRUE;case WM_COMMAND:if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL){EndDialog(hDlg, LOWORD(wParam));return (INT_PTR)TRUE;}break;}return (INT_PTR)FALSE;}INT_PTR CALLBACK Load(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam){UNREFERENCED_PARAMETER(lParam);switch (message){case WM_INITDIALOG:return (INT_PTR)TRUE; case IDLOAD:NULL;case WM_COMMAND:if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL){case IDCANCEL:EndDialog(hDlg, LOWORD(wParam));return (INT_PTR)TRUE;default:NULL;}break;}return (INT_PTR)FALSE;}INT_PTR CALLBACK New(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam){UNREFERENCED_PARAMETER(lParam);switch (message){case WM_INITDIALOG:return (INT_PTR)TRUE; case WM_COMMAND:if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL){case IDCANCEL:EndDialog(hDlg, LOWORD(wParam));return (INT_PTR)TRUE;default:NULL;}break;}return (INT_PTR)FALSE;}INT_PTR CALLBACK Flow_Graph(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam){UNREFERENCED_PARAMETER(lParam);switch (message){case WM_INITDIALOG:return (INT_PTR)TRUE;case ID_FILE_LOAD:DialogBox(hInst, MAKEINTRESOURCE(IDD_LOAD), hWnd, Load);    break; case WM_COMMAND:if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL){EndDialog(hWnd, LOWORD(wParam));return (INT_PTR)TRUE;default:NULL;}break;}return (INT_PTR)FALSE;}~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~IF SOMEONE CAN PLEASE HELP ME I WOULD BE SO THANKFUL!One exclamation point is sufficient. -- jpetrie[Edited by - jpetrie on July 7, 2010 10:24:57 PM]
  Maybe you should find a source of introductory code that doesn't create a god damned About dialog. Half this code is pointless garbage.That said, your error is that you haven't added d3d11.lib to your linker inputs.   ;  If you are interested in some reference source code, you could take a look at my engine (see link below in my signature).  I think Promit has a point - you should really try starting out at a very low level first, then build up more functionality and UI stuff later on.  It will make your life much easier in the long run!   ;  Okay well that helped alot but now it is giving me a new error so i modified the code a bit and it still gives me the errorHere is the error~~~~~~~~~~~~~~~~~~~~~~~~~~~~'WireZapp.exe': Loaded 'C:\Users\Louis\Documents\Visual Studio 2008\Projects\WireZapp\Debug\WireZapp.exe', Symbols loaded.'WireZapp.exe': Loaded 'C:\Windows\SysWOW64\ntdll.dll''WireZapp.exe': Loaded 'C:\Windows\SysWOW64\kernel32.dll''WireZapp.exe': Loaded 'C:\Windows\SysWOW64\KernelBase.dll''WireZapp.exe': Loaded 'C:\Windows\SysWOW64\d3d11.dll''WireZapp.exe': Loaded 'C:\Windows\SysWOW64\msvcrt.dll''WireZapp.exe': Loaded 'C:\Windows\SysWOW64\dxgi.dll''WireZapp.exe': Loaded 'C:\Windows\SysWOW64\user32.dll''WireZapp.exe': Loaded 'C:\Windows\SysWOW64\gdi32.dll''WireZapp.exe': Loaded 'C:\Windows\SysWOW64\lpk.dll''WireZapp.exe': Loaded 'C:\Windows\SysWOW64\usp10.dll''WireZapp.exe': Loaded 'C:\Windows\SysWOW64\advapi32.dll''WireZapp.exe': Loaded 'C:\Windows\SysWOW64\sechost.dll''WireZapp.exe': Loaded 'C:\Windows\SysWOW64\rpcrt4.dll''WireZapp.exe': Loaded 'C:\Windows\SysWOW64\sspicli.dll''WireZapp.exe': Loaded 'C:\Windows\SysWOW64\cryptbase.dll''WireZapp.exe': Loaded 'C:\Windows\SysWOW64\version.dll''WireZapp.exe': Loaded 'C:\Windows\SysWOW64\dwmapi.dll''WireZapp.exe': Loaded 'C:\Windows\winsxs\x86_microsoft.vc90.debugcrt_1fc8b3b9a1e18e3b_9.0.30729.1_none_bb1f6aa1308c35eb\msvcr90d.dll''WireZapp.exe': Loaded 'C:\Windows\SysWOW64\imm32.dll''WireZapp.exe': Loaded 'C:\Windows\SysWOW64\msctf.dll''WireZapp.exe': Loaded 'C:\Windows\SysWOW64\uxtheme.dll''WireZapp.exe': Loaded 'C:\Windows\SysWOW64\setupapi.dll''WireZapp.exe': Loaded 'C:\Windows\SysWOW64\cfgmgr32.dll''WireZapp.exe': Loaded 'C:\Windows\SysWOW64\oleaut32.dll''WireZapp.exe': Loaded 'C:\Windows\SysWOW64\ole32.dll''WireZapp.exe': Loaded 'C:\Windows\SysWOW64\devobj.dll''WireZapp.exe': Loaded 'C:\Windows\SysWOW64\wintrust.dll''WireZapp.exe': Loaded 'C:\Windows\SysWOW64\crypt32.dll''WireZapp.exe': Loaded 'C:\Windows\SysWOW64\msasn1.dll''WireZapp.exe': Unloaded 'C:\Windows\SysWOW64\setupapi.dll''WireZapp.exe': Unloaded 'C:\Windows\SysWOW64\devobj.dll''WireZapp.exe': Unloaded 'C:\Windows\SysWOW64\oleaut32.dll''WireZapp.exe': Unloaded 'C:\Windows\SysWOW64\ole32.dll''WireZapp.exe': Unloaded 'C:\Windows\SysWOW64\cfgmgr32.dll''WireZapp.exe': Loaded 'C:\Windows\SysWOW64\aticfx32.dll''WireZapp.exe': Loaded 'C:\Windows\SysWOW64\atiuxpag.dll''WireZapp.exe': Loaded 'C:\Windows\SysWOW64\atidxx32.dll''WireZapp.exe': Loaded 'C:\Windows\SysWOW64\shell32.dll''WireZapp.exe': Loaded 'C:\Windows\SysWOW64\shlwapi.dll'Invalid parameter passed to C runtime function.'WireZapp.exe': Loaded 'C:\Windows\SysWOW64\D3D11SDKLayers.dll''WireZapp.exe': Loaded 'C:\Windows\SysWOW64\ole32.dll'First-chance exception at 0x75fbb727 in WireZapp.exe: Microsoft C++ exception: _com_error at memory location 0x003ef3c8..The thread 'Win32 Thread' (0x1180) has exited with code 0 (0x0).'WireZapp.exe': Unloaded 'C:\Windows\SysWOW64\atidxx32.dll''WireZapp.exe': Unloaded 'C:\Windows\SysWOW64\shell32.dll''WireZapp.exe': Unloaded 'C:\Windows\SysWOW64\shlwapi.dll''WireZapp.exe': Unloaded 'C:\Windows\SysWOW64\aticfx32.dll''WireZapp.exe': Loaded 'C:\Windows\SysWOW64\d3d10warp.dll''WireZapp.exe': Loaded 'C:\Windows\SysWOW64\setupapi.dll''WireZapp.exe': Loaded 'C:\Windows\SysWOW64\cfgmgr32.dll''WireZapp.exe': Loaded 'C:\Windows\SysWOW64\oleaut32.dll''WireZapp.exe': Loaded 'C:\Windows\SysWOW64\devobj.dll''WireZapp.exe': Unloaded 'C:\Windows\SysWOW64\setupapi.dll''WireZapp.exe': Unloaded 'C:\Windows\SysWOW64\devobj.dll''WireZapp.exe': Unloaded 'C:\Windows\SysWOW64\oleaut32.dll''WireZapp.exe': Unloaded 'C:\Windows\SysWOW64\cfgmgr32.dll'First-chance exception at 0x75fbb727 in WireZapp.exe: Microsoft C++ exception: _com_error at memory location 0x003ef3c8..'WireZapp.exe': Unloaded 'C:\Windows\SysWOW64\d3d10warp.dll''WireZapp.exe': Loaded 'C:\Windows\SysWOW64\D3D11Ref.dll''WireZapp.exe': Loaded 'C:\Windows\SysWOW64\setupapi.dll''WireZapp.exe': Loaded 'C:\Windows\SysWOW64\cfgmgr32.dll''WireZapp.exe': Loaded 'C:\Windows\SysWOW64\oleaut32.dll''WireZapp.exe': Loaded 'C:\Windows\SysWOW64\devobj.dll''WireZapp.exe': Unloaded 'C:\Windows\SysWOW64\setupapi.dll''WireZapp.exe': Unloaded 'C:\Windows\SysWOW64\devobj.dll''WireZapp.exe': Unloaded 'C:\Windows\SysWOW64\oleaut32.dll''WireZapp.exe': Unloaded 'C:\Windows\SysWOW64\cfgmgr32.dll'First-chance exception at 0x75fbb727 in WireZapp.exe: Microsoft C++ exception: _com_error at memory location 0x003ef3c8..The thread 'Win32 Thread' (0x1170) has exited with code 0 (0x0).'WireZapp.exe': Unloaded 'C:\Windows\SysWOW64\D3D11Ref.dll'The thread 'Win32 Thread' (0x10b4) has exited with code 0 (0x0).The program '[4700] WireZapp.exe: Native' has exited with code 0 (0x0)I CANT BELIVE IT FITS ALL OF THIS IN A POPUP WINDOW ITS FUCKEN AMAZINGPLEASE RESPOND   ;  Ever considered using the debugger?   ;  Well that was the debugger but when it ran thats the popup message that it gave me   ;  Run in the debugger and step through your code until you can see what in your code stimulates that error. Then start backtracking.A huge aspect of becoming a good programmer is the ability to problem-solve. Right now it does not appear that you are being proactive in any way about resolving the problems you have.   ;  What I meant was using the debugger to actually debug the application and find out WHY it crashes. That list of loaded dlls along with a message that the application has crashed due to an unhandled exception will not help anyone on this board to say what's wrong.Here's a quick get-started-with-the-debugger:1) Find the function "int WINAPI wWinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int nCmdShow )"2) On the very first line of that function, place your marker (the blinking thingie that writes text)3) Press F9 and observe a red ball appearing in the left margin4) Now press F5 to begin debugging your application5) The program should immediately "break" at your red ball (the break point).6) Now you can "step" the application line-by-line by pressing F11, each press will step the program forward one line, sometimes the marker will jump into another function when you press F11, just go with it.7) continue do this until the application crashes and try to observe at what code-line the crash happens.8) When you know what line causes the crash it will be much easier for you, or anyone else to help you solve the problem.;  Thanks I am new with directX programing so this is VERY hard for me   ;  No offense, but you seem to be very new to programming in general. And D3D11 might not be the best starting point..   