Advertisement
Guest User

Untitled

a guest
Oct 26th, 2012
24
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.24 KB | None | 0 0
  1. #include <d3d9.h>
  2. #include "AxisRender.h"
  3.  
  4. AxisRender::AxisRender(float p_length, DWORD p_color)
  5. {
  6.     this->length = p_length;
  7.     this->color = p_color;
  8. }
  9.  
  10. AxisRender::~AxisRender()
  11. {
  12.     this->VertexBuffer->Release();
  13. }
  14.  
  15. void AxisRender::InitVideoMemory(IDirect3DDevice9* p_d3ddev)
  16. {
  17.     this->d3ddev = p_d3ddev;
  18.  
  19.     AxisRenderFV Vertices[] =
  20.     {
  21.         {+(this->length),   0.0f,               0.0f,               this->color,},
  22.         {-(this->length),   0.0f,               0.0f,               this->color,},
  23.         {0.0f,              +(this->length),    0.0f,               this->color,},
  24.         {0.0f,              -(this->length),    0.0f,               this->color,},
  25.         {0.0f,              0.0f,               +(this->length),    this->color,},
  26.         {0.0f,              0.0f,               -(this->length),    this->color,},
  27.     };
  28.  
  29.     this->d3ddev->CreateVertexBuffer    (
  30.                                             sizeof(Vertices),
  31.                                             D3DUSAGE_WRITEONLY,
  32.                                             AxisRenderFVF,
  33.                                             D3DPOOL_MANAGED,
  34.                                             &(this->VertexBuffer),
  35.                                             NULL
  36.                                         );
  37.  
  38.     void* pVoid;
  39.  
  40.     this->VertexBuffer->Lock(0, 0, (void**)&pVoid, 0);
  41.  
  42.     memcpy(pVoid, Vertices, sizeof(Vertices));
  43.  
  44.     this->VertexBuffer->Unlock();
  45. }
  46.  
  47. void AxisRender::Render()
  48. {
  49.     this->d3ddev->SetStreamSource(0, this->VertexBuffer, 0, sizeof(AxisRenderFV));
  50.     this->d3ddev->SetFVF(AxisRenderFVF);
  51.     this->d3ddev->DrawPrimitive(D3DPT_LINELIST, 0, 3);
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement