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