- Main Page
- Classes
- Files

# My Documents/TS2/src/GameUtils.cpp File Reference

Collection of usefull functions called by Game.cpp. More...

`#include "GameUtils.h"`

Include dependency graph for GameUtils.cpp:

## Functions
bool | InitD3D (HWND hWnd, LPDIRECT3DDEVICE9 *ppd3dDevice, LPDIRECT3D9 *ppD3D, D3DPRESENT_PARAMETERS **ppd3dpp, bool fullscreen)
| This function creates DirectX 3D Device.
bool | InitLight (LPDIRECT3DDEVICE9 pd3dDevice, D3DLIGHT9 *light1, D3DLIGHT9 *light2, D3DLIGHT9 *light3)
| This function creates lights.
bool | InitSound (HWND hWnd, IDirectSound8 **ppDS)
| This function creates DirectX sound device.
void | CaptureWindowParameters (HWND hWnd)
| Captures current window parameters, to restore them later.
void | ToggleFullScreen (HWND hWnd, LPDIRECT3DDEVICE9 pd3dDevice, D3DPRESENT_PARAMETERS **ppPP, LPDIRECT3D9 pD3D, int *oldScreenWidth, int *oldScreenHeight, int *screenWidth, int *screenHeight)
| Toggles fullscreen/windowed mode.
void | Reset3D (LPDIRECT3DDEVICE9 pd3dDevice, D3DPRESENT_PARAMETERS *pPP)
| This function resets D3D device.
void | SetupMatrices (LPDIRECT3DDEVICE9 *ppd3dDevice, D3DXVECTOR3 *eye, D3DXVECTOR3 *lookAt, D3DXVECTOR3 *upVec, float aspectRatio)
| World, View and Projection matrices are set with passed function parameters.

## Detailed Description

Collection of usefull functions called by Game.cpp.

Author:
  Petar Bajic, MPE (C) All Rights Reserved, Homepage: www.mystic-peanut.com

Date:
  January, 16 2007.

## Function Documentation

void CaptureWindowParameters | ( | HWND | hWnd | ) |

Captures current window parameters, to restore them later.

Parameters:

  | hWnd | handle to application window

Author:
  Petar Bajic

Date:
  January, 16 2007.

bool InitD3D | ( | HWND | hWnd,
|  | LPDIRECT3DDEVICE9 * | ppd3dDevice,
|  | LPDIRECT3D9 * | ppD3D,
|  | D3DPRESENT_PARAMETERS ** | ppd3dpp,
|  | bool | fullscreen |
| ) |  |  |

This function creates DirectX 3D Device.

Parameters:

  | hWnd | handle to the application window
  | ppd3dDevice | pointer to d3d device to be created
  | ppd3dpp | directX presentation parameters
  | fullscreen | boolean telling if application is started in fullscreen or windowed mode

Author:
  Petar Bajic

Date:
  January, 16 2007.

bool InitLight | ( | LPDIRECT3DDEVICE9 | pd3dDevice,
|  | D3DLIGHT9 * | light1,
|  | D3DLIGHT9 * | light2,
|  | D3DLIGHT9 * | light3 |
| ) |  |  |

This function creates lights.

Parameters:

  | light1 | pointer to light to be created

Author:
  Petar Bajic

Date:
  January, 16 2007.

bool InitSound | ( | HWND | hWnd,
|  | IDirectSound8 ** | ppDS |
| ) |  |  |

This function creates DirectX sound device.

Parameters:

  | ppDS | sound device to be created

Author:
  Petar Bajic

Date:
  January, 16 2007.

void Reset3D | ( | LPDIRECT3DDEVICE9 | pd3dDevice,
|  | D3DPRESENT_PARAMETERS * | pPP |
| ) |  |  |

This function resets D3D device.

Parameters:

  | pPP | new presentation parameters

Author:
  Petar Bajic

Date:
  January, 16 2007.

void SetupMatrices | ( | LPDIRECT3DDEVICE9 * | ppd3dDevice,
|  | D3DXVECTOR3 * | eye,
|  | D3DXVECTOR3 * | lookAt,
|  | D3DXVECTOR3 * | upVec,
|  | float | aspectRatio |
| ) |  |  |

World, View and Projection matrices are set with passed function parameters.

Parameters:

  | eye | position of the camera
  | lookAt | position where camera is pointed to.

Author:
  Petar Bajic

Date:
  January, 16 2007.

void ToggleFullScreen | ( | HWND | hWnd,
|  | LPDIRECT3DDEVICE9 | pd3dDevice,
|  | D3DPRESENT_PARAMETERS ** | ppPP,
|  | LPDIRECT3D9 | pD3D,
|  | int * | oldScreenWidth,
|  | int * | oldScreenHeight,
|  | int * | screenWidth,
|  | int * | screenHeight |
| ) |  |  |

Toggles fullscreen/windowed mode.

Parameters:

  | oldScreenWidth | screen width of previous application window state

Author:
  Petar Bajic

Date:
  January, 16 2007.