1 /* 2 * Copyright 2011-2019 Branimir Karadzic. All rights reserved. 3 * License: https://github.com/bkaradzic/bgfx/blob/master/LICENSE 4 */ 5 6 #ifndef BGFX_H_HEADER_GUARD 7 #define BGFX_H_HEADER_GUARD 8 9 #include <stdarg.h> // va_list 10 #include <stdint.h> // uint32_t 11 #include <stdlib.h> // NULL 12 13 #include "defines.h" 14 15 /// 16 #define BGFX_HANDLE(_name) \ 17 struct _name { uint16_t idx; }; \ 18 inline bool isValid(_name _handle) { return bgfx::kInvalidHandle != _handle.idx; } 19 20 #define BGFX_INVALID_HANDLE { bgfx::kInvalidHandle } 21 22 namespace bx { struct AllocatorI; } 23 24 /// BGFX 25 namespace bgfx 26 { 27 /// Fatal error enum. 28 /// 29 /// @attention C99 equivalent is `bgfx_fatal_t`. 30 /// 31 struct Fatal 32 { 33 enum Enum 34 { 35 DebugCheck, 36 InvalidShader, 37 UnableToInitialize, 38 UnableToCreateTexture, 39 DeviceLost, 40 41 Count 42 }; 43 }; 44 45 /// Renderer backend type enum. 46 /// 47 /// @attention C99 equivalent is `bgfx_renderer_type_t`. 48 /// 49 struct RendererType 50 { 51 /// Renderer types: 52 enum Enum 53 { 54 Noop, //!< No rendering. 55 Direct3D9, //!< Direct3D 9.0 56 Direct3D11, //!< Direct3D 11.0 57 Direct3D12, //!< Direct3D 12.0 58 Gnm, //!< GNM 59 Metal, //!< Metal 60 Nvn, //!< NVN 61 OpenGLES, //!< OpenGL ES 2.0+ 62 OpenGL, //!< OpenGL 2.1+ 63 Vulkan, //!< Vulkan 64 65 Count 66 }; 67 }; 68 69 /// Access mode enum. 70 /// 71 /// @attention C99 equivalent is `bgfx_access_t`. 72 /// 73 struct Access 74 { 75 /// Access: 76 enum Enum 77 { 78 Read, //!< Read 79 Write, //!< Write 80 ReadWrite, //!< Read and write 81 82 Count 83 }; 84 }; 85 86 /// Vertex attribute enum. 87 /// 88 /// @attention C99 equivalent is `bgfx_attrib_t`. 89 /// 90 struct Attrib 91 { 92 /// Corresponds to vertex shader attribute. 93 enum Enum 94 { 95 Position, //!< a_position 96 Normal, //!< a_normal 97 Tangent, //!< a_tangent 98 Bitangent, //!< a_bitangent 99 Color0, //!< a_color0 100 Color1, //!< a_color1 101 Color2, //!< a_color2 102 Color3, //!< a_color3 103 Indices, //!< a_indices 104 Weight, //!< a_weight 105 TexCoord0, //!< a_texcoord0 106 TexCoord1, //!< a_texcoord1 107 TexCoord2, //!< a_texcoord2 108 TexCoord3, //!< a_texcoord3 109 TexCoord4, //!< a_texcoord4 110 TexCoord5, //!< a_texcoord5 111 TexCoord6, //!< a_texcoord6 112 TexCoord7, //!< a_texcoord7 113 114 Count 115 }; 116 }; 117 118 /// Vertex attribute type enum. 119 /// 120 /// @attention C99 equivalent is `bgfx_attrib_type_t`. 121 /// 122 struct AttribType 123 { 124 /// Attribute types: 125 enum Enum 126 { 127 Uint8, //!< Uint8 128 Uint10, //!< Uint10, availability depends on: `BGFX_CAPS_VERTEX_ATTRIB_UINT10`. 129 Int16, //!< Int16 130 Half, //!< Half, availability depends on: `BGFX_CAPS_VERTEX_ATTRIB_HALF`. 131 Float, //!< Float 132 133 Count 134 }; 135 }; 136 137 /// Texture format enum. 138 /// 139 /// Notation: 140 /// 141 /// RGBA16S 142 /// ^ ^ ^ 143 /// | | +-- [ ]Unorm 144 /// | | [F]loat 145 /// | | [S]norm 146 /// | | [I]nt 147 /// | | [U]int 148 /// | +---- Number of bits per component 149 /// +-------- Components 150 /// 151 /// @attention Availability depends on Caps (see: formats). 152 /// 153 /// @attention C99 equivalent is `bgfx_texture_format_t`. 154 /// 155 struct TextureFormat 156 { 157 /// Texture formats: 158 enum Enum 159 { 160 BC1, //!< DXT1 R5G6B5A1 161 BC2, //!< DXT3 R5G6B5A4 162 BC3, //!< DXT5 R5G6B5A8 163 BC4, //!< LATC1/ATI1 R8 164 BC5, //!< LATC2/ATI2 RG8 165 BC6H, //!< BC6H RGB16F 166 BC7, //!< BC7 RGB 4-7 bits per color channel, 0-8 bits alpha 167 ETC1, //!< ETC1 RGB8 168 ETC2, //!< ETC2 RGB8 169 ETC2A, //!< ETC2 RGBA8 170 ETC2A1, //!< ETC2 RGB8A1 171 PTC12, //!< PVRTC1 RGB 2BPP 172 PTC14, //!< PVRTC1 RGB 4BPP 173 PTC12A, //!< PVRTC1 RGBA 2BPP 174 PTC14A, //!< PVRTC1 RGBA 4BPP 175 PTC22, //!< PVRTC2 RGBA 2BPP 176 PTC24, //!< PVRTC2 RGBA 4BPP 177 ATC, //!< ATC RGB 4BPP 178 ATCE, //!< ATCE RGBA 8 BPP explicit alpha 179 ATCI, //!< ATCI RGBA 8 BPP interpolated alpha 180 ASTC4x4, //!< ASTC 4x4 8.0 BPP 181 ASTC5x5, //!< ASTC 5x5 5.12 BPP 182 ASTC6x6, //!< ASTC 6x6 3.56 BPP 183 ASTC8x5, //!< ASTC 8x5 3.20 BPP 184 ASTC8x6, //!< ASTC 8x6 2.67 BPP 185 ASTC10x5, //!< ASTC 10x5 2.56 BPP 186 187 Unknown, // Compressed formats above. 188 189 R1, 190 A8, 191 R8, 192 R8I, 193 R8U, 194 R8S, 195 R16, 196 R16I, 197 R16U, 198 R16F, 199 R16S, 200 R32I, 201 R32U, 202 R32F, 203 RG8, 204 RG8I, 205 RG8U, 206 RG8S, 207 RG16, 208 RG16I, 209 RG16U, 210 RG16F, 211 RG16S, 212 RG32I, 213 RG32U, 214 RG32F, 215 RGB8, 216 RGB8I, 217 RGB8U, 218 RGB8S, 219 RGB9E5F, 220 BGRA8, 221 RGBA8, 222 RGBA8I, 223 RGBA8U, 224 RGBA8S, 225 RGBA16, 226 RGBA16I, 227 RGBA16U, 228 RGBA16F, 229 RGBA16S, 230 RGBA32I, 231 RGBA32U, 232 RGBA32F, 233 R5G6B5, 234 RGBA4, 235 RGB5A1, 236 RGB10A2, 237 RG11B10F, 238 239 UnknownDepth, // Depth formats below. 240 241 D16, 242 D24, 243 D24S8, 244 D32, 245 D16F, 246 D24F, 247 D32F, 248 D0S8, 249 250 Count 251 }; 252 }; 253 254 /// Uniform type enum. 255 /// 256 /// @attention C99 equivalent is `bgfx_uniform_type_t`. 257 /// 258 struct UniformType 259 { 260 /// Uniform types: 261 enum Enum 262 { 263 Sampler, //!< Sampler. 264 End, //!< Reserved, do not use. 265 266 Vec4, //!< 4 floats vector. 267 Mat3, //!< 3x3 matrix. 268 Mat4, //!< 4x4 matrix. 269 270 Count 271 }; 272 }; 273 274 /// Backbuffer ratio enum. 275 /// 276 /// @attention C99 equivalent is `bgfx_backbuffer_ratio_t`. 277 /// 278 struct BackbufferRatio 279 { 280 /// Backbuffer ratios: 281 enum Enum 282 { 283 Equal, //!< Equal to backbuffer. 284 Half, //!< One half size of backbuffer. 285 Quarter, //!< One quarter size of backbuffer. 286 Eighth, //!< One eighth size of backbuffer. 287 Sixteenth, //!< One sixteenth size of backbuffer. 288 Double, //!< Double size of backbuffer. 289 290 Count 291 }; 292 }; 293 294 /// Occlusion query result. 295 /// 296 /// @attention C99 equivalent is `bgfx_occlusion_query_result_t`. 297 /// 298 struct OcclusionQueryResult 299 { 300 /// Occlusion query results: 301 enum Enum 302 { 303 Invisible, //!< Query failed test. 304 Visible, //!< Query passed test. 305 NoResult, //!< Query result is not available yet. 306 307 Count 308 }; 309 }; 310 311 /// Primitive topology. 312 /// 313 /// @attention C99 equivalent is `bgfx_topology_t`. 314 /// 315 struct Topology 316 { 317 /// Primitive topology: 318 enum Enum 319 { 320 TriList, //!< Triangle list. 321 TriStrip, //!< Triangle strip. 322 LineList, //!< Line list. 323 LineStrip, //!< Line strip. 324 PointList, //!< Point list. 325 326 Count 327 }; 328 }; 329 330 /// Topology conversion function. 331 /// 332 /// @attention C99 equivalent is `bgfx_topology_convert_t`. 333 /// 334 struct TopologyConvert 335 { 336 /// Topology conversion functions: 337 enum Enum 338 { 339 TriListFlipWinding, //!< Flip winding order of triangle list. 340 TriStripFlipWinding, //!< Flip winding order of trinagle strip. 341 TriListToLineList, //!< Convert triangle list to line list. 342 TriStripToTriList, //!< Convert triangle strip to triangle list. 343 LineStripToLineList, //!< Convert line strip to line list. 344 345 Count 346 }; 347 }; 348 349 /// Topology sort order. 350 /// 351 /// @attention C99 equivalent is `bgfx_topology_sort_t`. 352 /// 353 struct TopologySort 354 { 355 /// Topology sort order: 356 enum Enum 357 { 358 DirectionFrontToBackMin, //!< 359 DirectionFrontToBackAvg, //!< 360 DirectionFrontToBackMax, //!< 361 DirectionBackToFrontMin, //!< 362 DirectionBackToFrontAvg, //!< 363 DirectionBackToFrontMax, //!< 364 DistanceFrontToBackMin, //!< 365 DistanceFrontToBackAvg, //!< 366 DistanceFrontToBackMax, //!< 367 DistanceBackToFrontMin, //!< 368 DistanceBackToFrontAvg, //!< 369 DistanceBackToFrontMax, //!< 370 371 Count 372 }; 373 }; 374 375 /// View mode sets draw call sort order. 376 /// 377 /// @attention C99 equivalent is `bgfx_view_mode_t`. 378 /// 379 struct ViewMode 380 { 381 /// View modes: 382 enum Enum 383 { 384 Default, //!< Default sort order. 385 Sequential, //!< Sort in the same order in which submit calls were called. 386 DepthAscending, //!< Sort draw call depth in ascending order. 387 DepthDescending, //!< Sort draw call depth in descending order. 388 389 Count 390 }; 391 }; 392 393 static const uint16_t kInvalidHandle = UINT16_MAX; 394 395 BGFX_HANDLE(DynamicIndexBufferHandle) 396 BGFX_HANDLE(DynamicVertexBufferHandle) 397 BGFX_HANDLE(FrameBufferHandle) 398 BGFX_HANDLE(IndexBufferHandle) 399 BGFX_HANDLE(IndirectBufferHandle) 400 BGFX_HANDLE(OcclusionQueryHandle) 401 BGFX_HANDLE(ProgramHandle) 402 BGFX_HANDLE(ShaderHandle) 403 BGFX_HANDLE(TextureHandle) 404 BGFX_HANDLE(UniformHandle) 405 BGFX_HANDLE(VertexBufferHandle) 406 BGFX_HANDLE(VertexLayoutHandle) 407 408 /// Callback interface to implement application specific behavior. 409 /// Cached items are currently used for OpenGL and Direct3D 12 binary 410 /// shaders. 411 /// 412 /// @remarks 413 /// 'fatal' and 'trace' callbacks can be called from any thread. Other 414 /// callbacks are called from the render thread. 415 /// 416 /// @attention C99 equivalent is `bgfx_callback_interface_t`. 417 /// 418 struct CallbackI 419 { 420 virtual ~CallbackI() = 0; 421 422 /// This callback is called on unrecoverable errors. 423 /// It's not safe to continue (Exluding _code `Fatal::DebugCheck`), 424 /// inform the user and terminate the application. 425 /// 426 /// @param[in] _filePath File path where fatal message was generated. 427 /// @param[in] _line Line where fatal message was generated. 428 /// @param[in] _code Fatal error code. 429 /// @param[in] _str More information about error. 430 /// 431 /// @remarks 432 /// Not thread safe and it can be called from any thread. 433 /// 434 /// @attention C99 equivalent is `bgfx_callback_vtbl.fatal`. 435 /// 436 virtual void fatal( 437 const char* _filePath 438 , uint16_t _line 439 , Fatal::Enum _code 440 , const char* _str 441 ) = 0; 442 443 /// Print debug message. 444 /// 445 /// @param[in] _filePath File path where debug message was generated. 446 /// @param[in] _line Line where debug message was generated. 447 /// @param[in] _format `printf` style format. 448 /// @param[in] _argList Variable arguments list initialized with 449 /// `va_start`. 450 /// 451 /// @remarks 452 /// Not thread safe and it can be called from any thread. 453 /// 454 /// @attention C99 equivalent is `bgfx_callback_vtbl.trace_vargs`. 455 /// 456 virtual void traceVargs( 457 const char* _filePath 458 , uint16_t _line 459 , const char* _format 460 , va_list _argList 461 ) = 0; 462 463 /// Profiler region begin. 464 /// 465 /// @param[in] _name Region name, contains dynamic string. 466 /// @param[in] _abgr Color of profiler region. 467 /// @param[in] _filePath File path where `profilerBegin` was called. 468 /// @param[in] _line Line where `profilerBegin` was called. 469 /// 470 /// @remarks 471 /// Not thread safe and it can be called from any thread. 472 /// 473 /// @attention C99 equivalent is `bgfx_callback_vtbl.profiler_begin`. 474 /// 475 virtual void profilerBegin( 476 const char* _name 477 , uint32_t _abgr 478 , const char* _filePath 479 , uint16_t _line 480 ) = 0; 481 482 /// Profiler region begin with string literal name. 483 /// 484 /// @param[in] _name Region name, contains string literal. 485 /// @param[in] _abgr Color of profiler region. 486 /// @param[in] _filePath File path where `profilerBeginLiteral` was called. 487 /// @param[in] _line Line where `profilerBeginLiteral` was called. 488 /// 489 /// @remarks 490 /// Not thread safe and it can be called from any thread. 491 /// 492 /// @attention C99 equivalent is `bgfx_callback_vtbl.profiler_begin_literal`. 493 /// 494 virtual void profilerBeginLiteral( 495 const char* _name 496 , uint32_t _abgr 497 , const char* _filePath 498 , uint16_t _line 499 ) = 0; 500 501 /// Profiler region end. 502 /// 503 /// @remarks 504 /// Not thread safe and it can be called from any thread. 505 /// 506 /// @attention C99 equivalent is `bgfx_callback_vtbl.profiler_end`. 507 /// 508 virtual void profilerEnd() = 0; 509 510 /// Returns the size of a cached item. Returns 0 if no cached item was 511 /// found. 512 /// 513 /// @param[in] _id Cache id. 514 /// @returns Number of bytes to read. 515 /// 516 /// @attention C99 equivalent is `bgfx_callback_vtbl.cache_read_size`. 517 /// 518 virtual uint32_t cacheReadSize(uint64_t _id) = 0; 519 520 /// Read cached item. 521 /// 522 /// @param[in] _id Cache id. 523 /// @param[in] _data Buffer where to read data. 524 /// @param[in] _size Size of data to read. 525 /// 526 /// @returns True if data is read. 527 /// 528 /// @attention C99 equivalent is `bgfx_callback_vtbl.cache_read`. 529 /// 530 virtual bool cacheRead(uint64_t _id, void* _data, uint32_t _size) = 0; 531 532 /// Write cached item. 533 /// 534 /// @param[in] _id Cache id. 535 /// @param[in] _data Data to write. 536 /// @param[in] _size Size of data to write. 537 /// 538 /// @attention C99 equivalent is `bgfx_callback_vtbl.cache_write`. 539 /// 540 virtual void cacheWrite(uint64_t _id, const void* _data, uint32_t _size) = 0; 541 542 /// Screenshot captured. Screenshot format is always 4-byte BGRA. 543 /// 544 /// @param[in] _filePath File path. 545 /// @param[in] _width Image width. 546 /// @param[in] _height Image height. 547 /// @param[in] _pitch Number of bytes to skip between the start of 548 /// each horizontal line of the image. 549 /// @param[in] _data Image data. 550 /// @param[in] _size Image size. 551 /// @param[in] _yflip If true, image origin is bottom left. 552 /// 553 /// @attention C99 equivalent is `bgfx_callback_vtbl.screen_shot`. 554 /// 555 virtual void screenShot( 556 const char* _filePath 557 , uint32_t _width 558 , uint32_t _height 559 , uint32_t _pitch 560 , const void* _data 561 , uint32_t _size 562 , bool _yflip 563 ) = 0; 564 565 /// Called when a video capture begins. 566 /// 567 /// @param[in] _width Image width. 568 /// @param[in] _height Image height. 569 /// @param[in] _pitch Number of bytes to skip between the start of 570 /// each horizontal line of the image. 571 /// @param[in] _format Texture format. See: `TextureFormat::Enum`. 572 /// @param[in] _yflip If true, image origin is bottom left. 573 /// 574 /// @attention C99 equivalent is `bgfx_callback_vtbl.capture_begin`. 575 /// 576 virtual void captureBegin( 577 uint32_t _width 578 , uint32_t _height 579 , uint32_t _pitch 580 , TextureFormat::Enum _format 581 , bool _yflip 582 ) = 0; 583 584 /// Called when a video capture ends. 585 /// 586 /// @attention C99 equivalent is `bgfx_callback_vtbl.capture_end`. 587 /// 588 virtual void captureEnd() = 0; 589 590 /// Captured frame. 591 /// 592 /// @param[in] _data Image data. 593 /// @param[in] _size Image size. 594 /// 595 /// @attention C99 equivalent is `bgfx_callback_vtbl.capture_frame`. 596 /// 597 virtual void captureFrame(const void* _data, uint32_t _size) = 0; 598 }; 599 ~CallbackI()600 inline CallbackI::~CallbackI() 601 { 602 } 603 604 /// Platform data. 605 /// 606 /// @attention C99 equivalent is `bgfx_platform_data_t`. 607 /// 608 struct PlatformData 609 { 610 PlatformData(); 611 612 void* ndt; //!< Native display type. 613 void* nwh; //!< Native window handle. 614 void* context; //!< GL context, or D3D device. 615 void* backBuffer; //!< GL backbuffer, or D3D render target view. 616 void* backBufferDS; //!< Backbuffer depth/stencil. 617 }; 618 619 /// Backbuffer resolution and reset parameters. 620 /// 621 /// @attention C99 equivalent is `bgfx_resolution_t`. 622 /// 623 struct Resolution 624 { 625 Resolution(); 626 627 TextureFormat::Enum format; //!< Backbuffer format. 628 uint32_t width; //!< Backbuffer width. 629 uint32_t height; //!< Backbuffer height. 630 uint32_t reset; //!< Reset parameters. 631 uint8_t numBackBuffers; //!< Number of back buffers. 632 uint8_t maxFrameLatency; //!< Maximum frame latency. 633 }; 634 635 /// Initialization parameters used by `bgfx::init`. 636 /// 637 /// @attention C99 equivalent is `bgfx_init_t`. 638 /// 639 struct Init 640 { 641 Init(); 642 643 /// Select rendering backend. When set to RendererType::Count 644 /// a default rendering backend will be selected appropriate to the platform. 645 /// See: `bgfx::RendererType` 646 RendererType::Enum type; 647 648 /// Vendor PCI id. If set to `BGFX_PCI_ID_NONE` it will select the first 649 /// device. 650 /// - `BGFX_PCI_ID_NONE` - Autoselect adapter. 651 /// - `BGFX_PCI_ID_SOFTWARE_RASTERIZER` - Software rasterizer. 652 /// - `BGFX_PCI_ID_AMD` - AMD adapter. 653 /// - `BGFX_PCI_ID_INTEL` - Intel adapter. 654 /// - `BGFX_PCI_ID_NVIDIA` - nVidia adapter. 655 uint16_t vendorId; 656 657 /// Device id. If set to 0 it will select first device, or device with 658 /// matching id. 659 uint16_t deviceId; 660 661 bool debug; //!< Enable device for debuging. 662 bool profile; //!< Enable device for profiling. 663 664 /// Platform data. 665 PlatformData platformData; 666 667 /// Backbuffer resolution and reset parameters. See: `bgfx::Resolution`. 668 Resolution resolution; 669 670 struct Limits 671 { 672 uint16_t maxEncoders; //!< Maximum number of encoder threads. 673 uint32_t transientVbSize; //!< Maximum transient vertex buffer size. 674 uint32_t transientIbSize; //!< Maximum transient index buffer size. 675 }; 676 677 Limits limits; 678 679 /// Provide application specific callback interface. 680 /// See: `bgfx::CallbackI` 681 CallbackI* callback; 682 683 /// Custom allocator. When a custom allocator is not 684 /// specified, bgfx uses the CRT allocator. Bgfx assumes 685 /// custom allocator is thread safe. 686 bx::AllocatorI* allocator; 687 }; 688 689 /// Memory release callback. 690 /// 691 /// param[in] _ptr Pointer to allocated data. 692 /// param[in] _userData User defined data if needed. 693 /// 694 /// @attention C99 equivalent is `bgfx_release_fn_t`. 695 /// 696 typedef void (*ReleaseFn)(void* _ptr, void* _userData); 697 698 /// Memory must be obtained by calling `bgfx::alloc`, `bgfx::copy`, or `bgfx::makeRef`. 699 /// 700 /// @attention It is illegal to create this structure on stack and pass it to any bgfx API. 701 /// 702 /// @attention C99 equivalent is `bgfx_memory_t`. 703 /// 704 struct Memory 705 { 706 uint8_t* data; //!< Pointer to data. 707 uint32_t size; //!< Data size. 708 }; 709 710 /// Renderer capabilities. 711 /// 712 /// @attention C99 equivalent is `bgfx_caps_t`. 713 /// 714 struct Caps 715 { 716 /// Renderer backend type. See: `bgfx::RendererType` 717 RendererType::Enum rendererType; 718 719 /// Supported functionality. 720 /// 721 /// @attention See BGFX_CAPS_* flags at https://bkaradzic.github.io/bgfx/bgfx.html#available-caps 722 /// 723 uint64_t supported; 724 725 uint16_t vendorId; //!< Selected GPU vendor PCI id. 726 uint16_t deviceId; //!< Selected GPU device id. 727 bool homogeneousDepth; //!< True when NDC depth is in [-1, 1] range, otherwise its [0, 1]. 728 bool originBottomLeft; //!< True when NDC origin is at bottom left. 729 uint8_t numGPUs; //!< Number of enumerated GPUs. 730 731 /// GPU info. 732 /// 733 /// @attention C99 equivalent is `bgfx_caps_gpu_t`. 734 /// 735 struct GPU 736 { 737 uint16_t vendorId; //!< Vendor PCI id. See `BGFX_PCI_ID_*`. 738 uint16_t deviceId; //!< Device id. 739 }; 740 741 GPU gpu[4]; //!< Enumerated GPUs. 742 743 struct Limits 744 { 745 uint32_t maxDrawCalls; //!< Maximum number of draw calls. 746 uint32_t maxBlits; //!< Maximum number of blit calls. 747 uint32_t maxTextureSize; //!< Maximum texture size. 748 uint32_t maxTextureLayers; //!< Maximum texture layers. 749 uint32_t maxViews; //!< Maximum number of views. 750 uint32_t maxFrameBuffers; //!< Maximum number of frame buffer handles. 751 uint32_t maxFBAttachments; //!< Maximum number of frame buffer attachments. 752 uint32_t maxPrograms; //!< Maximum number of program handles. 753 uint32_t maxShaders; //!< Maximum number of shader handles. 754 uint32_t maxTextures; //!< Maximum number of texture handles. 755 uint32_t maxTextureSamplers; //!< Maximum number of texture samplers. 756 uint32_t maxComputeBindings; //!< Maximum number of compute bindings. 757 uint32_t maxVertexLayouts; //!< Maximum number of vertex format layouts. 758 uint32_t maxVertexStreams; //!< Maximum number of vertex streams. 759 uint32_t maxIndexBuffers; //!< Maximum number of index buffer handles. 760 uint32_t maxVertexBuffers; //!< Maximum number of vertex buffer handles. 761 uint32_t maxDynamicIndexBuffers; //!< Maximum number of dynamic index buffer handles. 762 uint32_t maxDynamicVertexBuffers; //!< Maximum number of dynamic vertex buffer handles. 763 uint32_t maxUniforms; //!< Maximum number of uniform handles. 764 uint32_t maxOcclusionQueries; //!< Maximum number of occlusion query handles. 765 uint32_t maxEncoders; //!< Maximum number of encoder threads. 766 uint32_t transientVbSize; //!< Maximum transient vertex buffer size. 767 uint32_t transientIbSize; //!< Maximum transient index buffer size. 768 }; 769 770 Limits limits; 771 772 /// Supported texture format capabilities flags: 773 /// - `BGFX_CAPS_FORMAT_TEXTURE_NONE` - Texture format is not supported. 774 /// - `BGFX_CAPS_FORMAT_TEXTURE_2D` - Texture format is supported. 775 /// - `BGFX_CAPS_FORMAT_TEXTURE_2D_SRGB` - Texture as sRGB format is supported. 776 /// - `BGFX_CAPS_FORMAT_TEXTURE_2D_EMULATED` - Texture format is emulated. 777 /// - `BGFX_CAPS_FORMAT_TEXTURE_3D` - Texture format is supported. 778 /// - `BGFX_CAPS_FORMAT_TEXTURE_3D_SRGB` - Texture as sRGB format is supported. 779 /// - `BGFX_CAPS_FORMAT_TEXTURE_3D_EMULATED` - Texture format is emulated. 780 /// - `BGFX_CAPS_FORMAT_TEXTURE_CUBE` - Texture format is supported. 781 /// - `BGFX_CAPS_FORMAT_TEXTURE_CUBE_SRGB` - Texture as sRGB format is supported. 782 /// - `BGFX_CAPS_FORMAT_TEXTURE_CUBE_EMULATED` - Texture format is emulated. 783 /// - `BGFX_CAPS_FORMAT_TEXTURE_VERTEX` - Texture format can be used from vertex shader. 784 /// - `BGFX_CAPS_FORMAT_TEXTURE_IMAGE` - Texture format can be used as image from compute 785 /// shader. 786 /// - `BGFX_CAPS_FORMAT_TEXTURE_FRAMEBUFFER` - Texture format can be used as frame 787 /// buffer. 788 /// - `BGFX_CAPS_FORMAT_TEXTURE_FRAMEBUFFER_MSAA` - Texture format can be used as MSAA 789 /// frame buffer. 790 /// - `BGFX_CAPS_FORMAT_TEXTURE_MSAA` - Texture can be sampled as MSAA. 791 /// - `BGFX_CAPS_FORMAT_TEXTURE_MIP_AUTOGEN` - Texture format supports auto-generated 792 /// mips. 793 uint16_t formats[TextureFormat::Count]; 794 }; 795 796 /// Transient index buffer. 797 /// 798 /// @attention C99 equivalent is `bgfx_transient_index_buffer_t`. 799 /// 800 struct TransientIndexBuffer 801 { 802 uint8_t* data; //!< Pointer to data. 803 uint32_t size; //!< Data size. 804 uint32_t startIndex; //!< First index. 805 IndexBufferHandle handle; //!< Index buffer handle. 806 }; 807 808 /// Transient vertex buffer. 809 /// 810 /// @attention C99 equivalent is `bgfx_transient_vertex_buffer_t`. 811 /// 812 struct TransientVertexBuffer 813 { 814 uint8_t* data; //!< Pointer to data. 815 uint32_t size; //!< Data size. 816 uint32_t startVertex; //!< First vertex. 817 uint16_t stride; //!< Vertex stride. 818 VertexBufferHandle handle; //!< Vertex buffer handle. 819 VertexLayoutHandle layoutHandle; //!< Vertex layout handle. 820 }; 821 822 /// Instance data buffer info. 823 /// 824 /// @attention C99 equivalent is `bgfx_texture_info_t`. 825 /// 826 struct InstanceDataBuffer 827 { 828 uint8_t* data; //!< Pointer to data. 829 uint32_t size; //!< Data size. 830 uint32_t offset; //!< Offset in vertex buffer. 831 uint32_t num; //!< Number of instances. 832 uint16_t stride; //!< Vertex buffer stride. 833 VertexBufferHandle handle; //!< Vertex buffer object handle. 834 }; 835 836 /// Texture info. 837 /// 838 /// @attention C99 equivalent is `bgfx_texture_info_t`. 839 /// 840 struct TextureInfo 841 { 842 TextureFormat::Enum format; //!< Texture format. 843 uint32_t storageSize; //!< Total amount of bytes required to store texture. 844 uint16_t width; //!< Texture width. 845 uint16_t height; //!< Texture height. 846 uint16_t depth; //!< Texture depth. 847 uint16_t numLayers; //!< Number of layers in texture array. 848 uint8_t numMips; //!< Number of MIP maps. 849 uint8_t bitsPerPixel; //!< Format bits per pixel. 850 bool cubeMap; //!< Texture is cubemap. 851 }; 852 853 /// Uniform info. 854 /// 855 /// @attention C99 equivalent is `bgfx_uniform_info_t`. 856 /// 857 struct UniformInfo 858 { 859 char name[256]; //!< Uniform name. 860 UniformType::Enum type; //!< Uniform type. 861 uint16_t num; //!< Number of elements in array. 862 }; 863 864 /// Frame buffer texture attachment info. 865 /// 866 /// @attention C99 equivalent is `bgfx_attachment_t`. 867 /// 868 struct Attachment 869 { 870 /// Init attachment. 871 /// 872 /// @param[in] _handle Render target texture handle. 873 /// @param[in] _access Access. See `Access::Enum`. 874 /// @param[in] _layer Cubemap side or depth layer/slice. 875 /// @param[in] _mip Mip level. 876 /// @param[in] _resolve Resolve flags. See: `BGFX_RESOLVE_*` 877 /// 878 void init( 879 TextureHandle _handle 880 , Access::Enum _access = Access::Write 881 , uint16_t _layer = 0 882 , uint16_t _mip = 0 883 , uint8_t _resolve = BGFX_RESOLVE_AUTO_GEN_MIPS 884 ); 885 886 Access::Enum access; //!< Attachement access. See `Access::Enum`. 887 TextureHandle handle; //!< Render target texture handle. 888 uint16_t mip; //!< Mip level. 889 uint16_t layer; //!< Cubemap side or depth layer/slice. 890 uint8_t resolve; //!< Resolve flags. See: `BGFX_RESOLVE_*` 891 }; 892 893 /// Transform data. 894 /// 895 /// @attention C99 equivalent is `bgfx_transform_t`. 896 /// 897 struct Transform 898 { 899 float* data; //!< Pointer to first 4x4 matrix. 900 uint16_t num; //!< Number of matrices. 901 }; 902 903 /// 904 typedef uint16_t ViewId; 905 906 /// View stats. 907 /// 908 /// @attention C99 equivalent is `bgfx_view_stats_t`. 909 /// 910 struct ViewStats 911 { 912 char name[256]; //!< View name. 913 ViewId view; //!< View id. 914 int64_t cpuTimeBegin; //!< CPU (submit) begin time. 915 int64_t cpuTimeEnd; //!< CPU (submit) end time. 916 int64_t gpuTimeBegin; //!< GPU begin time. 917 int64_t gpuTimeEnd; //!< GPU end time. 918 }; 919 920 /// Encoder stats. 921 /// 922 /// @attention C99 equivalent is `bgfx_encoder_stats_t`. 923 /// 924 struct EncoderStats 925 { 926 int64_t cpuTimeBegin; //!< Encoder thread CPU submit begin time. 927 int64_t cpuTimeEnd; //!< Encoder thread CPU submit end time. 928 }; 929 930 /// Renderer statistics data. 931 /// 932 /// @attention C99 equivalent is `bgfx_stats_t`. 933 /// 934 /// @remarks All time values are high-resolution timestamps, while 935 /// time frequencies define timestamps-per-second for that hardware. 936 struct Stats 937 { 938 int64_t cpuTimeFrame; //!< CPU time between two `bgfx::frame` calls. 939 int64_t cpuTimeBegin; //!< Render thread CPU submit begin time. 940 int64_t cpuTimeEnd; //!< Render thread CPU submit end time. 941 int64_t cpuTimerFreq; //!< CPU timer frequency. Timestamps-per-second 942 943 int64_t gpuTimeBegin; //!< GPU frame begin time. 944 int64_t gpuTimeEnd; //!< GPU frame end time. 945 int64_t gpuTimerFreq; //!< GPU timer frequency. 946 947 int64_t waitRender; //!< Time spent waiting for render backend thread to finish issuing 948 //! draw commands to underlying graphics API. 949 int64_t waitSubmit; //!< Time spent waiting for submit thread to advance to next frame. 950 951 uint32_t numDraw; //!< Number of draw calls submitted. 952 uint32_t numCompute; //!< Number of compute calls submitted. 953 uint32_t numBlit; //!< Number of blit calls submitted. 954 uint32_t maxGpuLatency; //!< GPU driver latency. 955 956 uint16_t numDynamicIndexBuffers; //!< Number of used dynamic index buffers. 957 uint16_t numDynamicVertexBuffers; //!< Number of used dynamic vertex buffers. 958 uint16_t numFrameBuffers; //!< Number of used frame buffers. 959 uint16_t numIndexBuffers; //!< Number of used index buffers. 960 uint16_t numOcclusionQueries; //!< Number of used occlusion queries. 961 uint16_t numPrograms; //!< Number of used programs. 962 uint16_t numShaders; //!< Number of used shaders. 963 uint16_t numTextures; //!< Number of used textures. 964 uint16_t numUniforms; //!< Number of used uniforms. 965 uint16_t numVertexBuffers; //!< Number of used vertex buffers. 966 uint16_t numVertexLayouts; //!< Number of used vertex layouts. 967 968 int64_t textureMemoryUsed; //!< Estimate of texture memory used. 969 int64_t rtMemoryUsed; //!< Estimate of render target memory used. 970 int32_t transientVbUsed; //!< Amount of transient vertex buffer used. 971 int32_t transientIbUsed; //!< Amount of transient index buffer used. 972 973 uint32_t numPrims[Topology::Count]; //!< Number of primitives rendered. 974 975 int64_t gpuMemoryMax; //!< Maximum available GPU memory for application. 976 int64_t gpuMemoryUsed; //!< Amount of GPU memory used by the application. 977 978 uint16_t width; //!< Backbuffer width in pixels. 979 uint16_t height; //!< Backbuffer height in pixels. 980 uint16_t textWidth; //!< Debug text width in characters. 981 uint16_t textHeight; //!< Debug text height in characters. 982 983 uint16_t numViews; //!< Number of view stats. 984 ViewStats* viewStats; //!< Array of View stats. 985 986 uint8_t numEncoders; //!< Number of encoders used during frame. 987 EncoderStats* encoderStats; //!< Array of encoder stats. 988 }; 989 990 /// Encoders are used for submitting draw calls from multiple threads. Only one encoder 991 /// per thread should be used. Use `bgfx::begin()` to obtain an encoder for a thread. 992 /// 993 /// @attention C99 equivalent is `bgfx_encoder`. 994 /// 995 struct Encoder 996 { 997 /// Sets a debug marker. This allows you to group 998 /// graphics calls together for easy browsing in 999 /// graphics debugging tools. 1000 /// 1001 /// @attention C99 equivalent is `bgfx_encoder_set_marker`. 1002 /// 1003 void setMarker(const char* _marker); 1004 1005 /// Set render states for draw primitive. 1006 /// 1007 /// @param[in] _state State flags. Default state for primitive type is 1008 /// triangles. See: `BGFX_STATE_DEFAULT`. 1009 /// - `BGFX_STATE_DEPTH_TEST_*` - Depth test function. 1010 /// - `BGFX_STATE_BLEND_*` - See remark 1 about BGFX_STATE_BLEND_FUNC. 1011 /// - `BGFX_STATE_BLEND_EQUATION_*` - See remark 2. 1012 /// - `BGFX_STATE_CULL_*` - Backface culling mode. 1013 /// - `BGFX_STATE_WRITE_*` - Enable R, G, B, A or Z write. 1014 /// - `BGFX_STATE_MSAA` - Enable hardware multisample antialiasing. 1015 /// - `BGFX_STATE_PT_[TRISTRIP/LINES/POINTS]` - Primitive type. 1016 /// 1017 /// @param[in] _rgba Sets blend factor used by `BGFX_STATE_BLEND_FACTOR` and 1018 /// `BGFX_STATE_BLEND_INV_FACTOR` blend modes. 1019 /// 1020 /// @remarks 1021 /// 1. To setup more complex states use: 1022 /// `BGFX_STATE_ALPHA_REF(_ref)`, 1023 /// `BGFX_STATE_POINT_SIZE(_size)`, 1024 /// `BGFX_STATE_BLEND_FUNC(_src, _dst)`, 1025 /// `BGFX_STATE_BLEND_FUNC_SEPARATE(_srcRGB, _dstRGB, _srcA, _dstA)`, 1026 /// `BGFX_STATE_BLEND_EQUATION(_equation)`, 1027 /// `BGFX_STATE_BLEND_EQUATION_SEPARATE(_equationRGB, _equationA)` 1028 /// 2. `BGFX_STATE_BLEND_EQUATION_ADD` is set when no other blend 1029 /// equation is specified. 1030 /// 1031 /// @attention C99 equivalent is `bgfx_encoder_set_state`. 1032 /// 1033 void setState( 1034 uint64_t _state 1035 , uint32_t _rgba = 0 1036 ); 1037 1038 /// Set condition for rendering. 1039 /// 1040 /// @param[in] _handle Occlusion query handle. 1041 /// @param[in] _visible Render if occlusion query is visible. 1042 /// 1043 /// @attention C99 equivalent is `bgfx_encoder_set_condition`. 1044 /// 1045 void setCondition( 1046 OcclusionQueryHandle _handle 1047 , bool _visible 1048 ); 1049 1050 /// Set stencil test state. 1051 /// 1052 /// @param[in] _fstencil Front stencil state. 1053 /// @param[in] _bstencil Back stencil state. If back is set to `BGFX_STENCIL_NONE` 1054 /// _fstencil is applied to both front and back facing primitives. 1055 /// 1056 /// @attention C99 equivalent is `bgfx_encoder_set_stencil`. 1057 /// 1058 void setStencil( 1059 uint32_t _fstencil 1060 , uint32_t _bstencil = BGFX_STENCIL_NONE 1061 ); 1062 1063 /// Set scissor for draw primitive. To scissor for all primitives in 1064 /// view see `bgfx::setViewScissor`. 1065 /// 1066 /// @param[in] _x Position x from the left side of the window. 1067 /// @param[in] _y Position y from the top of the window. 1068 /// @param[in] _width Width of scissor region. 1069 /// @param[in] _height Height of scissor region. 1070 /// @returns Scissor cache index. 1071 /// 1072 /// @attention C99 equivalent is `bgfx_encoder_set_scissor`. 1073 /// 1074 uint16_t setScissor( 1075 uint16_t _x 1076 , uint16_t _y 1077 , uint16_t _width 1078 , uint16_t _height 1079 ); 1080 1081 /// Set scissor from cache for draw primitive. 1082 /// 1083 /// @param[in] _cache Index in scissor cache. 1084 /// Pass UINT16_MAX to have primitive use view scissor instead. 1085 /// 1086 /// @attention C99 equivalent is `bgfx_encoder_set_scissor_cached`. 1087 /// 1088 void setScissor(uint16_t _cache = UINT16_MAX); 1089 1090 /// Set model matrix for draw primitive. If it is not called, model will 1091 /// be rendered with identity model matrix. 1092 /// 1093 /// @param[in] _mtx Pointer to first matrix in array. 1094 /// @param[in] _num Number of matrices in array. 1095 /// @returns Index into matrix cache in case the same model matrix has 1096 /// to be used for other draw primitive call. 1097 /// 1098 /// @attention C99 equivalent is `bgfx_encoder_set_transform`. 1099 /// 1100 uint32_t setTransform( 1101 const void* _mtx 1102 , uint16_t _num = 1 1103 ); 1104 1105 /// Reserve `_num` matrices in internal matrix cache. 1106 /// 1107 /// @param[in] _transform Pointer to `Transform` structure. 1108 /// @param[in] _num Number of matrices. 1109 /// @returns Index into matrix cache. 1110 /// 1111 /// @attention Pointer returned can be modifed until `bgfx::frame` is called. 1112 /// @attention C99 equivalent is `bgfx_encoder_alloc_transform`. 1113 /// 1114 uint32_t allocTransform( 1115 Transform* _transform 1116 , uint16_t _num 1117 ); 1118 1119 /// Set model matrix from matrix cache for draw primitive. 1120 /// 1121 /// @param[in] _cache Index in matrix cache. 1122 /// @param[in] _num Number of matrices from cache. 1123 /// 1124 /// @attention C99 equivalent is `bgfx_encoder_set_transform_cached`. 1125 /// 1126 void setTransform( 1127 uint32_t _cache 1128 , uint16_t _num = 1 1129 ); 1130 1131 /// Set shader uniform parameter for draw primitive. 1132 /// 1133 /// @param[in] _handle Uniform. 1134 /// @param[in] _value Pointer to uniform data. 1135 /// @param[in] _num Number of elements. Passing `UINT16_MAX` will 1136 /// use the _num passed on uniform creation. 1137 /// 1138 /// @attention C99 equivalent is `bgfx_encoder_set_uniform`. 1139 /// 1140 void setUniform( 1141 UniformHandle _handle 1142 , const void* _value 1143 , uint16_t _num = 1 1144 ); 1145 1146 /// Set index buffer for draw primitive. 1147 /// 1148 /// @param[in] _handle Index buffer. 1149 /// 1150 /// @attention C99 equivalent is `bgfx_encoder_set_index_buffer`. 1151 /// 1152 void setIndexBuffer(IndexBufferHandle _handle); 1153 1154 /// Set index buffer for draw primitive. 1155 /// 1156 /// @param[in] _handle Index buffer. 1157 /// @param[in] _firstIndex First index to render. 1158 /// @param[in] _numIndices Number of indices to render. 1159 /// 1160 /// @attention C99 equivalent is `bgfx_encoder_set_index_buffer`. 1161 /// 1162 void setIndexBuffer( 1163 IndexBufferHandle _handle 1164 , uint32_t _firstIndex 1165 , uint32_t _numIndices 1166 ); 1167 1168 /// Set index buffer for draw primitive. 1169 /// 1170 /// @param[in] _handle Dynamic index buffer. 1171 /// 1172 /// @attention C99 equivalent is `bgfx_encoder_set_dynamic_index_buffer`. 1173 /// 1174 void setIndexBuffer(DynamicIndexBufferHandle _handle); 1175 1176 /// Set index buffer for draw primitive. 1177 /// 1178 /// @param[in] _handle Dynamic index buffer. 1179 /// @param[in] _firstIndex First index to render. 1180 /// @param[in] _numIndices Number of indices to render. 1181 /// 1182 /// @attention C99 equivalent is `bgfx_encoder_set_dynamic_index_buffer`. 1183 /// 1184 void setIndexBuffer( 1185 DynamicIndexBufferHandle _handle 1186 , uint32_t _firstIndex 1187 , uint32_t _numIndices 1188 ); 1189 1190 /// Set index buffer for draw primitive. 1191 /// 1192 /// @param[in] _tib Transient index buffer. 1193 /// 1194 /// @attention C99 equivalent is `bgfx_encoder_set_transient_index_buffer`. 1195 /// 1196 void setIndexBuffer(const TransientIndexBuffer* _tib); 1197 1198 /// Set index buffer for draw primitive. 1199 /// 1200 /// @param[in] _tib Transient index buffer. 1201 /// @param[in] _firstIndex First index to render. 1202 /// @param[in] _numIndices Number of indices to render. 1203 /// 1204 /// @attention C99 equivalent is `bgfx_encoder_set_transient_index_buffer`. 1205 /// 1206 void setIndexBuffer( 1207 const TransientIndexBuffer* _tib 1208 , uint32_t _firstIndex 1209 , uint32_t _numIndices 1210 ); 1211 1212 /// Set vertex buffer for draw primitive. 1213 /// 1214 /// @param[in] _stream Vertex stream. 1215 /// @param[in] _handle Vertex buffer. 1216 /// 1217 /// @attention C99 equivalent is `bgfx_encoder_set_vertex_buffer`. 1218 /// 1219 void setVertexBuffer( 1220 uint8_t _stream 1221 , VertexBufferHandle _handle 1222 ); 1223 1224 /// Set vertex buffer for draw primitive. 1225 /// 1226 /// @param[in] _stream Vertex stream. 1227 /// @param[in] _handle Vertex buffer. 1228 /// @param[in] _startVertex First vertex to render. 1229 /// @param[in] _numVertices Number of vertices to render. 1230 /// @param[in] _layoutHandle Vertex layout for aliasing vertex buffer. 1231 /// 1232 /// @attention C99 equivalent is `bgfx_encoder_set_vertex_buffer`. 1233 /// 1234 void setVertexBuffer( 1235 uint8_t _stream 1236 , VertexBufferHandle _handle 1237 , uint32_t _startVertex 1238 , uint32_t _numVertices 1239 , VertexLayoutHandle _layoutHandle = BGFX_INVALID_HANDLE 1240 ); 1241 1242 /// Set vertex buffer for draw primitive. 1243 /// 1244 /// @param[in] _stream Vertex stream. 1245 /// @param[in] _handle Dynamic vertex buffer. 1246 /// 1247 /// @attention C99 equivalent is `bgfx_encoder_set_dynamic_vertex_buffer`. 1248 /// 1249 void setVertexBuffer( 1250 uint8_t _stream 1251 , DynamicVertexBufferHandle _handle 1252 ); 1253 1254 /// Set vertex buffer for draw primitive. 1255 /// 1256 /// @param[in] _stream Vertex stream. 1257 /// @param[in] _handle Dynamic vertex buffer. 1258 /// @param[in] _startVertex First vertex to render. 1259 /// @param[in] _numVertices Number of vertices to render. 1260 /// @param[in] _layoutHandle Vertex layout for aliasing vertex buffer. 1261 /// 1262 /// @attention C99 equivalent is `bgfx_encoder_set_dynamic_vertex_buffer`. 1263 /// 1264 void setVertexBuffer( 1265 uint8_t _stream 1266 , DynamicVertexBufferHandle _handle 1267 , uint32_t _startVertex 1268 , uint32_t _numVertices 1269 , VertexLayoutHandle _layoutHandle = BGFX_INVALID_HANDLE 1270 ); 1271 1272 /// Set vertex buffer for draw primitive. 1273 /// 1274 /// @param[in] _stream Vertex stream. 1275 /// @param[in] _tvb Transient vertex buffer. 1276 /// 1277 /// @attention C99 equivalent is `bgfx_encoder_set_transient_vertex_buffer`. 1278 /// 1279 void setVertexBuffer( 1280 uint8_t _stream 1281 , const TransientVertexBuffer* _tvb 1282 ); 1283 1284 /// Set vertex buffer for draw primitive. 1285 /// 1286 /// @param[in] _stream Vertex stream. 1287 /// @param[in] _tvb Transient vertex buffer. 1288 /// @param[in] _startVertex First vertex to render. 1289 /// @param[in] _numVertices Number of vertices to render. 1290 /// @param[in] _layoutHandle Vertex layout for aliasing vertex buffer. 1291 /// 1292 /// @attention C99 equivalent is `bgfx_encoder_set_transient_vertex_buffer`. 1293 /// 1294 void setVertexBuffer( 1295 uint8_t _stream 1296 , const TransientVertexBuffer* _tvb 1297 , uint32_t _startVertex 1298 , uint32_t _numVertices 1299 , VertexLayoutHandle _layoutHandle = BGFX_INVALID_HANDLE 1300 ); 1301 1302 /// Set number of vertices for auto generated vertices use in conjuction 1303 /// with gl_VertexID. 1304 /// 1305 /// @param[in] _numVertices Number of vertices. 1306 /// 1307 /// @attention Availability depends on: `BGFX_CAPS_VERTEX_ID`. 1308 /// @attention C99 equivalent is `bgfx_encoder_set_vertex_count`. 1309 /// 1310 void setVertexCount(uint32_t _numVertices); 1311 1312 /// Set instance data buffer for draw primitive. 1313 /// 1314 /// @param[in] _idb Transient instance data buffer. 1315 /// 1316 /// @attention C99 equivalent is `bgfx_encoder_set_instance_data_buffer`. 1317 /// 1318 void setInstanceDataBuffer(const InstanceDataBuffer* _idb); 1319 1320 /// Set instance data buffer for draw primitive. 1321 /// 1322 /// @param[in] _idb Transient instance data buffer. 1323 /// @param[in] _start First instance data. 1324 /// @param[in] _num Number of data instances. 1325 /// 1326 /// @attention C99 equivalent is `bgfx_encoder_set_instance_data_buffer`. 1327 /// 1328 void setInstanceDataBuffer( 1329 const InstanceDataBuffer* _idb 1330 , uint32_t _start 1331 , uint32_t _num 1332 ); 1333 1334 /// Set instance data buffer for draw primitive. 1335 /// 1336 /// @param[in] _handle Vertex buffer. 1337 /// @param[in] _start First instance data. 1338 /// @param[in] _num Number of data instances. 1339 /// 1340 /// @attention C99 equivalent is `bgfx_encoder_set_instance_data_from_vertex_buffer`. 1341 /// 1342 void setInstanceDataBuffer( 1343 VertexBufferHandle _handle 1344 , uint32_t _start 1345 , uint32_t _num 1346 ); 1347 1348 /// Set instance data buffer for draw primitive. 1349 /// 1350 /// @param[in] _handle Vertex buffer. 1351 /// @param[in] _start First instance data. 1352 /// @param[in] _num Number of data instances. 1353 /// 1354 /// @attention C99 equivalent is `bgfx_encoder_set_instance_data_from_dynamic_vertex_buffer`. 1355 /// 1356 void setInstanceDataBuffer( 1357 DynamicVertexBufferHandle _handle 1358 , uint32_t _start 1359 , uint32_t _num 1360 ); 1361 1362 /// Set number of instances for auto generated instances use in conjuction 1363 /// with gl_InstanceID. 1364 /// 1365 /// @param[in] _numInstances Number of instances. 1366 /// 1367 /// @attention Availability depends on: `BGFX_CAPS_VERTEX_ID`. 1368 /// @attention C99 equivalent is `bgfx_encoder_set_instance_count`. 1369 /// 1370 void setInstanceCount(uint32_t _numInstances); 1371 1372 /// Set texture stage for draw primitive. 1373 /// 1374 /// @param[in] _stage Texture unit. 1375 /// @param[in] _sampler Program sampler. 1376 /// @param[in] _handle Texture handle. 1377 /// @param[in] _flags Texture sampling mode. Default value UINT32_MAX uses 1378 /// texture sampling settings from the texture. 1379 /// - `BGFX_SAMPLER_[U/V/W]_[MIRROR/CLAMP]` - Mirror or clamp to edge wrap 1380 /// mode. 1381 /// - `BGFX_SAMPLER_[MIN/MAG/MIP]_[POINT/ANISOTROPIC]` - Point or anisotropic 1382 /// sampling. 1383 /// 1384 /// @attention C99 equivalent is `bgfx_encoder_set_texture`. 1385 /// 1386 void setTexture( 1387 uint8_t _stage 1388 , UniformHandle _sampler 1389 , TextureHandle _handle 1390 , uint32_t _flags = UINT32_MAX 1391 ); 1392 1393 /// Submit an empty primitive for rendering. Uniforms and draw state 1394 /// will be applied but no geometry will be submitted. 1395 /// 1396 /// These empty draw calls will sort before ordinary draw calls. 1397 /// 1398 /// @param[in] _id View id. 1399 /// 1400 /// 1401 /// @attention C99 equivalent is `bgfx_encoder_touch`. 1402 /// 1403 void touch(ViewId _id); 1404 1405 /// Submit primitive for rendering. 1406 /// 1407 /// @param[in] _id View id. 1408 /// @param[in] _program Program. 1409 /// @param[in] _depth Depth for sorting. 1410 /// @param[in] _preserveState Preserve internal draw state for next draw 1411 /// call submit. 1412 /// 1413 /// @attention C99 equivalent is `bgfx_encoder_submit`. 1414 /// 1415 void submit( 1416 ViewId _id 1417 , ProgramHandle _program 1418 , uint32_t _depth = 0 1419 , bool _preserveState = false 1420 ); 1421 1422 /// Submit primitive with occlusion query for rendering. 1423 /// 1424 /// @param[in] _id View id. 1425 /// @param[in] _program Program. 1426 /// @param[in] _occlusionQuery Occlusion query. 1427 /// @param[in] _depth Depth for sorting. 1428 /// @param[in] _preserveState Preserve internal draw state for next draw 1429 /// call submit. 1430 /// 1431 /// @attention C99 equivalent is `bgfx_encoder_submit_occlusion_query`. 1432 /// 1433 void submit( 1434 ViewId _id 1435 , ProgramHandle _program 1436 , OcclusionQueryHandle _occlusionQuery 1437 , uint32_t _depth = 0 1438 , bool _preserveState = false 1439 ); 1440 1441 /// Submit primitive for rendering with index and instance data info from 1442 /// indirect buffer. 1443 /// 1444 /// @param[in] _id View id. 1445 /// @param[in] _program Program. 1446 /// @param[in] _indirectHandle Indirect buffer. 1447 /// @param[in] _start First element in indirect buffer. 1448 /// @param[in] _num Number of dispatches. 1449 /// @param[in] _depth Depth for sorting. 1450 /// @param[in] _preserveState Preserve internal draw state for next draw 1451 /// call submit. 1452 /// 1453 /// @attention C99 equivalent is `bgfx_encoder_submit_indirect`. 1454 /// 1455 void submit( 1456 ViewId _id 1457 , ProgramHandle _program 1458 , IndirectBufferHandle _indirectHandle 1459 , uint16_t _start = 0 1460 , uint16_t _num = 1 1461 , uint32_t _depth = 0 1462 , bool _preserveState = false 1463 ); 1464 1465 /// Set compute index buffer. 1466 /// 1467 /// @param[in] _stage Compute stage. 1468 /// @param[in] _handle Index buffer handle. 1469 /// @param[in] _access Buffer access. See `Access::Enum`. 1470 /// 1471 /// @attention C99 equivalent is `bgfx_encoder_set_compute_index_buffer`. 1472 /// 1473 void setBuffer( 1474 uint8_t _stage 1475 , IndexBufferHandle _handle 1476 , Access::Enum _access 1477 ); 1478 1479 /// Set compute vertex buffer. 1480 /// 1481 /// @param[in] _stage Compute stage. 1482 /// @param[in] _handle Vertex buffer handle. 1483 /// @param[in] _access Buffer access. See `Access::Enum`. 1484 /// 1485 /// @attention C99 equivalent is `bgfx_encoder_set_compute_vertex_buffer`. 1486 /// 1487 void setBuffer( 1488 uint8_t _stage 1489 , VertexBufferHandle _handle 1490 , Access::Enum _access 1491 ); 1492 1493 /// Set compute dynamic index buffer. 1494 /// 1495 /// @param[in] _stage Compute stage. 1496 /// @param[in] _handle Dynamic index buffer handle. 1497 /// @param[in] _access Buffer access. See `Access::Enum`. 1498 /// 1499 /// @attention C99 equivalent is `bgfx_encoder_set_compute_dynamic_index_buffer`. 1500 /// 1501 void setBuffer( 1502 uint8_t _stage 1503 , DynamicIndexBufferHandle _handle 1504 , Access::Enum _access 1505 ); 1506 1507 /// Set compute dynamic vertex buffer. 1508 /// 1509 /// @param[in] _stage Compute stage. 1510 /// @param[in] _handle Dynamic vertex buffer handle. 1511 /// @param[in] _access Buffer access. See `Access::Enum`. 1512 /// 1513 /// @attention C99 equivalent is `bgfx_encoder_set_compute_dynamic_vertex_buffer`. 1514 /// 1515 void setBuffer( 1516 uint8_t _stage 1517 , DynamicVertexBufferHandle _handle 1518 , Access::Enum _access 1519 ); 1520 1521 /// Set compute indirect buffer. 1522 /// 1523 /// @param[in] _stage Compute stage. 1524 /// @param[in] _handle Indirect buffer handle. 1525 /// @param[in] _access Buffer access. See `Access::Enum`. 1526 /// 1527 /// @attention C99 equivalent is `bgfx_encoder_set_compute_indirect_buffer`. 1528 /// 1529 void setBuffer( 1530 uint8_t _stage 1531 , IndirectBufferHandle _handle 1532 , Access::Enum _access 1533 ); 1534 1535 /// Set compute image from texture. 1536 /// 1537 /// @param[in] _stage Texture unit. 1538 /// @param[in] _handle Texture handle. 1539 /// @param[in] _mip Mip level. 1540 /// @param[in] _access Texture access. See `Access::Enum`. 1541 /// @param[in] _format Texture format. See: `TextureFormat::Enum`. 1542 /// 1543 /// @attention C99 equivalent is `bgfx_encoder_set_image`. 1544 /// 1545 void setImage( 1546 uint8_t _stage 1547 , TextureHandle _handle 1548 , uint8_t _mip 1549 , Access::Enum _access 1550 , TextureFormat::Enum _format = TextureFormat::Count 1551 ); 1552 1553 /// Dispatch compute. 1554 /// 1555 /// @param[in] _id View id. 1556 /// @param[in] _handle Compute program. 1557 /// @param[in] _numX Number of groups X. 1558 /// @param[in] _numY Number of groups Y. 1559 /// @param[in] _numZ Number of groups Z. 1560 /// 1561 /// @attention C99 equivalent is `bgfx_encoder_dispatch`. 1562 /// 1563 void dispatch( 1564 ViewId _id 1565 , ProgramHandle _handle 1566 , uint32_t _numX = 1 1567 , uint32_t _numY = 1 1568 , uint32_t _numZ = 1 1569 ); 1570 1571 /// Dispatch compute indirect. 1572 /// 1573 /// @param[in] _id View id. 1574 /// @param[in] _handle Compute program. 1575 /// @param[in] _indirectHandle Indirect buffer. 1576 /// @param[in] _start First element in indirect buffer. 1577 /// @param[in] _num Number of dispatches. 1578 /// 1579 /// @attention C99 equivalent is `bgfx_encoder_dispatch_indirect`. 1580 /// 1581 void dispatch( 1582 ViewId _id 1583 , ProgramHandle _handle 1584 , IndirectBufferHandle _indirectHandle 1585 , uint16_t _start = 0 1586 , uint16_t _num = 1 1587 ); 1588 1589 /// Discard all previously set state for draw or compute call. 1590 /// 1591 /// @attention C99 equivalent is `bgfx_encoder_discard`. 1592 /// 1593 void discard(); 1594 1595 /// Blit texture 2D region between two 2D textures. 1596 /// 1597 /// @param[in] _id View id. 1598 /// @param[in] _dst Destination texture handle. 1599 /// @param[in] _dstX Destination texture X position. 1600 /// @param[in] _dstY Destination texture Y position. 1601 /// @param[in] _src Source texture handle. 1602 /// @param[in] _srcX Source texture X position. 1603 /// @param[in] _srcY Source texture Y position. 1604 /// @param[in] _width Width of region. 1605 /// @param[in] _height Height of region. 1606 /// 1607 /// @attention Destination texture must be created with `BGFX_TEXTURE_BLIT_DST` flag. 1608 /// @attention Availability depends on: `BGFX_CAPS_TEXTURE_BLIT`. 1609 /// @attention C99 equivalent is `bgfx_encoder_blit`. 1610 /// 1611 void blit( 1612 ViewId _id 1613 , TextureHandle _dst 1614 , uint16_t _dstX 1615 , uint16_t _dstY 1616 , TextureHandle _src 1617 , uint16_t _srcX = 0 1618 , uint16_t _srcY = 0 1619 , uint16_t _width = UINT16_MAX 1620 , uint16_t _height = UINT16_MAX 1621 ); 1622 1623 /// Blit texture region between two textures. 1624 /// 1625 /// @param[in] _id View id. 1626 /// @param[in] _dst Destination texture handle. 1627 /// @param[in] _dstMip Destination texture mip level. 1628 /// @param[in] _dstX Destination texture X position. 1629 /// @param[in] _dstY Destination texture Y position. 1630 /// @param[in] _dstZ If texture is 2D this argument should be 0. If destination texture is cube 1631 /// this argument represents destination texture cube face. For 3D texture this argument 1632 /// represents destination texture Z position. 1633 /// @param[in] _src Source texture handle. 1634 /// @param[in] _srcMip Source texture mip level. 1635 /// @param[in] _srcX Source texture X position. 1636 /// @param[in] _srcY Source texture Y position. 1637 /// @param[in] _srcZ If texture is 2D this argument should be 0. If source texture is cube 1638 /// this argument represents source texture cube face. For 3D texture this argument 1639 /// represents source texture Z position. 1640 /// @param[in] _width Width of region. 1641 /// @param[in] _height Height of region. 1642 /// @param[in] _depth If texture is 3D this argument represents depth of region, otherwise it's 1643 /// unused. 1644 /// 1645 /// @attention Destination texture must be created with `BGFX_TEXTURE_BLIT_DST` flag. 1646 /// @attention Availability depends on: `BGFX_CAPS_TEXTURE_BLIT`. 1647 /// @attention C99 equivalent is `bgfx_encoder_blit`. 1648 /// 1649 void blit( 1650 ViewId _id 1651 , TextureHandle _dst 1652 , uint8_t _dstMip 1653 , uint16_t _dstX 1654 , uint16_t _dstY 1655 , uint16_t _dstZ 1656 , TextureHandle _src 1657 , uint8_t _srcMip = 0 1658 , uint16_t _srcX = 0 1659 , uint16_t _srcY = 0 1660 , uint16_t _srcZ = 0 1661 , uint16_t _width = UINT16_MAX 1662 , uint16_t _height = UINT16_MAX 1663 , uint16_t _depth = UINT16_MAX 1664 ); 1665 }; 1666 1667 /// Vertex layout. 1668 /// 1669 /// @attention C99 equivalent is `bgfx_vertex_layout_t`. 1670 /// 1671 struct VertexLayout 1672 { 1673 VertexLayout(); 1674 1675 /// Start VertexLayout. 1676 /// 1677 /// @attention C99 equivalent is `bgfx_vertex_layout_begin`. 1678 /// 1679 VertexLayout& begin(RendererType::Enum _renderer = RendererType::Noop); 1680 1681 /// End VertexLayout. 1682 /// 1683 /// @attention C99 equivalent is `bgfx_vertex_layout_end`. 1684 /// 1685 void end(); 1686 1687 /// Add attribute to VertexLayout. 1688 /// 1689 /// @param[in] _attrib Attribute semantics. See: `bgfx::Attrib` 1690 /// @param[in] _num Number of elements 1, 2, 3 or 4. 1691 /// @param[in] _type Element type. 1692 /// @param[in] _normalized When using fixed point AttribType (f.e. Uint8) 1693 /// value will be normalized for vertex shader usage. When normalized 1694 /// is set to true, AttribType::Uint8 value in range 0-255 will be 1695 /// in range 0.0-1.0 in vertex shader. 1696 /// @param[in] _asInt Packaging rule for vertexPack, vertexUnpack, and 1697 /// vertexConvert for AttribType::Uint8 and AttribType::Int16. 1698 /// Unpacking code must be implemented inside vertex shader. 1699 /// 1700 /// @remarks 1701 /// Must be called between begin/end. 1702 /// 1703 /// @attention C99 equivalent is `bgfx_vertex_layout_add`. 1704 /// 1705 VertexLayout& add( 1706 Attrib::Enum _attrib 1707 , uint8_t _num 1708 , AttribType::Enum _type 1709 , bool _normalized = false 1710 , bool _asInt = false 1711 ); 1712 1713 /// Skip _num bytes in vertex stream. 1714 /// 1715 /// @attention C99 equivalent is `bgfx_vertex_layout_skip`. 1716 /// 1717 VertexLayout& skip(uint8_t _num); 1718 1719 /// Decode attribute. 1720 /// 1721 /// @attention C99 equivalent is `bgfx_vertex_layout_decode`. 1722 /// 1723 void decode( 1724 Attrib::Enum _attrib 1725 , uint8_t& _num 1726 , AttribType::Enum& _type 1727 , bool& _normalized 1728 , bool& _asInt 1729 ) const; 1730 1731 /// Returns true if VertexLayout contains attribute. 1732 /// 1733 /// @attention C99 equivalent is `bgfx_vertex_layout_has`. 1734 /// hasVertexLayout1735 bool has(Attrib::Enum _attrib) const { return UINT16_MAX != m_attributes[_attrib]; } 1736 1737 /// Returns relative attribute offset from the vertex. getOffsetVertexLayout1738 uint16_t getOffset(Attrib::Enum _attrib) const { return m_offset[_attrib]; } 1739 1740 /// Returns vertex stride. getStrideVertexLayout1741 uint16_t getStride() const { return m_stride; } 1742 1743 /// Returns size of vertex buffer for number of vertices. getSizeVertexLayout1744 uint32_t getSize(uint32_t _num) const { return _num*m_stride; } 1745 1746 uint32_t m_hash; 1747 uint16_t m_stride; 1748 uint16_t m_offset[Attrib::Count]; 1749 uint16_t m_attributes[Attrib::Count]; 1750 }; 1751 1752 /// Pack vertex attribute into vertex stream format. 1753 /// 1754 /// @param[in] _input Value to be packed into vertex stream. 1755 /// @param[in] _inputNormalized True if input value is already normalized. 1756 /// @param[in] _attr Attribute to pack. 1757 /// @param[in] _layout Vertex stream layout. 1758 /// @param[in] _data Destination vertex stream where data will be packed. 1759 /// @param[in] _index Vertex index that will be modified. 1760 /// 1761 /// @attention C99 equivalent is `bgfx_vertex_pack`. 1762 /// 1763 void vertexPack( 1764 const float _input[4] 1765 , bool _inputNormalized 1766 , Attrib::Enum _attr 1767 , const VertexLayout& _layout 1768 , void* _data 1769 , uint32_t _index = 0 1770 ); 1771 1772 /// Unpack vertex attribute from vertex stream format. 1773 /// 1774 /// @param[out] _output Result of unpacking. 1775 /// @param[in] _attr Attribute to unpack. 1776 /// @param[in] _layout Vertex stream layout. 1777 /// @param[in] _data Source vertex stream from where data will be unpacked. 1778 /// @param[in] _index Vertex index that will be unpacked. 1779 /// 1780 /// @attention C99 equivalent is `bgfx_vertex_unpack`. 1781 /// 1782 void vertexUnpack( 1783 float _output[4] 1784 , Attrib::Enum _attr 1785 , const VertexLayout& _layout 1786 , const void* _data 1787 , uint32_t _index = 0 1788 ); 1789 1790 /// Converts vertex stream data from one vertex stream format to another. 1791 /// 1792 /// @param[in] _destLayout Destination vertex stream layout. 1793 /// @param[in] _destData Destination vertex stream. 1794 /// @param[in] _srcLayout Source vertex stream layout. 1795 /// @param[in] _srcData Source vertex stream data. 1796 /// @param[in] _num Number of vertices to convert from source to destination. 1797 /// 1798 /// @attention C99 equivalent is `bgfx_vertex_convert`. 1799 /// 1800 void vertexConvert( 1801 const VertexLayout& _destLayout 1802 , void* _destData 1803 , const VertexLayout& _srcLayout 1804 , const void* _srcData 1805 , uint32_t _num = 1 1806 ); 1807 1808 /// Weld vertices. 1809 /// 1810 /// @param[in] _output Welded vertices remapping table. The size of buffer 1811 /// must be the same as number of vertices. 1812 /// @param[in] _layout Vertex stream layout. 1813 /// @param[in] _data Vertex stream. 1814 /// @param[in] _num Number of vertices in vertex stream. 1815 /// @param[in] _epsilon Error tolerance for vertex position comparison. 1816 /// @returns Number of unique vertices after vertex welding. 1817 /// 1818 /// @attention C99 equivalent is `bgfx_weld_vertices`. 1819 /// 1820 uint16_t weldVertices( 1821 uint16_t* _output 1822 , const VertexLayout& _layout 1823 , const void* _data 1824 , uint16_t _num 1825 , float _epsilon = 0.001f 1826 ); 1827 1828 /// Convert index buffer for use with different primitive topologies. 1829 /// 1830 /// @param[in] _conversion Conversion type, see `TopologyConvert::Enum`. 1831 /// @param[in] _dst Destination index buffer. If this argument is NULL 1832 /// function will return number of indices after conversion. 1833 /// @param[in] _dstSize Destination index buffer in bytes. It must be 1834 /// large enough to contain output indices. If destination size is 1835 /// insufficient index buffer will be truncated. 1836 /// @param[in] _indices Source indices. 1837 /// @param[in] _numIndices Number of input indices. 1838 /// @param[in] _index32 Set to `true` if input indices are 32-bit. 1839 /// 1840 /// @returns Number of output indices after conversion. 1841 /// 1842 /// @attention C99 equivalent is `bgfx_topology_convert`. 1843 /// 1844 uint32_t topologyConvert( 1845 TopologyConvert::Enum _conversion 1846 , void* _dst 1847 , uint32_t _dstSize 1848 , const void* _indices 1849 , uint32_t _numIndices 1850 , bool _index32 1851 ); 1852 1853 /// Sort indices. 1854 /// 1855 /// @param[in] _sort Sort order, see `TopologySort::Enum`. 1856 /// @param[in] _dst Destination index buffer. 1857 /// @param[in] _dstSize Destination index buffer in bytes. It must be 1858 /// large enough to contain output indices. If destination size is 1859 /// insufficient index buffer will be truncated. 1860 /// @param[in] _dir Direction (vector must be normalized). 1861 /// @param[in] _pos Position. 1862 /// @param[in] _vertices Pointer to first vertex represented as 1863 /// float x, y, z. Must contain at least number of vertices 1864 /// referencende by index buffer. 1865 /// @param[in] _stride Vertex stride. 1866 /// @param[in] _indices Source indices. 1867 /// @param[in] _numIndices Number of input indices. 1868 /// @param[in] _index32 Set to `true` if input indices are 32-bit. 1869 /// 1870 /// @attention C99 equivalent is `bgfx_topology_sort_tri_list`. 1871 /// 1872 void topologySortTriList( 1873 TopologySort::Enum _sort 1874 , void* _dst 1875 , uint32_t _dstSize 1876 , const float _dir[3] 1877 , const float _pos[3] 1878 , const void* _vertices 1879 , uint32_t _stride 1880 , const void* _indices 1881 , uint32_t _numIndices 1882 , bool _index32 1883 ); 1884 1885 /// Returns supported backend API renderers. 1886 /// 1887 /// @param[in] _max Maximum number of elements in _enum array. 1888 /// @param[inout] _enum Array where supported renderers will be written. 1889 /// 1890 /// @returns Number of supported renderers. 1891 /// 1892 /// @attention C99 equivalent is `bgfx_get_supported_renderers`. 1893 /// 1894 uint8_t getSupportedRenderers( 1895 uint8_t _max = 0 1896 , RendererType::Enum* _enum = NULL 1897 ); 1898 1899 /// Returns name of renderer. 1900 /// 1901 /// @attention C99 equivalent is `bgfx_get_renderer_name`. 1902 /// 1903 const char* getRendererName(RendererType::Enum _type); 1904 1905 /// Initialize bgfx library. 1906 /// 1907 /// @param[in] _init Initialization parameters. See: `bgfx::Init` for more info. 1908 /// 1909 /// @returns `true` if initialization was successful. 1910 /// 1911 /// @attention C99 equivalent is `bgfx_init`. 1912 /// 1913 bool init(const Init& _init = {}); 1914 1915 /// Shutdown bgfx library. 1916 /// 1917 /// @attention C99 equivalent is `bgfx_shutdown`. 1918 /// 1919 void shutdown(); 1920 1921 /// Reset graphic settings and back-buffer size. 1922 /// 1923 /// @param[in] _width Back-buffer width. 1924 /// @param[in] _height Back-buffer height. 1925 /// @param[in] _flags See: `BGFX_RESET_*` for more info. 1926 /// - `BGFX_RESET_NONE` - No reset flags. 1927 /// - `BGFX_RESET_FULLSCREEN` - Not supported yet. 1928 /// - `BGFX_RESET_MSAA_X[2/4/8/16]` - Enable 2, 4, 8 or 16 x MSAA. 1929 /// - `BGFX_RESET_VSYNC` - Enable V-Sync. 1930 /// - `BGFX_RESET_MAXANISOTROPY` - Turn on/off max anisotropy. 1931 /// - `BGFX_RESET_CAPTURE` - Begin screen capture. 1932 /// - `BGFX_RESET_FLUSH_AFTER_RENDER` - Flush rendering after submitting to GPU. 1933 /// - `BGFX_RESET_FLIP_AFTER_RENDER` - This flag specifies where flip 1934 /// occurs. Default behavior is that flip occurs before rendering new 1935 /// frame. This flag only has effect when `BGFX_CONFIG_MULTITHREADED=0`. 1936 /// - `BGFX_RESET_SRGB_BACKBUFFER` - Enable sRGB backbuffer. 1937 /// @param[in] _format Texture format. See: `TextureFormat::Enum`. 1938 /// 1939 /// @attention This call doesn't actually change window size, it just 1940 /// resizes back-buffer. Windowing code has to change window size. 1941 /// 1942 /// @attention C99 equivalent is `bgfx_reset`. 1943 /// 1944 void reset( 1945 uint32_t _width 1946 , uint32_t _height 1947 , uint32_t _flags = BGFX_RESET_NONE 1948 , TextureFormat::Enum _format = TextureFormat::Count 1949 ); 1950 1951 /// Begin submitting draw calls from thread. 1952 /// 1953 /// @param[in] _forThread Explicitly request an encoder for a worker thread. 1954 /// 1955 Encoder* begin(bool _forThread = false); 1956 1957 /// End submitting draw calls from thread. 1958 /// 1959 void end(Encoder* _encoder); 1960 1961 /// Advance to next frame. When using multithreaded renderer, this call 1962 /// just swaps internal buffers, kicks render thread, and returns. In 1963 /// singlethreaded renderer this call does frame rendering. 1964 /// 1965 /// @param[in] _capture Capture frame with graphics debugger. 1966 /// 1967 /// @returns Current frame number. This might be used in conjunction with 1968 /// double/multi buffering data outside the library and passing it to 1969 /// library via `bgfx::makeRef` calls. 1970 /// 1971 /// @attention C99 equivalent is `bgfx_frame`. 1972 /// 1973 uint32_t frame(bool _capture = false); 1974 1975 /// Returns current renderer backend API type. 1976 /// 1977 /// @remarks 1978 /// Library must be initialized. 1979 /// 1980 /// @attention C99 equivalent is `bgfx_get_renderer_type`. 1981 /// 1982 RendererType::Enum getRendererType(); 1983 1984 /// Returns renderer capabilities. 1985 /// 1986 /// @returns Pointer to static `bgfx::Caps` structure. 1987 /// 1988 /// @remarks 1989 /// Library must be initialized. 1990 /// 1991 /// @attention C99 equivalent is `bgfx_get_caps`. 1992 /// 1993 const Caps* getCaps(); 1994 1995 /// Returns performance counters. 1996 /// 1997 /// @attention Pointer returned is valid until `bgfx::frame` is called. 1998 /// @attention C99 equivalent is `bgfx_get_stats`. 1999 /// 2000 const Stats* getStats(); 2001 2002 /// Allocate buffer to pass to bgfx calls. Data will be freed inside bgfx. 2003 /// 2004 /// @param[in] _size Size to allocate. 2005 /// 2006 /// @attention C99 equivalent is `bgfx_alloc`. 2007 /// 2008 const Memory* alloc(uint32_t _size); 2009 2010 /// Allocate buffer and copy data into it. Data will be freed inside bgfx. 2011 /// 2012 /// @param[in] _data Pointer to data to be copied. 2013 /// @param[in] _size Size of data to be copied. 2014 /// 2015 /// @attention C99 equivalent is `bgfx_copy`. 2016 /// 2017 const Memory* copy( 2018 const void* _data 2019 , uint32_t _size 2020 ); 2021 2022 /// Make reference to data to pass to bgfx. Unlike `bgfx::alloc`, this call 2023 /// doesn't allocate memory for data. It just copies the _data pointer. You 2024 /// can pass `ReleaseFn` function pointer to release this memory after it's 2025 /// consumed, otherwise you must make sure _data is available for at least 2 2026 /// `bgfx::frame` calls. `ReleaseFn` function must be able to be called 2027 /// from any thread. 2028 /// 2029 /// @param[in] _data Pointer to data. 2030 /// @param[in] _size Size of data. 2031 /// @param[in] _releaseFn Callback function to release memory after use. 2032 /// @param[in] _userData User data to be passed to callback function. 2033 /// 2034 /// @attention Data passed must be available for at least 2 `bgfx::frame` calls. 2035 /// @attention C99 equivalent are `bgfx_make_ref`, `bgfx_make_ref_release`. 2036 /// 2037 const Memory* makeRef( 2038 const void* _data 2039 , uint32_t _size 2040 , ReleaseFn _releaseFn = NULL 2041 , void* _userData = NULL 2042 ); 2043 2044 /// Set debug flags. 2045 /// 2046 /// @param[in] _debug Available flags: 2047 /// - `BGFX_DEBUG_IFH` - Infinitely fast hardware. When this flag is set 2048 /// all rendering calls will be skipped. This is useful when profiling 2049 /// to quickly assess potential bottlenecks between CPU and GPU. 2050 /// - `BGFX_DEBUG_PROFILER` - Enable profiler. 2051 /// - `BGFX_DEBUG_STATS` - Display internal statistics. 2052 /// - `BGFX_DEBUG_TEXT` - Display debug text. 2053 /// - `BGFX_DEBUG_WIREFRAME` - Wireframe rendering. All rendering 2054 /// primitives will be rendered as lines. 2055 /// 2056 /// @attention C99 equivalent is `bgfx_set_debug`. 2057 /// 2058 void setDebug(uint32_t _debug); 2059 2060 /// Clear internal debug text buffer. 2061 /// 2062 /// @param[in] _attr Background color. 2063 /// @param[in] _small Default 8x16 or 8x8 font. 2064 /// 2065 /// @attention C99 equivalent is `bgfx_dbg_text_clear`. 2066 /// 2067 void dbgTextClear( 2068 uint8_t _attr = 0 2069 , bool _small = false 2070 ); 2071 2072 /// Print into internal debug text character-buffer (VGA-compatible text mode). 2073 /// 2074 /// @param[in] _x, _y 2D position from top-left. 2075 /// @param[in] _attr Color palette. Where top 4-bits represent index of background, and bottom 2076 /// 4-bits represent foreground color from standard VGA text palette (ANSI escape codes). 2077 /// @param[in] _format `printf` style format. 2078 /// 2079 /// @attention C99 equivalent is `bgfx_dbg_text_printf`. 2080 /// 2081 void dbgTextPrintf( 2082 uint16_t _x 2083 , uint16_t _y 2084 , uint8_t _attr 2085 , const char* _format 2086 , ... 2087 ); 2088 2089 /// Print into internal debug text character-buffer (VGA-compatible text mode). 2090 /// 2091 /// @param[in] _x, _y 2D position from top-left. 2092 /// @param[in] _attr Color palette. Where top 4-bits represent index of background, and bottom 2093 /// 4-bits represent foreground color from standard VGA text palette (ANSI escape codes). 2094 /// @param[in] _format `printf` style format. 2095 /// @param[in] _argList additional arguments for format string 2096 /// 2097 /// @attention C99 equivalent is `bgfx_dbg_text_vprintf`. 2098 /// 2099 void dbgTextPrintfVargs( 2100 uint16_t _x 2101 , uint16_t _y 2102 , uint8_t _attr 2103 , const char* _format 2104 , va_list _argList 2105 ); 2106 2107 /// Draw image into internal debug text buffer. 2108 /// 2109 /// @param[in] _x, _y 2D position from top-left. 2110 /// @param[in] _width, _height Image width and height. 2111 /// @param[in] _data Raw image data (character/attribute raw encoding). 2112 /// @param[in] _pitch Image pitch in bytes. 2113 /// 2114 /// @attention C99 equivalent is `bgfx_dbg_text_image`. 2115 /// 2116 void dbgTextImage( 2117 uint16_t _x 2118 , uint16_t _y 2119 , uint16_t _width 2120 , uint16_t _height 2121 , const void* _data 2122 , uint16_t _pitch 2123 ); 2124 2125 /// Create static index buffer. 2126 /// 2127 /// @param[in] _mem Index buffer data. 2128 /// @param[in] _flags Buffer creation flags. 2129 /// - `BGFX_BUFFER_NONE` - No flags. 2130 /// - `BGFX_BUFFER_COMPUTE_READ` - Buffer will be read from by compute shader. 2131 /// - `BGFX_BUFFER_COMPUTE_WRITE` - Buffer will be written into by compute shader. When buffer 2132 /// is created with `BGFX_BUFFER_COMPUTE_WRITE` flag it cannot be updated from CPU. 2133 /// - `BGFX_BUFFER_COMPUTE_READ_WRITE` - Buffer will be used for read/write by compute shader. 2134 /// - `BGFX_BUFFER_ALLOW_RESIZE` - Buffer will resize on buffer update if a different amount of 2135 /// data is passed. If this flag is not specified, and more data is passed on update, the buffer 2136 /// will be trimmed to fit the existing buffer size. This flag has effect only on dynamic 2137 /// buffers. 2138 /// - `BGFX_BUFFER_INDEX32` - Buffer is using 32-bit indices. This flag has effect only on 2139 /// index buffers. 2140 /// 2141 /// @attention C99 equivalent is `bgfx_create_index_buffer`. 2142 /// 2143 IndexBufferHandle createIndexBuffer( 2144 const Memory* _mem 2145 , uint16_t _flags = BGFX_BUFFER_NONE 2146 ); 2147 2148 /// Set static index buffer debug name. 2149 /// 2150 /// @param[in] _handle Static index buffer handle. 2151 /// @param[in] _name Static index buffer name. 2152 /// @param[in] _len Static index buffer name length (if length is INT32_MAX, it's expected 2153 /// that _name is zero terminated string. 2154 /// 2155 /// @attention C99 equivalent is `bgfx_set_index_buffer_name`. 2156 /// 2157 void setName( 2158 IndexBufferHandle _handle 2159 , const char* _name 2160 , int32_t _len = INT32_MAX 2161 ); 2162 2163 /// Destroy static index buffer. 2164 /// 2165 /// @param[in] _handle Static index buffer handle. 2166 /// 2167 /// @attention C99 equivalent is `bgfx_destroy_index_buffer`. 2168 /// 2169 void destroy(IndexBufferHandle _handle); 2170 2171 /// Create vertex layout. 2172 /// 2173 /// @attention C99 equivalent is `bgfx_create_vertex_layout`. 2174 /// 2175 VertexLayoutHandle createVertexLayout(const VertexLayout& _layout); 2176 2177 /// Destroy vertex layout. 2178 /// 2179 /// @attention C99 equivalent is `bgfx_destroy_vertex_layout`. 2180 /// 2181 void destroy(VertexLayoutHandle _handle); 2182 2183 /// Create static vertex buffer. 2184 /// 2185 /// @param[in] _mem Vertex buffer data. 2186 /// @param[in] _layout Vertex layout. 2187 /// @param[in] _flags Buffer creation flags. 2188 /// - `BGFX_BUFFER_NONE` - No flags. 2189 /// - `BGFX_BUFFER_COMPUTE_READ` - Buffer will be read from by compute shader. 2190 /// - `BGFX_BUFFER_COMPUTE_WRITE` - Buffer will be written into by compute shader. When buffer 2191 /// is created with `BGFX_BUFFER_COMPUTE_WRITE` flag it cannot be updated from CPU. 2192 /// - `BGFX_BUFFER_COMPUTE_READ_WRITE` - Buffer will be used for read/write by compute shader. 2193 /// - `BGFX_BUFFER_ALLOW_RESIZE` - Buffer will resize on buffer update if a different amount of 2194 /// data is passed. If this flag is not specified, and more data is passed on update, the buffer 2195 /// will be trimmed to fit the existing buffer size. This flag has effect only on dynamic 2196 /// buffers. 2197 /// - `BGFX_BUFFER_INDEX32` - Buffer is using 32-bit indices. This flag has effect only on 2198 /// index buffers. 2199 /// @returns Static vertex buffer handle. 2200 /// 2201 /// @attention C99 equivalent is `bgfx_create_vertex_buffer`. 2202 /// 2203 VertexBufferHandle createVertexBuffer( 2204 const Memory* _mem 2205 , const VertexLayout& _layout 2206 , uint16_t _flags = BGFX_BUFFER_NONE 2207 ); 2208 2209 /// Set static vertex buffer debug name. 2210 /// 2211 /// @param[in] _handle Static vertex buffer handle. 2212 /// @param[in] _name Static vertex buffer name. 2213 /// @param[in] _len Static vertex buffer name length (if length is INT32_MAX, it's expected 2214 /// that _name is zero terminated string. 2215 /// 2216 /// @attention C99 equivalent is `bgfx_set_vertex_buffer_name`. 2217 /// 2218 void setName( 2219 VertexBufferHandle _handle 2220 , const char* _name 2221 , int32_t _len = INT32_MAX 2222 ); 2223 2224 /// Destroy static vertex buffer. 2225 /// 2226 /// @param[in] _handle Static vertex buffer handle. 2227 /// 2228 /// @attention C99 equivalent is `bgfx_destroy_vertex_buffer`. 2229 /// 2230 void destroy(VertexBufferHandle _handle); 2231 2232 /// Create empty dynamic index buffer. 2233 /// 2234 /// @param[in] _num Number of indices. 2235 /// @param[in] _flags Buffer creation flags. 2236 /// - `BGFX_BUFFER_NONE` - No flags. 2237 /// - `BGFX_BUFFER_COMPUTE_READ` - Buffer will be read from by compute shader. 2238 /// - `BGFX_BUFFER_COMPUTE_WRITE` - Buffer will be written into by compute shader. When buffer 2239 /// is created with `BGFX_BUFFER_COMPUTE_WRITE` flag it cannot be updated from CPU. 2240 /// - `BGFX_BUFFER_COMPUTE_READ_WRITE` - Buffer will be used for read/write by compute shader. 2241 /// - `BGFX_BUFFER_ALLOW_RESIZE` - Buffer will resize on buffer update if a different amount of 2242 /// data is passed. If this flag is not specified, and more data is passed on update, the buffer 2243 /// will be trimmed to fit the existing buffer size. This flag has effect only on dynamic 2244 /// buffers. 2245 /// - `BGFX_BUFFER_INDEX32` - Buffer is using 32-bit indices. This flag has effect only on 2246 /// index buffers. 2247 /// @returns Dynamic index buffer handle. 2248 /// 2249 /// @attention C99 equivalent is `bgfx_create_dynamic_index_buffer`. 2250 /// 2251 DynamicIndexBufferHandle createDynamicIndexBuffer( 2252 uint32_t _num 2253 , uint16_t _flags = BGFX_BUFFER_NONE 2254 ); 2255 2256 /// Create dynamic index buffer and initialized it. 2257 /// 2258 /// @param[in] _mem Index buffer data. 2259 /// @param[in] _flags Buffer creation flags. 2260 /// - `BGFX_BUFFER_NONE` - No flags. 2261 /// - `BGFX_BUFFER_COMPUTE_READ` - Buffer will be read from by compute shader. 2262 /// - `BGFX_BUFFER_COMPUTE_WRITE` - Buffer will be written into by compute shader. When buffer 2263 /// is created with `BGFX_BUFFER_COMPUTE_WRITE` flag it cannot be updated from CPU. 2264 /// - `BGFX_BUFFER_COMPUTE_READ_WRITE` - Buffer will be used for read/write by compute shader. 2265 /// - `BGFX_BUFFER_ALLOW_RESIZE` - Buffer will resize on buffer update if a different amount of 2266 /// data is passed. If this flag is not specified, and more data is passed on update, the buffer 2267 /// will be trimmed to fit the existing buffer size. This flag has effect only on dynamic 2268 /// buffers. 2269 /// - `BGFX_BUFFER_INDEX32` - Buffer is using 32-bit indices. This flag has effect only on 2270 /// index buffers. 2271 /// @returns Dynamic index buffer handle. 2272 /// 2273 /// @attention C99 equivalent is `bgfx_create_dynamic_index_buffer_mem`. 2274 /// 2275 DynamicIndexBufferHandle createDynamicIndexBuffer( 2276 const Memory* _mem 2277 , uint16_t _flags = BGFX_BUFFER_NONE 2278 ); 2279 2280 /// Update dynamic index buffer. 2281 /// 2282 /// @param[in] _handle Dynamic index buffer handle. 2283 /// @param[in] _startIndex Start index. 2284 /// @param[in] _mem Index buffer data. 2285 /// 2286 /// @attention C99 equivalent is `bgfx_update_dynamic_index_buffer`. 2287 /// 2288 void update( 2289 DynamicIndexBufferHandle _handle 2290 , uint32_t _startIndex 2291 , const Memory* _mem 2292 ); 2293 2294 /// Destroy dynamic index buffer. 2295 /// 2296 /// @param[in] _handle Dynamic index buffer handle. 2297 /// 2298 /// @attention C99 equivalent is `bgfx_destroy_dynamic_index_buffer`. 2299 /// 2300 void destroy(DynamicIndexBufferHandle _handle); 2301 2302 /// Create empty dynamic vertex buffer. 2303 /// 2304 /// @param[in] _num Number of vertices. 2305 /// @param[in] _layout Vertex layout. 2306 /// @param[in] _flags Buffer creation flags. 2307 /// - `BGFX_BUFFER_NONE` - No flags. 2308 /// - `BGFX_BUFFER_COMPUTE_READ` - Buffer will be read from by compute shader. 2309 /// - `BGFX_BUFFER_COMPUTE_WRITE` - Buffer will be written into by compute shader. When buffer 2310 /// is created with `BGFX_BUFFER_COMPUTE_WRITE` flag it cannot be updated from CPU. 2311 /// - `BGFX_BUFFER_COMPUTE_READ_WRITE` - Buffer will be used for read/write by compute shader. 2312 /// - `BGFX_BUFFER_ALLOW_RESIZE` - Buffer will resize on buffer update if a different amount of 2313 /// data is passed. If this flag is not specified, and more data is passed on update, the buffer 2314 /// will be trimmed to fit the existing buffer size. This flag has effect only on dynamic 2315 /// buffers. 2316 /// - `BGFX_BUFFER_INDEX32` - Buffer is using 32-bit indices. This flag has effect only on 2317 /// index buffers. 2318 /// @returns Dynamic vertex buffer handle. 2319 /// 2320 /// @attention C99 equivalent is `bgfx_create_dynamic_vertex_buffer`. 2321 /// 2322 DynamicVertexBufferHandle createDynamicVertexBuffer( 2323 uint32_t _num 2324 , const VertexLayout& _layout 2325 , uint16_t _flags = BGFX_BUFFER_NONE 2326 ); 2327 2328 /// Create dynamic vertex buffer and initialize it. 2329 /// 2330 /// @param[in] _mem Vertex buffer data. 2331 /// @param[in] _layout Vertex layout. 2332 /// @param[in] _flags Buffer creation flags. 2333 /// - `BGFX_BUFFER_NONE` - No flags. 2334 /// - `BGFX_BUFFER_COMPUTE_READ` - Buffer will be read from by compute shader. 2335 /// - `BGFX_BUFFER_COMPUTE_WRITE` - Buffer will be written into by compute shader. When buffer 2336 /// is created with `BGFX_BUFFER_COMPUTE_WRITE` flag it cannot be updated from CPU. 2337 /// - `BGFX_BUFFER_COMPUTE_READ_WRITE` - Buffer will be used for read/write by compute shader. 2338 /// - `BGFX_BUFFER_ALLOW_RESIZE` - Buffer will resize on buffer update if a different amount of 2339 /// data is passed. If this flag is not specified, and more data is passed on update, the buffer 2340 /// will be trimmed to fit the existing buffer size. This flag has effect only on dynamic 2341 /// buffers. 2342 /// - `BGFX_BUFFER_INDEX32` - Buffer is using 32-bit indices. This flag has effect only on 2343 /// index buffers. 2344 /// @returns Dynamic vertex buffer handle. 2345 /// 2346 /// @attention C99 equivalent is `bgfx_create_dynamic_vertex_buffer_mem`. 2347 /// 2348 DynamicVertexBufferHandle createDynamicVertexBuffer( 2349 const Memory* _mem 2350 , const VertexLayout& _layout 2351 , uint16_t _flags = BGFX_BUFFER_NONE 2352 ); 2353 2354 /// Update dynamic vertex buffer. 2355 /// 2356 /// @param[in] _handle Dynamic vertex buffer handle. 2357 /// @param[in] _startVertex Start vertex. 2358 /// @param[in] _mem Vertex buffer data. 2359 /// 2360 /// @attention C99 equivalent is `bgfx_update_dynamic_vertex_buffer`. 2361 /// 2362 void update( 2363 DynamicVertexBufferHandle _handle 2364 , uint32_t _startVertex 2365 , const Memory* _mem 2366 ); 2367 2368 /// Destroy dynamic vertex buffer. 2369 /// 2370 /// @param[in] _handle Dynamic vertex buffer handle. 2371 /// 2372 /// @attention C99 equivalent is `bgfx_destroy_dynamic_vertex_buffer`. 2373 /// 2374 void destroy(DynamicVertexBufferHandle _handle); 2375 2376 /// Returns number of requested or maximum available indices. 2377 /// 2378 /// @param[in] _num Number of required indices. 2379 /// 2380 /// @attention C99 equivalent is `bgfx_get_avail_transient_index_buffer`. 2381 /// 2382 uint32_t getAvailTransientIndexBuffer(uint32_t _num); 2383 2384 /// Returns number of requested or maximum available vertices. 2385 /// 2386 /// @param[in] _num Number of required vertices. 2387 /// @param[in] _layout Vertex layout. 2388 /// 2389 /// @attention C99 equivalent is `bgfx_get_avail_transient_vertex_buffer`. 2390 /// 2391 uint32_t getAvailTransientVertexBuffer( 2392 uint32_t _num 2393 , const VertexLayout& _layout 2394 ); 2395 2396 /// Returns number of requested or maximum available instance buffer slots. 2397 /// 2398 /// @param[in] _num Number of required instances. 2399 /// @param[in] _stride Stride per instance. 2400 /// 2401 /// @attention C99 equivalent is `bgfx_get_avail_instance_data_buffer`. 2402 /// 2403 uint32_t getAvailInstanceDataBuffer( 2404 uint32_t _num 2405 , uint16_t _stride 2406 ); 2407 2408 /// Allocate transient index buffer. 2409 /// 2410 /// @param[out] _tib TransientIndexBuffer structure is filled and is valid 2411 /// for the duration of frame, and it can be reused for multiple draw 2412 /// calls. 2413 /// @param[in] _num Number of indices to allocate. 2414 /// 2415 /// @remarks 2416 /// Only 16-bit index buffer is supported. 2417 /// 2418 /// @attention C99 equivalent is `bgfx_alloc_transient_index_buffer`. 2419 /// 2420 void allocTransientIndexBuffer( 2421 TransientIndexBuffer* _tib 2422 , uint32_t _num 2423 ); 2424 2425 /// Allocate transient vertex buffer. 2426 /// 2427 /// @param[out] _tvb TransientVertexBuffer structure is filled and is valid 2428 /// for the duration of frame, and it can be reused for multiple draw 2429 /// calls. 2430 /// @param[in] _num Number of vertices to allocate. 2431 /// @param[in] _layout Vertex layout. 2432 /// 2433 /// @attention C99 equivalent is `bgfx_alloc_transient_vertex_buffer`. 2434 /// 2435 void allocTransientVertexBuffer( 2436 TransientVertexBuffer* _tvb 2437 , uint32_t _num 2438 , const VertexLayout& _layout 2439 ); 2440 2441 /// Check for required space and allocate transient vertex and index 2442 /// buffers. If both space requirements are satisfied function returns 2443 /// true. 2444 /// 2445 /// @remarks 2446 /// Only 16-bit index buffer is supported. 2447 /// 2448 /// @attention C99 equivalent is `bgfx_alloc_transient_buffers`. 2449 /// 2450 bool allocTransientBuffers( 2451 TransientVertexBuffer* _tvb 2452 , const VertexLayout& _layout 2453 , uint32_t _numVertices 2454 , TransientIndexBuffer* _tib 2455 , uint32_t _numIndices 2456 ); 2457 2458 /// Allocate instance data buffer. 2459 /// 2460 /// @param[out] _idb InstanceDataBuffer structure is filled and is valid 2461 /// for duration of frame, and it can be reused for multiple draw 2462 /// calls. 2463 /// @param[in] _num Number of instances. 2464 /// @param[in] _stride Instance stride. Must be multiple of 16. 2465 /// 2466 /// @attention C99 equivalent is `bgfx_alloc_instance_data_buffer`. 2467 /// 2468 void allocInstanceDataBuffer( 2469 InstanceDataBuffer* _idb 2470 , uint32_t _num 2471 , uint16_t _stride 2472 ); 2473 2474 /// Create draw indirect buffer. 2475 /// 2476 /// @param[in] _num Number of indirect calls. 2477 /// @returns Indirect buffer handle. 2478 /// 2479 /// @attention C99 equivalent is `bgfx_create_indirect_buffer`. 2480 /// 2481 IndirectBufferHandle createIndirectBuffer(uint32_t _num); 2482 2483 /// Destroy draw indirect buffer. 2484 /// 2485 /// @param[in] _handle Indirect buffer handle. 2486 /// 2487 /// @attention C99 equivalent is `bgfx_destroy_indirect_buffer`. 2488 /// 2489 void destroy(IndirectBufferHandle _handle); 2490 2491 /// Create shader from memory buffer. 2492 /// 2493 /// @attention C99 equivalent is `bgfx_create_shader`. 2494 /// 2495 ShaderHandle createShader(const Memory* _mem); 2496 2497 /// Returns the number of uniforms and uniform handles used inside a shader. 2498 /// 2499 /// @param[in] _handle Shader handle. 2500 /// @param[in] _uniforms UniformHandle array where data will be stored. 2501 /// @param[in] _max Maximum capacity of array. 2502 /// @returns Number of uniforms used by shader. 2503 /// 2504 /// @remarks 2505 /// Only non-predefined uniforms are returned. 2506 /// 2507 /// @attention C99 equivalent is `bgfx_get_shader_uniforms`. 2508 /// 2509 uint16_t getShaderUniforms( 2510 ShaderHandle _handle 2511 , UniformHandle* _uniforms = NULL 2512 , uint16_t _max = 0 2513 ); 2514 2515 /// Set shader debug name. 2516 /// 2517 /// @param[in] _handle Shader handle. 2518 /// @param[in] _name Shader name. 2519 /// @param[in] _len Shader name length (if length is INT32_MAX, it's expected 2520 /// that _name is zero terminated string. 2521 /// 2522 /// @attention C99 equivalent is `bgfx_set_shader_name`. 2523 /// 2524 void setName( 2525 ShaderHandle _handle 2526 , const char* _name 2527 , int32_t _len = INT32_MAX 2528 ); 2529 2530 /// Destroy shader. Once a shader program is created with _handle, 2531 /// it is safe to destroy that shader. 2532 /// 2533 /// @param[in] _handle Shader handle. 2534 /// 2535 /// @attention C99 equivalent is `bgfx_destroy_shader`. 2536 /// 2537 void destroy(ShaderHandle _handle); 2538 2539 /// Create program with vertex and fragment shaders. 2540 /// 2541 /// @param[in] _vsh Vertex shader. 2542 /// @param[in] _fsh Fragment shader. 2543 /// @param[in] _destroyShaders If true, shaders will be destroyed when 2544 /// program is destroyed. 2545 /// @returns Program handle if vertex shader output and fragment shader 2546 /// input are matching, otherwise returns invalid program handle. 2547 /// 2548 /// @attention C99 equivalent is `bgfx_create_program`. 2549 /// 2550 ProgramHandle createProgram( 2551 ShaderHandle _vsh 2552 , ShaderHandle _fsh 2553 , bool _destroyShaders = false 2554 ); 2555 2556 /// Create program with compute shader. 2557 /// 2558 /// @param[in] _csh Compute shader. 2559 /// @param[in] _destroyShader If true, shader will be destroyed when 2560 /// program is destroyed. 2561 /// @returns Program handle. 2562 /// 2563 /// @attention C99 equivalent is `bgfx_create_compute_program`. 2564 /// 2565 ProgramHandle createProgram( 2566 ShaderHandle _csh 2567 , bool _destroyShader = false 2568 ); 2569 2570 /// Destroy program. 2571 /// 2572 /// @param[in] _handle Program handle. 2573 /// 2574 /// @attention C99 equivalent is `bgfx_destroy_program`. 2575 /// 2576 void destroy(ProgramHandle _handle); 2577 2578 /// Validate texture parameters. 2579 /// 2580 /// @param[in] _depth Depth dimension of volume texture. 2581 /// @param[in] _cubeMap Indicates that texture contains cubemap. 2582 /// @param[in] _numLayers Number of layers in texture array. 2583 /// @param[in] _format Texture format. See: `TextureFormat::Enum`. 2584 /// @param[in] _flags Texture flags. See `BGFX_TEXTURE_*`. 2585 /// @returns True if texture can be successfully created. 2586 /// 2587 /// @attention C99 equivalent is `bgfx_is_texture_valid`. 2588 /// 2589 bool isTextureValid( 2590 uint16_t _depth 2591 , bool _cubeMap 2592 , uint16_t _numLayers 2593 , TextureFormat::Enum _format 2594 , uint64_t _flags 2595 ); 2596 2597 /// Calculate amount of memory required for texture. 2598 /// 2599 /// @param[out] _info Resulting texture info structure. See: `TextureInfo`. 2600 /// @param[in] _width Width. 2601 /// @param[in] _height Height. 2602 /// @param[in] _depth Depth dimension of volume texture. 2603 /// @param[in] _cubeMap Indicates that texture contains cubemap. 2604 /// @param[in] _hasMips Indicates that texture contains full mip-map chain. 2605 /// @param[in] _numLayers Number of layers in texture array. 2606 /// @param[in] _format Texture format. See: `TextureFormat::Enum`. 2607 /// 2608 /// @attention C99 equivalent is `bgfx_calc_texture_size`. 2609 /// 2610 void calcTextureSize( 2611 TextureInfo& _info 2612 , uint16_t _width 2613 , uint16_t _height 2614 , uint16_t _depth 2615 , bool _cubeMap 2616 , bool _hasMips 2617 , uint16_t _numLayers 2618 , TextureFormat::Enum _format 2619 ); 2620 2621 /// Create texture from memory buffer. 2622 /// 2623 /// @param[in] _mem DDS, KTX or PVR texture data. 2624 /// @param[in] _flags Texture creation (see `BGFX_TEXTURE_*`.), and sampler (see `BGFX_SAMPLER_*`) 2625 /// flags. Default texture sampling mode is linear, and wrap mode is repeat. 2626 /// - `BGFX_SAMPLER_[U/V/W]_[MIRROR/CLAMP]` - Mirror or clamp to edge wrap 2627 /// mode. 2628 /// - `BGFX_SAMPLER_[MIN/MAG/MIP]_[POINT/ANISOTROPIC]` - Point or anisotropic 2629 /// sampling. 2630 /// 2631 /// @param[in] _skip Skip top level mips when parsing texture. 2632 /// @param[out] _info When non-`NULL` is specified it returns parsed texture information. 2633 /// @returns Texture handle. 2634 /// 2635 /// @attention C99 equivalent is `bgfx_create_texture`. 2636 /// 2637 TextureHandle createTexture( 2638 const Memory* _mem 2639 , uint64_t _flags = BGFX_TEXTURE_NONE|BGFX_SAMPLER_NONE 2640 , uint8_t _skip = 0 2641 , TextureInfo* _info = NULL 2642 ); 2643 2644 /// Create 2D texture. 2645 /// 2646 /// @param[in] _width Width. 2647 /// @param[in] _height Height. 2648 /// @param[in] _hasMips Indicates that texture contains full mip-map chain. 2649 /// @param[in] _numLayers Number of layers in texture array. Must be 1 if caps 2650 /// `BGFX_CAPS_TEXTURE_2D_ARRAY` flag is not set. 2651 /// @param[in] _format Texture format. See: `TextureFormat::Enum`. 2652 /// @param[in] _flags Texture creation (see `BGFX_TEXTURE_*`.), and sampler (see `BGFX_SAMPLER_*`) 2653 /// flags. Default texture sampling mode is linear, and wrap mode is repeat. 2654 /// - `BGFX_SAMPLER_[U/V/W]_[MIRROR/CLAMP]` - Mirror or clamp to edge wrap 2655 /// mode. 2656 /// - `BGFX_SAMPLER_[MIN/MAG/MIP]_[POINT/ANISOTROPIC]` - Point or anisotropic 2657 /// sampling. 2658 /// 2659 /// @param[in] _mem Texture data. If `_mem` is non-NULL, created texture will be immutable. If 2660 /// `_mem` is NULL content of the texture is uninitialized. When `_numLayers` is more than 2661 /// 1, expected memory layout is texture and all mips together for each array element. 2662 /// 2663 /// @attention C99 equivalent is `bgfx_create_texture_2d`. 2664 /// 2665 TextureHandle createTexture2D( 2666 uint16_t _width 2667 , uint16_t _height 2668 , bool _hasMips 2669 , uint16_t _numLayers 2670 , TextureFormat::Enum _format 2671 , uint64_t _flags = BGFX_TEXTURE_NONE|BGFX_SAMPLER_NONE 2672 , const Memory* _mem = NULL 2673 ); 2674 2675 /// Create texture with size based on backbuffer ratio. Texture will maintain ratio 2676 /// if back buffer resolution changes. 2677 /// 2678 /// @param[in] _ratio Frame buffer size in respect to back-buffer size. See: 2679 /// `BackbufferRatio::Enum`. 2680 /// @param[in] _hasMips Indicates that texture contains full mip-map chain. 2681 /// @param[in] _numLayers Number of layers in texture array. Must be 1 if caps 2682 /// `BGFX_CAPS_TEXTURE_2D_ARRAY` flag is not set. 2683 /// @param[in] _format Texture format. See: `TextureFormat::Enum`. 2684 /// @param[in] _flags Texture creation (see `BGFX_TEXTURE_*`.), and sampler (see `BGFX_SAMPLER_*`) 2685 /// flags. Default texture sampling mode is linear, and wrap mode is repeat. 2686 /// - `BGFX_SAMPLER_[U/V/W]_[MIRROR/CLAMP]` - Mirror or clamp to edge wrap 2687 /// mode. 2688 /// - `BGFX_SAMPLER_[MIN/MAG/MIP]_[POINT/ANISOTROPIC]` - Point or anisotropic 2689 /// sampling. 2690 /// 2691 /// @attention C99 equivalent is `bgfx_create_texture_2d_scaled`. 2692 /// 2693 TextureHandle createTexture2D( 2694 BackbufferRatio::Enum _ratio 2695 , bool _hasMips 2696 , uint16_t _numLayers 2697 , TextureFormat::Enum _format 2698 , uint64_t _flags = BGFX_TEXTURE_NONE|BGFX_SAMPLER_NONE 2699 ); 2700 2701 /// Create 3D texture. 2702 /// 2703 /// @param[in] _width Width. 2704 /// @param[in] _height Height. 2705 /// @param[in] _depth Depth. 2706 /// @param[in] _hasMips Indicates that texture contains full mip-map chain. 2707 /// @param[in] _format Texture format. See: `TextureFormat::Enum`. 2708 /// @param[in] _flags Texture creation (see `BGFX_TEXTURE_*`.), and sampler (see `BGFX_SAMPLER_*`) 2709 /// flags. Default texture sampling mode is linear, and wrap mode is repeat. 2710 /// - `BGFX_SAMPLER_[U/V/W]_[MIRROR/CLAMP]` - Mirror or clamp to edge wrap 2711 /// mode. 2712 /// - `BGFX_SAMPLER_[MIN/MAG/MIP]_[POINT/ANISOTROPIC]` - Point or anisotropic 2713 /// sampling. 2714 /// 2715 /// @param[in] _mem Texture data. If `_mem` is non-NULL, created texture will be immutable. If 2716 /// `_mem` is NULL content of the texture is uninitialized. 2717 /// 2718 /// @attention C99 equivalent is `bgfx_create_texture_3d`. 2719 /// 2720 TextureHandle createTexture3D( 2721 uint16_t _width 2722 , uint16_t _height 2723 , uint16_t _depth 2724 , bool _hasMips 2725 , TextureFormat::Enum _format 2726 , uint64_t _flags = BGFX_TEXTURE_NONE|BGFX_SAMPLER_NONE 2727 , const Memory* _mem = NULL 2728 ); 2729 2730 /// Create Cube texture. 2731 /// 2732 /// @param[in] _size Cube side size. 2733 /// @param[in] _hasMips Indicates that texture contains full mip-map chain. 2734 /// @param[in] _numLayers Number of layers in texture array. Must be 1 if caps 2735 /// `BGFX_CAPS_TEXTURE_CUBE_ARRAY` flag is not set. 2736 /// @param[in] _format Texture format. See: `TextureFormat::Enum`. 2737 /// @param[in] _flags Texture creation (see `BGFX_TEXTURE_*`.), and sampler (see `BGFX_SAMPLER_*`) 2738 /// flags. Default texture sampling mode is linear, and wrap mode is repeat. 2739 /// - `BGFX_SAMPLER_[U/V/W]_[MIRROR/CLAMP]` - Mirror or clamp to edge wrap 2740 /// mode. 2741 /// - `BGFX_SAMPLER_[MIN/MAG/MIP]_[POINT/ANISOTROPIC]` - Point or anisotropic 2742 /// sampling. 2743 /// 2744 /// @param[in] _mem Texture data. If `_mem` is non-NULL, created texture will be immutable. If 2745 /// `_mem` is NULL content of the texture is uninitialized. When `_numLayers` is more than 2746 /// 1, expected memory layout is texture and all mips together for each array element. 2747 /// 2748 /// @attention C99 equivalent is `bgfx_create_texture_cube`. 2749 /// 2750 TextureHandle createTextureCube( 2751 uint16_t _size 2752 , bool _hasMips 2753 , uint16_t _numLayers 2754 , TextureFormat::Enum _format 2755 , uint64_t _flags = BGFX_TEXTURE_NONE|BGFX_SAMPLER_NONE 2756 , const Memory* _mem = NULL 2757 ); 2758 2759 /// Update 2D texture. 2760 /// 2761 /// @param[in] _handle Texture handle. 2762 /// @param[in] _layer Layers in texture array. 2763 /// @param[in] _mip Mip level. 2764 /// @param[in] _x X offset in texture. 2765 /// @param[in] _y Y offset in texture. 2766 /// @param[in] _width Width of texture block. 2767 /// @param[in] _height Height of texture block. 2768 /// @param[in] _mem Texture update data. 2769 /// @param[in] _pitch Pitch of input image (bytes). When _pitch is set to 2770 /// UINT16_MAX, it will be calculated internally based on _width. 2771 /// 2772 /// @attention It's valid to update only mutable texture. See `bgfx::createTexture2D` for more info. 2773 /// 2774 /// @attention C99 equivalent is `bgfx_update_texture_2d`. 2775 /// 2776 void updateTexture2D( 2777 TextureHandle _handle 2778 , uint16_t _layer 2779 , uint8_t _mip 2780 , uint16_t _x 2781 , uint16_t _y 2782 , uint16_t _width 2783 , uint16_t _height 2784 , const Memory* _mem 2785 , uint16_t _pitch = UINT16_MAX 2786 ); 2787 2788 /// Update 3D texture. 2789 /// 2790 /// @param[in] _handle Texture handle. 2791 /// @param[in] _mip Mip level. 2792 /// @param[in] _x X offset in texture. 2793 /// @param[in] _y Y offset in texture. 2794 /// @param[in] _z Z offset in texture. 2795 /// @param[in] _width Width of texture block. 2796 /// @param[in] _height Height of texture block. 2797 /// @param[in] _depth Depth of texture block. 2798 /// @param[in] _mem Texture update data. 2799 /// 2800 /// @attention It's valid to update only mutable texture. See `bgfx::createTexture3D` for more info. 2801 /// 2802 /// @attention C99 equivalent is `bgfx_update_texture_3d`. 2803 /// 2804 void updateTexture3D( 2805 TextureHandle _handle 2806 , uint8_t _mip 2807 , uint16_t _x 2808 , uint16_t _y 2809 , uint16_t _z 2810 , uint16_t _width 2811 , uint16_t _height 2812 , uint16_t _depth 2813 , const Memory* _mem 2814 ); 2815 2816 /// Update Cube texture. 2817 /// 2818 /// @param[in] _handle Texture handle. 2819 /// @param[in] _layer Layers in texture array. 2820 /// @param[in] _side Cubemap side `BGFX_CUBE_MAP_<POSITIVE or NEGATIVE>_<X, Y or Z>`, 2821 /// where 0 is +X, 1 is -X, 2 is +Y, 3 is -Y, 4 is +Z, and 5 is -Z. 2822 /// 2823 /// +----------+ 2824 /// |-z 2| 2825 /// | ^ +y | 2826 /// | | | Unfolded cube: 2827 /// | +---->+x | 2828 /// +----------+----------+----------+----------+ 2829 /// |+y 1|+y 4|+y 0|+y 5| 2830 /// | ^ -x | ^ +z | ^ +x | ^ -z | 2831 /// | | | | | | | | | 2832 /// | +---->+z | +---->+x | +---->-z | +---->-x | 2833 /// +----------+----------+----------+----------+ 2834 /// |+z 3| 2835 /// | ^ -y | 2836 /// | | | 2837 /// | +---->+x | 2838 /// +----------+ 2839 /// 2840 /// @param[in] _mip Mip level. 2841 /// @param[in] _x X offset in texture. 2842 /// @param[in] _y Y offset in texture. 2843 /// @param[in] _width Width of texture block. 2844 /// @param[in] _height Height of texture block. 2845 /// @param[in] _mem Texture update data. 2846 /// @param[in] _pitch Pitch of input image (bytes). When _pitch is set to 2847 /// UINT16_MAX, it will be calculated internally based on _width. 2848 /// 2849 /// @attention It's valid to update only mutable texture. See `bgfx::createTextureCube` for more info. 2850 /// 2851 /// @attention C99 equivalent is `bgfx_update_texture_cube`. 2852 /// 2853 void updateTextureCube( 2854 TextureHandle _handle 2855 , uint16_t _layer 2856 , uint8_t _side 2857 , uint8_t _mip 2858 , uint16_t _x 2859 , uint16_t _y 2860 , uint16_t _width 2861 , uint16_t _height 2862 , const Memory* _mem 2863 , uint16_t _pitch = UINT16_MAX 2864 ); 2865 2866 /// Read back texture content. 2867 /// 2868 /// @param[in] _handle Texture handle. 2869 /// @param[in] _data Destination buffer. 2870 /// @param[in] _mip Mip level. 2871 /// 2872 /// @returns Frame number when the result will be available. See: `bgfx::frame`. 2873 /// 2874 /// @attention Texture must be created with `BGFX_TEXTURE_READ_BACK` flag. 2875 /// @attention Availability depends on: `BGFX_CAPS_TEXTURE_READ_BACK`. 2876 /// @attention C99 equivalent is `bgfx_read_texture`. 2877 /// 2878 uint32_t readTexture( 2879 TextureHandle _handle 2880 , void* _data 2881 , uint8_t _mip = 0 2882 ); 2883 2884 /// Set texture debug name. 2885 /// 2886 /// @param[in] _handle Texture handle. 2887 /// @param[in] _name Texture name. 2888 /// @param[in] _len Texture name length (if length is INT32_MAX, it's expected 2889 /// that _name is zero terminated string. 2890 /// 2891 /// @attention C99 equivalent is `bgfx_set_texture_name`. 2892 /// 2893 void setName( 2894 TextureHandle _handle 2895 , const char* _name 2896 , int32_t _len = INT32_MAX 2897 ); 2898 2899 /// Returns texture direct access pointer. 2900 /// 2901 /// @param[in] _handle Texture handle. 2902 /// 2903 /// @returns Pointer to texture memory. If returned pointer is `NULL` direct access 2904 /// is not available for this texture. If pointer is `UINTPTR_MAX` sentinel value 2905 /// it means texture is pending creation. Pointer returned can be cached and it 2906 /// will be valid until texture is destroyed. 2907 /// 2908 /// @attention Availability depends on: `BGFX_CAPS_TEXTURE_DIRECT_ACCESS`. This feature 2909 /// is available on GPUs that have unified memory architecture (UMA) support. 2910 /// 2911 /// @attention C99 equivalent is `bgfx_get_direct_access_ptr`. 2912 /// 2913 void* getDirectAccessPtr(TextureHandle _handle); 2914 2915 /// Destroy texture. 2916 /// 2917 /// @param[in] _handle Texture handle. 2918 /// 2919 /// @attention C99 equivalent is `bgfx_destroy_texture`. 2920 /// 2921 void destroy(TextureHandle _handle); 2922 2923 /// Create frame buffer (simple). 2924 /// 2925 /// @param[in] _width Texture width. 2926 /// @param[in] _height Texture height. 2927 /// @param[in] _format Texture format. See: `TextureFormat::Enum`. 2928 /// @param[in] _textureFlags Default texture sampling mode is linear, and wrap mode 2929 /// is repeat. 2930 /// - `BGFX_SAMPLER_[U/V/W]_[MIRROR/CLAMP]` - Mirror or clamp to edge wrap 2931 /// mode. 2932 /// - `BGFX_SAMPLER_[MIN/MAG/MIP]_[POINT/ANISOTROPIC]` - Point or anisotropic 2933 /// sampling. 2934 /// 2935 /// @returns Handle to frame buffer object. 2936 /// 2937 /// @attention C99 equivalent is `bgfx_create_frame_buffer`. 2938 /// 2939 FrameBufferHandle createFrameBuffer( 2940 uint16_t _width 2941 , uint16_t _height 2942 , TextureFormat::Enum _format 2943 , uint64_t _textureFlags = BGFX_SAMPLER_U_CLAMP|BGFX_SAMPLER_V_CLAMP 2944 ); 2945 2946 /// Create frame buffer with size based on backbuffer ratio. Frame buffer will maintain ratio 2947 /// if back buffer resolution changes. 2948 /// 2949 /// @param[in] _ratio Frame buffer size in respect to back-buffer size. See: 2950 /// `BackbufferRatio::Enum`. 2951 /// @param[in] _format Texture format. See: `TextureFormat::Enum`. 2952 /// @param[in] _textureFlags Default texture sampling mode is linear, and wrap mode 2953 /// is repeat. 2954 /// - `BGFX_SAMPLER_[U/V/W]_[MIRROR/CLAMP]` - Mirror or clamp to edge wrap 2955 /// mode. 2956 /// - `BGFX_SAMPLER_[MIN/MAG/MIP]_[POINT/ANISOTROPIC]` - Point or anisotropic 2957 /// sampling. 2958 /// 2959 /// @returns Handle to frame buffer object. 2960 /// 2961 /// @attention C99 equivalent is `bgfx_create_frame_buffer_scaled`. 2962 /// 2963 FrameBufferHandle createFrameBuffer( 2964 BackbufferRatio::Enum _ratio 2965 , TextureFormat::Enum _format 2966 , uint64_t _textureFlags = BGFX_SAMPLER_U_CLAMP|BGFX_SAMPLER_V_CLAMP 2967 ); 2968 2969 /// Create MRT frame buffer from texture handles (simple). 2970 /// 2971 /// @param[in] _num Number of texture attachments. 2972 /// @param[in] _handles Texture attachments. 2973 /// @param[in] _destroyTextures If true, textures will be destroyed when 2974 /// frame buffer is destroyed. 2975 /// 2976 /// @returns Handle to frame buffer object. 2977 /// 2978 /// @attention C99 equivalent is `bgfx_create_frame_buffer_from_handles`. 2979 /// 2980 FrameBufferHandle createFrameBuffer( 2981 uint8_t _num 2982 , const TextureHandle* _handles 2983 , bool _destroyTextures = false 2984 ); 2985 2986 /// Create MRT frame buffer from texture handles with specific layer and 2987 /// mip level. 2988 /// 2989 /// @param[in] _num Number of texture attachments. 2990 /// @param[in] _attachment Attachment texture info. See: `bgfx::Attachment`. 2991 /// @param[in] _destroyTextures If true, textures will be destroyed when 2992 /// frame buffer is destroyed. 2993 /// 2994 /// @returns Handle to frame buffer object. 2995 /// 2996 /// @attention C99 equivalent is `bgfx_create_frame_buffer_from_attachment`. 2997 /// 2998 FrameBufferHandle createFrameBuffer( 2999 uint8_t _num 3000 , const Attachment* _attachment 3001 , bool _destroyTextures = false 3002 ); 3003 3004 /// Create frame buffer for multiple window rendering. 3005 /// 3006 /// @param[in] _nwh OS' target native window handle. 3007 /// @param[in] _width Window back buffer width. 3008 /// @param[in] _height Window back buffer height. 3009 /// @param[in] _format Window back buffer color format. 3010 /// @param[in] _depthFormat Window back buffer depth format. 3011 /// 3012 /// @returns Handle to frame buffer object. 3013 /// 3014 /// @remarks 3015 /// Frame buffer cannot be used for sampling. 3016 /// 3017 /// @attention C99 equivalent is `bgfx_create_frame_buffer_from_nwh`. 3018 /// 3019 FrameBufferHandle createFrameBuffer( 3020 void* _nwh 3021 , uint16_t _width 3022 , uint16_t _height 3023 , TextureFormat::Enum _format = TextureFormat::Count 3024 , TextureFormat::Enum _depthFormat = TextureFormat::Count 3025 ); 3026 3027 /// Set frame buffer debug name. 3028 /// 3029 /// @param[in] _handle frame buffer handle. 3030 /// @param[in] _name frame buffer name. 3031 /// @param[in] _len frame buffer name length (if length is INT32_MAX, it's expected 3032 /// that _name is zero terminated string. 3033 /// 3034 /// @attention C99 equivalent is `bgfx_set_frame_buffer_name`. 3035 /// 3036 void setName( 3037 FrameBufferHandle _handle 3038 , const char* _name 3039 , int32_t _len = INT32_MAX 3040 ); 3041 3042 /// Obtain texture handle of frame buffer attachment. 3043 /// 3044 /// @param[in] _handle Frame buffer handle. 3045 /// @param[in] _attachment Frame buffer attachment index. 3046 /// 3047 /// @returns Returns invalid texture handle if attachment index is not 3048 /// correct, or frame buffer is created with native window handle. 3049 /// 3050 /// @attention C99 equivalent is `bgfx_get_texture`. 3051 /// 3052 TextureHandle getTexture( 3053 FrameBufferHandle _handle 3054 , uint8_t _attachment = 0 3055 ); 3056 3057 /// Destroy frame buffer. 3058 /// 3059 /// @param[in] _handle Frame buffer handle. 3060 /// 3061 /// @attention C99 equivalent is `bgfx_destroy_frame_buffer`. 3062 /// 3063 void destroy(FrameBufferHandle _handle); 3064 3065 /// Create shader uniform parameter. 3066 /// 3067 /// @param[in] _name Uniform name in shader. 3068 /// @param[in] _type Type of uniform (See: `bgfx::UniformType`). 3069 /// @param[in] _num Number of elements in array. 3070 /// 3071 /// @returns Handle to uniform object. 3072 /// 3073 /// @remarks 3074 /// 1. Uniform names are unique. It's valid to call `bgfx::createUniform` 3075 /// multiple times with the same uniform name. The library will always 3076 /// return the same handle, but the handle reference count will be 3077 /// incremented. This means that the same number of `bgfx::destroyUniform` 3078 /// must be called to properly destroy the uniform. 3079 /// 3080 /// 2. Predefined uniforms (declared in `bgfx_shader.sh`): 3081 /// - `u_viewRect vec4(x, y, width, height)` - view rectangle for current 3082 /// view, in pixels. 3083 /// - `u_viewTexel vec4(1.0/width, 1.0/height, undef, undef)` - inverse 3084 /// width and height 3085 /// - `u_view mat4` - view matrix 3086 /// - `u_invView mat4` - inverted view matrix 3087 /// - `u_proj mat4` - projection matrix 3088 /// - `u_invProj mat4` - inverted projection matrix 3089 /// - `u_viewProj mat4` - concatenated view projection matrix 3090 /// - `u_invViewProj mat4` - concatenated inverted view projection matrix 3091 /// - `u_model mat4[BGFX_CONFIG_MAX_BONES]` - array of model matrices. 3092 /// - `u_modelView mat4` - concatenated model view matrix, only first 3093 /// model matrix from array is used. 3094 /// - `u_modelViewProj mat4` - concatenated model view projection matrix. 3095 /// - `u_alphaRef float` - alpha reference value for alpha test. 3096 /// 3097 /// @attention C99 equivalent is `bgfx_create_uniform`. 3098 /// 3099 UniformHandle createUniform( 3100 const char* _name 3101 , UniformType::Enum _type 3102 , uint16_t _num = 1 3103 ); 3104 3105 /// Retrieve uniform info. 3106 /// 3107 /// @param[in] _handle Handle to uniform object. 3108 /// @param[out] _info Uniform info. 3109 /// 3110 /// @attention C99 equivalent is `bgfx_get_uniform_info`. 3111 /// 3112 void getUniformInfo( 3113 UniformHandle _handle 3114 , UniformInfo& _info 3115 ); 3116 3117 /// Destroy shader uniform parameter. 3118 /// 3119 /// @param[in] _handle Handle to uniform object. 3120 /// 3121 /// @attention C99 equivalent is `bgfx_destroy_uniform`. 3122 /// 3123 void destroy(UniformHandle _handle); 3124 3125 /// Create occlusion query. 3126 /// 3127 /// @returns Handle to occlusion query object. 3128 /// 3129 /// @attention C99 equivalent is `bgfx_create_occlusion_query`. 3130 /// 3131 OcclusionQueryHandle createOcclusionQuery(); 3132 3133 /// Retrieve occlusion query result from previous frame. 3134 /// 3135 /// @param[in] _handle Handle to occlusion query object. 3136 /// @param[out] _result Number of pixels that passed test. This argument 3137 /// can be `NULL` if result of occlusion query is not needed. 3138 /// @returns Occlusion query result. 3139 /// 3140 /// @attention C99 equivalent is `bgfx_get_result`. 3141 /// 3142 OcclusionQueryResult::Enum getResult( 3143 OcclusionQueryHandle _handle 3144 , int32_t* _result = NULL 3145 ); 3146 3147 /// Destroy occlusion query. 3148 /// 3149 /// @param[in] _handle Handle to occlusion query object. 3150 /// 3151 /// @attention C99 equivalent is `bgfx_destroy_occlusion_query`. 3152 /// 3153 void destroy(OcclusionQueryHandle _handle); 3154 3155 /// Set palette color value. 3156 /// 3157 /// @param[in] _index Index into palette. 3158 /// @param[in] _rgba Packed 32-bit RGBA value. 3159 /// 3160 /// @attention C99 equivalent is `bgfx_set_palette_color`. 3161 /// 3162 void setPaletteColor( 3163 uint8_t _index 3164 , uint32_t _rgba 3165 ); 3166 3167 /// Set palette color value. 3168 /// 3169 /// @param[in] _index Index into palette. 3170 /// @param[in] _r, _g, _b, _a RGBA floating point values. 3171 /// 3172 /// @attention C99 equivalent is `bgfx_set_palette_color`. 3173 /// 3174 void setPaletteColor( 3175 uint8_t _index 3176 , float _r 3177 , float _g 3178 , float _b 3179 , float _a 3180 ); 3181 3182 /// Set palette color value. 3183 /// 3184 /// @param[in] _index Index into palette. 3185 /// @param[in] _rgba RGBA floating point value. 3186 /// 3187 /// @attention C99 equivalent is `bgfx_set_palette_color`. 3188 /// 3189 void setPaletteColor( 3190 uint8_t _index 3191 , const float _rgba[4] 3192 ); 3193 3194 /// Set view name. 3195 /// 3196 /// @param[in] _id View id. 3197 /// @param[in] _name View name. 3198 /// 3199 /// @remarks 3200 /// This is debug only feature. 3201 /// 3202 /// In graphics debugger view name will appear as: 3203 /// 3204 /// "nnnce <view name>" 3205 /// ^ ^^ ^ 3206 /// | |+-- eye (L/R) 3207 /// | +--- compute (C) 3208 /// +------ view id 3209 /// 3210 /// @attention C99 equivalent is `bgfx_set_view_name`. 3211 /// 3212 void setViewName( 3213 ViewId _id 3214 , const char* _name 3215 ); 3216 3217 /// Set view rectangle. Draw primitive outside view will be clipped. 3218 /// 3219 /// @param[in] _id View id. 3220 /// @param[in] _x Position x from the left corner of the window. 3221 /// @param[in] _y Position y from the top corner of the window. 3222 /// @param[in] _width Width of view port region. 3223 /// @param[in] _height Height of view port region. 3224 /// 3225 /// @attention C99 equivalent is `bgfx_set_view_rect`. 3226 /// 3227 void setViewRect( 3228 ViewId _id 3229 , uint16_t _x 3230 , uint16_t _y 3231 , uint16_t _width 3232 , uint16_t _height 3233 ); 3234 3235 /// Set view rectangle. Draw primitive outside view will be clipped. 3236 /// 3237 /// @param[in] _id View id. 3238 /// @param[in] _x Position x from the left corner of the window. 3239 /// @param[in] _y Position y from the top corner of the window. 3240 /// @param[in] _ratio Width and height will be set in respect to back-buffer size. See: 3241 /// `BackbufferRatio::Enum`. 3242 /// 3243 /// @attention C99 equivalent is `bgfx_set_view_rect_auto`. 3244 /// 3245 void setViewRect( 3246 ViewId _id 3247 , uint16_t _x 3248 , uint16_t _y 3249 , BackbufferRatio::Enum _ratio 3250 ); 3251 3252 /// Set view scissor. Draw primitive outside view will be clipped. When 3253 /// _x, _y, _width and _height are set to 0, scissor will be disabled. 3254 /// 3255 /// @param[in] _id View id. 3256 /// @param[in] _x Position x from the left corner of the window. 3257 /// @param[in] _y Position y from the top corner of the window. 3258 /// @param[in] _width Width of scissor region. 3259 /// @param[in] _height Height of scissor region. 3260 /// 3261 /// @attention C99 equivalent is `bgfx_set_view_scissor`. 3262 /// 3263 void setViewScissor( 3264 ViewId _id 3265 , uint16_t _x = 0 3266 , uint16_t _y = 0 3267 , uint16_t _width = 0 3268 , uint16_t _height = 0 3269 ); 3270 3271 /// Set view clear flags. 3272 /// 3273 /// @param[in] _id View id. 3274 /// @param[in] _flags Clear flags. Use `BGFX_CLEAR_NONE` to remove any clear 3275 /// operation. See: `BGFX_CLEAR_*`. 3276 /// @param[in] _rgba Color clear value. 3277 /// @param[in] _depth Depth clear value. 3278 /// @param[in] _stencil Stencil clear value. 3279 /// 3280 /// @attention C99 equivalent is `bgfx_set_view_clear`. 3281 /// 3282 void setViewClear( 3283 ViewId _id 3284 , uint16_t _flags 3285 , uint32_t _rgba = 0x000000ff 3286 , float _depth = 1.0f 3287 , uint8_t _stencil = 0 3288 ); 3289 3290 /// Set view clear flags with different clear color for each 3291 /// frame buffer texture. Must use `bgfx::setPaletteColor` to setup clear color 3292 /// palette. 3293 /// 3294 /// @param[in] _id View id. 3295 /// @param[in] _flags Clear flags. Use `BGFX_CLEAR_NONE` to remove any clear 3296 /// operation. See: `BGFX_CLEAR_*`. 3297 /// @param[in] _depth Depth clear value. 3298 /// @param[in] _stencil Stencil clear value. 3299 /// @param[in] _0 Palette index for frame buffer attachment 0. 3300 /// @param[in] _1 Palette index for frame buffer attachment 1. 3301 /// @param[in] _2 Palette index for frame buffer attachment 2. 3302 /// @param[in] _3 Palette index for frame buffer attachment 3. 3303 /// @param[in] _4 Palette index for frame buffer attachment 4. 3304 /// @param[in] _5 Palette index for frame buffer attachment 5. 3305 /// @param[in] _6 Palette index for frame buffer attachment 6. 3306 /// @param[in] _7 Palette index for frame buffer attachment 7. 3307 /// 3308 /// @attention C99 equivalent is `bgfx_set_view_clear_mrt`. 3309 /// 3310 void setViewClear( 3311 ViewId _id 3312 , uint16_t _flags 3313 , float _depth 3314 , uint8_t _stencil 3315 , uint8_t _0 = UINT8_MAX 3316 , uint8_t _1 = UINT8_MAX 3317 , uint8_t _2 = UINT8_MAX 3318 , uint8_t _3 = UINT8_MAX 3319 , uint8_t _4 = UINT8_MAX 3320 , uint8_t _5 = UINT8_MAX 3321 , uint8_t _6 = UINT8_MAX 3322 , uint8_t _7 = UINT8_MAX 3323 ); 3324 3325 /// Set view sorting mode. 3326 /// 3327 /// @param[in] _id View id. 3328 /// @param[in] _mode View sort mode. See `ViewMode::Enum`. 3329 /// 3330 /// @remarks 3331 /// View mode must be set prior calling `bgfx::submit` for the view. 3332 /// 3333 /// @attention C99 equivalent is `bgfx_set_view_mode`. 3334 /// 3335 void setViewMode( 3336 ViewId _id 3337 , ViewMode::Enum _mode = ViewMode::Default 3338 ); 3339 3340 /// Set view frame buffer. 3341 /// 3342 /// @param[in] _id View id. 3343 /// @param[in] _handle Frame buffer handle. Passing `BGFX_INVALID_HANDLE` as 3344 /// frame buffer handle will draw primitives from this view into 3345 /// default back buffer. 3346 /// 3347 /// @remarks 3348 /// Not persistent after `bgfx::reset` call. 3349 /// 3350 /// @attention C99 equivalent is `bgfx_set_view_frame_buffer`. 3351 /// 3352 void setViewFrameBuffer( 3353 ViewId _id 3354 , FrameBufferHandle _handle 3355 ); 3356 3357 /// Set view view and projection matrices, all draw primitives in this 3358 /// view will use these matrices. 3359 /// 3360 /// @param[in] _id View id. 3361 /// @param[in] _view View matrix. 3362 /// @param[in] _proj Projection matrix. 3363 /// 3364 /// @attention C99 equivalent is `bgfx_set_view_transform`. 3365 /// 3366 void setViewTransform( 3367 ViewId _id 3368 , const void* _view 3369 , const void* _proj 3370 ); 3371 3372 /// Post submit view reordering. 3373 /// 3374 /// @param[in] _id First view id. 3375 /// @param[in] _num Number of views to remap. 3376 /// @param[in] _remap View remap id table. Passing `NULL` will reset view ids 3377 /// to default state. 3378 /// 3379 /// @attention C99 equivalent is `bgfx_set_view_order`. 3380 /// 3381 void setViewOrder( 3382 ViewId _id = 0 3383 , uint16_t _num = UINT16_MAX 3384 , const ViewId* _remap = NULL 3385 ); 3386 3387 /// Reset all view settings to default. 3388 /// 3389 /// @param[in] _id View id. 3390 /// 3391 /// @attention C99 equivalent is `bgfx_reset_view`. 3392 /// 3393 void resetView(ViewId _id); 3394 3395 /// Sets debug marker. 3396 /// 3397 /// @attention C99 equivalent is `bgfx_set_marker`. 3398 /// 3399 void setMarker(const char* _marker); 3400 3401 /// Set render states for draw primitive. 3402 /// 3403 /// @param[in] _state State flags. Default state for primitive type is 3404 /// triangles. See: `BGFX_STATE_DEFAULT`. 3405 /// - `BGFX_STATE_DEPTH_TEST_*` - Depth test function. 3406 /// - `BGFX_STATE_BLEND_*` - See remark 1 about BGFX_STATE_BLEND_FUNC. 3407 /// - `BGFX_STATE_BLEND_EQUATION_*` - See remark 2. 3408 /// - `BGFX_STATE_CULL_*` - Backface culling mode. 3409 /// - `BGFX_STATE_WRITE_*` - Enable R, G, B, A or Z write. 3410 /// - `BGFX_STATE_MSAA` - Enable MSAA. 3411 /// - `BGFX_STATE_PT_[TRISTRIP/LINES/POINTS]` - Primitive type. 3412 /// 3413 /// @param[in] _rgba Sets blend factor used by `BGFX_STATE_BLEND_FACTOR` and 3414 /// `BGFX_STATE_BLEND_INV_FACTOR` blend modes. 3415 /// 3416 /// @remarks 3417 /// 1. To setup more complex states use: 3418 /// `BGFX_STATE_ALPHA_REF(_ref)`, 3419 /// `BGFX_STATE_POINT_SIZE(_size)`, 3420 /// `BGFX_STATE_BLEND_FUNC(_src, _dst)`, 3421 /// `BGFX_STATE_BLEND_FUNC_SEPARATE(_srcRGB, _dstRGB, _srcA, _dstA)` 3422 /// `BGFX_STATE_BLEND_EQUATION(_equation)` 3423 /// `BGFX_STATE_BLEND_EQUATION_SEPARATE(_equationRGB, _equationA)` 3424 /// 2. `BGFX_STATE_BLEND_EQUATION_ADD` is set when no other blend 3425 /// equation is specified. 3426 /// 3427 /// @attention C99 equivalent is `bgfx_set_state`. 3428 /// 3429 void setState( 3430 uint64_t _state 3431 , uint32_t _rgba = 0 3432 ); 3433 3434 /// Set condition for rendering. 3435 /// 3436 /// @param[in] _handle Occlusion query handle. 3437 /// @param[in] _visible Render if occlusion query is visible. 3438 /// 3439 /// @attention C99 equivalent is `bgfx_set_condition`. 3440 /// 3441 void setCondition( 3442 OcclusionQueryHandle _handle 3443 , bool _visible 3444 ); 3445 3446 /// Set stencil test state. 3447 /// 3448 /// @param[in] _fstencil Front stencil state. 3449 /// @param[in] _bstencil Back stencil state. If back is set to `BGFX_STENCIL_NONE` 3450 /// _fstencil is applied to both front and back facing primitives. 3451 /// 3452 /// @attention C99 equivalent is `bgfx_set_stencil`. 3453 /// 3454 void setStencil( 3455 uint32_t _fstencil 3456 , uint32_t _bstencil = BGFX_STENCIL_NONE 3457 ); 3458 3459 /// Set scissor for draw primitive. For scissor for all primitives in 3460 /// view see `bgfx::setViewScissor`. 3461 /// 3462 /// @param[in] _x Position x from the left corner of the window. 3463 /// @param[in] _y Position y from the top corner of the window. 3464 /// @param[in] _width Width of scissor region. 3465 /// @param[in] _height Height of scissor region. 3466 /// @returns Scissor cache index. 3467 /// 3468 /// @attention C99 equivalent is `bgfx_set_scissor`. 3469 /// 3470 uint16_t setScissor( 3471 uint16_t _x 3472 , uint16_t _y 3473 , uint16_t _width 3474 , uint16_t _height 3475 ); 3476 3477 /// Set scissor from cache for draw primitive. 3478 /// 3479 /// @param[in] _cache Index in scissor cache. Passing UINT16_MAX unset primitive 3480 /// scissor and primitive will use view scissor instead. 3481 /// 3482 /// @attention C99 equivalent is `bgfx_set_scissor_cached`. 3483 /// 3484 void setScissor(uint16_t _cache = UINT16_MAX); 3485 3486 /// Set model matrix for draw primitive. If it is not called, 3487 /// the model will be rendered with an identity model matrix. 3488 /// 3489 /// @param[in] _mtx Pointer to first matrix in array. 3490 /// @param[in] _num Number of matrices in array. 3491 /// @returns index into matrix cache in case the same model matrix has 3492 /// to be used for other draw primitive call. 3493 /// 3494 /// @attention C99 equivalent is `bgfx_set_transform`. 3495 /// 3496 uint32_t setTransform( 3497 const void* _mtx 3498 , uint16_t _num = 1 3499 ); 3500 3501 /// Reserve `_num` matrices in internal matrix cache. 3502 /// 3503 /// @param[in] _transform Pointer to `Transform` structure. 3504 /// @param[in] _num Number of matrices. 3505 /// @returns index into matrix cache. 3506 /// 3507 /// @attention Pointer returned can be modifed until `bgfx::frame` is called. 3508 /// @attention C99 equivalent is `bgfx_alloc_transform`. 3509 /// 3510 uint32_t allocTransform( 3511 Transform* _transform 3512 , uint16_t _num 3513 ); 3514 3515 /// Set model matrix from matrix cache for draw primitive. 3516 /// 3517 /// @param[in] _cache Index in matrix cache. 3518 /// @param[in] _num Number of matrices from cache. 3519 /// 3520 /// @attention C99 equivalent is `bgfx_set_transform_cached`. 3521 /// 3522 void setTransform( 3523 uint32_t _cache 3524 , uint16_t _num = 1 3525 ); 3526 3527 /// Set shader uniform parameter for draw primitive. 3528 /// 3529 /// @param[in] _handle Uniform. 3530 /// @param[in] _value Pointer to uniform data. 3531 /// @param[in] _num Number of elements. Passing `UINT16_MAX` will 3532 /// use the _num passed on uniform creation. 3533 /// 3534 /// @attention C99 equivalent is `bgfx_set_uniform`. 3535 /// 3536 void setUniform( 3537 UniformHandle _handle 3538 , const void* _value 3539 , uint16_t _num = 1 3540 ); 3541 3542 /// Set index buffer for draw primitive. 3543 /// 3544 /// @param[in] _handle Index buffer. 3545 /// 3546 /// @attention C99 equivalent is `bgfx_set_index_buffer`. 3547 /// 3548 void setIndexBuffer(IndexBufferHandle _handle); 3549 3550 /// Set index buffer for draw primitive. 3551 /// 3552 /// @param[in] _handle Index buffer. 3553 /// @param[in] _firstIndex First index to render. 3554 /// @param[in] _numIndices Number of indices to render. 3555 /// 3556 /// @attention C99 equivalent is `bgfx_set_index_buffer`. 3557 /// 3558 void setIndexBuffer( 3559 IndexBufferHandle _handle 3560 , uint32_t _firstIndex 3561 , uint32_t _numIndices 3562 ); 3563 3564 /// Set index buffer for draw primitive. 3565 /// 3566 /// @param[in] _handle Dynamic index buffer. 3567 /// 3568 /// @attention C99 equivalent is `bgfx_set_dynamic_index_buffer`. 3569 /// 3570 void setIndexBuffer(DynamicIndexBufferHandle _handle); 3571 3572 /// Set index buffer for draw primitive. 3573 /// 3574 /// @param[in] _handle Dynamic index buffer. 3575 /// @param[in] _firstIndex First index to render. 3576 /// @param[in] _numIndices Number of indices to render. 3577 /// 3578 /// @attention C99 equivalent is `bgfx_set_dynamic_index_buffer`. 3579 /// 3580 void setIndexBuffer( 3581 DynamicIndexBufferHandle _handle 3582 , uint32_t _firstIndex 3583 , uint32_t _numIndices 3584 ); 3585 3586 /// Set index buffer for draw primitive. 3587 /// 3588 /// @param[in] _tib Transient index buffer. 3589 /// 3590 /// @attention C99 equivalent is `bgfx_set_transient_index_buffer`. 3591 /// 3592 void setIndexBuffer(const TransientIndexBuffer* _tib); 3593 3594 /// Set index buffer for draw primitive. 3595 /// 3596 /// @param[in] _tib Transient index buffer. 3597 /// @param[in] _firstIndex First index to render. 3598 /// @param[in] _numIndices Number of indices to render. 3599 /// 3600 /// @attention C99 equivalent is `bgfx_set_transient_index_buffer`. 3601 /// 3602 void setIndexBuffer( 3603 const TransientIndexBuffer* _tib 3604 , uint32_t _firstIndex 3605 , uint32_t _numIndices 3606 ); 3607 3608 /// Set vertex buffer for draw primitive. 3609 /// 3610 /// @param[in] _stream Vertex stream. 3611 /// @param[in] _handle Vertex buffer. 3612 /// 3613 /// @attention C99 equivalent is `bgfx_set_vertex_buffer`. 3614 /// 3615 void setVertexBuffer( 3616 uint8_t _stream 3617 , VertexBufferHandle _handle 3618 ); 3619 3620 /// Set vertex buffer for draw primitive. 3621 /// 3622 /// @param[in] _stream Vertex stream. 3623 /// @param[in] _handle Vertex buffer. 3624 /// @param[in] _startVertex First vertex to render. 3625 /// @param[in] _numVertices Number of vertices to render. 3626 /// @param[in] _layoutHandle Vertex layout for aliasing vertex buffer. 3627 /// 3628 /// @attention C99 equivalent is `bgfx_set_vertex_buffer`. 3629 /// 3630 void setVertexBuffer( 3631 uint8_t _stream 3632 , VertexBufferHandle _handle 3633 , uint32_t _startVertex 3634 , uint32_t _numVertices 3635 , VertexLayoutHandle _layoutHandle = BGFX_INVALID_HANDLE 3636 ); 3637 3638 /// Set vertex buffer for draw primitive. 3639 /// 3640 /// @param[in] _stream Vertex stream. 3641 /// @param[in] _handle Dynamic vertex buffer. 3642 /// 3643 /// @attention C99 equivalent is `bgfx_set_dynamic_vertex_buffer`. 3644 /// 3645 void setVertexBuffer( 3646 uint8_t _stream 3647 , DynamicVertexBufferHandle _handle 3648 ); 3649 3650 /// Set vertex buffer for draw primitive. 3651 /// 3652 /// @param[in] _stream Vertex stream. 3653 /// @param[in] _handle Dynamic vertex buffer. 3654 /// @param[in] _startVertex First vertex to render. 3655 /// @param[in] _numVertices Number of vertices to render. 3656 /// @param[in] _layoutHandle Vertex layout for aliasing vertex buffer. 3657 /// 3658 /// @attention C99 equivalent is `bgfx_set_dynamic_vertex_buffer`. 3659 /// 3660 void setVertexBuffer( 3661 uint8_t _stream 3662 , DynamicVertexBufferHandle _handle 3663 , uint32_t _startVertex 3664 , uint32_t _numVertices 3665 , VertexLayoutHandle _layoutHandle = BGFX_INVALID_HANDLE 3666 ); 3667 3668 /// Set vertex buffer for draw primitive. 3669 /// 3670 /// @param[in] _stream Vertex stream. 3671 /// @param[in] _tvb Transient vertex buffer. 3672 /// 3673 /// @attention C99 equivalent is `bgfx_set_transient_vertex_buffer`. 3674 /// 3675 void setVertexBuffer( 3676 uint8_t _stream 3677 , const TransientVertexBuffer* _tvb 3678 ); 3679 3680 /// Set vertex buffer for draw primitive. 3681 /// 3682 /// @param[in] _stream Vertex stream. 3683 /// @param[in] _tvb Transient vertex buffer. 3684 /// @param[in] _startVertex First vertex to render. 3685 /// @param[in] _numVertices Number of vertices to render. 3686 /// @param[in] _layoutHandle Vertex layout for aliasing vertex buffer. 3687 /// 3688 /// @attention C99 equivalent is `bgfx_set_transient_vertex_buffer`. 3689 /// 3690 void setVertexBuffer( 3691 uint8_t _stream 3692 , const TransientVertexBuffer* _tvb 3693 , uint32_t _startVertex 3694 , uint32_t _numVertices 3695 , VertexLayoutHandle _layoutHandle = BGFX_INVALID_HANDLE 3696 ); 3697 3698 /// Set number of vertices for auto generated vertices use in conjuction 3699 /// with gl_VertexID. 3700 /// 3701 /// @param[in] _numVertices Number of vertices. 3702 /// 3703 /// @attention Availability depends on: `BGFX_CAPS_VERTEX_ID`. 3704 /// @attention C99 equivalent is `bgfx_set_vertex_count`. 3705 /// 3706 void setVertexCount(uint32_t _numVertices); 3707 3708 /// Set instance data buffer for draw primitive. 3709 /// 3710 /// @param[in] _idb Transient instance data buffer. 3711 /// 3712 /// @attention C99 equivalent is `bgfx_set_instance_data_buffer`. 3713 /// 3714 void setInstanceDataBuffer(const InstanceDataBuffer* _idb); 3715 3716 /// Set instance data buffer for draw primitive. 3717 /// 3718 /// @param[in] _idb Transient instance data buffer. 3719 /// @param[in] _start First instance data. 3720 /// @param[in] _num Number of data instances. 3721 /// 3722 /// @attention C99 equivalent is `bgfx_set_instance_data_buffer`. 3723 /// 3724 void setInstanceDataBuffer( 3725 const InstanceDataBuffer* _idb 3726 , uint32_t _start 3727 , uint32_t _num 3728 ); 3729 3730 /// Set instance data buffer for draw primitive. 3731 /// 3732 /// @param[in] _handle Vertex buffer. 3733 /// @param[in] _start First instance data. 3734 /// @param[in] _num Number of data instances. 3735 /// 3736 /// @attention C99 equivalent is `bgfx_set_instance_data_from_vertex_buffer`. 3737 /// 3738 void setInstanceDataBuffer( 3739 VertexBufferHandle _handle 3740 , uint32_t _start 3741 , uint32_t _num 3742 ); 3743 3744 /// Set instance data buffer for draw primitive. 3745 /// 3746 /// @param[in] _handle Vertex buffer. 3747 /// @param[in] _start First instance data. 3748 /// @param[in] _num Number of data instances. 3749 /// 3750 /// @attention C99 equivalent is `bgfx_set_instance_data_from_dynamic_vertex_buffer`. 3751 /// 3752 void setInstanceDataBuffer( 3753 DynamicVertexBufferHandle _handle 3754 , uint32_t _start 3755 , uint32_t _num 3756 ); 3757 3758 /// Set number of instances for auto generated instances use in conjuction 3759 /// with gl_InstanceID. 3760 /// 3761 /// @param[in] _numInstances Number of instances. 3762 /// 3763 /// @attention Availability depends on: `BGFX_CAPS_VERTEX_ID`. 3764 /// @attention C99 equivalent is `bgfx_set_instance_count`. 3765 /// 3766 void setInstanceCount(uint32_t _numInstances); 3767 3768 /// Set texture stage for draw primitive. 3769 /// 3770 /// @param[in] _stage Texture unit. 3771 /// @param[in] _sampler Program sampler. 3772 /// @param[in] _handle Texture handle. 3773 /// @param[in] _flags Texture sampling mode. Default value UINT32_MAX uses 3774 /// texture sampling settings from the texture. 3775 /// - `BGFX_SAMPLER_[U/V/W]_[MIRROR/CLAMP]` - Mirror or clamp to edge wrap 3776 /// mode. 3777 /// - `BGFX_SAMPLER_[MIN/MAG/MIP]_[POINT/ANISOTROPIC]` - Point or anisotropic 3778 /// sampling. 3779 /// 3780 /// @attention C99 equivalent is `bgfx_set_texture`. 3781 /// 3782 void setTexture( 3783 uint8_t _stage 3784 , UniformHandle _sampler 3785 , TextureHandle _handle 3786 , uint32_t _flags = UINT32_MAX 3787 ); 3788 3789 /// Submit an empty primitive for rendering. Uniforms and draw state 3790 /// will be applied but no geometry will be submitted. 3791 /// 3792 /// These empty draw calls will sort before ordinary draw calls. 3793 /// 3794 /// @param[in] _id View id. 3795 /// 3796 /// @attention C99 equivalent is `bgfx_touch`. 3797 /// 3798 void touch(ViewId _id); 3799 3800 /// Submit primitive for rendering. 3801 /// 3802 /// @param[in] _id View id. 3803 /// @param[in] _program Program. 3804 /// @param[in] _depth Depth for sorting. 3805 /// @param[in] _preserveState Preserve internal draw state for next draw 3806 /// call submit. 3807 /// 3808 /// @attention C99 equivalent is `bgfx_submit`. 3809 /// 3810 void submit( 3811 ViewId _id 3812 , ProgramHandle _program 3813 , uint32_t _depth = 0 3814 , bool _preserveState = false 3815 ); 3816 3817 /// Submit primitive with occlusion query for rendering. 3818 /// 3819 /// @param[in] _id View id. 3820 /// @param[in] _program Program. 3821 /// @param[in] _occlusionQuery Occlusion query. 3822 /// @param[in] _depth Depth for sorting. 3823 /// @param[in] _preserveState Preserve internal draw state for next draw 3824 /// call submit. 3825 /// 3826 /// @attention C99 equivalent is `bgfx_submit_occlusion_query`. 3827 /// 3828 void submit( 3829 ViewId _id 3830 , ProgramHandle _program 3831 , OcclusionQueryHandle _occlusionQuery 3832 , uint32_t _depth = 0 3833 , bool _preserveState = false 3834 ); 3835 3836 /// Submit primitive for rendering with index and instance data info from 3837 /// indirect buffer. 3838 /// 3839 /// @param[in] _id View id. 3840 /// @param[in] _program Program. 3841 /// @param[in] _indirectHandle Indirect buffer. 3842 /// @param[in] _start First element in indirect buffer. 3843 /// @param[in] _num Number of dispatches. 3844 /// @param[in] _depth Depth for sorting. 3845 /// @param[in] _preserveState Preserve internal draw state for next draw 3846 /// call submit. 3847 /// 3848 /// @attention C99 equivalent is `bgfx_submit_indirect`. 3849 /// 3850 void submit( 3851 ViewId _id 3852 , ProgramHandle _program 3853 , IndirectBufferHandle _indirectHandle 3854 , uint16_t _start = 0 3855 , uint16_t _num = 1 3856 , uint32_t _depth = 0 3857 , bool _preserveState = false 3858 ); 3859 3860 /// Set compute index buffer. 3861 /// 3862 /// @param[in] _stage Compute stage. 3863 /// @param[in] _handle Index buffer handle. 3864 /// @param[in] _access Buffer access. See `Access::Enum`. 3865 /// 3866 /// @attention C99 equivalent is `bgfx_set_compute_index_buffer`. 3867 /// 3868 void setBuffer( 3869 uint8_t _stage 3870 , IndexBufferHandle _handle 3871 , Access::Enum _access 3872 ); 3873 3874 /// Set compute vertex buffer. 3875 /// 3876 /// @param[in] _stage Compute stage. 3877 /// @param[in] _handle Vertex buffer handle. 3878 /// @param[in] _access Buffer access. See `Access::Enum`. 3879 /// 3880 /// @attention C99 equivalent is `bgfx_set_compute_vertex_buffer`. 3881 /// 3882 void setBuffer( 3883 uint8_t _stage 3884 , VertexBufferHandle _handle 3885 , Access::Enum _access 3886 ); 3887 3888 /// Set compute dynamic index buffer. 3889 /// 3890 /// @param[in] _stage Compute stage. 3891 /// @param[in] _handle Dynamic index buffer handle. 3892 /// @param[in] _access Buffer access. See `Access::Enum`. 3893 /// 3894 /// @attention C99 equivalent is `bgfx_set_compute_dynamic_index_buffer`. 3895 /// 3896 void setBuffer( 3897 uint8_t _stage 3898 , DynamicIndexBufferHandle _handle 3899 , Access::Enum _access 3900 ); 3901 3902 /// Set compute dynamic vertex buffer. 3903 /// 3904 /// @param[in] _stage Compute stage. 3905 /// @param[in] _handle Dynamic vertex buffer handle. 3906 /// @param[in] _access Buffer access. See `Access::Enum`. 3907 /// 3908 /// @attention C99 equivalent is `bgfx_set_compute_dynamic_vertex_buffer`. 3909 /// 3910 void setBuffer( 3911 uint8_t _stage 3912 , DynamicVertexBufferHandle _handle 3913 , Access::Enum _access 3914 ); 3915 3916 /// Set compute indirect buffer. 3917 /// 3918 /// @param[in] _stage Compute stage. 3919 /// @param[in] _handle Indirect buffer handle. 3920 /// @param[in] _access Buffer access. See `Access::Enum`. 3921 /// 3922 /// @attention C99 equivalent is `bgfx_set_compute_indirect_buffer`. 3923 /// 3924 void setBuffer( 3925 uint8_t _stage 3926 , IndirectBufferHandle _handle 3927 , Access::Enum _access 3928 ); 3929 3930 /// Set compute image from texture. 3931 /// 3932 /// @param[in] _stage Texture unit. 3933 /// @param[in] _handle Texture handle. 3934 /// @param[in] _mip Mip level. 3935 /// @param[in] _access Texture access. See `Access::Enum`. 3936 /// @param[in] _format Texture format. See: `TextureFormat::Enum`. 3937 /// 3938 /// @attention C99 equivalent is `bgfx_set_image`. 3939 /// 3940 void setImage( 3941 uint8_t _stage 3942 , TextureHandle _handle 3943 , uint8_t _mip 3944 , Access::Enum _access 3945 , TextureFormat::Enum _format = TextureFormat::Count 3946 ); 3947 3948 /// Dispatch compute. 3949 /// 3950 /// @param[in] _id View id. 3951 /// @param[in] _handle Compute program. 3952 /// @param[in] _numX Number of groups X. 3953 /// @param[in] _numY Number of groups Y. 3954 /// @param[in] _numZ Number of groups Z. 3955 /// 3956 /// @attention C99 equivalent is `bgfx_dispatch`. 3957 /// 3958 void dispatch( 3959 ViewId _id 3960 , ProgramHandle _handle 3961 , uint32_t _numX = 1 3962 , uint32_t _numY = 1 3963 , uint32_t _numZ = 1 3964 ); 3965 3966 /// Dispatch compute indirect. 3967 /// 3968 /// @param[in] _id View id. 3969 /// @param[in] _handle Compute program. 3970 /// @param[in] _indirectHandle Indirect buffer. 3971 /// @param[in] _start First element in indirect buffer. 3972 /// @param[in] _num Number of dispatches. 3973 /// 3974 /// @attention C99 equivalent is `bgfx_dispatch_indirect`. 3975 /// 3976 void dispatch( 3977 ViewId _id 3978 , ProgramHandle _handle 3979 , IndirectBufferHandle _indirectHandle 3980 , uint16_t _start = 0 3981 , uint16_t _num = 1 3982 ); 3983 3984 /// Discard all previously set state for draw or compute call. 3985 /// 3986 /// @attention C99 equivalent is `bgfx_discard`. 3987 /// 3988 void discard(); 3989 3990 /// Blit 2D texture region between two 2D textures. 3991 /// 3992 /// @param[in] _id View id. 3993 /// @param[in] _dst Destination texture handle. 3994 /// @param[in] _dstX Destination texture X position. 3995 /// @param[in] _dstY Destination texture Y position. 3996 /// @param[in] _src Source texture handle. 3997 /// @param[in] _srcX Source texture X position. 3998 /// @param[in] _srcY Source texture Y position. 3999 /// @param[in] _width Width of region. 4000 /// @param[in] _height Height of region. 4001 /// 4002 /// @attention Destination texture must be created with `BGFX_TEXTURE_BLIT_DST` flag. 4003 /// @attention Availability depends on: `BGFX_CAPS_TEXTURE_BLIT`. 4004 /// @attention C99 equivalent is `bgfx_blit`. 4005 /// 4006 void blit( 4007 ViewId _id 4008 , TextureHandle _dst 4009 , uint16_t _dstX 4010 , uint16_t _dstY 4011 , TextureHandle _src 4012 , uint16_t _srcX = 0 4013 , uint16_t _srcY = 0 4014 , uint16_t _width = UINT16_MAX 4015 , uint16_t _height = UINT16_MAX 4016 ); 4017 4018 /// Blit texture region between two textures. 4019 /// 4020 /// @param[in] _id View id. 4021 /// @param[in] _dst Destination texture handle. 4022 /// @param[in] _dstMip Destination texture mip level. 4023 /// @param[in] _dstX Destination texture X position. 4024 /// @param[in] _dstY Destination texture Y position. 4025 /// @param[in] _dstZ If texture is 2D this argument should be 0. If destination texture is cube 4026 /// this argument represents destination texture cube face. For 3D texture this argument 4027 /// represents destination texture Z position. 4028 /// @param[in] _src Source texture handle. 4029 /// @param[in] _srcMip Source texture mip level. 4030 /// @param[in] _srcX Source texture X position. 4031 /// @param[in] _srcY Source texture Y position. 4032 /// @param[in] _srcZ If texture is 2D this argument should be 0. If source texture is cube 4033 /// this argument represents source texture cube face. For 3D texture this argument 4034 /// represents source texture Z position. 4035 /// @param[in] _width Width of region. 4036 /// @param[in] _height Height of region. 4037 /// @param[in] _depth If texture is 3D this argument represents depth of region, otherwise it's 4038 /// unused. 4039 /// 4040 /// @attention Destination texture must be created with `BGFX_TEXTURE_BLIT_DST` flag. 4041 /// @attention Availability depends on: `BGFX_CAPS_TEXTURE_BLIT`. 4042 /// @attention C99 equivalent is `bgfx_blit`. 4043 /// 4044 void blit( 4045 ViewId _id 4046 , TextureHandle _dst 4047 , uint8_t _dstMip 4048 , uint16_t _dstX 4049 , uint16_t _dstY 4050 , uint16_t _dstZ 4051 , TextureHandle _src 4052 , uint8_t _srcMip = 0 4053 , uint16_t _srcX = 0 4054 , uint16_t _srcY = 0 4055 , uint16_t _srcZ = 0 4056 , uint16_t _width = UINT16_MAX 4057 , uint16_t _height = UINT16_MAX 4058 , uint16_t _depth = UINT16_MAX 4059 ); 4060 4061 /// Request screen shot of window back buffer. 4062 /// 4063 /// @param[in] _handle Frame buffer handle. If handle is `BGFX_INVALID_HANDLE` request will be 4064 /// made for main window back buffer. 4065 /// @param[in] _filePath Will be passed to `bgfx::CallbackI::screenShot` callback. 4066 /// 4067 /// @remarks 4068 /// `bgfx::CallbackI::screenShot` must be implemented. 4069 /// 4070 /// @attention Frame buffer handle must be created with OS' target native window handle. 4071 /// @attention C99 equivalent is `bgfx_request_screen_shot`. 4072 /// 4073 void requestScreenShot( 4074 FrameBufferHandle _handle 4075 , const char* _filePath 4076 ); 4077 4078 } // namespace bgfx 4079 4080 #endif // BGFX_H_HEADER_GUARD 4081