Euphoria
shaderattribute.cc
Go to the documentation of this file.
2 
3 #include <utility>
4 
5 #include "assert/assert.h"
6 #include "base/cint.h"
7 
8 
9 namespace eu::render
10 {
11  int
13  {
14  switch(type)
15  {
16  case ShaderAttributeType::float1: return 1;
17  case ShaderAttributeType::float2: return 2;
18  case ShaderAttributeType::float3: return 3;
19  case ShaderAttributeType::float4: return 4;
20  case ShaderAttributeType::float33: return 3 * 3;
21  case ShaderAttributeType::float44: return 4 * 4;
22  default: DIE("Unhandled shader type"); return 0;
23  }
24  }
25 
26 
27  int
29  {
30  switch(type)
31  {
38  return c_sizet_to_int(sizeof(float)) * get_element_count();
39  default:
40  DIE("Unhandled shader type"); return 0;
41  }
42  }
43 
44 
45  bool
46  operator==(const ShaderAttribute& lhs, const ShaderAttribute& rhs)
47  {
48  return
49  lhs.name == rhs.name &&
50  lhs.id == rhs.id &&
51  lhs.type == rhs.type &&
52  lhs.normalize == rhs.normalize;
53  }
54 }
#define DIE(message)
Definition: assert.h:67
bool operator==(const ShaderAttribute &lhs, const ShaderAttribute &rhs)
int c_sizet_to_int(size_t t)
Definition: cint.cc:11
Represents a shader attribute like vertex, normal or uv coord.
gl::Int id
the id of the attribute
std::string_view name
the name of the shader attribute
ShaderAttributeType type
the type of the attribute