Blowbox 2017
A 3D Game Engine by Riko Ophorst using DirectX 12
vertex.h
1 #pragma once
2 
3 #include "renderer/d3d12_includes.h"
4 #include "util/vector.h"
5 
6 #define BLOWBOX_USE_32BIT_INDICES
7 
8 namespace blowbox
9 {
18 #ifdef BLOWBOX_USE_32BIT_INDICES
19  typedef uint32_t Index;
20 #else
21  typedef uint16_t Index;
22 #endif
23 
33  class Vertex
34  {
35  public:
36  Vertex() :
37  position(0.0f, 0.0f, 0.0f),
38  normal(0.0f, 1.0f, 0.0f),
39  tangent(1.0f, 0.0f, 0.0f),
40  uv(0.0f, 0.0f),
41  color(1.0f, 0.0f, 1.0f, 0.0f)
42  {
43 
44  }
45 
46  DirectX::XMFLOAT3 position;
47  DirectX::XMFLOAT3 normal;
48  DirectX::XMFLOAT3 tangent;
49  DirectX::XMFLOAT2 uv;
50  DirectX::XMFLOAT4 color;
51 
54  {
55  Vector<D3D12_INPUT_ELEMENT_DESC> input_elements(5);
56 
57  input_elements[0] = { "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA, 0 };
58  input_elements[1] = { "NORMAL", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 12, D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA, 0 };
59  input_elements[2] = { "TANGENT", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 24, D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA, 0 };
60  input_elements[3] = { "UV", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 36, D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA, 0 };
61  input_elements[4] = { "COLOR", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, 44, D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA, 0 };
62 
63  return input_elements;
64  }
65  };
66 }
eastl::vector< T > Vector
Typedef for wrapping the EASTL vector.
Definition: vector.h:14
Describes a Vertex.
Definition: vertex.h:33
DirectX::XMFLOAT2 uv
The UV coordinates of the vertex.
Definition: vertex.h:49
static Vector< D3D12_INPUT_ELEMENT_DESC > GetInputElements()
Definition: vertex.h:53
DirectX::XMFLOAT3 tangent
The tangent of the vertex.
Definition: vertex.h:48
DirectX::XMFLOAT4 color
The color of the vertex.
Definition: vertex.h:50
The main Blowbox namespace.
Definition: image.cc:8
DirectX::XMFLOAT3 normal
The normal of the vertex.
Definition: vertex.h:47
uint32_t Index
Descibes an index.
Definition: vertex.h:19
DirectX::XMFLOAT3 position
The position of the vertex.
Definition: vertex.h:46