Книга: DirectX 8 Programming Tutorial

Initialising DirectInput

Initialising DirectInput

The first thing we need to do is to initialise DirectInput. To do this, I have a new function called InitialiseDirectInput that is called from the main CGame::Initialise function. The code snippet below will create a DirectInput object that we will use to create further objects for user input.

//Create the DirectInput object
if (FAILED(DirectInput8Create(hInst, DIRECTINPUT_VERSION, IID_IDirectInput8, (void**)&m_pDirectInput, NULL))) {
 LogError("<li>Unable to create DirectInput interface.");
 return false;
} else {
 LogInfo("<li>DirectInput interface created OK");
}

The first parameter to DirectInput8Create is the HINSTANCE of our application which has been passed through from our WinMain function. The second parameter is the DirectInput version, this will always be DIRECTINPUT_VERSION. The third parameter is the desired interface, this will always be IID_IDirectInput8. The fourth parameter is the important one, this is a pointer the DirectInput interface which we will use later. The fifth parameter, for our examples is always NULL.

m_pDirectInput is a member variable of CGame and is of type LPDIRECTINPUT8.

Оглавление книги


Генерация: 1.598. Запросов К БД/Cache: 3 / 0
поделиться
Вверх Вниз