- Main Page
- Classes
- Files

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

File containing functions for drawing 2D sprites in 3D world. More...

`#include "MyDrawSprite.h"`

Include dependency graph for MyDrawSprite.cpp:

## Functions
void | my_DrawSprite (D3DXMATRIX *mat, D3DXVECTOR2 *scaling, D3DXVECTOR2 *spriteCentre, float rotation, D3DXVECTOR2 *trans, LPDIRECT3DTEXTURE9 tex, LPD3DXSPRITE sprite, bool enabled, LPRECT rect, WCHAR *strText, LPD3DXFONT pFont, D3DCOLOR color)
| my_DrawSprite draws sprite with the given billion parameters.
void | my_DrawOutlineText (D3DXMATRIX *mat, D3DXVECTOR2 *scaling, D3DXVECTOR2 *spriteCentre, float rotation, D3DXVECTOR2 *trans, LPD3DXSPRITE sprite, LPD3DXFONT pFont, WCHAR *strText, LPRECT rect, D3DCOLOR color, D3DCOLOR outlineColor)
| Ahh, my_DrawOutlineText, this is how I draw fancy outlined text used for intro movie.
void | my_DrawText (D3DXMATRIX *mat, D3DXVECTOR2 *scaling, D3DXVECTOR2 *spriteCentre, float rotation, D3DXVECTOR2 *trans, LPD3DXSPRITE sprite, LPD3DXFONT pFont, WCHAR *strText, LPRECT rect, D3DCOLOR color)
| Draws text on sprite.

## Detailed Description

File containing functions for drawing 2D sprites in 3D world.

Why did I make my own sprite drawing functions in separate file? 2D Sprites are drawn everywhere in the game. And newer DirectX version have diferent API for drawing sprites. If you want to move your game to another DirectX SDK there is no need to search the entire game code looking for all places sprites are drawn - you just change them in here. I happened to work on two close DirectX SDK - august and october 2006, and there was this difference in sprite API. Basicly - if I made all graphic calls in one separate layer I would have completely portable game. If I wanted to move my game to OpenGL then only one layer would be changed. But you don't do that for such small game like this unless youre bitten to.

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

Date:
  January, 16 2007.

## Function Documentation

void my_DrawOutlineText | ( | D3DXMATRIX * | mat,
|  | D3DXVECTOR2 * | scaling,
|  | D3DXVECTOR2 * | spriteCentre,
|  | float | rotation,
|  | D3DXVECTOR2 * | trans,
|  | LPD3DXSPRITE | sprite,
|  | LPD3DXFONT | pFont,
|  | WCHAR * | strText,
|  | LPRECT | rect,
|  | D3DCOLOR | color,
|  | D3DCOLOR | outlineColor |
| ) |  |  |

Ahh, my_DrawOutlineText, this is how I draw fancy outlined text used for intro movie.

Author:
  Petar Bajic

Date:
  January, 16 2007.

void my_DrawSprite | ( | D3DXMATRIX * | mat,
|  | D3DXVECTOR2 * | scaling,
|  | D3DXVECTOR2 * | spriteCentre,
|  | float | rotation,
|  | D3DXVECTOR2 * | trans,
|  | LPDIRECT3DTEXTURE9 | tex,
|  | LPD3DXSPRITE | sprite,
|  | bool | enabled,
|  | LPRECT | rect,
|  | WCHAR * | strText,
|  | LPD3DXFONT | pFont,
|  | D3DCOLOR | color |
| ) |  |  |

my_DrawSprite draws sprite with the given billion parameters.

Author:
  Petar Bajic

Date:
  January, 16 2007.

void my_DrawText | ( | D3DXMATRIX * | mat,
|  | D3DXVECTOR2 * | scaling,
|  | D3DXVECTOR2 * | spriteCentre,
|  | float | rotation,
|  | D3DXVECTOR2 * | trans,
|  | LPD3DXSPRITE | sprite,
|  | LPD3DXFONT | pFont,
|  | WCHAR * | strText,
|  | LPRECT | rect,
|  | D3DCOLOR | color |
| ) |  |  |

Draws text on sprite.

Author:
  Petar Bajic

Date:
  January, 16 2007.