1 // machine generated, do not edit 2 3 module sokol.shape; 4 import sg = sokol.gfx; 5 6 /// sshape_range is a pointer-size-pair struct used to pass memory 7 /// blobs into sokol-shape. When initialized from a value type 8 /// (array or struct), use the SSHAPE_RANGE() macro to build 9 /// an sshape_range struct 10 extern(C) 11 struct Range { 12 const(void)* ptr = null; 13 size_t size = 0; 14 } 15 /// a 4x4 matrix wrapper struct 16 extern(C) 17 struct Mat4 { 18 float[4][4] m = 0.0f; 19 } 20 /// vertex layout of the generated geometry 21 extern(C) 22 struct Vertex { 23 float x = 0.0f; 24 float y = 0.0f; 25 float z = 0.0f; 26 uint normal = 0; 27 ushort u = 0; 28 ushort v = 0; 29 uint color = 0; 30 } 31 /// a range of draw-elements (sg_draw(int base_element, int num_element, ...)) 32 extern(C) 33 struct ElementRange { 34 uint base_element = 0; 35 uint num_elements = 0; 36 } 37 /// number of elements and byte size of build actions 38 extern(C) 39 struct SizesItem { 40 uint num = 0; 41 uint size = 0; 42 } 43 extern(C) 44 struct Sizes { 45 SizesItem vertices; 46 SizesItem indices; 47 } 48 /// in/out struct to keep track of mesh-build state 49 extern(C) 50 struct BufferItem { 51 Range buffer; 52 size_t data_size = 0; 53 size_t shape_offset = 0; 54 } 55 extern(C) 56 struct Buffer { 57 bool valid = false; 58 BufferItem vertices; 59 BufferItem indices; 60 } 61 /// creation parameters for the different shape types 62 extern(C) 63 struct Plane { 64 float width = 0.0f; 65 float depth = 0.0f; 66 ushort tiles = 0; 67 uint color = 0; 68 bool random_colors = false; 69 bool merge = false; 70 Mat4 transform; 71 } 72 extern(C) 73 struct Box { 74 float width = 0.0f; 75 float height = 0.0f; 76 float depth = 0.0f; 77 ushort tiles = 0; 78 uint color = 0; 79 bool random_colors = false; 80 bool merge = false; 81 Mat4 transform; 82 } 83 extern(C) 84 struct Sphere { 85 float radius = 0.0f; 86 ushort slices = 0; 87 ushort stacks = 0; 88 uint color = 0; 89 bool random_colors = false; 90 bool merge = false; 91 Mat4 transform; 92 } 93 extern(C) 94 struct Cylinder { 95 float radius = 0.0f; 96 float height = 0.0f; 97 ushort slices = 0; 98 ushort stacks = 0; 99 uint color = 0; 100 bool random_colors = false; 101 bool merge = false; 102 Mat4 transform; 103 } 104 extern(C) 105 struct Torus { 106 float radius = 0.0f; 107 float ring_radius = 0.0f; 108 ushort sides = 0; 109 ushort rings = 0; 110 uint color = 0; 111 bool random_colors = false; 112 bool merge = false; 113 Mat4 transform; 114 } 115 /// shape builder functions 116 extern(C) Buffer sshape_build_plane(const Buffer *, const Plane *) @system @nogc nothrow; 117 /// shape builder functions 118 Buffer buildPlane(scope ref Buffer buf, scope ref Plane params) @trusted @nogc nothrow { 119 return sshape_build_plane(&buf, ¶ms); 120 } 121 extern(C) Buffer sshape_build_box(const Buffer *, const Box *) @system @nogc nothrow; 122 Buffer buildBox(scope ref Buffer buf, scope ref Box params) @trusted @nogc nothrow { 123 return sshape_build_box(&buf, ¶ms); 124 } 125 extern(C) Buffer sshape_build_sphere(const Buffer *, const Sphere *) @system @nogc nothrow; 126 Buffer buildSphere(scope ref Buffer buf, scope ref Sphere params) @trusted @nogc nothrow { 127 return sshape_build_sphere(&buf, ¶ms); 128 } 129 extern(C) Buffer sshape_build_cylinder(const Buffer *, const Cylinder *) @system @nogc nothrow; 130 Buffer buildCylinder(scope ref Buffer buf, scope ref Cylinder params) @trusted @nogc nothrow { 131 return sshape_build_cylinder(&buf, ¶ms); 132 } 133 extern(C) Buffer sshape_build_torus(const Buffer *, const Torus *) @system @nogc nothrow; 134 Buffer buildTorus(scope ref Buffer buf, scope ref Torus params) @trusted @nogc nothrow { 135 return sshape_build_torus(&buf, ¶ms); 136 } 137 /// query required vertex- and index-buffer sizes in bytes 138 extern(C) Sizes sshape_plane_sizes(uint) @system @nogc nothrow; 139 /// query required vertex- and index-buffer sizes in bytes 140 Sizes planeSizes(uint tiles) @trusted @nogc nothrow { 141 return sshape_plane_sizes(tiles); 142 } 143 extern(C) Sizes sshape_box_sizes(uint) @system @nogc nothrow; 144 Sizes boxSizes(uint tiles) @trusted @nogc nothrow { 145 return sshape_box_sizes(tiles); 146 } 147 extern(C) Sizes sshape_sphere_sizes(uint, uint) @system @nogc nothrow; 148 Sizes sphereSizes(uint slices, uint stacks) @trusted @nogc nothrow { 149 return sshape_sphere_sizes(slices, stacks); 150 } 151 extern(C) Sizes sshape_cylinder_sizes(uint, uint) @system @nogc nothrow; 152 Sizes cylinderSizes(uint slices, uint stacks) @trusted @nogc nothrow { 153 return sshape_cylinder_sizes(slices, stacks); 154 } 155 extern(C) Sizes sshape_torus_sizes(uint, uint) @system @nogc nothrow; 156 Sizes torusSizes(uint sides, uint rings) @trusted @nogc nothrow { 157 return sshape_torus_sizes(sides, rings); 158 } 159 /// extract sokol-gfx desc structs and primitive ranges from build state 160 extern(C) ElementRange sshape_element_range(const Buffer *) @system @nogc nothrow; 161 /// extract sokol-gfx desc structs and primitive ranges from build state 162 ElementRange elementRange(scope ref Buffer buf) @trusted @nogc nothrow { 163 return sshape_element_range(&buf); 164 } 165 extern(C) sg.BufferDesc sshape_vertex_buffer_desc(const Buffer *) @system @nogc nothrow; 166 sg.BufferDesc vertexBufferDesc(scope ref Buffer buf) @trusted @nogc nothrow { 167 return sshape_vertex_buffer_desc(&buf); 168 } 169 extern(C) sg.BufferDesc sshape_index_buffer_desc(const Buffer *) @system @nogc nothrow; 170 sg.BufferDesc indexBufferDesc(scope ref Buffer buf) @trusted @nogc nothrow { 171 return sshape_index_buffer_desc(&buf); 172 } 173 extern(C) sg.VertexBufferLayoutState sshape_vertex_buffer_layout_state() @system @nogc nothrow; 174 sg.VertexBufferLayoutState vertexBufferLayoutState() @trusted @nogc nothrow { 175 return sshape_vertex_buffer_layout_state(); 176 } 177 extern(C) sg.VertexAttrState sshape_position_vertex_attr_state() @system @nogc nothrow; 178 sg.VertexAttrState positionVertexAttrState() @trusted @nogc nothrow { 179 return sshape_position_vertex_attr_state(); 180 } 181 extern(C) sg.VertexAttrState sshape_normal_vertex_attr_state() @system @nogc nothrow; 182 sg.VertexAttrState normalVertexAttrState() @trusted @nogc nothrow { 183 return sshape_normal_vertex_attr_state(); 184 } 185 extern(C) sg.VertexAttrState sshape_texcoord_vertex_attr_state() @system @nogc nothrow; 186 sg.VertexAttrState texcoordVertexAttrState() @trusted @nogc nothrow { 187 return sshape_texcoord_vertex_attr_state(); 188 } 189 extern(C) sg.VertexAttrState sshape_color_vertex_attr_state() @system @nogc nothrow; 190 sg.VertexAttrState colorVertexAttrState() @trusted @nogc nothrow { 191 return sshape_color_vertex_attr_state(); 192 } 193 /// helper functions to build packed color value from floats or bytes 194 extern(C) uint sshape_color_4f(float, float, float, float) @system @nogc nothrow; 195 /// helper functions to build packed color value from floats or bytes 196 uint color4f(float r, float g, float b, float a) @trusted @nogc nothrow { 197 return sshape_color_4f(r, g, b, a); 198 } 199 extern(C) uint sshape_color_3f(float, float, float) @system @nogc nothrow; 200 uint color3f(float r, float g, float b) @trusted @nogc nothrow { 201 return sshape_color_3f(r, g, b); 202 } 203 extern(C) uint sshape_color_4b(ubyte, ubyte, ubyte, ubyte) @system @nogc nothrow; 204 uint color4b(ubyte r, ubyte g, ubyte b, ubyte a) @trusted @nogc nothrow { 205 return sshape_color_4b(r, g, b, a); 206 } 207 extern(C) uint sshape_color_3b(ubyte, ubyte, ubyte) @system @nogc nothrow; 208 uint color3b(ubyte r, ubyte g, ubyte b) @trusted @nogc nothrow { 209 return sshape_color_3b(r, g, b); 210 } 211 /// adapter function for filling matrix struct from generic float[16] array 212 extern(C) Mat4 sshape_mat4(const float *) @system @nogc nothrow; 213 /// adapter function for filling matrix struct from generic float[16] array 214 Mat4 mat4(scope const float * m) @trusted @nogc nothrow { 215 return sshape_mat4(m); 216 } 217 extern(C) Mat4 sshape_mat4_transpose(const float *) @system @nogc nothrow; 218 Mat4 mat4Transpose(scope const float * m) @trusted @nogc nothrow { 219 return sshape_mat4_transpose(m); 220 }