1 // machine generated, do not edit 2 3 module sokol.gl; 4 import sg = sokol.gfx; 5 6 enum LogItem { 7 Ok, 8 Malloc_failed, 9 Make_pipeline_failed, 10 Pipeline_pool_exhausted, 11 Add_commit_listener_failed, 12 Context_pool_exhausted, 13 Cannot_destroy_default_context, 14 } 15 /// sgl_logger_t 16 /// 17 /// Used in sgl_desc_t to provide a custom logging and error reporting 18 /// callback to sokol-gl 19 extern(C) 20 struct Logger { 21 extern(C) void function(const(char)*, uint, uint, const(char)*, uint, const(char)*, void*) func = null; 22 void* user_data = null; 23 } 24 /// sokol_gl pipeline handle (created with sgl_make_pipeline()) 25 extern(C) 26 struct Pipeline { 27 uint id = 0; 28 } 29 /// a context handle (created with sgl_make_context()) 30 extern(C) 31 struct Context { 32 uint id = 0; 33 } 34 /// sgl_error_t 35 /// 36 /// Errors are reset each frame after calling sgl_draw(), 37 /// get the last error code with sgl_error( 38 extern(C) 39 struct Error { 40 bool any = false; 41 bool vertices_full = false; 42 bool uniforms_full = false; 43 bool commands_full = false; 44 bool stack_overflow = false; 45 bool stack_underflow = false; 46 bool no_context = false; 47 } 48 /// sgl_context_desc_t 49 /// 50 /// Describes the initialization parameters of a rendering context. 51 /// Creating additional contexts is useful if you want to render 52 /// in separate sokol-gfx passes 53 extern(C) 54 struct ContextDesc { 55 int max_vertices = 0; 56 int max_commands = 0; 57 sg.PixelFormat color_format; 58 sg.PixelFormat depth_format; 59 int sample_count = 0; 60 } 61 /// sgl_allocator_t 62 /// 63 /// Used in sgl_desc_t to provide custom memory-alloc and -free functions 64 /// to sokol_gl.h. If memory management should be overridden, both the 65 /// alloc and free function must be provided (e.g. it's not valid to 66 /// override one function but not the other) 67 extern(C) 68 struct Allocator { 69 extern(C) void* function(size_t, void*) alloc_fn = null; 70 extern(C) void function(void*, void*) free_fn = null; 71 void* user_data = null; 72 } 73 extern(C) 74 struct Desc { 75 int max_vertices = 0; 76 int max_commands = 0; 77 int context_pool_size = 0; 78 int pipeline_pool_size = 0; 79 sg.PixelFormat color_format; 80 sg.PixelFormat depth_format; 81 int sample_count = 0; 82 sg.FaceWinding face_winding; 83 Allocator allocator; 84 Logger logger; 85 } 86 /// setup/shutdown/misc 87 extern(C) void sgl_setup(const Desc *) @system @nogc nothrow; 88 /// setup/shutdown/misc 89 void setup(scope ref Desc desc) @trusted @nogc nothrow { 90 sgl_setup(&desc); 91 } 92 extern(C) void sgl_shutdown() @system @nogc nothrow; 93 void shutdown() @trusted @nogc nothrow { 94 sgl_shutdown(); 95 } 96 extern(C) float sgl_rad(float) @system @nogc nothrow; 97 float asRadians(float deg) @trusted @nogc nothrow { 98 return sgl_rad(deg); 99 } 100 extern(C) float sgl_deg(float) @system @nogc nothrow; 101 float asDegrees(float rad) @trusted @nogc nothrow { 102 return sgl_deg(rad); 103 } 104 extern(C) Error sgl_error() @system @nogc nothrow; 105 Error getError() @trusted @nogc nothrow { 106 return sgl_error(); 107 } 108 extern(C) Error sgl_context_error(Context) @system @nogc nothrow; 109 Error contextError(Context ctx) @trusted @nogc nothrow { 110 return sgl_context_error(ctx); 111 } 112 /// context functions 113 extern(C) Context sgl_make_context(const ContextDesc *) @system @nogc nothrow; 114 /// context functions 115 Context makeContext(scope ref ContextDesc desc) @trusted @nogc nothrow { 116 return sgl_make_context(&desc); 117 } 118 extern(C) void sgl_destroy_context(Context) @system @nogc nothrow; 119 void destroyContext(Context ctx) @trusted @nogc nothrow { 120 sgl_destroy_context(ctx); 121 } 122 extern(C) void sgl_set_context(Context) @system @nogc nothrow; 123 void setContext(Context ctx) @trusted @nogc nothrow { 124 sgl_set_context(ctx); 125 } 126 extern(C) Context sgl_get_context() @system @nogc nothrow; 127 Context getContext() @trusted @nogc nothrow { 128 return sgl_get_context(); 129 } 130 extern(C) Context sgl_default_context() @system @nogc nothrow; 131 Context defaultContext() @trusted @nogc nothrow { 132 return sgl_default_context(); 133 } 134 /// get information about recorded vertices and commands in current context 135 extern(C) int sgl_num_vertices() @system @nogc nothrow; 136 /// get information about recorded vertices and commands in current context 137 int numVertices() @trusted @nogc nothrow { 138 return sgl_num_vertices(); 139 } 140 extern(C) int sgl_num_commands() @system @nogc nothrow; 141 int numCommands() @trusted @nogc nothrow { 142 return sgl_num_commands(); 143 } 144 /// draw recorded commands (call inside a sokol-gfx render pass) 145 extern(C) void sgl_draw() @system @nogc nothrow; 146 /// draw recorded commands (call inside a sokol-gfx render pass) 147 void draw() @trusted @nogc nothrow { 148 sgl_draw(); 149 } 150 extern(C) void sgl_context_draw(Context) @system @nogc nothrow; 151 void contextDraw(Context ctx) @trusted @nogc nothrow { 152 sgl_context_draw(ctx); 153 } 154 extern(C) void sgl_draw_layer(int) @system @nogc nothrow; 155 void drawLayer(int layer_id) @trusted @nogc nothrow { 156 sgl_draw_layer(layer_id); 157 } 158 extern(C) void sgl_context_draw_layer(Context, int) @system @nogc nothrow; 159 void contextDrawLayer(Context ctx, int layer_id) @trusted @nogc nothrow { 160 sgl_context_draw_layer(ctx, layer_id); 161 } 162 /// create and destroy pipeline objects 163 extern(C) Pipeline sgl_make_pipeline(const sg.PipelineDesc *) @system @nogc nothrow; 164 /// create and destroy pipeline objects 165 Pipeline makePipeline(scope ref sg.PipelineDesc desc) @trusted @nogc nothrow { 166 return sgl_make_pipeline(&desc); 167 } 168 extern(C) Pipeline sgl_context_make_pipeline(Context, const sg.PipelineDesc *) @system @nogc nothrow; 169 Pipeline contextMakePipeline(Context ctx, scope ref sg.PipelineDesc desc) @trusted @nogc nothrow { 170 return sgl_context_make_pipeline(ctx, &desc); 171 } 172 extern(C) void sgl_destroy_pipeline(Pipeline) @system @nogc nothrow; 173 void destroyPipeline(Pipeline pip) @trusted @nogc nothrow { 174 sgl_destroy_pipeline(pip); 175 } 176 /// render state functions 177 extern(C) void sgl_defaults() @system @nogc nothrow; 178 /// render state functions 179 void defaults() @trusted @nogc nothrow { 180 sgl_defaults(); 181 } 182 extern(C) void sgl_viewport(int, int, int, int, bool) @system @nogc nothrow; 183 void viewport(int x, int y, int w, int h, bool origin_top_left) @trusted @nogc nothrow { 184 sgl_viewport(x, y, w, h, origin_top_left); 185 } 186 extern(C) void sgl_viewportf(float, float, float, float, bool) @system @nogc nothrow; 187 void viewportf(float x, float y, float w, float h, bool origin_top_left) @trusted @nogc nothrow { 188 sgl_viewportf(x, y, w, h, origin_top_left); 189 } 190 extern(C) void sgl_scissor_rect(int, int, int, int, bool) @system @nogc nothrow; 191 void scissorRect(int x, int y, int w, int h, bool origin_top_left) @trusted @nogc nothrow { 192 sgl_scissor_rect(x, y, w, h, origin_top_left); 193 } 194 extern(C) void sgl_scissor_rectf(float, float, float, float, bool) @system @nogc nothrow; 195 void scissorRectf(float x, float y, float w, float h, bool origin_top_left) @trusted @nogc nothrow { 196 sgl_scissor_rectf(x, y, w, h, origin_top_left); 197 } 198 extern(C) void sgl_enable_texture() @system @nogc nothrow; 199 void enableTexture() @trusted @nogc nothrow { 200 sgl_enable_texture(); 201 } 202 extern(C) void sgl_disable_texture() @system @nogc nothrow; 203 void disableTexture() @trusted @nogc nothrow { 204 sgl_disable_texture(); 205 } 206 extern(C) void sgl_texture(sg.Image, sg.Sampler) @system @nogc nothrow; 207 void texture(sg.Image img, sg.Sampler smp) @trusted @nogc nothrow { 208 sgl_texture(img, smp); 209 } 210 extern(C) void sgl_layer(int) @system @nogc nothrow; 211 void layer(int layer_id) @trusted @nogc nothrow { 212 sgl_layer(layer_id); 213 } 214 /// pipeline stack functions 215 extern(C) void sgl_load_default_pipeline() @system @nogc nothrow; 216 /// pipeline stack functions 217 void loadDefaultPipeline() @trusted @nogc nothrow { 218 sgl_load_default_pipeline(); 219 } 220 extern(C) void sgl_load_pipeline(Pipeline) @system @nogc nothrow; 221 void loadPipeline(Pipeline pip) @trusted @nogc nothrow { 222 sgl_load_pipeline(pip); 223 } 224 extern(C) void sgl_push_pipeline() @system @nogc nothrow; 225 void pushPipeline() @trusted @nogc nothrow { 226 sgl_push_pipeline(); 227 } 228 extern(C) void sgl_pop_pipeline() @system @nogc nothrow; 229 void popPipeline() @trusted @nogc nothrow { 230 sgl_pop_pipeline(); 231 } 232 /// matrix stack functions 233 extern(C) void sgl_matrix_mode_modelview() @system @nogc nothrow; 234 /// matrix stack functions 235 void matrixModeModelview() @trusted @nogc nothrow { 236 sgl_matrix_mode_modelview(); 237 } 238 extern(C) void sgl_matrix_mode_projection() @system @nogc nothrow; 239 void matrixModeProjection() @trusted @nogc nothrow { 240 sgl_matrix_mode_projection(); 241 } 242 extern(C) void sgl_matrix_mode_texture() @system @nogc nothrow; 243 void matrixModeTexture() @trusted @nogc nothrow { 244 sgl_matrix_mode_texture(); 245 } 246 extern(C) void sgl_load_identity() @system @nogc nothrow; 247 void loadIdentity() @trusted @nogc nothrow { 248 sgl_load_identity(); 249 } 250 extern(C) void sgl_load_matrix(const float *) @system @nogc nothrow; 251 void loadMatrix(scope const float * m) @trusted @nogc nothrow { 252 sgl_load_matrix(m); 253 } 254 extern(C) void sgl_load_transpose_matrix(const float *) @system @nogc nothrow; 255 void loadTransposeMatrix(scope const float * m) @trusted @nogc nothrow { 256 sgl_load_transpose_matrix(m); 257 } 258 extern(C) void sgl_mult_matrix(const float *) @system @nogc nothrow; 259 void multMatrix(scope const float * m) @trusted @nogc nothrow { 260 sgl_mult_matrix(m); 261 } 262 extern(C) void sgl_mult_transpose_matrix(const float *) @system @nogc nothrow; 263 void multTransposeMatrix(scope const float * m) @trusted @nogc nothrow { 264 sgl_mult_transpose_matrix(m); 265 } 266 extern(C) void sgl_rotate(float, float, float, float) @system @nogc nothrow; 267 void rotate(float angle_rad, float x, float y, float z) @trusted @nogc nothrow { 268 sgl_rotate(angle_rad, x, y, z); 269 } 270 extern(C) void sgl_scale(float, float, float) @system @nogc nothrow; 271 void scale(float x, float y, float z) @trusted @nogc nothrow { 272 sgl_scale(x, y, z); 273 } 274 extern(C) void sgl_translate(float, float, float) @system @nogc nothrow; 275 void translate(float x, float y, float z) @trusted @nogc nothrow { 276 sgl_translate(x, y, z); 277 } 278 extern(C) void sgl_frustum(float, float, float, float, float, float) @system @nogc nothrow; 279 void frustum(float l, float r, float b, float t, float n, float f) @trusted @nogc nothrow { 280 sgl_frustum(l, r, b, t, n, f); 281 } 282 extern(C) void sgl_ortho(float, float, float, float, float, float) @system @nogc nothrow; 283 void ortho(float l, float r, float b, float t, float n, float f) @trusted @nogc nothrow { 284 sgl_ortho(l, r, b, t, n, f); 285 } 286 extern(C) void sgl_perspective(float, float, float, float) @system @nogc nothrow; 287 void perspective(float fov_y, float aspect, float z_near, float z_far) @trusted @nogc nothrow { 288 sgl_perspective(fov_y, aspect, z_near, z_far); 289 } 290 extern(C) void sgl_lookat(float, float, float, float, float, float, float, float, float) @system @nogc nothrow; 291 void lookat(float eye_x, float eye_y, float eye_z, float center_x, float center_y, float center_z, float up_x, float up_y, float up_z) @trusted @nogc nothrow { 292 sgl_lookat(eye_x, eye_y, eye_z, center_x, center_y, center_z, up_x, up_y, up_z); 293 } 294 extern(C) void sgl_push_matrix() @system @nogc nothrow; 295 void pushMatrix() @trusted @nogc nothrow { 296 sgl_push_matrix(); 297 } 298 extern(C) void sgl_pop_matrix() @system @nogc nothrow; 299 void popMatrix() @trusted @nogc nothrow { 300 sgl_pop_matrix(); 301 } 302 /// these functions only set the internal 'current texcoord / color / point size' (valid inside or outside begin/end) 303 extern(C) void sgl_t2f(float, float) @system @nogc nothrow; 304 /// these functions only set the internal 'current texcoord / color / point size' (valid inside or outside begin/end) 305 void t2f(float u, float v) @trusted @nogc nothrow { 306 sgl_t2f(u, v); 307 } 308 extern(C) void sgl_c3f(float, float, float) @system @nogc nothrow; 309 void c3f(float r, float g, float b) @trusted @nogc nothrow { 310 sgl_c3f(r, g, b); 311 } 312 extern(C) void sgl_c4f(float, float, float, float) @system @nogc nothrow; 313 void c4f(float r, float g, float b, float a) @trusted @nogc nothrow { 314 sgl_c4f(r, g, b, a); 315 } 316 extern(C) void sgl_c3b(ubyte, ubyte, ubyte) @system @nogc nothrow; 317 void c3b(ubyte r, ubyte g, ubyte b) @trusted @nogc nothrow { 318 sgl_c3b(r, g, b); 319 } 320 extern(C) void sgl_c4b(ubyte, ubyte, ubyte, ubyte) @system @nogc nothrow; 321 void c4b(ubyte r, ubyte g, ubyte b, ubyte a) @trusted @nogc nothrow { 322 sgl_c4b(r, g, b, a); 323 } 324 extern(C) void sgl_c1i(uint) @system @nogc nothrow; 325 void c1i(uint rgba) @trusted @nogc nothrow { 326 sgl_c1i(rgba); 327 } 328 extern(C) void sgl_point_size(float) @system @nogc nothrow; 329 void pointSize(float s) @trusted @nogc nothrow { 330 sgl_point_size(s); 331 } 332 /// define primitives, each begin/end is one draw command 333 extern(C) void sgl_begin_points() @system @nogc nothrow; 334 /// define primitives, each begin/end is one draw command 335 void beginPoints() @trusted @nogc nothrow { 336 sgl_begin_points(); 337 } 338 extern(C) void sgl_begin_lines() @system @nogc nothrow; 339 void beginLines() @trusted @nogc nothrow { 340 sgl_begin_lines(); 341 } 342 extern(C) void sgl_begin_line_strip() @system @nogc nothrow; 343 void beginLineStrip() @trusted @nogc nothrow { 344 sgl_begin_line_strip(); 345 } 346 extern(C) void sgl_begin_triangles() @system @nogc nothrow; 347 void beginTriangles() @trusted @nogc nothrow { 348 sgl_begin_triangles(); 349 } 350 extern(C) void sgl_begin_triangle_strip() @system @nogc nothrow; 351 void beginTriangleStrip() @trusted @nogc nothrow { 352 sgl_begin_triangle_strip(); 353 } 354 extern(C) void sgl_begin_quads() @system @nogc nothrow; 355 void beginQuads() @trusted @nogc nothrow { 356 sgl_begin_quads(); 357 } 358 extern(C) void sgl_v2f(float, float) @system @nogc nothrow; 359 void v2f(float x, float y) @trusted @nogc nothrow { 360 sgl_v2f(x, y); 361 } 362 extern(C) void sgl_v3f(float, float, float) @system @nogc nothrow; 363 void v3f(float x, float y, float z) @trusted @nogc nothrow { 364 sgl_v3f(x, y, z); 365 } 366 extern(C) void sgl_v2f_t2f(float, float, float, float) @system @nogc nothrow; 367 void v2fT2f(float x, float y, float u, float v) @trusted @nogc nothrow { 368 sgl_v2f_t2f(x, y, u, v); 369 } 370 extern(C) void sgl_v3f_t2f(float, float, float, float, float) @system @nogc nothrow; 371 void v3fT2f(float x, float y, float z, float u, float v) @trusted @nogc nothrow { 372 sgl_v3f_t2f(x, y, z, u, v); 373 } 374 extern(C) void sgl_v2f_c3f(float, float, float, float, float) @system @nogc nothrow; 375 void v2fC3f(float x, float y, float r, float g, float b) @trusted @nogc nothrow { 376 sgl_v2f_c3f(x, y, r, g, b); 377 } 378 extern(C) void sgl_v2f_c3b(float, float, ubyte, ubyte, ubyte) @system @nogc nothrow; 379 void v2fC3b(float x, float y, ubyte r, ubyte g, ubyte b) @trusted @nogc nothrow { 380 sgl_v2f_c3b(x, y, r, g, b); 381 } 382 extern(C) void sgl_v2f_c4f(float, float, float, float, float, float) @system @nogc nothrow; 383 void v2fC4f(float x, float y, float r, float g, float b, float a) @trusted @nogc nothrow { 384 sgl_v2f_c4f(x, y, r, g, b, a); 385 } 386 extern(C) void sgl_v2f_c4b(float, float, ubyte, ubyte, ubyte, ubyte) @system @nogc nothrow; 387 void v2fC4b(float x, float y, ubyte r, ubyte g, ubyte b, ubyte a) @trusted @nogc nothrow { 388 sgl_v2f_c4b(x, y, r, g, b, a); 389 } 390 extern(C) void sgl_v2f_c1i(float, float, uint) @system @nogc nothrow; 391 void v2fC1i(float x, float y, uint rgba) @trusted @nogc nothrow { 392 sgl_v2f_c1i(x, y, rgba); 393 } 394 extern(C) void sgl_v3f_c3f(float, float, float, float, float, float) @system @nogc nothrow; 395 void v3fC3f(float x, float y, float z, float r, float g, float b) @trusted @nogc nothrow { 396 sgl_v3f_c3f(x, y, z, r, g, b); 397 } 398 extern(C) void sgl_v3f_c3b(float, float, float, ubyte, ubyte, ubyte) @system @nogc nothrow; 399 void v3fC3b(float x, float y, float z, ubyte r, ubyte g, ubyte b) @trusted @nogc nothrow { 400 sgl_v3f_c3b(x, y, z, r, g, b); 401 } 402 extern(C) void sgl_v3f_c4f(float, float, float, float, float, float, float) @system @nogc nothrow; 403 void v3fC4f(float x, float y, float z, float r, float g, float b, float a) @trusted @nogc nothrow { 404 sgl_v3f_c4f(x, y, z, r, g, b, a); 405 } 406 extern(C) void sgl_v3f_c4b(float, float, float, ubyte, ubyte, ubyte, ubyte) @system @nogc nothrow; 407 void v3fC4b(float x, float y, float z, ubyte r, ubyte g, ubyte b, ubyte a) @trusted @nogc nothrow { 408 sgl_v3f_c4b(x, y, z, r, g, b, a); 409 } 410 extern(C) void sgl_v3f_c1i(float, float, float, uint) @system @nogc nothrow; 411 void v3fC1i(float x, float y, float z, uint rgba) @trusted @nogc nothrow { 412 sgl_v3f_c1i(x, y, z, rgba); 413 } 414 extern(C) void sgl_v2f_t2f_c3f(float, float, float, float, float, float, float) @system @nogc nothrow; 415 void v2fT2fC3f(float x, float y, float u, float v, float r, float g, float b) @trusted @nogc nothrow { 416 sgl_v2f_t2f_c3f(x, y, u, v, r, g, b); 417 } 418 extern(C) void sgl_v2f_t2f_c3b(float, float, float, float, ubyte, ubyte, ubyte) @system @nogc nothrow; 419 void v2fT2fC3b(float x, float y, float u, float v, ubyte r, ubyte g, ubyte b) @trusted @nogc nothrow { 420 sgl_v2f_t2f_c3b(x, y, u, v, r, g, b); 421 } 422 extern(C) void sgl_v2f_t2f_c4f(float, float, float, float, float, float, float, float) @system @nogc nothrow; 423 void v2fT2fC4f(float x, float y, float u, float v, float r, float g, float b, float a) @trusted @nogc nothrow { 424 sgl_v2f_t2f_c4f(x, y, u, v, r, g, b, a); 425 } 426 extern(C) void sgl_v2f_t2f_c4b(float, float, float, float, ubyte, ubyte, ubyte, ubyte) @system @nogc nothrow; 427 void v2fT2fC4b(float x, float y, float u, float v, ubyte r, ubyte g, ubyte b, ubyte a) @trusted @nogc nothrow { 428 sgl_v2f_t2f_c4b(x, y, u, v, r, g, b, a); 429 } 430 extern(C) void sgl_v2f_t2f_c1i(float, float, float, float, uint) @system @nogc nothrow; 431 void v2fT2fC1i(float x, float y, float u, float v, uint rgba) @trusted @nogc nothrow { 432 sgl_v2f_t2f_c1i(x, y, u, v, rgba); 433 } 434 extern(C) void sgl_v3f_t2f_c3f(float, float, float, float, float, float, float, float) @system @nogc nothrow; 435 void v3fT2fC3f(float x, float y, float z, float u, float v, float r, float g, float b) @trusted @nogc nothrow { 436 sgl_v3f_t2f_c3f(x, y, z, u, v, r, g, b); 437 } 438 extern(C) void sgl_v3f_t2f_c3b(float, float, float, float, float, ubyte, ubyte, ubyte) @system @nogc nothrow; 439 void v3fT2fC3b(float x, float y, float z, float u, float v, ubyte r, ubyte g, ubyte b) @trusted @nogc nothrow { 440 sgl_v3f_t2f_c3b(x, y, z, u, v, r, g, b); 441 } 442 extern(C) void sgl_v3f_t2f_c4f(float, float, float, float, float, float, float, float, float) @system @nogc nothrow; 443 void v3fT2fC4f(float x, float y, float z, float u, float v, float r, float g, float b, float a) @trusted @nogc nothrow { 444 sgl_v3f_t2f_c4f(x, y, z, u, v, r, g, b, a); 445 } 446 extern(C) void sgl_v3f_t2f_c4b(float, float, float, float, float, ubyte, ubyte, ubyte, ubyte) @system @nogc nothrow; 447 void v3fT2fC4b(float x, float y, float z, float u, float v, ubyte r, ubyte g, ubyte b, ubyte a) @trusted @nogc nothrow { 448 sgl_v3f_t2f_c4b(x, y, z, u, v, r, g, b, a); 449 } 450 extern(C) void sgl_v3f_t2f_c1i(float, float, float, float, float, uint) @system @nogc nothrow; 451 void v3fT2fC1i(float x, float y, float z, float u, float v, uint rgba) @trusted @nogc nothrow { 452 sgl_v3f_t2f_c1i(x, y, z, u, v, rgba); 453 } 454 extern(C) void sgl_end() @system @nogc nothrow; 455 void end() @trusted @nogc nothrow { 456 sgl_end(); 457 }