1 /*-------------------------------------------------------------------------
2 * drawElements Quality Program OpenGL ES 3.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 State change performance tests.
22 *//*--------------------------------------------------------------------*/
24 #include "es3pStateChangeTests.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 StateChangeCase : public gls::StateChangePerformanceCase
51 StateChangeCase (Context& context, int drawCallCount, int triangleCount, bool drawArrays, bool useIndexBuffer, const char* name, const char* description);
52 ~StateChangeCase (void);
55 virtual void renderTest (const glw::Functions& gl);
56 virtual void renderReference (const glw::Functions& gl);
58 virtual void changeState (const glw::Functions& gl, int stateId) = 0;
61 StateChangeCase::StateChangeCase (Context& context, int drawCallCount, int triangleCount, bool drawArrays, bool useIndexBuffer, const char* name, const char* description)
62 : gls::StateChangePerformanceCase(context.getTestContext(), context.getRenderContext(), name, description,
63 (useIndexBuffer ? DRAWTYPE_INDEXED_BUFFER :
64 drawArrays ? DRAWTYPE_NOT_INDEXED :
65 DRAWTYPE_INDEXED_USER_PTR), drawCallCount, triangleCount)
67 DE_ASSERT(!useIndexBuffer || !drawArrays);
70 StateChangeCase::~StateChangeCase (void)
74 void StateChangeCase::renderTest (const glw::Functions& gl)
76 for (int callNdx = 0; callNdx < m_callCount; callNdx++)
86 void StateChangeCase::renderReference (const glw::Functions& gl)
90 for (int callNdx = 0; callNdx < m_callCount; callNdx++)
95 for (int callNdx = 0; callNdx < m_callCount; callNdx++)
101 StateChangeTests::StateChangeTests (Context& context)
102 : TestCaseGroup(context, "state_change_draw", "Test state change perfomance with draw calls.")
106 StateChangeTests::~StateChangeTests (void)
110 #define MACRO_BLOCK(...) __VA_ARGS__
112 #define ADD_TESTCASE(NAME, DESC, DRAWARRAYS, INDEXBUFFER, INIT_FUNC, CHANGE_FUNC)\
114 class StateChangeCase_ ## NAME : public StateChangeCase\
117 StateChangeCase_ ## NAME (Context& context, int drawCallCount, int triangleCount, const char* name, const char* description)\
118 : StateChangeCase(context, drawCallCount, triangleCount, (DRAWARRAYS), (INDEXBUFFER), name, description)\
120 virtual void setupInitialState (const glw::Functions& gl)\
124 virtual void changeState (const glw::Functions& gl, int stateId)\
129 manySmallCallsGroup->addChild (new StateChangeCase_ ## NAME (m_context,1000,2,#NAME,(DESC)));\
130 fewBigCallsGroup->addChild (new StateChangeCase_ ## NAME (m_context,10,200,#NAME,(DESC)));\
133 void StateChangeTests::init (void)
135 tcu::TestCaseGroup* const manySmallCallsGroup = new tcu::TestCaseGroup(m_testCtx, "many_small_calls", "1000 calls, 2 triangles in each");
136 tcu::TestCaseGroup* const fewBigCallsGroup = new tcu::TestCaseGroup(m_testCtx, "few_big_calls", "10 calls, 200 triangles in each");
138 addChild(manySmallCallsGroup);
139 addChild(fewBigCallsGroup);
141 ADD_TESTCASE(blend, "Enable/Disable blending.",
145 requireCoordBuffers(1);
149 gl.useProgram(m_programs[0]->getProgram());
150 GLU_EXPECT_NO_ERROR(gl.getError(), "glUseProgram()");
151 GLint coordLoc = gl.getAttribLocation(m_programs[0]->getProgram(), "a_coord");
152 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetAttribLocation()");
154 gl.enableVertexAttribArray(coordLoc);
155 GLU_EXPECT_NO_ERROR(gl.getError(), "glEnableVertexAttribArray()");
156 gl.bindBuffer(GL_ARRAY_BUFFER, m_coordBuffers[0]);
157 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer()");
158 gl.vertexAttribPointer(coordLoc, 2, GL_FLOAT, GL_FALSE, 0, NULL);
159 GLU_EXPECT_NO_ERROR(gl.getError(), "glVertexAttribPointer()");
161 GLint samplerLoc = gl.getUniformLocation(m_programs[0]->getProgram(), "u_sampler");
162 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetUniformLocation()");
164 gl.bindTexture(GL_TEXTURE_2D, m_textures[0]);
165 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture()");
167 gl.uniform1i(samplerLoc, 0);
168 GLU_EXPECT_NO_ERROR(gl.getError(), "glUniform1i()");
170 gl.viewport(0, 0, VIEWPORT_WIDTH, VIEWPORT_HEIGHT);
171 GLU_EXPECT_NO_ERROR(gl.getError(), "glViewport()");
176 else if (stateId == 1)
177 gl.disable(GL_BLEND);
183 ADD_TESTCASE(depth_test, "Enable/Disable depth test.",
187 requireCoordBuffers(1);
191 gl.useProgram(m_programs[0]->getProgram());
192 GLU_EXPECT_NO_ERROR(gl.getError(), "glUseProgram()");
194 GLint coordLoc = gl.getAttribLocation(m_programs[0]->getProgram(), "a_coord");
195 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetAttribLocation()");
197 gl.enableVertexAttribArray(coordLoc);
198 GLU_EXPECT_NO_ERROR(gl.getError(), "glEnableVertexAttribArray()");
200 gl.bindBuffer(GL_ARRAY_BUFFER, m_coordBuffers[0]);
201 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer()");
202 gl.vertexAttribPointer(coordLoc, 2, GL_FLOAT, GL_FALSE, 0, NULL);
203 GLU_EXPECT_NO_ERROR(gl.getError(), "glVertexAttribPointer()");
205 GLint samplerLoc = gl.getUniformLocation(m_programs[0]->getProgram(), "u_sampler");
206 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetUniformLocation()");
208 gl.bindTexture(GL_TEXTURE_2D, m_textures[0]);
209 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture()");
211 gl.uniform1i(samplerLoc, 0);
212 GLU_EXPECT_NO_ERROR(gl.getError(), "glUniform1i()");
214 gl.viewport(0, 0, VIEWPORT_WIDTH, VIEWPORT_HEIGHT);
215 GLU_EXPECT_NO_ERROR(gl.getError(), "glViewport()");
217 gl.depthFunc(GL_LEQUAL);
218 GLU_EXPECT_NO_ERROR(gl.getError(), "glDepthFunc()");
222 gl.enable(GL_DEPTH_TEST);
223 else if (stateId == 1)
224 gl.disable(GL_DEPTH_TEST);
230 ADD_TESTCASE(stencil_test, "Enable/Disable stencil test.",
234 requireCoordBuffers(1);
238 gl.useProgram(m_programs[0]->getProgram());
239 GLU_EXPECT_NO_ERROR(gl.getError(), "glUseProgram()");
240 GLint coordLoc = gl.getAttribLocation(m_programs[0]->getProgram(), "a_coord");
241 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetAttribLocation()");
243 gl.enableVertexAttribArray(coordLoc);
244 GLU_EXPECT_NO_ERROR(gl.getError(), "glEnableVertexAttribArray()");
245 gl.bindBuffer(GL_ARRAY_BUFFER, m_coordBuffers[0]);
246 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer()");
247 gl.vertexAttribPointer(coordLoc, 2, GL_FLOAT, GL_FALSE, 0, NULL);
248 GLU_EXPECT_NO_ERROR(gl.getError(), "glVertexAttribPointer()");
250 GLint samplerLoc = gl.getUniformLocation(m_programs[0]->getProgram(), "u_sampler");
251 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetUniformLocation()");
253 gl.bindTexture(GL_TEXTURE_2D, m_textures[0]);
254 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture()");
256 gl.uniform1i(samplerLoc, 0);
257 GLU_EXPECT_NO_ERROR(gl.getError(), "glUniform1i()");
259 gl.viewport(0, 0, VIEWPORT_WIDTH, VIEWPORT_HEIGHT);
260 GLU_EXPECT_NO_ERROR(gl.getError(), "glViewport()");
262 gl.stencilFunc(GL_LEQUAL, 0, 0);
263 GLU_EXPECT_NO_ERROR(gl.getError(), "glStencilFunc()");
265 gl.stencilOp(GL_KEEP, GL_REPLACE, GL_REPLACE);
266 GLU_EXPECT_NO_ERROR(gl.getError(), "glStencilOp()");
269 GLU_EXPECT_NO_ERROR(gl.getError(), "glClearStencil()");
270 gl.clear(GL_STENCIL_BUFFER_BIT);
272 GLU_EXPECT_NO_ERROR(gl.getError(), "glClear()");
276 gl.enable(GL_STENCIL_TEST);
277 else if (stateId == 1)
278 gl.disable(GL_STENCIL_TEST);
284 ADD_TESTCASE(scissor_test, "Enable/Disable scissor test.",
288 requireCoordBuffers(1);
292 gl.useProgram(m_programs[0]->getProgram());
293 GLU_EXPECT_NO_ERROR(gl.getError(), "glUseProgram()");
294 GLint coordLoc = gl.getAttribLocation(m_programs[0]->getProgram(), "a_coord");
295 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetAttribLocation()");
297 gl.enableVertexAttribArray(coordLoc);
298 GLU_EXPECT_NO_ERROR(gl.getError(), "glEnableVertexAttribArray()");
299 gl.bindBuffer(GL_ARRAY_BUFFER, m_coordBuffers[0]);
300 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer()");
301 gl.vertexAttribPointer(coordLoc, 2, GL_FLOAT, GL_FALSE, 0, NULL);
302 GLU_EXPECT_NO_ERROR(gl.getError(), "glVertexAttribPointer()");
304 GLint samplerLoc = gl.getUniformLocation(m_programs[0]->getProgram(), "u_sampler");
305 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetUniformLocation()");
307 gl.bindTexture(GL_TEXTURE_2D, m_textures[0]);
308 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture()");
310 gl.uniform1i(samplerLoc, 0);
311 GLU_EXPECT_NO_ERROR(gl.getError(), "glUniform1i()");
313 gl.viewport(0, 0, VIEWPORT_WIDTH, VIEWPORT_HEIGHT);
314 GLU_EXPECT_NO_ERROR(gl.getError(), "glViewport()");
316 gl.scissor(2, 3, 12, 13);
317 GLU_EXPECT_NO_ERROR(gl.getError(), "glScissor()");
321 gl.enable(GL_SCISSOR_TEST);
322 else if (stateId == 1)
323 gl.disable(GL_SCISSOR_TEST);
329 ADD_TESTCASE(dither, "Enable/Disable dithering.",
333 requireCoordBuffers(1);
337 gl.useProgram(m_programs[0]->getProgram());
338 GLU_EXPECT_NO_ERROR(gl.getError(), "glUseProgram()");
339 GLint coordLoc = gl.getAttribLocation(m_programs[0]->getProgram(), "a_coord");
340 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetAttribLocation()");
342 gl.enableVertexAttribArray(coordLoc);
343 GLU_EXPECT_NO_ERROR(gl.getError(), "glEnableVertexAttribArray()");
344 gl.bindBuffer(GL_ARRAY_BUFFER, m_coordBuffers[0]);
345 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer()");
346 gl.vertexAttribPointer(coordLoc, 2, GL_FLOAT, GL_FALSE, 0, NULL);
347 GLU_EXPECT_NO_ERROR(gl.getError(), "glVertexAttribPointer()");
349 GLint samplerLoc = gl.getUniformLocation(m_programs[0]->getProgram(), "u_sampler");
350 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetUniformLocation()");
352 gl.bindTexture(GL_TEXTURE_2D, m_textures[0]);
353 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture()");
355 gl.uniform1i(samplerLoc, 0);
356 GLU_EXPECT_NO_ERROR(gl.getError(), "glUniform1i()");
358 gl.viewport(0, 0, VIEWPORT_WIDTH, VIEWPORT_HEIGHT);
359 GLU_EXPECT_NO_ERROR(gl.getError(), "glViewport()");
363 gl.enable(GL_DITHER);
364 else if (stateId == 1)
365 gl.disable(GL_DITHER);
371 ADD_TESTCASE(culling, "Enable/Disable culling.",
375 requireCoordBuffers(1);
379 gl.useProgram(m_programs[0]->getProgram());
380 GLU_EXPECT_NO_ERROR(gl.getError(), "glUseProgram()");
381 GLint coordLoc = gl.getAttribLocation(m_programs[0]->getProgram(), "a_coord");
382 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetAttribLocation()");
384 gl.enableVertexAttribArray(coordLoc);
385 GLU_EXPECT_NO_ERROR(gl.getError(), "glEnableVertexAttribArray()");
386 gl.bindBuffer(GL_ARRAY_BUFFER, m_coordBuffers[0]);
387 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer()");
388 gl.vertexAttribPointer(coordLoc, 2, GL_FLOAT, GL_FALSE, 0, NULL);
389 GLU_EXPECT_NO_ERROR(gl.getError(), "glVertexAttribPointer()");
391 GLint samplerLoc = gl.getUniformLocation(m_programs[0]->getProgram(), "u_sampler");
392 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetUniformLocation()");
394 gl.bindTexture(GL_TEXTURE_2D, m_textures[0]);
395 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture()");
397 gl.uniform1i(samplerLoc, 0);
398 GLU_EXPECT_NO_ERROR(gl.getError(), "glUniform1i()");
400 gl.viewport(0, 0, VIEWPORT_WIDTH, VIEWPORT_HEIGHT);
401 GLU_EXPECT_NO_ERROR(gl.getError(), "glViewport()");
404 GLU_EXPECT_NO_ERROR(gl.getError(), "glFrontFace()");
406 gl.cullFace(GL_FRONT);
407 GLU_EXPECT_NO_ERROR(gl.getError(), "glCullFace()");
411 gl.enable(GL_CULL_FACE);
412 else if (stateId == 1)
413 gl.disable(GL_CULL_FACE);
419 ADD_TESTCASE(rasterizer_discard, "Enable/Disable RASTERIZER_DISCARD.",
423 requireCoordBuffers(1);
427 gl.useProgram(m_programs[0]->getProgram());
428 GLU_EXPECT_NO_ERROR(gl.getError(), "glUseProgram()");
429 GLint coordLoc = gl.getAttribLocation(m_programs[0]->getProgram(), "a_coord");
430 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetAttribLocation()");
432 gl.enableVertexAttribArray(coordLoc);
433 GLU_EXPECT_NO_ERROR(gl.getError(), "glEnableVertexAttribArray()");
434 gl.bindBuffer(GL_ARRAY_BUFFER, m_coordBuffers[0]);
435 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer()");
436 gl.vertexAttribPointer(coordLoc, 2, GL_FLOAT, GL_FALSE, 0, NULL);
437 GLU_EXPECT_NO_ERROR(gl.getError(), "glVertexAttribPointer()");
439 GLint samplerLoc = gl.getUniformLocation(m_programs[0]->getProgram(), "u_sampler");
440 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetUniformLocation()");
442 gl.bindTexture(GL_TEXTURE_2D, m_textures[0]);
443 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture()");
445 gl.uniform1i(samplerLoc, 0);
446 GLU_EXPECT_NO_ERROR(gl.getError(), "glUniform1i()");
448 gl.viewport(0, 0, VIEWPORT_WIDTH, VIEWPORT_HEIGHT);
449 GLU_EXPECT_NO_ERROR(gl.getError(), "glViewport()");
453 gl.enable(GL_RASTERIZER_DISCARD);
454 else if (stateId == 1)
455 gl.disable(GL_RASTERIZER_DISCARD);
461 ADD_TESTCASE(primitive_restart_fixed_index, "Enable/Disable PRIMITIVE_RESTART_FIXED_INDEX.",
465 requireCoordBuffers(1);
469 gl.useProgram(m_programs[0]->getProgram());
470 GLU_EXPECT_NO_ERROR(gl.getError(), "glUseProgram()");
471 GLint coordLoc = gl.getAttribLocation(m_programs[0]->getProgram(), "a_coord");
472 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetAttribLocation()");
474 gl.enableVertexAttribArray(coordLoc);
475 GLU_EXPECT_NO_ERROR(gl.getError(), "glEnableVertexAttribArray()");
476 gl.bindBuffer(GL_ARRAY_BUFFER, m_coordBuffers[0]);
477 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer()");
478 gl.vertexAttribPointer(coordLoc, 2, GL_FLOAT, GL_FALSE, 0, NULL);
479 GLU_EXPECT_NO_ERROR(gl.getError(), "glVertexAttribPointer()");
481 GLint samplerLoc = gl.getUniformLocation(m_programs[0]->getProgram(), "u_sampler");
482 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetUniformLocation()");
484 gl.bindTexture(GL_TEXTURE_2D, m_textures[0]);
485 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture()");
487 gl.uniform1i(samplerLoc, 0);
488 GLU_EXPECT_NO_ERROR(gl.getError(), "glUniform1i()");
490 gl.viewport(0, 0, VIEWPORT_WIDTH, VIEWPORT_HEIGHT);
491 GLU_EXPECT_NO_ERROR(gl.getError(), "glViewport()");
495 gl.enable(GL_PRIMITIVE_RESTART_FIXED_INDEX);
496 else if (stateId == 1)
497 gl.disable(GL_PRIMITIVE_RESTART_FIXED_INDEX);
503 ADD_TESTCASE(depth_func, "Change depth func.",
507 requireCoordBuffers(1);
511 gl.useProgram(m_programs[0]->getProgram());
512 GLU_EXPECT_NO_ERROR(gl.getError(), "glUseProgram()");
513 GLint coordLoc = gl.getAttribLocation(m_programs[0]->getProgram(), "a_coord");
514 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetAttribLocation()");
516 gl.enableVertexAttribArray(coordLoc);
517 GLU_EXPECT_NO_ERROR(gl.getError(), "glEnableVertexAttribArray()");
518 gl.bindBuffer(GL_ARRAY_BUFFER, m_coordBuffers[0]);
519 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer()");
520 gl.vertexAttribPointer(coordLoc, 2, GL_FLOAT, GL_FALSE, 0, NULL);
521 GLU_EXPECT_NO_ERROR(gl.getError(), "glVertexAttribPointer()");
523 GLint samplerLoc = gl.getUniformLocation(m_programs[0]->getProgram(), "u_sampler");
524 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetUniformLocation()");
526 gl.bindTexture(GL_TEXTURE_2D, m_textures[0]);
527 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture()");
529 gl.uniform1i(samplerLoc, 0);
530 GLU_EXPECT_NO_ERROR(gl.getError(), "glUniform1i()");
532 gl.viewport(0, 0, VIEWPORT_WIDTH, VIEWPORT_HEIGHT);
533 GLU_EXPECT_NO_ERROR(gl.getError(), "glViewport()");
535 gl.enable(GL_DEPTH_TEST);
536 GLU_EXPECT_NO_ERROR(gl.getError(), "glEnable()");
540 gl.depthFunc(GL_GEQUAL);
541 else if (stateId == 1)
542 gl.depthFunc(GL_LEQUAL);
549 ADD_TESTCASE(depth_mask, "Toggle depth mask.",
553 requireCoordBuffers(1);
557 gl.useProgram(m_programs[0]->getProgram());
558 GLU_EXPECT_NO_ERROR(gl.getError(), "glUseProgram()");
559 GLint coordLoc = gl.getAttribLocation(m_programs[0]->getProgram(), "a_coord");
560 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetAttribLocation()");
562 gl.enableVertexAttribArray(coordLoc);
563 GLU_EXPECT_NO_ERROR(gl.getError(), "glEnableVertexAttribArray()");
564 gl.bindBuffer(GL_ARRAY_BUFFER, m_coordBuffers[0]);
565 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer()");
566 gl.vertexAttribPointer(coordLoc, 2, GL_FLOAT, GL_FALSE, 0, NULL);
567 GLU_EXPECT_NO_ERROR(gl.getError(), "glVertexAttribPointer()");
569 GLint samplerLoc = gl.getUniformLocation(m_programs[0]->getProgram(), "u_sampler");
570 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetUniformLocation()");
572 gl.bindTexture(GL_TEXTURE_2D, m_textures[0]);
573 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture()");
575 gl.uniform1i(samplerLoc, 0);
576 GLU_EXPECT_NO_ERROR(gl.getError(), "glUniform1i()");
578 gl.viewport(0, 0, VIEWPORT_WIDTH, VIEWPORT_HEIGHT);
579 GLU_EXPECT_NO_ERROR(gl.getError(), "glViewport()");
581 gl.enable(GL_DEPTH_TEST);
582 GLU_EXPECT_NO_ERROR(gl.getError(), "glEnable()");
584 gl.depthFunc(GL_LEQUAL);
585 GLU_EXPECT_NO_ERROR(gl.getError(), "glDepthFunc()");
589 gl.depthMask(GL_FALSE);
590 else if (stateId == 1)
591 gl.depthMask(GL_TRUE);
597 ADD_TESTCASE(depth_rangef, "Change depth range.",
601 requireCoordBuffers(1);
605 gl.useProgram(m_programs[0]->getProgram());
606 GLU_EXPECT_NO_ERROR(gl.getError(), "glUseProgram()");
607 GLint coordLoc = gl.getAttribLocation(m_programs[0]->getProgram(), "a_coord");
608 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetAttribLocation()");
610 gl.enableVertexAttribArray(coordLoc);
611 GLU_EXPECT_NO_ERROR(gl.getError(), "glEnableVertexAttribArray()");
612 gl.bindBuffer(GL_ARRAY_BUFFER, m_coordBuffers[0]);
613 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer()");
614 gl.vertexAttribPointer(coordLoc, 2, GL_FLOAT, GL_FALSE, 0, NULL);
615 GLU_EXPECT_NO_ERROR(gl.getError(), "glVertexAttribPointer()");
617 GLint samplerLoc = gl.getUniformLocation(m_programs[0]->getProgram(), "u_sampler");
618 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetUniformLocation()");
620 gl.bindTexture(GL_TEXTURE_2D, m_textures[0]);
621 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture()");
623 gl.uniform1i(samplerLoc, 0);
624 GLU_EXPECT_NO_ERROR(gl.getError(), "glUniform1i()");
626 gl.viewport(0, 0, VIEWPORT_WIDTH, VIEWPORT_HEIGHT);
627 GLU_EXPECT_NO_ERROR(gl.getError(), "glViewport()");
631 gl.depthRangef(0.0f, 1.0f);
632 else if (stateId == 1)
633 gl.depthRangef(0.25f, 0.75f);
639 ADD_TESTCASE(blend_equation, "Change blend equation.",
643 requireCoordBuffers(1);
647 gl.useProgram(m_programs[0]->getProgram());
648 GLU_EXPECT_NO_ERROR(gl.getError(), "glUseProgram()");
649 GLint coordLoc = gl.getAttribLocation(m_programs[0]->getProgram(), "a_coord");
650 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetAttribLocation()");
652 gl.enableVertexAttribArray(coordLoc);
653 GLU_EXPECT_NO_ERROR(gl.getError(), "glEnableVertexAttribArray()");
654 gl.bindBuffer(GL_ARRAY_BUFFER, m_coordBuffers[0]);
655 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer()");
656 gl.vertexAttribPointer(coordLoc, 2, GL_FLOAT, GL_FALSE, 0, NULL);
657 GLU_EXPECT_NO_ERROR(gl.getError(), "glVertexAttribPointer()");
659 GLint samplerLoc = gl.getUniformLocation(m_programs[0]->getProgram(), "u_sampler");
660 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetUniformLocation()");
662 gl.bindTexture(GL_TEXTURE_2D, m_textures[0]);
663 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture()");
665 gl.uniform1i(samplerLoc, 0);
666 GLU_EXPECT_NO_ERROR(gl.getError(), "glUniform1i()");
668 gl.viewport(0, 0, VIEWPORT_WIDTH, VIEWPORT_HEIGHT);
669 GLU_EXPECT_NO_ERROR(gl.getError(), "glViewport()");
672 GLU_EXPECT_NO_ERROR(gl.getError(), "glEnable()");
676 gl.blendEquation(GL_FUNC_SUBTRACT);
677 else if (stateId == 1)
678 gl.blendEquation(GL_FUNC_ADD);
684 ADD_TESTCASE(blend_func, "Change blend function.",
688 requireCoordBuffers(1);
692 gl.useProgram(m_programs[0]->getProgram());
693 GLU_EXPECT_NO_ERROR(gl.getError(), "glUseProgram()");
694 GLint coordLoc = gl.getAttribLocation(m_programs[0]->getProgram(), "a_coord");
695 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetAttribLocation()");
697 gl.enableVertexAttribArray(coordLoc);
698 GLU_EXPECT_NO_ERROR(gl.getError(), "glEnableVertexAttribArray()");
699 gl.bindBuffer(GL_ARRAY_BUFFER, m_coordBuffers[0]);
700 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer()");
701 gl.vertexAttribPointer(coordLoc, 2, GL_FLOAT, GL_FALSE, 0, NULL);
702 GLU_EXPECT_NO_ERROR(gl.getError(), "glVertexAttribPointer()");
704 GLint samplerLoc = gl.getUniformLocation(m_programs[0]->getProgram(), "u_sampler");
705 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetUniformLocation()");
707 gl.bindTexture(GL_TEXTURE_2D, m_textures[0]);
708 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture()");
710 gl.uniform1i(samplerLoc, 0);
711 GLU_EXPECT_NO_ERROR(gl.getError(), "glUniform1i()");
713 gl.viewport(0, 0, VIEWPORT_WIDTH, VIEWPORT_HEIGHT);
714 GLU_EXPECT_NO_ERROR(gl.getError(), "glViewport()");
717 GLU_EXPECT_NO_ERROR(gl.getError(), "glEnable()");
721 gl.blendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
722 else if (stateId == 1)
723 gl.blendFunc(GL_ONE, GL_ONE);
729 ADD_TESTCASE(polygon_offset, "Change polygon offset.",
733 requireCoordBuffers(1);
737 gl.useProgram(m_programs[0]->getProgram());
738 GLU_EXPECT_NO_ERROR(gl.getError(), "glUseProgram()");
739 GLint coordLoc = gl.getAttribLocation(m_programs[0]->getProgram(), "a_coord");
740 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetAttribLocation()");
742 gl.enableVertexAttribArray(coordLoc);
743 GLU_EXPECT_NO_ERROR(gl.getError(), "glEnableVertexAttribArray()");
744 gl.bindBuffer(GL_ARRAY_BUFFER, m_coordBuffers[0]);
745 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer()");
746 gl.vertexAttribPointer(coordLoc, 2, GL_FLOAT, GL_FALSE, 0, NULL);
747 GLU_EXPECT_NO_ERROR(gl.getError(), "glVertexAttribPointer()");
749 GLint samplerLoc = gl.getUniformLocation(m_programs[0]->getProgram(), "u_sampler");
750 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetUniformLocation()");
752 gl.bindTexture(GL_TEXTURE_2D, m_textures[0]);
753 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture()");
755 gl.uniform1i(samplerLoc, 0);
756 GLU_EXPECT_NO_ERROR(gl.getError(), "glUniform1i()");
758 gl.viewport(0, 0, VIEWPORT_WIDTH, VIEWPORT_HEIGHT);
759 GLU_EXPECT_NO_ERROR(gl.getError(), "glViewport()");
761 gl.enable(GL_POLYGON_OFFSET_FILL);
762 GLU_EXPECT_NO_ERROR(gl.getError(), "glEnable()");
766 gl.polygonOffset(0.0f, 0.0f);
767 else if (stateId == 1)
768 gl.polygonOffset(0.1f, 0.1f);
774 ADD_TESTCASE(sample_coverage, "Sample coverage.",
778 requireCoordBuffers(1);
782 gl.useProgram(m_programs[0]->getProgram());
783 GLU_EXPECT_NO_ERROR(gl.getError(), "glUseProgram()");
784 GLint coordLoc = gl.getAttribLocation(m_programs[0]->getProgram(), "a_coord");
785 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetAttribLocation()");
787 gl.enableVertexAttribArray(coordLoc);
788 GLU_EXPECT_NO_ERROR(gl.getError(), "glEnableVertexAttribArray()");
789 gl.bindBuffer(GL_ARRAY_BUFFER, m_coordBuffers[0]);
790 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer()");
791 gl.vertexAttribPointer(coordLoc, 2, GL_FLOAT, GL_FALSE, 0, NULL);
792 GLU_EXPECT_NO_ERROR(gl.getError(), "glVertexAttribPointer()");
794 GLint samplerLoc = gl.getUniformLocation(m_programs[0]->getProgram(), "u_sampler");
795 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetUniformLocation()");
797 gl.bindTexture(GL_TEXTURE_2D, m_textures[0]);
798 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture()");
800 gl.uniform1i(samplerLoc, 0);
801 GLU_EXPECT_NO_ERROR(gl.getError(), "glUniform1i()");
803 gl.viewport(0, 0, VIEWPORT_WIDTH, VIEWPORT_HEIGHT);
804 GLU_EXPECT_NO_ERROR(gl.getError(), "glViewport()");
808 gl.sampleCoverage(0.25f, GL_TRUE);
809 else if (stateId == 1)
810 gl.sampleCoverage(0.75f, GL_FALSE);
816 ADD_TESTCASE(viewport, "Change viewport.",
820 requireCoordBuffers(1);
824 gl.useProgram(m_programs[0]->getProgram());
825 GLU_EXPECT_NO_ERROR(gl.getError(), "glUseProgram()");
826 GLint coordLoc = gl.getAttribLocation(m_programs[0]->getProgram(), "a_coord");
827 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetAttribLocation()");
829 gl.enableVertexAttribArray(coordLoc);
830 GLU_EXPECT_NO_ERROR(gl.getError(), "glEnableVertexAttribArray()");
831 gl.bindBuffer(GL_ARRAY_BUFFER, m_coordBuffers[0]);
832 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer()");
833 gl.vertexAttribPointer(coordLoc, 2, GL_FLOAT, GL_FALSE, 0, NULL);
834 GLU_EXPECT_NO_ERROR(gl.getError(), "glVertexAttribPointer()");
836 GLint samplerLoc = gl.getUniformLocation(m_programs[0]->getProgram(), "u_sampler");
837 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetUniformLocation()");
839 gl.bindTexture(GL_TEXTURE_2D, m_textures[0]);
840 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture()");
842 gl.uniform1i(samplerLoc, 0);
843 GLU_EXPECT_NO_ERROR(gl.getError(), "glUniform1i()");
845 gl.viewport(0, 0, VIEWPORT_WIDTH, VIEWPORT_HEIGHT);
846 GLU_EXPECT_NO_ERROR(gl.getError(), "glViewport()");
850 gl.viewport(10, 11, 5, 6);
851 else if (stateId == 1)
852 gl.viewport(2, 3, 17, 14);
858 ADD_TESTCASE(scissor, "Change scissor box.",
862 requireCoordBuffers(1);
866 gl.useProgram(m_programs[0]->getProgram());
867 GLU_EXPECT_NO_ERROR(gl.getError(), "glUseProgram()");
868 GLint coordLoc = gl.getAttribLocation(m_programs[0]->getProgram(), "a_coord");
869 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetAttribLocation()");
871 gl.enableVertexAttribArray(coordLoc);
872 GLU_EXPECT_NO_ERROR(gl.getError(), "glEnableVertexAttribArray()");
873 gl.bindBuffer(GL_ARRAY_BUFFER, m_coordBuffers[0]);
874 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer()");
875 gl.vertexAttribPointer(coordLoc, 2, GL_FLOAT, GL_FALSE, 0, NULL);
876 GLU_EXPECT_NO_ERROR(gl.getError(), "glVertexAttribPointer()");
878 GLint samplerLoc = gl.getUniformLocation(m_programs[0]->getProgram(), "u_sampler");
879 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetUniformLocation()");
881 gl.bindTexture(GL_TEXTURE_2D, m_textures[0]);
882 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture()");
884 gl.uniform1i(samplerLoc, 0);
885 GLU_EXPECT_NO_ERROR(gl.getError(), "glUniform1i()");
887 gl.viewport(0, 0, VIEWPORT_WIDTH, VIEWPORT_HEIGHT);
888 GLU_EXPECT_NO_ERROR(gl.getError(), "glViewport()");
890 gl.enable(GL_SCISSOR_TEST);
891 GLU_EXPECT_NO_ERROR(gl.getError(), "glEnable()");
895 gl.scissor(17, 13, 5, 8);
896 else if (stateId == 1)
897 gl.scissor(7, 3, 13, 13);
903 ADD_TESTCASE(color_mask, "Change color mask.",
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()");
937 gl.colorMask(GL_TRUE, GL_FALSE, GL_TRUE, GL_FALSE);
938 else if (stateId == 1)
939 gl.colorMask(GL_FALSE, GL_TRUE, GL_FALSE, GL_TRUE);
945 ADD_TESTCASE(cull_face, "Change culling mode.",
949 requireCoordBuffers(1);
953 gl.useProgram(m_programs[0]->getProgram());
954 GLU_EXPECT_NO_ERROR(gl.getError(), "glUseProgram()");
955 GLint coordLoc = gl.getAttribLocation(m_programs[0]->getProgram(), "a_coord");
956 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetAttribLocation()");
958 gl.enableVertexAttribArray(coordLoc);
959 GLU_EXPECT_NO_ERROR(gl.getError(), "glEnableVertexAttribArray()");
960 gl.bindBuffer(GL_ARRAY_BUFFER, m_coordBuffers[0]);
961 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer()");
962 gl.vertexAttribPointer(coordLoc, 2, GL_FLOAT, GL_FALSE, 0, NULL);
963 GLU_EXPECT_NO_ERROR(gl.getError(), "glVertexAttribPointer()");
965 GLint samplerLoc = gl.getUniformLocation(m_programs[0]->getProgram(), "u_sampler");
966 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetUniformLocation()");
968 gl.bindTexture(GL_TEXTURE_2D, m_textures[0]);
969 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture()");
971 gl.uniform1i(samplerLoc, 0);
972 GLU_EXPECT_NO_ERROR(gl.getError(), "glUniform1i()");
974 gl.viewport(0, 0, VIEWPORT_WIDTH, VIEWPORT_HEIGHT);
975 GLU_EXPECT_NO_ERROR(gl.getError(), "glViewport()");
977 gl.enable(GL_CULL_FACE);
978 GLU_EXPECT_NO_ERROR(gl.getError(), "glEnable()");
982 gl.cullFace(GL_FRONT);
983 else if (stateId == 1)
984 gl.cullFace(GL_BACK);
990 ADD_TESTCASE(front_face, "Change front face.",
994 requireCoordBuffers(1);
998 gl.useProgram(m_programs[0]->getProgram());
999 GLU_EXPECT_NO_ERROR(gl.getError(), "glUseProgram()");
1000 GLint coordLoc = gl.getAttribLocation(m_programs[0]->getProgram(), "a_coord");
1001 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetAttribLocation()");
1003 gl.enableVertexAttribArray(coordLoc);
1004 GLU_EXPECT_NO_ERROR(gl.getError(), "glEnableVertexAttribArray()");
1005 gl.bindBuffer(GL_ARRAY_BUFFER, m_coordBuffers[0]);
1006 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer()");
1007 gl.vertexAttribPointer(coordLoc, 2, GL_FLOAT, GL_FALSE, 0, NULL);
1008 GLU_EXPECT_NO_ERROR(gl.getError(), "glVertexAttribPointer()");
1010 GLint samplerLoc = gl.getUniformLocation(m_programs[0]->getProgram(), "u_sampler");
1011 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetUniformLocation()");
1013 gl.bindTexture(GL_TEXTURE_2D, m_textures[0]);
1014 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture()");
1016 gl.uniform1i(samplerLoc, 0);
1017 GLU_EXPECT_NO_ERROR(gl.getError(), "glUniform1i()");
1019 gl.viewport(0, 0, VIEWPORT_WIDTH, VIEWPORT_HEIGHT);
1020 GLU_EXPECT_NO_ERROR(gl.getError(), "glViewport()");
1022 gl.enable(GL_CULL_FACE);
1023 GLU_EXPECT_NO_ERROR(gl.getError(), "glEnable()");
1027 gl.frontFace(GL_CCW);
1028 else if (stateId == 1)
1029 gl.frontFace(GL_CW);
1035 ADD_TESTCASE(stencil_mask, "Change stencil mask.",
1039 requireCoordBuffers(1);
1043 gl.useProgram(m_programs[0]->getProgram());
1044 GLU_EXPECT_NO_ERROR(gl.getError(), "glUseProgram()");
1045 GLint coordLoc = gl.getAttribLocation(m_programs[0]->getProgram(), "a_coord");
1046 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetAttribLocation()");
1048 gl.enableVertexAttribArray(coordLoc);
1049 GLU_EXPECT_NO_ERROR(gl.getError(), "glEnableVertexAttribArray()");
1050 gl.bindBuffer(GL_ARRAY_BUFFER, m_coordBuffers[0]);
1051 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer()");
1052 gl.vertexAttribPointer(coordLoc, 2, GL_FLOAT, GL_FALSE, 0, NULL);
1053 GLU_EXPECT_NO_ERROR(gl.getError(), "glVertexAttribPointer()");
1055 GLint samplerLoc = gl.getUniformLocation(m_programs[0]->getProgram(), "u_sampler");
1056 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetUniformLocation()");
1058 gl.bindTexture(GL_TEXTURE_2D, m_textures[0]);
1059 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture()");
1061 gl.uniform1i(samplerLoc, 0);
1062 GLU_EXPECT_NO_ERROR(gl.getError(), "glUniform1i()");
1064 gl.viewport(0, 0, VIEWPORT_WIDTH, VIEWPORT_HEIGHT);
1065 GLU_EXPECT_NO_ERROR(gl.getError(), "glViewport()");
1067 gl.enable(GL_STENCIL_TEST);
1068 GLU_EXPECT_NO_ERROR(gl.getError(), "glEnable()");
1070 gl.stencilFunc(GL_LEQUAL, 0, 0);
1071 GLU_EXPECT_NO_ERROR(gl.getError(), "glStencilFunc()");
1073 gl.stencilOp(GL_KEEP, GL_REPLACE, GL_REPLACE);
1074 GLU_EXPECT_NO_ERROR(gl.getError(), "glStencilOp()");
1077 GLU_EXPECT_NO_ERROR(gl.getError(), "glClearStencil()");
1078 gl.clear(GL_STENCIL_BUFFER_BIT);
1079 GLU_EXPECT_NO_ERROR(gl.getError(), "glClear()");
1083 gl.stencilMask(0xDD);
1084 else if (stateId == 1)
1085 gl.stencilMask(~0xDD);
1091 ADD_TESTCASE(stencil_func, "Change stencil func.",
1095 requireCoordBuffers(1);
1099 gl.useProgram(m_programs[0]->getProgram());
1100 GLU_EXPECT_NO_ERROR(gl.getError(), "glUseProgram()");
1101 GLint coordLoc = gl.getAttribLocation(m_programs[0]->getProgram(), "a_coord");
1102 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetAttribLocation()");
1104 gl.enableVertexAttribArray(coordLoc);
1105 GLU_EXPECT_NO_ERROR(gl.getError(), "glEnableVertexAttribArray()");
1106 gl.bindBuffer(GL_ARRAY_BUFFER, m_coordBuffers[0]);
1107 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer()");
1108 gl.vertexAttribPointer(coordLoc, 2, GL_FLOAT, GL_FALSE, 0, NULL);
1109 GLU_EXPECT_NO_ERROR(gl.getError(), "glVertexAttribPointer()");
1111 GLint samplerLoc = gl.getUniformLocation(m_programs[0]->getProgram(), "u_sampler");
1112 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetUniformLocation()");
1114 gl.bindTexture(GL_TEXTURE_2D, m_textures[0]);
1115 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture()");
1117 gl.uniform1i(samplerLoc, 0);
1118 GLU_EXPECT_NO_ERROR(gl.getError(), "glUniform1i()");
1120 gl.viewport(0, 0, VIEWPORT_WIDTH, VIEWPORT_HEIGHT);
1121 GLU_EXPECT_NO_ERROR(gl.getError(), "glViewport()");
1123 gl.enable(GL_STENCIL_TEST);
1124 GLU_EXPECT_NO_ERROR(gl.getError(), "glEnable()");
1126 gl.stencilOp(GL_KEEP, GL_REPLACE, GL_REPLACE);
1127 GLU_EXPECT_NO_ERROR(gl.getError(), "glStencilOp()");
1129 GLU_EXPECT_NO_ERROR(gl.getError(), "glClearStencil()");
1130 gl.clear(GL_STENCIL_BUFFER_BIT);
1131 GLU_EXPECT_NO_ERROR(gl.getError(), "glClear()");
1135 gl.stencilFunc(GL_LEQUAL, 0, 0xFF);
1136 else if (stateId == 1)
1137 gl.stencilFunc(GL_GEQUAL, 0, 0x00);
1143 ADD_TESTCASE(stencil_op, "Change stencil op.",
1147 requireCoordBuffers(1);
1151 gl.useProgram(m_programs[0]->getProgram());
1152 GLU_EXPECT_NO_ERROR(gl.getError(), "glUseProgram()");
1153 GLint coordLoc = gl.getAttribLocation(m_programs[0]->getProgram(), "a_coord");
1154 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetAttribLocation()");
1156 gl.enableVertexAttribArray(coordLoc);
1157 GLU_EXPECT_NO_ERROR(gl.getError(), "glEnableVertexAttribArray()");
1158 gl.bindBuffer(GL_ARRAY_BUFFER, m_coordBuffers[0]);
1159 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer()");
1160 gl.vertexAttribPointer(coordLoc, 2, GL_FLOAT, GL_FALSE, 0, NULL);
1161 GLU_EXPECT_NO_ERROR(gl.getError(), "glVertexAttribPointer()");
1163 GLint samplerLoc = gl.getUniformLocation(m_programs[0]->getProgram(), "u_sampler");
1164 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetUniformLocation()");
1166 gl.bindTexture(GL_TEXTURE_2D, m_textures[0]);
1167 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture()");
1169 gl.uniform1i(samplerLoc, 0);
1170 GLU_EXPECT_NO_ERROR(gl.getError(), "glUniform1i()");
1172 gl.viewport(0, 0, VIEWPORT_WIDTH, VIEWPORT_HEIGHT);
1173 GLU_EXPECT_NO_ERROR(gl.getError(), "glViewport()");
1175 gl.enable(GL_STENCIL_TEST);
1176 GLU_EXPECT_NO_ERROR(gl.getError(), "glEnable()");
1178 gl.stencilFunc(GL_LEQUAL, 0, 0);
1179 GLU_EXPECT_NO_ERROR(gl.getError(), "glStencilFunc()");
1182 GLU_EXPECT_NO_ERROR(gl.getError(), "glClearStencil()");
1184 gl.clear(GL_STENCIL_BUFFER_BIT);
1185 GLU_EXPECT_NO_ERROR(gl.getError(), "glClear()");
1189 gl.stencilOp(GL_KEEP, GL_REPLACE, GL_REPLACE);
1190 else if (stateId == 1)
1191 gl.stencilOp(GL_REPLACE, GL_KEEP, GL_KEEP);
1197 ADD_TESTCASE(bind_array_buffer, "Change array buffer and refresh vertex attrib pointer.",
1201 requireCoordBuffers(2);
1205 gl.bindAttribLocation(m_programs[0]->getProgram(), 0, "a_coord");
1206 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindAttribLocation()");
1207 gl.linkProgram(m_programs[0]->getProgram());
1208 GLU_EXPECT_NO_ERROR(gl.getError(), "glLinkProgram()");
1210 gl.useProgram(m_programs[0]->getProgram());
1211 GLU_EXPECT_NO_ERROR(gl.getError(), "glUseProgram()");
1213 gl.enableVertexAttribArray(0);
1214 GLU_EXPECT_NO_ERROR(gl.getError(), "glEnableVertexAttribArray()");
1215 gl.bindBuffer(GL_ARRAY_BUFFER, m_coordBuffers[0]);
1216 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer()");
1217 gl.vertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 0, NULL);
1218 GLU_EXPECT_NO_ERROR(gl.getError(), "glVertexAttribPointer()");
1220 GLint samplerLoc = gl.getUniformLocation(m_programs[0]->getProgram(), "u_sampler");
1221 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetUniformLocation()");
1223 gl.bindTexture(GL_TEXTURE_2D, m_textures[0]);
1224 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture()");
1226 gl.uniform1i(samplerLoc, 0);
1227 GLU_EXPECT_NO_ERROR(gl.getError(), "glUniform1i()");
1229 gl.viewport(0, 0, VIEWPORT_WIDTH, VIEWPORT_HEIGHT);
1230 GLU_EXPECT_NO_ERROR(gl.getError(), "glViewport()");
1235 gl.bindBuffer(GL_ARRAY_BUFFER, m_coordBuffers[0]);
1236 gl.vertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 0, NULL);
1238 else if (stateId == 1)
1240 gl.bindBuffer(GL_ARRAY_BUFFER, m_coordBuffers[1]);
1241 gl.vertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 0, NULL);
1248 ADD_TESTCASE(element_array_buffer, "Change element array buffer.",
1252 requireCoordBuffers(1);
1253 requireIndexBuffers(2);
1257 gl.useProgram(m_programs[0]->getProgram());
1258 GLU_EXPECT_NO_ERROR(gl.getError(), "glUseProgram()");
1259 GLint coordLoc = gl.getAttribLocation(m_programs[0]->getProgram(), "a_coord");
1260 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetAttribLocation()");
1262 gl.enableVertexAttribArray(coordLoc);
1263 GLU_EXPECT_NO_ERROR(gl.getError(), "glEnableVertexAttribArray()");
1264 gl.bindBuffer(GL_ARRAY_BUFFER, m_coordBuffers[0]);
1265 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer()");
1266 gl.vertexAttribPointer(coordLoc, 2, GL_FLOAT, GL_FALSE, 0, NULL);
1267 GLU_EXPECT_NO_ERROR(gl.getError(), "glVertexAttribPointer()");
1269 GLint samplerLoc = gl.getUniformLocation(m_programs[0]->getProgram(), "u_sampler");
1270 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetUniformLocation()");
1272 gl.bindTexture(GL_TEXTURE_2D, m_textures[0]);
1273 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture()");
1275 gl.uniform1i(samplerLoc, 0);
1276 GLU_EXPECT_NO_ERROR(gl.getError(), "glUniform1i()");
1278 gl.viewport(0, 0, VIEWPORT_WIDTH, VIEWPORT_HEIGHT);
1279 GLU_EXPECT_NO_ERROR(gl.getError(), "glViewport()");
1281 gl.bindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_indexBuffers[0]);
1282 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer()");
1286 gl.bindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_indexBuffers[0]);
1287 else if (stateId == 1)
1288 gl.bindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_indexBuffers[1]);
1294 ADD_TESTCASE(bind_texture, "Change texture binding.",
1298 requireCoordBuffers(1);
1302 gl.useProgram(m_programs[0]->getProgram());
1303 GLU_EXPECT_NO_ERROR(gl.getError(), "glUseProgram()");
1304 GLint coordLoc = gl.getAttribLocation(m_programs[0]->getProgram(), "a_coord");
1305 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetAttribLocation()");
1307 gl.enableVertexAttribArray(coordLoc);
1308 GLU_EXPECT_NO_ERROR(gl.getError(), "glEnableVertexAttribArray()");
1309 gl.bindBuffer(GL_ARRAY_BUFFER, m_coordBuffers[0]);
1310 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer()");
1311 gl.vertexAttribPointer(coordLoc, 2, GL_FLOAT, GL_FALSE, 0, NULL);
1312 GLU_EXPECT_NO_ERROR(gl.getError(), "glVertexAttribPointer()");
1314 GLint samplerLoc = gl.getUniformLocation(m_programs[0]->getProgram(), "u_sampler");
1315 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetUniformLocation()");
1317 gl.bindTexture(GL_TEXTURE_2D, m_textures[0]);
1318 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture()");
1320 gl.uniform1i(samplerLoc, 0);
1321 GLU_EXPECT_NO_ERROR(gl.getError(), "glUniform1i()");
1323 gl.viewport(0, 0, VIEWPORT_WIDTH, VIEWPORT_HEIGHT);
1324 GLU_EXPECT_NO_ERROR(gl.getError(), "glViewport()");
1328 gl.bindTexture(GL_TEXTURE_2D, m_textures[0]);
1329 else if (stateId == 1)
1330 gl.bindTexture(GL_TEXTURE_2D, m_textures[1]);
1336 ADD_TESTCASE(use_program, "Change used program.",
1340 requireCoordBuffers(1);
1344 GLint coordLoc = gl.getAttribLocation(m_programs[0]->getProgram(), "a_coord");
1345 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetAttribLocation()");
1347 gl.enableVertexAttribArray(coordLoc);
1348 GLU_EXPECT_NO_ERROR(gl.getError(), "glEnableVertexAttribArray()");
1349 gl.bindBuffer(GL_ARRAY_BUFFER, m_coordBuffers[0]);
1350 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer()");
1351 gl.vertexAttribPointer(coordLoc, 2, GL_FLOAT, GL_FALSE, 0, NULL);
1352 GLU_EXPECT_NO_ERROR(gl.getError(), "glVertexAttribPointer()");
1354 gl.bindTexture(GL_TEXTURE_2D, m_textures[0]);
1355 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture()");
1358 GLint samplerLoc = gl.getUniformLocation(m_programs[0]->getProgram(), "u_sampler");
1359 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetUniformLocation()");
1360 gl.useProgram(m_programs[0]->getProgram());
1361 GLU_EXPECT_NO_ERROR(gl.getError(), "glUseProgram()");
1362 gl.uniform1i(samplerLoc, 0);
1363 GLU_EXPECT_NO_ERROR(gl.getError(), "glUniform1i()");
1367 GLint samplerLoc = gl.getUniformLocation(m_programs[1]->getProgram(), "u_sampler");
1368 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetUniformLocation()");
1369 gl.useProgram(m_programs[1]->getProgram());
1370 GLU_EXPECT_NO_ERROR(gl.getError(), "glUseProgram()");
1371 gl.uniform1i(samplerLoc, 0);
1372 GLU_EXPECT_NO_ERROR(gl.getError(), "glUniform1i()");
1375 gl.viewport(0, 0, VIEWPORT_WIDTH, VIEWPORT_HEIGHT);
1376 GLU_EXPECT_NO_ERROR(gl.getError(), "glViewport()");
1380 gl.useProgram(m_programs[0]->getProgram());
1381 else if (stateId == 1)
1382 gl.useProgram(m_programs[1]->getProgram());
1388 ADD_TESTCASE(tex_parameter_min_filter, "Change texture parameter min filter.",
1392 requireCoordBuffers(1);
1396 gl.useProgram(m_programs[0]->getProgram());
1397 GLU_EXPECT_NO_ERROR(gl.getError(), "glUseProgram()");
1398 GLint coordLoc = gl.getAttribLocation(m_programs[0]->getProgram(), "a_coord");
1399 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetAttribLocation()");
1401 gl.enableVertexAttribArray(coordLoc);
1402 GLU_EXPECT_NO_ERROR(gl.getError(), "glEnableVertexAttribArray()");
1403 gl.bindBuffer(GL_ARRAY_BUFFER, m_coordBuffers[0]);
1404 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer()");
1405 gl.vertexAttribPointer(coordLoc, 2, GL_FLOAT, GL_FALSE, 0, NULL);
1406 GLU_EXPECT_NO_ERROR(gl.getError(), "glVertexAttribPointer()");
1408 GLint samplerLoc = gl.getUniformLocation(m_programs[0]->getProgram(), "u_sampler");
1409 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetUniformLocation()");
1411 gl.bindTexture(GL_TEXTURE_2D, m_textures[0]);
1412 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture()");
1414 gl.uniform1i(samplerLoc, 0);
1415 GLU_EXPECT_NO_ERROR(gl.getError(), "glUniform1i()");
1417 gl.viewport(0, 0, VIEWPORT_WIDTH, VIEWPORT_HEIGHT);
1418 GLU_EXPECT_NO_ERROR(gl.getError(), "glViewport()");
1422 gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
1423 else if (stateId == 1)
1424 gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
1430 ADD_TESTCASE(tex_parameter_mag_filter, "Change texture parameter mag filter.",
1434 requireCoordBuffers(1);
1438 gl.useProgram(m_programs[0]->getProgram());
1439 GLU_EXPECT_NO_ERROR(gl.getError(), "glUseProgram()");
1440 GLint coordLoc = gl.getAttribLocation(m_programs[0]->getProgram(), "a_coord");
1441 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetAttribLocation()");
1443 gl.enableVertexAttribArray(coordLoc);
1444 GLU_EXPECT_NO_ERROR(gl.getError(), "glEnableVertexAttribArray()");
1445 gl.bindBuffer(GL_ARRAY_BUFFER, m_coordBuffers[0]);
1446 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer()");
1447 gl.vertexAttribPointer(coordLoc, 2, GL_FLOAT, GL_FALSE, 0, NULL);
1448 GLU_EXPECT_NO_ERROR(gl.getError(), "glVertexAttribPointer()");
1450 GLint samplerLoc = gl.getUniformLocation(m_programs[0]->getProgram(), "u_sampler");
1451 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetUniformLocation()");
1453 gl.bindTexture(GL_TEXTURE_2D, m_textures[0]);
1454 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture()");
1456 gl.uniform1i(samplerLoc, 0);
1457 GLU_EXPECT_NO_ERROR(gl.getError(), "glUniform1i()");
1459 gl.viewport(0, 0, VIEWPORT_WIDTH, VIEWPORT_HEIGHT);
1460 GLU_EXPECT_NO_ERROR(gl.getError(), "glViewport()");
1464 gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
1465 else if (stateId == 1)
1466 gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
1472 ADD_TESTCASE(tex_parameter_wrap, "Change texture parameter wrap filter.",
1476 requireCoordBuffers(1);
1480 gl.useProgram(m_programs[0]->getProgram());
1481 GLU_EXPECT_NO_ERROR(gl.getError(), "glUseProgram()");
1482 GLint coordLoc = gl.getAttribLocation(m_programs[0]->getProgram(), "a_coord");
1483 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetAttribLocation()");
1485 gl.enableVertexAttribArray(coordLoc);
1486 GLU_EXPECT_NO_ERROR(gl.getError(), "glEnableVertexAttribArray()");
1487 gl.bindBuffer(GL_ARRAY_BUFFER, m_coordBuffers[0]);
1488 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer()");
1489 gl.vertexAttribPointer(coordLoc, 2, GL_FLOAT, GL_FALSE, 0, NULL);
1490 GLU_EXPECT_NO_ERROR(gl.getError(), "glVertexAttribPointer()");
1492 GLint samplerLoc = gl.getUniformLocation(m_programs[0]->getProgram(), "u_sampler");
1493 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetUniformLocation()");
1495 gl.bindTexture(GL_TEXTURE_2D, m_textures[0]);
1496 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture()");
1498 gl.uniform1i(samplerLoc, 0);
1499 GLU_EXPECT_NO_ERROR(gl.getError(), "glUniform1i()");
1501 gl.viewport(0, 0, VIEWPORT_WIDTH, VIEWPORT_HEIGHT);
1502 GLU_EXPECT_NO_ERROR(gl.getError(), "glViewport()");
1506 gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
1507 else if (stateId == 1)
1508 gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
1514 ADD_TESTCASE(bind_framebuffer, "Change framebuffer.",
1518 requireCoordBuffers(1);
1520 requireFramebuffers(2);
1523 gl.useProgram(m_programs[0]->getProgram());
1524 GLU_EXPECT_NO_ERROR(gl.getError(), "glUseProgram()");
1525 GLint coordLoc = gl.getAttribLocation(m_programs[0]->getProgram(), "a_coord");
1526 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetAttribLocation()");
1528 gl.enableVertexAttribArray(coordLoc);
1529 GLU_EXPECT_NO_ERROR(gl.getError(), "glEnableVertexAttribArray()");
1530 gl.bindBuffer(GL_ARRAY_BUFFER, m_coordBuffers[0]);
1531 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer()");
1532 gl.vertexAttribPointer(coordLoc, 2, GL_FLOAT, GL_FALSE, 0, NULL);
1533 GLU_EXPECT_NO_ERROR(gl.getError(), "glVertexAttribPointer()");
1535 GLint samplerLoc = gl.getUniformLocation(m_programs[0]->getProgram(), "u_sampler");
1536 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetUniformLocation()");
1538 gl.bindTexture(GL_TEXTURE_2D, m_textures[0]);
1539 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture()");
1541 gl.uniform1i(samplerLoc, 0);
1542 GLU_EXPECT_NO_ERROR(gl.getError(), "glUniform1i()");
1544 gl.viewport(0, 0, VIEWPORT_WIDTH, VIEWPORT_HEIGHT);
1545 GLU_EXPECT_NO_ERROR(gl.getError(), "glViewport()");
1547 gl.bindFramebuffer(GL_FRAMEBUFFER, m_framebuffers[0]);
1548 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer()");
1552 gl.bindFramebuffer(GL_FRAMEBUFFER, m_framebuffers[0]);
1553 else if (stateId == 1)
1554 gl.bindFramebuffer(GL_FRAMEBUFFER, m_framebuffers[1]);
1560 ADD_TESTCASE(blend_color, "Change blend color.",
1564 requireCoordBuffers(1);
1568 gl.useProgram(m_programs[0]->getProgram());
1569 GLU_EXPECT_NO_ERROR(gl.getError(), "glUseProgram()");
1570 GLint coordLoc = gl.getAttribLocation(m_programs[0]->getProgram(), "a_coord");
1571 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetAttribLocation()");
1573 gl.enableVertexAttribArray(coordLoc);
1574 GLU_EXPECT_NO_ERROR(gl.getError(), "glEnableVertexAttribArray()");
1575 gl.bindBuffer(GL_ARRAY_BUFFER, m_coordBuffers[0]);
1576 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer()");
1577 gl.vertexAttribPointer(coordLoc, 2, GL_FLOAT, GL_FALSE, 0, NULL);
1578 GLU_EXPECT_NO_ERROR(gl.getError(), "glVertexAttribPointer()");
1580 GLint samplerLoc = gl.getUniformLocation(m_programs[0]->getProgram(), "u_sampler");
1581 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetUniformLocation()");
1583 gl.bindTexture(GL_TEXTURE_2D, m_textures[0]);
1584 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture()");
1586 gl.uniform1i(samplerLoc, 0);
1587 GLU_EXPECT_NO_ERROR(gl.getError(), "glUniform1i()");
1589 gl.viewport(0, 0, VIEWPORT_WIDTH, VIEWPORT_HEIGHT);
1590 GLU_EXPECT_NO_ERROR(gl.getError(), "glViewport()");
1592 gl.enable(GL_BLEND);
1593 GLU_EXPECT_NO_ERROR(gl.getError(), "glEnable()");
1595 gl.blendFunc(GL_CONSTANT_COLOR, GL_CONSTANT_COLOR);
1596 GLU_EXPECT_NO_ERROR(gl.getError(), "glBlendFunc()");
1600 gl.blendColor(0.25f, 0.25f, 0.25f, 0.25f);
1601 else if (stateId == 1)
1602 gl.blendColor(0.75f, 0.75f, 0.75f, 0.75f);
1608 ADD_TESTCASE(sampler, "Change sampler binding.",
1612 requireCoordBuffers(1);
1617 gl.useProgram(m_programs[0]->getProgram());
1618 GLU_EXPECT_NO_ERROR(gl.getError(), "glUseProgram()");
1619 GLint coordLoc = gl.getAttribLocation(m_programs[0]->getProgram(), "a_coord");
1620 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetAttribLocation()");
1622 gl.enableVertexAttribArray(coordLoc);
1623 GLU_EXPECT_NO_ERROR(gl.getError(), "glEnableVertexAttribArray()");
1624 gl.bindBuffer(GL_ARRAY_BUFFER, m_coordBuffers[0]);
1625 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer()");
1626 gl.vertexAttribPointer(coordLoc, 2, GL_FLOAT, GL_FALSE, 0, NULL);
1627 GLU_EXPECT_NO_ERROR(gl.getError(), "glVertexAttribPointer()");
1629 GLint samplerLoc = gl.getUniformLocation(m_programs[0]->getProgram(), "u_sampler");
1630 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetUniformLocation()");
1632 gl.bindTexture(GL_TEXTURE_2D, m_textures[0]);
1633 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture()");
1635 gl.uniform1i(samplerLoc, 0);
1636 GLU_EXPECT_NO_ERROR(gl.getError(), "glUniform1i()");
1638 gl.viewport(0, 0, VIEWPORT_WIDTH, VIEWPORT_HEIGHT);
1639 GLU_EXPECT_NO_ERROR(gl.getError(), "glViewport()");
1641 for (int ndx = 0; ndx < 2; ndx++)
1643 gl.bindSampler(0, m_samplers[ndx]);
1644 gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, ndx == 0 ? GL_NEAREST : GL_LINEAR);
1645 gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, ndx == 0 ? GL_LINEAR : GL_NEAREST);
1646 GLU_EXPECT_NO_ERROR(gl.getError(), "Sampler setup");
1650 DE_ASSERT(de::inBounds(stateId, 0, 2));
1651 gl.bindSampler(0, m_samplers[stateId]);
1655 ADD_TESTCASE(bind_vertex_array, "Change vertex array binding.",
1659 requireCoordBuffers(2);
1662 requireVertexArrays(2);
1664 gl.bindAttribLocation(m_programs[0]->getProgram(), 0, "a_coord");
1665 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindAttribLocation()");
1666 gl.linkProgram(m_programs[0]->getProgram());
1667 GLU_EXPECT_NO_ERROR(gl.getError(), "glLinkProgram()");
1669 gl.useProgram(m_programs[0]->getProgram());
1670 GLU_EXPECT_NO_ERROR(gl.getError(), "glUseProgram()");
1672 for (int ndx = 0; ndx < 2; ndx++)
1674 gl.bindVertexArray(m_vertexArrays[ndx]);
1675 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindVertexArray()");
1676 gl.enableVertexAttribArray(0);
1677 GLU_EXPECT_NO_ERROR(gl.getError(), "glEnableVertexAttribArray()");
1678 gl.bindBuffer(GL_ARRAY_BUFFER, m_coordBuffers[ndx]);
1679 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer()");
1680 gl.vertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 0, NULL);
1681 GLU_EXPECT_NO_ERROR(gl.getError(), "glVertexAttribPointer()");
1684 GLint samplerLoc = gl.getUniformLocation(m_programs[0]->getProgram(), "u_sampler");
1685 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetUniformLocation()");
1687 gl.bindTexture(GL_TEXTURE_2D, m_textures[0]);
1688 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture()");
1690 gl.uniform1i(samplerLoc, 0);
1691 GLU_EXPECT_NO_ERROR(gl.getError(), "glUniform1i()");
1693 gl.viewport(0, 0, VIEWPORT_WIDTH, VIEWPORT_HEIGHT);
1694 GLU_EXPECT_NO_ERROR(gl.getError(), "glViewport()");
1697 DE_ASSERT(de::inRange(stateId, 0, 2));
1698 gl.bindVertexArray(m_vertexArrays[stateId]);