2017-02-27 2 views
0

私はGPUレンダリングパーティクルシステムを作成しようとしており、この入力クラスを使用してマウス/キーボード入力を処理しています。DX11 DirectInput8 LNK2019エラーを引き起こします。

問題は行です。

により、LNK2019:未解決の外部シンボルエラーが発生します。必要なファイルが含まれているので、なぜこれが起こっているのかわかりません。以下はそれぞれInput.hとファイルです。

INPUT.Hファイル

#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ファイル

#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; 
    } 
... 
... 
... 
} 

私は、この問題を解決するために任意の助けをいただければと思います。

+0

それはあなたの.hと.cppのようにリンカエラーですファイルは無関係です。インポートライブラリdinput8.libをリンクするのを忘れた場合 –

+1

DirectX 11を使用している場合は、古いDirectInputを使用する必要はありません。さらに、現代版のWindowsでは、DirectInputをキーボード入力やマウス入力に使用しないでください。Win32メッセージの上に実装されているだけです。 [DirectX Tool Kit:Now with GamePads](https://blogs.msdn.microsoft.com/chuckw/2014/09/05/directx-tool-kit-now-with-gamepads/)と[DirectX Tool Kit:キーボードとマウスのサポート](https://blogs.msdn.microsoft.com/chuckw/2015/08/06/directx-tool-kit-keyboard-and-mouse-support/)を参照してください。 –

答えて

関連する問題