+int GetNumComponents(Graphics::VertexInputFormat vertexFormat)
+{
+ switch(vertexFormat)
+ {
+ case Graphics::VertexInputFormat::UNDEFINED:
+ case Graphics::VertexInputFormat::FLOAT:
+ case Graphics::VertexInputFormat::INTEGER:
+ return 1;
+ case Graphics::VertexInputFormat::IVECTOR2:
+ case Graphics::VertexInputFormat::FVECTOR2:
+ return 2;
+ case Graphics::VertexInputFormat::IVECTOR3:
+ case Graphics::VertexInputFormat::FVECTOR3:
+ return 3;
+ case Graphics::VertexInputFormat::FVECTOR4:
+ case Graphics::VertexInputFormat::IVECTOR4:
+ return 4;
+ }
+ return 1;
+}
+
+GLint GetSize(Graphics::VertexInputFormat vertexFormat)
+{
+ switch(vertexFormat)
+ {
+ case Graphics::VertexInputFormat::UNDEFINED:
+ return 1u;
+ case Graphics::VertexInputFormat::INTEGER:
+ case Graphics::VertexInputFormat::IVECTOR2:
+ case Graphics::VertexInputFormat::IVECTOR3:
+ case Graphics::VertexInputFormat::IVECTOR4:
+ return 2u;
+ case Graphics::VertexInputFormat::FLOAT:
+ case Graphics::VertexInputFormat::FVECTOR2:
+ case Graphics::VertexInputFormat::FVECTOR3:
+ case Graphics::VertexInputFormat::FVECTOR4:
+ return 4u;
+ }
+ return 1u;
+}
+
+GLint GetGlType(Graphics::VertexInputFormat vertexFormat)
+{
+ switch(vertexFormat)
+ {
+ case Graphics::VertexInputFormat::UNDEFINED:
+ return GL_BYTE;
+ case Graphics::VertexInputFormat::INTEGER:
+ case Graphics::VertexInputFormat::IVECTOR2:
+ case Graphics::VertexInputFormat::IVECTOR3:
+ case Graphics::VertexInputFormat::IVECTOR4:
+ return GL_SHORT;
+ case Graphics::VertexInputFormat::FLOAT:
+ case Graphics::VertexInputFormat::FVECTOR2:
+ case Graphics::VertexInputFormat::FVECTOR3:
+ case Graphics::VertexInputFormat::FVECTOR4:
+ return GL_FLOAT;
+ }
+ return GL_BYTE;
+}
+
+GLenum GetTopology(Graphics::PrimitiveTopology topology)
+{
+ switch(topology)
+ {
+ case Graphics::PrimitiveTopology::POINT_LIST:
+ return GL_POINTS;
+
+ case Graphics::PrimitiveTopology::LINE_LIST:
+ return GL_LINES;
+
+ case Graphics::PrimitiveTopology::LINE_LOOP:
+ return GL_LINE_LOOP;
+
+ case Graphics::PrimitiveTopology::LINE_STRIP:
+ return GL_LINE_STRIP;
+
+ case Graphics::PrimitiveTopology::TRIANGLE_LIST:
+ return GL_TRIANGLES;
+
+ case Graphics::PrimitiveTopology::TRIANGLE_STRIP:
+ return GL_TRIANGLE_STRIP;
+
+ case Graphics::PrimitiveTopology::TRIANGLE_FAN:
+ return GL_TRIANGLE_FAN;
+ }
+ return GL_TRIANGLES;
+}
+
+GLenum GetCullFace(Graphics::CullMode cullMode)
+{
+ switch(cullMode)
+ {
+ case Graphics::CullMode::NONE:
+ return GL_NONE;
+ case Graphics::CullMode::FRONT:
+ return GL_FRONT;
+ case Graphics::CullMode::BACK:
+ return GL_BACK;
+ case Graphics::CullMode::FRONT_AND_BACK:
+ return GL_FRONT_AND_BACK;
+ }
+ return GL_NONE;
+}
+
+GLenum GetFrontFace(Graphics::FrontFace frontFace)
+{
+ if(frontFace == Graphics::FrontFace::CLOCKWISE)
+ {
+ return GL_CW;
+ }
+ return GL_CCW;
+}
+
+GLenum GetBlendFactor(Graphics::BlendFactor blendFactor)
+{
+ GLenum glFactor = GL_ZERO;
+
+ switch(blendFactor)
+ {
+ case Graphics::BlendFactor::ZERO:
+ glFactor = GL_ZERO;
+ break;
+ case Graphics::BlendFactor::ONE:
+ glFactor = GL_ONE;
+ break;
+ case Graphics::BlendFactor::SRC_COLOR:
+ glFactor = GL_SRC_COLOR;
+ break;
+ case Graphics::BlendFactor::ONE_MINUS_SRC_COLOR:
+ glFactor = GL_ONE_MINUS_SRC_COLOR;
+ break;
+ case Graphics::BlendFactor::DST_COLOR:
+ glFactor = GL_DST_COLOR;
+ break;
+ case Graphics::BlendFactor::ONE_MINUS_DST_COLOR:
+ glFactor = GL_ONE_MINUS_DST_COLOR;
+ break;
+ case Graphics::BlendFactor::SRC_ALPHA:
+ glFactor = GL_SRC_ALPHA;
+ break;
+ case Graphics::BlendFactor::ONE_MINUS_SRC_ALPHA:
+ glFactor = GL_ONE_MINUS_SRC_ALPHA;
+ break;
+ case Graphics::BlendFactor::DST_ALPHA:
+ glFactor = GL_DST_ALPHA;
+ break;
+ case Graphics::BlendFactor::ONE_MINUS_DST_ALPHA:
+ glFactor = GL_ONE_MINUS_DST_ALPHA;
+ break;
+ case Graphics::BlendFactor::CONSTANT_COLOR:
+ glFactor = GL_CONSTANT_COLOR;
+ break;
+ case Graphics::BlendFactor::ONE_MINUS_CONSTANT_COLOR:
+ glFactor = GL_ONE_MINUS_CONSTANT_COLOR;
+ break;
+ case Graphics::BlendFactor::CONSTANT_ALPHA:
+ glFactor = GL_CONSTANT_ALPHA;
+ break;
+ case Graphics::BlendFactor::ONE_MINUS_CONSTANT_ALPHA:
+ glFactor = GL_ONE_MINUS_CONSTANT_ALPHA;
+ break;
+ case Graphics::BlendFactor::SRC_ALPHA_SATURATE:
+ glFactor = GL_SRC_ALPHA_SATURATE;
+ break;
+ // GLES doesn't appear to have dual source blending.
+ case Graphics::BlendFactor::SRC1_COLOR:
+ glFactor = GL_SRC_COLOR;
+ break;
+ case Graphics::BlendFactor::ONE_MINUS_SRC1_COLOR:
+ glFactor = GL_ONE_MINUS_SRC_COLOR;
+ break;
+ case Graphics::BlendFactor::SRC1_ALPHA:
+ glFactor = GL_SRC_ALPHA;
+ break;
+ case Graphics::BlendFactor::ONE_MINUS_SRC1_ALPHA:
+ glFactor = GL_ONE_MINUS_SRC_ALPHA;
+ break;
+ }
+ return glFactor;
+}
+
+GLenum GetBlendOp(Graphics::BlendOp blendOp)
+{
+ GLenum op = GL_FUNC_ADD;
+ switch(blendOp)
+ {
+ case Graphics::BlendOp::ADD:
+ op = GL_FUNC_ADD;
+ break;
+ case Graphics::BlendOp::SUBTRACT:
+ op = GL_FUNC_SUBTRACT;
+ break;
+ case Graphics::BlendOp::REVERSE_SUBTRACT:
+ op = GL_FUNC_REVERSE_SUBTRACT;
+ break;
+ case Graphics::BlendOp::MIN:
+ op = GL_MIN;
+ break;
+ case Graphics::BlendOp::MAX:
+ op = GL_MAX;
+ break;
+
+ // @todo Add advanced blend equations
+ }
+ return op;
+}
+