| 182 | } |
| 183 | |
| 184 | bool VertexDeclaration::Initialize() |
| 185 | { |
| 186 | if (!VertexDeclarationLibrary::Initialize()) |
| 187 | { |
| 188 | NazaraError("Failed to initialise library"); |
| 189 | return false; |
| 190 | } |
| 191 | |
| 192 | try |
| 193 | { |
| 194 | ErrorFlags flags(ErrorFlag_Silent | ErrorFlag_ThrowException); |
| 195 | |
| 196 | // Layout : Type |
| 197 | VertexDeclaration* declaration; |
| 198 | |
| 199 | // VertexLayout_XY : VertexStruct_XY |
| 200 | declaration = &s_declarations[VertexLayout_XY]; |
| 201 | declaration->EnableComponent(VertexComponent_Position, ComponentType_Float2, NazaraOffsetOf(VertexStruct_XY, position)); |
| 202 | |
| 203 | NazaraAssert(declaration->GetStride() == sizeof(VertexStruct_XY), "Invalid stride for declaration VertexLayout_XY"); |
| 204 | |
| 205 | // VertexLayout_XY_Color : VertexStruct_XY_Color |
| 206 | declaration = &s_declarations[VertexLayout_XY_Color]; |
| 207 | declaration->EnableComponent(VertexComponent_Position, ComponentType_Float2, NazaraOffsetOf(VertexStruct_XY_Color, position)); |
| 208 | declaration->EnableComponent(VertexComponent_Color, ComponentType_Color, NazaraOffsetOf(VertexStruct_XY_Color, color)); |
| 209 | |
| 210 | NazaraAssert(declaration->GetStride() == sizeof(VertexStruct_XY_Color), "Invalid stride for declaration VertexLayout_XY_Color"); |
| 211 | |
| 212 | // VertexLayout_XY_UV : VertexStruct_XY_UV |
| 213 | declaration = &s_declarations[VertexLayout_XY_UV]; |
| 214 | declaration->EnableComponent(VertexComponent_Position, ComponentType_Float2, NazaraOffsetOf(VertexStruct_XY_UV, position)); |
| 215 | declaration->EnableComponent(VertexComponent_TexCoord, ComponentType_Float2, NazaraOffsetOf(VertexStruct_XY_UV, uv)); |
| 216 | |
| 217 | NazaraAssert(declaration->GetStride() == sizeof(VertexStruct_XY_UV), "Invalid stride for declaration VertexLayout_XY_UV"); |
| 218 | |
| 219 | // VertexLayout_XYZ : VertexStruct_XYZ |
| 220 | declaration = &s_declarations[VertexLayout_XYZ]; |
| 221 | declaration->EnableComponent(VertexComponent_Position, ComponentType_Float3, NazaraOffsetOf(VertexStruct_XYZ, position)); |
| 222 | |
| 223 | NazaraAssert(declaration->GetStride() == sizeof(VertexStruct_XYZ), "Invalid stride for declaration VertexLayout_XYZ"); |
| 224 | |
| 225 | // VertexLayout_XYZ_Color : VertexStruct_XYZ_Color |
| 226 | declaration = &s_declarations[VertexLayout_XYZ_Color]; |
| 227 | declaration->EnableComponent(VertexComponent_Position, ComponentType_Float3, NazaraOffsetOf(VertexStruct_XYZ_Color, position)); |
| 228 | declaration->EnableComponent(VertexComponent_Color, ComponentType_Color, NazaraOffsetOf(VertexStruct_XYZ_Color, color)); |
| 229 | |
| 230 | NazaraAssert(declaration->GetStride() == sizeof(VertexStruct_XYZ_Color), "Invalid stride for declaration VertexLayout_XYZ_Color"); |
| 231 | |
| 232 | // VertexLayout_XYZ_Color_UV : VertexStruct_XYZ_Color_UV |
| 233 | declaration = &s_declarations[VertexLayout_XYZ_Color_UV]; |
| 234 | declaration->EnableComponent(VertexComponent_Position, ComponentType_Float3, NazaraOffsetOf(VertexStruct_XYZ_Color_UV, position)); |
| 235 | declaration->EnableComponent(VertexComponent_Color, ComponentType_Color, NazaraOffsetOf(VertexStruct_XYZ_Color_UV, color)); |
| 236 | declaration->EnableComponent(VertexComponent_TexCoord, ComponentType_Float2, NazaraOffsetOf(VertexStruct_XYZ_Color_UV, uv)); |
| 237 | |
| 238 | NazaraAssert(declaration->GetStride() == sizeof(VertexStruct_XYZ_Color_UV), "Invalid stride for declaration VertexLayout_XYZ_Color_UV"); |
| 239 | |
| 240 | // VertexLayout_XYZ_Normal : VertexStruct_XYZ_Normal |
| 241 | declaration = &s_declarations[VertexLayout_XYZ_Normal]; |
nothing calls this directly
no test coverage detected