Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <d3d9.h>
- #include "AxisRender.h"
- AxisRender::AxisRender(float p_length, DWORD p_color)
- {
- this->length = p_length;
- this->color = p_color;
- }
- AxisRender::~AxisRender()
- {
- this->VertexBuffer->Release();
- }
- void AxisRender::InitVideoMemory(IDirect3DDevice9* p_d3ddev)
- {
- this->d3ddev = p_d3ddev;
- AxisRenderFV Vertices[] =
- {
- {+(this->length), 0.0f, 0.0f, this->color,},
- {-(this->length), 0.0f, 0.0f, this->color,},
- {0.0f, +(this->length), 0.0f, this->color,},
- {0.0f, -(this->length), 0.0f, this->color,},
- {0.0f, 0.0f, +(this->length), this->color,},
- {0.0f, 0.0f, -(this->length), this->color,},
- };
- this->d3ddev->CreateVertexBuffer (
- sizeof(Vertices),
- D3DUSAGE_WRITEONLY,
- AxisRenderFVF,
- D3DPOOL_MANAGED,
- &(this->VertexBuffer),
- NULL
- );
- void* pVoid;
- this->VertexBuffer->Lock(0, 0, (void**)&pVoid, 0);
- memcpy(pVoid, Vertices, sizeof(Vertices));
- this->VertexBuffer->Unlock();
- }
- void AxisRender::Render()
- {
- this->d3ddev->SetStreamSource(0, this->VertexBuffer, 0, sizeof(AxisRenderFV));
- this->d3ddev->SetFVF(AxisRenderFVF);
- this->d3ddev->DrawPrimitive(D3DPT_LINELIST, 0, 3);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement