2017-02-27 5 views
0

Ich versuche, ein GPU-Partikel-System zu erstellen, und es verwendet diese Eingabeklasse, um Maus/Tastatureingabe zu behandeln.DX11 DirectInput8Create verursacht LNK2019 Fehler

Das Problem ist die Linie;

HRESULT result = DirectInput8Create(.....); 

verursacht einen LNK2019: Unresolved External Symbol error. Ich habe die notwendigen Dateien beigefügt, also bin ich mir nicht sicher, warum das passiert. Unten sind die Input.h und Dateien.

INPUT.H Datei

#ifndef _INPUT_ 
#define _INPUT_ 

#include <stdafx.h> 
#include <dinput.h> 

class Input{ 
private: 
    IDirectInputDevice8* _DIKeyboard; 
    IDirectInputDevice8* _DIMouse; 

    LPDIRECTINPUT8   _directInput; 

    LONG     _mouseXabsolute, _mouseYabsolute, _mouseZabsolute; 
    LONG     _mouseXrelative, _mouseYrelative, _mouseZrelative; 
    BYTE     _keyboardState[256]; 
    BYTE     _leftMouseButton, _rightMouseButton; 

    int      _screenWidth, _screenHeight; 
    HWND     _hWnd; 

    POINT     _point; 
    RECT     _rect; 

public: 
    Input(); 
    ~Input(); 

    void unload(); 
    bool initializeInput(HINSTANCE hInstance, HWND hWnd, int screenWidth, int screenHeight); 

    void updateInput(); 

    BYTE* getKeyboardState(); 

    LONG getMouseXRelative(); 
    LONG getMouseYRelative(); 
    LONG getMouseZRelative(); 

    LONG getMouseXAbsolute(); 
    LONG getMouseYAbsolute(); 
    LONG getMouseZAbsolute(); 

    BYTE getLeftMouseClick(); 
    BYTE getRightMouseClick(); 
}; 

#endif 

INPUT.CPP Datei

#include <stdafx.h> 
#include <Input.h> 
#define DIRECTINPUT_VERSION 0x0800 
#include <dinput.h> 

using namespace std; 

Input::Input() : _DIKeyboard(), _DIMouse(), _directInput(), _point(), _rect(){ 
    _mouseXabsolute = _mouseYabsolute = 0; 
    _mouseZabsolute = 1; 
    _mouseXrelative = _mouseXrelative = _mouseXrelative = 0; 
} 

Input::~Input(){ 
    unload(); 
} 

void Input::unload(){ 
    if (_DIKeyboard) _DIKeyboard->Release(); 
    if (_DIMouse) _DIMouse->Release(); 
    if (_directInput) _directInput->Release(); 
} 

bool Input::initializeInput(HINSTANCE hInstance, HWND hWnd, int screenWidth, int screenHeight){ 

    _screenWidth = screenWidth; 
    _screenHeight = screenHeight; 
    _hWnd = hWnd; 
    ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 
    ///////////////////////////////////////////////Create direct input, keyboard and mouse devices/////////////////////////////////////////////////// 

    HRESULT result = DirectInput8Create(hInstance, DIRECTINPUT_VERSION, IID_IDirectInput8, (void**)&_directInput, NULL); 

    if (FAILED(result)){ 
     MessageBox(0, L"Could not create direct input!", L"Error", MB_OK); 
     return false; 
    } 
... 
... 
... 
} 

ich Hilfe dieses Problem zu lösen, schätzen würde.

+0

Es ist ein Linker-Fehler so Ihre .h und .cpp Dateien sind irrelevant. Sie haben einfach vergessen, die Importbibliothek zu verknüpfen, dinput8.lib –

+1

Beachten Sie, dass Sie DirectX 11 nicht verwenden müssen, wenn Sie DirectX Direct verwenden. Außerdem sollten Sie DirectInput nicht für Tastatur- oder Mauseingaben in modernen Windows-Versionen verwenden - es wird nur auf Win32-Nachrichten implementiert. Siehe [DirectX Tool Kit: Jetzt mit GamePads] (https://blogs.msdn.microsoft.com/chuckw/2014/09/05/directx-tool-kit-now-with-gamepads/) und [DirectX Tool Kit: Tastatur- und Mausunterstützung] (https://blogs.msdn.microsoft.com/chuckw/2015/08/06/directx-tool-kit-keyboard-and-mouse-support/). –

Antwort

Verwandte Themen