question

FyMa2618-9573 avatar image
0 Votes"
FyMa2618-9573 asked FyMa2618-9573 commented

Visual Studio C++ (11x) help wanted

Good day,
i am develop a Gameengine in C++ / C on Visual studio.
I try to make a gameEngine but its always came a error,
See picture whit errors, Scrippts bellow.
Thanks in advance.


 ![//GraphicEngine.h
 #pragma once
 #include <d3d11.h>
    
 class GraphicsEngine
 {
 public:
     GraphicsEngine();
     //Initialize the GraphicsEngine and DirectX 11 Device
     bool init();
     //Release all the resources loaded
     bool release();
     ~GraphicsEngine();
 public:
     static GraphicsEngine* get();
    
 private:
    
 private:
     ID3D11Device* m_d3d_device;
     D3D_FEATURE_LEVEL m_feature_level;
     ID3D11DeviceContext* m_imm_context;
 };
    
 //GraphicsEngine.cpp
 #include "GraphicsEngine.h"
    
    
 GraphicsEngine::GraphicsEngine()
 {
 }
    
 bool GraphicsEngine::init()
 {
     D3D_DRIVER_TYPE driver_types[] =
     {
         D3D_DRIVER_TYPE_HARDWARE,
         D3D_DRIVER_TYPE_WARP,
         D3D_DRIVER_TYPE_REFERENCE
     };
     UINT num_driver_types = ARRAYSIZE(driver_types);
    
     D3D_FEATURE_LEVEL feature_levels[] =
     {
         D3D_FEATURE_LEVEL_11_0
     };
     UINT num_feature_levels = ARRAYSIZE(feature_levels);
    
     HRESULT res = 0;
     for (UINT driver_type_index = 0; driver_type_index < num_driver_types;)
     {
         res = D3D11CreateDevice(NULL, driver_types[driver_type_index], NULL, NULL, feature_levels,
             num_feature_levels, D3D11_SDK_VERSION, &m_d3d_device, &m_feature_level, &m_imm_context);
         if (SUCCEEDED(res))
             break;
         ++driver_type_index;
     }
     if (FAILED(res))
     {
         return false;
     }
    
    
    
     return true;
 }
    
    
 bool GraphicsEngine::release()
 {
     m_imm_context->Release();
     m_d3d_device->Release();
     return true;
 }
    
 GraphicsEngine::~GraphicsEngine()
 {
 }
    
    
 GraphicsEngine* GraphicsEngine::get()
 {
     static GraphicsEngine engine;
     return &engine;
 }
    
 //AppWindow.h
    
 #pragma once
 #include "Window.h"
 #include "//GraphicsEngine.h location"
 class AppWindow : public Window
 {
 public:
     AppWindow();
     ~AppWindow();
    
     // Inherited via Window
     virtual void onCreate() override;
     virtual void onUpdate() override;
     virtual void onDestroy() override;
 };
    
 //Appwindow.cpp
 #include "AppWindow.h"
    
    
    
 AppWindow::AppWindow()
 {
 }
    
    
 AppWindow::~AppWindow()
 {
 }
    
 void AppWindow::onCreate()
 {
     GraphicsEngine::get()->init();
     Window::onCreate();
 }
    
 void AppWindow::onUpdate()
 {
     Window::onUpdate();
    
 }
    
 void AppWindow::onDestroy()
 {
     GraphicsEngine::get()->release();
     Window::onDestroy();
 }
    
 //main
 #include "AppWindow.h"
    
    
    
 int main()
 {
     AppWindow app;
     if (app.init())
     {
         while (app.isRun())
         {
             app.broadcast();
         }
     }
    
     return 0;
 }][1]


[1]: /answers/storage/attachments/100276-ehelre.png

c++
ehelre.png (10.3 KiB)
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Viorel-1 avatar image
1 Vote"
Viorel-1 answered FyMa2618-9573 commented

Try adding the next line:

 #pragma comment(lib, "d3d11")


· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

It worked, thanks.

0 Votes 0 ·
RLWA32-6355 avatar image
0 Votes"
RLWA32-6355 answered

Did you link with the D3D11.lib by including it as in input to the linker in project properties or by using the #pragma comment(lib, "D3D11.lib") directive in your source file?

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.