3,978 questions
Try adding the next line:
#pragma comment(lib, "d3d11")
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
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]
Try adding the next line:
#pragma comment(lib, "d3d11")
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?