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