Advertisement
Guest User

Untitled

a guest
Oct 18th, 2019
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 69.43 KB | None | 0 0
  1. declare module 'picogl' {
  2. enum GL {
  3. DEPTH_BUFFER_BIT = 0x00000100,
  4. STENCIL_BUFFER_BIT = 0x00000400,
  5. COLOR_BUFFER_BIT = 0x00004000,
  6. POINTS = 0x0000,
  7. LINES = 0x0001,
  8. LINE_LOOP = 0x0002,
  9. LINE_STRIP = 0x0003,
  10. TRIANGLES = 0x0004,
  11. TRIANGLE_STRIP = 0x0005,
  12. TRIANGLE_FAN = 0x0006,
  13. ZERO = 0,
  14. ONE = 1,
  15. SRC_COLOR = 0x0300,
  16. ONE_MINUS_SRC_COLOR = 0x0301,
  17. SRC_ALPHA = 0x0302,
  18. ONE_MINUS_SRC_ALPHA = 0x0303,
  19. DST_ALPHA = 0x0304,
  20. ONE_MINUS_DST_ALPHA = 0x0305,
  21. DST_COLOR = 0x0306,
  22. ONE_MINUS_DST_COLOR = 0x0307,
  23. SRC_ALPHA_SATURATE = 0x0308,
  24. FUNC_ADD = 0x8006,
  25. BLEND_EQUATION = 0x8009,
  26. BLEND_EQUATION_RGB = 0x8009,
  27. BLEND_EQUATION_ALPHA = 0x883d,
  28. FUNC_SUBTRACT = 0x800a,
  29. FUNC_REVERSE_SUBTRACT = 0x800b,
  30. BLEND_DST_RGB = 0x80c8,
  31. BLEND_SRC_RGB = 0x80c9,
  32. BLEND_DST_ALPHA = 0x80ca,
  33. BLEND_SRC_ALPHA = 0x80cb,
  34. CONSTANT_COLOR = 0x8001,
  35. ONE_MINUS_CONSTANT_COLOR = 0x8002,
  36. CONSTANT_ALPHA = 0x8003,
  37. ONE_MINUS_CONSTANT_ALPHA = 0x8004,
  38. BLEND_COLOR = 0x8005,
  39. ARRAY_BUFFER = 0x8892,
  40. ELEMENT_ARRAY_BUFFER = 0x8893,
  41. ARRAY_BUFFER_BINDING = 0x8894,
  42. ELEMENT_ARRAY_BUFFER_BINDING = 0x8895,
  43. STREAM_DRAW = 0x88e0,
  44. STATIC_DRAW = 0x88e4,
  45. DYNAMIC_DRAW = 0x88e8,
  46. BUFFER_SIZE = 0x8764,
  47. BUFFER_USAGE = 0x8765,
  48. CURRENT_VERTEX_ATTRIB = 0x8626,
  49. FRONT = 0x0404,
  50. BACK = 0x0405,
  51. FRONT_AND_BACK = 0x0408,
  52. CULL_FACE = 0x0b44,
  53. BLEND = 0x0be2,
  54. DITHER = 0x0bd0,
  55. STENCIL_TEST = 0x0b90,
  56. DEPTH_TEST = 0x0b71,
  57. SCISSOR_TEST = 0x0c11,
  58. POLYGON_OFFSET_FILL = 0x8037,
  59. SAMPLE_ALPHA_TO_COVERAGE = 0x809e,
  60. SAMPLE_COVERAGE = 0x80a0,
  61. NO_ERROR = 0,
  62. INVALID_ENUM = 0x0500,
  63. INVALID_VALUE = 0x0501,
  64. INVALID_OPERATION = 0x0502,
  65. OUT_OF_MEMORY = 0x0505,
  66. CW = 0x0900,
  67. CCW = 0x0901,
  68. LINE_WIDTH = 0x0b21,
  69. ALIASED_POINT_SIZE_RANGE = 0x846d,
  70. ALIASED_LINE_WIDTH_RANGE = 0x846e,
  71. CULL_FACE_MODE = 0x0b45,
  72. FRONT_FACE = 0x0b46,
  73. DEPTH_RANGE = 0x0b70,
  74. DEPTH_WRITEMASK = 0x0b72,
  75. DEPTH_CLEAR_VALUE = 0x0b73,
  76. DEPTH_FUNC = 0x0b74,
  77. STENCIL_CLEAR_VALUE = 0x0b91,
  78. STENCIL_FUNC = 0x0b92,
  79. STENCIL_FAIL = 0x0b94,
  80. STENCIL_PASS_DEPTH_FAIL = 0x0b95,
  81. STENCIL_PASS_DEPTH_PASS = 0x0b96,
  82. STENCIL_REF = 0x0b97,
  83. STENCIL_VALUE_MASK = 0x0b93,
  84. STENCIL_WRITEMASK = 0x0b98,
  85. STENCIL_BACK_FUNC = 0x8800,
  86. STENCIL_BACK_FAIL = 0x8801,
  87. STENCIL_BACK_PASS_DEPTH_FAIL = 0x8802,
  88. STENCIL_BACK_PASS_DEPTH_PASS = 0x8803,
  89. STENCIL_BACK_REF = 0x8ca3,
  90. STENCIL_BACK_VALUE_MASK = 0x8ca4,
  91. STENCIL_BACK_WRITEMASK = 0x8ca5,
  92. VIEWPORT = 0x0ba2,
  93. SCISSOR_BOX = 0x0c10,
  94. COLOR_CLEAR_VALUE = 0x0c22,
  95. COLOR_WRITEMASK = 0x0c23,
  96. UNPACK_ALIGNMENT = 0x0cf5,
  97. PACK_ALIGNMENT = 0x0d05,
  98. MAX_TEXTURE_SIZE = 0x0d33,
  99. MAX_VIEWPORT_DIMS = 0x0d3a,
  100. SUBPIXEL_BITS = 0x0d50,
  101. RED_BITS = 0x0d52,
  102. GREEN_BITS = 0x0d53,
  103. BLUE_BITS = 0x0d54,
  104. ALPHA_BITS = 0x0d55,
  105. DEPTH_BITS = 0x0d56,
  106. STENCIL_BITS = 0x0d57,
  107. POLYGON_OFFSET_UNITS = 0x2a00,
  108. POLYGON_OFFSET_FACTOR = 0x8038,
  109. TEXTURE_BINDING_2D = 0x8069,
  110. SAMPLE_BUFFERS = 0x80a8,
  111. SAMPLES = 0x80a9,
  112. SAMPLE_COVERAGE_VALUE = 0x80aa,
  113. SAMPLE_COVERAGE_INVERT = 0x80ab,
  114. COMPRESSED_TEXTURE_FORMATS = 0x86a3,
  115. DONT_CARE = 0x1100,
  116. FASTEST = 0x1101,
  117. NICEST = 0x1102,
  118. GENERATE_MIPMAP_HINT = 0x8192,
  119. BYTE = 0x1400,
  120. UNSIGNED_BYTE = 0x1401,
  121. SHORT = 0x1402,
  122. UNSIGNED_SHORT = 0x1403,
  123. INT = 0x1404,
  124. UNSIGNED_INT = 0x1405,
  125. FLOAT = 0x1406,
  126. DEPTH_COMPONENT = 0x1902,
  127. ALPHA = 0x1906,
  128. RGB = 0x1907,
  129. RGBA = 0x1908,
  130. LUMINANCE = 0x1909,
  131. LUMINANCE_ALPHA = 0x190a,
  132. UNSIGNED_SHORT_4_4_4_4 = 0x8033,
  133. UNSIGNED_SHORT_5_5_5_1 = 0x8034,
  134. UNSIGNED_SHORT_5_6_5 = 0x8363,
  135. FRAGMENT_SHADER = 0x8b30,
  136. VERTEX_SHADER = 0x8b31,
  137. MAX_VERTEX_ATTRIBS = 0x8869,
  138. MAX_VERTEX_UNIFORM_VECTORS = 0x8dfb,
  139. MAX_VARYING_VECTORS = 0x8dfc,
  140. MAX_COMBINED_TEXTURE_IMAGE_UNITS = 0x8b4d,
  141. MAX_VERTEX_TEXTURE_IMAGE_UNITS = 0x8b4c,
  142. MAX_TEXTURE_IMAGE_UNITS = 0x8872,
  143. MAX_FRAGMENT_UNIFORM_VECTORS = 0x8dfd,
  144. SHADER_TYPE = 0x8b4f,
  145. DELETE_STATUS = 0x8b80,
  146. LINK_STATUS = 0x8b82,
  147. VALIDATE_STATUS = 0x8b83,
  148. ATTACHED_SHADERS = 0x8b85,
  149. ACTIVE_UNIFORMS = 0x8b86,
  150. ACTIVE_ATTRIBUTES = 0x8b89,
  151. SHADING_LANGUAGE_VERSION = 0x8b8c,
  152. CURRENT_PROGRAM = 0x8b8d,
  153. NEVER = 0x0200,
  154. LESS = 0x0201,
  155. EQUAL = 0x0202,
  156. LEQUAL = 0x0203,
  157. GREATER = 0x0204,
  158. NOTEQUAL = 0x0205,
  159. GEQUAL = 0x0206,
  160. ALWAYS = 0x0207,
  161. KEEP = 0x1e00,
  162. REPLACE = 0x1e01,
  163. INCR = 0x1e02,
  164. DECR = 0x1e03,
  165. INVERT = 0x150a,
  166. INCR_WRAP = 0x8507,
  167. DECR_WRAP = 0x8508,
  168. VENDOR = 0x1f00,
  169. RENDERER = 0x1f01,
  170. VERSION = 0x1f02,
  171. NEAREST = 0x2600,
  172. LINEAR = 0x2601,
  173. NEAREST_MIPMAP_NEAREST = 0x2700,
  174. LINEAR_MIPMAP_NEAREST = 0x2701,
  175. NEAREST_MIPMAP_LINEAR = 0x2702,
  176. LINEAR_MIPMAP_LINEAR = 0x2703,
  177. TEXTURE_MAG_FILTER = 0x2800,
  178. TEXTURE_MIN_FILTER = 0x2801,
  179. TEXTURE_WRAP_S = 0x2802,
  180. TEXTURE_WRAP_T = 0x2803,
  181. TEXTURE_2D = 0x0de1,
  182. TEXTURE = 0x1702,
  183. TEXTURE_CUBE_MAP = 0x8513,
  184. TEXTURE_BINDING_CUBE_MAP = 0x8514,
  185. TEXTURE_CUBE_MAP_POSITIVE_X = 0x8515,
  186. TEXTURE_CUBE_MAP_NEGATIVE_X = 0x8516,
  187. TEXTURE_CUBE_MAP_POSITIVE_Y = 0x8517,
  188. TEXTURE_CUBE_MAP_NEGATIVE_Y = 0x8518,
  189. TEXTURE_CUBE_MAP_POSITIVE_Z = 0x8519,
  190. TEXTURE_CUBE_MAP_NEGATIVE_Z = 0x851a,
  191. MAX_CUBE_MAP_TEXTURE_SIZE = 0x851c,
  192. TEXTURE0 = 0x84c0,
  193. TEXTURE1 = 0x84c1,
  194. TEXTURE2 = 0x84c2,
  195. TEXTURE3 = 0x84c3,
  196. TEXTURE4 = 0x84c4,
  197. TEXTURE5 = 0x84c5,
  198. TEXTURE6 = 0x84c6,
  199. TEXTURE7 = 0x84c7,
  200. TEXTURE8 = 0x84c8,
  201. TEXTURE9 = 0x84c9,
  202. TEXTURE10 = 0x84ca,
  203. TEXTURE11 = 0x84cb,
  204. TEXTURE12 = 0x84cc,
  205. TEXTURE13 = 0x84cd,
  206. TEXTURE14 = 0x84ce,
  207. TEXTURE15 = 0x84cf,
  208. TEXTURE16 = 0x84d0,
  209. TEXTURE17 = 0x84d1,
  210. TEXTURE18 = 0x84d2,
  211. TEXTURE19 = 0x84d3,
  212. TEXTURE20 = 0x84d4,
  213. TEXTURE21 = 0x84d5,
  214. TEXTURE22 = 0x84d6,
  215. TEXTURE23 = 0x84d7,
  216. TEXTURE24 = 0x84d8,
  217. TEXTURE25 = 0x84d9,
  218. TEXTURE26 = 0x84da,
  219. TEXTURE27 = 0x84db,
  220. TEXTURE28 = 0x84dc,
  221. TEXTURE29 = 0x84dd,
  222. TEXTURE30 = 0x84de,
  223. TEXTURE31 = 0x84df,
  224. ACTIVE_TEXTURE = 0x84e0,
  225. REPEAT = 0x2901,
  226. CLAMP_TO_EDGE = 0x812f,
  227. MIRRORED_REPEAT = 0x8370,
  228. FLOAT_VEC2 = 0x8b50,
  229. FLOAT_VEC3 = 0x8b51,
  230. FLOAT_VEC4 = 0x8b52,
  231. INT_VEC2 = 0x8b53,
  232. INT_VEC3 = 0x8b54,
  233. INT_VEC4 = 0x8b55,
  234. BOOL = 0x8b56,
  235. BOOL_VEC2 = 0x8b57,
  236. BOOL_VEC3 = 0x8b58,
  237. BOOL_VEC4 = 0x8b59,
  238. FLOAT_MAT2 = 0x8b5a,
  239. FLOAT_MAT3 = 0x8b5b,
  240. FLOAT_MAT4 = 0x8b5c,
  241. SAMPLER_2D = 0x8b5e,
  242. SAMPLER_CUBE = 0x8b60,
  243. VERTEX_ATTRIB_ARRAY_ENABLED = 0x8622,
  244. VERTEX_ATTRIB_ARRAY_SIZE = 0x8623,
  245. VERTEX_ATTRIB_ARRAY_STRIDE = 0x8624,
  246. VERTEX_ATTRIB_ARRAY_TYPE = 0x8625,
  247. VERTEX_ATTRIB_ARRAY_NORMALIZED = 0x886a,
  248. VERTEX_ATTRIB_ARRAY_POINTER = 0x8645,
  249. VERTEX_ATTRIB_ARRAY_BUFFER_BINDING = 0x889f,
  250. IMPLEMENTATION_COLOR_READ_TYPE = 0x8b9a,
  251. IMPLEMENTATION_COLOR_READ_FORMAT = 0x8b9b,
  252. COMPILE_STATUS = 0x8b81,
  253. LOW_FLOAT = 0x8df0,
  254. MEDIUM_FLOAT = 0x8df1,
  255. HIGH_FLOAT = 0x8df2,
  256. LOW_INT = 0x8df3,
  257. MEDIUM_INT = 0x8df4,
  258. HIGH_INT = 0x8df5,
  259. FRAMEBUFFER = 0x8d40,
  260. RENDERBUFFER = 0x8d41,
  261. RGBA4 = 0x8056,
  262. RGB5_A1 = 0x8057,
  263. RGB565 = 0x8d62,
  264. DEPTH_COMPONENT16 = 0x81a5,
  265. STENCIL_INDEX = 0x1901,
  266. STENCIL_INDEX8 = 0x8d48,
  267. DEPTH_STENCIL = 0x84f9,
  268. RENDERBUFFER_WIDTH = 0x8d42,
  269. RENDERBUFFER_HEIGHT = 0x8d43,
  270. RENDERBUFFER_INTERNAL_FORMAT = 0x8d44,
  271. RENDERBUFFER_RED_SIZE = 0x8d50,
  272. RENDERBUFFER_GREEN_SIZE = 0x8d51,
  273. RENDERBUFFER_BLUE_SIZE = 0x8d52,
  274. RENDERBUFFER_ALPHA_SIZE = 0x8d53,
  275. RENDERBUFFER_DEPTH_SIZE = 0x8d54,
  276. RENDERBUFFER_STENCIL_SIZE = 0x8d55,
  277. FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE = 0x8cd0,
  278. FRAMEBUFFER_ATTACHMENT_OBJECT_NAME = 0x8cd1,
  279. FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL = 0x8cd2,
  280. FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE = 0x8cd3,
  281. COLOR_ATTACHMENT0 = 0x8ce0,
  282. DEPTH_ATTACHMENT = 0x8d00,
  283. STENCIL_ATTACHMENT = 0x8d20,
  284. DEPTH_STENCIL_ATTACHMENT = 0x821a,
  285. NONE = 0,
  286. FRAMEBUFFER_COMPLETE = 0x8cd5,
  287. FRAMEBUFFER_INCOMPLETE_ATTACHMENT = 0x8cd6,
  288. FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT = 0x8cd7,
  289. FRAMEBUFFER_INCOMPLETE_DIMENSIONS = 0x8cd9,
  290. FRAMEBUFFER_UNSUPPORTED = 0x8cdd,
  291. FRAMEBUFFER_BINDING = 0x8ca6,
  292. RENDERBUFFER_BINDING = 0x8ca7,
  293. MAX_RENDERBUFFER_SIZE = 0x84e8,
  294. INVALID_FRAMEBUFFER_OPERATION = 0x0506,
  295. UNPACK_FLIP_Y_WEBGL = 0x9240,
  296. UNPACK_PREMULTIPLY_ALPHA_WEBGL = 0x9241,
  297. CONTEXT_LOST_WEBGL = 0x9242,
  298. UNPACK_COLORSPACE_CONVERSION_WEBGL = 0x9243,
  299. BROWSER_DEFAULT_WEBGL = 0x9244,
  300. READ_BUFFER = 0x0c02,
  301. UNPACK_ROW_LENGTH = 0x0cf2,
  302. UNPACK_SKIP_ROWS = 0x0cf3,
  303. UNPACK_SKIP_PIXELS = 0x0cf4,
  304. PACK_ROW_LENGTH = 0x0d02,
  305. PACK_SKIP_ROWS = 0x0d03,
  306. PACK_SKIP_PIXELS = 0x0d04,
  307. COLOR = 0x1800,
  308. DEPTH = 0x1801,
  309. STENCIL = 0x1802,
  310. RED = 0x1903,
  311. RGB8 = 0x8051,
  312. RGBA8 = 0x8058,
  313. RGB10_A2 = 0x8059,
  314. TEXTURE_BINDING_3D = 0x806a,
  315. UNPACK_SKIP_IMAGES = 0x806d,
  316. UNPACK_IMAGE_HEIGHT = 0x806e,
  317. TEXTURE_3D = 0x806f,
  318. TEXTURE_WRAP_R = 0x8072,
  319. MAX_3D_TEXTURE_SIZE = 0x8073,
  320. UNSIGNED_INT_2_10_10_10_REV = 0x8368,
  321. MAX_ELEMENTS_VERTICES = 0x80e8,
  322. MAX_ELEMENTS_INDICES = 0x80e9,
  323. TEXTURE_MIN_LOD = 0x813a,
  324. TEXTURE_MAX_LOD = 0x813b,
  325. TEXTURE_BASE_LEVEL = 0x813c,
  326. TEXTURE_MAX_LEVEL = 0x813d,
  327. MIN = 0x8007,
  328. MAX = 0x8008,
  329. DEPTH_COMPONENT24 = 0x81a6,
  330. MAX_TEXTURE_LOD_BIAS = 0x84fd,
  331. TEXTURE_COMPARE_MODE = 0x884c,
  332. TEXTURE_COMPARE_FUNC = 0x884d,
  333. CURRENT_QUERY = 0x8865,
  334. QUERY_RESULT = 0x8866,
  335. QUERY_RESULT_AVAILABLE = 0x8867,
  336. STREAM_READ = 0x88e1,
  337. STREAM_COPY = 0x88e2,
  338. STATIC_READ = 0x88e5,
  339. STATIC_COPY = 0x88e6,
  340. DYNAMIC_READ = 0x88e9,
  341. DYNAMIC_COPY = 0x88ea,
  342. MAX_DRAW_BUFFERS = 0x8824,
  343. DRAW_BUFFER0 = 0x8825,
  344. DRAW_BUFFER1 = 0x8826,
  345. DRAW_BUFFER2 = 0x8827,
  346. DRAW_BUFFER3 = 0x8828,
  347. DRAW_BUFFER4 = 0x8829,
  348. DRAW_BUFFER5 = 0x882a,
  349. DRAW_BUFFER6 = 0x882b,
  350. DRAW_BUFFER7 = 0x882c,
  351. DRAW_BUFFER8 = 0x882d,
  352. DRAW_BUFFER9 = 0x882e,
  353. DRAW_BUFFER10 = 0x882f,
  354. DRAW_BUFFER11 = 0x8830,
  355. DRAW_BUFFER12 = 0x8831,
  356. DRAW_BUFFER13 = 0x8832,
  357. DRAW_BUFFER14 = 0x8833,
  358. DRAW_BUFFER15 = 0x8834,
  359. MAX_FRAGMENT_UNIFORM_COMPONENTS = 0x8b49,
  360. MAX_VERTEX_UNIFORM_COMPONENTS = 0x8b4a,
  361. SAMPLER_3D = 0x8b5f,
  362. SAMPLER_2D_SHADOW = 0x8b62,
  363. FRAGMENT_SHADER_DERIVATIVE_HINT = 0x8b8b,
  364. PIXEL_PACK_BUFFER = 0x88eb,
  365. PIXEL_UNPACK_BUFFER = 0x88ec,
  366. PIXEL_PACK_BUFFER_BINDING = 0x88ed,
  367. PIXEL_UNPACK_BUFFER_BINDING = 0x88ef,
  368. FLOAT_MAT2x3 = 0x8b65,
  369. FLOAT_MAT2x4 = 0x8b66,
  370. FLOAT_MAT3x2 = 0x8b67,
  371. FLOAT_MAT3x4 = 0x8b68,
  372. FLOAT_MAT4x2 = 0x8b69,
  373. FLOAT_MAT4x3 = 0x8b6a,
  374. SRGB = 0x8c40,
  375. SRGB8 = 0x8c41,
  376. SRGB8_ALPHA8 = 0x8c43,
  377. COMPARE_REF_TO_TEXTURE = 0x884e,
  378. RGBA32F = 0x8814,
  379. RGB32F = 0x8815,
  380. RGBA16F = 0x881a,
  381. RGB16F = 0x881b,
  382. VERTEX_ATTRIB_ARRAY_INTEGER = 0x88fd,
  383. MAX_ARRAY_TEXTURE_LAYERS = 0x88ff,
  384. MIN_PROGRAM_TEXEL_OFFSET = 0x8904,
  385. MAX_PROGRAM_TEXEL_OFFSET = 0x8905,
  386. MAX_VARYING_COMPONENTS = 0x8b4b,
  387. TEXTURE_2D_ARRAY = 0x8c1a,
  388. TEXTURE_BINDING_2D_ARRAY = 0x8c1d,
  389. R11F_G11F_B10F = 0x8c3a,
  390. UNSIGNED_INT_10F_11F_11F_REV = 0x8c3b,
  391. RGB9_E5 = 0x8c3d,
  392. UNSIGNED_INT_5_9_9_9_REV = 0x8c3e,
  393. TRANSFORM_FEEDBACK_BUFFER_MODE = 0x8c7f,
  394. MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS = 0x8c80,
  395. TRANSFORM_FEEDBACK_VARYINGS = 0x8c83,
  396. TRANSFORM_FEEDBACK_BUFFER_START = 0x8c84,
  397. TRANSFORM_FEEDBACK_BUFFER_SIZE = 0x8c85,
  398. TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN = 0x8c88,
  399. RASTERIZER_DISCARD = 0x8c89,
  400. MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS = 0x8c8a,
  401. MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS = 0x8c8b,
  402. INTERLEAVED_ATTRIBS = 0x8c8c,
  403. SEPARATE_ATTRIBS = 0x8c8d,
  404. TRANSFORM_FEEDBACK_BUFFER = 0x8c8e,
  405. TRANSFORM_FEEDBACK_BUFFER_BINDING = 0x8c8f,
  406. RGBA32UI = 0x8d70,
  407. RGB32UI = 0x8d71,
  408. RGBA16UI = 0x8d76,
  409. RGB16UI = 0x8d77,
  410. RGBA8UI = 0x8d7c,
  411. RGB8UI = 0x8d7d,
  412. RGBA32I = 0x8d82,
  413. RGB32I = 0x8d83,
  414. RGBA16I = 0x8d88,
  415. RGB16I = 0x8d89,
  416. RGBA8I = 0x8d8e,
  417. RGB8I = 0x8d8f,
  418. RED_INTEGER = 0x8d94,
  419. RGB_INTEGER = 0x8d98,
  420. RGBA_INTEGER = 0x8d99,
  421. SAMPLER_2D_ARRAY = 0x8dc1,
  422. SAMPLER_2D_ARRAY_SHADOW = 0x8dc4,
  423. SAMPLER_CUBE_SHADOW = 0x8dc5,
  424. UNSIGNED_INT_VEC2 = 0x8dc6,
  425. UNSIGNED_INT_VEC3 = 0x8dc7,
  426. UNSIGNED_INT_VEC4 = 0x8dc8,
  427. INT_SAMPLER_2D = 0x8dca,
  428. INT_SAMPLER_3D = 0x8dcb,
  429. INT_SAMPLER_CUBE = 0x8dcc,
  430. INT_SAMPLER_2D_ARRAY = 0x8dcf,
  431. UNSIGNED_INT_SAMPLER_2D = 0x8dd2,
  432. UNSIGNED_INT_SAMPLER_3D = 0x8dd3,
  433. UNSIGNED_INT_SAMPLER_CUBE = 0x8dd4,
  434. UNSIGNED_INT_SAMPLER_2D_ARRAY = 0x8dd7,
  435. DEPTH_COMPONENT32F = 0x8cac,
  436. DEPTH32F_STENCIL8 = 0x8cad,
  437. FLOAT_32_UNSIGNED_INT_24_8_REV = 0x8dad,
  438. FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING = 0x8210,
  439. FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE = 0x8211,
  440. FRAMEBUFFER_ATTACHMENT_RED_SIZE = 0x8212,
  441. FRAMEBUFFER_ATTACHMENT_GREEN_SIZE = 0x8213,
  442. FRAMEBUFFER_ATTACHMENT_BLUE_SIZE = 0x8214,
  443. FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE = 0x8215,
  444. FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE = 0x8216,
  445. FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE = 0x8217,
  446. FRAMEBUFFER_DEFAULT = 0x8218,
  447. UNSIGNED_INT_24_8 = 0x84fa,
  448. DEPTH24_STENCIL8 = 0x88f0,
  449. UNSIGNED_NORMALIZED = 0x8c17,
  450. DRAW_FRAMEBUFFER_BINDING = 0x8ca6,
  451. READ_FRAMEBUFFER = 0x8ca8,
  452. DRAW_FRAMEBUFFER = 0x8ca9,
  453. READ_FRAMEBUFFER_BINDING = 0x8caa,
  454. RENDERBUFFER_SAMPLES = 0x8cab,
  455. FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER = 0x8cd4,
  456. MAX_COLOR_ATTACHMENTS = 0x8cdf,
  457. COLOR_ATTACHMENT1 = 0x8ce1,
  458. COLOR_ATTACHMENT2 = 0x8ce2,
  459. COLOR_ATTACHMENT3 = 0x8ce3,
  460. COLOR_ATTACHMENT4 = 0x8ce4,
  461. COLOR_ATTACHMENT5 = 0x8ce5,
  462. COLOR_ATTACHMENT6 = 0x8ce6,
  463. COLOR_ATTACHMENT7 = 0x8ce7,
  464. COLOR_ATTACHMENT8 = 0x8ce8,
  465. COLOR_ATTACHMENT9 = 0x8ce9,
  466. COLOR_ATTACHMENT10 = 0x8cea,
  467. COLOR_ATTACHMENT11 = 0x8ceb,
  468. COLOR_ATTACHMENT12 = 0x8cec,
  469. COLOR_ATTACHMENT13 = 0x8ced,
  470. COLOR_ATTACHMENT14 = 0x8cee,
  471. COLOR_ATTACHMENT15 = 0x8cef,
  472. FRAMEBUFFER_INCOMPLETE_MULTISAMPLE = 0x8d56,
  473. MAX_SAMPLES = 0x8d57,
  474. HALF_FLOAT = 0x140b,
  475. RG = 0x8227,
  476. RG_INTEGER = 0x8228,
  477. R8 = 0x8229,
  478. RG8 = 0x822b,
  479. R16F = 0x822d,
  480. R32F = 0x822e,
  481. RG16F = 0x822f,
  482. RG32F = 0x8230,
  483. R8I = 0x8231,
  484. R8UI = 0x8232,
  485. R16I = 0x8233,
  486. R16UI = 0x8234,
  487. R32I = 0x8235,
  488. R32UI = 0x8236,
  489. RG8I = 0x8237,
  490. RG8UI = 0x8238,
  491. RG16I = 0x8239,
  492. RG16UI = 0x823a,
  493. RG32I = 0x823b,
  494. RG32UI = 0x823c,
  495. VERTEX_ARRAY_BINDING = 0x85b5,
  496. R8_SNORM = 0x8f94,
  497. RG8_SNORM = 0x8f95,
  498. RGB8_SNORM = 0x8f96,
  499. RGBA8_SNORM = 0x8f97,
  500. SIGNED_NORMALIZED = 0x8f9c,
  501. COPY_READ_BUFFER = 0x8f36,
  502. COPY_WRITE_BUFFER = 0x8f37,
  503. COPY_READ_BUFFER_BINDING = 0x8f36,
  504. COPY_WRITE_BUFFER_BINDING = 0x8f37,
  505. UNIFORM_BUFFER = 0x8a11,
  506. UNIFORM_BUFFER_BINDING = 0x8a28,
  507. UNIFORM_BUFFER_START = 0x8a29,
  508. UNIFORM_BUFFER_SIZE = 0x8a2a,
  509. MAX_VERTEX_UNIFORM_BLOCKS = 0x8a2b,
  510. MAX_FRAGMENT_UNIFORM_BLOCKS = 0x8a2d,
  511. MAX_COMBINED_UNIFORM_BLOCKS = 0x8a2e,
  512. MAX_UNIFORM_BUFFER_BINDINGS = 0x8a2f,
  513. MAX_UNIFORM_BLOCK_SIZE = 0x8a30,
  514. MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS = 0x8a31,
  515. MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS = 0x8a33,
  516. UNIFORM_BUFFER_OFFSET_ALIGNMENT = 0x8a34,
  517. ACTIVE_UNIFORM_BLOCKS = 0x8a36,
  518. UNIFORM_TYPE = 0x8a37,
  519. UNIFORM_SIZE = 0x8a38,
  520. UNIFORM_BLOCK_INDEX = 0x8a3a,
  521. UNIFORM_OFFSET = 0x8a3b,
  522. UNIFORM_ARRAY_STRIDE = 0x8a3c,
  523. UNIFORM_MATRIX_STRIDE = 0x8a3d,
  524. UNIFORM_IS_ROW_MAJOR = 0x8a3e,
  525. UNIFORM_BLOCK_BINDING = 0x8a3f,
  526. UNIFORM_BLOCK_DATA_SIZE = 0x8a40,
  527. UNIFORM_BLOCK_ACTIVE_UNIFORMS = 0x8a42,
  528. UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES = 0x8a43,
  529. UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER = 0x8a44,
  530. UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER = 0x8a46,
  531. INVALID_INDEX = 0xffffffff,
  532. MAX_VERTEX_OUTPUT_COMPONENTS = 0x9122,
  533. MAX_FRAGMENT_INPUT_COMPONENTS = 0x9125,
  534. MAX_SERVER_WAIT_TIMEOUT = 0x9111,
  535. OBJECT_TYPE = 0x9112,
  536. SYNC_CONDITION = 0x9113,
  537. SYNC_STATUS = 0x9114,
  538. SYNC_FLAGS = 0x9115,
  539. SYNC_FENCE = 0x9116,
  540. SYNC_GPU_COMMANDS_COMPLETE = 0x9117,
  541. UNSIGNALED = 0x9118,
  542. SIGNALED = 0x9119,
  543. ALREADY_SIGNALED = 0x911a,
  544. TIMEOUT_EXPIRED = 0x911b,
  545. CONDITION_SATISFIED = 0x911c,
  546. WAIT_FAILED = 0x911d,
  547. SYNC_FLUSH_COMMANDS_BIT = 0x00000001,
  548. VERTEX_ATTRIB_ARRAY_DIVISOR = 0x88fe,
  549. ANY_SAMPLES_PASSED = 0x8c2f,
  550. ANY_SAMPLES_PASSED_CONSERVATIVE = 0x8d6a,
  551. SAMPLER_BINDING = 0x8919,
  552. RGB10_A2UI = 0x906f,
  553. INT_2_10_10_10_REV = 0x8d9f,
  554. TRANSFORM_FEEDBACK = 0x8e22,
  555. TRANSFORM_FEEDBACK_PAUSED = 0x8e23,
  556. TRANSFORM_FEEDBACK_ACTIVE = 0x8e24,
  557. TRANSFORM_FEEDBACK_BINDING = 0x8e25,
  558. TEXTURE_IMMUTABLE_FORMAT = 0x912f,
  559. MAX_ELEMENT_INDEX = 0x8d6b,
  560. TEXTURE_IMMUTABLE_LEVELS = 0x82df,
  561. TIMEOUT_IGNORED = -1,
  562. MAX_CLIENT_WAIT_TIMEOUT_WEBGL = 0x9247,
  563.  
  564. QUERY_COUNTER_BITS_EXT = 0x8864,
  565. TIME_ELAPSED_EXT = 0x88bf,
  566. TIMESTAMP_EXT = 0x8e28,
  567. GPU_DISJOINT_EXT = 0x8fbb,
  568.  
  569. TEXTURE_MAX_ANISOTROPY_EXT = 0x84fe,
  570. MAX_TEXTURE_MAX_ANISOTROPY_EXT = 0x84ff,
  571.  
  572. UNMASKED_VENDOR_WEBGL = 0x9245,
  573. UNMASKED_RENDERER_WEBGL = 0x9246,
  574.  
  575. COMPLETION_STATUS_KHR = 0x91b1,
  576.  
  577. COMPRESSED_RGB_S3TC_DXT1_EXT = 0x83f0,
  578. COMPRESSED_RGBA_S3TC_DXT1_EXT = 0x83f1,
  579. COMPRESSED_RGBA_S3TC_DXT3_EXT = 0x83f2,
  580. COMPRESSED_RGBA_S3TC_DXT5_EXT = 0x83f3,
  581.  
  582. COMPRESSED_SRGB_S3TC_DXT1_EXT = 0x8c4c,
  583. COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT = 0x8c4d,
  584. COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT = 0x8c4e,
  585. COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT = 0x8c4f,
  586.  
  587. COMPRESSED_R11_EAC = 0x9270,
  588. COMPRESSED_SIGNED_R11_EAC = 0x9271,
  589. COMPRESSED_RG11_EAC = 0x9272,
  590. COMPRESSED_SIGNED_RG11_EAC = 0x9273,
  591. COMPRESSED_RGB8_ETC2 = 0x9274,
  592. COMPRESSED_SRGB8_ETC2 = 0x9275,
  593. COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2 = 0x9276,
  594. COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2 = 0x9277,
  595. COMPRESSED_RGBA8_ETC2_EAC = 0x9278,
  596. COMPRESSED_SRGB8_ALPHA8_ETC2_EAC = 0x9279,
  597.  
  598. COMPRESSED_RGB_PVRTC_4BPPV1_IMG = 0x8c00,
  599. COMPRESSED_RGB_PVRTC_2BPPV1_IMG = 0x8c01,
  600. COMPRESSED_RGBA_PVRTC_4BPPV1_IMG = 0x8c02,
  601. COMPRESSED_RGBA_PVRTC_2BPPV1_IMG = 0x8c03,
  602.  
  603. COMPRESSED_RGBA_ASTC_4x4_KHR = 0x93b0,
  604. COMPRESSED_RGBA_ASTC_5x4_KHR = 0x93b1,
  605. COMPRESSED_RGBA_ASTC_5x5_KHR = 0x93b2,
  606. COMPRESSED_RGBA_ASTC_6x5_KHR = 0x93b3,
  607. COMPRESSED_RGBA_ASTC_6x6_KHR = 0x93b4,
  608. COMPRESSED_RGBA_ASTC_8x5_KHR = 0x93b5,
  609. COMPRESSED_RGBA_ASTC_8x6_KHR = 0x93b6,
  610. COMPRESSED_RGBA_ASTC_8x8_KHR = 0x93b7,
  611. COMPRESSED_RGBA_ASTC_10x5_KHR = 0x93b8,
  612. COMPRESSED_RGBA_ASTC_10x6_KHR = 0x93b9,
  613. COMPRESSED_RGBA_ASTC_10x8_KHR = 0x93ba,
  614. COMPRESSED_RGBA_ASTC_10x10_KHR = 0x93bb,
  615. COMPRESSED_RGBA_ASTC_12x10_KHR = 0x93bc,
  616. COMPRESSED_RGBA_ASTC_12x12_KHR = 0x93bd,
  617. COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR = 0x93d0,
  618. COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR = 0x93d1,
  619. COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR = 0x93d2,
  620. COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR = 0x93d3,
  621. COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR = 0x93d4,
  622. COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR = 0x93d5,
  623. COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR = 0x93d6,
  624. COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR = 0x93d7,
  625. COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR = 0x93d8,
  626. COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR = 0x93d9,
  627. COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR = 0x93da,
  628. COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR = 0x93db,
  629. COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR = 0x93dc,
  630. COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR = 0x93dd,
  631. }
  632.  
  633. type WEBGL_INFO = {
  634. MAX_TEXTURE_UNITS: GLint
  635. MAX_UNIFORM_BUFFERS: GLint
  636. MAX_UNIFORMS: GLint
  637. SAMPLES: GLint
  638. VENDOR: string
  639. RENDERER: string
  640.  
  641. FLOAT_RENDER_TARGETS: boolean
  642. LINEAR_FLOAT_TEXTURES: boolean
  643. S3TC_TEXTURES: boolean
  644. S3TC_SRGB_TEXTURES: boolean
  645. ETC_TEXTURES: boolean
  646. ASTC_TEXTURES: boolean
  647. PVRTC_TEXTURES: boolean
  648. LOSE_CONTEXT: boolean
  649. DEBUG_SHADERS: boolean
  650. GPU_TIMER: boolean
  651.  
  652. TEXTURE_ANISOTROPY: boolean
  653. MAX_TEXTURE_ANISOTROPY: GLint
  654.  
  655. DEBUG_RENDERER_INFO: boolean
  656.  
  657. PARALLEL_SHADER_COMPILE: boolean
  658. MULTI_DRAW_INSTANCED: boolean
  659. }
  660.  
  661. export const PicoGL: {
  662. readonly version: string
  663. /** Create a PicoGL app. The app is the primary entry point to PicoGL. It stores the canvas, the WebGL context and all WebGL state. */
  664. createApp(canvas: OffscreenCanvas | HTMLCanvasElement, attributes: WebGLContextAttributes): App
  665. } & Readonly<WEBGL_INFO> &
  666. {
  667. readonly [key in keyof typeof GL]: (typeof GL)[key]
  668. }
  669. export default PicoGL
  670.  
  671. type GLReadPixelFormat = GL.STENCIL_INDEX | GL.DEPTH_COMPONENT | GL.RED | GL.ALPHA | GL.RGB | GL.RGBA | GL.LUMINANCE | GL.LUMINANCE_ALPHA
  672. type GLInternalFormat =
  673. | GL.R8
  674. | GL.R8UI
  675. | GL.R8I
  676. | GL.R16UI
  677. | GL.R16I
  678. | GL.R32UI
  679. | GL.R32I
  680. | GL.RG8
  681. | GL.RG8UI
  682. | GL.RG8I
  683. | GL.RG16UI
  684. | GL.RG16I
  685. | GL.RG32UI
  686. | GL.RG32I
  687. | GL.RGB8
  688. | GL.RGBA8
  689. | GL.SRGB8_ALPHA8
  690. | GL.RGBA4
  691. | GL.RGB565
  692. | GL.RGB5_A1
  693. | GL.RGB10_A2
  694. | GL.RGBA8UI
  695. | GL.RGBA8I
  696. | GL.RGB10_A2UI
  697. | GL.RGBA16UI
  698. | GL.RGBA16I
  699. | GL.RGBA32I
  700. | GL.RGBA32UI
  701. | GL.DEPTH_COMPONENT16
  702. | GL.DEPTH_COMPONENT24
  703. | GL.DEPTH_COMPONENT32F
  704. | GL.DEPTH_STENCIL
  705. | GL.DEPTH24_STENCIL8
  706. | GL.DEPTH32F_STENCIL8
  707. | GL.STENCIL_INDEX8
  708. type GLType =
  709. | GL.UNSIGNED_BYTE
  710. | GL.UNSIGNED_SHORT_5_6_5
  711. | GL.UNSIGNED_SHORT_4_4_4_4
  712. | GL.UNSIGNED_SHORT_5_5_5_1
  713. | GL.FLOAT
  714. | GL.BYTE
  715. | GL.UNSIGNED_INT_2_10_10_10_REV
  716. | GL.HALF_FLOAT
  717. | GL.SHORT
  718. | GL.UNSIGNED_SHORT
  719. | GL.INT
  720. | GL.UNSIGNED_INT
  721. | GL.UNSIGNED_INT_10F_11F_11F_REV
  722. | GL.UNSIGNED_INT_5_9_9_9_REV
  723. type GLMatrixType =
  724. | GL.FLOAT_MAT2
  725. | GL.FLOAT_MAT2x3
  726. | GL.FLOAT_MAT2x4
  727. | GL.FLOAT_MAT3
  728. | GL.FLOAT_MAT3x2
  729. | GL.FLOAT_MAT3x4
  730. | GL.FLOAT_MAT4
  731. | GL.FLOAT_MAT4x2
  732. | GL.FLOAT_MAT4x3
  733. type GLMagFilter = GL.NEAREST | GL.LINEAR
  734. type GLMinFilter = GLMagFilter | GL.NEAREST_MIPMAP_NEAREST | GL.LINEAR_MIPMAP_NEAREST | GL.NEAREST_MIPMAP_LINEAR | GL.LINEAR_MIPMAP_LINEAR
  735. type GLWrap = GL.CLAMP_TO_EDGE | GL.MIRRORED_REPEAT | GL.REPEAT
  736. type GLCompareMode = GL.NONE | GL.COMPARE_REF_TO_TEXTURE
  737. type GLCompareFunc = GL.LEQUAL | GL.GEQUAL | GL.LESS | GL.GREATER | GL.EQUAL | GL.NOTEQUAL | GL.ALWAYS | GL.NEVER
  738. type GLBlend =
  739. | GL.ZERO
  740. | GL.ONE
  741. | GL.SRC_COLOR
  742. | GL.ONE_MINUS_SRC_COLOR
  743. | GL.DST_COLOR
  744. | GL.ONE_MINUS_DST_COLOR
  745. | GL.SRC_ALPHA
  746. | GL.ONE_MINUS_SRC_ALPHA
  747. | GL.DST_ALPHA
  748. | GL.ONE_MINUS_DST_ALPHA
  749. | GL.CONSTANT_COLOR
  750. | GL.ONE_MINUS_CONSTANT_COLOR
  751. | GL.CONSTANT_ALPHA
  752. | GL.ONE_MINUS_CONSTANT_ALPHA
  753. | GL.SRC_ALPHA_SATURATE
  754. type GLFace = GL.FRONT | GL.BACK | GL.FRONT_AND_BACK
  755. type GLStencilOP = GL.KEEP | GL.ZERO | GL.REPLACE | GL.INCR | GL.INCR_WRAP | GL.DECR | GL.DECR_WRAP | GL.INVERT
  756. type GLShaderType = GL.VERTEX_SHADER | GL.FRAGMENT_SHADER
  757. type GLUsage =
  758. | GL.STREAM_DRAW
  759. | GL.STREAM_READ
  760. | GL.STREAM_COPY
  761. | GL.STATIC_DRAW
  762. | GL.STATIC_READ
  763. | GL.STATIC_COPY
  764. | GL.DYNAMIC_DRAW
  765. | GL.DYNAMIC_READ
  766. | GL.DYNAMIC_COPY
  767. type GLQueryType = GL.ANY_SAMPLES_PASSED | GL.ANY_SAMPLES_PASSED_CONSERVATIVE | GL.TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN
  768. type GLTextTarget =
  769. | GL.TEXTURE_2D
  770. | GL.TEXTURE_CUBE_MAP_POSITIVE_X
  771. | GL.TEXTURE_CUBE_MAP_NEGATIVE_X
  772. | GL.TEXTURE_CUBE_MAP_POSITIVE_Y
  773. | GL.TEXTURE_CUBE_MAP_NEGATIVE_Y
  774. | GL.TEXTURE_CUBE_MAP_POSITIVE_Z
  775. | GL.TEXTURE_CUBE_MAP_NEGATIVE_Z
  776. type GLFrameBufferStatus =
  777. | GL.FRAMEBUFFER_COMPLETE
  778. | GL.FRAMEBUFFER_INCOMPLETE_ATTACHMENT
  779. | GL.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT
  780. | GL.FRAMEBUFFER_INCOMPLETE_DIMENSIONS
  781. | GL.FRAMEBUFFER_UNSUPPORTED
  782. | GL.FRAMEBUFFER_INCOMPLETE_MULTISAMPLE
  783. | GL.RENDERBUFFER_SAMPLES
  784. type GLBinding = GL.ARRAY_BUFFER | GL.ELEMENT_ARRAY_BUFFER
  785. type GLPrimitive = GL.POINTS | GL.LINE_STRIP | GL.LINE_LOOP | GL.LINES | GL.TRIANGLE_STRIP | GL.TRIANGLE_FAN | GL.TRIANGLES
  786.  
  787. /** Blit options. */
  788. interface BlitFramebufferOptions {
  789. /** Source start x coordinate. */
  790. srcStartX?: number
  791. /** Source start y coordinate. */
  792. srcStartY?: number
  793. /** Source end x coordinate. */
  794. srcEndX?: number
  795. /** Source end y coordinate. */
  796. srcEndY?: number
  797. /** Destination start x coordinate. */
  798. dstStartX?: number
  799. /** Destination start y coordinate. */
  800. dstStartY?: number
  801. /** Destination end x coordinate. */
  802. dstEndX?: number
  803. /** Destination end y coordinate. */
  804. dstEndY?: number
  805. /** Sampling filter. */
  806. filter?: GLMagFilter
  807. }
  808.  
  809. interface ReadPixelOptions {
  810. /** Type of data stored in the read framebuffer. */
  811. type?: GLType
  812. /** Read framebuffer data format. */
  813. format?: GLReadPixelFormat
  814. }
  815.  
  816. /** Texture2D options. */
  817. interface Texture2DOptions {
  818. /** Texture data internal format. Must be a sized format.
  819. * @default PicoGL.RGBA8
  820. */
  821. internalFormat?: GLInternalFormat
  822. /** Type of data stored in the texture. Default based on **internalFormat**. */
  823. type?: GLType
  824. /** Whether the y-axis should be flipped when unpacking the texture.
  825. * @default false
  826. */
  827. flipY?: boolean
  828. /** Whether the alpha channel should be pre-multiplied when unpacking the texture.
  829. * @default false
  830. */
  831. premultiplyAlpha?: boolean
  832. /** Minification filter. Defaults to LINEAR_MIPMAP_NEAREST if image data is provided, NEAREST otherwise. */
  833. minFilter?: GLMinFilter
  834. /** Magnification filter. Defaults to LINEAR if image data is provided, NEAREST otherwise. */
  835. magFilter?: GLMagFilter
  836. /** Horizontal wrap mode.
  837. * @default PicoGL.REPEAT
  838. */
  839. wrapS?: GLWrap
  840. /** Vertical wrap mode.
  841. * @default PicoGL.REPEAT
  842. */
  843. wrapT?: GLWrap
  844. /** Comparison mode.
  845. * @default PicoGL.NONE
  846. */
  847. compareMode?: GLCompareMode
  848. /** Comparison function.
  849. * @default PicoGL.LEQUAL
  850. */
  851. compareFunc?: GLCompareFunc
  852. /** Base mipmap level. */
  853. baseLevel?: GLint
  854. /** Maximum mipmap level. */
  855. maxLevel?: GLint
  856. /** Mimimum level of detail. */
  857. minLOD?: GLfloat
  858. /** Maximum level of detail. */
  859. maxLOD?: GLfloat
  860. /** Maximum anisotropy in filtering. */
  861. maxAnisotropy?: GLfloat
  862. }
  863.  
  864. interface Texture3DOptions extends Texture2DOptions {
  865. /** Depth wrap mode.
  866. * @default PicoGL.REPEAT
  867. */
  868. wrapR?: GLWrap
  869. }
  870.  
  871. interface CubemapOptions extends Texture2DOptions {
  872. /** The image data for the negative X direction. Can be any format that would be accepted by texImage2D. */
  873. negX: CanvasImageSource | ArrayBufferView
  874. /** The image data for the positive X direction. Can be any format that would be accepted by texImage2D. */
  875. posX: CanvasImageSource | ArrayBufferView
  876. /** The image data for the negative Y direction. Can be any format that would be accepted by texImage2D. */
  877. negY: CanvasImageSource | ArrayBufferView
  878. /** The image data for the positive Y direction. Can be any format that would be accepted by texImage2D. */
  879. posY: CanvasImageSource | ArrayBufferView
  880. /** The image data for the negative Z direction. Can be any format that would be accepted by texImage2D. */
  881. negZ: CanvasImageSource | ArrayBufferView
  882. /** The image data for the positive Z direction. Can be any format that would be accepted by texImage2D. */
  883. posZ: CanvasImageSource | ArrayBufferView
  884. /** Cubemap side width. Defaults to the width of negX if negX is an image. */
  885. width?: number
  886. /** Cubemap side height. Defaults to the height of negX if negX is an image. */
  887. height?: number
  888. }
  889.  
  890. /**
  891. Primary entry point to PicoGL. An app will store all parts of the WebGL state.
  892. */
  893. export interface App {
  894. /** The canvas on which this app drawing. */
  895. canvas: OffscreenCanvas | HTMLCanvasElement
  896. /** The WebGL context. */
  897. gl: WebGL2RenderingContext
  898. /** The width of the drawing surface. */
  899. width: number
  900. /** The height of the drawing surface. */
  901. height: number
  902. /** Tracked GL state. */
  903. state: {
  904. // todo
  905. }
  906. /** Current clear mask to use with clear(). */
  907. clearBits: GLbitfield
  908.  
  909. /**
  910. * Simulate context loss.
  911. * @method
  912. * @return {App} The App object.
  913. */
  914. loseContext(): this
  915.  
  916. /**
  917. * Simulate context restoration.
  918. * @method
  919. * @return {App} The App object.
  920. */
  921. restoreContext(): this
  922.  
  923. /**
  924. * Set function to handle context restoration after loss.
  925. * @method
  926. * @param {function} fn Context restored handler.
  927. * @return {App} The App object.
  928. */
  929. onContextRestored(fn: () => void): this
  930.  
  931. /**
  932. * Set the color mask to selectively enable or disable particular color channels while rendering.
  933. * @method
  934. * @param {boolean} r Red channel.
  935. * @param {boolean} g Green channel.
  936. * @param {boolean} b Blue channel.
  937. * @param {boolean} a Alpha channel.
  938. * @return {App} The App object.
  939. */
  940. colorMask(r: number, g: number, b: number, a: number): this
  941.  
  942. /**
  943. * Set the clear color.
  944. * @method
  945. * @param {number} r Red channel.
  946. * @param {number} g Green channel.
  947. * @param {number} b Blue channel.
  948. * @param {number} a Alpha channel.
  949. * @return {App} The App object.
  950. */
  951. clearColor(r: number, g: number, b: number, a: number): this
  952.  
  953. /**
  954. * Set the clear mask bits to use when calling clear().
  955. * E.g. app.clearMask(PicoGL.COLOR_BUFFER_BIT).
  956. * @method
  957. * @param {GLbitfield} mask Bit mask of buffers to clear.
  958. * @return {App} The App object.
  959. */
  960. clearMask(mask: GLbitfield): this
  961.  
  962. /**
  963. * Clear the canvas
  964. * @method
  965. * @return {App} The App object.
  966. */
  967. clear(): this
  968.  
  969. /**
  970. * Bind a draw framebuffer to the WebGL context.
  971. * @method
  972. * @param {Framebuffer} framebuffer The Framebuffer object to bind.
  973. * @see Framebuffer
  974. * @return {App} The App object.
  975. */
  976. drawFramebuffer(framebuffer: Framebuffer): this
  977.  
  978. /**
  979. * Bind a read framebuffer to the WebGL context.
  980. * @method
  981. * @param {Framebuffer} framebuffer The Framebuffer object to bind.
  982. * @see Framebuffer
  983. * @return {App} The App object.
  984. */
  985. readFramebuffer(framebuffer: Framebuffer): this
  986.  
  987. /**
  988. * Switch back to the default framebuffer for drawing (i.e. draw to the screen).
  989. * Note that this method resets the viewport to match the default framebuffer.
  990. * @method
  991. * @return {App} The App object.
  992. */
  993. defaultDrawFramebuffer(): this
  994.  
  995. /**
  996. * Switch back to the default framebuffer for reading (i.e. read from the screen).
  997. * @method
  998. * @return {App} The App object.
  999. */
  1000. defaultReadFramebuffer(): this
  1001.  
  1002. /**
  1003. * Copy data from framebuffer attached to READ_FRAMEBUFFER to framebuffer attached to DRAW_FRAMEBUFFER.
  1004. * @method
  1005. * @param {GLbitfield} mask Write mask (e.g. PicoGL.COLOR_BUFFER_BIT).
  1006. * @param {Object} [options] Blit options.
  1007. * @return {App} The App object.
  1008. */
  1009. blitFramebuffer(mask: GLbitfield, options?: BlitFramebufferOptions): this
  1010.  
  1011. /**
  1012. * Set the depth range.
  1013. * @method
  1014. * @param {number} near Minimum depth value.
  1015. * @param {number} far Maximum depth value.
  1016. * @return {App} The App object.
  1017. */
  1018. depthRange(near: number, far: number): this
  1019.  
  1020. /**
  1021. * Enable depth testing.
  1022. * @method
  1023. * @return {App} The App object.
  1024. */
  1025. depthTest(): this
  1026.  
  1027. /**
  1028. * Disable depth testing.
  1029. * @method
  1030. * @return {App} The App object.
  1031. */
  1032. noDepthTest(): this
  1033.  
  1034. /**
  1035. * Enable or disable writing to the depth buffer.
  1036. * @method
  1037. * @param {boolean} mask The depth mask.
  1038. * @return {App} The App object.
  1039. */
  1040. depthMask(mask: boolean): this
  1041.  
  1042. /**
  1043. * Set the depth test function. E.g. app.depthFunc(PicoGL.LEQUAL).
  1044. * @method
  1045. * @param {GLCompareFunc} func The depth testing function to use.
  1046. * @return {App} The App object.
  1047. */
  1048. depthFunc(func: GLCompareFunc): this
  1049.  
  1050. /**
  1051. * Enable blending.
  1052. * @method
  1053. * @return {App} The App object.
  1054. */
  1055. blend(): this
  1056.  
  1057. /**
  1058. * Disable blending
  1059. * @method
  1060. * @return {App} The App object.
  1061. */
  1062. noBlend(): this
  1063.  
  1064. /**
  1065. * Set the blend function. E.g. app.blendFunc(PicoGL.ONE, PicoGL.ONE_MINUS_SRC_ALPHA).
  1066. * @method
  1067. * @param {GLBlend} src The source blending weight.
  1068. * @param {GLBlend} dest The destination blending weight.
  1069. * @return {App} The App object.
  1070. */
  1071. blendFunc(src: GLBlend, dest: GLBlend): this
  1072.  
  1073. /**
  1074. * Set the blend function, with separate weighting for color and alpha channels.
  1075. * E.g. app.blendFuncSeparate(PicoGL.ONE, PicoGL.ONE_MINUS_SRC_ALPHA, PicoGL.ONE, PicoGL.ONE).
  1076. * @method
  1077. * @param {GLBlend} csrc The source blending weight for the RGB channels.
  1078. * @param {GLBlend} cdest The destination blending weight for the RGB channels.
  1079. * @param {GLBlend} asrc The source blending weight for the alpha channel.
  1080. * @param {GLBlend} adest The destination blending weight for the alpha channel.
  1081. * @return {App} The App object.
  1082. */
  1083. blendFuncSeparate(csrc: GLBlend, cdest: GLBlend, asrc: GLBlend, adest: GLBlend): this
  1084.  
  1085. /**
  1086. * Enable stencil testing.
  1087. * NOTE: Only works if { stencil: true } passed as a context attribute when creating the App!
  1088. * @method
  1089. * @return {App} The App object.
  1090. */
  1091. stencilTest(): this
  1092.  
  1093. /**
  1094. * Disable stencil testing.
  1095. * @method
  1096. * @return {App} The App object.
  1097. */
  1098. noStencilTest(): this
  1099.  
  1100. /**
  1101. * Enable scissor testing.
  1102. * @method
  1103. * @return {App} The App object.
  1104. */
  1105. scissorTest(): this
  1106.  
  1107. /**
  1108. * Disable scissor testing.
  1109. * @method
  1110. * @return {App} The App object.
  1111. */
  1112. noScissorTest(): this
  1113.  
  1114. /**
  1115. * Define the scissor box.
  1116. * @method
  1117. * @return {App} The App object.
  1118. */
  1119. scissor(x: number, y: number, width: number, height: number): this
  1120.  
  1121. /**
  1122. * Set the bitmask to use for tested stencil values.
  1123. * E.g. app.stencilMask(0xFF).
  1124. * NOTE: Only works if { stencil: true } passed as a context attribute when creating the App!
  1125. * @method
  1126. * @param {GLuint} mask The mask value.
  1127. * @return {App} The App object.
  1128. */
  1129. stencilMask(mask: GLuint): this
  1130.  
  1131. /**
  1132. * Set the bitmask to use for tested stencil values for a particular face orientation.
  1133. * E.g. app.stencilMaskSeparate(PicoGL.FRONT, 0xFF).
  1134. * NOTE: Only works if { stencil: true } passed as a context attribute when creating the App!
  1135. * @method
  1136. * @param {GLFace} face The face orientation to apply the mask to.
  1137. * @param {GLuint} mask The mask value.
  1138. * @return {App} The App object.
  1139. */
  1140. stencilMaskSeparate(face: GLFace, mask: GLuint): this
  1141.  
  1142. /**
  1143. * Set the stencil function and reference value.
  1144. * E.g. app.stencilFunc(PicoGL.EQUAL, 1, 0xFF).
  1145. * NOTE: Only works if { stencil: true } passed as a context attribute when creating the App!
  1146. * @method
  1147. * @param {GLCompareFunc} func The testing function.
  1148. * @param {number} ref The reference value.
  1149. * @param {GLuint} mask The bitmask to use against tested values before applying
  1150. * the stencil function.
  1151. * @return {App} The App object.
  1152. */
  1153. stencilFunc(func: GLCompareFunc, ref: number, mask: GLuint): this
  1154.  
  1155. /**
  1156. * Set the stencil function and reference value for a particular face orientation.
  1157. * E.g. app.stencilFuncSeparate(PicoGL.FRONT, PicoGL.EQUAL, 1, 0xFF).
  1158. * NOTE: Only works if { stencil: true } passed as a context attribute when creating the App!
  1159. * @method
  1160. * @param {GLFace} face The face orientation to apply the function to.
  1161. * @param {GLCompareFunc} func The testing function.
  1162. * @param {number} ref The reference value.
  1163. * @param {GLuint} mask The bitmask to use against tested values before applying
  1164. * the stencil function.
  1165. * @return {App} The App object.
  1166. */
  1167. stencilFuncSeparate(face: GLFace, func: GLCompareFunc, ref: number, mask: GLuint): this
  1168.  
  1169. /**
  1170. * Set the operations for updating stencil buffer values.
  1171. * E.g. app.stencilOp(PicoGL.KEEP, PicoGL.KEEP, PicoGL.REPLACE).
  1172. * NOTE: Only works if { stencil: true } passed as a context attribute when creating the App!
  1173. * @method
  1174. * @param {GLStencilOP} stencilFail Operation to apply if the stencil test fails.
  1175. * @param {GLStencilOP} depthFail Operation to apply if the depth test fails.
  1176. * @param {GLStencilOP} pass Operation to apply if the both the depth and stencil tests pass.
  1177. * @return {App} The App object.
  1178. */
  1179. stencilOp(stencilFail: GLStencilOP, depthFail: GLStencilOP, pass: GLStencilOP): this
  1180.  
  1181. /**
  1182. * Set the operations for updating stencil buffer values for a particular face orientation.
  1183. * E.g. app.stencilOpSeparate(PicoGL.FRONT, PicoGL.KEEP, PicoGL.KEEP, PicoGL.REPLACE).
  1184. * NOTE: Only works if { stencil: true } passed as a context attribute when creating the App!
  1185. * @method
  1186. * @param {GLFace} face The face orientation to apply the operations to.
  1187. * @param {GLStencilOP} stencilFail Operation to apply if the stencil test fails.
  1188. * @param {GLStencilOP} depthFail Operation to apply if the depth test fails.
  1189. * @param {GLStencilOP} pass Operation to apply if the both the depth and stencil tests pass.
  1190. * @return {App} The App object.
  1191. */
  1192. stencilOpSeparate(face: GLFace, stencilFail: GLStencilOP, depthFail: GLStencilOP, pass: GLStencilOP): this
  1193.  
  1194. /**
  1195. * Enable rasterization step.
  1196. * @method
  1197. * @return {App} The App object.
  1198. */
  1199. rasterize(): this
  1200.  
  1201. /**
  1202. * Disable rasterization step.
  1203. * @method
  1204. * @return {App} The App object.
  1205. */
  1206. noRasterize(): this
  1207.  
  1208. /**
  1209. * Enable backface culling.
  1210. * @method
  1211. * @return {App} The App object.
  1212. */
  1213. cullBackfaces(): this
  1214.  
  1215. /**
  1216. * Disable backface culling.
  1217. * @method
  1218. * @return {App} The App object.
  1219. */
  1220. drawBackfaces(): this
  1221.  
  1222. /**
  1223. * Read a pixel's color value from the currently-bound framebuffer.
  1224. * @method
  1225. * @param {number} x The x coordinate of the pixel.
  1226. * @param {number} y The y coordinate of the pixel.
  1227. * @param {ArrayBufferView} outColor Typed array to store the pixel's color.
  1228. * @param {object} [options] Options.
  1229. * @return {App} The App object.
  1230. */
  1231. readPixel(x: number, y: number, outColor: ArrayBufferView, options?: ReadPixelOptions): this
  1232.  
  1233. /**
  1234. * Set the viewport.
  1235. * @method
  1236. * @param {number} x Left bound of the viewport rectangle.
  1237. * @param {number} y Lower bound of the viewport rectangle.
  1238. * @param {number} width Width of the viewport rectangle.
  1239. * @param {number} height Height of the viewport rectangle.
  1240. * @return {App} The App object.
  1241. */
  1242. viewport(x: number, y: number, width: number, height: number): this
  1243.  
  1244. /**
  1245. * Set the viewport to the full canvas.
  1246. * @method
  1247. * @return {App} The App object.
  1248. */
  1249. defaultViewport(): this
  1250.  
  1251. /**
  1252. * Resize the drawing surface.
  1253. * @method
  1254. * @param {number} width The new canvas width.
  1255. * @param {number} height The new canvas height.
  1256. * @return {App} The App object.
  1257. */
  1258. resize(width: number, height: number): this
  1259.  
  1260. /**
  1261. * Create a program synchronously. It is highly recommended to use <b>createPrograms</b> instead as that method will compile shaders in parallel where possible.
  1262. * @method
  1263. * @param {Shader|string} vertexShader Vertex shader object or source code.
  1264. * @param {Shader|string} fragmentShader Fragment shader object or source code.
  1265. * @param {Array} [xformFeedbackVars] Transform feedback varyings.
  1266. * @return {Program} New Program object.
  1267. */
  1268. createProgram(vsSource: Shader | string, fsSource: Shader | string, xformFeedbackVars?: string[]): Program
  1269.  
  1270. /**
  1271. * Create several programs. Preferred method for program creation as it will compile shaders
  1272. * in parallel where possible.
  1273. * @method
  1274. * @param {...Array} sources Variable number of 2 or 3 element arrays, each containing:
  1275. * <ul>
  1276. * <li> (Shader|string) Vertex shader object or source code.
  1277. * <li> (Shader|string) Fragment shader object or source code.
  1278. * <li> (Array - optional) Array of names of transform feedback varyings.
  1279. * </ul>
  1280. * @return {Promise} Promise that will resolve to an array of Programs when compilation and
  1281. * linking are complete for all programs.
  1282. */
  1283. createPrograms(...sources: Array<[Shader | string, Shader | string] | [Shader | string, Shader | string, string[]]>): Promise<Program[]>
  1284.  
  1285. /**
  1286. * Restore several programs after a context loss. Will do so in parallel where available.
  1287. * @method
  1288. * @param {...Program} sources Variable number of programs to restore.
  1289. * @return {Promise} Promise that will resolve once all programs have been restored.
  1290. */
  1291. restorePrograms(...programs: Program[]): Promise<void>
  1292.  
  1293. /**
  1294. * Create a shader. Creating a shader separately from a program allows for
  1295. * shader reuse.
  1296. * @method
  1297. * @param {GLShaderType} type Shader type.
  1298. * @param {string} source Shader source.
  1299. * @return {Shader} New Shader object.
  1300. */
  1301. createShader(type: GLShaderType, source: string): Shader
  1302.  
  1303. /**
  1304. * Create a vertex array.
  1305. * @method
  1306. * @return {VertexArray} New VertexArray object.
  1307. */
  1308. createVertexArray(): VertexArray
  1309.  
  1310. /**
  1311. * Create a transform feedback object.
  1312. * @method
  1313. * @return {TransformFeedback} New TransformFeedback object.
  1314. */
  1315. createTransformFeedback(): TransformFeedback
  1316.  
  1317. /**
  1318. * Create a vertex buffer.
  1319. * @method
  1320. * @param {GLType} type The data type stored in the vertex buffer.
  1321. * @param {number} itemSize Number of elements per vertex.
  1322. * @param {ArrayBufferView|number} data Buffer data itself or the total number of elements to be allocated.
  1323. * @param {GLUsage} [usage=STATIC_DRAW] Buffer usage.
  1324. * @return {VertexBuffer} New VertexBuffer object.
  1325. */
  1326. createVertexBuffer(type: GLType, itemSize: number, data: ArrayBufferView | number, usage?: GLUsage): VertexBuffer
  1327.  
  1328. /**
  1329. * Create a per-vertex matrix buffer. Matrix buffers ensure that columns
  1330. * are correctly split across attribute locations.
  1331. * @method
  1332. * @param {GLMatrixType} type The data type stored in the matrix buffer. Valid types
  1333. * are FLOAT_MAT4, FLOAT_MAT4x2, FLOAT_MAT4x3, FLOAT_MAT3, FLOAT_MAT3x2,
  1334. * FLOAT_MAT3x4, FLOAT_MAT2, FLOAT_MAT2x3, FLOAT_MAT2x4.
  1335. * @param {ArrayBufferView} data Matrix buffer data.
  1336. * @param {GLUsage} [usage=STATIC_DRAW] Buffer usage.
  1337. * @return {VertexBuffer} New VertexBuffer object.
  1338. */
  1339. createMatrixBuffer(type: GLMatrixType, data: ArrayBufferView, usage?: GLUsage): VertexBuffer
  1340.  
  1341. /**
  1342. * Create an buffer without any structure information. Structure
  1343. * must be fully specified when binding to a VertexArray.
  1344. * @method
  1345. * @param {number} bytesPerVertex Number of bytes per vertex.
  1346. * @param {ArrayBufferView|number} data Buffer data itself or the total
  1347. * number of bytes to be allocated.
  1348. * @param {GLUsage} [usage=STATIC_DRAW] Buffer usage.
  1349. * @return {VertexBuffer} New VertexBuffer object.
  1350. */
  1351. createInterleavedBuffer(bytesPerVertex: number, data: ArrayBufferView | number, usage?: GLUsage): VertexBuffer
  1352.  
  1353. /**
  1354. * Create an index buffer.
  1355. * @method
  1356. * @param {GLType} type The data type stored in the index buffer.
  1357. * @param {number} itemSize Number of elements per primitive.
  1358. * @param {ArrayBufferView} data Index buffer data.
  1359. * @param {GLUsage} [usage=STATIC_DRAW] Buffer usage.
  1360. * @return {VertexBuffer} New VertexBuffer object.
  1361. */
  1362. createIndexBuffer(type: GLType, itemSize: number, data: ArrayBufferView, usage?: GLUsage): VertexBuffer
  1363.  
  1364. /**
  1365. * Create a uniform buffer in std140 layout. NOTE: FLOAT_MAT2, FLOAT_MAT3x2, FLOAT_MAT4x2,
  1366. * FLOAT_MAT3, FLOAT_MAT2x3, FLOAT_MAT4x3 are supported, but must be manually padded to
  1367. * 4-float column alignment by the application!
  1368. * @method
  1369. * @param {Array} layout Array indicating the order and types of items to
  1370. * * be stored in the buffer.
  1371. * @param {GLUsage} [usage=DYNAMIC_DRAW] Buffer usage.
  1372. * @return {UniformBuffer} New UniformBuffer object.
  1373. */
  1374. createUniformBuffer(layout: Array<GLType | GLMatrixType>, usage?: GLUsage): UniformBuffer
  1375.  
  1376. /**
  1377. * Create a 2D texture. Can be used in several ways depending on the type of texture data:
  1378. * @method
  1379. * @param {DOMElement} image Image data. An array can be passed to manually set all levels
  1380. * of the mipmap chain. If a single level is passed and mipmap filtering is being used,
  1381. * generateMipmap() will be called to produce the remaining levels.
  1382. * @param {Texture2DOptions} [options] Texture options.
  1383. * @return {Texture} New Texture object.
  1384. */
  1385. createTexture2D(image: CanvasImageSource, options?: Texture2DOptions): Texture
  1386.  
  1387. /**
  1388. * Create a 2D texture. Can be used in several ways depending on the type of texture data:
  1389. * @method
  1390. * @param {ArrayBufferView|Array} image Image data. An array can be passed to manually set all levels
  1391. * of the mipmap chain. If a single level is passed and mipmap filtering is being used,
  1392. * generateMipmap() will be called to produce the remaining levels.
  1393. * @param {number} width Texture width. Required for array or empty data.
  1394. * @param {number} height Texture height. Required for array or empty data.
  1395. * @param {Texture2DOptions} [options] Texture options.
  1396. * @return {Texture} New Texture object.
  1397. */
  1398. createTexture2D(image: ArrayBufferView | Array<number>, width: number, height: number, options?: Texture2DOptions): Texture
  1399.  
  1400. /**
  1401. * Create a 2D texture. Can be used in several ways depending on the type of texture data:
  1402. * @method
  1403. * @param {number} width Texture width. Required for array or empty data.
  1404. * @param {number} height Texture height. Required for array or empty data.
  1405. * @param {Texture2DOptions} [options] Texture options.
  1406. * @return {Texture} New Texture object.
  1407. */
  1408. createTexture2D(width: number, height: number, options?: Texture2DOptions): Texture
  1409.  
  1410. /**
  1411. * Create a 3D texture.
  1412. * @method
  1413. * @param {ArrayBufferView|Array} image Pixel data. An array can be passed to manually set all levels of the mipmap chain. If a single level is passed and mipmap filtering is being used, generateMipmap() will be called to produce the remaining levels.
  1414. * @param {number} width Texture width. Required for array or empty data.
  1415. * @param {number} height Texture height. Required for array or empty data.
  1416. * @param {number} depth Texture depth.
  1417. * @param {Texture3DOptions} [options] Texture options.
  1418. * @return {Texture} New Texture object.
  1419. */
  1420. createTexture3D(image: ArrayBufferView | Array<number>, width: number, height: number, options?: Texture3DOptions): Texture
  1421.  
  1422. /**
  1423. * Create a cubemap.
  1424. * @method
  1425. * @param {CubemapOptions} options Texture options.
  1426. * @return {Cubemap} New Cubemap object.
  1427. */
  1428. createCubemap(options: CubemapOptions): Cubemap
  1429.  
  1430. /**
  1431. * Create a renderbuffer.
  1432. * @method
  1433. * @param {number} width Renderbuffer width.
  1434. * @param {number} height Renderbuffer height.
  1435. * @param {GLInternalFormat} internalFormat Internal arrangement of the renderbuffer data.
  1436. * @param {number} [samples=0] Number of MSAA samples.
  1437. * @return {Renderbuffer} New Renderbuffer object.
  1438. */
  1439. createRenderbuffer(width: number, height: number, internalFormat: GLInternalFormat, samples: number): Renderbuffer
  1440.  
  1441. /**
  1442. * Create a framebuffer.
  1443. * @method
  1444. * @return {Framebuffer} New Framebuffer object.
  1445. */
  1446. createFramebuffer(): Framebuffer
  1447.  
  1448. /**
  1449. * Create a query.
  1450. * @method
  1451. * @param {GLQueryType} target Information to query.
  1452. * @return {Query} New Query object.
  1453. */
  1454. createQuery(target: GLQueryType): Query
  1455.  
  1456. /**
  1457. * Create a timer.
  1458. * @method
  1459. * @return {Timer} New Timer object.
  1460. */
  1461. createTimer(): Timer
  1462.  
  1463. /**
  1464. * Create a DrawCall. A DrawCall manages the state associated with
  1465. * a WebGL draw call including a program and associated vertex data, textures,
  1466. * uniforms and uniform blocks.
  1467. * @method
  1468. * @param {Program} program The program to use for this DrawCall.
  1469. * @param {VertexArray} [vertexArray=null] Vertex data to use for drawing.
  1470. * @return {DrawCall} New DrawCall object.
  1471. */
  1472. createDrawCall(program: Program, vertexArray: VertexArray): DrawCall
  1473.  
  1474. // Clear the canvas
  1475. clear(): this
  1476. }
  1477.  
  1478. /** Offscreen drawing surface. */
  1479. export interface Framebuffer {
  1480. /** The WebGL context. */
  1481. gl: WebGL2RenderingContext
  1482. /** Handle to the framebuffer. */
  1483. framebuffer: WebGLFramebuffer
  1484. /** Framebuffer width. */
  1485. width: number
  1486. /** Framebuffer height. */
  1487. height: number
  1488. /** Array of color attachments. */
  1489. colorAttachments: Array<Texture | Cubemap | Renderbuffer>
  1490. /** Depth attachment. */
  1491. depthAttachment: Texture | Cubemap | Renderbuffer
  1492.  
  1493. appState: {
  1494. // TODO
  1495. }
  1496.  
  1497. /**
  1498. * Restore framebuffer after context loss.
  1499. * @method
  1500. * @return {Framebuffer} The Framebuffer object.
  1501. */
  1502. restore(): this
  1503.  
  1504. /**
  1505. * Attach a color target to this framebuffer.
  1506. * @method
  1507. * @param {number} index Color attachment index.
  1508. * @param {Texture|Cubemap|Renderbuffer} attachment The texture, cubemap or renderbuffer to attach.
  1509. * @param {GLTextTarget} [target] The texture target or layer to attach. If the texture is 3D or a texture array,
  1510. * defaults to 0, otherwise to TEXTURE_2D. Ignored for renderbuffers.
  1511. * @return {Framebuffer} The Framebuffer object.
  1512. */
  1513. colorTarget(index: number, attachment: Texture | Cubemap | Renderbuffer, target?: GLTextTarget): this
  1514.  
  1515. /**
  1516. * Attach a depth target to this framebuffer.
  1517. * @method
  1518. * @param {Texture|Cubemap|Renderbuffer} texture The texture, cubemap or renderbuffer to attach.
  1519. * @param {GLTextTarget} [target] The texture target or layer to attach. If the texture is 3D or a texture array or renderbuffer,
  1520. * defaults to 0, otherwise to TEXTURE_2D. Ignored for renderbuffers.
  1521. * @return {Framebuffer} The Framebuffer object.
  1522. */
  1523. depthTarget(attachment: Texture | Cubemap | Renderbuffer, target?: GLTextTarget): this
  1524.  
  1525. /**
  1526. * Resize all attachments.
  1527. * @method
  1528. * @param {number} [width=app.width] New width of the framebuffer.
  1529. * @param {number} [height=app.height] New height of the framebuffer.
  1530. * @return {Framebuffer} The Framebuffer object.
  1531. */
  1532. resize(width: number, height: number): this
  1533.  
  1534. /**
  1535. * Delete this framebuffer.
  1536. * @method
  1537. * @return {Framebuffer} The Framebuffer object.
  1538. */
  1539. delete(): this
  1540.  
  1541. /**
  1542. * Get the current status of this framebuffer.
  1543. * @method
  1544. * @return {GLFrameBufferStatus} The current status of this framebuffer.
  1545. */
  1546. getStatus(): GLFrameBufferStatus
  1547. }
  1548.  
  1549. /** WebGL shader. */
  1550. export interface Shader {
  1551. gl: WebGL2RenderingContext
  1552. shader: WebGLShader
  1553.  
  1554. /**
  1555. * Restore shader after context loss.
  1556. * @method
  1557. * @return {Shader} The Shader object.
  1558. */
  1559. restore(): this
  1560.  
  1561. /**
  1562. * Get the shader source translated for the platform's API.
  1563. * @method
  1564. * @return {String} The translated shader source.
  1565. */
  1566. translatedSource(): string
  1567.  
  1568. /**
  1569. * Delete this shader.
  1570. * @method
  1571. * @return {Shader} The Shader object.
  1572. */
  1573. delete(): this
  1574. }
  1575.  
  1576. /** WebGL program consisting of compiled and linked vertex and fragment shaders. */
  1577. export interface Program {
  1578. gl: WebGL2RenderingContext
  1579. program: WebGLProgram
  1580. transformFeedback: boolean
  1581. uniforms: object
  1582.  
  1583. /**
  1584. * Restore program after context loss. Note that this
  1585. * will stall for completion. <b>App.restorePrograms</b>
  1586. * is the preferred method for program restoration as
  1587. * it will parallelize compilation where available.
  1588. * @method
  1589. * @return {Program} The Program object.
  1590. */
  1591. restore(): this
  1592.  
  1593. /**
  1594. * Get the vertex shader source translated for the platform's API.
  1595. * @method
  1596. * @return {String} The translated vertex shader source.
  1597. */
  1598. translatedVertexSource(): string
  1599.  
  1600. /**
  1601. * Get the fragment shader source translated for the platform's API.
  1602. * @method
  1603. * @return {String} The translated fragment shader source.
  1604. */
  1605. translatedFragmentSource(): string
  1606.  
  1607. /**
  1608. * Delete this program.
  1609. * @method
  1610. * @return {Program} The Program object.
  1611. */
  1612. delete(): Program
  1613. }
  1614.  
  1615. interface VertexArrayBufferOptions {
  1616. /** Type of data stored in the buffer. */
  1617. type?: GLType
  1618. /** Number of components per vertex. */
  1619. size?: 1 | 2 | 3 | 4
  1620. /** Number of bytes between the start of data for each vertex. */
  1621. stride?: GLuint
  1622. /** Number of bytes before the start of data for the first vertex. */
  1623. offset?: GLuint
  1624. /** Data is integer data that should be normalized to a float. */
  1625. normalized?: boolean
  1626. /** Pass data as integers. */
  1627. integer?: boolean
  1628. }
  1629.  
  1630. /** Organizes vertex buffer and attribute state. */
  1631. export interface VertexArray {
  1632. /** The WebGL context. */
  1633. gl: WebGL2RenderingContext
  1634. /** Vertex array object. */
  1635. vertexArray: WebGLVertexArrayObject
  1636. /** Number of elements in the vertex array. */
  1637. numElements: number
  1638. /** Whether this vertex array is set up for indexed drawing. */
  1639. indexed: boolean
  1640. /** Data type of the indices. */
  1641. indexType: GLType
  1642. /** Number of instances to draw with this vertex array. */
  1643. numInstances: number
  1644.  
  1645. /**
  1646. * Restore vertex array after context loss.
  1647. * @method
  1648. * @return {VertexArray} The VertexArray object.
  1649. */
  1650. restore(): this
  1651.  
  1652. /**
  1653. * Bind an per-vertex attribute buffer to this vertex array.
  1654. * @method
  1655. * @param {number} attributeIndex The attribute location to bind to.
  1656. * @param {VertexBuffer} vertexBuffer The VertexBuffer to bind.
  1657. * @param {VertexArrayBufferOptions} [options] Attribute pointer options. These will override those provided in the VertexBuffer.
  1658. * @return {VertexArray} The VertexArray object.
  1659. */
  1660. vertexAttributeBuffer(attributeIndex: number, vertexBuffer: VertexBuffer, options?: VertexArrayBufferOptions): this
  1661.  
  1662. /**
  1663. * Bind an per-instance attribute buffer to this vertex array.
  1664. * @method
  1665. * @param {number} attributeIndex The attribute location to bind to.
  1666. * @param {VertexBuffer} vertexBuffer The VertexBuffer to bind.
  1667. * @param {VertexArrayBufferOptions} [options] Attribute pointer options. These will override those provided in the VertexBuffer.
  1668. * @return {VertexArray} The VertexArray object.
  1669. */
  1670. instanceAttributeBuffer(attributeIndex: number, vertexBuffer: VertexBuffer, options?: VertexArrayBufferOptions): this
  1671.  
  1672. /**
  1673. * Bind an index buffer to this vertex array.
  1674. * @method
  1675. * @param {VertexBuffer} vertexBuffer The VertexBuffer to bind.
  1676. * @return {VertexArray} The VertexArray object.
  1677. */
  1678. indexBuffer(vertexBuffer: VertexBuffer): this
  1679.  
  1680. /**
  1681. * Delete this vertex array.
  1682. * @method
  1683. * @return {VertexArray} The VertexArray object.
  1684. */
  1685. delete(): this
  1686. }
  1687.  
  1688. /** Tranform feedback object. */
  1689. export interface TransformFeedback {
  1690. /** The WebGL context. */
  1691. gl: WebGL2RenderingContext
  1692. /** Transform feedback object. */
  1693. transformFeedback: WebGLTransformFeedback
  1694.  
  1695. /**
  1696. * Restore transform feedback after context loss.
  1697. * @method
  1698. * @return {TransformFeedback} The TransformFeedback object.
  1699. */
  1700. restore(): this
  1701.  
  1702. /**
  1703. * Bind a feedback buffer to capture transform output.
  1704. * @method
  1705. * @param {number} index Index of transform feedback varying to capture.
  1706. * @param {VertexBuffer} buffer Buffer to record output into.
  1707. * @return {TransformFeedback} The TransformFeedback object.
  1708. */
  1709. feedbackBuffer(index: number, buffer: VertexBuffer): this
  1710.  
  1711. /**
  1712. * Delete this transform feedback.
  1713. * @method
  1714. * @return {TransformFeedback} The TransformFeedback object.
  1715. */
  1716. delete(): this
  1717. }
  1718.  
  1719. /** Storage for vertex data. */
  1720. export interface VertexBuffer {
  1721. /** The WebGL context. */
  1722. gl: WebGL2RenderingContext
  1723. /** Allocated buffer storage. */
  1724. buffer: WebGLBuffer
  1725. /** The type of data stored in the buffer. */
  1726. type: GLType
  1727. /** Number of array elements per vertex. */
  1728. itemSize: number
  1729. /** Number of vertices represented. */
  1730. numItems: number
  1731. /** The usage pattern of the buffer. */
  1732. usage: GLUsage
  1733. /** Whether this is an index array. */
  1734. indexArray: boolean
  1735. /** GL binding point (ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER). */
  1736. binding: GLBinding
  1737.  
  1738. /**
  1739. * Restore vertex buffer after context loss.
  1740. * @method
  1741. * @param {ArrayBufferView|number} data Buffer data itself or the total number of elements to be allocated.
  1742. * @return {VertexBuffer} The VertexBuffer object.
  1743. */
  1744. restore(data: ArrayBufferView | number): this
  1745.  
  1746. /**
  1747. * Update data in this buffer. NOTE: the data must fit the originally-allocated buffer!
  1748. * @method
  1749. * @param {ArrayBufferView} data Data to store in the buffer.
  1750. * @return {VertexBuffer} The VertexBuffer object.
  1751. */
  1752. data(data: ArrayBufferView): this
  1753.  
  1754. /**
  1755. * Delete this array buffer.
  1756. * @method
  1757. * @return {VertexBuffer} The VertexBuffer object.
  1758. */
  1759. delete(): this
  1760. }
  1761.  
  1762. /** General-purpose texture. */
  1763. export interface Texture {
  1764. /** The WebGL context. */
  1765. gl: WebGL2RenderingContext
  1766. /** Handle to the texture. */
  1767. texture: WebGLTexture
  1768. /** Texture width. */
  1769. width: number
  1770. /** Texture height. */
  1771. height: number
  1772. /** Texture depth. */
  1773. depth: number
  1774. /** Binding point for the texture. */
  1775. binding: GLBinding
  1776. /** Type of data stored in the texture. */
  1777. type: GLType
  1778. /** Layout of texture data. */
  1779. format: GLInternalFormat
  1780. /** Internal arrangement of the texture data. */
  1781. internalFormat: GLInternalFormat
  1782. /** The current texture unit this texture is bound to. */
  1783. currentUnit: number
  1784. /** Whether this texture contains 3D data. */
  1785. is3D: boolean
  1786. /** Whether the y-axis is flipped for this texture. */
  1787. flipY: boolean
  1788. /** Whether alpha should be pre-multiplied when loading this texture. */
  1789. premultiplyAlpha: boolean
  1790. /** Whether this texture is using mipmap filtering (and thus should have a complete mipmap chain). */
  1791. mipmaps: boolean
  1792.  
  1793. /**
  1794. * Restore texture after context loss.
  1795. * @method
  1796. * @param {DOMElement|ArrayBufferView|Array} [image] Image data. An array can be passed to manually set all levels of the mipmap chain. If a single level is passed and mipmap filtering is being used, generateMipmap() will be called to produce the remaining levels.
  1797. * @return {Texture} The Texture object.
  1798. */
  1799. restore(image: CanvasImageSource | ArrayBufferView): this
  1800.  
  1801. /**
  1802. * Re-allocate texture storage.
  1803. * @method
  1804. * @param {number} width Image width.
  1805. * @param {number} height Image height.
  1806. * @param {number} [depth] Image depth or number of images. Required when passing 3D or texture array data.
  1807. * @return {Texture} The Texture object.
  1808. */
  1809. resize(width: number, height: number, depth?: number): this
  1810.  
  1811. /**
  1812. * Set the image data for the texture. An array can be passed to manually set all levels of the mipmap chain. If a single level is passed and mipmap filtering is being used, generateMipmap() will be called to produce the remaining levels.
  1813. * NOTE: the data must fit the currently-allocated storage!
  1814. * @method
  1815. * @param {ImageElement|ArrayBufferView|Array} data Image data. If an array is passed, it will be
  1816. * used to set mip map levels.
  1817. * @return {Texture} The Texture object.
  1818. */
  1819. data(image: CanvasImageSource | ArrayBufferView): this
  1820.  
  1821. /**
  1822. * Delete this texture.
  1823. * @method
  1824. * @return {Texture} The Texture object.
  1825. */
  1826. delete(): this
  1827. }
  1828.  
  1829. /** Cubemap for environment mapping. */
  1830. export interface Cubemap {
  1831. /** The WebGL context. */
  1832. gl: WebGL2RenderingContext
  1833. /** Handle to the texture. */
  1834. texture: WebGLTexture
  1835. /** Type of data stored in the texture. */
  1836. type: GLType
  1837. /** Layout of texture data. */
  1838. format: GLInternalFormat
  1839. /** Internal arrangement of the texture data. */
  1840. internalFormat: GLInternalFormat
  1841. /** The current texture unit this texture is bound to. */
  1842. currentUnit: number
  1843. /** Whether the y-axis is flipped for this texture. */
  1844. flipY: boolean
  1845. /** Whether alpha should be pre-multiplied when loading this texture. */
  1846. premultiplyAlpha: boolean
  1847.  
  1848. /**
  1849. * Restore cubemap after context loss.
  1850. * @method
  1851. * @param {CubemapOptions} [options] Texture options.
  1852. * @return {Cubemap} The Cubemap object.
  1853. */
  1854. restore(options?: CubemapOptions): this
  1855.  
  1856. /**
  1857. * Delete this cubemap.
  1858. * @method
  1859. * @return {Cubemap} The Cubemap object.
  1860. */
  1861. delete(): this
  1862. }
  1863.  
  1864. /** Offscreen drawing attachment. */
  1865. export interface Renderbuffer {
  1866. /** The WebGL context. */
  1867. gl: WebGL2RenderingContext
  1868. /** Handle to the renderbuffer. */
  1869. renderbuffer: WebGLRenderbuffer
  1870. /** Texture width. */
  1871. width: number
  1872. /** Texture height. */
  1873. height: number
  1874. /** Internal arrangement of the texture data. */
  1875. internalFormat: GLInternalFormat
  1876. /** Number of MSAA samples. */
  1877. samples: number
  1878.  
  1879. /**
  1880. * Restore renderbuffer after context loss.
  1881. * @method
  1882. * @return {Renderbuffer} The Renderbuffer object.
  1883. */
  1884. restore(): this
  1885.  
  1886. /**
  1887. * Resize the renderbuffer.
  1888. * @method
  1889. * @param {number} width New width of the renderbuffer.
  1890. * @param {number} height New height of the renderbuffer.
  1891. * @return {Renderbuffer} The Renderbuffer object.
  1892. */
  1893. resize(width: number, height: number): this
  1894.  
  1895. /**
  1896. * Delete this renderbuffer.
  1897. * @method
  1898. * @return {Renderbuffer} The Renderbuffer object.
  1899. */
  1900. delete(): this
  1901. }
  1902.  
  1903. /** Generic query object. */
  1904. export interface Query {
  1905. /** The WebGL context. */
  1906. gl: WebGL2RenderingContext
  1907. /** Query object. */
  1908. query: WebGLQuery
  1909. /** The type of information being queried. */
  1910. target: GLQueryType
  1911. /** Whether or not a query is currently in progress. */
  1912. active: boolean
  1913. /** The result of the query (only available after a call to ready() returns true). */
  1914. result: any
  1915.  
  1916. /**
  1917. * Restore query after context loss.
  1918. * @method
  1919. * @return {Query} The Query object.
  1920. */
  1921. restore(): this
  1922.  
  1923. /**
  1924. * Begin a query.
  1925. * @method
  1926. * @return {Query} The Query object.
  1927. */
  1928. begin(): this
  1929.  
  1930. /**
  1931. * End a query.
  1932. * @method
  1933. * @return {Query} The Query object.
  1934. */
  1935. end(): this
  1936.  
  1937. /**
  1938. * Check if query result is available.
  1939. * @method
  1940. * @return {boolean} If results are available.
  1941. */
  1942. ready(): boolean
  1943.  
  1944. /**
  1945. * Delete this query.
  1946. * @method
  1947. * @return {Query} The Query object.
  1948. */
  1949. delete(): this
  1950. }
  1951.  
  1952. export interface Timer {
  1953. /** The WebGL context. */
  1954. gl: WebGL2RenderingContext
  1955. /** Timer for CPU. Will be window.performance, if available, or window.Date. */
  1956. cpuTimer: Object
  1957. /** Timer query object for GPU (if gpu timing is supported). */
  1958. gpuTimerQuery: WebGLQuery
  1959. /** Whether a gpu timer query is currently in progress. */
  1960. gpuTimerQueryInProgress: boolean
  1961. /** When the last CPU timing started. */
  1962. cpuStartTime: number
  1963. /** Time spent on CPU during last timing. Only valid if ready() returns true. */
  1964. cpuTime: number
  1965. /** Time spent on GPU during last timing. Only valid if ready() returns true. Will remain 0 if extension EXT_disjoint_timer_query_webgl2 is unavailable. */
  1966. gpuTime: number
  1967.  
  1968. /**
  1969. * Restore timer after context loss.
  1970. * @method
  1971. * @return {Timer} The Timer object.
  1972. */
  1973. restore(): this
  1974.  
  1975. /**
  1976. * Start timing.
  1977. * @method
  1978. * @return {Timer} The Timer object.
  1979. */
  1980. start(): this
  1981.  
  1982. /**
  1983. * Stop timing.
  1984. * @method
  1985. * @return {Timer} The Timer object.
  1986. */
  1987. end(): this
  1988.  
  1989. /**
  1990. * Check if timing results are available. If
  1991. * this method returns true, the cpuTime and
  1992. * gpuTime properties will be set to valid
  1993. * values.
  1994. * @method
  1995. * @return {boolean} If results are available.
  1996. */
  1997. ready(): boolean
  1998.  
  1999. /**
  2000. * Delete this timer.
  2001. * @method
  2002. * @return {Timer} The Timer object.
  2003. */
  2004. delete(): this
  2005. }
  2006.  
  2007. /** A DrawCall represents the program and values of associated attributes, uniforms and textures for a single draw call. */
  2008. export interface DrawCall {
  2009. /** The WebGL context. */
  2010. gl: WebGL2RenderingContext
  2011. /** The program to use for this draw call. */
  2012. currentProgram: Program
  2013. /** Vertex array to use for this draw call. */
  2014. currentVertexArray: VertexArray
  2015. /** Transform feedback to use for this draw call. */
  2016. currentTransformFeedback: TransformFeedback
  2017. /** Ordered list of active uniform buffers. */
  2018. uniformBuffers: UniformBuffer[]
  2019. /** Ordered list of uniform block names. */
  2020. uniformBlockNames: string[]
  2021. /** Number of active uniform blocks for this draw call. */
  2022. uniformBlockCount: number
  2023. /** Map of uniform names to indices in the uniform arrays. */
  2024. uniformIndices: { [key: string]: number }
  2025. /** Ordered list of uniform names. */
  2026. uniformNames: string[]
  2027. /** Ordered list of uniform values. */
  2028. uniformValue: any[]
  2029. /** The number of active uniforms for this draw call. */
  2030. uniformCount: number
  2031. /** Array of active textures. */
  2032. textures: Array<Texture | Cubemap | Renderbuffer>
  2033. /** The number of active textures for this draw call. */
  2034. textureCount: number
  2035. /** The number of element to draw. */
  2036. numElements: number
  2037. /** The number of instances to draw. */
  2038. numInstances: number
  2039.  
  2040. /**
  2041. * Set the current draw primitive for this draw call.
  2042. * @method
  2043. * @param {GLPrimitive} primitive Primitive to draw.
  2044. * @return {DrawCall} The DrawCall object.
  2045. */
  2046. primitive(primitive: GLPrimitive): this
  2047.  
  2048. /**
  2049. * Set the current TransformFeedback object for draw.
  2050. * @method
  2051. * @param {TransformFeedback} transformFeedback Transform Feedback to set.
  2052. * @return {DrawCall} The DrawCall object.
  2053. */
  2054. transformFeedback(transformFeedback: TransformFeedback): this
  2055.  
  2056. /**
  2057. * Set the value for a uniform. Array uniforms are supported by
  2058. * using appending "[0]" to the array name and passing a flat array
  2059. * with all required values.
  2060. * @method
  2061. * @param {string} name Uniform name.
  2062. * @param {any} value Uniform value.
  2063. * @return {DrawCall} The DrawCall object.
  2064. */
  2065. uniform(name: string, value: any): this
  2066.  
  2067. /**
  2068. * Set texture to bind to a sampler uniform.
  2069. * @method
  2070. * @param {string} name Sampler uniform name.
  2071. * @param {Texture|Cubemap|Renderbuffer} texture Texture or Cubemap to bind.
  2072. * @return {DrawCall} The DrawCall object.
  2073. */
  2074. texture(name: string, texture: Texture | Cubemap | Renderbuffer): this
  2075.  
  2076. /**
  2077. * Set uniform buffer to bind to a uniform block.
  2078. * @method
  2079. * @param {string} name Uniform block name.
  2080. * @param {UniformBuffer} buffer Uniform buffer to bind.
  2081. * @return {DrawCall} The DrawCall object.
  2082. */
  2083. uniformBlock(name: string, buffer: UniformBuffer): this
  2084.  
  2085. /**
  2086. * Ranges in the vertex array to draw. Multiple arguments can be provided to set up
  2087. * a multi-draw.
  2088. * @method
  2089. * @param {...Array} counts Variable number of 2 or 3 element arrays, each containing:
  2090. * <ul>
  2091. * <li> (Number) Number of elements to skip at the start of the array.
  2092. * <li> (Number) Number of elements to draw.
  2093. * <li> (Number - optional) Number of instances to draw of the given range.
  2094. * </ul>
  2095. * @return {DrawCall} The DrawCall object.
  2096. */
  2097. drawRanges(...counts: Array<[number, number] | [number, number, number]>): this
  2098.  
  2099. /**
  2100. * Draw based on current state.
  2101. * @method
  2102. * @return {DrawCall} The DrawCall object.
  2103. */
  2104. draw(): this
  2105. }
  2106.  
  2107. /** Storage for uniform data. Data is stored in std140 layout. */
  2108. export interface UniformBuffer {
  2109. /** The WebGL context. */
  2110. gl: WebGL2RenderingContext
  2111. /** Allocated buffer storage. */
  2112. buffer: WebGLBuffer
  2113. /** Buffer data. */
  2114. data: Float32Array
  2115. /** Map of base data types to matching ArrayBufferViews of the buffer data. */
  2116. dataViews: object
  2117. /** Offsets into the array for each item in the buffer. */
  2118. offsets: number[]
  2119. /** Size of the item at the given offset. */
  2120. sizes: number[]
  2121. /** The base type of the item at the given offset (FLOAT, INT or UNSIGNED_INT). */
  2122. types: GLType[]
  2123. /** The size of the buffer (in 4-byte items). */
  2124. size: number
  2125. /** Usage pattern of the buffer. */
  2126. usage: GLUsage
  2127.  
  2128. /**
  2129. * Restore uniform buffer after context loss.
  2130. * @method
  2131. * @return {UniformBuffer} The UniformBuffer object.
  2132. */
  2133. restore(): this
  2134.  
  2135. /**
  2136. * Update data for a given item in the buffer. NOTE: Data is not
  2137. * sent the the GPU until the update() method is called!
  2138. * @method
  2139. * @param {number} index Index in the layout of item to set.
  2140. * @param {ArrayBufferView} value Value to store at the layout location.
  2141. * @return {UniformBuffer} The UniformBuffer object.
  2142. */
  2143. set(index: number, value: ArrayBufferView): this
  2144.  
  2145. /**
  2146. * Send stored buffer data to the GPU.
  2147. * @method
  2148. * @return {UniformBuffer} The UniformBuffer object.
  2149. */
  2150. update(): this
  2151.  
  2152. /**
  2153. * Delete this uniform buffer.
  2154. * @method
  2155. * @return {UniformBuffer} The UniformBuffer object.
  2156. */
  2157. delete(): this
  2158. }
  2159. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement