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_t 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 enum min_vertex_size = 12; 23 enum max_vertex_size = 24; 24 /++ 25 + a 4x4 matrix wrapper struct 26 +/ 27 extern(C) struct Mat4 { 28 float[4][4] m = [0.0f, 0.0f, 0.0f, 0.0f]; 29 } 30 /++ 31 + a struct for configuring optional vertex components 32 +/ 33 extern(C) struct OptionalComponents { 34 bool normals = false; 35 bool texcoords = false; 36 bool colors = false; 37 } 38 /++ 39 + a range of draw-elements (sg_draw(int base_element, int num_element, ...)) 40 +/ 41 extern(C) struct ElementRange { 42 uint base_element = 0; 43 uint num_elements = 0; 44 } 45 /++ 46 + number of elements and byte size of build actions 47 +/ 48 extern(C) struct SizesItem { 49 uint num = 0; 50 uint size = 0; 51 } 52 extern(C) struct Sizes { 53 SizesItem vertices = {}; 54 SizesItem indices = {}; 55 } 56 /++ 57 + in/out struct to keep track of mesh-build state 58 +/ 59 extern(C) struct BufferState { 60 Range buffer = {}; 61 size_t data_size = 0; 62 size_t shape_offset = 0; 63 } 64 extern(C) struct State { 65 bool valid = false; 66 OptionalComponents disable = {}; 67 BufferState vertices = {}; 68 BufferState indices = {}; 69 } 70 /++ 71 + creation parameters for the different shape types 72 +/ 73 extern(C) struct Plane { 74 float width = 0.0f; 75 float depth = 0.0f; 76 ushort tiles = 0; 77 uint color = 0; 78 bool random_colors = false; 79 bool merge = false; 80 Mat4 transform = {}; 81 } 82 extern(C) struct Box { 83 float width = 0.0f; 84 float height = 0.0f; 85 float depth = 0.0f; 86 ushort tiles = 0; 87 uint color = 0; 88 bool random_colors = false; 89 bool merge = false; 90 Mat4 transform = {}; 91 } 92 extern(C) struct Sphere { 93 float radius = 0.0f; 94 ushort slices = 0; 95 ushort stacks = 0; 96 uint color = 0; 97 bool random_colors = false; 98 bool merge = false; 99 Mat4 transform = {}; 100 } 101 extern(C) struct Cylinder { 102 float radius = 0.0f; 103 float height = 0.0f; 104 ushort slices = 0; 105 ushort stacks = 0; 106 uint color = 0; 107 bool random_colors = false; 108 bool merge = false; 109 Mat4 transform = {}; 110 } 111 extern(C) struct Torus { 112 float radius = 0.0f; 113 float ring_radius = 0.0f; 114 ushort sides = 0; 115 ushort rings = 0; 116 uint color = 0; 117 bool random_colors = false; 118 bool merge = false; 119 Mat4 transform = {}; 120 } 121 /++ 122 + shape builder functions 123 +/ 124 extern(C) void sshape_build_plane(const State* state, const Plane* params) @system @nogc nothrow pure; 125 void buildPlane(scope ref State state, scope ref Plane params) @trusted @nogc nothrow pure { 126 sshape_build_plane(&state, ¶ms); 127 } 128 extern(C) void sshape_build_box(const State* state, const Box* params) @system @nogc nothrow pure; 129 void buildBox(scope ref State state, scope ref Box params) @trusted @nogc nothrow pure { 130 sshape_build_box(&state, ¶ms); 131 } 132 extern(C) void sshape_build_sphere(const State* state, const Sphere* params) @system @nogc nothrow pure; 133 void buildSphere(scope ref State state, scope ref Sphere params) @trusted @nogc nothrow pure { 134 sshape_build_sphere(&state, ¶ms); 135 } 136 extern(C) void sshape_build_cylinder(const State* state, const Cylinder* params) @system @nogc nothrow pure; 137 void buildCylinder(scope ref State state, scope ref Cylinder params) @trusted @nogc nothrow pure { 138 sshape_build_cylinder(&state, ¶ms); 139 } 140 extern(C) void sshape_build_torus(const State* state, const Torus* params) @system @nogc nothrow pure; 141 void buildTorus(scope ref State state, scope ref Torus params) @trusted @nogc nothrow pure { 142 sshape_build_torus(&state, ¶ms); 143 } 144 /++ 145 + compute size of vertex given optional components 146 +/ 147 extern(C) size_t sshape_vertex_size(const OptionalComponents* components) @system @nogc nothrow pure; 148 size_t vertexSize(scope ref OptionalComponents components) @trusted @nogc nothrow pure { 149 return sshape_vertex_size(&components); 150 } 151 /++ 152 + query required vertex- and index-buffer sizes in bytes 153 +/ 154 extern(C) Sizes sshape_plane_sizes(uint tiles, size_t vertex_size) @system @nogc nothrow pure; 155 Sizes planeSizes(uint tiles, size_t vertex_size) @trusted @nogc nothrow pure { 156 return sshape_plane_sizes(tiles, vertex_size); 157 } 158 extern(C) Sizes sshape_box_sizes(uint tiles, size_t vertex_size) @system @nogc nothrow pure; 159 Sizes boxSizes(uint tiles, size_t vertex_size) @trusted @nogc nothrow pure { 160 return sshape_box_sizes(tiles, vertex_size); 161 } 162 extern(C) Sizes sshape_sphere_sizes(uint slices, uint stacks, size_t vertex_size) @system @nogc nothrow pure; 163 Sizes sphereSizes(uint slices, uint stacks, size_t vertex_size) @trusted @nogc nothrow pure { 164 return sshape_sphere_sizes(slices, stacks, vertex_size); 165 } 166 extern(C) Sizes sshape_cylinder_sizes(uint slices, uint stacks, size_t vertex_size) @system @nogc nothrow pure; 167 Sizes cylinderSizes(uint slices, uint stacks, size_t vertex_size) @trusted @nogc nothrow pure { 168 return sshape_cylinder_sizes(slices, stacks, vertex_size); 169 } 170 extern(C) Sizes sshape_torus_sizes(uint sides, uint rings, size_t vertex_size) @system @nogc nothrow pure; 171 Sizes torusSizes(uint sides, uint rings, size_t vertex_size) @trusted @nogc nothrow pure { 172 return sshape_torus_sizes(sides, rings, vertex_size); 173 } 174 /++ 175 + extract sokol-gfx desc structs and primitive ranges from build state 176 +/ 177 extern(C) ElementRange sshape_element_range(const State* state) @system @nogc nothrow pure; 178 ElementRange elementRange(scope ref State state) @trusted @nogc nothrow pure { 179 return sshape_element_range(&state); 180 } 181 extern(C) sg.BufferDesc sshape_vertex_buffer_desc(const State* state) @system @nogc nothrow pure; 182 sg.BufferDesc vertexBufferDesc(scope ref State state) @trusted @nogc nothrow pure { 183 return sshape_vertex_buffer_desc(&state); 184 } 185 extern(C) sg.BufferDesc sshape_index_buffer_desc(const State* state) @system @nogc nothrow pure; 186 sg.BufferDesc indexBufferDesc(scope ref State state) @trusted @nogc nothrow pure { 187 return sshape_index_buffer_desc(&state); 188 } 189 extern(C) sg.VertexBufferLayoutState sshape_vertex_buffer_layout_state(const State* state) @system @nogc nothrow pure; 190 sg.VertexBufferLayoutState vertexBufferLayoutState(scope ref State state) @trusted @nogc nothrow pure { 191 return sshape_vertex_buffer_layout_state(&state); 192 } 193 extern(C) sg.VertexAttrState sshape_position_vertex_attr_state(const State* state) @system @nogc nothrow pure; 194 sg.VertexAttrState positionVertexAttrState(scope ref State state) @trusted @nogc nothrow pure { 195 return sshape_position_vertex_attr_state(&state); 196 } 197 extern(C) sg.VertexAttrState sshape_normal_vertex_attr_state(const State* state) @system @nogc nothrow pure; 198 sg.VertexAttrState normalVertexAttrState(scope ref State state) @trusted @nogc nothrow pure { 199 return sshape_normal_vertex_attr_state(&state); 200 } 201 extern(C) sg.VertexAttrState sshape_texcoord_vertex_attr_state(const State* state) @system @nogc nothrow pure; 202 sg.VertexAttrState texcoordVertexAttrState(scope ref State state) @trusted @nogc nothrow pure { 203 return sshape_texcoord_vertex_attr_state(&state); 204 } 205 extern(C) sg.VertexAttrState sshape_color_vertex_attr_state(const State* state) @system @nogc nothrow pure; 206 sg.VertexAttrState colorVertexAttrState(scope ref State state) @trusted @nogc nothrow pure { 207 return sshape_color_vertex_attr_state(&state); 208 } 209 /++ 210 + helper functions to build packed color value from floats or bytes 211 +/ 212 extern(C) uint sshape_color_4f(float r, float g, float b, float a) @system @nogc nothrow pure; 213 uint color4f(float r, float g, float b, float a) @trusted @nogc nothrow pure { 214 return sshape_color_4f(r, g, b, a); 215 } 216 extern(C) uint sshape_color_3f(float r, float g, float b) @system @nogc nothrow pure; 217 uint color3f(float r, float g, float b) @trusted @nogc nothrow pure { 218 return sshape_color_3f(r, g, b); 219 } 220 extern(C) uint sshape_color_4b(ubyte r, ubyte g, ubyte b, ubyte a) @system @nogc nothrow pure; 221 uint color4b(ubyte r, ubyte g, ubyte b, ubyte a) @trusted @nogc nothrow pure { 222 return sshape_color_4b(r, g, b, a); 223 } 224 extern(C) uint sshape_color_3b(ubyte r, ubyte g, ubyte b) @system @nogc nothrow pure; 225 uint color3b(ubyte r, ubyte g, ubyte b) @trusted @nogc nothrow pure { 226 return sshape_color_3b(r, g, b); 227 } 228 /++ 229 + adapter function for filling matrix struct from generic float[16] array 230 +/ 231 extern(C) Mat4 sshape_mat4(const float* m) @system @nogc nothrow pure; 232 Mat4 mat4(const float* m) @trusted @nogc nothrow pure { 233 return sshape_mat4(m); 234 } 235 extern(C) Mat4 sshape_mat4_transpose(const float* m) @system @nogc nothrow pure; 236 Mat4 mat4Transpose(const float* m) @trusted @nogc nothrow pure { 237 return sshape_mat4_transpose(m); 238 }