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