bgfx.h 72 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061
  1. /*
  2. * Copyright 2011-2015 Branimir Karadzic. All rights reserved.
  3. * License: https://github.com/bkaradzic/bgfx/blob/master/LICENSE
  4. */
  5. #ifndef BGFX_H_HEADER_GUARD
  6. #define BGFX_H_HEADER_GUARD
  7. #include <stdarg.h> // va_list
  8. #include <stdint.h> // uint32_t
  9. #include <stdlib.h> // size_t
  10. #include "bgfxdefines.h"
  11. ///
  12. #define BGFX_HANDLE(_name) \
  13. struct _name { uint16_t idx; }; \
  14. inline bool isValid(_name _handle) { return bgfx::invalidHandle != _handle.idx; }
  15. #define BGFX_INVALID_HANDLE { bgfx::invalidHandle }
  16. namespace bx { struct ReallocatorI; }
  17. /// BGFX
  18. namespace bgfx
  19. {
  20. /// Fatal error enum.
  21. ///
  22. /// @attention C99 equivalent is `bgfx_fatal_t`.
  23. ///
  24. struct Fatal
  25. {
  26. enum Enum
  27. {
  28. DebugCheck,
  29. MinimumRequiredSpecs,
  30. InvalidShader,
  31. UnableToInitialize,
  32. UnableToCreateTexture,
  33. DeviceLost,
  34. Count
  35. };
  36. };
  37. /// Renderer backend type enum.
  38. ///
  39. /// @attention C99 equivalent is `bgfx_renderer_type_t`.
  40. ///
  41. struct RendererType
  42. {
  43. /// Renderer types:
  44. enum Enum
  45. {
  46. Null, //!< No rendering.
  47. Direct3D9, //!< Direct3D 9.0
  48. Direct3D11, //!< Direct3D 11.0
  49. Direct3D12, //!< Direct3D 12.0
  50. Metal, //!< Metal
  51. OpenGLES, //!< OpenGL ES 2.0+
  52. OpenGL, //!< OpenGL 2.1+
  53. Vulkan, //!< Vulkan
  54. Count
  55. };
  56. };
  57. /// Access mode enum.
  58. ///
  59. /// @attention C99 equivalent is `bgfx_access_t`.
  60. ///
  61. struct Access
  62. {
  63. /// Access:
  64. enum Enum
  65. {
  66. Read,
  67. Write,
  68. ReadWrite,
  69. Count
  70. };
  71. };
  72. /// Vertex attribute enum.
  73. ///
  74. /// @attention C99 equivalent is `bgfx_attrib_t`.
  75. ///
  76. struct Attrib
  77. {
  78. /// Corresponds to vertex shader attribute. Attributes:
  79. enum Enum
  80. {
  81. Position, //!< a_position
  82. Normal, //!< a_normal
  83. Tangent, //!< a_tangent
  84. Bitangent, //!< a_bitangent
  85. Color0, //!< a_color0
  86. Color1, //!< a_color1
  87. Indices, //!< a_indices
  88. Weight, //!< a_weight
  89. TexCoord0, //!< a_texcoord0
  90. TexCoord1, //!< a_texcoord1
  91. TexCoord2, //!< a_texcoord2
  92. TexCoord3, //!< a_texcoord3
  93. TexCoord4, //!< a_texcoord4
  94. TexCoord5, //!< a_texcoord5
  95. TexCoord6, //!< a_texcoord6
  96. TexCoord7, //!< a_texcoord7
  97. Count
  98. };
  99. };
  100. /// Vertex attribute type enum.
  101. ///
  102. /// @attention C99 equivalent is `bgfx_attrib_type_t`.
  103. ///
  104. struct AttribType
  105. {
  106. /// Attribute types:
  107. enum Enum
  108. {
  109. Uint8, //!< Uint8
  110. Uint10, //!< Uint10, availability depends on: `BGFX_CAPS_VERTEX_ATTRIB_UINT10`.
  111. Int16, //!< Int16
  112. Half, //!< Half, availability depends on: `BGFX_CAPS_VERTEX_ATTRIB_HALF`.
  113. Float, //!< Float
  114. Count
  115. };
  116. };
  117. /// Texture format enum.
  118. ///
  119. /// Notation:
  120. ///
  121. /// RGBA16S
  122. /// ^ ^ ^
  123. /// | | +-- [ ]Unorm
  124. /// | | [F]loat
  125. /// | | [S]norm
  126. /// | | [I]nt
  127. /// | | [U]int
  128. /// | +---- Number of bits per component
  129. /// +-------- Components
  130. ///
  131. /// @attention Availability depends on Caps (see: formats).
  132. ///
  133. /// @attention C99 equivalent is `bgfx_texture_format_t`.
  134. ///
  135. struct TextureFormat
  136. {
  137. /// Texture formats:
  138. enum Enum
  139. {
  140. BC1, //!< DXT1
  141. BC2, //!< DXT3
  142. BC3, //!< DXT5
  143. BC4, //!< LATC1/ATI1
  144. BC5, //!< LATC2/ATI2
  145. BC6H, //!< BC6H
  146. BC7, //!< BC7
  147. ETC1, //!< ETC1 RGB8
  148. ETC2, //!< ETC2 RGB8
  149. ETC2A, //!< ETC2 RGBA8
  150. ETC2A1, //!< ETC2 RGB8A1
  151. PTC12, //!< PVRTC1 RGB 2BPP
  152. PTC14, //!< PVRTC1 RGB 4BPP
  153. PTC12A, //!< PVRTC1 RGBA 2BPP
  154. PTC14A, //!< PVRTC1 RGBA 4BPP
  155. PTC22, //!< PVRTC2 RGBA 2BPP
  156. PTC24, //!< PVRTC2 RGBA 4BPP
  157. Unknown, // Compressed formats above.
  158. R1,
  159. A8,
  160. R8,
  161. R8I,
  162. R8U,
  163. R8S,
  164. R16,
  165. R16I,
  166. R16U,
  167. R16F,
  168. R16S,
  169. R32I,
  170. R32U,
  171. R32F,
  172. RG8,
  173. RG8I,
  174. RG8U,
  175. RG8S,
  176. RG16,
  177. RG16I,
  178. RG16U,
  179. RG16F,
  180. RG16S,
  181. RG32I,
  182. RG32U,
  183. RG32F,
  184. BGRA8,
  185. RGBA8,
  186. RGBA8I,
  187. RGBA8U,
  188. RGBA8S,
  189. RGBA16,
  190. RGBA16I,
  191. RGBA16U,
  192. RGBA16F,
  193. RGBA16S,
  194. RGBA32I,
  195. RGBA32U,
  196. RGBA32F,
  197. R5G6B5,
  198. RGBA4,
  199. RGB5A1,
  200. RGB10A2,
  201. R11G11B10F,
  202. UnknownDepth, // Depth formats below.
  203. D16,
  204. D24,
  205. D24S8,
  206. D32,
  207. D16F,
  208. D24F,
  209. D32F,
  210. D0S8,
  211. Count
  212. };
  213. };
  214. /// Uniform type enum.
  215. ///
  216. /// @attention C99 equivalent is `bgfx_uniform_type_t`.
  217. ///
  218. struct UniformType
  219. {
  220. /// Uniform types:
  221. enum Enum
  222. {
  223. Int1,
  224. End,
  225. Vec4,
  226. Mat3,
  227. Mat4,
  228. Count
  229. };
  230. };
  231. /// Backbuffer ratio enum.
  232. ///
  233. /// @attention C99 equivalent is `bgfx_backbuffer_ratio_t`.
  234. ///
  235. struct BackbufferRatio
  236. {
  237. /// Backbuffer ratios:
  238. enum Enum
  239. {
  240. Equal,
  241. Half,
  242. Quarter,
  243. Eighth,
  244. Sixteenth,
  245. Double,
  246. Count
  247. };
  248. };
  249. static const uint16_t invalidHandle = UINT16_MAX;
  250. BGFX_HANDLE(DynamicIndexBufferHandle);
  251. BGFX_HANDLE(DynamicVertexBufferHandle);
  252. BGFX_HANDLE(FrameBufferHandle);
  253. BGFX_HANDLE(IndexBufferHandle);
  254. BGFX_HANDLE(IndirectBufferHandle);
  255. BGFX_HANDLE(ProgramHandle);
  256. BGFX_HANDLE(ShaderHandle);
  257. BGFX_HANDLE(TextureHandle);
  258. BGFX_HANDLE(UniformHandle);
  259. BGFX_HANDLE(VertexBufferHandle);
  260. BGFX_HANDLE(VertexDeclHandle);
  261. /// Callback interface to implement application specific behavior.
  262. /// Cached items are currently used for OpenGL and Direct3D 12 binary
  263. /// shaders.
  264. ///
  265. /// @remarks
  266. /// 'fatal' and 'trace' callbacks can be called from any thread. Other
  267. /// callbacks are called from the render thread.
  268. ///
  269. /// @attention C99 equivalent is `bgfx_callback_interface_t`.
  270. ///
  271. struct CallbackI
  272. {
  273. virtual ~CallbackI() = 0;
  274. /// If fatal code code is not Fatal::DebugCheck this callback is
  275. /// called on unrecoverable error. It's not safe to continue, inform
  276. /// user and terminate application from this call.
  277. ///
  278. /// @param[in] _code Fatal error code.
  279. /// @param[in] _str More information about error.
  280. ///
  281. /// @remarks
  282. /// Not thread safe and it can be called from any thread.
  283. ///
  284. /// @attention C99 equivalent is `bgfx_callback_vtbl.fatal`.
  285. ///
  286. virtual void fatal(Fatal::Enum _code, const char* _str) = 0;
  287. /// Print debug message.
  288. ///
  289. /// @param[in] _filePath File path where debug message was generated.
  290. /// @param[in] _line Line where debug message was generated.
  291. /// @param[in] _format `printf` style format.
  292. /// @param[in] _argList Variable arguments list initialized with
  293. /// `va_start`.
  294. ///
  295. /// @remarks
  296. /// Not thread safe and it can be called from any thread.
  297. ///
  298. /// @attention C99 equivalent is `bgfx_callback_vtbl.trace_vargs`.
  299. ///
  300. virtual void traceVargs(const char* _filePath, uint16_t _line, const char* _format, va_list _argList) = 0;
  301. /// Return size of for cached item. Return 0 if no cached item was
  302. /// found.
  303. ///
  304. /// @param[in] _id Cache id.
  305. /// @returns Number of bytes to read.
  306. ///
  307. /// @attention C99 equivalent is `bgfx_callback_vtbl.cache_read_size`.
  308. ///
  309. virtual uint32_t cacheReadSize(uint64_t _id) = 0;
  310. /// Read cached item.
  311. ///
  312. /// @param[in] _id Cache id.
  313. /// @param[in] _data Buffer where to read data.
  314. /// @param[in] _size Size of data to read.
  315. ///
  316. /// @returns True if data is read.
  317. ///
  318. /// @attention C99 equivalent is `bgfx_callback_vtbl.cache_read`.
  319. ///
  320. virtual bool cacheRead(uint64_t _id, void* _data, uint32_t _size) = 0;
  321. /// Write cached item.
  322. ///
  323. /// @param[in] _id Cache id.
  324. /// @param[in] _data Data to write.
  325. /// @param[in] _size Size of data to write.
  326. ///
  327. /// @attention C99 equivalent is `bgfx_callback_vtbl.cache_write`.
  328. ///
  329. virtual void cacheWrite(uint64_t _id, const void* _data, uint32_t _size) = 0;
  330. /// Screenshot captured. Screenshot format is always 4-byte BGRA.
  331. ///
  332. /// @param[in] _filePath File path.
  333. /// @param[in] _width Image width.
  334. /// @param[in] _height Image height.
  335. /// @param[in] _pitch Number of bytes to skip to next line.
  336. /// @param[in] _data Image data.
  337. /// @param[in] _size Image size.
  338. /// @param[in] _yflip If true image origin is bottom left.
  339. ///
  340. /// @attention C99 equivalent is `bgfx_callback_vtbl.screen_shot`.
  341. ///
  342. virtual void screenShot(const char* _filePath, uint32_t _width, uint32_t _height, uint32_t _pitch, const void* _data, uint32_t _size, bool _yflip) = 0;
  343. /// Called when capture begins.
  344. ///
  345. /// @attention C99 equivalent is `bgfx_callback_vtbl.capture_begin`.
  346. ///
  347. virtual void captureBegin(uint32_t _width, uint32_t _height, uint32_t _pitch, TextureFormat::Enum _format, bool _yflip) = 0;
  348. /// Called when capture ends.
  349. ///
  350. /// @attention C99 equivalent is `bgfx_callback_vtbl.capture_end`.
  351. ///
  352. virtual void captureEnd() = 0;
  353. /// Captured frame.
  354. ///
  355. /// @param[in] _data Image data.
  356. /// @param[in] _size Image size.
  357. ///
  358. /// @attention C99 equivalent is `bgfx_callback_vtbl.capture_frame`.
  359. ///
  360. virtual void captureFrame(const void* _data, uint32_t _size) = 0;
  361. };
  362. inline CallbackI::~CallbackI()
  363. {
  364. }
  365. /// Memory release callback.
  366. ///
  367. /// @attention C99 equivalent is `bgfx_release_fn_t`.
  368. ///
  369. typedef void (*ReleaseFn)(void* _ptr, void* _userData);
  370. /// Memory obtained by calling `bgfx::alloc`, `bgfx::copy`, or `bgfx::makeRef`.
  371. ///
  372. /// @attention C99 equivalent is `bgfx_memory_t`.
  373. ///
  374. struct Memory
  375. {
  376. uint8_t* data;
  377. uint32_t size;
  378. };
  379. /// Renderer capabilities.
  380. ///
  381. /// @attention C99 equivalent is `bgfx_caps_t`.
  382. ///
  383. struct Caps
  384. {
  385. /// Renderer backend type. See: `bgfx::RendererType`
  386. RendererType::Enum rendererType;
  387. /// Supported functionality.
  388. ///
  389. /// - `BGFX_CAPS_TEXTURE_COMPARE_LEQUAL` - Less equal texture
  390. /// compare mode.
  391. /// - `BGFX_CAPS_TEXTURE_COMPARE_ALL` - All texture compare modes.
  392. /// - `BGFX_CAPS_TEXTURE_3D` - 3D textures.
  393. /// - `BGFX_CAPS_VERTEX_ATTRIB_HALF` - AttribType::Half.
  394. /// - `BGFX_CAPS_INSTANCING` - Vertex instancing.
  395. /// - `BGFX_CAPS_RENDERER_MULTITHREADED` - Renderer on separate
  396. /// thread.
  397. /// - `BGFX_CAPS_FRAGMENT_DEPTH` - Fragment shader can modify depth
  398. /// buffer value (gl_FragDepth).
  399. /// - `BGFX_CAPS_BLEND_INDEPENDENT` - Multiple render targets can
  400. /// have different blend mode set individually.
  401. /// - `BGFX_CAPS_COMPUTE` - Renderer has compute shaders.
  402. /// - `BGFX_CAPS_FRAGMENT_ORDERING` - Intel's pixel sync.
  403. /// - `BGFX_CAPS_SWAP_CHAIN` - Multiple windows.
  404. ///
  405. uint64_t supported;
  406. uint32_t maxDrawCalls; //!< Maximum draw calls.
  407. uint16_t maxTextureSize; //!< Maximum texture size.
  408. uint16_t maxViews; //!< Maximum views.
  409. uint8_t maxFBAttachments; //!< Maximum frame buffer attachments.
  410. uint8_t numGPUs; //!< Number of enumerated GPUs.
  411. uint16_t vendorId; //!< Selected GPU vendor id.
  412. uint16_t deviceId; //!< Selected GPU device id.
  413. /// GPU info.
  414. ///
  415. /// @attention C99 equivalent is `bgfx_caps_gpu_t`.
  416. ///
  417. struct GPU
  418. {
  419. uint16_t vendorId;
  420. uint16_t deviceId;
  421. };
  422. GPU gpu[4]; //!< Enumerated GPUs.
  423. /// Supported texture formats.
  424. /// - `BGFX_CAPS_FORMAT_TEXTURE_NONE` - not supported
  425. /// - `BGFX_CAPS_FORMAT_TEXTURE_COLOR` - supported
  426. /// - `BGFX_CAPS_FORMAT_TEXTURE_EMULATED` - emulated
  427. /// - `BGFX_CAPS_FORMAT_TEXTURE_VERTEX` - supported vertex texture
  428. uint8_t formats[TextureFormat::Count];
  429. };
  430. /// Transient index buffer.
  431. ///
  432. /// @attention C99 equivalent is `bgfx_transient_index_buffer_t`.
  433. ///
  434. struct TransientIndexBuffer
  435. {
  436. uint8_t* data; //!< Pointer to data.
  437. uint32_t size; //!< Data size.
  438. uint32_t startIndex; //!< First index.
  439. IndexBufferHandle handle; //!< Index buffer handle.
  440. };
  441. /// Transient vertex buffer.
  442. ///
  443. /// @attention C99 equivalent is `bgfx_transient_vertex_buffer_t`.
  444. ///
  445. struct TransientVertexBuffer
  446. {
  447. uint8_t* data; //!< Pointer to data.
  448. uint32_t size; //!< Data size.
  449. uint32_t startVertex; //!< First vertex.
  450. uint16_t stride; //!< Vertex stride.
  451. VertexBufferHandle handle; //!< Vertex buffer handle.
  452. VertexDeclHandle decl; //!< Vertex declaration handle.
  453. };
  454. /// Instance data buffer info.
  455. ///
  456. /// @attention C99 equivalent is `bgfx_texture_info_t`.
  457. ///
  458. struct InstanceDataBuffer
  459. {
  460. uint8_t* data; //!< Pointer to data.
  461. uint32_t size; //!< Data size.
  462. uint32_t offset; //!< Offset in vertex buffer.
  463. uint32_t num; //!< Number of instances.
  464. uint16_t stride; //!< Vertex buffer stride.
  465. VertexBufferHandle handle; //!< Vertex buffer object handle.
  466. };
  467. /// Texture info.
  468. ///
  469. /// @attention C99 equivalent is `bgfx_texture_info_t`.
  470. ///
  471. struct TextureInfo
  472. {
  473. TextureFormat::Enum format; //!< Texture format.
  474. uint32_t storageSize; //!< Total amount of bytes required to store texture.
  475. uint16_t width; //!< Texture width.
  476. uint16_t height; //!< Texture height.
  477. uint16_t depth; //!< Texture depth.
  478. uint8_t numMips; //!< Number of MIP maps.
  479. uint8_t bitsPerPixel; //!< Format bits per pixel.
  480. bool cubeMap; //!< Texture is cubemap.
  481. };
  482. /// Transform data.
  483. ///
  484. /// @attention C99 equivalent is `bgfx_transform_t`.
  485. ///
  486. struct Transform
  487. {
  488. float* data; //!< Pointer to first matrix.
  489. uint16_t num; //!< Number of matrices.
  490. };
  491. /// HMD info.
  492. ///
  493. /// @attention C99 equivalent is `bgfx_hmd_t`.
  494. ///
  495. struct HMD
  496. {
  497. /// Eye
  498. ///
  499. /// @attention C99 equivalent is `bgfx_hmd_eye_t`.
  500. ///
  501. struct Eye
  502. {
  503. float rotation[4]; //!< Eye rotation represented as quaternion.
  504. float translation[3]; //!< Eye translation.
  505. float fov[4]; //!< Field of view (up, down, left, right).
  506. float viewOffset[3]; //!< Eye view matrix translation adjustment.
  507. float pixelsPerTanAngle[2]; //!<
  508. };
  509. Eye eye[2];
  510. uint16_t width; //!< Framebuffer width.
  511. uint16_t height; //!< Framebuffer width.
  512. uint32_t deviceWidth; //!< Device resolution width
  513. uint32_t deviceHeight; //!< Device resolution height
  514. uint8_t flags; //!< Status flags
  515. };
  516. /// Renderer statistics data.
  517. ///
  518. /// @attention C99 equivalent is `bgfx_stats_t`.
  519. ///
  520. struct Stats
  521. {
  522. uint64_t cpuTime; //!< CPU frame time.
  523. uint64_t cpuTimerFreq; //!< CPU timer frequency.
  524. uint64_t gpuTime; //!< GPU frame time.
  525. uint64_t gpuTimerFreq; //!< GPU timer frequency.
  526. };
  527. /// Vertex declaration.
  528. ///
  529. /// @attention C99 equivalent is `bgfx_vertex_decl_t`.
  530. ///
  531. struct VertexDecl
  532. {
  533. VertexDecl();
  534. /// Start VertexDecl.
  535. ///
  536. /// @attention C99 equivalent is `bgfx_vertex_decl_begin`.
  537. ///
  538. VertexDecl& begin(RendererType::Enum _renderer = RendererType::Null);
  539. /// End VertexDecl.
  540. ///
  541. /// @attention C99 equivalent is `bgfx_vertex_decl_begin`.
  542. ///
  543. void end();
  544. /// Add attribute to VertexDecl.
  545. ///
  546. /// @param[in] _attrib Attribute semantics. See: `bgfx::Attrib`
  547. /// @param[in] _num Number of elements 1, 2, 3 or 4.
  548. /// @param[in] _type Element type.
  549. /// @param[in] _normalized When using fixed point AttribType (f.e. Uint8)
  550. /// value will be normalized for vertex shader usage. When normalized
  551. /// is set to true, AttribType::Uint8 value in range 0-255 will be
  552. /// in range 0.0-1.0 in vertex shader.
  553. /// @param[in] _asInt Packaging rule for vertexPack, vertexUnpack, and
  554. /// vertexConvert for AttribType::Uint8 and AttribType::Int16.
  555. /// Unpacking code must be implemented inside vertex shader.
  556. ///
  557. /// @remarks
  558. /// Must be called between begin/end.
  559. ///
  560. /// @attention C99 equivalent is `bgfx_vertex_decl_add`.
  561. ///
  562. VertexDecl& add(Attrib::Enum _attrib, uint8_t _num, AttribType::Enum _type, bool _normalized = false, bool _asInt = false);
  563. /// Skip _num bytes in vertex stream.
  564. ///
  565. /// @attention C99 equivalent is `bgfx_vertex_decl_skip`.
  566. ///
  567. VertexDecl& skip(uint8_t _num);
  568. /// Decode attribute.
  569. ///
  570. /// @attention C99 equivalent is ``.
  571. ///
  572. void decode(Attrib::Enum _attrib, uint8_t& _num, AttribType::Enum& _type, bool& _normalized, bool& _asInt) const;
  573. /// Returns true if VertexDecl contains attribute.
  574. bool has(Attrib::Enum _attrib) const { return UINT16_MAX != m_attributes[_attrib]; }
  575. /// Returns relative attribute offset from the vertex.
  576. uint16_t getOffset(Attrib::Enum _attrib) const { return m_offset[_attrib]; }
  577. /// Returns vertex stride.
  578. uint16_t getStride() const { return m_stride; }
  579. /// Returns size of vertex buffer for number of vertices.
  580. uint32_t getSize(uint32_t _num) const { return _num*m_stride; }
  581. uint32_t m_hash;
  582. uint16_t m_stride;
  583. uint16_t m_offset[Attrib::Count];
  584. uint16_t m_attributes[Attrib::Count];
  585. };
  586. /// Pack vec4 into vertex stream format.
  587. ///
  588. /// @attention C99 equivalent is `bgfx_vertex_pack`.
  589. ///
  590. void vertexPack(const float _input[4], bool _inputNormalized, Attrib::Enum _attr, const VertexDecl& _decl, void* _data, uint32_t _index = 0);
  591. /// Unpack vec4 from vertex stream format.
  592. ///
  593. /// @attention C99 equivalent is `bgfx_vertex_unpack`.
  594. ///
  595. void vertexUnpack(float _output[4], Attrib::Enum _attr, const VertexDecl& _decl, const void* _data, uint32_t _index = 0);
  596. /// Converts vertex stream data from one vertex stream format to another.
  597. ///
  598. /// @param[in] _destDecl Destination vertex stream declaration.
  599. /// @param[in] _destData Destination vertex stream.
  600. /// @param[in] _srcDecl Source vertex stream declaration.
  601. /// @param[in] _srcData Source vertex stream data.
  602. /// @param[in] _num Number of vertices to convert from source to destination.
  603. ///
  604. /// @attention C99 equivalent is `bgfx_vertex_convert`.
  605. ///
  606. void vertexConvert(const VertexDecl& _destDecl, void* _destData, const VertexDecl& _srcDecl, const void* _srcData, uint32_t _num = 1);
  607. /// Weld vertices.
  608. ///
  609. /// @param[in] _output Welded vertices remapping table. The size of buffer
  610. /// must be the same as number of vertices.
  611. /// @param[in] _decl Vertex stream declaration.
  612. /// @param[in] _data Vertex stream.
  613. /// @param[in] _num Number of vertices in vertex stream.
  614. /// @param[in] _epsilon Error tolerance for vertex position comparison.
  615. /// @returns Number of unique vertices after vertex welding.
  616. ///
  617. /// @attention C99 equivalent is `bgfx_weld_vertices`.
  618. ///
  619. uint16_t weldVertices(uint16_t* _output, const VertexDecl& _decl, const void* _data, uint16_t _num, float _epsilon = 0.001f);
  620. /// Swizzle RGBA8 image to BGRA8.
  621. ///
  622. /// @param[in] _width Width of input image (pixels).
  623. /// @param[in] _height Height of input image (pixels).
  624. /// @param[in] _pitch Pitch of input image (bytes).
  625. /// @param[in] _src Source image.
  626. /// @param[in] _dst Destination image. Must be the same size as input image.
  627. /// _dst might be pointer to the same memory as _src.
  628. ///
  629. /// @attention C99 equivalent is `bgfx_image_swizzle_bgra8`.
  630. ///
  631. void imageSwizzleBgra8(uint32_t _width, uint32_t _height, uint32_t _pitch, const void* _src, void* _dst);
  632. /// Downsample RGBA8 image with 2x2 pixel average filter.
  633. ///
  634. /// @param[in] _width Width of input image (pixels).
  635. /// @param[in] _height Height of input image (pixels).
  636. /// @param[in] _pitch Pitch of input image (bytes).
  637. /// @param[in] _src Source image.
  638. /// @param[in] _dst Destination image. Must be at least quarter size of
  639. /// input image. _dst might be pointer to the same memory as _src.
  640. ///
  641. /// @attention C99 equivalent is `bgfx_image_rgba8_downsample_2x2`.
  642. ///
  643. void imageRgba8Downsample2x2(uint32_t _width, uint32_t _height, uint32_t _pitch, const void* _src, void* _dst);
  644. /// Returns supported backend API renderers.
  645. ///
  646. /// @attention C99 equivalent is `bgfx_get_supported_renderers`.
  647. ///
  648. uint8_t getSupportedRenderers(RendererType::Enum _enum[RendererType::Count]);
  649. /// Returns name of renderer.
  650. ///
  651. /// @attention C99 equivalent is `bgfx_get_renderer_name`.
  652. ///
  653. const char* getRendererName(RendererType::Enum _type);
  654. /// Initialize bgfx library.
  655. ///
  656. /// @param[in] _type Select rendering backend. When set to RendererType::Count
  657. /// default rendering backend will be selected.
  658. /// See: `bgfx::RendererType`
  659. ///
  660. /// @param[in] _vendorId Vendor PCI id. If set to `BGFX_PCI_ID_NONE` it will select the first
  661. /// device.
  662. /// - `BGFX_PCI_ID_NONE` - autoselect.
  663. /// - `BGFX_PCI_ID_AMD` - AMD.
  664. /// - `BGFX_PCI_ID_INTEL` - Intel.
  665. /// - `BGFX_PCI_ID_NVIDIA` - nVidia.
  666. ///
  667. /// @param[in] _deviceId Device id. If set to 0 it will select first device, or device with
  668. /// matching id.
  669. ///
  670. /// @param[in] _callback Provide application specific callback interface.
  671. /// See: `bgfx::CallbackI`
  672. ///
  673. /// @param[in] _reallocator Custom allocator. When custom allocator is not
  674. /// specified, library uses default CRT allocator. The library assumes
  675. /// icustom allocator is thread safe.
  676. ///
  677. /// @returns `true` if initialization is sucessful.
  678. ///
  679. /// @attention C99 equivalent is `bgfx_init`.
  680. ///
  681. bool init(RendererType::Enum _type = RendererType::Count, uint16_t _vendorId = BGFX_PCI_ID_NONE, uint16_t _deviceId = 0, CallbackI* _callback = NULL, bx::ReallocatorI* _reallocator = NULL);
  682. /// Shutdown bgfx library.
  683. ///
  684. /// @attention C99 equivalent is `bgfx_shutdown`.
  685. ///
  686. void shutdown();
  687. /// Reset graphic settings and back-buffer size.
  688. ///
  689. /// @param[in] _width Back-buffer width.
  690. /// @param[in] _height Back-buffer height.
  691. /// @param[in] _flags See: `BGFX_RESET_*` for more info.
  692. /// - `BGFX_RESET_NONE` - No reset flags.
  693. /// - `BGFX_RESET_FULLSCREEN` - Not supported yet.
  694. /// - `BGFX_RESET_MSAA_X[2/4/8/16]` - Enable 2, 4, 8 or 16 x MSAA.
  695. /// - `BGFX_RESET_VSYNC` - Enable V-Sync.
  696. /// - `BGFX_RESET_MAXANISOTROPY` - Turn on/off max anisotropy.
  697. /// - `BGFX_RESET_CAPTURE` - Begin screen capture.
  698. /// - `BGFX_RESET_HMD` - HMD stereo rendering.
  699. /// - `BGFX_RESET_HMD_DEBUG` - HMD stereo rendering debug mode.
  700. /// - `BGFX_RESET_HMD_RECENTER` - HMD calibration.
  701. /// - `BGFX_RESET_FLUSH_AFTER_RENDER` - Flush rendering after submitting to GPU.
  702. /// - `BGFX_RESET_FLIP_AFTER_RENDER` - This flag specifies where flip
  703. /// occurs. Default behavior is that flip occurs before rendering new
  704. /// frame. This flag only has effect when `BGFX_CONFIG_MULTITHREADED=0`.
  705. /// - `BGFX_RESET_SRGB_BACKBUFFER` - Enable sRGB backbuffer.
  706. ///
  707. /// @attention This call doesn't actually change window size, it just
  708. /// resizes back-buffer. Windowing code has to change window size.
  709. ///
  710. /// @attention C99 equivalent is `bgfx_reset`.
  711. ///
  712. void reset(uint32_t _width, uint32_t _height, uint32_t _flags = BGFX_RESET_NONE);
  713. /// Advance to next frame. When using multithreaded renderer, this call
  714. /// just swaps internal buffers, kicks render thread, and returns. In
  715. /// singlethreaded renderer this call does frame rendering.
  716. ///
  717. /// @returns Current frame number. This might be used in conjunction with
  718. /// double/multi buffering data outside the library and passing it to
  719. /// library via `bgfx::makeRef` calls.
  720. ///
  721. /// @attention C99 equivalent is `bgfx_frame`.
  722. ///
  723. uint32_t frame();
  724. /// Returns current renderer backend API type.
  725. ///
  726. /// @remarks
  727. /// Library must be initialized.
  728. ///
  729. /// @attention C99 equivalent is `bgfx_get_renderer_type`.
  730. ///
  731. RendererType::Enum getRendererType();
  732. /// Returns renderer capabilities.
  733. ///
  734. /// @returns Pointer to static `bgfx::Caps` structure.
  735. ///
  736. /// @remarks
  737. /// Library must be initialized.
  738. ///
  739. /// @attention C99 equivalent is `bgfx_get_caps`.
  740. ///
  741. const Caps* getCaps();
  742. /// Returns HMD info.
  743. ///
  744. /// @attention C99 equivalent is `bgfx_get_hmd`.
  745. ///
  746. const HMD* getHMD();
  747. /// Returns performance counters.
  748. ///
  749. const Stats* getStats();
  750. /// Allocate buffer to pass to bgfx calls. Data will be freed inside bgfx.
  751. ///
  752. /// @attention C99 equivalent is `bgfx_alloc`.
  753. ///
  754. const Memory* alloc(uint32_t _size);
  755. /// Allocate buffer and copy data into it. Data will be freed inside bgfx.
  756. ///
  757. /// @attention C99 equivalent is `bgfx_copy`.
  758. ///
  759. const Memory* copy(const void* _data, uint32_t _size);
  760. /// Make reference to data to pass to bgfx. Unlike `bgfx::alloc` this call
  761. /// doesn't allocate memory for data. It just copies pointer to data. You
  762. /// can pass `ReleaseFn` function pointer to release this memory after it's
  763. /// consumed, or you must make sure data is available for at least 2
  764. /// `bgfx::frame` calls. `ReleaseFn` function must be able to be called
  765. /// called from any thread.
  766. ///
  767. /// @attention C99 equivalent are `bgfx_make_ref`, `bgfx_make_ref_release`.
  768. ///
  769. const Memory* makeRef(const void* _data, uint32_t _size, ReleaseFn _releaseFn = NULL, void* _userData = NULL);
  770. /// Set debug flags.
  771. ///
  772. /// @param[in] _debug Available flags:
  773. /// - `BGFX_DEBUG_IFH` - Infinitely fast hardware. When this flag is set
  774. /// all rendering calls will be skipped. It's useful when profiling
  775. /// to quickly assess bottleneck between CPU and GPU.
  776. /// - `BGFX_DEBUG_STATS` - Display internal statistics.
  777. /// - `BGFX_DEBUG_TEXT` - Display debug text.
  778. /// - `BGFX_DEBUG_WIREFRAME` - Wireframe rendering. All rendering
  779. /// primitives will be rendered as lines.
  780. ///
  781. /// @attention C99 equivalent is `bgfx_set_debug`.
  782. ///
  783. void setDebug(uint32_t _debug);
  784. /// Clear internal debug text buffer.
  785. ///
  786. /// @attention C99 equivalent is `bgfx_dbg_text_clear`.
  787. ///
  788. void dbgTextClear(uint8_t _attr = 0, bool _small = false);
  789. /// Print into internal debug text buffer.
  790. ///
  791. /// @attention C99 equivalent is `bgfx_dbg_text_printf`.
  792. ///
  793. void dbgTextPrintf(uint16_t _x, uint16_t _y, uint8_t _attr, const char* _format, ...);
  794. /// Draw image into internal debug text buffer.
  795. ///
  796. /// @param[in] _x X position from top-left.
  797. /// @param[in] _y Y position from top-left.
  798. /// @param[in] _width Image width.
  799. /// @param[in] _height Image height.
  800. /// @param[in] _data Raw image data (character/attribute raw encoding).
  801. /// @param[in] _pitch Image pitch in bytes.
  802. ///
  803. /// @attention C99 equivalent is `bgfx_dbg_text_image`.
  804. ///
  805. void dbgTextImage(uint16_t _x, uint16_t _y, uint16_t _width, uint16_t _height, const void* _data, uint16_t _pitch);
  806. /// Create static index buffer.
  807. ///
  808. /// @param[in] _mem Index buffer data.
  809. /// @param[in] _flags Buffer creation flags.
  810. /// - `BGFX_BUFFER_NONE` - No flags.
  811. /// - `BGFX_BUFFER_COMPUTE_READ` - Buffer will be read from by compute shader.
  812. /// - `BGFX_BUFFER_COMPUTE_WRITE` - Buffer will be written into by compute shader. When buffer
  813. /// is created with `BGFX_BUFFER_COMPUTE_WRITE` flag it cannot be updated from CPU.
  814. /// - `BGFX_BUFFER_COMPUTE_READ_WRITE` - Buffer will be used for read/write by compute shader.
  815. /// - `BGFX_BUFFER_ALLOW_RESIZE` - Buffer will resize on buffer update if different amount of
  816. /// data is passed. If this flag is not specified if more data is passed on update buffer
  817. /// will be trimmed to fit existing buffer size. This flag has effect only on dynamic
  818. /// buffers.
  819. /// - `BGFX_BUFFER_INDEX32` - Buffer is using 32-bit indices. This flag has effect only on
  820. /// index buffers.
  821. ///
  822. /// @attention C99 equivalent is `bgfx_create_index_buffer`.
  823. ///
  824. IndexBufferHandle createIndexBuffer(const Memory* _mem, uint16_t _flags = BGFX_BUFFER_NONE);
  825. /// Destroy static index buffer.
  826. ///
  827. /// @attention C99 equivalent is `bgfx_destroy_index_buffer`.
  828. ///
  829. void destroyIndexBuffer(IndexBufferHandle _handle);
  830. /// Create static vertex buffer.
  831. ///
  832. /// @param[in] _mem Vertex buffer data.
  833. /// @param[in] _decl Vertex declaration.
  834. /// @param[in] _flags Buffer creation flags.
  835. /// - `BGFX_BUFFER_NONE` - No flags.
  836. /// - `BGFX_BUFFER_COMPUTE_READ` - Buffer will be read from by compute shader.
  837. /// - `BGFX_BUFFER_COMPUTE_WRITE` - Buffer will be written into by compute shader. When buffer
  838. /// is created with `BGFX_BUFFER_COMPUTE_WRITE` flag it cannot be updated from CPU.
  839. /// - `BGFX_BUFFER_COMPUTE_READ_WRITE` - Buffer will be used for read/write by compute shader.
  840. /// - `BGFX_BUFFER_ALLOW_RESIZE` - Buffer will resize on buffer update if different amount of
  841. /// data is passed. If this flag is not specified if more data is passed on update buffer
  842. /// will be trimmed to fit existing buffer size. This flag has effect only on dynamic
  843. /// buffers.
  844. /// - `BGFX_BUFFER_INDEX32` - Buffer is using 32-bit indices. This flag has effect only on
  845. /// index buffers.
  846. /// @returns Static vertex buffer handle.
  847. ///
  848. /// @attention C99 equivalent is `bgfx_create_vertex_buffer`.
  849. ///
  850. VertexBufferHandle createVertexBuffer(const Memory* _mem, const VertexDecl& _decl, uint16_t _flags = BGFX_BUFFER_NONE);
  851. /// Destroy static vertex buffer.
  852. ///
  853. /// @param[in] _handle Static vertex buffer handle.
  854. ///
  855. /// @attention C99 equivalent is `bgfx_destroy_vertex_buffer`.
  856. ///
  857. void destroyVertexBuffer(VertexBufferHandle _handle);
  858. /// Create empty dynamic index buffer.
  859. ///
  860. /// @param[in] _num Number of indices.
  861. /// @param[in] _flags Buffer creation flags.
  862. /// - `BGFX_BUFFER_NONE` - No flags.
  863. /// - `BGFX_BUFFER_COMPUTE_READ` - Buffer will be read from by compute shader.
  864. /// - `BGFX_BUFFER_COMPUTE_WRITE` - Buffer will be written into by compute shader. When buffer
  865. /// is created with `BGFX_BUFFER_COMPUTE_WRITE` flag it cannot be updated from CPU.
  866. /// - `BGFX_BUFFER_COMPUTE_READ_WRITE` - Buffer will be used for read/write by compute shader.
  867. /// - `BGFX_BUFFER_ALLOW_RESIZE` - Buffer will resize on buffer update if different amount of
  868. /// data is passed. If this flag is not specified if more data is passed on update buffer
  869. /// will be trimmed to fit existing buffer size. This flag has effect only on dynamic
  870. /// buffers.
  871. /// - `BGFX_BUFFER_INDEX32` - Buffer is using 32-bit indices. This flag has effect only on
  872. /// index buffers.
  873. ///
  874. /// @attention C99 equivalent is `bgfx_create_dynamic_index_buffer`.
  875. ///
  876. DynamicIndexBufferHandle createDynamicIndexBuffer(uint32_t _num, uint16_t _flags = BGFX_BUFFER_NONE);
  877. /// Create dynamic index buffer and initialized it.
  878. ///
  879. /// @param[in] _mem Index buffer data.
  880. /// @param[in] _flags Buffer creation flags.
  881. /// - `BGFX_BUFFER_NONE` - No flags.
  882. /// - `BGFX_BUFFER_COMPUTE_READ` - Buffer will be read from by compute shader.
  883. /// - `BGFX_BUFFER_COMPUTE_WRITE` - Buffer will be written into by compute shader. When buffer
  884. /// is created with `BGFX_BUFFER_COMPUTE_WRITE` flag it cannot be updated from CPU.
  885. /// - `BGFX_BUFFER_COMPUTE_READ_WRITE` - Buffer will be used for read/write by compute shader.
  886. /// - `BGFX_BUFFER_ALLOW_RESIZE` - Buffer will resize on buffer update if different amount of
  887. /// data is passed. If this flag is not specified if more data is passed on update buffer
  888. /// will be trimmed to fit existing buffer size. This flag has effect only on dynamic
  889. /// buffers.
  890. /// - `BGFX_BUFFER_INDEX32` - Buffer is using 32-bit indices. This flag has effect only on
  891. /// index buffers.
  892. ///
  893. /// @attention C99 equivalent is `bgfx_create_dynamic_index_buffer_mem`.
  894. ///
  895. DynamicIndexBufferHandle createDynamicIndexBuffer(const Memory* _mem, uint16_t _flags = BGFX_BUFFER_NONE);
  896. /// Update dynamic index buffer.
  897. ///
  898. /// @param[in] _handle Dynamic index buffer handle.
  899. /// @param[in] _startIndex Start index.
  900. /// @param[in] _mem Index buffer data.
  901. ///
  902. /// @attention C99 equivalent is `bgfx_update_dynamic_index_buffer`.
  903. ///
  904. void updateDynamicIndexBuffer(DynamicIndexBufferHandle _handle, uint32_t _startIndex, const Memory* _mem);
  905. /// Destroy dynamic index buffer.
  906. ///
  907. /// @param[in] _handle Dynamic index buffer handle.
  908. ///
  909. /// @attention C99 equivalent is `bgfx_destroy_dynamic_index_buffer`.
  910. ///
  911. void destroyDynamicIndexBuffer(DynamicIndexBufferHandle _handle);
  912. /// Create empty dynamic vertex buffer.
  913. ///
  914. /// @param[in] _num Number of vertices.
  915. /// @param[in] _decl Vertex declaration.
  916. /// @param[in] _flags Buffer creation flags.
  917. /// - `BGFX_BUFFER_NONE` - No flags.
  918. /// - `BGFX_BUFFER_COMPUTE_READ` - Buffer will be read from by compute shader.
  919. /// - `BGFX_BUFFER_COMPUTE_WRITE` - Buffer will be written into by compute shader. When buffer
  920. /// is created with `BGFX_BUFFER_COMPUTE_WRITE` flag it cannot be updated from CPU.
  921. /// - `BGFX_BUFFER_COMPUTE_READ_WRITE` - Buffer will be used for read/write by compute shader.
  922. /// - `BGFX_BUFFER_ALLOW_RESIZE` - Buffer will resize on buffer update if different amount of
  923. /// data is passed. If this flag is not specified if more data is passed on update buffer
  924. /// will be trimmed to fit existing buffer size. This flag has effect only on dynamic
  925. /// buffers.
  926. /// - `BGFX_BUFFER_INDEX32` - Buffer is using 32-bit indices. This flag has effect only on
  927. /// index buffers.
  928. ///
  929. /// @attention C99 equivalent is `bgfx_create_dynamic_vertex_buffer`.
  930. ///
  931. DynamicVertexBufferHandle createDynamicVertexBuffer(uint32_t _num, const VertexDecl& _decl, uint16_t _flags = BGFX_BUFFER_NONE);
  932. /// Create dynamic vertex buffer and initialize it.
  933. ///
  934. /// @param[in] _mem Vertex buffer data.
  935. /// @param[in] _decl Vertex declaration.
  936. /// @param[in] _flags Buffer creation flags.
  937. /// - `BGFX_BUFFER_NONE` - No flags.
  938. /// - `BGFX_BUFFER_COMPUTE_READ` - Buffer will be read from by compute shader.
  939. /// - `BGFX_BUFFER_COMPUTE_WRITE` - Buffer will be written into by compute shader. When buffer
  940. /// is created with `BGFX_BUFFER_COMPUTE_WRITE` flag it cannot be updated from CPU.
  941. /// - `BGFX_BUFFER_COMPUTE_READ_WRITE` - Buffer will be used for read/write by compute shader.
  942. /// - `BGFX_BUFFER_ALLOW_RESIZE` - Buffer will resize on buffer update if different amount of
  943. /// data is passed. If this flag is not specified if more data is passed on update buffer
  944. /// will be trimmed to fit existing buffer size. This flag has effect only on dynamic
  945. /// buffers.
  946. /// - `BGFX_BUFFER_INDEX32` - Buffer is using 32-bit indices. This flag has effect only on
  947. /// index buffers.
  948. ///
  949. /// @attention C99 equivalent is `bgfx_create_dynamic_vertex_buffer_mem`.
  950. ///
  951. DynamicVertexBufferHandle createDynamicVertexBuffer(const Memory* _mem, const VertexDecl& _decl, uint16_t _flags = BGFX_BUFFER_NONE);
  952. /// Update dynamic vertex buffer.
  953. ///
  954. /// @param[in] _handle Dynamic vertex buffer handle.
  955. /// @param[in] _startVertex Start vertex.
  956. /// @param[in] _mem Vertex buffer data.
  957. ///
  958. /// @attention C99 equivalent is `bgfx_update_dynamic_vertex_buffer`.
  959. ///
  960. void updateDynamicVertexBuffer(DynamicVertexBufferHandle _handle, uint32_t _startVertex, const Memory* _mem);
  961. /// Destroy dynamic vertex buffer.
  962. ///
  963. /// @attention C99 equivalent is `bgfx_destroy_dynamic_vertex_buffer`.
  964. ///
  965. void destroyDynamicVertexBuffer(DynamicVertexBufferHandle _handle);
  966. /// Returns true if internal transient index buffer has enough space.
  967. ///
  968. /// @param[in] _num Number of indices.
  969. ///
  970. /// @attention C99 equivalent is `bgfx_check_avail_transient_index_buffer`.
  971. ///
  972. bool checkAvailTransientIndexBuffer(uint32_t _num);
  973. /// Returns true if internal transient vertex buffer has enough space.
  974. ///
  975. /// @param[in] _num Number of vertices.
  976. /// @param[in] _decl Vertex declaration.
  977. ///
  978. /// @attention C99 equivalent is `bgfx_check_avail_transient_vertex_buffer`.
  979. ///
  980. bool checkAvailTransientVertexBuffer(uint32_t _num, const VertexDecl& _decl);
  981. /// Returns true if internal instance data buffer has enough space.
  982. ///
  983. /// @param[in] _num Number of instances.
  984. /// @param[in] _stride Stride per instance.
  985. ///
  986. /// @attention C99 equivalent is `bgfx_check_avail_instance_data_buffer`.
  987. ///
  988. bool checkAvailInstanceDataBuffer(uint32_t _num, uint16_t _stride);
  989. /// Returns true if both internal transient index and vertex buffer have
  990. /// enough space.
  991. ///
  992. /// @param[in] _numVertices Number of vertices.
  993. /// @param[in] _decl Vertex declaration.
  994. /// @param[in] _numIndices Number of indices.
  995. ///
  996. /// @attention C99 equivalent is `bgfx_check_avail_transient_buffers`.
  997. ///
  998. bool checkAvailTransientBuffers(uint32_t _numVertices, const VertexDecl& _decl, uint32_t _numIndices);
  999. /// Allocate transient index buffer.
  1000. ///
  1001. /// @param[out] _tib TransientIndexBuffer structure is filled and is valid
  1002. /// for the duration of frame, and it can be reused for multiple draw
  1003. /// calls.
  1004. /// @param[in] _num Number of indices to allocate.
  1005. ///
  1006. /// @remarks
  1007. /// 1. You must call setIndexBuffer after alloc in order to avoid memory
  1008. /// leak.
  1009. /// 2. Only 16-bit index buffer is supported.
  1010. ///
  1011. /// @attention C99 equivalent is `bgfx_alloc_transient_index_buffer`.
  1012. ///
  1013. void allocTransientIndexBuffer(TransientIndexBuffer* _tib, uint32_t _num);
  1014. /// Allocate transient vertex buffer.
  1015. ///
  1016. /// @param[out] _tvb TransientVertexBuffer structure is filled and is valid
  1017. /// for the duration of frame, and it can be reused for multiple draw
  1018. /// calls.
  1019. /// @param[in] _num Number of vertices to allocate.
  1020. /// @param[in] _decl Vertex declaration.
  1021. ///
  1022. /// @remarks
  1023. /// You must call setVertexBuffer after alloc in order to avoid memory
  1024. /// leak.
  1025. ///
  1026. /// @attention C99 equivalent is `bgfx_alloc_transient_vertex_buffer`.
  1027. ///
  1028. void allocTransientVertexBuffer(TransientVertexBuffer* _tvb, uint32_t _num, const VertexDecl& _decl);
  1029. /// Check for required space and allocate transient vertex and index
  1030. /// buffers. If both space requirements are satisfied function returns
  1031. /// true.
  1032. ///
  1033. /// @remarks
  1034. /// Only 16-bit index buffer is supported.
  1035. ///
  1036. /// @attention C99 equivalent is `bgfx_alloc_transient_buffers`.
  1037. ///
  1038. bool allocTransientBuffers(TransientVertexBuffer* _tvb, const VertexDecl& _decl, uint32_t _numVertices, TransientIndexBuffer* _tib, uint32_t _numIndices);
  1039. /// Allocate instance data buffer.
  1040. ///
  1041. /// @remarks
  1042. /// You must call setInstanceDataBuffer after alloc in order to avoid
  1043. /// memory leak.
  1044. ///
  1045. /// @attention C99 equivalent is `bgfx_alloc_instance_data_buffer`.
  1046. ///
  1047. const InstanceDataBuffer* allocInstanceDataBuffer(uint32_t _num, uint16_t _stride);
  1048. /// Create draw indirect buffer.
  1049. ///
  1050. /// @attention C99 equivalent is `bgfx_create_indirect_buffer`.
  1051. ///
  1052. IndirectBufferHandle createIndirectBuffer(uint32_t _num);
  1053. /// Destroy draw indirect buffer.
  1054. ///
  1055. /// @attention C99 equivalent is `bgfx_destroy_indirect_buffer`.
  1056. ///
  1057. void destroyIndirectBuffer(IndirectBufferHandle _handle);
  1058. /// Create shader from memory buffer.
  1059. ///
  1060. /// @attention C99 equivalent is `bgfx_create_shader`.
  1061. ///
  1062. ShaderHandle createShader(const Memory* _mem);
  1063. /// Returns num of uniforms, and uniform handles used inside shader.
  1064. ///
  1065. /// @param[in] _handle Shader handle.
  1066. /// @param[in] _uniforms UniformHandle array where data will be stored.
  1067. /// @param[in] _max Maximum capacity of array.
  1068. /// @returns Number of uniforms used by shader.
  1069. ///
  1070. /// @remarks
  1071. /// Only non-predefined uniforms are returned.
  1072. ///
  1073. /// @attention C99 equivalent is `bgfx_get_shader_uniforms`.
  1074. ///
  1075. uint16_t getShaderUniforms(ShaderHandle _handle, UniformHandle* _uniforms = NULL, uint16_t _max = 0);
  1076. /// Destroy shader. Once program is created with shader it is safe to
  1077. /// destroy shader.
  1078. ///
  1079. /// @attention C99 equivalent is `bgfx_destroy_shader`.
  1080. ///
  1081. void destroyShader(ShaderHandle _handle);
  1082. /// Create program with vertex and fragment shaders.
  1083. ///
  1084. /// @param[in] _vsh Vertex shader.
  1085. /// @param[in] _fsh Fragment shader.
  1086. /// @param[in] _destroyShaders If true, shaders will be destroyed when
  1087. /// program is destroyed.
  1088. /// @returns Program handle if vertex shader output and fragment shader
  1089. /// input are matching, otherwise returns invalid program handle.
  1090. ///
  1091. /// @attention C99 equivalent is `bgfx_create_program`.
  1092. ///
  1093. ProgramHandle createProgram(ShaderHandle _vsh, ShaderHandle _fsh, bool _destroyShaders = false);
  1094. /// Create program with compute shader.
  1095. ///
  1096. /// @param[in] _csh Compute shader.
  1097. /// @param[in] _destroyShader If true, shader will be destroyed when
  1098. /// program is destroyed.
  1099. /// @returns Program handle.
  1100. ///
  1101. /// @attention C99 equivalent is `bgfx_create_compute_program`.
  1102. ///
  1103. ProgramHandle createProgram(ShaderHandle _csh, bool _destroyShader = false);
  1104. /// Destroy program.
  1105. ///
  1106. /// @attention C99 equivalent is `bgfx_destroy_program`.
  1107. ///
  1108. void destroyProgram(ProgramHandle _handle);
  1109. /// Calculate amount of memory required for texture.
  1110. ///
  1111. /// @attention C99 equivalent is `bgfx_calc_texture_size`.
  1112. ///
  1113. void calcTextureSize(TextureInfo& _info, uint16_t _width, uint16_t _height, uint16_t _depth, bool _cubeMap, uint8_t _numMips, TextureFormat::Enum _format);
  1114. /// Create texture from memory buffer.
  1115. ///
  1116. /// @param[in] _mem DDS, KTX or PVR texture data.
  1117. /// @param[in] _flags Default texture sampling mode is linear, and wrap mode
  1118. /// is repeat.
  1119. /// - `BGFX_TEXTURE_[U/V/W]_[MIRROR/CLAMP]` - Mirror or clamp to edge wrap
  1120. /// mode.
  1121. /// - `BGFX_TEXTURE_[MIN/MAG/MIP]_[POINT/ANISOTROPIC]` - Point or anisotropic
  1122. /// sampling.
  1123. ///
  1124. /// @param[in] _skip Skip top level mips when parsing texture.
  1125. /// @param[out] _info When non-`NULL` is specified it returns parsed texture information.
  1126. /// @returns Texture handle.
  1127. ///
  1128. /// @attention C99 equivalent is `bgfx_create_texture`.
  1129. ///
  1130. TextureHandle createTexture(const Memory* _mem, uint32_t _flags = BGFX_TEXTURE_NONE, uint8_t _skip = 0, TextureInfo* _info = NULL);
  1131. /// Create 2D texture.
  1132. ///
  1133. /// @param[in] _width Width.
  1134. /// @param[in] _height Height.
  1135. /// @param[in] _numMips Number of mip-maps.
  1136. /// @param[in] _format Texture format. See: `TextureFormat::Enum`.
  1137. /// @param[in] _flags Default texture sampling mode is linear, and wrap mode
  1138. /// is repeat.
  1139. /// - `BGFX_TEXTURE_[U/V/W]_[MIRROR/CLAMP]` - Mirror or clamp to edge wrap
  1140. /// mode.
  1141. /// - `BGFX_TEXTURE_[MIN/MAG/MIP]_[POINT/ANISOTROPIC]` - Point or anisotropic
  1142. /// sampling.
  1143. ///
  1144. /// @param[in] _mem Texture data. If `_mem` is non-NULL, created texture will be immutable.
  1145. ///
  1146. /// @attention C99 equivalent is `bgfx_create_texture_2d`.
  1147. ///
  1148. TextureHandle createTexture2D(uint16_t _width, uint16_t _height, uint8_t _numMips, TextureFormat::Enum _format, uint32_t _flags = BGFX_TEXTURE_NONE, const Memory* _mem = NULL);
  1149. /// Create frame buffer with size based on backbuffer ratio. Frame buffer will maintain ratio
  1150. /// if back buffer resolution changes.
  1151. ///
  1152. /// @param[in] _ratio Frame buffer size in respect to back-buffer size. See:
  1153. /// `BackbufferRatio::Enum`.
  1154. /// @param[in] _numMips Number of mip-maps.
  1155. /// @param[in] _format Texture format. See: `TextureFormat::Enum`.
  1156. /// @param[in] _flags Default texture sampling mode is linear, and wrap mode
  1157. /// is repeat.
  1158. /// - `BGFX_TEXTURE_[U/V/W]_[MIRROR/CLAMP]` - Mirror or clamp to edge wrap
  1159. /// mode.
  1160. /// - `BGFX_TEXTURE_[MIN/MAG/MIP]_[POINT/ANISOTROPIC]` - Point or anisotropic
  1161. /// sampling.
  1162. ///
  1163. /// @attention C99 equivalent is `bgfx_create_texture_2d_scaled`.
  1164. ///
  1165. TextureHandle createTexture2D(BackbufferRatio::Enum _ratio, uint8_t _numMips, TextureFormat::Enum _format, uint32_t _flags = BGFX_TEXTURE_NONE);
  1166. /// Create 3D texture.
  1167. ///
  1168. /// @param[in] _width Width.
  1169. /// @param[in] _height Height.
  1170. /// @param[in] _depth Depth.
  1171. /// @param[in] _numMips Number of mip-maps.
  1172. /// @param[in] _format Texture format. See: `TextureFormat::Enum`.
  1173. /// @param[in] _flags Default texture sampling mode is linear, and wrap mode
  1174. /// is repeat.
  1175. /// - `BGFX_TEXTURE_[U/V/W]_[MIRROR/CLAMP]` - Mirror or clamp to edge wrap
  1176. /// mode.
  1177. /// - `BGFX_TEXTURE_[MIN/MAG/MIP]_[POINT/ANISOTROPIC]` - Point or anisotropic
  1178. /// sampling.
  1179. ///
  1180. /// @param[in] _mem Texture data. If `_mem` is non-NULL, created texture will be immutable.
  1181. ///
  1182. /// @attention C99 equivalent is `bgfx_create_texture_3d`.
  1183. ///
  1184. TextureHandle createTexture3D(uint16_t _width, uint16_t _height, uint16_t _depth, uint8_t _numMips, TextureFormat::Enum _format, uint32_t _flags = BGFX_TEXTURE_NONE, const Memory* _mem = NULL);
  1185. /// Create Cube texture.
  1186. ///
  1187. /// @param[in] _size Cube side size.
  1188. /// @param[in] _numMips Number of mip-maps.
  1189. /// @param[in] _format Texture format. See: `TextureFormat::Enum`.
  1190. /// @param[in] _flags Default texture sampling mode is linear, and wrap mode
  1191. /// is repeat.
  1192. /// - `BGFX_TEXTURE_[U/V/W]_[MIRROR/CLAMP]` - Mirror or clamp to edge wrap
  1193. /// mode.
  1194. /// - `BGFX_TEXTURE_[MIN/MAG/MIP]_[POINT/ANISOTROPIC]` - Point or anisotropic
  1195. /// sampling.
  1196. ///
  1197. /// @param[in] _mem Texture data. If `_mem` is non-NULL, created texture will be immutable.
  1198. ///
  1199. /// @attention C99 equivalent is `bgfx_create_texture_cube`.
  1200. ///
  1201. TextureHandle createTextureCube(uint16_t _size, uint8_t _numMips, TextureFormat::Enum _format, uint32_t _flags = BGFX_TEXTURE_NONE, const Memory* _mem = NULL);
  1202. /// Update 2D texture.
  1203. ///
  1204. /// @param[in] _handle Texture handle.
  1205. /// @param[in] _mip Mip level.
  1206. /// @param[in] _x X offset in texture.
  1207. /// @param[in] _y Y offset in texture.
  1208. /// @param[in] _width Width of texture block.
  1209. /// @param[in] _height Height of texture block.
  1210. /// @param[in] _mem Texture update data.
  1211. /// @param[in] _pitch Pitch of input image (bytes). When _pitch is set to
  1212. /// UINT16_MAX, it will be calculated internally based on _width.
  1213. ///
  1214. /// @attention C99 equivalent is `bgfx_update_texture_2d`.
  1215. ///
  1216. void updateTexture2D(TextureHandle _handle, uint8_t _mip, uint16_t _x, uint16_t _y, uint16_t _width, uint16_t _height, const Memory* _mem, uint16_t _pitch = UINT16_MAX);
  1217. /// Update 3D texture.
  1218. ///
  1219. /// @param[in] _handle Texture handle.
  1220. /// @param[in] _mip Mip level.
  1221. /// @param[in] _x X offset in texture.
  1222. /// @param[in] _y Y offset in texture.
  1223. /// @param[in] _z Z offset in texture.
  1224. /// @param[in] _width Width of texture block.
  1225. /// @param[in] _height Height of texture block.
  1226. /// @param[in] _depth Depth of texture block.
  1227. /// @param[in] _mem Texture update data.
  1228. ///
  1229. /// @attention C99 equivalent is `bgfx_update_texture_3d`.
  1230. ///
  1231. void updateTexture3D(TextureHandle _handle, uint8_t _mip, uint16_t _x, uint16_t _y, uint16_t _z, uint16_t _width, uint16_t _height, uint16_t _depth, const Memory* _mem);
  1232. /// Update Cube texture.
  1233. ///
  1234. /// @param[in] _handle Texture handle.
  1235. /// @param[in] _side Cubemap side, where 0 is +X, 1 is -X, 2 is +Y, 3 is
  1236. /// -Y, 4 is +Z, and 5 is -Z.
  1237. ///
  1238. /// +----------+
  1239. /// |-z 2|
  1240. /// | ^ +y |
  1241. /// | | |
  1242. /// | +---->+x |
  1243. /// +----------+----------+----------+----------+
  1244. /// |+y 1|+y 4|+y 0|+y 5|
  1245. /// | ^ -x | ^ +z | ^ +x | ^ -z |
  1246. /// | | | | | | | | |
  1247. /// | +---->+z | +---->+x | +---->-z | +---->-x |
  1248. /// +----------+----------+----------+----------+
  1249. /// |+z 3|
  1250. /// | ^ -y |
  1251. /// | | |
  1252. /// | +---->+x |
  1253. /// +----------+
  1254. ///
  1255. /// @param[in] _mip Mip level.
  1256. /// @param[in] _x X offset in texture.
  1257. /// @param[in] _y Y offset in texture.
  1258. /// @param[in] _width Width of texture block.
  1259. /// @param[in] _height Height of texture block.
  1260. /// @param[in] _mem Texture update data.
  1261. /// @param[in] _pitch Pitch of input image (bytes). When _pitch is set to
  1262. /// UINT16_MAX, it will be calculated internally based on _width.
  1263. ///
  1264. /// @attention C99 equivalent is `bgfx_update_texture_cube`.
  1265. ///
  1266. void updateTextureCube(TextureHandle _handle, uint8_t _side, uint8_t _mip, uint16_t _x, uint16_t _y, uint16_t _width, uint16_t _height, const Memory* _mem, uint16_t _pitch = UINT16_MAX);
  1267. /// Destroy texture.
  1268. ///
  1269. /// @attention C99 equivalent is `bgfx_destroy_texture`.
  1270. ///
  1271. void destroyTexture(TextureHandle _handle);
  1272. /// Create frame buffer (simple).
  1273. ///
  1274. /// @param[in] _width Texture width.
  1275. /// @param[in] _height Texture height.
  1276. /// @param[in] _format Texture format. See: `TextureFormat::Enum`.
  1277. /// @param[in] _textureFlags Default texture sampling mode is linear, and wrap mode
  1278. /// is repeat.
  1279. /// - `BGFX_TEXTURE_[U/V/W]_[MIRROR/CLAMP]` - Mirror or clamp to edge wrap
  1280. /// mode.
  1281. /// - `BGFX_TEXTURE_[MIN/MAG/MIP]_[POINT/ANISOTROPIC]` - Point or anisotropic
  1282. /// sampling.
  1283. ///
  1284. /// @attention C99 equivalent is `bgfx_create_frame_buffer`.
  1285. ///
  1286. FrameBufferHandle createFrameBuffer(uint16_t _width, uint16_t _height, TextureFormat::Enum _format, uint32_t _textureFlags = BGFX_TEXTURE_U_CLAMP|BGFX_TEXTURE_V_CLAMP);
  1287. /// Create frame buffer with size based on backbuffer ratio. Frame buffer will maintain ratio
  1288. /// if back buffer resolution changes.
  1289. ///
  1290. /// @param[in] _ratio Frame buffer size in respect to back-buffer size. See:
  1291. /// `BackbufferRatio::Enum`.
  1292. /// @param[in] _format Texture format. See: `TextureFormat::Enum`.
  1293. /// @param[in] _textureFlags Default texture sampling mode is linear, and wrap mode
  1294. /// is repeat.
  1295. /// - `BGFX_TEXTURE_[U/V/W]_[MIRROR/CLAMP]` - Mirror or clamp to edge wrap
  1296. /// mode.
  1297. /// - `BGFX_TEXTURE_[MIN/MAG/MIP]_[POINT/ANISOTROPIC]` - Point or anisotropic
  1298. /// sampling.
  1299. ///
  1300. /// @attention C99 equivalent is `bgfx_create_frame_buffer_scaled`.
  1301. ///
  1302. FrameBufferHandle createFrameBuffer(BackbufferRatio::Enum _ratio, TextureFormat::Enum _format, uint32_t _textureFlags = BGFX_TEXTURE_U_CLAMP|BGFX_TEXTURE_V_CLAMP);
  1303. /// Create frame buffer.
  1304. ///
  1305. /// @param[in] _num Number of texture attachments.
  1306. /// @param[in] _handles Texture attachments.
  1307. /// @param[in] _destroyTextures If true, textures will be destroyed when
  1308. /// frame buffer is destroyed.
  1309. ///
  1310. /// @attention C99 equivalent is `bgfx_create_frame_buffer_from_handles`.
  1311. ///
  1312. FrameBufferHandle createFrameBuffer(uint8_t _num, TextureHandle* _handles, bool _destroyTextures = false);
  1313. /// Create frame buffer for multiple window rendering.
  1314. ///
  1315. /// @param[in] _nwh OS' target native window handle.
  1316. /// @param[in] _width Window back buffer width.
  1317. /// @param[in] _height Window back buffer height.
  1318. /// @param[in] _depthFormat Window back buffer depth format.
  1319. ///
  1320. /// @returns Handle to frame buffer object.
  1321. ///
  1322. /// @remarks
  1323. /// Frame buffer cannnot be used for sampling.
  1324. ///
  1325. /// @attention C99 equivalent is `bgfx_create_frame_buffer_from_nwh`.
  1326. ///
  1327. FrameBufferHandle createFrameBuffer(void* _nwh, uint16_t _width, uint16_t _height, TextureFormat::Enum _depthFormat = TextureFormat::UnknownDepth);
  1328. /// Destroy frame buffer.
  1329. ///
  1330. /// @attention C99 equivalent is `bgfx_destroy_frame_buffer`.
  1331. ///
  1332. void destroyFrameBuffer(FrameBufferHandle _handle);
  1333. /// Create shader uniform parameter.
  1334. ///
  1335. /// @param[in] _name Uniform name in shader.
  1336. /// @param[in] _type Type of uniform (See: `bgfx::UniformType`).
  1337. /// @param[in] _num Number of elements in array.
  1338. ///
  1339. /// @returns Handle to uniform object.
  1340. ///
  1341. /// @remarks
  1342. /// Predefined uniforms (declared in `bgfx_shader.sh`):
  1343. /// - `u_viewRect vec4(x, y, width, height)` - view rectangle for current
  1344. /// view.
  1345. /// - `u_viewTexel vec4(1.0/width, 1.0/height, undef, undef)` - inverse
  1346. /// width and height
  1347. /// - `u_view mat4` - view matrix
  1348. /// - `u_invView mat4` - inverted view matrix
  1349. /// - `u_proj mat4` - projection matrix
  1350. /// - `u_invProj mat4` - inverted projection matrix
  1351. /// - `u_viewProj mat4` - concatenated view projection matrix
  1352. /// - `u_invViewProj mat4` - concatenated inverted view projection matrix
  1353. /// - `u_model mat4[BGFX_CONFIG_MAX_BONES]` - array of model matrices.
  1354. /// - `u_modelView mat4` - concatenated model view matrix, only first
  1355. /// model matrix from array is used.
  1356. /// - `u_modelViewProj mat4` - concatenated model view projection matrix.
  1357. /// - `u_alphaRef float` - alpha reference value for alpha test.
  1358. ///
  1359. /// @attention C99 equivalent is `bgfx_create_uniform`.
  1360. ///
  1361. UniformHandle createUniform(const char* _name, UniformType::Enum _type, uint16_t _num = 1);
  1362. /// Destroy shader uniform parameter.
  1363. ///
  1364. /// @param[in] _handle Handle to uniform object.
  1365. ///
  1366. /// @attention C99 equivalent is `bgfx_destroy_uniform`.
  1367. ///
  1368. void destroyUniform(UniformHandle _handle);
  1369. /// Set clear color palette value.
  1370. ///
  1371. /// @param[in] _index Index into palette.
  1372. /// @param[in] _rgba Packed 32-bit RGBA value.
  1373. ///
  1374. /// @attention C99 equivalent is `bgfx_set_clear_color`.
  1375. ///
  1376. void setClearColor(uint8_t _index, uint32_t _rgba);
  1377. /// Set clear color palette value.
  1378. ///
  1379. /// @param[in] _index Index into palette.
  1380. /// @param[in] _r, _g, _b, _a RGBA floating point values.
  1381. ///
  1382. /// @attention C99 equivalent is `bgfx_set_clear_color`.
  1383. ///
  1384. void setClearColor(uint8_t _index, float _r, float _g, float _b, float _a);
  1385. /// Set clear color palette value.
  1386. ///
  1387. /// @param[in] _index Index into palette.
  1388. /// @param[in] _rgba RGBA floating point value.
  1389. ///
  1390. /// @attention C99 equivalent is `bgfx_set_clear_color`.
  1391. ///
  1392. void setClearColor(uint8_t _index, const float _rgba[4]);
  1393. /// Set view name.
  1394. ///
  1395. /// @param[in] _id View id.
  1396. /// @param[in] _name View name.
  1397. ///
  1398. /// @remarks
  1399. /// This is debug only feature.
  1400. ///
  1401. /// In graphics debugger view name will appear as:
  1402. ///
  1403. /// "nnnce <view name>"
  1404. /// ^ ^^ ^
  1405. /// | |+-- eye (L/R)
  1406. /// | +-- compute (C)
  1407. /// +-- view id
  1408. ///
  1409. /// @attention C99 equivalent is `bgfx_set_view_name`.
  1410. ///
  1411. void setViewName(uint8_t _id, const char* _name);
  1412. /// Set view rectangle. Draw primitive outside view will be clipped.
  1413. ///
  1414. /// @param[in] _id View id.
  1415. /// @param[in] _x Position x from the left corner of the window.
  1416. /// @param[in] _y Position y from the top corner of the window.
  1417. /// @param[in] _width Width of view port region.
  1418. /// @param[in] _height Height of view port region.
  1419. ///
  1420. /// @attention C99 equivalent is `bgfx_set_view_rect`.
  1421. ///
  1422. void setViewRect(uint8_t _id, uint16_t _x, uint16_t _y, uint16_t _width, uint16_t _height);
  1423. /// Set view scissor. Draw primitive outside view will be clipped. When
  1424. /// _x, _y, _width and _height are set to 0, scissor will be disabled.
  1425. ///
  1426. /// @param[in] _id View id.
  1427. /// @param[in] _x Position x from the left corner of the window.
  1428. /// @param[in] _y Position y from the top corner of the window.
  1429. /// @param[in] _width Width of scissor region.
  1430. /// @param[in] _height Height of scissor region.
  1431. ///
  1432. /// @attention C99 equivalent is `bgfx_set_view_scissor`.
  1433. ///
  1434. void setViewScissor(uint8_t _id, uint16_t _x = 0, uint16_t _y = 0, uint16_t _width = 0, uint16_t _height = 0);
  1435. /// Set view clear flags.
  1436. ///
  1437. /// @param[in] _id View id.
  1438. /// @param[in] _flags Clear flags. Use `BGFX_CLEAR_NONE` to remove any clear
  1439. /// operation. See: `BGFX_CLEAR_*`.
  1440. /// @param[in] _rgba Color clear value.
  1441. /// @param[in] _depth Depth clear value.
  1442. /// @param[in] _stencil Stencil clear value.
  1443. ///
  1444. /// @attention C99 equivalent is `bgfx_set_view_clear`.
  1445. ///
  1446. void setViewClear(uint8_t _id, uint16_t _flags, uint32_t _rgba = 0x000000ff, float _depth = 1.0f, uint8_t _stencil = 0);
  1447. /// Set view clear flags with different clear color for each
  1448. /// frame buffer texture. Must use setClearColor to setup clear color
  1449. /// palette.
  1450. ///
  1451. /// @param[in] _id View id.
  1452. /// @param[in] _flags Clear flags. Use `BGFX_CLEAR_NONE` to remove any clear
  1453. /// operation. See: `BGFX_CLEAR_*`.
  1454. /// @param[in] _depth Depth clear value.
  1455. /// @param[in] _stencil Stencil clear value.
  1456. /// @param[in] _0 Palette index for frame buffer attachment 0.
  1457. /// @param[in] _1 Palette index for frame buffer attachment 1.
  1458. /// @param[in] _2 Palette index for frame buffer attachment 2.
  1459. /// @param[in] _3 Palette index for frame buffer attachment 3.
  1460. /// @param[in] _4 Palette index for frame buffer attachment 4.
  1461. /// @param[in] _5 Palette index for frame buffer attachment 5.
  1462. /// @param[in] _6 Palette index for frame buffer attachment 6.
  1463. /// @param[in] _7 Palette index for frame buffer attachment 7.
  1464. ///
  1465. /// @attention C99 equivalent is `bgfx_set_view_clear_mrt`.
  1466. ///
  1467. void setViewClear(uint8_t _id, uint16_t _flags, float _depth, uint8_t _stencil, uint8_t _0 = UINT8_MAX, uint8_t _1 = UINT8_MAX, uint8_t _2 = UINT8_MAX, uint8_t _3 = UINT8_MAX, uint8_t _4 = UINT8_MAX, uint8_t _5 = UINT8_MAX, uint8_t _6 = UINT8_MAX, uint8_t _7 = UINT8_MAX);
  1468. /// Set view into sequential mode. Draw calls will be sorted in the same
  1469. /// order in which submit calls were called.
  1470. ///
  1471. /// @attention C99 equivalent is `bgfx_set_view_seq`.
  1472. ///
  1473. void setViewSeq(uint8_t _id, bool _enabled);
  1474. /// Set view frame buffer.
  1475. ///
  1476. /// @param[in] _id View id.
  1477. /// @param[in] _handle Frame buffer handle. Passing `BGFX_INVALID_HANDLE` as
  1478. /// frame buffer handle will draw primitives from this view into
  1479. /// default back buffer.
  1480. ///
  1481. /// @remarks
  1482. /// Not persistent after `bgfx::reset` call.
  1483. ///
  1484. /// @attention C99 equivalent is `bgfx_set_view_frame_buffer`.
  1485. ///
  1486. void setViewFrameBuffer(uint8_t _id, FrameBufferHandle _handle);
  1487. /// Set view view and projection matrices, all draw primitives in this
  1488. /// view will use these matrices.
  1489. ///
  1490. /// @param[in] _id View id.
  1491. /// @param[in] _view View matrix.
  1492. /// @param[in] _projL Projection matrix. When using stereo rendering this projection matrix
  1493. /// represent projection matrix for left eye.
  1494. /// @param[in] _flags View flags. Use
  1495. /// - `BGFX_VIEW_NONE` - View will be rendered only once if stereo mode is enabled.
  1496. /// - `BGFX_VIEW_STEREO` - View will be rendered for both eyes if stereo mode is enabled. When
  1497. /// stereo mode is disabled this flag doesn't have effect.
  1498. /// @param[in] _projR Projection matrix for right eye in stereo mode.
  1499. ///
  1500. /// @attention C99 equivalent are `bgfx_set_view_transform`, `bgfx_set_view_transform_stereo`.
  1501. ///
  1502. void setViewTransform(uint8_t _id, const void* _view, const void* _projL, uint8_t _flags = BGFX_VIEW_STEREO, const void* _projR = NULL);
  1503. /// Post submit view reordering.
  1504. ///
  1505. /// @param[in] _id First view id.
  1506. /// @param[in] _num Number of views to remap.
  1507. /// @param[in] _remap View remap id table. Passing `NULL` will reset view ids
  1508. /// to default state.
  1509. ///
  1510. /// @attention C99 equivalent is `bgfx_set_view_remap`.
  1511. ///
  1512. void setViewRemap(uint8_t _id = 0, uint8_t _num = UINT8_MAX, const void* _remap = NULL);
  1513. /// Sets debug marker.
  1514. ///
  1515. /// @attention C99 equivalent is `bgfx_set_marker`.
  1516. ///
  1517. void setMarker(const char* _marker);
  1518. /// Set render states for draw primitive.
  1519. ///
  1520. /// @param[in] _state State flags. Default state for primitive type is
  1521. /// triangles. See: `BGFX_STATE_DEFAULT`.
  1522. /// - `BGFX_STATE_ALPHA_WRITE` - Enable alpha write.
  1523. /// - `BGFX_STATE_DEPTH_WRITE` - Enable depth write.
  1524. /// - `BGFX_STATE_DEPTH_TEST_*` - Depth test function.
  1525. /// - `BGFX_STATE_BLEND_*` - See remark 1 about BGFX_STATE_BLEND_FUNC.
  1526. /// - `BGFX_STATE_BLEND_EQUATION_*` - See remark 2.
  1527. /// - `BGFX_STATE_CULL_*` - Backface culling mode.
  1528. /// - `BGFX_STATE_RGB_WRITE` - Enable RGB write.
  1529. /// - `BGFX_STATE_MSAA` - Enable MSAA.
  1530. /// - `BGFX_STATE_PT_[TRISTRIP/LINES/POINTS]` - Primitive type.
  1531. ///
  1532. /// @param[in] _rgba Sets blend factor used by `BGFX_STATE_BLEND_FACTOR` and
  1533. /// `BGFX_STATE_BLEND_INV_FACTOR` blend modes.
  1534. ///
  1535. /// @remarks
  1536. /// 1. Use `BGFX_STATE_ALPHA_REF`, `BGFX_STATE_POINT_SIZE` and
  1537. /// `BGFX_STATE_BLEND_FUNC` macros to setup more complex states.
  1538. /// 2. `BGFX_STATE_BLEND_EQUATION_ADD` is set when no other blend
  1539. /// equation is specified.
  1540. ///
  1541. /// @attention C99 equivalent is `bgfx_set_state`.
  1542. ///
  1543. void setState(uint64_t _state, uint32_t _rgba = 0);
  1544. /// Set stencil test state.
  1545. ///
  1546. /// @param[in] _fstencil Front stencil state.
  1547. /// @param[in] _bstencil Back stencil state. If back is set to `BGFX_STENCIL_NONE`
  1548. /// _fstencil is applied to both front and back facing primitives.
  1549. ///
  1550. /// @attention C99 equivalent is `bgfx_set_stencil`.
  1551. ///
  1552. void setStencil(uint32_t _fstencil, uint32_t _bstencil = BGFX_STENCIL_NONE);
  1553. /// Set scissor for draw primitive. For scissor for all primitives in
  1554. /// view see `bgfx::setViewScissor`.
  1555. ///
  1556. /// @param[in] _x Position x from the left corner of the window.
  1557. /// @param[in] _y Position y from the top corner of the window.
  1558. /// @param[in] _width Width of scissor region.
  1559. /// @param[in] _height Height of scissor region.
  1560. /// @returns Scissor cache index.
  1561. ///
  1562. /// @attention C99 equivalent is `bgfx_set_scissor`.
  1563. ///
  1564. uint16_t setScissor(uint16_t _x, uint16_t _y, uint16_t _width, uint16_t _height);
  1565. /// Set scissor from cache for draw primitive.
  1566. ///
  1567. /// @param[in] _cache Index in scissor cache. Passing UINT16_MAX unset primitive
  1568. /// scissor and primitive will use view scissor instead.
  1569. ///
  1570. /// @attention C99 equivalent is `bgfx_set_scissor_cached`.
  1571. ///
  1572. void setScissor(uint16_t _cache = UINT16_MAX);
  1573. /// Set model matrix for draw primitive. If it is not called model will
  1574. /// be rendered with identity model matrix.
  1575. ///
  1576. /// @param[in] _mtx Pointer to first matrix in array.
  1577. /// @param[in] _num Number of matrices in array.
  1578. /// @returns index into matrix cache in case the same model matrix has
  1579. /// to be used for other draw primitive call.
  1580. ///
  1581. /// @attention C99 equivalent is `bgfx_set_transform`.
  1582. ///
  1583. uint32_t setTransform(const void* _mtx, uint16_t _num = 1);
  1584. /// Reserve `_num` matrices in internal matrix cache. Pointer returned
  1585. /// can be modifed until `bgfx::frame` is called.
  1586. ///
  1587. /// @param[in] _transform Pointer to `Transform` structure.
  1588. /// @param[in] _num Number of matrices.
  1589. /// @returns index into matrix cache.
  1590. ///
  1591. /// @attention C99 equivalent is `bgfx_alloc_transform`.
  1592. ///
  1593. uint32_t allocTransform(Transform* _transform, uint16_t _num);
  1594. /// Set model matrix from matrix cache for draw primitive.
  1595. ///
  1596. /// @param[in] _cache Index in matrix cache.
  1597. /// @param[in] _num Number of matrices from cache.
  1598. ///
  1599. /// @attention C99 equivalent is `bgfx_set_transform_cached`.
  1600. ///
  1601. void setTransform(uint32_t _cache, uint16_t _num = 1);
  1602. /// Set shader uniform parameter for draw primitive.
  1603. ///
  1604. /// @param[in] _handle Uniform.
  1605. /// @param[in] _value Pointer to uniform data.
  1606. /// @param[in] _num Number of elements.
  1607. ///
  1608. /// @attention C99 equivalent is `bgfx_set_uniform`.
  1609. ///
  1610. void setUniform(UniformHandle _handle, const void* _value, uint16_t _num = 1);
  1611. /// Set index buffer for draw primitive.
  1612. ///
  1613. /// @param[in] _handle Index buffer.
  1614. /// @param[in] _firstIndex First index to render.
  1615. /// @param[in] _numIndices Number of indices to render.
  1616. ///
  1617. /// @attention C99 equivalent is `bgfx_set_index_buffer`.
  1618. ///
  1619. void setIndexBuffer(IndexBufferHandle _handle, uint32_t _firstIndex = 0, uint32_t _numIndices = UINT32_MAX);
  1620. /// Set index buffer for draw primitive.
  1621. ///
  1622. /// @param[in] _handle Dynamic index buffer.
  1623. /// @param[in] _firstIndex First index to render.
  1624. /// @param[in] _numIndices Number of indices to render.
  1625. ///
  1626. /// @attention C99 equivalent is `bgfx_set_dynamic_index_buffer`.
  1627. ///
  1628. void setIndexBuffer(DynamicIndexBufferHandle _handle, uint32_t _firstIndex = 0, uint32_t _numIndices = UINT32_MAX);
  1629. /// Set index buffer for draw primitive.
  1630. ///
  1631. /// @param[in] _tib Transient index buffer.
  1632. ///
  1633. /// @attention C99 equivalent is `bgfx_set_transient_index_buffer`.
  1634. ///
  1635. void setIndexBuffer(const TransientIndexBuffer* _tib);
  1636. /// Set index buffer for draw primitive.
  1637. ///
  1638. /// @param[in] _tib Transient index buffer.
  1639. /// @param[in] _firstIndex First index to render.
  1640. /// @param[in] _numIndices Number of indices to render.
  1641. ///
  1642. /// @attention C99 equivalent is `bgfx_set_transient_index_buffer`.
  1643. ///
  1644. void setIndexBuffer(const TransientIndexBuffer* _tib, uint32_t _firstIndex, uint32_t _numIndices);
  1645. /// Set vertex buffer for draw primitive.
  1646. ///
  1647. /// @param[in] _handle Vertex buffer.
  1648. ///
  1649. /// @attention C99 equivalent is `bgfx_set_vertex_buffer`.
  1650. ///
  1651. void setVertexBuffer(VertexBufferHandle _handle);
  1652. /// Set vertex buffer for draw primitive.
  1653. ///
  1654. /// @param[in] _handle Vertex buffer.
  1655. /// @param[in] _startVertex First vertex to render.
  1656. /// @param[in] _numVertices Number of vertices to render.
  1657. ///
  1658. /// @attention C99 equivalent is `bgfx_set_vertex_buffer`.
  1659. ///
  1660. void setVertexBuffer(VertexBufferHandle _handle, uint32_t _startVertex, uint32_t _numVertices);
  1661. /// Set vertex buffer for draw primitive.
  1662. ///
  1663. /// @param[in] _handle Dynamic vertex buffer.
  1664. /// @param[in] _numVertices Number of vertices to render.
  1665. ///
  1666. /// @attention C99 equivalent is `bgfx_set_dynamic_vertex_buffer`.
  1667. ///
  1668. void setVertexBuffer(DynamicVertexBufferHandle _handle, uint32_t _numVertices = UINT32_MAX);
  1669. /// Set vertex buffer for draw primitive.
  1670. ///
  1671. /// @param[in] _tvb Transient vertex buffer.
  1672. ///
  1673. /// @attention C99 equivalent is `bgfx_set_transient_vertex_buffer`.
  1674. ///
  1675. void setVertexBuffer(const TransientVertexBuffer* _tvb);
  1676. /// Set vertex buffer for draw primitive.
  1677. ///
  1678. /// @param[in] _tvb Transient vertex buffer.
  1679. /// @param[in] _startVertex First vertex to render.
  1680. /// @param[in] _numVertices Number of vertices to render.
  1681. ///
  1682. /// @attention C99 equivalent is `bgfx_set_transient_vertex_buffer`.
  1683. ///
  1684. void setVertexBuffer(const TransientVertexBuffer* _tvb, uint32_t _startVertex, uint32_t _numVertices);
  1685. /// Set instance data buffer for draw primitive.
  1686. ///
  1687. /// @attention C99 equivalent is `bgfx_set_instance_data_buffer`.
  1688. ///
  1689. void setInstanceDataBuffer(const InstanceDataBuffer* _idb, uint32_t _num = UINT32_MAX);
  1690. /// Set instance data buffer for draw primitive.
  1691. ///
  1692. /// @attention C99 equivalent is `bgfx_set_instance_data_from_vertex_buffer`.
  1693. ///
  1694. void setInstanceDataBuffer(VertexBufferHandle _handle, uint32_t _startVertex, uint32_t _num);
  1695. /// Set instance data buffer for draw primitive.
  1696. ///
  1697. /// @attention C99 equivalent is `bgfx_set_instance_data_from_dynamic_vertex_buffer`.
  1698. ///
  1699. void setInstanceDataBuffer(DynamicVertexBufferHandle _handle, uint32_t _startVertex, uint32_t _num);
  1700. /// Set texture stage for draw primitive.
  1701. ///
  1702. /// @param[in] _stage Texture unit.
  1703. /// @param[in] _sampler Program sampler.
  1704. /// @param[in] _handle Texture handle.
  1705. /// @param[in] _flags Texture sampling mode. Default value UINT32_MAX uses
  1706. /// texture sampling settings from the texture.
  1707. /// - `BGFX_TEXTURE_[U/V/W]_[MIRROR/CLAMP]` - Mirror or clamp to edge wrap
  1708. /// mode.
  1709. /// - `BGFX_TEXTURE_[MIN/MAG/MIP]_[POINT/ANISOTROPIC]` - Point or anisotropic
  1710. /// sampling.
  1711. ///
  1712. /// @param[in] _flags Texture sampler filtering flags. UINT32_MAX use the
  1713. /// sampler filtering mode set by texture.
  1714. ///
  1715. /// @attention C99 equivalent is `bgfx_set_texture`.
  1716. ///
  1717. void setTexture(uint8_t _stage, UniformHandle _sampler, TextureHandle _handle, uint32_t _flags = UINT32_MAX);
  1718. /// Set texture stage for draw primitive.
  1719. ///
  1720. /// @param[in] _stage Texture unit.
  1721. /// @param[in] _sampler Program sampler.
  1722. /// @param[in] _handle Frame buffer handle.
  1723. /// @param[in] _attachment Attachment index.
  1724. /// @param[in] _flags Texture sampling mode. Default value UINT32_MAX uses
  1725. /// texture sampling settings from the texture.
  1726. /// - `BGFX_TEXTURE_[U/V/W]_[MIRROR/CLAMP]` - Mirror or clamp to edge wrap
  1727. /// mode.
  1728. /// - `BGFX_TEXTURE_[MIN/MAG/MIP]_[POINT/ANISOTROPIC]` - Point or anisotropic
  1729. /// sampling.
  1730. ///
  1731. /// @attention C99 equivalent is `bgfx_set_texture_from_frame_buffer`.
  1732. ///
  1733. void setTexture(uint8_t _stage, UniformHandle _sampler, FrameBufferHandle _handle, uint8_t _attachment = 0, uint32_t _flags = UINT32_MAX);
  1734. /// Touch view.
  1735. uint32_t touch(uint8_t _id);
  1736. /// Submit primitive for rendering.
  1737. ///
  1738. /// @param[in] _id View id.
  1739. /// @param[in] _handle Program.
  1740. /// @param[in] _depth Depth for sorting.
  1741. /// @returns Number of draw calls.
  1742. ///
  1743. /// @attention C99 equivalent is `bgfx_submit`.
  1744. ///
  1745. uint32_t submit(uint8_t _id, ProgramHandle _handle, int32_t _depth = 0);
  1746. /// Submit primitive for rendering with index and instance data info from
  1747. /// indirect buffer.
  1748. ///
  1749. /// @param[in] _id View id.
  1750. /// @param[in] _handle Program.
  1751. /// @param[in] _indirectHandle Indirect buffer.
  1752. /// @param[in] _start First element in indirect buffer.
  1753. /// @param[in] _num Number of dispatches.
  1754. /// @param[in] _depth Depth for sorting.
  1755. ///
  1756. /// @attention C99 equivalent is `bgfx_submit_indirect`.
  1757. ///
  1758. uint32_t submit(uint8_t _id, ProgramHandle _handle, IndirectBufferHandle _indirectHandle, uint16_t _start = 0, uint16_t _num = 1, int32_t _depth = 0);
  1759. /// Set compute index buffer.
  1760. ///
  1761. /// @param[in] _stage Compute stage.
  1762. /// @param[in] _handle Index buffer handle.
  1763. /// @param[in] _access Buffer access. See `Access::Enum`.
  1764. ///
  1765. /// @attention C99 equivalent is `bgfx_set_compute_index_buffer`.
  1766. ///
  1767. void setBuffer(uint8_t _stage, IndexBufferHandle _handle, Access::Enum _access);
  1768. /// Set compute vertex buffer.
  1769. ///
  1770. /// @param[in] _stage Compute stage.
  1771. /// @param[in] _handle Vertex buffer handle.
  1772. /// @param[in] _access Buffer access. See `Access::Enum`.
  1773. ///
  1774. /// @attention C99 equivalent is `bgfx_set_compute_vertex_buffer`.
  1775. ///
  1776. void setBuffer(uint8_t _stage, VertexBufferHandle _handle, Access::Enum _access);
  1777. /// Set compute dynamic index buffer.
  1778. ///
  1779. /// @param[in] _stage Compute stage.
  1780. /// @param[in] _handle Dynamic index buffer handle.
  1781. /// @param[in] _access Buffer access. See `Access::Enum`.
  1782. ///
  1783. /// @attention C99 equivalent is `bgfx_set_compute_dynamic_index_buffer`.
  1784. ///
  1785. void setBuffer(uint8_t _stage, DynamicIndexBufferHandle _handle, Access::Enum _access);
  1786. /// Set compute dynamic vertex buffer.
  1787. ///
  1788. /// @param[in] _stage Compute stage.
  1789. /// @param[in] _handle Dynamic vertex buffer handle.
  1790. /// @param[in] _access Buffer access. See `Access::Enum`.
  1791. ///
  1792. /// @attention C99 equivalent is `bgfx_set_compute_dynamic_vertex_buffer`.
  1793. ///
  1794. void setBuffer(uint8_t _stage, DynamicVertexBufferHandle _handle, Access::Enum _access);
  1795. /// Set compute indirect buffer.
  1796. ///
  1797. /// @param[in] _stage Compute stage.
  1798. /// @param[in] _handle Indirect buffer handle.
  1799. /// @param[in] _access Buffer access. See `Access::Enum`.
  1800. ///
  1801. /// @attention C99 equivalent is `bgfx_set_compute_indirect_buffer`.
  1802. ///
  1803. void setBuffer(uint8_t _stage, IndirectBufferHandle _handle, Access::Enum _access);
  1804. /// Set compute image from texture.
  1805. ///
  1806. /// @param[in] _stage Texture unit.
  1807. /// @param[in] _sampler Program sampler.
  1808. /// @param[in] _handle Texture handle.
  1809. /// @param[in] _mip Mip level.
  1810. /// @param[in] _access Texture access. See `Access::Enum`.
  1811. /// @param[in] _format Texture format. See: `TextureFormat::Enum`.
  1812. ///
  1813. /// @attention C99 equivalent is `bgfx_set_image`.
  1814. ///
  1815. void setImage(uint8_t _stage, UniformHandle _sampler, TextureHandle _handle, uint8_t _mip, Access::Enum _access, TextureFormat::Enum _format = TextureFormat::Count);
  1816. /// Set compute image from frame buffer texture.
  1817. ///
  1818. /// @param[in] _stage Texture unit.
  1819. /// @param[in] _sampler Program sampler.
  1820. /// @param[in] _handle Frame buffer handle.
  1821. /// @param[in] _attachment Attachment index.
  1822. /// @param[in] _access Texture access. See `Access::Enum`.
  1823. /// @param[in] _format Texture format. See: `TextureFormat::Enum`.
  1824. ///
  1825. /// @attention C99 equivalent is `bgfx_set_image_from_frame_buffer`.
  1826. ///
  1827. void setImage(uint8_t _stage, UniformHandle _sampler, FrameBufferHandle _handle, uint8_t _attachment, Access::Enum _access, TextureFormat::Enum _format = TextureFormat::Count);
  1828. /// Dispatch compute.
  1829. ///
  1830. /// @param[in] _id View id.
  1831. /// @param[in] _handle Compute program.
  1832. /// @param[in] _numX Number of groups X.
  1833. /// @param[in] _numY Number of groups Y.
  1834. /// @param[in] _numZ Number of groups Z.
  1835. /// @param[in] _flags View flags. Use
  1836. /// - `BGFX_VIEW_NONE` - View will be rendered only once if stereo mode is enabled.
  1837. /// - `BGFX_VIEW_STEREO` - View will be rendered for both eyes if stereo mode is enabled. When
  1838. /// stereo mode is disabled this flag doesn't have effect.
  1839. ///
  1840. /// @attention C99 equivalent is `bgfx_dispatch`.
  1841. ///
  1842. uint32_t dispatch(uint8_t _id, ProgramHandle _handle, uint16_t _numX = 1, uint16_t _numY = 1, uint16_t _numZ = 1, uint8_t _flags = BGFX_SUBMIT_EYE_FIRST);
  1843. /// Dispatch compute indirect.
  1844. ///
  1845. /// @param[in] _id View id.
  1846. /// @param[in] _handle Compute program.
  1847. /// @param[in] _indirectHandle Indirect buffer.
  1848. /// @param[in] _start First element in indirect buffer.
  1849. /// @param[in] _num Number of dispatches.
  1850. /// @param[in] _flags View flags. Use
  1851. /// - `BGFX_VIEW_NONE` - View will be rendered only once if stereo mode is enabled.
  1852. /// - `BGFX_VIEW_STEREO` - View will be rendered for both eyes if stereo mode is enabled. When
  1853. /// stereo mode is disabled this flag doesn't have effect.
  1854. ///
  1855. /// @attention C99 equivalent is `bgfx_dispatch_indirect`.
  1856. ///
  1857. uint32_t dispatch(uint8_t _id, ProgramHandle _handle, IndirectBufferHandle _indirectHandle, uint16_t _start = 0, uint16_t _num = 1, uint8_t _flags = BGFX_SUBMIT_EYE_FIRST);
  1858. /// Discard all previously set state for draw or compute call.
  1859. ///
  1860. /// @attention C99 equivalent is `bgfx_discard`.
  1861. ///
  1862. void discard();
  1863. /// Request screen shot.
  1864. ///
  1865. /// @param[in] _filePath Will be passed to `bgfx::CallbackI::screenShot` callback.
  1866. ///
  1867. /// @remarks
  1868. /// `bgfx::CallbackI::screenShot` must be implemented.
  1869. ///
  1870. /// @attention C99 equivalent is `bgfx_save_screen_shot`.
  1871. ///
  1872. void saveScreenShot(const char* _filePath);
  1873. } // namespace bgfx
  1874. #endif // BGFX_H_HEADER_GUARD