Skip to content

Commit

Permalink
Refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
matt77hias committed Jun 15, 2017
1 parent 8fc7510 commit cd5c3c3
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 36 deletions.
18 changes: 9 additions & 9 deletions MAGE/MAGE/src/mesh/vertex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,58 +12,58 @@
//-----------------------------------------------------------------------------
namespace mage {

const D3D11_INPUT_ELEMENT_DESC VertexPosition::input_element_desc[] = {
const D3D11_INPUT_ELEMENT_DESC VertexPosition::s_input_element_desc[] = {
{ MAGE_VERTEX_SEMANTIC_NAME_POSITION, 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 }
};

static_assert(sizeof(VertexPosition) == 12, "Vertex struct/layout mismatch");

const D3D11_INPUT_ELEMENT_DESC VertexPositionNormal::input_element_desc[] = {
const D3D11_INPUT_ELEMENT_DESC VertexPositionNormal::s_input_element_desc[] = {
{ MAGE_VERTEX_SEMANTIC_NAME_POSITION, 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 },
{ MAGE_VERTEX_SEMANTIC_NAME_NORMAL, 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 }
};

static_assert(sizeof(VertexPositionNormal) == 24, "Vertex struct/layout mismatch");

const D3D11_INPUT_ELEMENT_DESC VertexPositionColor::input_element_desc[] = {
const D3D11_INPUT_ELEMENT_DESC VertexPositionColor::s_input_element_desc[] = {
{ MAGE_VERTEX_SEMANTIC_NAME_POSITION, 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 },
{ MAGE_VERTEX_SEMANTIC_NAME_COLOR, 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 }
};

static_assert(sizeof(VertexPositionColor) == 28, "Vertex struct/layout mismatch");

const D3D11_INPUT_ELEMENT_DESC VertexPositionTexture::input_element_desc[] = {
const D3D11_INPUT_ELEMENT_DESC VertexPositionTexture::s_input_element_desc[] = {
{ MAGE_VERTEX_SEMANTIC_NAME_POSITION, 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 },
{ MAGE_VERTEX_SEMANTIC_NAME_TEXTURE, 0, DXGI_FORMAT_R32G32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 }
};

static_assert(sizeof(VertexPositionTexture) == 20, "Vertex struct/layout mismatch");

const D3D11_INPUT_ELEMENT_DESC VertexPositionNormalColor::input_element_desc[] = {
const D3D11_INPUT_ELEMENT_DESC VertexPositionNormalColor::s_input_element_desc[] = {
{ MAGE_VERTEX_SEMANTIC_NAME_POSITION, 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 },
{ MAGE_VERTEX_SEMANTIC_NAME_NORMAL, 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 },
{ MAGE_VERTEX_SEMANTIC_NAME_COLOR, 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 }
};

static_assert(sizeof(VertexPositionNormalColor) == 40, "Vertex struct/layout mismatch");

const D3D11_INPUT_ELEMENT_DESC VertexPositionNormalTexture::input_element_desc[] = {
const D3D11_INPUT_ELEMENT_DESC VertexPositionNormalTexture::s_input_element_desc[] = {
{ MAGE_VERTEX_SEMANTIC_NAME_POSITION, 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 },
{ MAGE_VERTEX_SEMANTIC_NAME_NORMAL, 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 },
{ MAGE_VERTEX_SEMANTIC_NAME_TEXTURE, 0, DXGI_FORMAT_R32G32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 }
};

static_assert(sizeof(VertexPositionNormalTexture) == 32, "Vertex struct/layout mismatch");

const D3D11_INPUT_ELEMENT_DESC VertexPositionColorTexture::input_element_desc[] = {
const D3D11_INPUT_ELEMENT_DESC VertexPositionColorTexture::s_input_element_desc[] = {
{ MAGE_VERTEX_SEMANTIC_NAME_POSITION, 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 },
{ MAGE_VERTEX_SEMANTIC_NAME_COLOR, 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 },
{ MAGE_VERTEX_SEMANTIC_NAME_TEXTURE, 0, DXGI_FORMAT_R32G32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 }
};

static_assert(sizeof(VertexPositionColorTexture) == 36, "Vertex struct/layout mismatch");

const D3D11_INPUT_ELEMENT_DESC VertexPositionNormalColorTexture::input_element_desc[] = {
const D3D11_INPUT_ELEMENT_DESC VertexPositionNormalColorTexture::s_input_element_desc[] = {
{ MAGE_VERTEX_SEMANTIC_NAME_POSITION, 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 },
{ MAGE_VERTEX_SEMANTIC_NAME_NORMAL, 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 },
{ MAGE_VERTEX_SEMANTIC_NAME_COLOR, 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 },
Expand All @@ -72,7 +72,7 @@ namespace mage {

static_assert(sizeof(VertexPositionNormalColorTexture) == 48, "Vertex struct/layout mismatch");

const D3D11_INPUT_ELEMENT_DESC VertexPositionTextureTexture::input_element_desc[] = {
const D3D11_INPUT_ELEMENT_DESC VertexPositionTextureTexture::s_input_element_desc[] = {
{ MAGE_VERTEX_SEMANTIC_NAME_POSITION, 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 },
{ MAGE_VERTEX_SEMANTIC_NAME_TEXTURE, 0, DXGI_FORMAT_R32G32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 },
{ MAGE_VERTEX_SEMANTIC_NAME_TEXTURE, 1, DXGI_FORMAT_R32G32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 }
Expand Down
36 changes: 18 additions & 18 deletions MAGE/MAGE/src/mesh/vertex.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,12 @@ namespace mage {
/**
The number of elements in the input element descriptor of a vertex.
*/
static const uint32_t nb_input_elements = 1;
static const uint32_t s_nb_input_elements = 1;

/**
The input element descriptor of a vertex.
*/
static const D3D11_INPUT_ELEMENT_DESC input_element_desc[nb_input_elements];
static const D3D11_INPUT_ELEMENT_DESC s_input_element_desc[s_nb_input_elements];
};

/**
Expand Down Expand Up @@ -214,12 +214,12 @@ namespace mage {
/**
The number of elements in the input element descriptor of a vertex.
*/
static const uint32_t nb_input_elements = 2;
static const uint32_t s_nb_input_elements = 2;

/**
The input element descriptor of a vertex.
*/
static const D3D11_INPUT_ELEMENT_DESC input_element_desc[nb_input_elements];
static const D3D11_INPUT_ELEMENT_DESC s_input_element_desc[s_nb_input_elements];
};

/**
Expand Down Expand Up @@ -315,12 +315,12 @@ namespace mage {
/**
The number of elements in the input element descriptor of a vertex.
*/
static const uint32_t nb_input_elements = 2;
static const uint32_t s_nb_input_elements = 2;

/**
The input element descriptor of a vertex.
*/
static const D3D11_INPUT_ELEMENT_DESC input_element_desc[nb_input_elements];
static const D3D11_INPUT_ELEMENT_DESC s_input_element_desc[s_nb_input_elements];
};

/**
Expand Down Expand Up @@ -416,12 +416,12 @@ namespace mage {
/**
The number of elements in the input element descriptor of a vertex.
*/
static const uint32_t nb_input_elements = 2;
static const uint32_t s_nb_input_elements = 2;

/**
The input element descriptor of a vertex.
*/
static const D3D11_INPUT_ELEMENT_DESC input_element_desc[nb_input_elements];
static const D3D11_INPUT_ELEMENT_DESC s_input_element_desc[s_nb_input_elements];
};

/**
Expand Down Expand Up @@ -524,12 +524,12 @@ namespace mage {
/**
The number of elements in the input element descriptor of a vertex.
*/
static const uint32_t nb_input_elements = 3;
static const uint32_t s_nb_input_elements = 3;

/**
The input element descriptor of a vertex.
*/
static const D3D11_INPUT_ELEMENT_DESC input_element_desc[nb_input_elements];
static const D3D11_INPUT_ELEMENT_DESC s_input_element_desc[s_nb_input_elements];
};

/**
Expand Down Expand Up @@ -632,12 +632,12 @@ namespace mage {
/**
The number of elements in the input element descriptor of a vertex.
*/
static const uint32_t nb_input_elements = 3;
static const uint32_t s_nb_input_elements = 3;

/**
The input element descriptor of a vertex.
*/
static const D3D11_INPUT_ELEMENT_DESC input_element_desc[nb_input_elements];
static const D3D11_INPUT_ELEMENT_DESC s_input_element_desc[s_nb_input_elements];
};

/**
Expand Down Expand Up @@ -740,12 +740,12 @@ namespace mage {
/**
The number of elements in the input element descriptor of a vertex.
*/
static const uint32_t nb_input_elements = 3;
static const uint32_t s_nb_input_elements = 3;

/**
The input element descriptor of a vertex.
*/
static const D3D11_INPUT_ELEMENT_DESC input_element_desc[nb_input_elements];
static const D3D11_INPUT_ELEMENT_DESC s_input_element_desc[s_nb_input_elements];
};

/**
Expand Down Expand Up @@ -855,12 +855,12 @@ namespace mage {
/**
The number of elements in the input element descriptor of a vertex.
*/
static const int nb_input_elements = 4;
static const int s_nb_input_elements = 4;

/**
The input element descriptor of a vertex.
*/
static const D3D11_INPUT_ELEMENT_DESC input_element_desc[nb_input_elements];
static const D3D11_INPUT_ELEMENT_DESC s_input_element_desc[s_nb_input_elements];
};

/**
Expand Down Expand Up @@ -963,11 +963,11 @@ namespace mage {
/**
The number of elements in the input element descriptor of a vertex.
*/
static const int nb_input_elements = 3;
static const int s_nb_input_elements = 3;

/**
The input element descriptor of a vertex.
*/
static const D3D11_INPUT_ELEMENT_DESC input_element_desc[nb_input_elements];
static const D3D11_INPUT_ELEMENT_DESC s_input_element_desc[s_nb_input_elements];
};
}
8 changes: 4 additions & 4 deletions MAGE/MAGE/src/shader/basic_shader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ namespace mage {
BasicVertexShader::BasicVertexShader(ID3D11Device2 *device, ID3D11DeviceContext2 *device_context,
const wstring &fname)
: VertexShader(device, device_context, fname,
VertexPositionNormalTexture::input_element_desc,
VertexPositionNormalTexture::nb_input_elements) {}
VertexPositionNormalTexture::s_input_element_desc,
VertexPositionNormalTexture::s_nb_input_elements) {}

BasicVertexShader::BasicVertexShader(ID3D11Device2 *device, ID3D11DeviceContext2 *device_context,
const CompiledVertexShader &compiled_vertex_shader)
: VertexShader(device, device_context, compiled_vertex_shader,
VertexPositionNormalTexture::input_element_desc,
VertexPositionNormalTexture::nb_input_elements) {}
VertexPositionNormalTexture::s_input_element_desc,
VertexPositionNormalTexture::s_nb_input_elements) {}

BasicVertexShader::BasicVertexShader(BasicVertexShader &&vertex_shader) = default;

Expand Down
2 changes: 1 addition & 1 deletion MAGE/MAGE/src/shader/sprite_shader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ namespace mage {

SpriteVertexShader::SpriteVertexShader(ID3D11Device2 *device, ID3D11DeviceContext2 *device_context)
: VertexShader(device, device_context, CreateCompiledSpriteVertexShader(),
VertexPositionColorTexture::input_element_desc, VertexPositionColorTexture::nb_input_elements) {}
VertexPositionColorTexture::s_input_element_desc, VertexPositionColorTexture::s_nb_input_elements) {}

SpriteVertexShader::SpriteVertexShader(SpriteVertexShader &&vertex_shader) = default;

Expand Down
8 changes: 4 additions & 4 deletions MAGE/MAGE/src/shader/tsnm_shader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ namespace mage {
TSNMVertexShader::TSNMVertexShader(ID3D11Device2 *device, ID3D11DeviceContext2 *device_context,
const wstring &fname)
: VertexShader(device, device_context, fname,
VertexPositionNormalTexture::input_element_desc,
VertexPositionNormalTexture::nb_input_elements) {}
VertexPositionNormalTexture::s_input_element_desc,
VertexPositionNormalTexture::s_nb_input_elements) {}

TSNMVertexShader::TSNMVertexShader(ID3D11Device2 *device, ID3D11DeviceContext2 *device_context,
const CompiledVertexShader &compiled_vertex_shader)
: VertexShader(device, device_context, compiled_vertex_shader,
VertexPositionNormalTexture::input_element_desc,
VertexPositionNormalTexture::nb_input_elements) {}
VertexPositionNormalTexture::s_input_element_desc,
VertexPositionNormalTexture::s_nb_input_elements) {}

TSNMVertexShader::TSNMVertexShader(TSNMVertexShader &&vertex_shader) = default;

Expand Down

0 comments on commit cd5c3c3

Please sign in to comment.