bgfx.c99.h 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753
  1. /*
  2. * Copyright 2011-2015 Branimir Karadzic. All rights reserved.
  3. * License: https://github.com/bkaradzic/bgfx/blob/master/LICENSE
  4. *
  5. * vim: set tabstop=4 expandtab:
  6. */
  7. #ifndef BGFX_C99_H_HEADER_GUARD
  8. #define BGFX_C99_H_HEADER_GUARD
  9. #include <stdarg.h> // va_list
  10. #include <stdbool.h> // bool
  11. #include <stdint.h> // uint32_t
  12. #include <stdlib.h> // size_t
  13. #include "bgfxdefines.h"
  14. typedef enum bgfx_renderer_type
  15. {
  16. BGFX_RENDERER_TYPE_NULL,
  17. BGFX_RENDERER_TYPE_DIRECT3D9,
  18. BGFX_RENDERER_TYPE_DIRECT3D11,
  19. BGFX_RENDERER_TYPE_DIRECT3D12,
  20. BGFX_RENDERER_TYPE_METAL,
  21. BGFX_RENDERER_TYPE_OPENGLES,
  22. BGFX_RENDERER_TYPE_OPENGL,
  23. BGFX_RENDERER_TYPE_VULKAN,
  24. BGFX_RENDERER_TYPE_COUNT
  25. } bgfx_renderer_type_t;
  26. typedef enum bgfx_access
  27. {
  28. BGFX_ACCESS_READ,
  29. BGFX_ACCESS_WRITE,
  30. BGFX_ACCESS_READWRITE,
  31. BGFX_ACCESS_COUNT
  32. } bgfx_access_t;
  33. typedef enum bgfx_attrib
  34. {
  35. BGFX_ATTRIB_POSITION,
  36. BGFX_ATTRIB_NORMAL,
  37. BGFX_ATTRIB_TANGENT,
  38. BGFX_ATTRIB_BITANGENT,
  39. BGFX_ATTRIB_COLOR0,
  40. BGFX_ATTRIB_COLOR1,
  41. BGFX_ATTRIB_INDICES,
  42. BGFX_ATTRIB_WEIGHT,
  43. BGFX_ATTRIB_TEXCOORD0,
  44. BGFX_ATTRIB_TEXCOORD1,
  45. BGFX_ATTRIB_TEXCOORD2,
  46. BGFX_ATTRIB_TEXCOORD3,
  47. BGFX_ATTRIB_TEXCOORD4,
  48. BGFX_ATTRIB_TEXCOORD5,
  49. BGFX_ATTRIB_TEXCOORD6,
  50. BGFX_ATTRIB_TEXCOORD7,
  51. BGFX_ATTRIB_COUNT
  52. } bgfx_attrib_t;
  53. typedef enum bgfx_attrib_type
  54. {
  55. BGFX_ATTRIB_TYPE_UINT8,
  56. BGFX_ATTRIB_TYPE_UINT10,
  57. BGFX_ATTRIB_TYPE_INT16,
  58. BGFX_ATTRIB_TYPE_HALF,
  59. BGFX_ATTRIB_TYPE_FLOAT,
  60. BGFX_ATTRIB_TYPE_COUNT
  61. } bgfx_attrib_type_t;
  62. typedef enum bgfx_texture_format
  63. {
  64. BGFX_TEXTURE_FORMAT_BC1,
  65. BGFX_TEXTURE_FORMAT_BC2,
  66. BGFX_TEXTURE_FORMAT_BC3,
  67. BGFX_TEXTURE_FORMAT_BC4,
  68. BGFX_TEXTURE_FORMAT_BC5,
  69. BGFX_TEXTURE_FORMAT_BC6H,
  70. BGFX_TEXTURE_FORMAT_BC7,
  71. BGFX_TEXTURE_FORMAT_ETC1,
  72. BGFX_TEXTURE_FORMAT_ETC2,
  73. BGFX_TEXTURE_FORMAT_ETC2A,
  74. BGFX_TEXTURE_FORMAT_ETC2A1,
  75. BGFX_TEXTURE_FORMAT_PTC12,
  76. BGFX_TEXTURE_FORMAT_PTC14,
  77. BGFX_TEXTURE_FORMAT_PTC12A,
  78. BGFX_TEXTURE_FORMAT_PTC14A,
  79. BGFX_TEXTURE_FORMAT_PTC22,
  80. BGFX_TEXTURE_FORMAT_PTC24,
  81. BGFX_TEXTURE_FORMAT_UNKNOWN,
  82. BGFX_TEXTURE_FORMAT_R1,
  83. BGFX_TEXTURE_FORMAT_R8,
  84. BGFX_TEXTURE_FORMAT_R16,
  85. BGFX_TEXTURE_FORMAT_R16F,
  86. BGFX_TEXTURE_FORMAT_R32,
  87. BGFX_TEXTURE_FORMAT_R32F,
  88. BGFX_TEXTURE_FORMAT_RG8,
  89. BGFX_TEXTURE_FORMAT_RG16,
  90. BGFX_TEXTURE_FORMAT_RG16F,
  91. BGFX_TEXTURE_FORMAT_RG32,
  92. BGFX_TEXTURE_FORMAT_RG32F,
  93. BGFX_TEXTURE_FORMAT_BGRA8,
  94. BGFX_TEXTURE_FORMAT_RGBA8,
  95. BGFX_TEXTURE_FORMAT_RGBA16,
  96. BGFX_TEXTURE_FORMAT_RGBA16F,
  97. BGFX_TEXTURE_FORMAT_RGBA32,
  98. BGFX_TEXTURE_FORMAT_RGBA32F,
  99. BGFX_TEXTURE_FORMAT_R5G6B5,
  100. BGFX_TEXTURE_FORMAT_RGBA4,
  101. BGFX_TEXTURE_FORMAT_RGB5A1,
  102. BGFX_TEXTURE_FORMAT_RGB10A2,
  103. BGFX_TEXTURE_FORMAT_R11G11B10F,
  104. BGFX_TEXTURE_FORMAT_UNKNOWN_DEPTH,
  105. BGFX_TEXTURE_FORMAT_D16,
  106. BGFX_TEXTURE_FORMAT_D24,
  107. BGFX_TEXTURE_FORMAT_D24S8,
  108. BGFX_TEXTURE_FORMAT_D32,
  109. BGFX_TEXTURE_FORMAT_D16F,
  110. BGFX_TEXTURE_FORMAT_D24F,
  111. BGFX_TEXTURE_FORMAT_D32F,
  112. BGFX_TEXTURE_FORMAT_D0S8,
  113. BGFX_TEXTURE_FORMAT_COUNT
  114. } bgfx_texture_format_t;
  115. typedef enum bgfx_uniform_type
  116. {
  117. BGFX_UNIFORM_TYPE_INT1,
  118. BGFX_UNIFORM_TYPE_END,
  119. BGFX_UNIFORM_TYPE_VEC4,
  120. BGFX_UNIFORM_TYPE_MAT3,
  121. BGFX_UNIFORM_TYPE_MAT4,
  122. BGFX_UNIFORM_TYPE_COUNT
  123. } bgfx_uniform_type_t;
  124. typedef enum bgfx_backbuffer_ratio
  125. {
  126. BGFX_BACKBUFFER_RATIO_EQUAL,
  127. BGFX_BACKBUFFER_RATIO_HALF,
  128. BGFX_BACKBUFFER_RATIO_QUARTER,
  129. BGFX_BACKBUFFER_RATIO_EIGHTH,
  130. BGFX_BACKBUFFER_RATIO_SIXTEENTH,
  131. BGFX_BACKBUFFER_RATIO_DOUBLE,
  132. BGFX_BACKBUFFER_RATIO_COUNT
  133. } bgfx_backbuffer_ratio_t;
  134. #define BGFX_HANDLE_T(_name) \
  135. typedef struct _name { uint16_t idx; } _name##_t;
  136. BGFX_HANDLE_T(bgfx_indirect_buffer_handle);
  137. BGFX_HANDLE_T(bgfx_dynamic_index_buffer_handle);
  138. BGFX_HANDLE_T(bgfx_dynamic_vertex_buffer_handle);
  139. BGFX_HANDLE_T(bgfx_frame_buffer_handle);
  140. BGFX_HANDLE_T(bgfx_index_buffer_handle);
  141. BGFX_HANDLE_T(bgfx_program_handle);
  142. BGFX_HANDLE_T(bgfx_shader_handle);
  143. BGFX_HANDLE_T(bgfx_texture_handle);
  144. BGFX_HANDLE_T(bgfx_uniform_handle);
  145. BGFX_HANDLE_T(bgfx_vertex_buffer_handle);
  146. BGFX_HANDLE_T(bgfx_vertex_decl_handle);
  147. #undef BGFX_HANDLE_T
  148. /**/
  149. typedef void (*bgfx_release_fn_t)(void* _ptr, void* _userData);
  150. /**/
  151. typedef struct bgfx_memory
  152. {
  153. uint8_t* data;
  154. uint32_t size;
  155. } bgfx_memory_t;
  156. /**/
  157. typedef struct bgfx_transform
  158. {
  159. float* data;
  160. uint16_t num;
  161. } bgfx_transform_t;
  162. /**/
  163. typedef struct bgfx_hmd_eye
  164. {
  165. float rotation[4];
  166. float translation[3];
  167. float fov[4];
  168. float adjust[3];
  169. float pixelsPerTanAngle[2];
  170. } bgfx_hmd_eye_t;
  171. /**/
  172. typedef struct bgfx_hmd
  173. {
  174. bgfx_hmd_eye_t eye[2];
  175. uint16_t width;
  176. uint16_t height;
  177. uint32_t deviceWidth;
  178. uint32_t deviceHeight;
  179. uint8_t flags;
  180. } bgfx_hmd_t;
  181. /**/
  182. typedef struct bgfx_stats
  183. {
  184. uint64_t cpuTime;
  185. uint64_t cpuTimerFreq;
  186. uint64_t gpuTime;
  187. uint64_t gpuTimerFreq;
  188. } bgfx_stats_t;
  189. /**/
  190. typedef struct bgfx_vertex_decl
  191. {
  192. uint32_t hash;
  193. uint16_t stride;
  194. uint16_t offset[BGFX_ATTRIB_COUNT];
  195. uint16_t attributes[BGFX_ATTRIB_COUNT];
  196. } bgfx_vertex_decl_t;
  197. /**/
  198. typedef struct bgfx_transient_index_buffer
  199. {
  200. uint8_t* data;
  201. uint32_t size;
  202. bgfx_index_buffer_handle_t handle;
  203. uint32_t startIndex;
  204. } bgfx_transient_index_buffer_t;
  205. /**/
  206. typedef struct bgfx_transient_vertex_buffer
  207. {
  208. uint8_t* data;
  209. uint32_t size;
  210. uint32_t startVertex;
  211. uint16_t stride;
  212. bgfx_vertex_buffer_handle_t handle;
  213. bgfx_vertex_decl_handle_t decl;
  214. } bgfx_transient_vertex_buffer_t;
  215. /**/
  216. typedef struct bgfx_instance_data_buffer
  217. {
  218. uint8_t* data;
  219. uint32_t size;
  220. uint32_t offset;
  221. uint32_t num;
  222. uint16_t stride;
  223. bgfx_vertex_buffer_handle_t handle;
  224. } bgfx_instance_data_buffer_t;
  225. /**/
  226. typedef struct bgfx_texture_info
  227. {
  228. bgfx_texture_format_t format;
  229. uint32_t storageSize;
  230. uint16_t width;
  231. uint16_t height;
  232. uint16_t depth;
  233. uint8_t numMips;
  234. uint8_t bitsPerPixel;
  235. bool cubeMap;
  236. } bgfx_texture_info_t;
  237. /**/
  238. typedef struct bgfx_caps_gpu
  239. {
  240. uint16_t vendorId;
  241. uint16_t deviceId;
  242. } bgfx_caps_gpu_t;
  243. /**/
  244. typedef struct bgfx_caps
  245. {
  246. bgfx_renderer_type_t rendererType;
  247. uint64_t supported;
  248. uint32_t maxDrawCalls;
  249. uint16_t maxTextureSize;
  250. uint16_t maxViews;
  251. uint8_t maxFBAttachments;
  252. uint8_t numGPUs;
  253. uint16_t vendorId;
  254. uint16_t deviceId;
  255. bgfx_caps_gpu_t gpu[4];
  256. uint8_t formats[BGFX_TEXTURE_FORMAT_COUNT];
  257. } bgfx_caps_t;
  258. /**/
  259. typedef enum bgfx_fatal
  260. {
  261. BGFX_FATAL_DEBUG_CHECK,
  262. BGFX_FATAL_MINIMUM_REQUIRED_SPECS,
  263. BGFX_FATAL_INVALID_SHADER,
  264. BGFX_FATAL_UNABLE_TO_INITIALIZE,
  265. BGFX_FATAL_UNABLE_TO_CREATE_TEXTURE,
  266. BGFX_FATAL_DEVICE_LOST,
  267. BGFX_FATAL_COUNT
  268. } bgfx_fatal_t;
  269. #ifndef BGFX_SHARED_LIB_BUILD
  270. # define BGFX_SHARED_LIB_BUILD 0
  271. #endif // BGFX_SHARED_LIB_BUILD
  272. #ifndef BGFX_SHARED_LIB_USE
  273. # define BGFX_SHARED_LIB_USE 0
  274. #endif // BGFX_SHARED_LIB_USE
  275. #if defined(_MSC_VER)
  276. # if BGFX_SHARED_LIB_BUILD
  277. # define BGFX_SHARED_LIB_API __declspec(dllexport)
  278. # elif BGFX_SHARED_LIB_USE
  279. # define BGFX_SHARED_LIB_API __declspec(dllimport)
  280. # else
  281. # define BGFX_SHARED_LIB_API
  282. # endif // BGFX_SHARED_LIB_*
  283. #else
  284. # define BGFX_SHARED_LIB_API
  285. #endif // defined(_MSC_VER)
  286. #if defined(__cplusplus)
  287. # define BGFX_C_API extern "C" BGFX_SHARED_LIB_API
  288. #else
  289. # define BGFX_C_API BGFX_SHARED_LIB_API
  290. #endif // defined(__cplusplus)
  291. /**/
  292. typedef struct bgfx_callback_interface
  293. {
  294. const struct bgfx_callback_vtbl* vtbl;
  295. } bgfx_callback_interface_t;
  296. /**/
  297. typedef struct bgfx_callback_vtbl
  298. {
  299. void (*fatal)(bgfx_callback_interface_t* _this, bgfx_fatal_t _code, const char* _str);
  300. void (*trace_vargs)(bgfx_callback_interface_t* _this, const char* _filePath, uint16_t _line, const char* _format, va_list _argList);
  301. uint32_t (*cache_read_size)(bgfx_callback_interface_t* _this, uint64_t _id);
  302. bool (*cache_read)(bgfx_callback_interface_t* _this, uint64_t _id, void* _data, uint32_t _size);
  303. void (*cache_write)(bgfx_callback_interface_t* _this, uint64_t _id, const void* _data, uint32_t _size);
  304. void (*screen_shot)(bgfx_callback_interface_t* _this, const char* _filePath, uint32_t _width, uint32_t _height, uint32_t _pitch, const void* _data, uint32_t _size, bool _yflip);
  305. void (*capture_begin)(bgfx_callback_interface_t* _this, uint32_t _width, uint32_t _height, uint32_t _pitch, bgfx_texture_format_t _format, bool _yflip);
  306. void (*capture_end)(bgfx_callback_interface_t* _this);
  307. void (*capture_frame)(bgfx_callback_interface_t* _this, const void* _data, uint32_t _size);
  308. } bgfx_callback_vtbl_t;
  309. /**/
  310. typedef struct bgfx_reallocator_interface
  311. {
  312. const struct bgfx_reallocator_vtbl* vtbl;
  313. } bgfx_reallocator_interface_t;
  314. /**/
  315. typedef struct bgfx_reallocator_vtbl
  316. {
  317. void* (*alloc)(bgfx_reallocator_interface_t* _this, size_t _size, size_t _align, const char* _file, uint32_t _line);
  318. void (*free)(bgfx_reallocator_interface_t* _this, void* _ptr, size_t _align, const char* _file, uint32_t _line);
  319. void* (*realloc)(bgfx_reallocator_interface_t* _this, void* _ptr, size_t _size, size_t _align, const char* _file, uint32_t _line);
  320. } bgfx_reallocator_vtbl_t;
  321. /**/
  322. BGFX_C_API void bgfx_vertex_decl_begin(bgfx_vertex_decl_t* _decl, bgfx_renderer_type_t _renderer);
  323. /**/
  324. BGFX_C_API void bgfx_vertex_decl_add(bgfx_vertex_decl_t* _decl, bgfx_attrib_t _attrib, uint8_t _num, bgfx_attrib_type_t _type, bool _normalized, bool _asInt);
  325. /**/
  326. BGFX_C_API void bgfx_vertex_decl_skip(bgfx_vertex_decl_t* _decl, uint8_t _num);
  327. /**/
  328. BGFX_C_API void bgfx_vertex_decl_end(bgfx_vertex_decl_t* _decl);
  329. /**/
  330. BGFX_C_API void bgfx_vertex_pack(const float _input[4], bool _inputNormalized, bgfx_attrib_t _attr, const bgfx_vertex_decl_t* _decl, void* _data, uint32_t _index);
  331. /**/
  332. BGFX_C_API void bgfx_vertex_unpack(float _output[4], bgfx_attrib_t _attr, const bgfx_vertex_decl_t* _decl, const void* _data, uint32_t _index);
  333. /**/
  334. BGFX_C_API void bgfx_vertex_convert(const bgfx_vertex_decl_t* _destDecl, void* _destData, const bgfx_vertex_decl_t* _srcDecl, const void* _srcData, uint32_t _num);
  335. /**/
  336. BGFX_C_API uint16_t bgfx_weld_vertices(uint16_t* _output, const bgfx_vertex_decl_t* _decl, const void* _data, uint16_t _num, float _epsilon);
  337. /**/
  338. BGFX_C_API void bgfx_image_swizzle_bgra8(uint32_t _width, uint32_t _height, uint32_t _pitch, const void* _src, void* _dst);
  339. /**/
  340. BGFX_C_API void bgfx_image_rgba8_downsample_2x2(uint32_t _width, uint32_t _height, uint32_t _pitch, const void* _src, void* _dst);
  341. /**/
  342. BGFX_C_API uint8_t bgfx_get_supported_renderers(bgfx_renderer_type_t _enum[BGFX_RENDERER_TYPE_COUNT]);
  343. /**/
  344. BGFX_C_API const char* bgfx_get_renderer_name(bgfx_renderer_type_t _type);
  345. /**/
  346. BGFX_C_API bool bgfx_init(bgfx_renderer_type_t _type, uint16_t _vendorId, uint16_t _deviceId, bgfx_callback_interface_t* _callback, bgfx_reallocator_interface_t* _allocator);
  347. /**/
  348. BGFX_C_API void bgfx_shutdown();
  349. /**/
  350. BGFX_C_API void bgfx_reset(uint32_t _width, uint32_t _height, uint32_t _flags);
  351. /**/
  352. BGFX_C_API uint32_t bgfx_frame();
  353. /**/
  354. BGFX_C_API bgfx_renderer_type_t bgfx_get_renderer_type();
  355. /**/
  356. BGFX_C_API const bgfx_caps_t* bgfx_get_caps();
  357. /**/
  358. BGFX_C_API const bgfx_hmd_t* bgfx_get_hmd();
  359. /**/
  360. BGFX_C_API const bgfx_stats_t* bgfx_get_stats();
  361. /**/
  362. BGFX_C_API const bgfx_memory_t* bgfx_alloc(uint32_t _size);
  363. /**/
  364. BGFX_C_API const bgfx_memory_t* bgfx_copy(const void* _data, uint32_t _size);
  365. /**/
  366. BGFX_C_API const bgfx_memory_t* bgfx_make_ref(const void* _data, uint32_t _size);
  367. /**/
  368. BGFX_C_API const bgfx_memory_t* bgfx_make_ref_release(const void* _data, uint32_t _size, bgfx_release_fn_t _releaseFn, void* _userData);
  369. /**/
  370. BGFX_C_API void bgfx_set_debug(uint32_t _debug);
  371. /**/
  372. BGFX_C_API void bgfx_dbg_text_clear(uint8_t _attr, bool _small);
  373. /**/
  374. BGFX_C_API void bgfx_dbg_text_printf(uint16_t _x, uint16_t _y, uint8_t _attr, const char* _format, ...);
  375. /**/
  376. BGFX_C_API void bgfx_dbg_text_image(uint16_t _x, uint16_t _y, uint16_t _width, uint16_t _height, const void* _data, uint16_t _pitch);
  377. /**/
  378. BGFX_C_API bgfx_index_buffer_handle_t bgfx_create_index_buffer(const bgfx_memory_t* _mem, uint16_t _flags);
  379. /**/
  380. BGFX_C_API void bgfx_destroy_index_buffer(bgfx_index_buffer_handle_t _handle);
  381. /**/
  382. BGFX_C_API bgfx_vertex_buffer_handle_t bgfx_create_vertex_buffer(const bgfx_memory_t* _mem, const bgfx_vertex_decl_t* _decl, uint16_t _flags);
  383. /**/
  384. BGFX_C_API void bgfx_destroy_vertex_buffer(bgfx_vertex_buffer_handle_t _handle);
  385. /**/
  386. BGFX_C_API bgfx_dynamic_index_buffer_handle_t bgfx_create_dynamic_index_buffer(uint32_t _num, uint16_t _flags);
  387. /**/
  388. BGFX_C_API bgfx_dynamic_index_buffer_handle_t bgfx_create_dynamic_index_buffer_mem(const bgfx_memory_t* _mem, uint16_t _flags);
  389. /**/
  390. BGFX_C_API void bgfx_update_dynamic_index_buffer(bgfx_dynamic_index_buffer_handle_t _handle, uint32_t _startIndex, const bgfx_memory_t* _mem);
  391. /**/
  392. BGFX_C_API void bgfx_destroy_dynamic_index_buffer(bgfx_dynamic_index_buffer_handle_t _handle);
  393. /**/
  394. BGFX_C_API bgfx_dynamic_vertex_buffer_handle_t bgfx_create_dynamic_vertex_buffer(uint32_t _num, const bgfx_vertex_decl_t* _decl, uint16_t _flags);
  395. /**/
  396. BGFX_C_API bgfx_dynamic_vertex_buffer_handle_t bgfx_create_dynamic_vertex_buffer_mem(const bgfx_memory_t* _mem, const bgfx_vertex_decl_t* _decl, uint16_t _flags);
  397. /**/
  398. BGFX_C_API void bgfx_update_dynamic_vertex_buffer(bgfx_dynamic_vertex_buffer_handle_t _handle, uint32_t _startVertex, const bgfx_memory_t* _mem);
  399. /**/
  400. BGFX_C_API void bgfx_destroy_dynamic_vertex_buffer(bgfx_dynamic_vertex_buffer_handle_t _handle);
  401. /**/
  402. BGFX_C_API bool bgfx_check_avail_transient_index_buffer(uint32_t _num);
  403. /**/
  404. BGFX_C_API bool bgfx_check_avail_transient_vertex_buffer(uint32_t _num, const bgfx_vertex_decl_t* _decl);
  405. /**/
  406. BGFX_C_API bool bgfx_check_avail_instance_data_buffer(uint32_t _num, uint16_t _stride);
  407. /**/
  408. BGFX_C_API bool bgfx_check_avail_transient_buffers(uint32_t _numVertices, const bgfx_vertex_decl_t* _decl, uint32_t _numIndices);
  409. /**/
  410. BGFX_C_API void bgfx_alloc_transient_index_buffer(bgfx_transient_index_buffer_t* _tib, uint32_t _num);
  411. /**/
  412. BGFX_C_API void bgfx_alloc_transient_vertex_buffer(bgfx_transient_vertex_buffer_t* _tvb, uint32_t _num, const bgfx_vertex_decl_t* _decl);
  413. /**/
  414. BGFX_C_API bool bgfx_alloc_transient_buffers(bgfx_transient_vertex_buffer_t* _tvb, const bgfx_vertex_decl_t* _decl, uint32_t _numVertices, bgfx_transient_index_buffer_t* _tib, uint32_t _numIndices);
  415. /**/
  416. BGFX_C_API const bgfx_instance_data_buffer_t* bgfx_alloc_instance_data_buffer(uint32_t _num, uint16_t _stride);
  417. /**/
  418. BGFX_C_API bgfx_indirect_buffer_handle_t bgfx_create_indirect_buffer(uint32_t _num);
  419. /**/
  420. BGFX_C_API void bgfx_destroy_indirect_buffer(bgfx_indirect_buffer_handle_t _handle);
  421. /**/
  422. BGFX_C_API bgfx_shader_handle_t bgfx_create_shader(const bgfx_memory_t* _mem);
  423. /**/
  424. BGFX_C_API uint16_t bgfx_get_shader_uniforms(bgfx_shader_handle_t _handle, bgfx_uniform_handle_t* _uniforms, uint16_t _max);
  425. /**/
  426. BGFX_C_API void bgfx_destroy_shader(bgfx_shader_handle_t _handle);
  427. /**/
  428. BGFX_C_API bgfx_program_handle_t bgfx_create_program(bgfx_shader_handle_t _vsh, bgfx_shader_handle_t _fsh, bool _destroyShaders);
  429. /**/
  430. BGFX_C_API bgfx_program_handle_t bgfx_create_compute_program(bgfx_shader_handle_t _csh, bool _destroyShaders);
  431. /**/
  432. BGFX_C_API void bgfx_destroy_program(bgfx_program_handle_t _handle);
  433. /**/
  434. BGFX_C_API void bgfx_calc_texture_size(bgfx_texture_info_t* _info, uint16_t _width, uint16_t _height, uint16_t _depth, bool _cubeMap, uint8_t _numMips, bgfx_texture_format_t _format);
  435. /**/
  436. BGFX_C_API bgfx_texture_handle_t bgfx_create_texture(const bgfx_memory_t* _mem, uint32_t _flags, uint8_t _skip, bgfx_texture_info_t* _info);
  437. /**/
  438. BGFX_C_API bgfx_texture_handle_t bgfx_create_texture_2d(uint16_t _width, uint16_t _height, uint8_t _numMips, bgfx_texture_format_t _format, uint32_t _flags, const bgfx_memory_t* _mem);
  439. /**/
  440. BGFX_C_API bgfx_texture_handle_t bgfx_create_texture_2d_scaled(bgfx_backbuffer_ratio_t _ratio, uint8_t _numMips, bgfx_texture_format_t _format, uint32_t _flags);
  441. /**/
  442. BGFX_C_API bgfx_texture_handle_t bgfx_create_texture_3d(uint16_t _width, uint16_t _height, uint16_t _depth, uint8_t _numMips, bgfx_texture_format_t _format, uint32_t _flags, const bgfx_memory_t* _mem);
  443. /**/
  444. BGFX_C_API bgfx_texture_handle_t bgfx_create_texture_cube(uint16_t _size, uint8_t _numMips, bgfx_texture_format_t _format, uint32_t _flags, const bgfx_memory_t* _mem);
  445. /**/
  446. BGFX_C_API void bgfx_update_texture_2d(bgfx_texture_handle_t _handle, uint8_t _mip, uint16_t _x, uint16_t _y, uint16_t _width, uint16_t _height, const bgfx_memory_t* _mem, uint16_t _pitch);
  447. /**/
  448. BGFX_C_API void bgfx_update_texture_3d(bgfx_texture_handle_t _handle, uint8_t _mip, uint16_t _x, uint16_t _y, uint16_t _z, uint16_t _width, uint16_t _height, uint16_t _depth, const bgfx_memory_t* _mem);
  449. /**/
  450. BGFX_C_API void bgfx_update_texture_cube(bgfx_texture_handle_t _handle, uint8_t _side, uint8_t _mip, uint16_t _x, uint16_t _y, uint16_t _width, uint16_t _height, const bgfx_memory_t* _mem, uint16_t _pitch);
  451. /**/
  452. BGFX_C_API void bgfx_destroy_texture(bgfx_texture_handle_t _handle);
  453. /**/
  454. BGFX_C_API bgfx_frame_buffer_handle_t bgfx_create_frame_buffer(uint16_t _width, uint16_t _height, bgfx_texture_format_t _format, uint32_t _textureFlags);
  455. /**/
  456. BGFX_C_API bgfx_frame_buffer_handle_t bgfx_create_frame_buffer_scaled(bgfx_backbuffer_ratio_t _ratio, bgfx_texture_format_t _format, uint32_t _textureFlags);
  457. /**/
  458. BGFX_C_API bgfx_frame_buffer_handle_t bgfx_create_frame_buffer_from_handles(uint8_t _num, bgfx_texture_handle_t* _handles, bool _destroyTextures);
  459. /**/
  460. BGFX_C_API bgfx_frame_buffer_handle_t bgfx_create_frame_buffer_from_nwh(void* _nwh, uint16_t _width, uint16_t _height, bgfx_texture_format_t _depthFormat);
  461. /**/
  462. BGFX_C_API void bgfx_destroy_frame_buffer(bgfx_frame_buffer_handle_t _handle);
  463. /**/
  464. BGFX_C_API bgfx_uniform_handle_t bgfx_create_uniform(const char* _name, bgfx_uniform_type_t _type, uint16_t _num);
  465. /**/
  466. BGFX_C_API void bgfx_destroy_uniform(bgfx_uniform_handle_t _handle);
  467. /**/
  468. BGFX_C_API void bgfx_set_clear_color(uint8_t _index, const float _rgba[4]);
  469. /**/
  470. BGFX_C_API void bgfx_set_view_name(uint8_t _id, const char* _name);
  471. /**/
  472. BGFX_C_API void bgfx_set_view_rect(uint8_t _id, uint16_t _x, uint16_t _y, uint16_t _width, uint16_t _height);
  473. /**/
  474. BGFX_C_API void bgfx_set_view_scissor(uint8_t _id, uint16_t _x, uint16_t _y, uint16_t _width, uint16_t _height);
  475. /**/
  476. BGFX_C_API void bgfx_set_view_clear(uint8_t _id, uint16_t _flags, uint32_t _rgba, float _depth, uint8_t _stencil);
  477. /**/
  478. BGFX_C_API void bgfx_set_view_clear_mrt(uint8_t _id, uint16_t _flags, float _depth, uint8_t _stencil, uint8_t _0, uint8_t _1, uint8_t _2, uint8_t _3, uint8_t _4, uint8_t _5, uint8_t _6, uint8_t _7);
  479. /**/
  480. BGFX_C_API void bgfx_set_view_seq(uint8_t _id, bool _enabled);
  481. /**/
  482. BGFX_C_API void bgfx_set_view_frame_buffer(uint8_t _id, bgfx_frame_buffer_handle_t _handle);
  483. /**/
  484. BGFX_C_API void bgfx_set_view_transform(uint8_t _id, const void* _view, const void* _proj);
  485. /**/
  486. BGFX_C_API void bgfx_set_view_transform_stereo(uint8_t _id, const void* _view, const void* _projL, uint8_t _flags, const void* _projR);
  487. /**/
  488. BGFX_C_API void bgfx_set_view_remap(uint8_t _id, uint8_t _num, const void* _remap);
  489. /**/
  490. BGFX_C_API void bgfx_set_marker(const char* _marker);
  491. /**/
  492. BGFX_C_API void bgfx_set_state(uint64_t _state, uint32_t _rgba);
  493. /**/
  494. BGFX_C_API void bgfx_set_stencil(uint32_t _fstencil, uint32_t _bstencil);
  495. /**/
  496. BGFX_C_API uint16_t bgfx_set_scissor(uint16_t _x, uint16_t _y, uint16_t _width, uint16_t _height);
  497. /**/
  498. BGFX_C_API void bgfx_set_scissor_cached(uint16_t _cache);
  499. /**/
  500. BGFX_C_API uint32_t bgfx_set_transform(const void* _mtx, uint16_t _num);
  501. /**/
  502. BGFX_C_API uint32_t bgfx_alloc_transform(bgfx_transform_t* _transform, uint16_t _num);
  503. /**/
  504. BGFX_C_API void bgfx_set_transform_cached(uint32_t _cache, uint16_t _num);
  505. /**/
  506. BGFX_C_API void bgfx_set_uniform(bgfx_uniform_handle_t _handle, const void* _value, uint16_t _num);
  507. /**/
  508. BGFX_C_API void bgfx_set_index_buffer(bgfx_index_buffer_handle_t _handle, uint32_t _firstIndex, uint32_t _numIndices);
  509. /**/
  510. BGFX_C_API void bgfx_set_dynamic_index_buffer(bgfx_dynamic_index_buffer_handle_t _handle, uint32_t _firstIndex, uint32_t _numIndices);
  511. /**/
  512. BGFX_C_API void bgfx_set_transient_index_buffer(const bgfx_transient_index_buffer_t* _tib, uint32_t _firstIndex, uint32_t _numIndices);
  513. /**/
  514. BGFX_C_API void bgfx_set_vertex_buffer(bgfx_vertex_buffer_handle_t _handle, uint32_t _startVertex, uint32_t _numVertices);
  515. /**/
  516. BGFX_C_API void bgfx_set_dynamic_vertex_buffer(bgfx_dynamic_vertex_buffer_handle_t _handle, uint32_t _numVertices);
  517. /**/
  518. BGFX_C_API void bgfx_set_transient_vertex_buffer(const bgfx_transient_vertex_buffer_t* _tvb, uint32_t _startVertex, uint32_t _numVertices);
  519. /**/
  520. BGFX_C_API void bgfx_set_instance_data_buffer(const bgfx_instance_data_buffer_t* _idb, uint32_t _num);
  521. /**/
  522. BGFX_C_API void bgfx_set_instance_data_from_vertex_buffer(bgfx_vertex_buffer_handle_t _handle, uint32_t _startVertex, uint32_t _num);
  523. /**/
  524. BGFX_C_API void bgfx_set_instance_data_from_dynamic_vertex_buffer(bgfx_dynamic_vertex_buffer_handle_t _handle, uint32_t _startVertex, uint32_t _num);
  525. /**/
  526. BGFX_C_API void bgfx_set_texture(uint8_t _stage, bgfx_uniform_handle_t _sampler, bgfx_texture_handle_t _handle, uint32_t _flags);
  527. /**/
  528. BGFX_C_API void bgfx_set_texture_from_frame_buffer(uint8_t _stage, bgfx_uniform_handle_t _sampler, bgfx_frame_buffer_handle_t _handle, uint8_t _attachment, uint32_t _flags);
  529. /**/
  530. BGFX_C_API uint32_t bgfx_touch(uint8_t _id);
  531. /**/
  532. BGFX_C_API uint32_t bgfx_submit(uint8_t _id, bgfx_program_handle_t _handle, int32_t _depth);
  533. /**/
  534. BGFX_C_API uint32_t bgfx_submit_indirect(uint8_t _id, bgfx_program_handle_t _handle, bgfx_indirect_buffer_handle_t _indirectHandle, uint16_t _start, uint16_t _num, int32_t _depth);
  535. /**/
  536. BGFX_C_API void bgfx_set_image(uint8_t _stage, bgfx_uniform_handle_t _sampler, bgfx_texture_handle_t _handle, uint8_t _mip, bgfx_access_t _access, bgfx_texture_format_t _format);
  537. /**/
  538. BGFX_C_API void bgfx_set_image_from_frame_buffer(uint8_t _stage, bgfx_uniform_handle_t _sampler, bgfx_frame_buffer_handle_t _handle, uint8_t _attachment, bgfx_access_t _access, bgfx_texture_format_t _format);
  539. /**/
  540. BGFX_C_API void bgfx_set_compute_index_buffer(uint8_t _stage, bgfx_index_buffer_handle_t _handle, bgfx_access_t _access);
  541. /**/
  542. BGFX_C_API void bgfx_set_compute_vertex_buffer(uint8_t _stage, bgfx_vertex_buffer_handle_t _handle, bgfx_access_t _access);
  543. /**/
  544. BGFX_C_API void bgfx_set_compute_dynamic_index_buffer(uint8_t _stage, bgfx_dynamic_index_buffer_handle_t _handle, bgfx_access_t _access);
  545. /**/
  546. BGFX_C_API void bgfx_set_compute_dynamic_vertex_buffer(uint8_t _stage, bgfx_dynamic_vertex_buffer_handle_t _handle, bgfx_access_t _access);
  547. /**/
  548. BGFX_C_API void bgfx_set_compute_indirect_buffer(uint8_t _stage, bgfx_indirect_buffer_handle_t _handle, bgfx_access_t _access);
  549. /**/
  550. BGFX_C_API uint32_t bgfx_dispatch(uint8_t _id, bgfx_program_handle_t _handle, uint16_t _numX, uint16_t _numY, uint16_t _numZ, uint8_t _flags);
  551. /**/
  552. BGFX_C_API uint32_t bgfx_dispatch_indirect(uint8_t _id, bgfx_program_handle_t _handle, bgfx_indirect_buffer_handle_t _indirectHandle, uint16_t _start, uint16_t _num, uint8_t _flags);
  553. /**/
  554. BGFX_C_API void bgfx_discard();
  555. /**/
  556. BGFX_C_API void bgfx_save_screen_shot(const char* _filePath);
  557. #endif // BGFX_C99_H_HEADER_GUARD