Nebula
Loading...
Searching...
No Matches
indextype.h
Go to the documentation of this file.
1#pragma once
2//------------------------------------------------------------------------------
12#include "core/types.h"
13
14//------------------------------------------------------------------------------
15namespace CoreGraphics
16{
18{
19public:
21 enum Code
22 {
23 None, // index type not defined
24 Index16, // 16 bit indices
25 Index32, // 32 bit indices
26 };
27
29 static SizeT SizeOf(IndexType::Code type);
31 static IndexType::Code ToIndexType(const SizeT size);
35 static IndexType::Code FromString(const Util::String& str);
36};
37
38//------------------------------------------------------------------------------
41inline SizeT
43{
44 n_assert(type != None);
45 switch (type)
46 {
47 case Index16: return 2;
48 case Index32: return 4;
49 default: return 0;
50 }
51}
52
53//------------------------------------------------------------------------------
56inline IndexType::Code
58{
59 n_assert(size != 0);
60 switch (size)
61 {
62 case 2: return Index16;
63 case 4: return Index32;
64 default: return None;
65 }
66}
67
68//------------------------------------------------------------------------------
71inline Util::String
73{
74 switch (type)
75 {
76 case None: return "None";
77 case Index16: return "Index16";
78 case Index32: return "Index32";
79 default:
80 n_error("IndexType::ToString(): Invalid IndexType code!");
81 return "";
82 }
83}
84
85//------------------------------------------------------------------------------
88inline IndexType::Code
90{
91 if ("None" == str) return None;
92 else if ("Index16" == str) return Index16;
93 else if ("Index32" == str) return Index32;
94 else
95 {
96 n_error("IndexType::FromString(): invalid index type string '%s'!", str.AsCharPtr());
97 return None;
98 }
99}
100
101}
102//------------------------------------------------------------------------------
Data type of vertex indices (16 bit or 32 bit).
Definition indextype.h:18
static IndexType::Code FromString(const Util::String &str)
convert string to index type
Definition indextype.h:89
static SizeT SizeOf(IndexType::Code type)
get byte size of index
Definition indextype.h:42
static Util::String ToString(IndexType::Code type)
convert index type to string
Definition indextype.h:72
static IndexType::Code ToIndexType(const SizeT size)
get size type from size
Definition indextype.h:57
Code
index types enum
Definition indextype.h:22
@ None
Definition indextype.h:23
@ Index32
Definition indextype.h:25
@ Index16
Definition indextype.h:24
void __cdecl n_error(const char *msg,...)
This function is called when a serious situation is encountered which requires abortion of the applic...
Definition debug.cc:138
#define n_assert(exp)
Definition debug.h:50
Acceleration structures are used to enable ray tracing on the GPU by dividing the scene into a BVH.
Definition accelerationstructure.h:24
Nebula's universal string class.
Definition string.h:50
const char * AsCharPtr() const
return contents as character pointer
Definition string.h:540
int SizeT
Definition types.h:49