Visual Studio C++ (11x) help wanted

FyMa2618 61 Reputation points
2021-05-27T14:20:16.757+00:00

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]  
Developer technologies | C++
0 comments No comments
{count} votes

Accepted answer
  1. Viorel 122.9K Reputation points
    2021-05-27T14:24:58.51+00:00

    Try adding the next line:

    #pragma comment(lib, "d3d11")
    
    1 person found this answer helpful.

1 additional answer

Sort by: Most helpful
  1. RLWA32 49,666 Reputation points
    2021-05-27T14:27:24.01+00:00

    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?

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.