Hi I'm currently trying to set up Direct X project in visual studio 2015.
i have downloaded the correct SDK and linked the project to the correct directories, from what i have been taught at uni. (this entire project was just meant to be a simple copy the code across from a word document provided)
I found that this is the only line of code that results in error.
if (FAILED(InitialiseWindow(hInstance, nCmdShow)))
{
DXTRACE_MSG("Failed to create Window");
return 0;
}
if i comment out the DXTRACE_MSG then the program complies correctly.
The exact error is LNK2019 unresolved external symbol __vsnprintf referenced in function "long __stdcall StringVPrintfWorkerA(char *,unsigned int,unsigned int *,char const *,char *)" (?StringVPrintfWorkerA@@YGJPADIPAIPBD0@Z) Tutorial 01 Exercise 01 C:\Users\Tony\Desktop\AGP\Tutorial 1 Exercise 01\dxerr.lib(dxerra.obj).
So overall i just need help in understanding the error, why it occurs and what i can do to rectify it so i can continue moving along with what i need for my assignment.
any help is greatly appreciated.
#include <windows.h>
#include <D3D11.h>
#include <d3d11.h>
#include <D3DX11.h>
#include <d3dx11.h>
#include <DxErr.h>
//int (WINAPIV * __vsprintf)(char*, size_t, const char*, va_list) = __vsprintf;
// Global Variables
HINSTANCE g_hInst = NULL;
HWND g_hWnd = NULL;
// Rename for each tutorial
char g_TutorialName[100] = "Tutorial 01 Exercise 01\0";
// Forward declarations
HRESULT InitialiseWindow(HINSTANCE hInstance, int nCmdShow);
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
// Entry point to the program. Initializes everything and goes into a message processing
// loop. Idle time is used to render the scene.
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
UNREFERENCED_PARAMETER(hPrevInstance);
UNREFERENCED_PARAMETER(lpCmdLine);
if (FAILED(InitialiseWindow(hInstance, nCmdShow)))
{
DXTRACE_MSG("Failed to create Window");
return 0;
}
// Main message loop
MSG msg = { 0 };
while (msg.message != WM_QUIT)
{
if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
else
{
//do somthing
}
}
return (int)msg.wParam;
}
// Register class and create window
HRESULT InitialiseWindow(HINSTANCE hInstance, int nCmdShow)
{
// Give your app window your own name
char Name[100] = "Hello World\0";
// Register class
WNDCLASSEX wcex = { 0 };
wcex.cbSize = sizeof(WNDCLASSEX);
wcex.style = CS_HREDRAW | CS_VREDRAW;
wcex.lpfnWndProc = WndProc;
wcex.hInstance = hInstance;
wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
// wcex.hbrBackground = (HBRUSH )( COLOR_WINDOW + 1); // Needed for non-D3D apps
wcex.lpszClassName = Name;
if (!RegisterClassEx(&wcex)) return E_FAIL;
// Create window
g_hInst = hInstance;
RECT rc = { 0, 0, 640, 480 };
AdjustWindowRect(&rc, WS_OVERLAPPEDWINDOW, FALSE);
g_hWnd = CreateWindow(Name, g_TutorialName, 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;
}
// Called every time the application receives a message
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
PAINTSTRUCT ps;
HDC hdc;
switch (message)
{
case WM_PAINT:
hdc = BeginPaint(hWnd, &ps);
EndPaint(hWnd, &ps);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
case WM_KEYDOWN:
if (wParam == VK_ESCAPE)
DestroyWindow(g_hWnd);
return 0;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
return 0;
}