WebGLRenderer.tests.js 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469
  1. /* global QUnit */
  2. import { WebGLRenderer } from '../../../../src/renderers/WebGLRenderer';
  3. var customWebGLContext = function () {
  4. this.DEPTH_BUFFER_BIT = 256;
  5. this.STENCIL_BUFFER_BIT = 1024;
  6. this.COLOR_BUFFER_BIT = 16384;
  7. this.POINTS = 0;
  8. this.LINES = 1;
  9. this.LINE_LOOP = 2;
  10. this.LINE_STRIP = 3;
  11. this.TRIANGLES = 4;
  12. this.TRIANGLE_STRIP = 5;
  13. this.TRIANGLE_FAN = 6;
  14. this.ZERO = 0;
  15. this.ONE = 1;
  16. this.SRC_COLOR = 768;
  17. this.ONE_MINUS_SRC_COLOR = 769;
  18. this.SRC_ALPHA = 770;
  19. this.ONE_MINUS_SRC_ALPHA = 771;
  20. this.DST_ALPHA = 772;
  21. this.ONE_MINUS_DST_ALPHA = 773;
  22. this.DST_COLOR = 774;
  23. this.ONE_MINUS_DST_COLOR = 775;
  24. this.SRC_ALPHA_SATURATE = 776;
  25. this.FUNC_ADD = 32774;
  26. this.BLEND_EQUATION = 32777;
  27. this.BLEND_EQUATION_RGB = 32777;
  28. this.BLEND_EQUATION_ALPHA = 34877;
  29. this.FUNC_SUBTRACT = 32778;
  30. this.FUNC_REVERSE_SUBTRACT = 32779;
  31. this.BLEND_DST_RGB = 32968;
  32. this.BLEND_SRC_RGB = 32969;
  33. this.BLEND_DST_ALPHA = 32970;
  34. this.BLEND_SRC_ALPHA = 32971;
  35. this.CONSTANT_COLOR = 32769;
  36. this.ONE_MINUS_CONSTANT_COLOR = 32770;
  37. this.CONSTANT_ALPHA = 32771;
  38. this.ONE_MINUS_CONSTANT_ALPHA = 32772;
  39. this.BLEND_COLOR = 32773;
  40. this.ARRAY_BUFFER = 34962;
  41. this.ELEMENT_ARRAY_BUFFER = 34963;
  42. this.ARRAY_BUFFER_BINDING = 34964;
  43. this.ELEMENT_ARRAY_BUFFER_BINDING = 34965;
  44. this.STREAM_DRAW = 35040;
  45. this.STATIC_DRAW = 35044;
  46. this.DYNAMIC_DRAW = 35048;
  47. this.BUFFER_SIZE = 34660;
  48. this.BUFFER_USAGE = 34661;
  49. this.CURRENT_VERTEX_ATTRIB = 34342;
  50. this.FRONT = 1028;
  51. this.BACK = 1029;
  52. this.FRONT_AND_BACK = 1032;
  53. this.TEXTURE_2D = 3553;
  54. this.CULL_FACE = 2884;
  55. this.BLEND = 3042;
  56. this.DITHER = 3024;
  57. this.STENCIL_TEST = 2960;
  58. this.DEPTH_TEST = 2929;
  59. this.SCISSOR_TEST = 3089;
  60. this.POLYGON_OFFSET_FILL = 32823;
  61. this.SAMPLE_ALPHA_TO_COVERAGE = 32926;
  62. this.SAMPLE_COVERAGE = 32928;
  63. this.NO_ERROR = 0;
  64. this.INVALID_ENUM = 1280;
  65. this.INVALID_VALUE = 1281;
  66. this.INVALID_OPERATION = 1282;
  67. this.OUT_OF_MEMORY = 1285;
  68. this.CW = 2304;
  69. this.CCW = 2305;
  70. this.LINE_WIDTH = 2849;
  71. this.ALIASED_POINT_SIZE_RANGE = 33901;
  72. this.ALIASED_LINE_WIDTH_RANGE = 33902;
  73. this.CULL_FACE_MODE = 2885;
  74. this.FRONT_FACE = 2886;
  75. this.DEPTH_RANGE = 2928;
  76. this.DEPTH_WRITEMASK = 2930;
  77. this.DEPTH_CLEAR_VALUE = 2931;
  78. this.DEPTH_FUNC = 2932;
  79. this.STENCIL_CLEAR_VALUE = 2961;
  80. this.STENCIL_FUNC = 2962;
  81. this.STENCIL_FAIL = 2964;
  82. this.STENCIL_PASS_DEPTH_FAIL = 2965;
  83. this.STENCIL_PASS_DEPTH_PASS = 2966;
  84. this.STENCIL_REF = 2967;
  85. this.STENCIL_VALUE_MASK = 2963;
  86. this.STENCIL_WRITEMASK = 2968;
  87. this.STENCIL_BACK_FUNC = 34816;
  88. this.STENCIL_BACK_FAIL = 34817;
  89. this.STENCIL_BACK_PASS_DEPTH_FAIL = 34818;
  90. this.STENCIL_BACK_PASS_DEPTH_PASS = 34819;
  91. this.STENCIL_BACK_REF = 36003;
  92. this.STENCIL_BACK_VALUE_MASK = 36004;
  93. this.STENCIL_BACK_WRITEMASK = 36005;
  94. this.VIEWPORT = 2978;
  95. this.SCISSOR_BOX = 3088;
  96. this.COLOR_CLEAR_VALUE = 3106;
  97. this.COLOR_WRITEMASK = 3107;
  98. this.UNPACK_ALIGNMENT = 3317;
  99. this.PACK_ALIGNMENT = 3333;
  100. this.MAX_TEXTURE_SIZE = 3379;
  101. this.MAX_VIEWPORT_DIMS = 3386;
  102. this.SUBPIXEL_BITS = 3408;
  103. this.RED_BITS = 3410;
  104. this.GREEN_BITS = 3411;
  105. this.BLUE_BITS = 3412;
  106. this.ALPHA_BITS = 3413;
  107. this.DEPTH_BITS = 3414;
  108. this.STENCIL_BITS = 3415;
  109. this.POLYGON_OFFSET_UNITS = 10752;
  110. this.POLYGON_OFFSET_FACTOR = 32824;
  111. this.TEXTURE_BINDING_2D = 32873;
  112. this.SAMPLE_BUFFERS = 32936;
  113. this.SAMPLES = 32937;
  114. this.SAMPLE_COVERAGE_VALUE = 32938;
  115. this.SAMPLE_COVERAGE_INVERT = 32939;
  116. this.COMPRESSED_TEXTURE_FORMATS = 34467;
  117. this.DONT_CARE = 4352;
  118. this.FASTEST = 4353;
  119. this.NICEST = 4354;
  120. this.GENERATE_MIPMAP_HINT = 33170;
  121. this.BYTE = 5120;
  122. this.UNSIGNED_BYTE = 5121;
  123. this.SHORT = 5122;
  124. this.UNSIGNED_SHORT = 5123;
  125. this.INT = 5124;
  126. this.UNSIGNED_INT = 5125;
  127. this.FLOAT = 5126;
  128. this.DEPTH_COMPONENT = 6402;
  129. this.ALPHA = 6406;
  130. this.RGB = 6407;
  131. this.RGBA = 6408;
  132. this.LUMINANCE = 6409;
  133. this.LUMINANCE_ALPHA = 6410;
  134. this.UNSIGNED_SHORT_4_4_4_4 = 32819;
  135. this.UNSIGNED_SHORT_5_5_5_1 = 32820;
  136. this.UNSIGNED_SHORT_5_6_5 = 33635;
  137. this.FRAGMENT_SHADER = 35632;
  138. this.VERTEX_SHADER = 35633;
  139. this.MAX_VERTEX_ATTRIBS = 34921;
  140. this.MAX_VERTEX_UNIFORM_VECTORS = 36347;
  141. this.MAX_VARYING_VECTORS = 36348;
  142. this.MAX_COMBINED_TEXTURE_IMAGE_UNITS = 35661;
  143. this.MAX_VERTEX_TEXTURE_IMAGE_UNITS = 35660;
  144. this.MAX_TEXTURE_IMAGE_UNITS = 34930;
  145. this.MAX_FRAGMENT_UNIFORM_VECTORS = 36349;
  146. this.SHADER_TYPE = 35663;
  147. this.DELETE_STATUS = 35712;
  148. this.LINK_STATUS = 35714;
  149. this.VALIDATE_STATUS = 35715;
  150. this.ATTACHED_SHADERS = 35717;
  151. this.ACTIVE_UNIFORMS = 35718;
  152. this.ACTIVE_ATTRIBUTES = 35721;
  153. this.SHADING_LANGUAGE_VERSION = 35724;
  154. this.CURRENT_PROGRAM = 35725;
  155. this.NEVER = 512;
  156. this.LESS = 513;
  157. this.EQUAL = 514;
  158. this.LEQUAL = 515;
  159. this.GREATER = 516;
  160. this.NOTEQUAL = 517;
  161. this.GEQUAL = 518;
  162. this.ALWAYS = 519;
  163. this.KEEP = 7680;
  164. this.REPLACE = 7681;
  165. this.INCR = 7682;
  166. this.DECR = 7683;
  167. this.INVERT = 5386;
  168. this.INCR_WRAP = 34055;
  169. this.DECR_WRAP = 34056;
  170. this.VENDOR = 7936;
  171. this.RENDERER = 7937;
  172. this.VERSION = 7938;
  173. this.NEAREST = 9728;
  174. this.LINEAR = 9729;
  175. this.NEAREST_MIPMAP_NEAREST = 9984;
  176. this.LINEAR_MIPMAP_NEAREST = 9985;
  177. this.NEAREST_MIPMAP_LINEAR = 9986;
  178. this.LINEAR_MIPMAP_LINEAR = 9987;
  179. this.TEXTURE_MAG_FILTER = 10240;
  180. this.TEXTURE_MIN_FILTER = 10241;
  181. this.TEXTURE_WRAP_S = 10242;
  182. this.TEXTURE_WRAP_T = 10243;
  183. this.TEXTURE = 5890;
  184. this.TEXTURE_CUBE_MAP = 34067;
  185. this.TEXTURE_BINDING_CUBE_MAP = 34068;
  186. this.TEXTURE_CUBE_MAP_POSITIVE_X = 34069;
  187. this.TEXTURE_CUBE_MAP_NEGATIVE_X = 34070;
  188. this.TEXTURE_CUBE_MAP_POSITIVE_Y = 34071;
  189. this.TEXTURE_CUBE_MAP_NEGATIVE_Y = 34072;
  190. this.TEXTURE_CUBE_MAP_POSITIVE_Z = 34073;
  191. this.TEXTURE_CUBE_MAP_NEGATIVE_Z = 34074;
  192. this.MAX_CUBE_MAP_TEXTURE_SIZE = 34076;
  193. this.TEXTURE0 = 33984;
  194. this.TEXTURE1 = 33985;
  195. this.TEXTURE2 = 33986;
  196. this.TEXTURE3 = 33987;
  197. this.TEXTURE4 = 33988;
  198. this.TEXTURE5 = 33989;
  199. this.TEXTURE6 = 33990;
  200. this.TEXTURE7 = 33991;
  201. this.TEXTURE8 = 33992;
  202. this.TEXTURE9 = 33993;
  203. this.TEXTURE10 = 33994;
  204. this.TEXTURE11 = 33995;
  205. this.TEXTURE12 = 33996;
  206. this.TEXTURE13 = 33997;
  207. this.TEXTURE14 = 33998;
  208. this.TEXTURE15 = 33999;
  209. this.TEXTURE16 = 34000;
  210. this.TEXTURE17 = 34001;
  211. this.TEXTURE18 = 34002;
  212. this.TEXTURE19 = 34003;
  213. this.TEXTURE20 = 34004;
  214. this.TEXTURE21 = 34005;
  215. this.TEXTURE22 = 34006;
  216. this.TEXTURE23 = 34007;
  217. this.TEXTURE24 = 34008;
  218. this.TEXTURE25 = 34009;
  219. this.TEXTURE26 = 34010;
  220. this.TEXTURE27 = 34011;
  221. this.TEXTURE28 = 34012;
  222. this.TEXTURE29 = 34013;
  223. this.TEXTURE30 = 34014;
  224. this.TEXTURE31 = 34015;
  225. this.ACTIVE_TEXTURE = 34016;
  226. this.REPEAT = 10497;
  227. this.CLAMP_TO_EDGE = 33071;
  228. this.MIRRORED_REPEAT = 33648;
  229. this.FLOAT_VEC2 = 35664;
  230. this.FLOAT_VEC3 = 35665;
  231. this.FLOAT_VEC4 = 35666;
  232. this.INT_VEC2 = 35667;
  233. this.INT_VEC3 = 35668;
  234. this.INT_VEC4 = 35669;
  235. this.BOOL = 35670;
  236. this.BOOL_VEC2 = 35671;
  237. this.BOOL_VEC3 = 35672;
  238. this.BOOL_VEC4 = 35673;
  239. this.FLOAT_MAT2 = 35674;
  240. this.FLOAT_MAT3 = 35675;
  241. this.FLOAT_MAT4 = 35676;
  242. this.SAMPLER_2D = 35678;
  243. this.SAMPLER_CUBE = 35680;
  244. this.VERTEX_ATTRIB_ARRAY_ENABLED = 34338;
  245. this.VERTEX_ATTRIB_ARRAY_SIZE = 34339;
  246. this.VERTEX_ATTRIB_ARRAY_STRIDE = 34340;
  247. this.VERTEX_ATTRIB_ARRAY_TYPE = 34341;
  248. this.VERTEX_ATTRIB_ARRAY_NORMALIZED = 34922;
  249. this.VERTEX_ATTRIB_ARRAY_POINTER = 34373;
  250. this.VERTEX_ATTRIB_ARRAY_BUFFER_BINDING = 34975;
  251. this.IMPLEMENTATION_COLOR_READ_TYPE = 35738;
  252. this.IMPLEMENTATION_COLOR_READ_FORMAT = 35739;
  253. this.COMPILE_STATUS = 35713;
  254. this.LOW_FLOAT = 36336;
  255. this.MEDIUM_FLOAT = 36337;
  256. this.HIGH_FLOAT = 36338;
  257. this.LOW_INT = 36339;
  258. this.MEDIUM_INT = 36340;
  259. this.HIGH_INT = 36341;
  260. this.FRAMEBUFFER = 36160;
  261. this.RENDERBUFFER = 36161;
  262. this.RGBA4 = 32854;
  263. this.RGB5_A1 = 32855;
  264. this.RGB565 = 36194;
  265. this.DEPTH_COMPONENT16 = 33189;
  266. this.STENCIL_INDEX8 = 36168;
  267. this.DEPTH_STENCIL = 34041;
  268. this.RENDERBUFFER_WIDTH = 36162;
  269. this.RENDERBUFFER_HEIGHT = 36163;
  270. this.RENDERBUFFER_INTERNAL_FORMAT = 36164;
  271. this.RENDERBUFFER_RED_SIZE = 36176;
  272. this.RENDERBUFFER_GREEN_SIZE = 36177;
  273. this.RENDERBUFFER_BLUE_SIZE = 36178;
  274. this.RENDERBUFFER_ALPHA_SIZE = 36179;
  275. this.RENDERBUFFER_DEPTH_SIZE = 36180;
  276. this.RENDERBUFFER_STENCIL_SIZE = 36181;
  277. this.FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE = 36048;
  278. this.FRAMEBUFFER_ATTACHMENT_OBJECT_NAME = 36049;
  279. this.FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL = 36050;
  280. this.FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE = 36051;
  281. this.COLOR_ATTACHMENT0 = 36064;
  282. this.DEPTH_ATTACHMENT = 36096;
  283. this.STENCIL_ATTACHMENT = 36128;
  284. this.DEPTH_STENCIL_ATTACHMENT = 33306;
  285. this.NONE = 0;
  286. this.FRAMEBUFFER_COMPLETE = 36053;
  287. this.FRAMEBUFFER_INCOMPLETE_ATTACHMENT = 36054;
  288. this.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT = 36055;
  289. this.FRAMEBUFFER_INCOMPLETE_DIMENSIONS = 36057;
  290. this.FRAMEBUFFER_UNSUPPORTED = 36061;
  291. this.FRAMEBUFFER_BINDING = 36006;
  292. this.RENDERBUFFER_BINDING = 36007;
  293. this.MAX_RENDERBUFFER_SIZE = 34024;
  294. this.INVALID_FRAMEBUFFER_OPERATION = 1286;
  295. this.UNPACK_FLIP_Y_WEBGL = 37440;
  296. this.UNPACK_PREMULTIPLY_ALPHA_WEBGL = 37441;
  297. this.CONTEXT_LOST_WEBGL = 37442;
  298. this.UNPACK_COLORSPACE_CONVERSION_WEBGL = 37443;
  299. this.BROWSER_DEFAULT_WEBGL = 37444;
  300. this.activeTexture = function () {};
  301. this.attachShader = function () {};
  302. this.bindAttribLocation = function () {};
  303. this.bindBuffer = function () {};
  304. this.bindFramebuffer = function () {};
  305. this.bindRenderbuffer = function () {};
  306. this.bindTexture = function () {};
  307. this.blendColor = function () {};
  308. this.blendEquation = function () {};
  309. this.blendEquationSeparate = function () {};
  310. this.blendFunc = function () {};
  311. this.blendFuncSeparate = function () {};
  312. this.bufferData = function () {};
  313. this.bufferSubData = function () {};
  314. this.checkFramebufferStatus = function () {};
  315. this.clear = function () {};
  316. this.clearColor = function () {};
  317. this.clearDepth = function () {};
  318. this.clearStencil = function () {};
  319. this.colorMask = function () {};
  320. this.compileShader = function () {};
  321. this.compressedTexImage2D = function () {};
  322. this.compressedTexSubImage2D = function () {};
  323. this.copyTexImage2D = function () {};
  324. this.copyTexSubImage2D = function () {};
  325. this.createBuffer = function () {};
  326. this.createFramebuffer = function () {};
  327. this.createProgram = function () {};
  328. this.createRenderbuffer = function () {};
  329. this.createShader = function () {};
  330. this.createTexture = function () {};
  331. this.cullFace = function () {};
  332. this.deleteBuffer = function () {};
  333. this.deleteFramebuffer = function () {};
  334. this.deleteProgram = function () {};
  335. this.deleteRenderbuffer = function () {};
  336. this.deleteShader = function () {};
  337. this.deleteTexture = function () {};
  338. this.depthFunc = function () {};
  339. this.depthMask = function () {};
  340. this.depthRange = function () {};
  341. this.detachShader = function () {};
  342. this.disable = function () {};
  343. this.disableVertexAttribArray = function () {};
  344. this.drawArrays = function () {};
  345. this.drawElements = function () {};
  346. this.enable = function () {};
  347. this.enableVertexAttribArray = function () {};
  348. this.finish = function () {};
  349. this.flush = function () {};
  350. this.framebufferRenderbuffer = function () {};
  351. this.framebufferTexture2D = function () {};
  352. this.frontFace = function () {};
  353. this.generateMipmap = function () {};
  354. this.getActiveAttrib = function () {};
  355. this.getActiveUniform = function () {};
  356. this.getAttachedShaders = function () {};
  357. this.getAttribLocation = function () {};
  358. this.getBufferParameter = function () {};
  359. this.getContextAttributes = function () {};
  360. this.getError = function () {};
  361. this.getExtension = function () {};
  362. this.getFramebufferAttachmentParameter = function () {};
  363. var parameters = {};
  364. parameters[ this.VERSION ] = "Custom";
  365. this.getParameter = function ( parameterID ) {
  366. return parameters[ parameterID ];
  367. };
  368. this.getProgramParameter = function () {};
  369. this.getProgramInfoLog = function () {};
  370. this.getRenderbufferParameter = function () {};
  371. this.getShaderParameter = function () {};
  372. this.getShaderInfoLog = function () {};
  373. this.getShaderPrecisionFormat = function () {
  374. return { 'rangeMin': 1, 'rangeMax': 1, 'precision': 1 };
  375. };
  376. this.getShaderSource = function () {};
  377. this.getSupportedExtensions = function () {};
  378. this.getTexParameter = function () {};
  379. this.getUniform = function () {};
  380. this.getUniformLocation = function () {};
  381. this.getVertexAttrib = function () {};
  382. this.getVertexAttribOffset = function () {};
  383. this.hint = function () {};
  384. this.isBuffer = function () {};
  385. this.isContextLost = function () {};
  386. this.isEnabled = function () {};
  387. this.isFramebuffer = function () {};
  388. this.isProgram = function () {};
  389. this.isRenderbuffer = function () {};
  390. this.isShader = function () {};
  391. this.isTexture = function () {};
  392. this.lineWidth = function () {};
  393. this.linkProgram = function () {};
  394. this.pixelStorei = function () {};
  395. this.polygonOffset = function () {};
  396. this.readPixels = function () {};
  397. this.renderbufferStorage = function () {};
  398. this.sampleCoverage = function () {};
  399. this.scissor = function () {};
  400. this.shaderSource = function () {};
  401. this.stencilFunc = function () {};
  402. this.stencilFuncSeparate = function () {};
  403. this.stencilMask = function () {};
  404. this.stencilMaskSeparate = function () {};
  405. this.stencilOp = function () {};
  406. this.stencilOpSeparate = function () {};
  407. this.texParameterf = function () {};
  408. this.texParameteri = function () {};
  409. this.texImage2D = function () {};
  410. this.texSubImage2D = function () {};
  411. this.uniform1f = function () {};
  412. this.uniform1fv = function () {};
  413. this.uniform1i = function () {};
  414. this.uniform1iv = function () {};
  415. this.uniform2f = function () {};
  416. this.uniform2fv = function () {};
  417. this.uniform2i = function () {};
  418. this.uniform2iv = function () {};
  419. this.uniform3f = function () {};
  420. this.uniform3fv = function () {};
  421. this.uniform3i = function () {};
  422. this.uniform3iv = function () {};
  423. this.uniform4f = function () {};
  424. this.uniform4fv = function () {};
  425. this.uniform4i = function () {};
  426. this.uniform4iv = function () {};
  427. this.uniformMatrix2fv = function () {};
  428. this.uniformMatrix3fv = function () {};
  429. this.uniformMatrix4fv = function () {};
  430. this.useProgram = function () {};
  431. this.validateProgram = function () {};
  432. this.vertexAttrib1f = function () {};
  433. this.vertexAttrib1fv = function () {};
  434. this.vertexAttrib2f = function () {};
  435. this.vertexAttrib2fv = function () {};
  436. this.vertexAttrib3f = function () {};
  437. this.vertexAttrib3fv = function () {};
  438. this.vertexAttrib4f = function () {};
  439. this.vertexAttrib4fv = function () {};
  440. this.vertexAttribPointer = function () {};
  441. this.viewport = function () {};
  442. };
  443. export default QUnit.module( 'Renderers', () => {
  444. QUnit.module( 'WebGLRenderer-webonly', () => {
  445. QUnit.test( "Instancing", ( assert ) => {
  446. assert.ok( new WebGLRenderer(), "Can instantiate a renderer." );
  447. } );
  448. } );
  449. } );