1 /*-------------------------------------------------------------------------
2 * drawElements Quality Program OpenGL ES 2.0 Module
3 * -------------------------------------------------
5 * Copyright 2014 The Android Open Source Project
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
21 * \brief Redundant state change performance tests.
22 *//*--------------------------------------------------------------------*/
24 #include "es2pRedundantStateChangeTests.hpp"
25 #include "glsStateChangePerfTestCases.hpp"
26 #include "gluShaderProgram.hpp"
27 #include "glwFunctions.hpp"
28 #include "glwEnums.hpp"
37 using namespace glw; // GL types
48 class RedundantStateChangeCase : public gls::StateChangePerformanceCase
51 RedundantStateChangeCase (Context& context, int drawCallCount, int triangleCount, bool drawArrays, bool useIndexBuffer, const char* name, const char* description);
52 ~RedundantStateChangeCase (void);
55 virtual void renderTest (const glw::Functions& gl);
56 virtual void renderReference (const glw::Functions& gl);
57 virtual void changeState (const glw::Functions& gl) = 0;
60 RedundantStateChangeCase::RedundantStateChangeCase (Context& context, int drawCallCount, int triangleCount, bool drawArrays, bool useIndexBuffer, const char* name, const char* description)
61 : gls::StateChangePerformanceCase(context.getTestContext(), context.getRenderContext(), name, description,
62 (useIndexBuffer ? DRAWTYPE_INDEXED_BUFFER :
63 drawArrays ? DRAWTYPE_NOT_INDEXED :
64 DRAWTYPE_INDEXED_USER_PTR), drawCallCount, triangleCount)
66 DE_ASSERT(!useIndexBuffer || !drawArrays);
69 RedundantStateChangeCase::~RedundantStateChangeCase (void)
73 void RedundantStateChangeCase::renderTest (const glw::Functions& gl)
75 for (int callNdx = 0; callNdx < m_callCount; callNdx++)
82 void RedundantStateChangeCase::renderReference (const glw::Functions& gl)
86 for (int callNdx = 0; callNdx < m_callCount; callNdx++)
92 RedundantStateChangeTests::RedundantStateChangeTests (Context& context)
93 : TestCaseGroup(context, "redundant_state_change_draw", "Test performance with redundant sate changes between rendering.")
97 RedundantStateChangeTests::~RedundantStateChangeTests (void)
101 #define MACRO_BLOCK(...) __VA_ARGS__
103 #define ADD_TESTCASE(NAME, DESC, DRAWARRAYS, INDEXBUFFER, INIT_FUNC, CHANGE_FUNC)\
105 class RedundantStateChangeCase_ ## NAME : public RedundantStateChangeCase\
108 RedundantStateChangeCase_ ## NAME (Context& context, int drawCallCount, int triangleCount, const char* name, const char* description)\
109 : RedundantStateChangeCase(context, drawCallCount, triangleCount, (DRAWARRAYS), (INDEXBUFFER), name, description)\
111 virtual void setupInitialState (const glw::Functions& gl)\
115 virtual void changeState (const glw::Functions& gl)\
120 manySmallCallsGroup->addChild (new RedundantStateChangeCase_ ## NAME (m_context,1000,2,#NAME,(DESC)));\
121 fewBigCallsGroup->addChild (new RedundantStateChangeCase_ ## NAME (m_context,10,200,#NAME,(DESC)));\
124 void RedundantStateChangeTests::init (void)
126 tcu::TestCaseGroup* const manySmallCallsGroup = new tcu::TestCaseGroup(m_testCtx, "many_small_calls", "1000 calls, 2 triangles in each");
127 tcu::TestCaseGroup* const fewBigCallsGroup = new tcu::TestCaseGroup(m_testCtx, "few_big_calls", "10 calls, 200 triangles in each");
129 addChild(manySmallCallsGroup);
130 addChild(fewBigCallsGroup);
132 ADD_TESTCASE(blend, "Enable/Disable blending.",
136 requireCoordBuffers(1);
140 gl.useProgram(m_programs[0]->getProgram());
141 GLU_EXPECT_NO_ERROR(gl.getError(), "glUseProgram()");
142 GLint coordLoc = gl.getAttribLocation(m_programs[0]->getProgram(), "a_coord");
143 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetAttribLocation()");
145 gl.enableVertexAttribArray(coordLoc);
146 GLU_EXPECT_NO_ERROR(gl.getError(), "glEnableVertexAttribArray()");
147 gl.bindBuffer(GL_ARRAY_BUFFER, m_coordBuffers[0]);
148 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer()");
149 gl.vertexAttribPointer(coordLoc, 2, GL_FLOAT, GL_FALSE, 0, NULL);
150 GLU_EXPECT_NO_ERROR(gl.getError(), "glVertexAttribPointer()");
152 GLint samplerLoc = gl.getUniformLocation(m_programs[0]->getProgram(), "u_sampler");
153 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetUniformLocation()");
155 gl.bindTexture(GL_TEXTURE_2D, m_textures[0]);
156 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture()");
158 gl.uniform1i(samplerLoc, 0);
159 GLU_EXPECT_NO_ERROR(gl.getError(), "glUniform1i()");
161 gl.viewport(0, 0, VIEWPORT_WIDTH, VIEWPORT_HEIGHT);
162 GLU_EXPECT_NO_ERROR(gl.getError(), "glViewport()");
169 ADD_TESTCASE(depth_test, "Enable/Disable depth test.",
173 requireCoordBuffers(1);
177 gl.useProgram(m_programs[0]->getProgram());
178 GLU_EXPECT_NO_ERROR(gl.getError(), "glUseProgram()");
180 GLint coordLoc = gl.getAttribLocation(m_programs[0]->getProgram(), "a_coord");
181 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetAttribLocation()");
183 gl.enableVertexAttribArray(coordLoc);
184 GLU_EXPECT_NO_ERROR(gl.getError(), "glEnableVertexAttribArray()");
186 gl.bindBuffer(GL_ARRAY_BUFFER, m_coordBuffers[0]);
187 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer()");
188 gl.vertexAttribPointer(coordLoc, 2, GL_FLOAT, GL_FALSE, 0, NULL);
189 GLU_EXPECT_NO_ERROR(gl.getError(), "glVertexAttribPointer()");
191 GLint samplerLoc = gl.getUniformLocation(m_programs[0]->getProgram(), "u_sampler");
192 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetUniformLocation()");
194 gl.bindTexture(GL_TEXTURE_2D, m_textures[0]);
195 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture()");
197 gl.uniform1i(samplerLoc, 0);
198 GLU_EXPECT_NO_ERROR(gl.getError(), "glUniform1i()");
200 gl.viewport(0, 0, VIEWPORT_WIDTH, VIEWPORT_HEIGHT);
201 GLU_EXPECT_NO_ERROR(gl.getError(), "glViewport()");
203 gl.depthFunc(GL_LEQUAL);
204 GLU_EXPECT_NO_ERROR(gl.getError(), "glDepthFunc()");
207 gl.enable(GL_DEPTH_TEST);
211 ADD_TESTCASE(stencil_test, "Enable/Disable stencil test.",
215 requireCoordBuffers(1);
219 gl.useProgram(m_programs[0]->getProgram());
220 GLU_EXPECT_NO_ERROR(gl.getError(), "glUseProgram()");
221 GLint coordLoc = gl.getAttribLocation(m_programs[0]->getProgram(), "a_coord");
222 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetAttribLocation()");
224 gl.enableVertexAttribArray(coordLoc);
225 GLU_EXPECT_NO_ERROR(gl.getError(), "glEnableVertexAttribArray()");
226 gl.bindBuffer(GL_ARRAY_BUFFER, m_coordBuffers[0]);
227 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer()");
228 gl.vertexAttribPointer(coordLoc, 2, GL_FLOAT, GL_FALSE, 0, NULL);
229 GLU_EXPECT_NO_ERROR(gl.getError(), "glVertexAttribPointer()");
231 GLint samplerLoc = gl.getUniformLocation(m_programs[0]->getProgram(), "u_sampler");
232 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetUniformLocation()");
234 gl.bindTexture(GL_TEXTURE_2D, m_textures[0]);
235 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture()");
237 gl.uniform1i(samplerLoc, 0);
238 GLU_EXPECT_NO_ERROR(gl.getError(), "glUniform1i()");
240 gl.viewport(0, 0, VIEWPORT_WIDTH, VIEWPORT_HEIGHT);
241 GLU_EXPECT_NO_ERROR(gl.getError(), "glViewport()");
243 gl.stencilFunc(GL_LEQUAL, 0, 0);
244 GLU_EXPECT_NO_ERROR(gl.getError(), "glStencilFunc()");
246 gl.stencilOp(GL_KEEP, GL_REPLACE, GL_REPLACE);
247 GLU_EXPECT_NO_ERROR(gl.getError(), "glStencilOp()");
250 GLU_EXPECT_NO_ERROR(gl.getError(), "glClearStencil()");
251 gl.clear(GL_STENCIL_BUFFER_BIT);
253 GLU_EXPECT_NO_ERROR(gl.getError(), "glClear()");
256 gl.enable(GL_STENCIL_TEST);
260 ADD_TESTCASE(scissor_test, "Enable/Disable scissor test.",
264 requireCoordBuffers(1);
268 gl.useProgram(m_programs[0]->getProgram());
269 GLU_EXPECT_NO_ERROR(gl.getError(), "glUseProgram()");
270 GLint coordLoc = gl.getAttribLocation(m_programs[0]->getProgram(), "a_coord");
271 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetAttribLocation()");
273 gl.enableVertexAttribArray(coordLoc);
274 GLU_EXPECT_NO_ERROR(gl.getError(), "glEnableVertexAttribArray()");
275 gl.bindBuffer(GL_ARRAY_BUFFER, m_coordBuffers[0]);
276 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer()");
277 gl.vertexAttribPointer(coordLoc, 2, GL_FLOAT, GL_FALSE, 0, NULL);
278 GLU_EXPECT_NO_ERROR(gl.getError(), "glVertexAttribPointer()");
280 GLint samplerLoc = gl.getUniformLocation(m_programs[0]->getProgram(), "u_sampler");
281 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetUniformLocation()");
283 gl.bindTexture(GL_TEXTURE_2D, m_textures[0]);
284 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture()");
286 gl.uniform1i(samplerLoc, 0);
287 GLU_EXPECT_NO_ERROR(gl.getError(), "glUniform1i()");
289 gl.viewport(0, 0, VIEWPORT_WIDTH, VIEWPORT_HEIGHT);
290 GLU_EXPECT_NO_ERROR(gl.getError(), "glViewport()");
292 gl.scissor(2, 3, 12, 13);
293 GLU_EXPECT_NO_ERROR(gl.getError(), "glScissor()");
296 gl.enable(GL_SCISSOR_TEST);
300 ADD_TESTCASE(dither, "Enable/Disable dithering.",
304 requireCoordBuffers(1);
308 gl.useProgram(m_programs[0]->getProgram());
309 GLU_EXPECT_NO_ERROR(gl.getError(), "glUseProgram()");
310 GLint coordLoc = gl.getAttribLocation(m_programs[0]->getProgram(), "a_coord");
311 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetAttribLocation()");
313 gl.enableVertexAttribArray(coordLoc);
314 GLU_EXPECT_NO_ERROR(gl.getError(), "glEnableVertexAttribArray()");
315 gl.bindBuffer(GL_ARRAY_BUFFER, m_coordBuffers[0]);
316 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer()");
317 gl.vertexAttribPointer(coordLoc, 2, GL_FLOAT, GL_FALSE, 0, NULL);
318 GLU_EXPECT_NO_ERROR(gl.getError(), "glVertexAttribPointer()");
320 GLint samplerLoc = gl.getUniformLocation(m_programs[0]->getProgram(), "u_sampler");
321 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetUniformLocation()");
323 gl.bindTexture(GL_TEXTURE_2D, m_textures[0]);
324 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture()");
326 gl.uniform1i(samplerLoc, 0);
327 GLU_EXPECT_NO_ERROR(gl.getError(), "glUniform1i()");
329 gl.viewport(0, 0, VIEWPORT_WIDTH, VIEWPORT_HEIGHT);
330 GLU_EXPECT_NO_ERROR(gl.getError(), "glViewport()");
333 gl.enable(GL_DITHER);
337 ADD_TESTCASE(culling, "Enable/Disable culling.",
341 requireCoordBuffers(1);
345 gl.useProgram(m_programs[0]->getProgram());
346 GLU_EXPECT_NO_ERROR(gl.getError(), "glUseProgram()");
347 GLint coordLoc = gl.getAttribLocation(m_programs[0]->getProgram(), "a_coord");
348 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetAttribLocation()");
350 gl.enableVertexAttribArray(coordLoc);
351 GLU_EXPECT_NO_ERROR(gl.getError(), "glEnableVertexAttribArray()");
352 gl.bindBuffer(GL_ARRAY_BUFFER, m_coordBuffers[0]);
353 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer()");
354 gl.vertexAttribPointer(coordLoc, 2, GL_FLOAT, GL_FALSE, 0, NULL);
355 GLU_EXPECT_NO_ERROR(gl.getError(), "glVertexAttribPointer()");
357 GLint samplerLoc = gl.getUniformLocation(m_programs[0]->getProgram(), "u_sampler");
358 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetUniformLocation()");
360 gl.bindTexture(GL_TEXTURE_2D, m_textures[0]);
361 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture()");
363 gl.uniform1i(samplerLoc, 0);
364 GLU_EXPECT_NO_ERROR(gl.getError(), "glUniform1i()");
366 gl.viewport(0, 0, VIEWPORT_WIDTH, VIEWPORT_HEIGHT);
367 GLU_EXPECT_NO_ERROR(gl.getError(), "glViewport()");
370 GLU_EXPECT_NO_ERROR(gl.getError(), "glFrontFace()");
372 gl.cullFace(GL_FRONT);
373 GLU_EXPECT_NO_ERROR(gl.getError(), "glCullFace()");
376 gl.enable(GL_CULL_FACE);
380 ADD_TESTCASE(depth_func, "Change depth func.",
384 requireCoordBuffers(1);
388 gl.useProgram(m_programs[0]->getProgram());
389 GLU_EXPECT_NO_ERROR(gl.getError(), "glUseProgram()");
390 GLint coordLoc = gl.getAttribLocation(m_programs[0]->getProgram(), "a_coord");
391 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetAttribLocation()");
393 gl.enableVertexAttribArray(coordLoc);
394 GLU_EXPECT_NO_ERROR(gl.getError(), "glEnableVertexAttribArray()");
395 gl.bindBuffer(GL_ARRAY_BUFFER, m_coordBuffers[0]);
396 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer()");
397 gl.vertexAttribPointer(coordLoc, 2, GL_FLOAT, GL_FALSE, 0, NULL);
398 GLU_EXPECT_NO_ERROR(gl.getError(), "glVertexAttribPointer()");
400 GLint samplerLoc = gl.getUniformLocation(m_programs[0]->getProgram(), "u_sampler");
401 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetUniformLocation()");
403 gl.bindTexture(GL_TEXTURE_2D, m_textures[0]);
404 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture()");
406 gl.uniform1i(samplerLoc, 0);
407 GLU_EXPECT_NO_ERROR(gl.getError(), "glUniform1i()");
409 gl.viewport(0, 0, VIEWPORT_WIDTH, VIEWPORT_HEIGHT);
410 GLU_EXPECT_NO_ERROR(gl.getError(), "glViewport()");
412 gl.enable(GL_DEPTH_TEST);
413 GLU_EXPECT_NO_ERROR(gl.getError(), "glEnable()");
416 gl.depthFunc(GL_GEQUAL);
421 ADD_TESTCASE(depth_mask, "Toggle depth mask.",
425 requireCoordBuffers(1);
429 gl.useProgram(m_programs[0]->getProgram());
430 GLU_EXPECT_NO_ERROR(gl.getError(), "glUseProgram()");
431 GLint coordLoc = gl.getAttribLocation(m_programs[0]->getProgram(), "a_coord");
432 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetAttribLocation()");
434 gl.enableVertexAttribArray(coordLoc);
435 GLU_EXPECT_NO_ERROR(gl.getError(), "glEnableVertexAttribArray()");
436 gl.bindBuffer(GL_ARRAY_BUFFER, m_coordBuffers[0]);
437 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer()");
438 gl.vertexAttribPointer(coordLoc, 2, GL_FLOAT, GL_FALSE, 0, NULL);
439 GLU_EXPECT_NO_ERROR(gl.getError(), "glVertexAttribPointer()");
441 GLint samplerLoc = gl.getUniformLocation(m_programs[0]->getProgram(), "u_sampler");
442 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetUniformLocation()");
444 gl.bindTexture(GL_TEXTURE_2D, m_textures[0]);
445 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture()");
447 gl.uniform1i(samplerLoc, 0);
448 GLU_EXPECT_NO_ERROR(gl.getError(), "glUniform1i()");
450 gl.viewport(0, 0, VIEWPORT_WIDTH, VIEWPORT_HEIGHT);
451 GLU_EXPECT_NO_ERROR(gl.getError(), "glViewport()");
453 gl.enable(GL_DEPTH_TEST);
454 GLU_EXPECT_NO_ERROR(gl.getError(), "glEnable()");
456 gl.depthFunc(GL_LEQUAL);
457 GLU_EXPECT_NO_ERROR(gl.getError(), "glDepthFunc()");
460 gl.depthMask(GL_FALSE);
464 ADD_TESTCASE(depth_rangef, "Change depth range.",
468 requireCoordBuffers(1);
472 gl.useProgram(m_programs[0]->getProgram());
473 GLU_EXPECT_NO_ERROR(gl.getError(), "glUseProgram()");
474 GLint coordLoc = gl.getAttribLocation(m_programs[0]->getProgram(), "a_coord");
475 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetAttribLocation()");
477 gl.enableVertexAttribArray(coordLoc);
478 GLU_EXPECT_NO_ERROR(gl.getError(), "glEnableVertexAttribArray()");
479 gl.bindBuffer(GL_ARRAY_BUFFER, m_coordBuffers[0]);
480 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer()");
481 gl.vertexAttribPointer(coordLoc, 2, GL_FLOAT, GL_FALSE, 0, NULL);
482 GLU_EXPECT_NO_ERROR(gl.getError(), "glVertexAttribPointer()");
484 GLint samplerLoc = gl.getUniformLocation(m_programs[0]->getProgram(), "u_sampler");
485 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetUniformLocation()");
487 gl.bindTexture(GL_TEXTURE_2D, m_textures[0]);
488 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture()");
490 gl.uniform1i(samplerLoc, 0);
491 GLU_EXPECT_NO_ERROR(gl.getError(), "glUniform1i()");
493 gl.viewport(0, 0, VIEWPORT_WIDTH, VIEWPORT_HEIGHT);
494 GLU_EXPECT_NO_ERROR(gl.getError(), "glViewport()");
497 gl.depthRangef(0.0f, 1.0f);
501 ADD_TESTCASE(blend_equation, "Change blend equation.",
505 requireCoordBuffers(1);
509 gl.useProgram(m_programs[0]->getProgram());
510 GLU_EXPECT_NO_ERROR(gl.getError(), "glUseProgram()");
511 GLint coordLoc = gl.getAttribLocation(m_programs[0]->getProgram(), "a_coord");
512 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetAttribLocation()");
514 gl.enableVertexAttribArray(coordLoc);
515 GLU_EXPECT_NO_ERROR(gl.getError(), "glEnableVertexAttribArray()");
516 gl.bindBuffer(GL_ARRAY_BUFFER, m_coordBuffers[0]);
517 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer()");
518 gl.vertexAttribPointer(coordLoc, 2, GL_FLOAT, GL_FALSE, 0, NULL);
519 GLU_EXPECT_NO_ERROR(gl.getError(), "glVertexAttribPointer()");
521 GLint samplerLoc = gl.getUniformLocation(m_programs[0]->getProgram(), "u_sampler");
522 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetUniformLocation()");
524 gl.bindTexture(GL_TEXTURE_2D, m_textures[0]);
525 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture()");
527 gl.uniform1i(samplerLoc, 0);
528 GLU_EXPECT_NO_ERROR(gl.getError(), "glUniform1i()");
530 gl.viewport(0, 0, VIEWPORT_WIDTH, VIEWPORT_HEIGHT);
531 GLU_EXPECT_NO_ERROR(gl.getError(), "glViewport()");
534 GLU_EXPECT_NO_ERROR(gl.getError(), "glEnable()");
537 gl.blendEquation(GL_FUNC_SUBTRACT);
541 ADD_TESTCASE(blend_func, "Change blend function.",
545 requireCoordBuffers(1);
549 gl.useProgram(m_programs[0]->getProgram());
550 GLU_EXPECT_NO_ERROR(gl.getError(), "glUseProgram()");
551 GLint coordLoc = gl.getAttribLocation(m_programs[0]->getProgram(), "a_coord");
552 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetAttribLocation()");
554 gl.enableVertexAttribArray(coordLoc);
555 GLU_EXPECT_NO_ERROR(gl.getError(), "glEnableVertexAttribArray()");
556 gl.bindBuffer(GL_ARRAY_BUFFER, m_coordBuffers[0]);
557 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer()");
558 gl.vertexAttribPointer(coordLoc, 2, GL_FLOAT, GL_FALSE, 0, NULL);
559 GLU_EXPECT_NO_ERROR(gl.getError(), "glVertexAttribPointer()");
561 GLint samplerLoc = gl.getUniformLocation(m_programs[0]->getProgram(), "u_sampler");
562 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetUniformLocation()");
564 gl.bindTexture(GL_TEXTURE_2D, m_textures[0]);
565 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture()");
567 gl.uniform1i(samplerLoc, 0);
568 GLU_EXPECT_NO_ERROR(gl.getError(), "glUniform1i()");
570 gl.viewport(0, 0, VIEWPORT_WIDTH, VIEWPORT_HEIGHT);
571 GLU_EXPECT_NO_ERROR(gl.getError(), "glViewport()");
574 GLU_EXPECT_NO_ERROR(gl.getError(), "glEnable()");
577 gl.blendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
581 ADD_TESTCASE(polygon_offset, "Change polygon offset.",
585 requireCoordBuffers(1);
589 gl.useProgram(m_programs[0]->getProgram());
590 GLU_EXPECT_NO_ERROR(gl.getError(), "glUseProgram()");
591 GLint coordLoc = gl.getAttribLocation(m_programs[0]->getProgram(), "a_coord");
592 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetAttribLocation()");
594 gl.enableVertexAttribArray(coordLoc);
595 GLU_EXPECT_NO_ERROR(gl.getError(), "glEnableVertexAttribArray()");
596 gl.bindBuffer(GL_ARRAY_BUFFER, m_coordBuffers[0]);
597 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer()");
598 gl.vertexAttribPointer(coordLoc, 2, GL_FLOAT, GL_FALSE, 0, NULL);
599 GLU_EXPECT_NO_ERROR(gl.getError(), "glVertexAttribPointer()");
601 GLint samplerLoc = gl.getUniformLocation(m_programs[0]->getProgram(), "u_sampler");
602 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetUniformLocation()");
604 gl.bindTexture(GL_TEXTURE_2D, m_textures[0]);
605 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture()");
607 gl.uniform1i(samplerLoc, 0);
608 GLU_EXPECT_NO_ERROR(gl.getError(), "glUniform1i()");
610 gl.viewport(0, 0, VIEWPORT_WIDTH, VIEWPORT_HEIGHT);
611 GLU_EXPECT_NO_ERROR(gl.getError(), "glViewport()");
613 gl.enable(GL_POLYGON_OFFSET_FILL);
614 GLU_EXPECT_NO_ERROR(gl.getError(), "glEnable()");
617 gl.polygonOffset(0.0f, 0.0f);
621 ADD_TESTCASE(sample_coverage, "Sample coverage.",
625 requireCoordBuffers(1);
629 gl.useProgram(m_programs[0]->getProgram());
630 GLU_EXPECT_NO_ERROR(gl.getError(), "glUseProgram()");
631 GLint coordLoc = gl.getAttribLocation(m_programs[0]->getProgram(), "a_coord");
632 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetAttribLocation()");
634 gl.enableVertexAttribArray(coordLoc);
635 GLU_EXPECT_NO_ERROR(gl.getError(), "glEnableVertexAttribArray()");
636 gl.bindBuffer(GL_ARRAY_BUFFER, m_coordBuffers[0]);
637 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer()");
638 gl.vertexAttribPointer(coordLoc, 2, GL_FLOAT, GL_FALSE, 0, NULL);
639 GLU_EXPECT_NO_ERROR(gl.getError(), "glVertexAttribPointer()");
641 GLint samplerLoc = gl.getUniformLocation(m_programs[0]->getProgram(), "u_sampler");
642 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetUniformLocation()");
644 gl.bindTexture(GL_TEXTURE_2D, m_textures[0]);
645 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture()");
647 gl.uniform1i(samplerLoc, 0);
648 GLU_EXPECT_NO_ERROR(gl.getError(), "glUniform1i()");
650 gl.viewport(0, 0, VIEWPORT_WIDTH, VIEWPORT_HEIGHT);
651 GLU_EXPECT_NO_ERROR(gl.getError(), "glViewport()");
654 gl.sampleCoverage(0.25f, GL_TRUE);
658 ADD_TESTCASE(viewport, "Change viewport.",
662 requireCoordBuffers(1);
666 gl.useProgram(m_programs[0]->getProgram());
667 GLU_EXPECT_NO_ERROR(gl.getError(), "glUseProgram()");
668 GLint coordLoc = gl.getAttribLocation(m_programs[0]->getProgram(), "a_coord");
669 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetAttribLocation()");
671 gl.enableVertexAttribArray(coordLoc);
672 GLU_EXPECT_NO_ERROR(gl.getError(), "glEnableVertexAttribArray()");
673 gl.bindBuffer(GL_ARRAY_BUFFER, m_coordBuffers[0]);
674 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer()");
675 gl.vertexAttribPointer(coordLoc, 2, GL_FLOAT, GL_FALSE, 0, NULL);
676 GLU_EXPECT_NO_ERROR(gl.getError(), "glVertexAttribPointer()");
678 GLint samplerLoc = gl.getUniformLocation(m_programs[0]->getProgram(), "u_sampler");
679 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetUniformLocation()");
681 gl.bindTexture(GL_TEXTURE_2D, m_textures[0]);
682 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture()");
684 gl.uniform1i(samplerLoc, 0);
685 GLU_EXPECT_NO_ERROR(gl.getError(), "glUniform1i()");
687 gl.viewport(0, 0, VIEWPORT_WIDTH, VIEWPORT_HEIGHT);
688 GLU_EXPECT_NO_ERROR(gl.getError(), "glViewport()");
691 gl.viewport(10, 11, 5, 6);
695 ADD_TESTCASE(scissor, "Change scissor box.",
699 requireCoordBuffers(1);
703 gl.useProgram(m_programs[0]->getProgram());
704 GLU_EXPECT_NO_ERROR(gl.getError(), "glUseProgram()");
705 GLint coordLoc = gl.getAttribLocation(m_programs[0]->getProgram(), "a_coord");
706 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetAttribLocation()");
708 gl.enableVertexAttribArray(coordLoc);
709 GLU_EXPECT_NO_ERROR(gl.getError(), "glEnableVertexAttribArray()");
710 gl.bindBuffer(GL_ARRAY_BUFFER, m_coordBuffers[0]);
711 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer()");
712 gl.vertexAttribPointer(coordLoc, 2, GL_FLOAT, GL_FALSE, 0, NULL);
713 GLU_EXPECT_NO_ERROR(gl.getError(), "glVertexAttribPointer()");
715 GLint samplerLoc = gl.getUniformLocation(m_programs[0]->getProgram(), "u_sampler");
716 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetUniformLocation()");
718 gl.bindTexture(GL_TEXTURE_2D, m_textures[0]);
719 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture()");
721 gl.uniform1i(samplerLoc, 0);
722 GLU_EXPECT_NO_ERROR(gl.getError(), "glUniform1i()");
724 gl.viewport(0, 0, VIEWPORT_WIDTH, VIEWPORT_HEIGHT);
725 GLU_EXPECT_NO_ERROR(gl.getError(), "glViewport()");
727 gl.enable(GL_SCISSOR_TEST);
728 GLU_EXPECT_NO_ERROR(gl.getError(), "glEnable()");
731 gl.scissor(17, 13, 5, 8);
735 ADD_TESTCASE(color_mask, "Change color mask.",
739 requireCoordBuffers(1);
743 gl.useProgram(m_programs[0]->getProgram());
744 GLU_EXPECT_NO_ERROR(gl.getError(), "glUseProgram()");
745 GLint coordLoc = gl.getAttribLocation(m_programs[0]->getProgram(), "a_coord");
746 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetAttribLocation()");
748 gl.enableVertexAttribArray(coordLoc);
749 GLU_EXPECT_NO_ERROR(gl.getError(), "glEnableVertexAttribArray()");
750 gl.bindBuffer(GL_ARRAY_BUFFER, m_coordBuffers[0]);
751 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer()");
752 gl.vertexAttribPointer(coordLoc, 2, GL_FLOAT, GL_FALSE, 0, NULL);
753 GLU_EXPECT_NO_ERROR(gl.getError(), "glVertexAttribPointer()");
755 GLint samplerLoc = gl.getUniformLocation(m_programs[0]->getProgram(), "u_sampler");
756 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetUniformLocation()");
758 gl.bindTexture(GL_TEXTURE_2D, m_textures[0]);
759 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture()");
761 gl.uniform1i(samplerLoc, 0);
762 GLU_EXPECT_NO_ERROR(gl.getError(), "glUniform1i()");
764 gl.viewport(0, 0, VIEWPORT_WIDTH, VIEWPORT_HEIGHT);
765 GLU_EXPECT_NO_ERROR(gl.getError(), "glViewport()");
768 gl.colorMask(GL_TRUE, GL_FALSE, GL_TRUE, GL_FALSE);
772 ADD_TESTCASE(cull_face, "Change culling mode.",
776 requireCoordBuffers(1);
780 gl.useProgram(m_programs[0]->getProgram());
781 GLU_EXPECT_NO_ERROR(gl.getError(), "glUseProgram()");
782 GLint coordLoc = gl.getAttribLocation(m_programs[0]->getProgram(), "a_coord");
783 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetAttribLocation()");
785 gl.enableVertexAttribArray(coordLoc);
786 GLU_EXPECT_NO_ERROR(gl.getError(), "glEnableVertexAttribArray()");
787 gl.bindBuffer(GL_ARRAY_BUFFER, m_coordBuffers[0]);
788 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer()");
789 gl.vertexAttribPointer(coordLoc, 2, GL_FLOAT, GL_FALSE, 0, NULL);
790 GLU_EXPECT_NO_ERROR(gl.getError(), "glVertexAttribPointer()");
792 GLint samplerLoc = gl.getUniformLocation(m_programs[0]->getProgram(), "u_sampler");
793 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetUniformLocation()");
795 gl.bindTexture(GL_TEXTURE_2D, m_textures[0]);
796 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture()");
798 gl.uniform1i(samplerLoc, 0);
799 GLU_EXPECT_NO_ERROR(gl.getError(), "glUniform1i()");
801 gl.viewport(0, 0, VIEWPORT_WIDTH, VIEWPORT_HEIGHT);
802 GLU_EXPECT_NO_ERROR(gl.getError(), "glViewport()");
804 gl.enable(GL_CULL_FACE);
805 GLU_EXPECT_NO_ERROR(gl.getError(), "glEnable()");
808 gl.cullFace(GL_FRONT);
812 ADD_TESTCASE(front_face, "Change front face.",
816 requireCoordBuffers(1);
820 gl.useProgram(m_programs[0]->getProgram());
821 GLU_EXPECT_NO_ERROR(gl.getError(), "glUseProgram()");
822 GLint coordLoc = gl.getAttribLocation(m_programs[0]->getProgram(), "a_coord");
823 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetAttribLocation()");
825 gl.enableVertexAttribArray(coordLoc);
826 GLU_EXPECT_NO_ERROR(gl.getError(), "glEnableVertexAttribArray()");
827 gl.bindBuffer(GL_ARRAY_BUFFER, m_coordBuffers[0]);
828 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer()");
829 gl.vertexAttribPointer(coordLoc, 2, GL_FLOAT, GL_FALSE, 0, NULL);
830 GLU_EXPECT_NO_ERROR(gl.getError(), "glVertexAttribPointer()");
832 GLint samplerLoc = gl.getUniformLocation(m_programs[0]->getProgram(), "u_sampler");
833 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetUniformLocation()");
835 gl.bindTexture(GL_TEXTURE_2D, m_textures[0]);
836 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture()");
838 gl.uniform1i(samplerLoc, 0);
839 GLU_EXPECT_NO_ERROR(gl.getError(), "glUniform1i()");
841 gl.viewport(0, 0, VIEWPORT_WIDTH, VIEWPORT_HEIGHT);
842 GLU_EXPECT_NO_ERROR(gl.getError(), "glViewport()");
844 gl.enable(GL_CULL_FACE);
845 GLU_EXPECT_NO_ERROR(gl.getError(), "glEnable()");
848 gl.frontFace(GL_CCW);
852 ADD_TESTCASE(stencil_mask, "Change stencil mask.",
856 requireCoordBuffers(1);
860 gl.useProgram(m_programs[0]->getProgram());
861 GLU_EXPECT_NO_ERROR(gl.getError(), "glUseProgram()");
862 GLint coordLoc = gl.getAttribLocation(m_programs[0]->getProgram(), "a_coord");
863 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetAttribLocation()");
865 gl.enableVertexAttribArray(coordLoc);
866 GLU_EXPECT_NO_ERROR(gl.getError(), "glEnableVertexAttribArray()");
867 gl.bindBuffer(GL_ARRAY_BUFFER, m_coordBuffers[0]);
868 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer()");
869 gl.vertexAttribPointer(coordLoc, 2, GL_FLOAT, GL_FALSE, 0, NULL);
870 GLU_EXPECT_NO_ERROR(gl.getError(), "glVertexAttribPointer()");
872 GLint samplerLoc = gl.getUniformLocation(m_programs[0]->getProgram(), "u_sampler");
873 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetUniformLocation()");
875 gl.bindTexture(GL_TEXTURE_2D, m_textures[0]);
876 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture()");
878 gl.uniform1i(samplerLoc, 0);
879 GLU_EXPECT_NO_ERROR(gl.getError(), "glUniform1i()");
881 gl.viewport(0, 0, VIEWPORT_WIDTH, VIEWPORT_HEIGHT);
882 GLU_EXPECT_NO_ERROR(gl.getError(), "glViewport()");
884 gl.enable(GL_STENCIL_TEST);
885 GLU_EXPECT_NO_ERROR(gl.getError(), "glEnable()");
887 gl.stencilFunc(GL_LEQUAL, 0, 0);
888 GLU_EXPECT_NO_ERROR(gl.getError(), "glStencilFunc()");
890 gl.stencilOp(GL_KEEP, GL_REPLACE, GL_REPLACE);
891 GLU_EXPECT_NO_ERROR(gl.getError(), "glStencilOp()");
894 GLU_EXPECT_NO_ERROR(gl.getError(), "glClearStencil()");
895 gl.clear(GL_STENCIL_BUFFER_BIT);
896 GLU_EXPECT_NO_ERROR(gl.getError(), "glClear()");
899 gl.stencilMask(0xDD);
903 ADD_TESTCASE(stencil_func, "Change stencil func.",
907 requireCoordBuffers(1);
911 gl.useProgram(m_programs[0]->getProgram());
912 GLU_EXPECT_NO_ERROR(gl.getError(), "glUseProgram()");
913 GLint coordLoc = gl.getAttribLocation(m_programs[0]->getProgram(), "a_coord");
914 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetAttribLocation()");
916 gl.enableVertexAttribArray(coordLoc);
917 GLU_EXPECT_NO_ERROR(gl.getError(), "glEnableVertexAttribArray()");
918 gl.bindBuffer(GL_ARRAY_BUFFER, m_coordBuffers[0]);
919 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer()");
920 gl.vertexAttribPointer(coordLoc, 2, GL_FLOAT, GL_FALSE, 0, NULL);
921 GLU_EXPECT_NO_ERROR(gl.getError(), "glVertexAttribPointer()");
923 GLint samplerLoc = gl.getUniformLocation(m_programs[0]->getProgram(), "u_sampler");
924 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetUniformLocation()");
926 gl.bindTexture(GL_TEXTURE_2D, m_textures[0]);
927 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture()");
929 gl.uniform1i(samplerLoc, 0);
930 GLU_EXPECT_NO_ERROR(gl.getError(), "glUniform1i()");
932 gl.viewport(0, 0, VIEWPORT_WIDTH, VIEWPORT_HEIGHT);
933 GLU_EXPECT_NO_ERROR(gl.getError(), "glViewport()");
935 gl.enable(GL_STENCIL_TEST);
936 GLU_EXPECT_NO_ERROR(gl.getError(), "glEnable()");
938 gl.stencilOp(GL_KEEP, GL_REPLACE, GL_REPLACE);
939 GLU_EXPECT_NO_ERROR(gl.getError(), "glStencilOp()");
941 GLU_EXPECT_NO_ERROR(gl.getError(), "glClearStencil()");
942 gl.clear(GL_STENCIL_BUFFER_BIT);
943 GLU_EXPECT_NO_ERROR(gl.getError(), "glClear()");
946 gl.stencilFunc(GL_LEQUAL, 0, 0xFF);
950 ADD_TESTCASE(stencil_op, "Change stencil op.",
954 requireCoordBuffers(1);
958 gl.useProgram(m_programs[0]->getProgram());
959 GLU_EXPECT_NO_ERROR(gl.getError(), "glUseProgram()");
960 GLint coordLoc = gl.getAttribLocation(m_programs[0]->getProgram(), "a_coord");
961 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetAttribLocation()");
963 gl.enableVertexAttribArray(coordLoc);
964 GLU_EXPECT_NO_ERROR(gl.getError(), "glEnableVertexAttribArray()");
965 gl.bindBuffer(GL_ARRAY_BUFFER, m_coordBuffers[0]);
966 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer()");
967 gl.vertexAttribPointer(coordLoc, 2, GL_FLOAT, GL_FALSE, 0, NULL);
968 GLU_EXPECT_NO_ERROR(gl.getError(), "glVertexAttribPointer()");
970 GLint samplerLoc = gl.getUniformLocation(m_programs[0]->getProgram(), "u_sampler");
971 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetUniformLocation()");
973 gl.bindTexture(GL_TEXTURE_2D, m_textures[0]);
974 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture()");
976 gl.uniform1i(samplerLoc, 0);
977 GLU_EXPECT_NO_ERROR(gl.getError(), "glUniform1i()");
979 gl.viewport(0, 0, VIEWPORT_WIDTH, VIEWPORT_HEIGHT);
980 GLU_EXPECT_NO_ERROR(gl.getError(), "glViewport()");
982 gl.enable(GL_STENCIL_TEST);
983 GLU_EXPECT_NO_ERROR(gl.getError(), "glEnable()");
985 gl.stencilFunc(GL_LEQUAL, 0, 0);
986 GLU_EXPECT_NO_ERROR(gl.getError(), "glStencilFunc()");
989 GLU_EXPECT_NO_ERROR(gl.getError(), "glClearStencil()");
991 gl.clear(GL_STENCIL_BUFFER_BIT);
992 GLU_EXPECT_NO_ERROR(gl.getError(), "glClear()");
995 gl.stencilOp(GL_KEEP, GL_REPLACE, GL_REPLACE);
999 ADD_TESTCASE(bind_array_buffer, "Change array buffer and refresh vertex attrib pointer.",
1003 requireCoordBuffers(1);
1007 gl.bindAttribLocation(m_programs[0]->getProgram(), 0, "a_coord");
1008 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindAttribLocation()");
1009 gl.linkProgram(m_programs[0]->getProgram());
1010 GLU_EXPECT_NO_ERROR(gl.getError(), "glLinkProgram()");
1012 gl.useProgram(m_programs[0]->getProgram());
1013 GLU_EXPECT_NO_ERROR(gl.getError(), "glUseProgram()");
1015 gl.enableVertexAttribArray(0);
1016 GLU_EXPECT_NO_ERROR(gl.getError(), "glEnableVertexAttribArray()");
1017 gl.bindBuffer(GL_ARRAY_BUFFER, m_coordBuffers[0]);
1018 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer()");
1019 gl.vertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 0, NULL);
1020 GLU_EXPECT_NO_ERROR(gl.getError(), "glVertexAttribPointer()");
1022 GLint samplerLoc = gl.getUniformLocation(m_programs[0]->getProgram(), "u_sampler");
1023 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetUniformLocation()");
1025 gl.bindTexture(GL_TEXTURE_2D, m_textures[0]);
1026 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture()");
1028 gl.uniform1i(samplerLoc, 0);
1029 GLU_EXPECT_NO_ERROR(gl.getError(), "glUniform1i()");
1031 gl.viewport(0, 0, VIEWPORT_WIDTH, VIEWPORT_HEIGHT);
1032 GLU_EXPECT_NO_ERROR(gl.getError(), "glViewport()");
1035 gl.bindBuffer(GL_ARRAY_BUFFER, m_coordBuffers[0]);
1036 gl.vertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 0, NULL);
1040 ADD_TESTCASE(element_array_buffer, "Change element array buffer.",
1044 requireCoordBuffers(1);
1045 requireIndexBuffers(1);
1049 gl.useProgram(m_programs[0]->getProgram());
1050 GLU_EXPECT_NO_ERROR(gl.getError(), "glUseProgram()");
1051 GLint coordLoc = gl.getAttribLocation(m_programs[0]->getProgram(), "a_coord");
1052 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetAttribLocation()");
1054 gl.enableVertexAttribArray(coordLoc);
1055 GLU_EXPECT_NO_ERROR(gl.getError(), "glEnableVertexAttribArray()");
1056 gl.bindBuffer(GL_ARRAY_BUFFER, m_coordBuffers[0]);
1057 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer()");
1058 gl.vertexAttribPointer(coordLoc, 2, GL_FLOAT, GL_FALSE, 0, NULL);
1059 GLU_EXPECT_NO_ERROR(gl.getError(), "glVertexAttribPointer()");
1061 GLint samplerLoc = gl.getUniformLocation(m_programs[0]->getProgram(), "u_sampler");
1062 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetUniformLocation()");
1064 gl.bindTexture(GL_TEXTURE_2D, m_textures[0]);
1065 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture()");
1067 gl.uniform1i(samplerLoc, 0);
1068 GLU_EXPECT_NO_ERROR(gl.getError(), "glUniform1i()");
1070 gl.viewport(0, 0, VIEWPORT_WIDTH, VIEWPORT_HEIGHT);
1071 GLU_EXPECT_NO_ERROR(gl.getError(), "glViewport()");
1073 gl.bindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_indexBuffers[0]);
1074 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer()");
1077 gl.bindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_indexBuffers[0]);
1081 ADD_TESTCASE(bind_texture, "Change texture binding.",
1085 requireCoordBuffers(1);
1089 gl.useProgram(m_programs[0]->getProgram());
1090 GLU_EXPECT_NO_ERROR(gl.getError(), "glUseProgram()");
1091 GLint coordLoc = gl.getAttribLocation(m_programs[0]->getProgram(), "a_coord");
1092 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetAttribLocation()");
1094 gl.enableVertexAttribArray(coordLoc);
1095 GLU_EXPECT_NO_ERROR(gl.getError(), "glEnableVertexAttribArray()");
1096 gl.bindBuffer(GL_ARRAY_BUFFER, m_coordBuffers[0]);
1097 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer()");
1098 gl.vertexAttribPointer(coordLoc, 2, GL_FLOAT, GL_FALSE, 0, NULL);
1099 GLU_EXPECT_NO_ERROR(gl.getError(), "glVertexAttribPointer()");
1101 GLint samplerLoc = gl.getUniformLocation(m_programs[0]->getProgram(), "u_sampler");
1102 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetUniformLocation()");
1104 gl.bindTexture(GL_TEXTURE_2D, m_textures[0]);
1105 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture()");
1107 gl.uniform1i(samplerLoc, 0);
1108 GLU_EXPECT_NO_ERROR(gl.getError(), "glUniform1i()");
1110 gl.viewport(0, 0, VIEWPORT_WIDTH, VIEWPORT_HEIGHT);
1111 GLU_EXPECT_NO_ERROR(gl.getError(), "glViewport()");
1114 gl.bindTexture(GL_TEXTURE_2D, m_textures[0]);
1118 ADD_TESTCASE(use_program, "Change used program.",
1122 requireCoordBuffers(1);
1126 GLint coordLoc = gl.getAttribLocation(m_programs[0]->getProgram(), "a_coord");
1127 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetAttribLocation()");
1129 gl.enableVertexAttribArray(coordLoc);
1130 GLU_EXPECT_NO_ERROR(gl.getError(), "glEnableVertexAttribArray()");
1131 gl.bindBuffer(GL_ARRAY_BUFFER, m_coordBuffers[0]);
1132 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer()");
1133 gl.vertexAttribPointer(coordLoc, 2, GL_FLOAT, GL_FALSE, 0, NULL);
1134 GLU_EXPECT_NO_ERROR(gl.getError(), "glVertexAttribPointer()");
1136 gl.bindTexture(GL_TEXTURE_2D, m_textures[0]);
1137 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture()");
1139 GLint samplerLoc = gl.getUniformLocation(m_programs[0]->getProgram(), "u_sampler");
1140 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetUniformLocation()");
1141 gl.useProgram(m_programs[0]->getProgram());
1142 GLU_EXPECT_NO_ERROR(gl.getError(), "glUseProgram()");
1143 gl.uniform1i(samplerLoc, 0);
1144 GLU_EXPECT_NO_ERROR(gl.getError(), "glUniform1i()");
1146 gl.viewport(0, 0, VIEWPORT_WIDTH, VIEWPORT_HEIGHT);
1147 GLU_EXPECT_NO_ERROR(gl.getError(), "glViewport()");
1150 gl.useProgram(m_programs[0]->getProgram());
1154 ADD_TESTCASE(tex_parameter_min_filter, "Change texture parameter min filter.",
1158 requireCoordBuffers(1);
1162 gl.useProgram(m_programs[0]->getProgram());
1163 GLU_EXPECT_NO_ERROR(gl.getError(), "glUseProgram()");
1164 GLint coordLoc = gl.getAttribLocation(m_programs[0]->getProgram(), "a_coord");
1165 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetAttribLocation()");
1167 gl.enableVertexAttribArray(coordLoc);
1168 GLU_EXPECT_NO_ERROR(gl.getError(), "glEnableVertexAttribArray()");
1169 gl.bindBuffer(GL_ARRAY_BUFFER, m_coordBuffers[0]);
1170 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer()");
1171 gl.vertexAttribPointer(coordLoc, 2, GL_FLOAT, GL_FALSE, 0, NULL);
1172 GLU_EXPECT_NO_ERROR(gl.getError(), "glVertexAttribPointer()");
1174 GLint samplerLoc = gl.getUniformLocation(m_programs[0]->getProgram(), "u_sampler");
1175 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetUniformLocation()");
1177 gl.bindTexture(GL_TEXTURE_2D, m_textures[0]);
1178 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture()");
1180 gl.uniform1i(samplerLoc, 0);
1181 GLU_EXPECT_NO_ERROR(gl.getError(), "glUniform1i()");
1183 gl.viewport(0, 0, VIEWPORT_WIDTH, VIEWPORT_HEIGHT);
1184 GLU_EXPECT_NO_ERROR(gl.getError(), "glViewport()");
1187 gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
1191 ADD_TESTCASE(tex_parameter_mag_filter, "Change texture parameter mag filter.",
1195 requireCoordBuffers(1);
1199 gl.useProgram(m_programs[0]->getProgram());
1200 GLU_EXPECT_NO_ERROR(gl.getError(), "glUseProgram()");
1201 GLint coordLoc = gl.getAttribLocation(m_programs[0]->getProgram(), "a_coord");
1202 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetAttribLocation()");
1204 gl.enableVertexAttribArray(coordLoc);
1205 GLU_EXPECT_NO_ERROR(gl.getError(), "glEnableVertexAttribArray()");
1206 gl.bindBuffer(GL_ARRAY_BUFFER, m_coordBuffers[0]);
1207 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer()");
1208 gl.vertexAttribPointer(coordLoc, 2, GL_FLOAT, GL_FALSE, 0, NULL);
1209 GLU_EXPECT_NO_ERROR(gl.getError(), "glVertexAttribPointer()");
1211 GLint samplerLoc = gl.getUniformLocation(m_programs[0]->getProgram(), "u_sampler");
1212 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetUniformLocation()");
1214 gl.bindTexture(GL_TEXTURE_2D, m_textures[0]);
1215 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture()");
1217 gl.uniform1i(samplerLoc, 0);
1218 GLU_EXPECT_NO_ERROR(gl.getError(), "glUniform1i()");
1220 gl.viewport(0, 0, VIEWPORT_WIDTH, VIEWPORT_HEIGHT);
1221 GLU_EXPECT_NO_ERROR(gl.getError(), "glViewport()");
1224 gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
1228 ADD_TESTCASE(tex_parameter_wrap, "Change texture parameter wrap filter.",
1232 requireCoordBuffers(1);
1236 gl.useProgram(m_programs[0]->getProgram());
1237 GLU_EXPECT_NO_ERROR(gl.getError(), "glUseProgram()");
1238 GLint coordLoc = gl.getAttribLocation(m_programs[0]->getProgram(), "a_coord");
1239 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetAttribLocation()");
1241 gl.enableVertexAttribArray(coordLoc);
1242 GLU_EXPECT_NO_ERROR(gl.getError(), "glEnableVertexAttribArray()");
1243 gl.bindBuffer(GL_ARRAY_BUFFER, m_coordBuffers[0]);
1244 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer()");
1245 gl.vertexAttribPointer(coordLoc, 2, GL_FLOAT, GL_FALSE, 0, NULL);
1246 GLU_EXPECT_NO_ERROR(gl.getError(), "glVertexAttribPointer()");
1248 GLint samplerLoc = gl.getUniformLocation(m_programs[0]->getProgram(), "u_sampler");
1249 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetUniformLocation()");
1251 gl.bindTexture(GL_TEXTURE_2D, m_textures[0]);
1252 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture()");
1254 gl.uniform1i(samplerLoc, 0);
1255 GLU_EXPECT_NO_ERROR(gl.getError(), "glUniform1i()");
1257 gl.viewport(0, 0, VIEWPORT_WIDTH, VIEWPORT_HEIGHT);
1258 GLU_EXPECT_NO_ERROR(gl.getError(), "glViewport()");
1261 gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
1265 ADD_TESTCASE(bind_framebuffer, "Change framebuffer.",
1269 requireCoordBuffers(1);
1271 requireFramebuffers(1);
1274 gl.useProgram(m_programs[0]->getProgram());
1275 GLU_EXPECT_NO_ERROR(gl.getError(), "glUseProgram()");
1276 GLint coordLoc = gl.getAttribLocation(m_programs[0]->getProgram(), "a_coord");
1277 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetAttribLocation()");
1279 gl.enableVertexAttribArray(coordLoc);
1280 GLU_EXPECT_NO_ERROR(gl.getError(), "glEnableVertexAttribArray()");
1281 gl.bindBuffer(GL_ARRAY_BUFFER, m_coordBuffers[0]);
1282 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer()");
1283 gl.vertexAttribPointer(coordLoc, 2, GL_FLOAT, GL_FALSE, 0, NULL);
1284 GLU_EXPECT_NO_ERROR(gl.getError(), "glVertexAttribPointer()");
1286 GLint samplerLoc = gl.getUniformLocation(m_programs[0]->getProgram(), "u_sampler");
1287 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetUniformLocation()");
1289 gl.bindTexture(GL_TEXTURE_2D, m_textures[0]);
1290 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture()");
1292 gl.uniform1i(samplerLoc, 0);
1293 GLU_EXPECT_NO_ERROR(gl.getError(), "glUniform1i()");
1295 gl.viewport(0, 0, VIEWPORT_WIDTH, VIEWPORT_HEIGHT);
1296 GLU_EXPECT_NO_ERROR(gl.getError(), "glViewport()");
1298 gl.bindFramebuffer(GL_FRAMEBUFFER, m_framebuffers[0]);
1299 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer()");
1302 gl.bindFramebuffer(GL_FRAMEBUFFER, m_framebuffers[0]);
1306 ADD_TESTCASE(blend_color, "Change blend color.",
1310 requireCoordBuffers(1);
1314 gl.useProgram(m_programs[0]->getProgram());
1315 GLU_EXPECT_NO_ERROR(gl.getError(), "glUseProgram()");
1316 GLint coordLoc = gl.getAttribLocation(m_programs[0]->getProgram(), "a_coord");
1317 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetAttribLocation()");
1319 gl.enableVertexAttribArray(coordLoc);
1320 GLU_EXPECT_NO_ERROR(gl.getError(), "glEnableVertexAttribArray()");
1321 gl.bindBuffer(GL_ARRAY_BUFFER, m_coordBuffers[0]);
1322 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer()");
1323 gl.vertexAttribPointer(coordLoc, 2, GL_FLOAT, GL_FALSE, 0, NULL);
1324 GLU_EXPECT_NO_ERROR(gl.getError(), "glVertexAttribPointer()");
1326 GLint samplerLoc = gl.getUniformLocation(m_programs[0]->getProgram(), "u_sampler");
1327 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetUniformLocation()");
1329 gl.bindTexture(GL_TEXTURE_2D, m_textures[0]);
1330 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture()");
1332 gl.uniform1i(samplerLoc, 0);
1333 GLU_EXPECT_NO_ERROR(gl.getError(), "glUniform1i()");
1335 gl.viewport(0, 0, VIEWPORT_WIDTH, VIEWPORT_HEIGHT);
1336 GLU_EXPECT_NO_ERROR(gl.getError(), "glViewport()");
1338 gl.enable(GL_BLEND);
1339 GLU_EXPECT_NO_ERROR(gl.getError(), "glEnable()");
1341 gl.blendFunc(GL_CONSTANT_COLOR, GL_CONSTANT_COLOR);
1342 GLU_EXPECT_NO_ERROR(gl.getError(), "glBlendFunc()");
1345 gl.blendColor(0.75f, 0.75f, 0.75f, 0.75f);