Advertisement
noodleBowl

vBatcher.h

Oct 6th, 2013
33
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.25 KB | None | 0 0
  1. #ifndef V_BATCHER
  2. #define V_BATCHER
  3.  
  4. #include <d3d9.h>
  5. #include <d3dx9.h>
  6. #include <iostream>
  7. #include <vector>
  8.  
  9. class vBatcher
  10. {
  11.  
  12.     //Vertex struct
  13.     struct vertex
  14.     {
  15.         float x;
  16.         float y;
  17.         float z;
  18.         float rhw;
  19.         D3DCOLOR color;
  20.         float u;
  21.         float v;
  22.     };
  23.  
  24.     //Quad struct
  25.     struct quad
  26.     {
  27.         vertex verts[4];
  28.         LPDIRECT3DTEXTURE9 texture;
  29.     };
  30.  
  31.     public:
  32.         vBatcher();
  33.         ~vBatcher();
  34.        
  35.         void initBatcher(LPDIRECT3DDEVICE9 &device);
  36.         void beginBatch();
  37.         void draw(float x, float y, float width, float height, LPDIRECT3DTEXTURE9 texture);
  38.         void endBatch();
  39.  
  40.     private:
  41.         //DirectX 9 device ref
  42.         LPDIRECT3DDEVICE9 batDevice;
  43.         DWORD CUSTOMFVF2;
  44.  
  45.         //Index and Vertex buffer items
  46.         LPDIRECT3DVERTEXBUFFER9 vBuffer;
  47.         LPDIRECT3DINDEXBUFFER9 iBuffer;
  48.         UINT vertexBufferSize;
  49.         UINT indexBufferSize;
  50.         DWORD bufferLockFlag;
  51.  
  52.         //Render vars
  53.         LPDIRECT3DTEXTURE9 currentTexture;
  54.         vertex *vertices;
  55.         short *indices;
  56.         int currentVertexBufferPosition;
  57.         int currentIndexBufferPosition;
  58.         int vertexOffsetForBuffer;
  59.         int numberOfVertsToDraw;
  60.         int numberOfShapesToDraw;
  61.         UINT totalAmountOfData;
  62.         bool bufferIsFull;
  63.  
  64.         //Draw var items
  65.         std::vector<quad> drawData;
  66.         quad quadData;
  67.  
  68.  
  69.  
  70.        
  71.  
  72.  
  73.  
  74.  
  75.  
  76. };
  77.  
  78. #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement