Advertisement
noodleBowl

SpriteBatcher.h

Sep 26th, 2013
30
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. #ifndef SPRITE_BATCHER
  2. #define SPRITE_BATCHER
  3. #include <d3d9.h>
  4. #include <d3dx9.h>
  5. #include <iostream>
  6.  
  7. #define CUSTOMFVF (D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_TEX1)
  8.  
  9. class SpriteBatcher
  10. {
  11. //Vertex struct
  12. struct vertex
  13. {
  14. float x;
  15. float y;
  16. float z;
  17. float rhw;
  18. D3DCOLOR color;
  19. float u;
  20. float v;
  21. };
  22.  
  23. private:
  24. LPDIRECT3DDEVICE9 batDevice;
  25. LPDIRECT3DVERTEXBUFFER9 vBuffer;
  26. LPDIRECT3DINDEXBUFFER9 iBuffer;
  27. LPDIRECT3DTEXTURE9 currentTexture;
  28. D3DCOLOR CLEAR_COLOR;
  29. vertex vertices[12];
  30. short indices[18];
  31. int numShapes;
  32. int vertCount;
  33. int idxBuffCount;
  34. int renderCount;
  35. bool setTexture;
  36. VOID* pVoid;
  37. void render();
  38. void resetCounts();
  39.  
  40. public:
  41. SpriteBatcher();
  42. ~SpriteBatcher();
  43. void setBatcherDevice(LPDIRECT3DDEVICE9 &device);
  44. void beginBatch();
  45. void endBatch();
  46. void draw(float x, float y, float width, float height, D3DCOLOR color, LPDIRECT3DTEXTURE9 texture);
  47. void draw(float x, float y, float width, float height, D3DCOLOR color, float rotation, LPDIRECT3DTEXTURE9 texture);
  48. };
  49.  
  50. #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement