1
+ #ifndef FASTGLTF_C_H
2
+ #define FASTGLTF_C_H
3
+
4
+ #ifdef __cplusplus
5
+ #include <cstddef>
6
+ #else
7
+ #include <stddef.h>
8
+ #endif
9
+
1
10
enum fastgltf_extensions {
2
11
KHR_texture_transform = 1 << 1 ,
3
12
KHR_texture_basisu = 1 << 2 ,
@@ -32,24 +41,140 @@ enum fastgltf_error {
32
41
enum fastgltf_category {
33
42
CategoryNone = 0 ,
34
43
35
- CategoryBuffers = 1 << 0 ,
44
+ CategoryBuffers = 1 << 0 ,
36
45
CategoryBufferViews = 1 << 1 | CategoryBuffers ,
37
- CategoryAccessors = 1 << 2 | CategoryBufferViews ,
38
- CategoryImages = 1 << 3 | CategoryBufferViews ,
39
- CategorySamplers = 1 << 4 ,
40
- CategoryTextures = 1 << 5 | CategoryImages | CategorySamplers ,
41
- CategoryAnimations = 1 << 6 | CategoryAccessors ,
42
- CategoryCameras = 1 << 7 ,
43
- CategoryMaterials = 1 << 8 | CategoryTextures ,
44
- CategoryMeshes = 1 << 9 | CategoryAccessors | CategoryMaterials ,
45
- CategorySkins = 1 << 10 | CategoryAccessors | (1 << 11 ),
46
- CategoryNodes = 1 << 11 | CategoryCameras | CategoryMeshes | CategorySkins ,
47
- CategoryScenes = 1 << 12 | CategoryNodes ,
48
- CategoryAsset = 1 << 13 ,
49
-
50
- CategoryAll = CategoryAsset | CategoryScenes | CategoryAnimations ,
46
+ CategoryAccessors = 1 << 2 | CategoryBufferViews ,
47
+ CategoryImages = 1 << 3 | CategoryBufferViews ,
48
+ CategorySamplers = 1 << 4 ,
49
+ CategoryTextures = 1 << 5 | CategoryImages | CategorySamplers ,
50
+ CategoryAnimations = 1 << 6 | CategoryAccessors ,
51
+ CategoryCameras = 1 << 7 ,
52
+ CategoryMaterials = 1 << 8 | CategoryTextures ,
53
+ CategoryMeshes = 1 << 9 | CategoryAccessors | CategoryMaterials ,
54
+ CategorySkins = 1 << 10 | CategoryAccessors | (1 << 11 ),
55
+ CategoryNodes = 1 << 11 | CategoryCameras | CategoryMeshes | CategorySkins ,
56
+ CategoryScenes = 1 << 12 | CategoryNodes ,
57
+ CategoryAsset = 1 << 13 ,
58
+
59
+ CategoryAll = CategoryAsset | CategoryScenes | CategoryAnimations ,
60
+ };
61
+
62
+ enum fastgltf_primitive_type {
63
+ PrimitiveTypePoints = 0 ,
64
+ PrimitiveTypeLines = 1 ,
65
+ PrimitiveTypeLineLoop = 2 ,
66
+ PrimitiveTypeLineStrip = 3 ,
67
+ PrimitiveTypeTriangles = 4 ,
68
+ PrimitiveTypeTriangleStrip = 5 ,
69
+ PrimitiveTypeTriangleFan = 6 ,
70
+ };
71
+
72
+ enum fastgltf_accessor_type {
73
+ AccessorTypeInvalid = 0 ,
74
+ AccessorTypeScalar = (1 << 8 ) | 1 ,
75
+ AccessorTypeVec2 = (2 << 8 ) | 2 ,
76
+ AccessorTypeVec3 = (3 << 8 ) | 3 ,
77
+ AccessorTypeVec4 = ( 4 << 8 ) | 4 ,
78
+ AccessorTypeMat2 = ( 4 << 8 ) | 5 ,
79
+ AccessorTypeMat3 = ( 9 << 8 ) | 6 ,
80
+ AccessorTypeMat4 = (16 << 8 ) | 7 ,
81
+ };
82
+
83
+ enum fastgltf_component_type {
84
+ ComponentTypeInvalid = 0 ,
85
+ ComponentTypeByte = ( 8 << 16 ) | 5120 ,
86
+ ComponentTypeUnsignedByte = ( 8 << 16 ) | 5121 ,
87
+ ComponentTypeShort = (16 << 16 ) | 5122 ,
88
+ ComponentTypeUnsignedShort = (16 << 16 ) | 5123 ,
89
+ ComponentTypeUnsignedInt = (32 << 16 ) | 5125 ,
90
+ ComponentTypeFloat = (32 << 16 ) | 5126 ,
91
+ ComponentTypeDouble = (64 << 16 ) | 5130 ,
92
+ };
93
+
94
+ enum fastgltf_filter {
95
+ FilterNearest = 9728 ,
96
+ FilterLinear = 9729 ,
97
+ FilterNearestMipMapNearest = 9984 ,
98
+ FilterLinearMipMapNearest = 9985 ,
99
+ FilterNearestMipMapLinear = 9986 ,
100
+ FilterLinearMipMapLinear = 9987 ,
101
+ };
102
+
103
+ enum fastgltf_wrap {
104
+ WrapClampToEdge = 33071 ,
105
+ WrapMirroredRepeat = 33648 ,
106
+ WrapRepeat = 10497 ,
107
+ };
108
+
109
+ enum BufferTarget {
110
+ BufferTargetArrayBuffer = 34962 ,
111
+ BufferTargetElementArrayBuffer = 34963 ,
112
+ };
113
+
114
+ enum MimeType {
115
+ MimeTypeNone = 0 ,
116
+ MimeTypeJPEG = 1 ,
117
+ MimeTypePNG = 2 ,
118
+ MimeTypeKTX2 = 3 ,
119
+ MimeTypeDDS = 4 ,
120
+ MimeTypeGltfBuffer = 5 ,
121
+ MimeTypeOctetStream = 6 ,
122
+ };
123
+
124
+ enum AnimationInterpolation {
125
+ AnimationInterpolationLinear = 0 ,
126
+ AnimationInterpolationStep = 1 ,
127
+ AnimationInterpolationCubicSpline = 2 ,
51
128
};
52
129
130
+ enum AnimationPath {
131
+ AnimationPathTranslation = 1 ,
132
+ AnimationPathRotation = 2 ,
133
+ AnimationPathScale = 3 ,
134
+ AnimationPathWeights = 4 ,
135
+ };
136
+
137
+ enum CameraType {
138
+ CameraTypePerspective = 0 ,
139
+ CameraTypeOrthographic = 1 ,
140
+ };
141
+
142
+ enum AlphaMode {
143
+ AlphaModeOpaque = 0 ,
144
+ AlphaModeMask = 1 ,
145
+ AlphaModeBlend = 2 ,
146
+ };
147
+
148
+ enum MeshoptCompressionMode {
149
+ MeshoptCompressionModeNone = 0 ,
150
+ MeshoptCompressionModeAttributes = 1 ,
151
+ MeshoptCompressionModeTriangles = 2 ,
152
+ MeshoptCompressionModeIndices = 3 ,
153
+ };
154
+
155
+ enum MeshoptCompressionFilter {
156
+ MeshoptCompressionFilterNone = 0 ,
157
+ MeshoptCompressionFilterOctahedral = 1 ,
158
+ MeshoptCompressionFilterQuaternion = 2 ,
159
+ MeshoptCompressionFilterExponential = 3 ,
160
+ };
161
+
162
+ inline unsigned int getNumComponents (fastgltf_accessor_type type ) {
163
+ return (type >> 8 ) & 0xFF ;
164
+ }
165
+
166
+ inline unsigned int getComponentBitSize (fastgltf_component_type type ) {
167
+ return (type & 0xFFFF0000 ) >> 16 ;
168
+ }
169
+
170
+ inline unsigned int getElementByteSize (fastgltf_accessor_type type , fastgltf_component_type componentType ) {
171
+ return getNumComponents (type ) * (getComponentBitSize (componentType ) / 8 );
172
+ }
173
+
174
+ inline unsigned int getGLComponentType (fastgltf_component_type type ) {
175
+ return type & 0xFFFF ;
176
+ }
177
+
53
178
#define FASTGLTF_EXPORT
54
179
55
180
#ifdef __cplusplus
@@ -61,6 +186,9 @@ typedef struct fastgltf_gltf_data_buffer_s fastgltf_gltf_data_buffer;
61
186
typedef struct fastgltf_gltf_s fastgltf_gltf ;
62
187
typedef struct fastgltf_asset_s fastgltf_asset ;
63
188
189
+ FASTGLTF_EXPORT fastgltf_component_type fastgltf_get_component_type (unsigned int componentType );
190
+ FASTGLTF_EXPORT fastgltf_accessor_type fastgltf_get_accessor_type (const char * string );
191
+
64
192
FASTGLTF_EXPORT fastgltf_parser * fastgltf_create_parser (fastgltf_extensions extensions );
65
193
FASTGLTF_EXPORT void fastgltf_destroy_parser (fastgltf_parser * parser );
66
194
@@ -83,3 +211,5 @@ FASTGLTF_EXPORT void fastgltf_destroy_asset(fastgltf_asset* asset);
83
211
#endif
84
212
85
213
#undef FASTGLTF_EXPORT
214
+
215
+ #endif
0 commit comments