Jump to content
  • Advertisement

Adam Turner

Member
  • Content Count

    5
  • Joined

  • Last visited

Community Reputation

112 Neutral

About Adam Turner

  • Rank
    Newbie
  1. I have a problem which i have never came across and totally have no idea what is the cause but when i "resize" my window the the client area is black, this also happens with the "minimize" and then maximize.   Can someone help with this please the code is below.   // Initialisation of window and core component(s) void cSystem::f_InitSystem(HINSTANCE hInstance, int nCmdShow) { /* Window class definition */ m_wc.cbSize = sizeof(WNDCLASSEX); // set size of the window class m_wc.style = CS_VREDRAW | CS_HREDRAW; //  m_wc.lpfnWndProc = WindowProc; // identify the window procedure m_wc.hInstance = hInstance; // identify the instance of the window m_wc.hCursor = LoadCursor(NULL, IDC_ARROW); // load cursor m_wc.lpszClassName = lpszClassName; // name window class to be registered m_wc.hIcon = LoadIcon(NULL, IDI_APPLICATION); // load window icon /* Window Class registration */ if (!RegisterClassEx(&m_wc)) // register the window class { ERROR(L"RegisterClassEx() Failed") // display error message PostQuitMessage(0); // return 0x0 to windows } else { if (!AdjustWindowRectEx(&m_wr, m_WS, FALSE, NULL)) { UnregisterClass(L"WindowClass", hInstance); // unregister the window class DestroyWindow(m_hwnd); // destroy window ERROR(L"AdjustWindowRect() Failed") // display error message PostQuitMessage(0); // return 0x0 to windows } if (m_hwnd = CreateWindowEx(NULL, lpszClassName, // window class text lpszWindowName, // window title text m_WS, // window style m_DisplayDimentions.WindowXPOS, m_DisplayDimentions.WindowYPOS, // X-Y position coordinate(s) m_wr.right - m_wr.left,  m_wr.bottom - m_wr.top, // X-Y dimension(s) // State no parent window, not using any menu's, attach to window instance and set not using multiple window's NULL, NULL, // no parent window or menu(s) hInstance, // window instance NULL)) // used with multiple window(s) { if (ShowWindow(m_hwnd, nCmdShow)) // display our window { UnregisterClass(L"WindowClass", hInstance); // unregister the window class DestroyWindow(m_hwnd); // destroy window ERROR(L"ShowWindow() Failed") // display error message PostQuitMessage(0); // return 0x0 to windows } else { if (!UpdateWindow(m_hwnd)) // update our window { UnregisterClass(L"WindowClass", hInstance); // unregister the window class DestroyWindow(m_hwnd); // destroy window ERROR(L"UnregisterClass() Failed") // display error message PostQuitMessage(0); // return 0x0 to windows } else { if (!SetForegroundWindow(m_hwnd)) // set our window to the foreground window { UnregisterClass(L"WindowClass", hInstance); // unregister the window class DestroyWindow(m_hwnd); // destroy window ERROR(L"SetForegroundWindow() Failed") // display error message PostQuitMessage(0); // return 0x0 to windows } else { if (!SetFocus(m_hwnd)) // set our window to be the focal window { UnregisterClass(L"WindowClass", hInstance); // unregister the window class DestroyWindow(m_hwnd); // destroy window ERROR(L"SetFocus() Failed") // display error message PostQuitMessage(0); // return 0x0 to windows } } } } } else { UnregisterClass(L"WindowClass", hInstance); // unregister the window class MessageBox(NULL, L"CreateWindowEx()", NULL, NULL); // display error message PostQuitMessage(0); // return 0x0 to windows } } }  
  2. Adam Turner

    CreateRenderTargetView - Giving C2039 error

    well that would explain it, thanks 
  3. Hello,   I am receiving this error below:   Error 31 error C2039: 'CreateRenderTargetView' : is not a member of 'ID3D11DeviceContext' D:\Development\C++ Project(s)\GameEngine Development Project\GameEngine__0_02\GameEngine__0_02\EngineMain.cpp 272 1 GameEngine__0_02   The compiler also brings this up:   32 IntelliSense: class "ID3D11DeviceContext" has no member "CreateRenderTargetView" d:\Development\C++ Project(s)\GameEngine Development Project\GameEngine__0_02\GameEngine__0_02\EngineMain.cpp 272 19 GameEngine__0_02     I have check over everything and all the libs and correct headers are linked and included.   The code for this is: m_d3ddevcontext->CreateRenderTargetView(p_D3DBackBuffer, NULL, &D3D_backbuffer); p_D3DBackBuffer->Release(); Please if any one knows why the library doesn't appear to have this function which should clearly be in there as im completely baffled.   Also i you need any more code snippets or information please just ask..
  4. Thank you for taking the time to review the problem and you are right, my linker was set to only look at the 64bit lib folder and not the x86 folder  of the SDK. So it couldn't find the "d3d11.lib" file.   And unfortunately the code is only half complete.   Thanks again tho i can now complete my code.
  5. Introduction Would like help with the D3D11CreateDeviceAndSwapChain when i implement it i receive LNK2019 and LNK1120:3. I would like help to resolve these issues and also perhaps help understanding the why as well. I am trying to set up the window i recently developed to be linked through Dirct3D and the graphic(s) card.     Main Section Title Explaining the Concept The problem im facing as mentioned is link errors, im unsure why i am receiving the errors and the code looks just fine to me, i haven't programmed for nearly 4 years and i am very out of practice below i will link the code. The code section that is causing the problem is: D3D11CreateDeviceAndSwapChain(NULL, D3D_DRIVER_TYPE_HARDWARE, NULL, NULL,         NULL, NULL, D3D11_SDK_VERSION, &scd,         &swapchain, &d3d_device, NULL, &dev_context); This is what is causing the problem in the program. I will show the full code in both the cpp and hpp file to help understand.   Using the Code I have created a class for Direct3D to keep things easier for me while programming. I am unsure if this may have anything to do with the problem here. WindowInit.hpp #ifndef D3DAPP_HPP #define D3DAPP_HPP /////////////////////////////////////////////////////////////////////////////////////////////////// WINDOW STUFF //////////////////////////////////////////////////////////////////////////////////////////////////////// /* INCLUDE FILES GO HERE */ // include the basic windows header file #include <windows.h> #include <windowsx.h> /* DEFINITIONS GO HERE */ // Long pointers to strings, constances for window class and title const wchar_t lpszClassName[] = L"Window WindowClassEx"; // window class name const wchar_t lpszTitleName[] = L"Window - 64bit 0.00"; // window title // Define screen constant(s) #define WINDOW_X        CW_USEDEFAULT    // x start draw coordinate #define WINDOW_Y        CW_USEDEFAULT    // y start draw coordinate #define WINDOW_WIDTH    800    // screen width #define WINDOW_HEIGHT    600 // screen height // Define macro message box(s) //#define ERROR(g_msg)(MessageBoxW(g_hWnd, g_msg, L"ERROR", MB_ICONERROR)); // error handling message box #define SUCCESSFUL(g_msg)(MessageBoxW(g_hWnd, g_msg, L"SUCCESS", NULL)); // success handling message box #define MSG(g_msg)(MessageBoxW(g_hWnd,g_msg, L"Message", MB_ICONINFORMATION)); // error handling message box /* GLOBAL VARIABLES GO HERE */ // the handle for the window, filled by a function HWND g_hWnd; // this struct holds information for the window class WNDCLASSEX g_wc; // this struct holds Windows event messages MSG g_msg; /* GLOBAL FUNCTIONS GO HERE */ // window initialising functions here bool f_WindowInit(HINSTANCE hInstance, HWND hWnd, int showWindow); // initialise the main window with the window class structure and the create window function // application run time int f_EngineRun(); // the WindowProc function prototype LRESULT CALLBACK WindowProc(HWND hWnd,     UINT message,     WPARAM wParam,     LPARAM lParam); /////////////////////////////////////////////////////////////////////////////////////////////////// WINDOW STUFF //////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////// DIRECT3D STUFF /////////////////////////////////////////////////////////////////////////////////////////////////////// /* INCLUDE FILES GO HERE */ // include directx header file // #include <direct.h> #include <d3d11.h> #include <D3DX11.h> /* GLOBAL CLASSES GO HERE */ class cD3D {     // call the constructor and initialise the deconstructor public:     cD3D();    // constructor     ~cD3D();    // deconstructor     // Private member data type(s) private:     IDXGISwapChain *swapchain;    // the pointer to the swap chain interface     ID3D11Device *d3d_device;    // the pointer to our Direct3D device interface     ID3D11DeviceContext *dev_context;    // the pointer to our Direct3D device context     // Public function(s) public:     bool f_D3DInit(HWND hWnd);    // initalise direct3d with the window and get a handle to the gfx card     bool f_D3DCleanUp(void);    // clean up direct3d and release all memory back to the system }; #endif // D3DAPP_HPP Main.cpp /* INCLUDE FILES GO HERE */ #include <WindowInit.hpp> // include required definitions ////////////////////////////////////////////////////////////////////////////////////////////// WINDOW EXECUTION AND EVENTS ////////////////////////////////////////////////////////////////////////////////////////////// /* WINDOW MAIN */ // the entry point for any Windows program int WINAPI WinMain(HINSTANCE hInstance,     HINSTANCE hPrevInstance,     LPSTR lpCmdLine,     int nCmdShow) {     // Initialise Window     if (!f_WindowInit(hInstance, g_hWnd, nCmdShow))     {         MessageBox(g_hWnd, L"ERROR - f_D3DWindowInit() failed to initialise!", NULL, NULL);         PostQuitMessage(0);     };    // set up the window     cD3D    d3d;     d3d.f_D3DInit(g_hWnd);     // enter the main loop:     return f_EngineRun();    // enter the main window message loop } // this is the main message handler for the program LRESULT CALLBACK WindowProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) {     // sort through and find what code to run for the message given     switch (message)     {     case WM_KEYDOWN:     {         if (wParam == VK_ESCAPE)         { // close the application entirely             PostQuitMessage(0);             return 0;         }         if (wParam == VK_F1)         { // close the application entirely             // PostQuitMessage(0);             MSG(L"Hello im Adam's Window")                 return DefWindowProc(hWnd, message, wParam, lParam);         }     }         // this message is read when the window is closed     case WM_DESTROY:     {         // close the application entirely         PostQuitMessage(0);         return 0;     } break;     }     // Handle any messages the switch statement didn't     return DefWindowProc(hWnd, message, wParam, lParam); } ////////////////////////////////////////////////////////////////////////////////////////////// WINDOW EXECUTION AND EVENTS ////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////// WINDOW INITALISATION STUFF ////////////////////////////////////////////////////////////////////////////////////////////// /* WINDOW INITIALISATION GOES HERE */ // Window initialisation bool f_WindowInit(HINSTANCE hInstance, HWND hWnd, int showWindow) {     // clear out the window class for use     ZeroMemory(&g_wc, sizeof(WNDCLASSEX));     // fill in the struct with the needed information     g_wc.cbSize = sizeof(WNDCLASSEX);     g_wc.style = CS_HREDRAW | CS_VREDRAW;     g_wc.lpfnWndProc = WindowProc;     g_wc.hInstance = hInstance;     g_wc.hCursor = LoadCursor(NULL, IDC_ARROW);     g_wc.hbrBackground = (HBRUSH)COLOR_WINDOW;     g_wc.lpszClassName = lpszClassName;     // register the window class     if (!RegisterClassEx(&g_wc))     {         ERROR(L"WindowClassEx failed to register!");         PostQuitMessage(0);     };     // create the window and use the result as the handle     g_hWnd = CreateWindowEx(NULL,         // class, title and style         lpszClassName, // name of the window class         lpszTitleName, // title of the window         WS_OVERLAPPEDWINDOW, // window style         // window draw coordinate and size of window in pixels         WINDOW_X, // x-position of the window         WINDOW_Y, // y-position of the window         WINDOW_WIDTH, // width of the window         WINDOW_HEIGHT, // height of the window         // state we have no parent window, not using menu's, attatch to window instance, multiple window's = false         NULL, // we have no parent window, NULL         NULL, // we aren't using menus, NULL         hInstance, // application handle         NULL); // used with multiple windows, NULL     // test the value returned by CreateWindowEx stored in g_hWnd     if (g_hWnd == 0)     {         ERROR(L"CreateWindowEx failed to be created!");         PostQuitMessage(0);     }     // display the window on the screen     ShowWindow(g_hWnd, showWindow);     return true; } // Main loop function int f_EngineRun() {     while (GetMessage(&g_msg, NULL, 0, 0))     {         // translate keystroke messages into the right format         TranslateMessage(&g_msg);         // send the message to the WindowProc function         DispatchMessage(&g_msg);     }     // return this part of the WM_QUIT message to Windows     return g_msg.wParam; } /////////////////////////////////////////////////////////////////////////////////////////////// WINDOW INITALISATION STUFF ////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////// DIRECT3D INITALISATION STUFF ///////////////////////////////////////////////////////////////////////////////////////////// bool cD3D::f_D3DInit(HWND hWnd) {     DXGI_SWAP_CHAIN_DESC    scd;     ZeroMemory(&scd, sizeof(DXGI_SWAP_CHAIN_DESC));     scd.BufferCount = 1;     scd.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;     scd.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;     scd.OutputWindow = hWnd;     scd.SampleDesc.Count = 4;     scd.Windowed = TRUE;     D3D11CreateDeviceAndSwapChain(NULL, D3D_DRIVER_TYPE_HARDWARE, NULL, NULL,         NULL, NULL, D3D11_SDK_VERSION, &scd,         &swapchain, &d3d_device, NULL, &dev_context);     return true; } bool cD3D::f_D3DCleanUp(void) {     swapchain();     3d_device->Release();     dev_context->Release();     return true; } Again when i add the D3D11CreateDeviceAndSwapChain(NULL, D3D_DRIVER_TYPE_HARDWARE, NULL, NULL,         NULL, NULL, D3D11_SDK_VERSION, &scd,         &swapchain, &d3d_device, NULL, &dev_context); I reveive the link error: Error 31 error LNK2019: unresolved external symbol _D3D11CreateDeviceAndSwapChain@48 referenced in function "public: bool __thiscall cD3D::f_D3DInit(struct HWND__ *)" (?f_D3DInit@cD3D@@QAE_NPAUHWND__@@@Z) D:\Development\C++ Project(s)\Testing Area\Playing around with code\D3D_Engine__0_00\D3D_Engine__0_00\Main.obj D3D_Engine__0_00 followed by Error 32 error LNK2019: unresolved external symbol "public: __thiscall cD3D::cD3D(void)" (??0cD3D@@QAE@XZ) referenced in function _WinMain@16 D:\Development\C++ Project(s)\Testing Area\Playing around with code\D3D_Engine__0_00\D3D_Engine__0_00\Main.obj D3D_Engine__0_00 Error 33 error LNK2019: unresolved external symbol "public: __thiscall cD3D::~cD3D(void)" (??1cD3D@@QAE@XZ) referenced in function _WinMain@16 D:\Development\C++ Project(s)\Testing Area\Playing around with code\D3D_Engine__0_00\D3D_Engine__0_00\Main.obj D3D_Engine__0_00 Error 34 error LNK1120: 3 unresolved externals D:\Development\C++ Project(s)\Testing Area\Playing around with code\D3D_Engine__0_00\Debug\D3D_Engine__0_00.exe 1 1 D3D_Engine__0_00       Conclusion   I have tried removing the class and nothing changes no matter how i get the result i desire from the program, please help.
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!