1e5c31af7Sopenharmony_ci/*------------------------------------------------------------------------- 2e5c31af7Sopenharmony_ci * drawElements Quality Program OpenGL ES 2.0 Module 3e5c31af7Sopenharmony_ci * ------------------------------------------------- 4e5c31af7Sopenharmony_ci * 5e5c31af7Sopenharmony_ci * Copyright 2014 The Android Open Source Project 6e5c31af7Sopenharmony_ci * 7e5c31af7Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 8e5c31af7Sopenharmony_ci * you may not use this file except in compliance with the License. 9e5c31af7Sopenharmony_ci * You may obtain a copy of the License at 10e5c31af7Sopenharmony_ci * 11e5c31af7Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 12e5c31af7Sopenharmony_ci * 13e5c31af7Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 14e5c31af7Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 15e5c31af7Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16e5c31af7Sopenharmony_ci * See the License for the specific language governing permissions and 17e5c31af7Sopenharmony_ci * limitations under the License. 18e5c31af7Sopenharmony_ci * 19e5c31af7Sopenharmony_ci *//*! 20e5c31af7Sopenharmony_ci * \file 21e5c31af7Sopenharmony_ci * \brief Redundant state change performance tests. 22e5c31af7Sopenharmony_ci *//*--------------------------------------------------------------------*/ 23e5c31af7Sopenharmony_ci 24e5c31af7Sopenharmony_ci#include "es2pRedundantStateChangeTests.hpp" 25e5c31af7Sopenharmony_ci#include "glsStateChangePerfTestCases.hpp" 26e5c31af7Sopenharmony_ci#include "gluShaderProgram.hpp" 27e5c31af7Sopenharmony_ci#include "glwFunctions.hpp" 28e5c31af7Sopenharmony_ci#include "glwEnums.hpp" 29e5c31af7Sopenharmony_ci 30e5c31af7Sopenharmony_cinamespace deqp 31e5c31af7Sopenharmony_ci{ 32e5c31af7Sopenharmony_cinamespace gles2 33e5c31af7Sopenharmony_ci{ 34e5c31af7Sopenharmony_cinamespace Performance 35e5c31af7Sopenharmony_ci{ 36e5c31af7Sopenharmony_ci 37e5c31af7Sopenharmony_ciusing namespace glw; // GL types 38e5c31af7Sopenharmony_ci 39e5c31af7Sopenharmony_cinamespace 40e5c31af7Sopenharmony_ci{ 41e5c31af7Sopenharmony_ci 42e5c31af7Sopenharmony_cienum 43e5c31af7Sopenharmony_ci{ 44e5c31af7Sopenharmony_ci VIEWPORT_WIDTH = 24, 45e5c31af7Sopenharmony_ci VIEWPORT_HEIGHT = 24 46e5c31af7Sopenharmony_ci}; 47e5c31af7Sopenharmony_ci 48e5c31af7Sopenharmony_ciclass RedundantStateChangeCase : public gls::StateChangePerformanceCase 49e5c31af7Sopenharmony_ci{ 50e5c31af7Sopenharmony_cipublic: 51e5c31af7Sopenharmony_ci RedundantStateChangeCase (Context& context, int drawCallCount, int triangleCount, bool drawArrays, bool useIndexBuffer, const char* name, const char* description); 52e5c31af7Sopenharmony_ci ~RedundantStateChangeCase (void); 53e5c31af7Sopenharmony_ci 54e5c31af7Sopenharmony_ciprotected: 55e5c31af7Sopenharmony_ci virtual void renderTest (const glw::Functions& gl); 56e5c31af7Sopenharmony_ci virtual void renderReference (const glw::Functions& gl); 57e5c31af7Sopenharmony_ci virtual void changeState (const glw::Functions& gl) = 0; 58e5c31af7Sopenharmony_ci}; 59e5c31af7Sopenharmony_ci 60e5c31af7Sopenharmony_ciRedundantStateChangeCase::RedundantStateChangeCase (Context& context, int drawCallCount, int triangleCount, bool drawArrays, bool useIndexBuffer, const char* name, const char* description) 61e5c31af7Sopenharmony_ci : gls::StateChangePerformanceCase(context.getTestContext(), context.getRenderContext(), name, description, 62e5c31af7Sopenharmony_ci (useIndexBuffer ? DRAWTYPE_INDEXED_BUFFER : 63e5c31af7Sopenharmony_ci drawArrays ? DRAWTYPE_NOT_INDEXED : 64e5c31af7Sopenharmony_ci DRAWTYPE_INDEXED_USER_PTR), drawCallCount, triangleCount) 65e5c31af7Sopenharmony_ci{ 66e5c31af7Sopenharmony_ci DE_ASSERT(!useIndexBuffer || !drawArrays); 67e5c31af7Sopenharmony_ci} 68e5c31af7Sopenharmony_ci 69e5c31af7Sopenharmony_ciRedundantStateChangeCase::~RedundantStateChangeCase (void) 70e5c31af7Sopenharmony_ci{ 71e5c31af7Sopenharmony_ci} 72e5c31af7Sopenharmony_ci 73e5c31af7Sopenharmony_civoid RedundantStateChangeCase::renderTest (const glw::Functions& gl) 74e5c31af7Sopenharmony_ci{ 75e5c31af7Sopenharmony_ci for (int callNdx = 0; callNdx < m_callCount; callNdx++) 76e5c31af7Sopenharmony_ci { 77e5c31af7Sopenharmony_ci changeState(gl); 78e5c31af7Sopenharmony_ci callDraw(gl); 79e5c31af7Sopenharmony_ci } 80e5c31af7Sopenharmony_ci} 81e5c31af7Sopenharmony_ci 82e5c31af7Sopenharmony_civoid RedundantStateChangeCase::renderReference (const glw::Functions& gl) 83e5c31af7Sopenharmony_ci{ 84e5c31af7Sopenharmony_ci changeState(gl); 85e5c31af7Sopenharmony_ci 86e5c31af7Sopenharmony_ci for (int callNdx = 0; callNdx < m_callCount; callNdx++) 87e5c31af7Sopenharmony_ci callDraw(gl); 88e5c31af7Sopenharmony_ci} 89e5c31af7Sopenharmony_ci 90e5c31af7Sopenharmony_ci} // anonymous 91e5c31af7Sopenharmony_ci 92e5c31af7Sopenharmony_ciRedundantStateChangeTests::RedundantStateChangeTests (Context& context) 93e5c31af7Sopenharmony_ci : TestCaseGroup(context, "redundant_state_change_draw", "Test performance with redundant sate changes between rendering.") 94e5c31af7Sopenharmony_ci{ 95e5c31af7Sopenharmony_ci} 96e5c31af7Sopenharmony_ci 97e5c31af7Sopenharmony_ciRedundantStateChangeTests::~RedundantStateChangeTests (void) 98e5c31af7Sopenharmony_ci{ 99e5c31af7Sopenharmony_ci} 100e5c31af7Sopenharmony_ci 101e5c31af7Sopenharmony_ci#define MACRO_BLOCK(...) __VA_ARGS__ 102e5c31af7Sopenharmony_ci 103e5c31af7Sopenharmony_ci#define ADD_TESTCASE(NAME, DESC, DRAWARRAYS, INDEXBUFFER, INIT_FUNC, CHANGE_FUNC)\ 104e5c31af7Sopenharmony_cido {\ 105e5c31af7Sopenharmony_ci class RedundantStateChangeCase_ ## NAME : public RedundantStateChangeCase\ 106e5c31af7Sopenharmony_ci {\ 107e5c31af7Sopenharmony_ci public:\ 108e5c31af7Sopenharmony_ci RedundantStateChangeCase_ ## NAME (Context& context, int drawCallCount, int triangleCount, const char* name, const char* description)\ 109e5c31af7Sopenharmony_ci : RedundantStateChangeCase(context, drawCallCount, triangleCount, (DRAWARRAYS), (INDEXBUFFER), name, description)\ 110e5c31af7Sopenharmony_ci {}\ 111e5c31af7Sopenharmony_ci virtual void setupInitialState (const glw::Functions& gl)\ 112e5c31af7Sopenharmony_ci {\ 113e5c31af7Sopenharmony_ci INIT_FUNC\ 114e5c31af7Sopenharmony_ci }\ 115e5c31af7Sopenharmony_ci virtual void changeState (const glw::Functions& gl)\ 116e5c31af7Sopenharmony_ci {\ 117e5c31af7Sopenharmony_ci CHANGE_FUNC\ 118e5c31af7Sopenharmony_ci }\ 119e5c31af7Sopenharmony_ci };\ 120e5c31af7Sopenharmony_ci manySmallCallsGroup->addChild (new RedundantStateChangeCase_ ## NAME (m_context,1000,2,#NAME,(DESC)));\ 121e5c31af7Sopenharmony_ci fewBigCallsGroup->addChild (new RedundantStateChangeCase_ ## NAME (m_context,10,200,#NAME,(DESC)));\ 122e5c31af7Sopenharmony_ci} while (0); 123e5c31af7Sopenharmony_ci 124e5c31af7Sopenharmony_civoid RedundantStateChangeTests::init (void) 125e5c31af7Sopenharmony_ci{ 126e5c31af7Sopenharmony_ci tcu::TestCaseGroup* const manySmallCallsGroup = new tcu::TestCaseGroup(m_testCtx, "many_small_calls", "1000 calls, 2 triangles in each"); 127e5c31af7Sopenharmony_ci tcu::TestCaseGroup* const fewBigCallsGroup = new tcu::TestCaseGroup(m_testCtx, "few_big_calls", "10 calls, 200 triangles in each"); 128e5c31af7Sopenharmony_ci 129e5c31af7Sopenharmony_ci addChild(manySmallCallsGroup); 130e5c31af7Sopenharmony_ci addChild(fewBigCallsGroup); 131e5c31af7Sopenharmony_ci 132e5c31af7Sopenharmony_ci ADD_TESTCASE(blend, "Enable/Disable blending.", 133e5c31af7Sopenharmony_ci true, 134e5c31af7Sopenharmony_ci false, 135e5c31af7Sopenharmony_ci MACRO_BLOCK({ 136e5c31af7Sopenharmony_ci requireCoordBuffers(1); 137e5c31af7Sopenharmony_ci requireTextures(1); 138e5c31af7Sopenharmony_ci requirePrograms(1); 139e5c31af7Sopenharmony_ci 140e5c31af7Sopenharmony_ci gl.useProgram(m_programs[0]->getProgram()); 141e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glUseProgram()"); 142e5c31af7Sopenharmony_ci GLint coordLoc = gl.getAttribLocation(m_programs[0]->getProgram(), "a_coord"); 143e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glGetAttribLocation()"); 144e5c31af7Sopenharmony_ci 145e5c31af7Sopenharmony_ci gl.enableVertexAttribArray(coordLoc); 146e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glEnableVertexAttribArray()"); 147e5c31af7Sopenharmony_ci gl.bindBuffer(GL_ARRAY_BUFFER, m_coordBuffers[0]); 148e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer()"); 149e5c31af7Sopenharmony_ci gl.vertexAttribPointer(coordLoc, 2, GL_FLOAT, GL_FALSE, 0, NULL); 150e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glVertexAttribPointer()"); 151e5c31af7Sopenharmony_ci 152e5c31af7Sopenharmony_ci GLint samplerLoc = gl.getUniformLocation(m_programs[0]->getProgram(), "u_sampler"); 153e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glGetUniformLocation()"); 154e5c31af7Sopenharmony_ci 155e5c31af7Sopenharmony_ci gl.bindTexture(GL_TEXTURE_2D, m_textures[0]); 156e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture()"); 157e5c31af7Sopenharmony_ci 158e5c31af7Sopenharmony_ci gl.uniform1i(samplerLoc, 0); 159e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glUniform1i()"); 160e5c31af7Sopenharmony_ci 161e5c31af7Sopenharmony_ci gl.viewport(0, 0, VIEWPORT_WIDTH, VIEWPORT_HEIGHT); 162e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glViewport()"); 163e5c31af7Sopenharmony_ci }), 164e5c31af7Sopenharmony_ci MACRO_BLOCK({ 165e5c31af7Sopenharmony_ci gl.enable(GL_BLEND); 166e5c31af7Sopenharmony_ci }) 167e5c31af7Sopenharmony_ci ) 168e5c31af7Sopenharmony_ci 169e5c31af7Sopenharmony_ci ADD_TESTCASE(depth_test, "Enable/Disable depth test.", 170e5c31af7Sopenharmony_ci true, 171e5c31af7Sopenharmony_ci false, 172e5c31af7Sopenharmony_ci MACRO_BLOCK({ 173e5c31af7Sopenharmony_ci requireCoordBuffers(1); 174e5c31af7Sopenharmony_ci requireTextures(1); 175e5c31af7Sopenharmony_ci requirePrograms(1); 176e5c31af7Sopenharmony_ci 177e5c31af7Sopenharmony_ci gl.useProgram(m_programs[0]->getProgram()); 178e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glUseProgram()"); 179e5c31af7Sopenharmony_ci 180e5c31af7Sopenharmony_ci GLint coordLoc = gl.getAttribLocation(m_programs[0]->getProgram(), "a_coord"); 181e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glGetAttribLocation()"); 182e5c31af7Sopenharmony_ci 183e5c31af7Sopenharmony_ci gl.enableVertexAttribArray(coordLoc); 184e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glEnableVertexAttribArray()"); 185e5c31af7Sopenharmony_ci 186e5c31af7Sopenharmony_ci gl.bindBuffer(GL_ARRAY_BUFFER, m_coordBuffers[0]); 187e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer()"); 188e5c31af7Sopenharmony_ci gl.vertexAttribPointer(coordLoc, 2, GL_FLOAT, GL_FALSE, 0, NULL); 189e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glVertexAttribPointer()"); 190e5c31af7Sopenharmony_ci 191e5c31af7Sopenharmony_ci GLint samplerLoc = gl.getUniformLocation(m_programs[0]->getProgram(), "u_sampler"); 192e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glGetUniformLocation()"); 193e5c31af7Sopenharmony_ci 194e5c31af7Sopenharmony_ci gl.bindTexture(GL_TEXTURE_2D, m_textures[0]); 195e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture()"); 196e5c31af7Sopenharmony_ci 197e5c31af7Sopenharmony_ci gl.uniform1i(samplerLoc, 0); 198e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glUniform1i()"); 199e5c31af7Sopenharmony_ci 200e5c31af7Sopenharmony_ci gl.viewport(0, 0, VIEWPORT_WIDTH, VIEWPORT_HEIGHT); 201e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glViewport()"); 202e5c31af7Sopenharmony_ci 203e5c31af7Sopenharmony_ci gl.depthFunc(GL_LEQUAL); 204e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glDepthFunc()"); 205e5c31af7Sopenharmony_ci }), 206e5c31af7Sopenharmony_ci MACRO_BLOCK({ 207e5c31af7Sopenharmony_ci gl.enable(GL_DEPTH_TEST); 208e5c31af7Sopenharmony_ci }) 209e5c31af7Sopenharmony_ci ) 210e5c31af7Sopenharmony_ci 211e5c31af7Sopenharmony_ci ADD_TESTCASE(stencil_test, "Enable/Disable stencil test.", 212e5c31af7Sopenharmony_ci true, 213e5c31af7Sopenharmony_ci false, 214e5c31af7Sopenharmony_ci MACRO_BLOCK({ 215e5c31af7Sopenharmony_ci requireCoordBuffers(1); 216e5c31af7Sopenharmony_ci requireTextures(1); 217e5c31af7Sopenharmony_ci requirePrograms(1); 218e5c31af7Sopenharmony_ci 219e5c31af7Sopenharmony_ci gl.useProgram(m_programs[0]->getProgram()); 220e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glUseProgram()"); 221e5c31af7Sopenharmony_ci GLint coordLoc = gl.getAttribLocation(m_programs[0]->getProgram(), "a_coord"); 222e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glGetAttribLocation()"); 223e5c31af7Sopenharmony_ci 224e5c31af7Sopenharmony_ci gl.enableVertexAttribArray(coordLoc); 225e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glEnableVertexAttribArray()"); 226e5c31af7Sopenharmony_ci gl.bindBuffer(GL_ARRAY_BUFFER, m_coordBuffers[0]); 227e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer()"); 228e5c31af7Sopenharmony_ci gl.vertexAttribPointer(coordLoc, 2, GL_FLOAT, GL_FALSE, 0, NULL); 229e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glVertexAttribPointer()"); 230e5c31af7Sopenharmony_ci 231e5c31af7Sopenharmony_ci GLint samplerLoc = gl.getUniformLocation(m_programs[0]->getProgram(), "u_sampler"); 232e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glGetUniformLocation()"); 233e5c31af7Sopenharmony_ci 234e5c31af7Sopenharmony_ci gl.bindTexture(GL_TEXTURE_2D, m_textures[0]); 235e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture()"); 236e5c31af7Sopenharmony_ci 237e5c31af7Sopenharmony_ci gl.uniform1i(samplerLoc, 0); 238e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glUniform1i()"); 239e5c31af7Sopenharmony_ci 240e5c31af7Sopenharmony_ci gl.viewport(0, 0, VIEWPORT_WIDTH, VIEWPORT_HEIGHT); 241e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glViewport()"); 242e5c31af7Sopenharmony_ci 243e5c31af7Sopenharmony_ci gl.stencilFunc(GL_LEQUAL, 0, 0); 244e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glStencilFunc()"); 245e5c31af7Sopenharmony_ci 246e5c31af7Sopenharmony_ci gl.stencilOp(GL_KEEP, GL_REPLACE, GL_REPLACE); 247e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glStencilOp()"); 248e5c31af7Sopenharmony_ci 249e5c31af7Sopenharmony_ci gl.clearStencil(0); 250e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glClearStencil()"); 251e5c31af7Sopenharmony_ci gl.clear(GL_STENCIL_BUFFER_BIT); 252e5c31af7Sopenharmony_ci 253e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glClear()"); 254e5c31af7Sopenharmony_ci }), 255e5c31af7Sopenharmony_ci MACRO_BLOCK({ 256e5c31af7Sopenharmony_ci gl.enable(GL_STENCIL_TEST); 257e5c31af7Sopenharmony_ci }) 258e5c31af7Sopenharmony_ci ) 259e5c31af7Sopenharmony_ci 260e5c31af7Sopenharmony_ci ADD_TESTCASE(scissor_test, "Enable/Disable scissor test.", 261e5c31af7Sopenharmony_ci true, 262e5c31af7Sopenharmony_ci false, 263e5c31af7Sopenharmony_ci MACRO_BLOCK({ 264e5c31af7Sopenharmony_ci requireCoordBuffers(1); 265e5c31af7Sopenharmony_ci requireTextures(1); 266e5c31af7Sopenharmony_ci requirePrograms(1); 267e5c31af7Sopenharmony_ci 268e5c31af7Sopenharmony_ci gl.useProgram(m_programs[0]->getProgram()); 269e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glUseProgram()"); 270e5c31af7Sopenharmony_ci GLint coordLoc = gl.getAttribLocation(m_programs[0]->getProgram(), "a_coord"); 271e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glGetAttribLocation()"); 272e5c31af7Sopenharmony_ci 273e5c31af7Sopenharmony_ci gl.enableVertexAttribArray(coordLoc); 274e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glEnableVertexAttribArray()"); 275e5c31af7Sopenharmony_ci gl.bindBuffer(GL_ARRAY_BUFFER, m_coordBuffers[0]); 276e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer()"); 277e5c31af7Sopenharmony_ci gl.vertexAttribPointer(coordLoc, 2, GL_FLOAT, GL_FALSE, 0, NULL); 278e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glVertexAttribPointer()"); 279e5c31af7Sopenharmony_ci 280e5c31af7Sopenharmony_ci GLint samplerLoc = gl.getUniformLocation(m_programs[0]->getProgram(), "u_sampler"); 281e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glGetUniformLocation()"); 282e5c31af7Sopenharmony_ci 283e5c31af7Sopenharmony_ci gl.bindTexture(GL_TEXTURE_2D, m_textures[0]); 284e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture()"); 285e5c31af7Sopenharmony_ci 286e5c31af7Sopenharmony_ci gl.uniform1i(samplerLoc, 0); 287e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glUniform1i()"); 288e5c31af7Sopenharmony_ci 289e5c31af7Sopenharmony_ci gl.viewport(0, 0, VIEWPORT_WIDTH, VIEWPORT_HEIGHT); 290e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glViewport()"); 291e5c31af7Sopenharmony_ci 292e5c31af7Sopenharmony_ci gl.scissor(2, 3, 12, 13); 293e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glScissor()"); 294e5c31af7Sopenharmony_ci }), 295e5c31af7Sopenharmony_ci MACRO_BLOCK({ 296e5c31af7Sopenharmony_ci gl.enable(GL_SCISSOR_TEST); 297e5c31af7Sopenharmony_ci }) 298e5c31af7Sopenharmony_ci ) 299e5c31af7Sopenharmony_ci 300e5c31af7Sopenharmony_ci ADD_TESTCASE(dither, "Enable/Disable dithering.", 301e5c31af7Sopenharmony_ci true, 302e5c31af7Sopenharmony_ci false, 303e5c31af7Sopenharmony_ci MACRO_BLOCK({ 304e5c31af7Sopenharmony_ci requireCoordBuffers(1); 305e5c31af7Sopenharmony_ci requireTextures(1); 306e5c31af7Sopenharmony_ci requirePrograms(1); 307e5c31af7Sopenharmony_ci 308e5c31af7Sopenharmony_ci gl.useProgram(m_programs[0]->getProgram()); 309e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glUseProgram()"); 310e5c31af7Sopenharmony_ci GLint coordLoc = gl.getAttribLocation(m_programs[0]->getProgram(), "a_coord"); 311e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glGetAttribLocation()"); 312e5c31af7Sopenharmony_ci 313e5c31af7Sopenharmony_ci gl.enableVertexAttribArray(coordLoc); 314e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glEnableVertexAttribArray()"); 315e5c31af7Sopenharmony_ci gl.bindBuffer(GL_ARRAY_BUFFER, m_coordBuffers[0]); 316e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer()"); 317e5c31af7Sopenharmony_ci gl.vertexAttribPointer(coordLoc, 2, GL_FLOAT, GL_FALSE, 0, NULL); 318e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glVertexAttribPointer()"); 319e5c31af7Sopenharmony_ci 320e5c31af7Sopenharmony_ci GLint samplerLoc = gl.getUniformLocation(m_programs[0]->getProgram(), "u_sampler"); 321e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glGetUniformLocation()"); 322e5c31af7Sopenharmony_ci 323e5c31af7Sopenharmony_ci gl.bindTexture(GL_TEXTURE_2D, m_textures[0]); 324e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture()"); 325e5c31af7Sopenharmony_ci 326e5c31af7Sopenharmony_ci gl.uniform1i(samplerLoc, 0); 327e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glUniform1i()"); 328e5c31af7Sopenharmony_ci 329e5c31af7Sopenharmony_ci gl.viewport(0, 0, VIEWPORT_WIDTH, VIEWPORT_HEIGHT); 330e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glViewport()"); 331e5c31af7Sopenharmony_ci }), 332e5c31af7Sopenharmony_ci MACRO_BLOCK({ 333e5c31af7Sopenharmony_ci gl.enable(GL_DITHER); 334e5c31af7Sopenharmony_ci }) 335e5c31af7Sopenharmony_ci ) 336e5c31af7Sopenharmony_ci 337e5c31af7Sopenharmony_ci ADD_TESTCASE(culling, "Enable/Disable culling.", 338e5c31af7Sopenharmony_ci true, 339e5c31af7Sopenharmony_ci false, 340e5c31af7Sopenharmony_ci MACRO_BLOCK({ 341e5c31af7Sopenharmony_ci requireCoordBuffers(1); 342e5c31af7Sopenharmony_ci requireTextures(1); 343e5c31af7Sopenharmony_ci requirePrograms(1); 344e5c31af7Sopenharmony_ci 345e5c31af7Sopenharmony_ci gl.useProgram(m_programs[0]->getProgram()); 346e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glUseProgram()"); 347e5c31af7Sopenharmony_ci GLint coordLoc = gl.getAttribLocation(m_programs[0]->getProgram(), "a_coord"); 348e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glGetAttribLocation()"); 349e5c31af7Sopenharmony_ci 350e5c31af7Sopenharmony_ci gl.enableVertexAttribArray(coordLoc); 351e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glEnableVertexAttribArray()"); 352e5c31af7Sopenharmony_ci gl.bindBuffer(GL_ARRAY_BUFFER, m_coordBuffers[0]); 353e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer()"); 354e5c31af7Sopenharmony_ci gl.vertexAttribPointer(coordLoc, 2, GL_FLOAT, GL_FALSE, 0, NULL); 355e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glVertexAttribPointer()"); 356e5c31af7Sopenharmony_ci 357e5c31af7Sopenharmony_ci GLint samplerLoc = gl.getUniformLocation(m_programs[0]->getProgram(), "u_sampler"); 358e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glGetUniformLocation()"); 359e5c31af7Sopenharmony_ci 360e5c31af7Sopenharmony_ci gl.bindTexture(GL_TEXTURE_2D, m_textures[0]); 361e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture()"); 362e5c31af7Sopenharmony_ci 363e5c31af7Sopenharmony_ci gl.uniform1i(samplerLoc, 0); 364e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glUniform1i()"); 365e5c31af7Sopenharmony_ci 366e5c31af7Sopenharmony_ci gl.viewport(0, 0, VIEWPORT_WIDTH, VIEWPORT_HEIGHT); 367e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glViewport()"); 368e5c31af7Sopenharmony_ci 369e5c31af7Sopenharmony_ci gl.frontFace(GL_CW); 370e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glFrontFace()"); 371e5c31af7Sopenharmony_ci 372e5c31af7Sopenharmony_ci gl.cullFace(GL_FRONT); 373e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glCullFace()"); 374e5c31af7Sopenharmony_ci }), 375e5c31af7Sopenharmony_ci MACRO_BLOCK({ 376e5c31af7Sopenharmony_ci gl.enable(GL_CULL_FACE); 377e5c31af7Sopenharmony_ci }) 378e5c31af7Sopenharmony_ci ) 379e5c31af7Sopenharmony_ci 380e5c31af7Sopenharmony_ci ADD_TESTCASE(depth_func, "Change depth func.", 381e5c31af7Sopenharmony_ci true, 382e5c31af7Sopenharmony_ci false, 383e5c31af7Sopenharmony_ci MACRO_BLOCK({ 384e5c31af7Sopenharmony_ci requireCoordBuffers(1); 385e5c31af7Sopenharmony_ci requireTextures(1); 386e5c31af7Sopenharmony_ci requirePrograms(1); 387e5c31af7Sopenharmony_ci 388e5c31af7Sopenharmony_ci gl.useProgram(m_programs[0]->getProgram()); 389e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glUseProgram()"); 390e5c31af7Sopenharmony_ci GLint coordLoc = gl.getAttribLocation(m_programs[0]->getProgram(), "a_coord"); 391e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glGetAttribLocation()"); 392e5c31af7Sopenharmony_ci 393e5c31af7Sopenharmony_ci gl.enableVertexAttribArray(coordLoc); 394e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glEnableVertexAttribArray()"); 395e5c31af7Sopenharmony_ci gl.bindBuffer(GL_ARRAY_BUFFER, m_coordBuffers[0]); 396e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer()"); 397e5c31af7Sopenharmony_ci gl.vertexAttribPointer(coordLoc, 2, GL_FLOAT, GL_FALSE, 0, NULL); 398e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glVertexAttribPointer()"); 399e5c31af7Sopenharmony_ci 400e5c31af7Sopenharmony_ci GLint samplerLoc = gl.getUniformLocation(m_programs[0]->getProgram(), "u_sampler"); 401e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glGetUniformLocation()"); 402e5c31af7Sopenharmony_ci 403e5c31af7Sopenharmony_ci gl.bindTexture(GL_TEXTURE_2D, m_textures[0]); 404e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture()"); 405e5c31af7Sopenharmony_ci 406e5c31af7Sopenharmony_ci gl.uniform1i(samplerLoc, 0); 407e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glUniform1i()"); 408e5c31af7Sopenharmony_ci 409e5c31af7Sopenharmony_ci gl.viewport(0, 0, VIEWPORT_WIDTH, VIEWPORT_HEIGHT); 410e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glViewport()"); 411e5c31af7Sopenharmony_ci 412e5c31af7Sopenharmony_ci gl.enable(GL_DEPTH_TEST); 413e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glEnable()"); 414e5c31af7Sopenharmony_ci }), 415e5c31af7Sopenharmony_ci MACRO_BLOCK({ 416e5c31af7Sopenharmony_ci gl.depthFunc(GL_GEQUAL); 417e5c31af7Sopenharmony_ci }) 418e5c31af7Sopenharmony_ci ) 419e5c31af7Sopenharmony_ci 420e5c31af7Sopenharmony_ci 421e5c31af7Sopenharmony_ci ADD_TESTCASE(depth_mask, "Toggle depth mask.", 422e5c31af7Sopenharmony_ci true, 423e5c31af7Sopenharmony_ci false, 424e5c31af7Sopenharmony_ci MACRO_BLOCK({ 425e5c31af7Sopenharmony_ci requireCoordBuffers(1); 426e5c31af7Sopenharmony_ci requireTextures(1); 427e5c31af7Sopenharmony_ci requirePrograms(1); 428e5c31af7Sopenharmony_ci 429e5c31af7Sopenharmony_ci gl.useProgram(m_programs[0]->getProgram()); 430e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glUseProgram()"); 431e5c31af7Sopenharmony_ci GLint coordLoc = gl.getAttribLocation(m_programs[0]->getProgram(), "a_coord"); 432e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glGetAttribLocation()"); 433e5c31af7Sopenharmony_ci 434e5c31af7Sopenharmony_ci gl.enableVertexAttribArray(coordLoc); 435e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glEnableVertexAttribArray()"); 436e5c31af7Sopenharmony_ci gl.bindBuffer(GL_ARRAY_BUFFER, m_coordBuffers[0]); 437e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer()"); 438e5c31af7Sopenharmony_ci gl.vertexAttribPointer(coordLoc, 2, GL_FLOAT, GL_FALSE, 0, NULL); 439e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glVertexAttribPointer()"); 440e5c31af7Sopenharmony_ci 441e5c31af7Sopenharmony_ci GLint samplerLoc = gl.getUniformLocation(m_programs[0]->getProgram(), "u_sampler"); 442e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glGetUniformLocation()"); 443e5c31af7Sopenharmony_ci 444e5c31af7Sopenharmony_ci gl.bindTexture(GL_TEXTURE_2D, m_textures[0]); 445e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture()"); 446e5c31af7Sopenharmony_ci 447e5c31af7Sopenharmony_ci gl.uniform1i(samplerLoc, 0); 448e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glUniform1i()"); 449e5c31af7Sopenharmony_ci 450e5c31af7Sopenharmony_ci gl.viewport(0, 0, VIEWPORT_WIDTH, VIEWPORT_HEIGHT); 451e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glViewport()"); 452e5c31af7Sopenharmony_ci 453e5c31af7Sopenharmony_ci gl.enable(GL_DEPTH_TEST); 454e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glEnable()"); 455e5c31af7Sopenharmony_ci 456e5c31af7Sopenharmony_ci gl.depthFunc(GL_LEQUAL); 457e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glDepthFunc()"); 458e5c31af7Sopenharmony_ci }), 459e5c31af7Sopenharmony_ci MACRO_BLOCK({ 460e5c31af7Sopenharmony_ci gl.depthMask(GL_FALSE); 461e5c31af7Sopenharmony_ci }) 462e5c31af7Sopenharmony_ci ) 463e5c31af7Sopenharmony_ci 464e5c31af7Sopenharmony_ci ADD_TESTCASE(depth_rangef, "Change depth range.", 465e5c31af7Sopenharmony_ci true, 466e5c31af7Sopenharmony_ci false, 467e5c31af7Sopenharmony_ci MACRO_BLOCK({ 468e5c31af7Sopenharmony_ci requireCoordBuffers(1); 469e5c31af7Sopenharmony_ci requireTextures(1); 470e5c31af7Sopenharmony_ci requirePrograms(1); 471e5c31af7Sopenharmony_ci 472e5c31af7Sopenharmony_ci gl.useProgram(m_programs[0]->getProgram()); 473e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glUseProgram()"); 474e5c31af7Sopenharmony_ci GLint coordLoc = gl.getAttribLocation(m_programs[0]->getProgram(), "a_coord"); 475e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glGetAttribLocation()"); 476e5c31af7Sopenharmony_ci 477e5c31af7Sopenharmony_ci gl.enableVertexAttribArray(coordLoc); 478e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glEnableVertexAttribArray()"); 479e5c31af7Sopenharmony_ci gl.bindBuffer(GL_ARRAY_BUFFER, m_coordBuffers[0]); 480e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer()"); 481e5c31af7Sopenharmony_ci gl.vertexAttribPointer(coordLoc, 2, GL_FLOAT, GL_FALSE, 0, NULL); 482e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glVertexAttribPointer()"); 483e5c31af7Sopenharmony_ci 484e5c31af7Sopenharmony_ci GLint samplerLoc = gl.getUniformLocation(m_programs[0]->getProgram(), "u_sampler"); 485e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glGetUniformLocation()"); 486e5c31af7Sopenharmony_ci 487e5c31af7Sopenharmony_ci gl.bindTexture(GL_TEXTURE_2D, m_textures[0]); 488e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture()"); 489e5c31af7Sopenharmony_ci 490e5c31af7Sopenharmony_ci gl.uniform1i(samplerLoc, 0); 491e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glUniform1i()"); 492e5c31af7Sopenharmony_ci 493e5c31af7Sopenharmony_ci gl.viewport(0, 0, VIEWPORT_WIDTH, VIEWPORT_HEIGHT); 494e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glViewport()"); 495e5c31af7Sopenharmony_ci }), 496e5c31af7Sopenharmony_ci MACRO_BLOCK({ 497e5c31af7Sopenharmony_ci gl.depthRangef(0.0f, 1.0f); 498e5c31af7Sopenharmony_ci }) 499e5c31af7Sopenharmony_ci ) 500e5c31af7Sopenharmony_ci 501e5c31af7Sopenharmony_ci ADD_TESTCASE(blend_equation, "Change blend equation.", 502e5c31af7Sopenharmony_ci true, 503e5c31af7Sopenharmony_ci false, 504e5c31af7Sopenharmony_ci MACRO_BLOCK({ 505e5c31af7Sopenharmony_ci requireCoordBuffers(1); 506e5c31af7Sopenharmony_ci requireTextures(1); 507e5c31af7Sopenharmony_ci requirePrograms(1); 508e5c31af7Sopenharmony_ci 509e5c31af7Sopenharmony_ci gl.useProgram(m_programs[0]->getProgram()); 510e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glUseProgram()"); 511e5c31af7Sopenharmony_ci GLint coordLoc = gl.getAttribLocation(m_programs[0]->getProgram(), "a_coord"); 512e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glGetAttribLocation()"); 513e5c31af7Sopenharmony_ci 514e5c31af7Sopenharmony_ci gl.enableVertexAttribArray(coordLoc); 515e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glEnableVertexAttribArray()"); 516e5c31af7Sopenharmony_ci gl.bindBuffer(GL_ARRAY_BUFFER, m_coordBuffers[0]); 517e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer()"); 518e5c31af7Sopenharmony_ci gl.vertexAttribPointer(coordLoc, 2, GL_FLOAT, GL_FALSE, 0, NULL); 519e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glVertexAttribPointer()"); 520e5c31af7Sopenharmony_ci 521e5c31af7Sopenharmony_ci GLint samplerLoc = gl.getUniformLocation(m_programs[0]->getProgram(), "u_sampler"); 522e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glGetUniformLocation()"); 523e5c31af7Sopenharmony_ci 524e5c31af7Sopenharmony_ci gl.bindTexture(GL_TEXTURE_2D, m_textures[0]); 525e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture()"); 526e5c31af7Sopenharmony_ci 527e5c31af7Sopenharmony_ci gl.uniform1i(samplerLoc, 0); 528e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glUniform1i()"); 529e5c31af7Sopenharmony_ci 530e5c31af7Sopenharmony_ci gl.viewport(0, 0, VIEWPORT_WIDTH, VIEWPORT_HEIGHT); 531e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glViewport()"); 532e5c31af7Sopenharmony_ci 533e5c31af7Sopenharmony_ci gl.enable(GL_BLEND); 534e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glEnable()"); 535e5c31af7Sopenharmony_ci }), 536e5c31af7Sopenharmony_ci MACRO_BLOCK({ 537e5c31af7Sopenharmony_ci gl.blendEquation(GL_FUNC_SUBTRACT); 538e5c31af7Sopenharmony_ci }) 539e5c31af7Sopenharmony_ci ) 540e5c31af7Sopenharmony_ci 541e5c31af7Sopenharmony_ci ADD_TESTCASE(blend_func, "Change blend function.", 542e5c31af7Sopenharmony_ci true, 543e5c31af7Sopenharmony_ci false, 544e5c31af7Sopenharmony_ci MACRO_BLOCK({ 545e5c31af7Sopenharmony_ci requireCoordBuffers(1); 546e5c31af7Sopenharmony_ci requireTextures(1); 547e5c31af7Sopenharmony_ci requirePrograms(1); 548e5c31af7Sopenharmony_ci 549e5c31af7Sopenharmony_ci gl.useProgram(m_programs[0]->getProgram()); 550e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glUseProgram()"); 551e5c31af7Sopenharmony_ci GLint coordLoc = gl.getAttribLocation(m_programs[0]->getProgram(), "a_coord"); 552e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glGetAttribLocation()"); 553e5c31af7Sopenharmony_ci 554e5c31af7Sopenharmony_ci gl.enableVertexAttribArray(coordLoc); 555e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glEnableVertexAttribArray()"); 556e5c31af7Sopenharmony_ci gl.bindBuffer(GL_ARRAY_BUFFER, m_coordBuffers[0]); 557e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer()"); 558e5c31af7Sopenharmony_ci gl.vertexAttribPointer(coordLoc, 2, GL_FLOAT, GL_FALSE, 0, NULL); 559e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glVertexAttribPointer()"); 560e5c31af7Sopenharmony_ci 561e5c31af7Sopenharmony_ci GLint samplerLoc = gl.getUniformLocation(m_programs[0]->getProgram(), "u_sampler"); 562e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glGetUniformLocation()"); 563e5c31af7Sopenharmony_ci 564e5c31af7Sopenharmony_ci gl.bindTexture(GL_TEXTURE_2D, m_textures[0]); 565e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture()"); 566e5c31af7Sopenharmony_ci 567e5c31af7Sopenharmony_ci gl.uniform1i(samplerLoc, 0); 568e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glUniform1i()"); 569e5c31af7Sopenharmony_ci 570e5c31af7Sopenharmony_ci gl.viewport(0, 0, VIEWPORT_WIDTH, VIEWPORT_HEIGHT); 571e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glViewport()"); 572e5c31af7Sopenharmony_ci 573e5c31af7Sopenharmony_ci gl.enable(GL_BLEND); 574e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glEnable()"); 575e5c31af7Sopenharmony_ci }), 576e5c31af7Sopenharmony_ci MACRO_BLOCK({ 577e5c31af7Sopenharmony_ci gl.blendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); 578e5c31af7Sopenharmony_ci }) 579e5c31af7Sopenharmony_ci ) 580e5c31af7Sopenharmony_ci 581e5c31af7Sopenharmony_ci ADD_TESTCASE(polygon_offset, "Change polygon offset.", 582e5c31af7Sopenharmony_ci true, 583e5c31af7Sopenharmony_ci false, 584e5c31af7Sopenharmony_ci MACRO_BLOCK({ 585e5c31af7Sopenharmony_ci requireCoordBuffers(1); 586e5c31af7Sopenharmony_ci requireTextures(1); 587e5c31af7Sopenharmony_ci requirePrograms(1); 588e5c31af7Sopenharmony_ci 589e5c31af7Sopenharmony_ci gl.useProgram(m_programs[0]->getProgram()); 590e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glUseProgram()"); 591e5c31af7Sopenharmony_ci GLint coordLoc = gl.getAttribLocation(m_programs[0]->getProgram(), "a_coord"); 592e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glGetAttribLocation()"); 593e5c31af7Sopenharmony_ci 594e5c31af7Sopenharmony_ci gl.enableVertexAttribArray(coordLoc); 595e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glEnableVertexAttribArray()"); 596e5c31af7Sopenharmony_ci gl.bindBuffer(GL_ARRAY_BUFFER, m_coordBuffers[0]); 597e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer()"); 598e5c31af7Sopenharmony_ci gl.vertexAttribPointer(coordLoc, 2, GL_FLOAT, GL_FALSE, 0, NULL); 599e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glVertexAttribPointer()"); 600e5c31af7Sopenharmony_ci 601e5c31af7Sopenharmony_ci GLint samplerLoc = gl.getUniformLocation(m_programs[0]->getProgram(), "u_sampler"); 602e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glGetUniformLocation()"); 603e5c31af7Sopenharmony_ci 604e5c31af7Sopenharmony_ci gl.bindTexture(GL_TEXTURE_2D, m_textures[0]); 605e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture()"); 606e5c31af7Sopenharmony_ci 607e5c31af7Sopenharmony_ci gl.uniform1i(samplerLoc, 0); 608e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glUniform1i()"); 609e5c31af7Sopenharmony_ci 610e5c31af7Sopenharmony_ci gl.viewport(0, 0, VIEWPORT_WIDTH, VIEWPORT_HEIGHT); 611e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glViewport()"); 612e5c31af7Sopenharmony_ci 613e5c31af7Sopenharmony_ci gl.enable(GL_POLYGON_OFFSET_FILL); 614e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glEnable()"); 615e5c31af7Sopenharmony_ci }), 616e5c31af7Sopenharmony_ci MACRO_BLOCK({ 617e5c31af7Sopenharmony_ci gl.polygonOffset(0.0f, 0.0f); 618e5c31af7Sopenharmony_ci }) 619e5c31af7Sopenharmony_ci ) 620e5c31af7Sopenharmony_ci 621e5c31af7Sopenharmony_ci ADD_TESTCASE(sample_coverage, "Sample coverage.", 622e5c31af7Sopenharmony_ci true, 623e5c31af7Sopenharmony_ci false, 624e5c31af7Sopenharmony_ci MACRO_BLOCK({ 625e5c31af7Sopenharmony_ci requireCoordBuffers(1); 626e5c31af7Sopenharmony_ci requireTextures(1); 627e5c31af7Sopenharmony_ci requirePrograms(1); 628e5c31af7Sopenharmony_ci 629e5c31af7Sopenharmony_ci gl.useProgram(m_programs[0]->getProgram()); 630e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glUseProgram()"); 631e5c31af7Sopenharmony_ci GLint coordLoc = gl.getAttribLocation(m_programs[0]->getProgram(), "a_coord"); 632e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glGetAttribLocation()"); 633e5c31af7Sopenharmony_ci 634e5c31af7Sopenharmony_ci gl.enableVertexAttribArray(coordLoc); 635e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glEnableVertexAttribArray()"); 636e5c31af7Sopenharmony_ci gl.bindBuffer(GL_ARRAY_BUFFER, m_coordBuffers[0]); 637e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer()"); 638e5c31af7Sopenharmony_ci gl.vertexAttribPointer(coordLoc, 2, GL_FLOAT, GL_FALSE, 0, NULL); 639e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glVertexAttribPointer()"); 640e5c31af7Sopenharmony_ci 641e5c31af7Sopenharmony_ci GLint samplerLoc = gl.getUniformLocation(m_programs[0]->getProgram(), "u_sampler"); 642e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glGetUniformLocation()"); 643e5c31af7Sopenharmony_ci 644e5c31af7Sopenharmony_ci gl.bindTexture(GL_TEXTURE_2D, m_textures[0]); 645e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture()"); 646e5c31af7Sopenharmony_ci 647e5c31af7Sopenharmony_ci gl.uniform1i(samplerLoc, 0); 648e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glUniform1i()"); 649e5c31af7Sopenharmony_ci 650e5c31af7Sopenharmony_ci gl.viewport(0, 0, VIEWPORT_WIDTH, VIEWPORT_HEIGHT); 651e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glViewport()"); 652e5c31af7Sopenharmony_ci }), 653e5c31af7Sopenharmony_ci MACRO_BLOCK({ 654e5c31af7Sopenharmony_ci gl.sampleCoverage(0.25f, GL_TRUE); 655e5c31af7Sopenharmony_ci }) 656e5c31af7Sopenharmony_ci ) 657e5c31af7Sopenharmony_ci 658e5c31af7Sopenharmony_ci ADD_TESTCASE(viewport, "Change viewport.", 659e5c31af7Sopenharmony_ci true, 660e5c31af7Sopenharmony_ci false, 661e5c31af7Sopenharmony_ci MACRO_BLOCK({ 662e5c31af7Sopenharmony_ci requireCoordBuffers(1); 663e5c31af7Sopenharmony_ci requireTextures(1); 664e5c31af7Sopenharmony_ci requirePrograms(1); 665e5c31af7Sopenharmony_ci 666e5c31af7Sopenharmony_ci gl.useProgram(m_programs[0]->getProgram()); 667e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glUseProgram()"); 668e5c31af7Sopenharmony_ci GLint coordLoc = gl.getAttribLocation(m_programs[0]->getProgram(), "a_coord"); 669e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glGetAttribLocation()"); 670e5c31af7Sopenharmony_ci 671e5c31af7Sopenharmony_ci gl.enableVertexAttribArray(coordLoc); 672e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glEnableVertexAttribArray()"); 673e5c31af7Sopenharmony_ci gl.bindBuffer(GL_ARRAY_BUFFER, m_coordBuffers[0]); 674e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer()"); 675e5c31af7Sopenharmony_ci gl.vertexAttribPointer(coordLoc, 2, GL_FLOAT, GL_FALSE, 0, NULL); 676e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glVertexAttribPointer()"); 677e5c31af7Sopenharmony_ci 678e5c31af7Sopenharmony_ci GLint samplerLoc = gl.getUniformLocation(m_programs[0]->getProgram(), "u_sampler"); 679e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glGetUniformLocation()"); 680e5c31af7Sopenharmony_ci 681e5c31af7Sopenharmony_ci gl.bindTexture(GL_TEXTURE_2D, m_textures[0]); 682e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture()"); 683e5c31af7Sopenharmony_ci 684e5c31af7Sopenharmony_ci gl.uniform1i(samplerLoc, 0); 685e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glUniform1i()"); 686e5c31af7Sopenharmony_ci 687e5c31af7Sopenharmony_ci gl.viewport(0, 0, VIEWPORT_WIDTH, VIEWPORT_HEIGHT); 688e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glViewport()"); 689e5c31af7Sopenharmony_ci }), 690e5c31af7Sopenharmony_ci MACRO_BLOCK({ 691e5c31af7Sopenharmony_ci gl.viewport(10, 11, 5, 6); 692e5c31af7Sopenharmony_ci }) 693e5c31af7Sopenharmony_ci ) 694e5c31af7Sopenharmony_ci 695e5c31af7Sopenharmony_ci ADD_TESTCASE(scissor, "Change scissor box.", 696e5c31af7Sopenharmony_ci true, 697e5c31af7Sopenharmony_ci false, 698e5c31af7Sopenharmony_ci MACRO_BLOCK({ 699e5c31af7Sopenharmony_ci requireCoordBuffers(1); 700e5c31af7Sopenharmony_ci requireTextures(1); 701e5c31af7Sopenharmony_ci requirePrograms(1); 702e5c31af7Sopenharmony_ci 703e5c31af7Sopenharmony_ci gl.useProgram(m_programs[0]->getProgram()); 704e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glUseProgram()"); 705e5c31af7Sopenharmony_ci GLint coordLoc = gl.getAttribLocation(m_programs[0]->getProgram(), "a_coord"); 706e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glGetAttribLocation()"); 707e5c31af7Sopenharmony_ci 708e5c31af7Sopenharmony_ci gl.enableVertexAttribArray(coordLoc); 709e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glEnableVertexAttribArray()"); 710e5c31af7Sopenharmony_ci gl.bindBuffer(GL_ARRAY_BUFFER, m_coordBuffers[0]); 711e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer()"); 712e5c31af7Sopenharmony_ci gl.vertexAttribPointer(coordLoc, 2, GL_FLOAT, GL_FALSE, 0, NULL); 713e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glVertexAttribPointer()"); 714e5c31af7Sopenharmony_ci 715e5c31af7Sopenharmony_ci GLint samplerLoc = gl.getUniformLocation(m_programs[0]->getProgram(), "u_sampler"); 716e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glGetUniformLocation()"); 717e5c31af7Sopenharmony_ci 718e5c31af7Sopenharmony_ci gl.bindTexture(GL_TEXTURE_2D, m_textures[0]); 719e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture()"); 720e5c31af7Sopenharmony_ci 721e5c31af7Sopenharmony_ci gl.uniform1i(samplerLoc, 0); 722e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glUniform1i()"); 723e5c31af7Sopenharmony_ci 724e5c31af7Sopenharmony_ci gl.viewport(0, 0, VIEWPORT_WIDTH, VIEWPORT_HEIGHT); 725e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glViewport()"); 726e5c31af7Sopenharmony_ci 727e5c31af7Sopenharmony_ci gl.enable(GL_SCISSOR_TEST); 728e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glEnable()"); 729e5c31af7Sopenharmony_ci }), 730e5c31af7Sopenharmony_ci MACRO_BLOCK({ 731e5c31af7Sopenharmony_ci gl.scissor(17, 13, 5, 8); 732e5c31af7Sopenharmony_ci }) 733e5c31af7Sopenharmony_ci ) 734e5c31af7Sopenharmony_ci 735e5c31af7Sopenharmony_ci ADD_TESTCASE(color_mask, "Change color mask.", 736e5c31af7Sopenharmony_ci true, 737e5c31af7Sopenharmony_ci false, 738e5c31af7Sopenharmony_ci MACRO_BLOCK({ 739e5c31af7Sopenharmony_ci requireCoordBuffers(1); 740e5c31af7Sopenharmony_ci requireTextures(1); 741e5c31af7Sopenharmony_ci requirePrograms(1); 742e5c31af7Sopenharmony_ci 743e5c31af7Sopenharmony_ci gl.useProgram(m_programs[0]->getProgram()); 744e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glUseProgram()"); 745e5c31af7Sopenharmony_ci GLint coordLoc = gl.getAttribLocation(m_programs[0]->getProgram(), "a_coord"); 746e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glGetAttribLocation()"); 747e5c31af7Sopenharmony_ci 748e5c31af7Sopenharmony_ci gl.enableVertexAttribArray(coordLoc); 749e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glEnableVertexAttribArray()"); 750e5c31af7Sopenharmony_ci gl.bindBuffer(GL_ARRAY_BUFFER, m_coordBuffers[0]); 751e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer()"); 752e5c31af7Sopenharmony_ci gl.vertexAttribPointer(coordLoc, 2, GL_FLOAT, GL_FALSE, 0, NULL); 753e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glVertexAttribPointer()"); 754e5c31af7Sopenharmony_ci 755e5c31af7Sopenharmony_ci GLint samplerLoc = gl.getUniformLocation(m_programs[0]->getProgram(), "u_sampler"); 756e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glGetUniformLocation()"); 757e5c31af7Sopenharmony_ci 758e5c31af7Sopenharmony_ci gl.bindTexture(GL_TEXTURE_2D, m_textures[0]); 759e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture()"); 760e5c31af7Sopenharmony_ci 761e5c31af7Sopenharmony_ci gl.uniform1i(samplerLoc, 0); 762e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glUniform1i()"); 763e5c31af7Sopenharmony_ci 764e5c31af7Sopenharmony_ci gl.viewport(0, 0, VIEWPORT_WIDTH, VIEWPORT_HEIGHT); 765e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glViewport()"); 766e5c31af7Sopenharmony_ci }), 767e5c31af7Sopenharmony_ci MACRO_BLOCK({ 768e5c31af7Sopenharmony_ci gl.colorMask(GL_TRUE, GL_FALSE, GL_TRUE, GL_FALSE); 769e5c31af7Sopenharmony_ci }) 770e5c31af7Sopenharmony_ci ) 771e5c31af7Sopenharmony_ci 772e5c31af7Sopenharmony_ci ADD_TESTCASE(cull_face, "Change culling mode.", 773e5c31af7Sopenharmony_ci true, 774e5c31af7Sopenharmony_ci false, 775e5c31af7Sopenharmony_ci MACRO_BLOCK({ 776e5c31af7Sopenharmony_ci requireCoordBuffers(1); 777e5c31af7Sopenharmony_ci requireTextures(1); 778e5c31af7Sopenharmony_ci requirePrograms(1); 779e5c31af7Sopenharmony_ci 780e5c31af7Sopenharmony_ci gl.useProgram(m_programs[0]->getProgram()); 781e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glUseProgram()"); 782e5c31af7Sopenharmony_ci GLint coordLoc = gl.getAttribLocation(m_programs[0]->getProgram(), "a_coord"); 783e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glGetAttribLocation()"); 784e5c31af7Sopenharmony_ci 785e5c31af7Sopenharmony_ci gl.enableVertexAttribArray(coordLoc); 786e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glEnableVertexAttribArray()"); 787e5c31af7Sopenharmony_ci gl.bindBuffer(GL_ARRAY_BUFFER, m_coordBuffers[0]); 788e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer()"); 789e5c31af7Sopenharmony_ci gl.vertexAttribPointer(coordLoc, 2, GL_FLOAT, GL_FALSE, 0, NULL); 790e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glVertexAttribPointer()"); 791e5c31af7Sopenharmony_ci 792e5c31af7Sopenharmony_ci GLint samplerLoc = gl.getUniformLocation(m_programs[0]->getProgram(), "u_sampler"); 793e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glGetUniformLocation()"); 794e5c31af7Sopenharmony_ci 795e5c31af7Sopenharmony_ci gl.bindTexture(GL_TEXTURE_2D, m_textures[0]); 796e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture()"); 797e5c31af7Sopenharmony_ci 798e5c31af7Sopenharmony_ci gl.uniform1i(samplerLoc, 0); 799e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glUniform1i()"); 800e5c31af7Sopenharmony_ci 801e5c31af7Sopenharmony_ci gl.viewport(0, 0, VIEWPORT_WIDTH, VIEWPORT_HEIGHT); 802e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glViewport()"); 803e5c31af7Sopenharmony_ci 804e5c31af7Sopenharmony_ci gl.enable(GL_CULL_FACE); 805e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glEnable()"); 806e5c31af7Sopenharmony_ci }), 807e5c31af7Sopenharmony_ci MACRO_BLOCK({ 808e5c31af7Sopenharmony_ci gl.cullFace(GL_FRONT); 809e5c31af7Sopenharmony_ci }) 810e5c31af7Sopenharmony_ci ) 811e5c31af7Sopenharmony_ci 812e5c31af7Sopenharmony_ci ADD_TESTCASE(front_face, "Change front face.", 813e5c31af7Sopenharmony_ci true, 814e5c31af7Sopenharmony_ci false, 815e5c31af7Sopenharmony_ci MACRO_BLOCK({ 816e5c31af7Sopenharmony_ci requireCoordBuffers(1); 817e5c31af7Sopenharmony_ci requireTextures(1); 818e5c31af7Sopenharmony_ci requirePrograms(1); 819e5c31af7Sopenharmony_ci 820e5c31af7Sopenharmony_ci gl.useProgram(m_programs[0]->getProgram()); 821e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glUseProgram()"); 822e5c31af7Sopenharmony_ci GLint coordLoc = gl.getAttribLocation(m_programs[0]->getProgram(), "a_coord"); 823e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glGetAttribLocation()"); 824e5c31af7Sopenharmony_ci 825e5c31af7Sopenharmony_ci gl.enableVertexAttribArray(coordLoc); 826e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glEnableVertexAttribArray()"); 827e5c31af7Sopenharmony_ci gl.bindBuffer(GL_ARRAY_BUFFER, m_coordBuffers[0]); 828e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer()"); 829e5c31af7Sopenharmony_ci gl.vertexAttribPointer(coordLoc, 2, GL_FLOAT, GL_FALSE, 0, NULL); 830e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glVertexAttribPointer()"); 831e5c31af7Sopenharmony_ci 832e5c31af7Sopenharmony_ci GLint samplerLoc = gl.getUniformLocation(m_programs[0]->getProgram(), "u_sampler"); 833e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glGetUniformLocation()"); 834e5c31af7Sopenharmony_ci 835e5c31af7Sopenharmony_ci gl.bindTexture(GL_TEXTURE_2D, m_textures[0]); 836e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture()"); 837e5c31af7Sopenharmony_ci 838e5c31af7Sopenharmony_ci gl.uniform1i(samplerLoc, 0); 839e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glUniform1i()"); 840e5c31af7Sopenharmony_ci 841e5c31af7Sopenharmony_ci gl.viewport(0, 0, VIEWPORT_WIDTH, VIEWPORT_HEIGHT); 842e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glViewport()"); 843e5c31af7Sopenharmony_ci 844e5c31af7Sopenharmony_ci gl.enable(GL_CULL_FACE); 845e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glEnable()"); 846e5c31af7Sopenharmony_ci }), 847e5c31af7Sopenharmony_ci MACRO_BLOCK({ 848e5c31af7Sopenharmony_ci gl.frontFace(GL_CCW); 849e5c31af7Sopenharmony_ci }) 850e5c31af7Sopenharmony_ci ) 851e5c31af7Sopenharmony_ci 852e5c31af7Sopenharmony_ci ADD_TESTCASE(stencil_mask, "Change stencil mask.", 853e5c31af7Sopenharmony_ci true, 854e5c31af7Sopenharmony_ci false, 855e5c31af7Sopenharmony_ci MACRO_BLOCK({ 856e5c31af7Sopenharmony_ci requireCoordBuffers(1); 857e5c31af7Sopenharmony_ci requireTextures(1); 858e5c31af7Sopenharmony_ci requirePrograms(1); 859e5c31af7Sopenharmony_ci 860e5c31af7Sopenharmony_ci gl.useProgram(m_programs[0]->getProgram()); 861e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glUseProgram()"); 862e5c31af7Sopenharmony_ci GLint coordLoc = gl.getAttribLocation(m_programs[0]->getProgram(), "a_coord"); 863e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glGetAttribLocation()"); 864e5c31af7Sopenharmony_ci 865e5c31af7Sopenharmony_ci gl.enableVertexAttribArray(coordLoc); 866e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glEnableVertexAttribArray()"); 867e5c31af7Sopenharmony_ci gl.bindBuffer(GL_ARRAY_BUFFER, m_coordBuffers[0]); 868e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer()"); 869e5c31af7Sopenharmony_ci gl.vertexAttribPointer(coordLoc, 2, GL_FLOAT, GL_FALSE, 0, NULL); 870e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glVertexAttribPointer()"); 871e5c31af7Sopenharmony_ci 872e5c31af7Sopenharmony_ci GLint samplerLoc = gl.getUniformLocation(m_programs[0]->getProgram(), "u_sampler"); 873e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glGetUniformLocation()"); 874e5c31af7Sopenharmony_ci 875e5c31af7Sopenharmony_ci gl.bindTexture(GL_TEXTURE_2D, m_textures[0]); 876e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture()"); 877e5c31af7Sopenharmony_ci 878e5c31af7Sopenharmony_ci gl.uniform1i(samplerLoc, 0); 879e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glUniform1i()"); 880e5c31af7Sopenharmony_ci 881e5c31af7Sopenharmony_ci gl.viewport(0, 0, VIEWPORT_WIDTH, VIEWPORT_HEIGHT); 882e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glViewport()"); 883e5c31af7Sopenharmony_ci 884e5c31af7Sopenharmony_ci gl.enable(GL_STENCIL_TEST); 885e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glEnable()"); 886e5c31af7Sopenharmony_ci 887e5c31af7Sopenharmony_ci gl.stencilFunc(GL_LEQUAL, 0, 0); 888e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glStencilFunc()"); 889e5c31af7Sopenharmony_ci 890e5c31af7Sopenharmony_ci gl.stencilOp(GL_KEEP, GL_REPLACE, GL_REPLACE); 891e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glStencilOp()"); 892e5c31af7Sopenharmony_ci 893e5c31af7Sopenharmony_ci gl.clearStencil(0); 894e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glClearStencil()"); 895e5c31af7Sopenharmony_ci gl.clear(GL_STENCIL_BUFFER_BIT); 896e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glClear()"); 897e5c31af7Sopenharmony_ci }), 898e5c31af7Sopenharmony_ci MACRO_BLOCK({ 899e5c31af7Sopenharmony_ci gl.stencilMask(0xDD); 900e5c31af7Sopenharmony_ci }) 901e5c31af7Sopenharmony_ci ) 902e5c31af7Sopenharmony_ci 903e5c31af7Sopenharmony_ci ADD_TESTCASE(stencil_func, "Change stencil func.", 904e5c31af7Sopenharmony_ci true, 905e5c31af7Sopenharmony_ci false, 906e5c31af7Sopenharmony_ci MACRO_BLOCK({ 907e5c31af7Sopenharmony_ci requireCoordBuffers(1); 908e5c31af7Sopenharmony_ci requireTextures(1); 909e5c31af7Sopenharmony_ci requirePrograms(1); 910e5c31af7Sopenharmony_ci 911e5c31af7Sopenharmony_ci gl.useProgram(m_programs[0]->getProgram()); 912e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glUseProgram()"); 913e5c31af7Sopenharmony_ci GLint coordLoc = gl.getAttribLocation(m_programs[0]->getProgram(), "a_coord"); 914e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glGetAttribLocation()"); 915e5c31af7Sopenharmony_ci 916e5c31af7Sopenharmony_ci gl.enableVertexAttribArray(coordLoc); 917e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glEnableVertexAttribArray()"); 918e5c31af7Sopenharmony_ci gl.bindBuffer(GL_ARRAY_BUFFER, m_coordBuffers[0]); 919e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer()"); 920e5c31af7Sopenharmony_ci gl.vertexAttribPointer(coordLoc, 2, GL_FLOAT, GL_FALSE, 0, NULL); 921e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glVertexAttribPointer()"); 922e5c31af7Sopenharmony_ci 923e5c31af7Sopenharmony_ci GLint samplerLoc = gl.getUniformLocation(m_programs[0]->getProgram(), "u_sampler"); 924e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glGetUniformLocation()"); 925e5c31af7Sopenharmony_ci 926e5c31af7Sopenharmony_ci gl.bindTexture(GL_TEXTURE_2D, m_textures[0]); 927e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture()"); 928e5c31af7Sopenharmony_ci 929e5c31af7Sopenharmony_ci gl.uniform1i(samplerLoc, 0); 930e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glUniform1i()"); 931e5c31af7Sopenharmony_ci 932e5c31af7Sopenharmony_ci gl.viewport(0, 0, VIEWPORT_WIDTH, VIEWPORT_HEIGHT); 933e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glViewport()"); 934e5c31af7Sopenharmony_ci 935e5c31af7Sopenharmony_ci gl.enable(GL_STENCIL_TEST); 936e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glEnable()"); 937e5c31af7Sopenharmony_ci 938e5c31af7Sopenharmony_ci gl.stencilOp(GL_KEEP, GL_REPLACE, GL_REPLACE); 939e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glStencilOp()"); 940e5c31af7Sopenharmony_ci gl.clearStencil(0); 941e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glClearStencil()"); 942e5c31af7Sopenharmony_ci gl.clear(GL_STENCIL_BUFFER_BIT); 943e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glClear()"); 944e5c31af7Sopenharmony_ci }), 945e5c31af7Sopenharmony_ci MACRO_BLOCK({ 946e5c31af7Sopenharmony_ci gl.stencilFunc(GL_LEQUAL, 0, 0xFF); 947e5c31af7Sopenharmony_ci }) 948e5c31af7Sopenharmony_ci ) 949e5c31af7Sopenharmony_ci 950e5c31af7Sopenharmony_ci ADD_TESTCASE(stencil_op, "Change stencil op.", 951e5c31af7Sopenharmony_ci true, 952e5c31af7Sopenharmony_ci false, 953e5c31af7Sopenharmony_ci MACRO_BLOCK({ 954e5c31af7Sopenharmony_ci requireCoordBuffers(1); 955e5c31af7Sopenharmony_ci requireTextures(1); 956e5c31af7Sopenharmony_ci requirePrograms(1); 957e5c31af7Sopenharmony_ci 958e5c31af7Sopenharmony_ci gl.useProgram(m_programs[0]->getProgram()); 959e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glUseProgram()"); 960e5c31af7Sopenharmony_ci GLint coordLoc = gl.getAttribLocation(m_programs[0]->getProgram(), "a_coord"); 961e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glGetAttribLocation()"); 962e5c31af7Sopenharmony_ci 963e5c31af7Sopenharmony_ci gl.enableVertexAttribArray(coordLoc); 964e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glEnableVertexAttribArray()"); 965e5c31af7Sopenharmony_ci gl.bindBuffer(GL_ARRAY_BUFFER, m_coordBuffers[0]); 966e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer()"); 967e5c31af7Sopenharmony_ci gl.vertexAttribPointer(coordLoc, 2, GL_FLOAT, GL_FALSE, 0, NULL); 968e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glVertexAttribPointer()"); 969e5c31af7Sopenharmony_ci 970e5c31af7Sopenharmony_ci GLint samplerLoc = gl.getUniformLocation(m_programs[0]->getProgram(), "u_sampler"); 971e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glGetUniformLocation()"); 972e5c31af7Sopenharmony_ci 973e5c31af7Sopenharmony_ci gl.bindTexture(GL_TEXTURE_2D, m_textures[0]); 974e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture()"); 975e5c31af7Sopenharmony_ci 976e5c31af7Sopenharmony_ci gl.uniform1i(samplerLoc, 0); 977e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glUniform1i()"); 978e5c31af7Sopenharmony_ci 979e5c31af7Sopenharmony_ci gl.viewport(0, 0, VIEWPORT_WIDTH, VIEWPORT_HEIGHT); 980e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glViewport()"); 981e5c31af7Sopenharmony_ci 982e5c31af7Sopenharmony_ci gl.enable(GL_STENCIL_TEST); 983e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glEnable()"); 984e5c31af7Sopenharmony_ci 985e5c31af7Sopenharmony_ci gl.stencilFunc(GL_LEQUAL, 0, 0); 986e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glStencilFunc()"); 987e5c31af7Sopenharmony_ci 988e5c31af7Sopenharmony_ci gl.clearStencil(0); 989e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glClearStencil()"); 990e5c31af7Sopenharmony_ci 991e5c31af7Sopenharmony_ci gl.clear(GL_STENCIL_BUFFER_BIT); 992e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glClear()"); 993e5c31af7Sopenharmony_ci }), 994e5c31af7Sopenharmony_ci MACRO_BLOCK({ 995e5c31af7Sopenharmony_ci gl.stencilOp(GL_KEEP, GL_REPLACE, GL_REPLACE); 996e5c31af7Sopenharmony_ci }) 997e5c31af7Sopenharmony_ci ) 998e5c31af7Sopenharmony_ci 999e5c31af7Sopenharmony_ci ADD_TESTCASE(bind_array_buffer, "Change array buffer and refresh vertex attrib pointer.", 1000e5c31af7Sopenharmony_ci true, 1001e5c31af7Sopenharmony_ci false, 1002e5c31af7Sopenharmony_ci MACRO_BLOCK({ 1003e5c31af7Sopenharmony_ci requireCoordBuffers(1); 1004e5c31af7Sopenharmony_ci requireTextures(1); 1005e5c31af7Sopenharmony_ci requirePrograms(1); 1006e5c31af7Sopenharmony_ci 1007e5c31af7Sopenharmony_ci gl.bindAttribLocation(m_programs[0]->getProgram(), 0, "a_coord"); 1008e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glBindAttribLocation()"); 1009e5c31af7Sopenharmony_ci gl.linkProgram(m_programs[0]->getProgram()); 1010e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glLinkProgram()"); 1011e5c31af7Sopenharmony_ci 1012e5c31af7Sopenharmony_ci gl.useProgram(m_programs[0]->getProgram()); 1013e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glUseProgram()"); 1014e5c31af7Sopenharmony_ci 1015e5c31af7Sopenharmony_ci gl.enableVertexAttribArray(0); 1016e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glEnableVertexAttribArray()"); 1017e5c31af7Sopenharmony_ci gl.bindBuffer(GL_ARRAY_BUFFER, m_coordBuffers[0]); 1018e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer()"); 1019e5c31af7Sopenharmony_ci gl.vertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 0, NULL); 1020e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glVertexAttribPointer()"); 1021e5c31af7Sopenharmony_ci 1022e5c31af7Sopenharmony_ci GLint samplerLoc = gl.getUniformLocation(m_programs[0]->getProgram(), "u_sampler"); 1023e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glGetUniformLocation()"); 1024e5c31af7Sopenharmony_ci 1025e5c31af7Sopenharmony_ci gl.bindTexture(GL_TEXTURE_2D, m_textures[0]); 1026e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture()"); 1027e5c31af7Sopenharmony_ci 1028e5c31af7Sopenharmony_ci gl.uniform1i(samplerLoc, 0); 1029e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glUniform1i()"); 1030e5c31af7Sopenharmony_ci 1031e5c31af7Sopenharmony_ci gl.viewport(0, 0, VIEWPORT_WIDTH, VIEWPORT_HEIGHT); 1032e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glViewport()"); 1033e5c31af7Sopenharmony_ci }), 1034e5c31af7Sopenharmony_ci MACRO_BLOCK({ 1035e5c31af7Sopenharmony_ci gl.bindBuffer(GL_ARRAY_BUFFER, m_coordBuffers[0]); 1036e5c31af7Sopenharmony_ci gl.vertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 0, NULL); 1037e5c31af7Sopenharmony_ci }) 1038e5c31af7Sopenharmony_ci ) 1039e5c31af7Sopenharmony_ci 1040e5c31af7Sopenharmony_ci ADD_TESTCASE(element_array_buffer, "Change element array buffer.", 1041e5c31af7Sopenharmony_ci false, 1042e5c31af7Sopenharmony_ci true, 1043e5c31af7Sopenharmony_ci MACRO_BLOCK({ 1044e5c31af7Sopenharmony_ci requireCoordBuffers(1); 1045e5c31af7Sopenharmony_ci requireIndexBuffers(1); 1046e5c31af7Sopenharmony_ci requireTextures(1); 1047e5c31af7Sopenharmony_ci requirePrograms(1); 1048e5c31af7Sopenharmony_ci 1049e5c31af7Sopenharmony_ci gl.useProgram(m_programs[0]->getProgram()); 1050e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glUseProgram()"); 1051e5c31af7Sopenharmony_ci GLint coordLoc = gl.getAttribLocation(m_programs[0]->getProgram(), "a_coord"); 1052e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glGetAttribLocation()"); 1053e5c31af7Sopenharmony_ci 1054e5c31af7Sopenharmony_ci gl.enableVertexAttribArray(coordLoc); 1055e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glEnableVertexAttribArray()"); 1056e5c31af7Sopenharmony_ci gl.bindBuffer(GL_ARRAY_BUFFER, m_coordBuffers[0]); 1057e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer()"); 1058e5c31af7Sopenharmony_ci gl.vertexAttribPointer(coordLoc, 2, GL_FLOAT, GL_FALSE, 0, NULL); 1059e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glVertexAttribPointer()"); 1060e5c31af7Sopenharmony_ci 1061e5c31af7Sopenharmony_ci GLint samplerLoc = gl.getUniformLocation(m_programs[0]->getProgram(), "u_sampler"); 1062e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glGetUniformLocation()"); 1063e5c31af7Sopenharmony_ci 1064e5c31af7Sopenharmony_ci gl.bindTexture(GL_TEXTURE_2D, m_textures[0]); 1065e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture()"); 1066e5c31af7Sopenharmony_ci 1067e5c31af7Sopenharmony_ci gl.uniform1i(samplerLoc, 0); 1068e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glUniform1i()"); 1069e5c31af7Sopenharmony_ci 1070e5c31af7Sopenharmony_ci gl.viewport(0, 0, VIEWPORT_WIDTH, VIEWPORT_HEIGHT); 1071e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glViewport()"); 1072e5c31af7Sopenharmony_ci 1073e5c31af7Sopenharmony_ci gl.bindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_indexBuffers[0]); 1074e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer()"); 1075e5c31af7Sopenharmony_ci }), 1076e5c31af7Sopenharmony_ci MACRO_BLOCK({ 1077e5c31af7Sopenharmony_ci gl.bindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_indexBuffers[0]); 1078e5c31af7Sopenharmony_ci }) 1079e5c31af7Sopenharmony_ci ) 1080e5c31af7Sopenharmony_ci 1081e5c31af7Sopenharmony_ci ADD_TESTCASE(bind_texture, "Change texture binding.", 1082e5c31af7Sopenharmony_ci true, 1083e5c31af7Sopenharmony_ci false, 1084e5c31af7Sopenharmony_ci MACRO_BLOCK({ 1085e5c31af7Sopenharmony_ci requireCoordBuffers(1); 1086e5c31af7Sopenharmony_ci requireTextures(1); 1087e5c31af7Sopenharmony_ci requirePrograms(1); 1088e5c31af7Sopenharmony_ci 1089e5c31af7Sopenharmony_ci gl.useProgram(m_programs[0]->getProgram()); 1090e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glUseProgram()"); 1091e5c31af7Sopenharmony_ci GLint coordLoc = gl.getAttribLocation(m_programs[0]->getProgram(), "a_coord"); 1092e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glGetAttribLocation()"); 1093e5c31af7Sopenharmony_ci 1094e5c31af7Sopenharmony_ci gl.enableVertexAttribArray(coordLoc); 1095e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glEnableVertexAttribArray()"); 1096e5c31af7Sopenharmony_ci gl.bindBuffer(GL_ARRAY_BUFFER, m_coordBuffers[0]); 1097e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer()"); 1098e5c31af7Sopenharmony_ci gl.vertexAttribPointer(coordLoc, 2, GL_FLOAT, GL_FALSE, 0, NULL); 1099e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glVertexAttribPointer()"); 1100e5c31af7Sopenharmony_ci 1101e5c31af7Sopenharmony_ci GLint samplerLoc = gl.getUniformLocation(m_programs[0]->getProgram(), "u_sampler"); 1102e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glGetUniformLocation()"); 1103e5c31af7Sopenharmony_ci 1104e5c31af7Sopenharmony_ci gl.bindTexture(GL_TEXTURE_2D, m_textures[0]); 1105e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture()"); 1106e5c31af7Sopenharmony_ci 1107e5c31af7Sopenharmony_ci gl.uniform1i(samplerLoc, 0); 1108e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glUniform1i()"); 1109e5c31af7Sopenharmony_ci 1110e5c31af7Sopenharmony_ci gl.viewport(0, 0, VIEWPORT_WIDTH, VIEWPORT_HEIGHT); 1111e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glViewport()"); 1112e5c31af7Sopenharmony_ci }), 1113e5c31af7Sopenharmony_ci MACRO_BLOCK({ 1114e5c31af7Sopenharmony_ci gl.bindTexture(GL_TEXTURE_2D, m_textures[0]); 1115e5c31af7Sopenharmony_ci }) 1116e5c31af7Sopenharmony_ci ) 1117e5c31af7Sopenharmony_ci 1118e5c31af7Sopenharmony_ci ADD_TESTCASE(use_program, "Change used program.", 1119e5c31af7Sopenharmony_ci true, 1120e5c31af7Sopenharmony_ci false, 1121e5c31af7Sopenharmony_ci MACRO_BLOCK({ 1122e5c31af7Sopenharmony_ci requireCoordBuffers(1); 1123e5c31af7Sopenharmony_ci requireTextures(1); 1124e5c31af7Sopenharmony_ci requirePrograms(1); 1125e5c31af7Sopenharmony_ci 1126e5c31af7Sopenharmony_ci GLint coordLoc = gl.getAttribLocation(m_programs[0]->getProgram(), "a_coord"); 1127e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glGetAttribLocation()"); 1128e5c31af7Sopenharmony_ci 1129e5c31af7Sopenharmony_ci gl.enableVertexAttribArray(coordLoc); 1130e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glEnableVertexAttribArray()"); 1131e5c31af7Sopenharmony_ci gl.bindBuffer(GL_ARRAY_BUFFER, m_coordBuffers[0]); 1132e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer()"); 1133e5c31af7Sopenharmony_ci gl.vertexAttribPointer(coordLoc, 2, GL_FLOAT, GL_FALSE, 0, NULL); 1134e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glVertexAttribPointer()"); 1135e5c31af7Sopenharmony_ci 1136e5c31af7Sopenharmony_ci gl.bindTexture(GL_TEXTURE_2D, m_textures[0]); 1137e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture()"); 1138e5c31af7Sopenharmony_ci 1139e5c31af7Sopenharmony_ci GLint samplerLoc = gl.getUniformLocation(m_programs[0]->getProgram(), "u_sampler"); 1140e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glGetUniformLocation()"); 1141e5c31af7Sopenharmony_ci gl.useProgram(m_programs[0]->getProgram()); 1142e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glUseProgram()"); 1143e5c31af7Sopenharmony_ci gl.uniform1i(samplerLoc, 0); 1144e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glUniform1i()"); 1145e5c31af7Sopenharmony_ci 1146e5c31af7Sopenharmony_ci gl.viewport(0, 0, VIEWPORT_WIDTH, VIEWPORT_HEIGHT); 1147e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glViewport()"); 1148e5c31af7Sopenharmony_ci }), 1149e5c31af7Sopenharmony_ci MACRO_BLOCK({ 1150e5c31af7Sopenharmony_ci gl.useProgram(m_programs[0]->getProgram()); 1151e5c31af7Sopenharmony_ci }) 1152e5c31af7Sopenharmony_ci ) 1153e5c31af7Sopenharmony_ci 1154e5c31af7Sopenharmony_ci ADD_TESTCASE(tex_parameter_min_filter, "Change texture parameter min filter.", 1155e5c31af7Sopenharmony_ci true, 1156e5c31af7Sopenharmony_ci false, 1157e5c31af7Sopenharmony_ci MACRO_BLOCK({ 1158e5c31af7Sopenharmony_ci requireCoordBuffers(1); 1159e5c31af7Sopenharmony_ci requireTextures(1); 1160e5c31af7Sopenharmony_ci requirePrograms(1); 1161e5c31af7Sopenharmony_ci 1162e5c31af7Sopenharmony_ci gl.useProgram(m_programs[0]->getProgram()); 1163e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glUseProgram()"); 1164e5c31af7Sopenharmony_ci GLint coordLoc = gl.getAttribLocation(m_programs[0]->getProgram(), "a_coord"); 1165e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glGetAttribLocation()"); 1166e5c31af7Sopenharmony_ci 1167e5c31af7Sopenharmony_ci gl.enableVertexAttribArray(coordLoc); 1168e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glEnableVertexAttribArray()"); 1169e5c31af7Sopenharmony_ci gl.bindBuffer(GL_ARRAY_BUFFER, m_coordBuffers[0]); 1170e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer()"); 1171e5c31af7Sopenharmony_ci gl.vertexAttribPointer(coordLoc, 2, GL_FLOAT, GL_FALSE, 0, NULL); 1172e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glVertexAttribPointer()"); 1173e5c31af7Sopenharmony_ci 1174e5c31af7Sopenharmony_ci GLint samplerLoc = gl.getUniformLocation(m_programs[0]->getProgram(), "u_sampler"); 1175e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glGetUniformLocation()"); 1176e5c31af7Sopenharmony_ci 1177e5c31af7Sopenharmony_ci gl.bindTexture(GL_TEXTURE_2D, m_textures[0]); 1178e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture()"); 1179e5c31af7Sopenharmony_ci 1180e5c31af7Sopenharmony_ci gl.uniform1i(samplerLoc, 0); 1181e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glUniform1i()"); 1182e5c31af7Sopenharmony_ci 1183e5c31af7Sopenharmony_ci gl.viewport(0, 0, VIEWPORT_WIDTH, VIEWPORT_HEIGHT); 1184e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glViewport()"); 1185e5c31af7Sopenharmony_ci }), 1186e5c31af7Sopenharmony_ci MACRO_BLOCK({ 1187e5c31af7Sopenharmony_ci gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); 1188e5c31af7Sopenharmony_ci }) 1189e5c31af7Sopenharmony_ci ) 1190e5c31af7Sopenharmony_ci 1191e5c31af7Sopenharmony_ci ADD_TESTCASE(tex_parameter_mag_filter, "Change texture parameter mag filter.", 1192e5c31af7Sopenharmony_ci true, 1193e5c31af7Sopenharmony_ci false, 1194e5c31af7Sopenharmony_ci MACRO_BLOCK({ 1195e5c31af7Sopenharmony_ci requireCoordBuffers(1); 1196e5c31af7Sopenharmony_ci requireTextures(1); 1197e5c31af7Sopenharmony_ci requirePrograms(1); 1198e5c31af7Sopenharmony_ci 1199e5c31af7Sopenharmony_ci gl.useProgram(m_programs[0]->getProgram()); 1200e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glUseProgram()"); 1201e5c31af7Sopenharmony_ci GLint coordLoc = gl.getAttribLocation(m_programs[0]->getProgram(), "a_coord"); 1202e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glGetAttribLocation()"); 1203e5c31af7Sopenharmony_ci 1204e5c31af7Sopenharmony_ci gl.enableVertexAttribArray(coordLoc); 1205e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glEnableVertexAttribArray()"); 1206e5c31af7Sopenharmony_ci gl.bindBuffer(GL_ARRAY_BUFFER, m_coordBuffers[0]); 1207e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer()"); 1208e5c31af7Sopenharmony_ci gl.vertexAttribPointer(coordLoc, 2, GL_FLOAT, GL_FALSE, 0, NULL); 1209e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glVertexAttribPointer()"); 1210e5c31af7Sopenharmony_ci 1211e5c31af7Sopenharmony_ci GLint samplerLoc = gl.getUniformLocation(m_programs[0]->getProgram(), "u_sampler"); 1212e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glGetUniformLocation()"); 1213e5c31af7Sopenharmony_ci 1214e5c31af7Sopenharmony_ci gl.bindTexture(GL_TEXTURE_2D, m_textures[0]); 1215e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture()"); 1216e5c31af7Sopenharmony_ci 1217e5c31af7Sopenharmony_ci gl.uniform1i(samplerLoc, 0); 1218e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glUniform1i()"); 1219e5c31af7Sopenharmony_ci 1220e5c31af7Sopenharmony_ci gl.viewport(0, 0, VIEWPORT_WIDTH, VIEWPORT_HEIGHT); 1221e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glViewport()"); 1222e5c31af7Sopenharmony_ci }), 1223e5c31af7Sopenharmony_ci MACRO_BLOCK({ 1224e5c31af7Sopenharmony_ci gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); 1225e5c31af7Sopenharmony_ci }) 1226e5c31af7Sopenharmony_ci ) 1227e5c31af7Sopenharmony_ci 1228e5c31af7Sopenharmony_ci ADD_TESTCASE(tex_parameter_wrap, "Change texture parameter wrap filter.", 1229e5c31af7Sopenharmony_ci true, 1230e5c31af7Sopenharmony_ci false, 1231e5c31af7Sopenharmony_ci MACRO_BLOCK({ 1232e5c31af7Sopenharmony_ci requireCoordBuffers(1); 1233e5c31af7Sopenharmony_ci requireTextures(1); 1234e5c31af7Sopenharmony_ci requirePrograms(1); 1235e5c31af7Sopenharmony_ci 1236e5c31af7Sopenharmony_ci gl.useProgram(m_programs[0]->getProgram()); 1237e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glUseProgram()"); 1238e5c31af7Sopenharmony_ci GLint coordLoc = gl.getAttribLocation(m_programs[0]->getProgram(), "a_coord"); 1239e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glGetAttribLocation()"); 1240e5c31af7Sopenharmony_ci 1241e5c31af7Sopenharmony_ci gl.enableVertexAttribArray(coordLoc); 1242e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glEnableVertexAttribArray()"); 1243e5c31af7Sopenharmony_ci gl.bindBuffer(GL_ARRAY_BUFFER, m_coordBuffers[0]); 1244e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer()"); 1245e5c31af7Sopenharmony_ci gl.vertexAttribPointer(coordLoc, 2, GL_FLOAT, GL_FALSE, 0, NULL); 1246e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glVertexAttribPointer()"); 1247e5c31af7Sopenharmony_ci 1248e5c31af7Sopenharmony_ci GLint samplerLoc = gl.getUniformLocation(m_programs[0]->getProgram(), "u_sampler"); 1249e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glGetUniformLocation()"); 1250e5c31af7Sopenharmony_ci 1251e5c31af7Sopenharmony_ci gl.bindTexture(GL_TEXTURE_2D, m_textures[0]); 1252e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture()"); 1253e5c31af7Sopenharmony_ci 1254e5c31af7Sopenharmony_ci gl.uniform1i(samplerLoc, 0); 1255e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glUniform1i()"); 1256e5c31af7Sopenharmony_ci 1257e5c31af7Sopenharmony_ci gl.viewport(0, 0, VIEWPORT_WIDTH, VIEWPORT_HEIGHT); 1258e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glViewport()"); 1259e5c31af7Sopenharmony_ci }), 1260e5c31af7Sopenharmony_ci MACRO_BLOCK({ 1261e5c31af7Sopenharmony_ci gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); 1262e5c31af7Sopenharmony_ci }) 1263e5c31af7Sopenharmony_ci ) 1264e5c31af7Sopenharmony_ci 1265e5c31af7Sopenharmony_ci ADD_TESTCASE(bind_framebuffer, "Change framebuffer.", 1266e5c31af7Sopenharmony_ci true, 1267e5c31af7Sopenharmony_ci false, 1268e5c31af7Sopenharmony_ci MACRO_BLOCK({ 1269e5c31af7Sopenharmony_ci requireCoordBuffers(1); 1270e5c31af7Sopenharmony_ci requireTextures(1); 1271e5c31af7Sopenharmony_ci requireFramebuffers(1); 1272e5c31af7Sopenharmony_ci requirePrograms(1); 1273e5c31af7Sopenharmony_ci 1274e5c31af7Sopenharmony_ci gl.useProgram(m_programs[0]->getProgram()); 1275e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glUseProgram()"); 1276e5c31af7Sopenharmony_ci GLint coordLoc = gl.getAttribLocation(m_programs[0]->getProgram(), "a_coord"); 1277e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glGetAttribLocation()"); 1278e5c31af7Sopenharmony_ci 1279e5c31af7Sopenharmony_ci gl.enableVertexAttribArray(coordLoc); 1280e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glEnableVertexAttribArray()"); 1281e5c31af7Sopenharmony_ci gl.bindBuffer(GL_ARRAY_BUFFER, m_coordBuffers[0]); 1282e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer()"); 1283e5c31af7Sopenharmony_ci gl.vertexAttribPointer(coordLoc, 2, GL_FLOAT, GL_FALSE, 0, NULL); 1284e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glVertexAttribPointer()"); 1285e5c31af7Sopenharmony_ci 1286e5c31af7Sopenharmony_ci GLint samplerLoc = gl.getUniformLocation(m_programs[0]->getProgram(), "u_sampler"); 1287e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glGetUniformLocation()"); 1288e5c31af7Sopenharmony_ci 1289e5c31af7Sopenharmony_ci gl.bindTexture(GL_TEXTURE_2D, m_textures[0]); 1290e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture()"); 1291e5c31af7Sopenharmony_ci 1292e5c31af7Sopenharmony_ci gl.uniform1i(samplerLoc, 0); 1293e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glUniform1i()"); 1294e5c31af7Sopenharmony_ci 1295e5c31af7Sopenharmony_ci gl.viewport(0, 0, VIEWPORT_WIDTH, VIEWPORT_HEIGHT); 1296e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glViewport()"); 1297e5c31af7Sopenharmony_ci 1298e5c31af7Sopenharmony_ci gl.bindFramebuffer(GL_FRAMEBUFFER, m_framebuffers[0]); 1299e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer()"); 1300e5c31af7Sopenharmony_ci }), 1301e5c31af7Sopenharmony_ci MACRO_BLOCK({ 1302e5c31af7Sopenharmony_ci gl.bindFramebuffer(GL_FRAMEBUFFER, m_framebuffers[0]); 1303e5c31af7Sopenharmony_ci }) 1304e5c31af7Sopenharmony_ci ) 1305e5c31af7Sopenharmony_ci 1306e5c31af7Sopenharmony_ci ADD_TESTCASE(blend_color, "Change blend color.", 1307e5c31af7Sopenharmony_ci true, 1308e5c31af7Sopenharmony_ci false, 1309e5c31af7Sopenharmony_ci MACRO_BLOCK({ 1310e5c31af7Sopenharmony_ci requireCoordBuffers(1); 1311e5c31af7Sopenharmony_ci requireTextures(1); 1312e5c31af7Sopenharmony_ci requirePrograms(1); 1313e5c31af7Sopenharmony_ci 1314e5c31af7Sopenharmony_ci gl.useProgram(m_programs[0]->getProgram()); 1315e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glUseProgram()"); 1316e5c31af7Sopenharmony_ci GLint coordLoc = gl.getAttribLocation(m_programs[0]->getProgram(), "a_coord"); 1317e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glGetAttribLocation()"); 1318e5c31af7Sopenharmony_ci 1319e5c31af7Sopenharmony_ci gl.enableVertexAttribArray(coordLoc); 1320e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glEnableVertexAttribArray()"); 1321e5c31af7Sopenharmony_ci gl.bindBuffer(GL_ARRAY_BUFFER, m_coordBuffers[0]); 1322e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer()"); 1323e5c31af7Sopenharmony_ci gl.vertexAttribPointer(coordLoc, 2, GL_FLOAT, GL_FALSE, 0, NULL); 1324e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glVertexAttribPointer()"); 1325e5c31af7Sopenharmony_ci 1326e5c31af7Sopenharmony_ci GLint samplerLoc = gl.getUniformLocation(m_programs[0]->getProgram(), "u_sampler"); 1327e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glGetUniformLocation()"); 1328e5c31af7Sopenharmony_ci 1329e5c31af7Sopenharmony_ci gl.bindTexture(GL_TEXTURE_2D, m_textures[0]); 1330e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture()"); 1331e5c31af7Sopenharmony_ci 1332e5c31af7Sopenharmony_ci gl.uniform1i(samplerLoc, 0); 1333e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glUniform1i()"); 1334e5c31af7Sopenharmony_ci 1335e5c31af7Sopenharmony_ci gl.viewport(0, 0, VIEWPORT_WIDTH, VIEWPORT_HEIGHT); 1336e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glViewport()"); 1337e5c31af7Sopenharmony_ci 1338e5c31af7Sopenharmony_ci gl.enable(GL_BLEND); 1339e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glEnable()"); 1340e5c31af7Sopenharmony_ci 1341e5c31af7Sopenharmony_ci gl.blendFunc(GL_CONSTANT_COLOR, GL_CONSTANT_COLOR); 1342e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "glBlendFunc()"); 1343e5c31af7Sopenharmony_ci }), 1344e5c31af7Sopenharmony_ci MACRO_BLOCK({ 1345e5c31af7Sopenharmony_ci gl.blendColor(0.75f, 0.75f, 0.75f, 0.75f); 1346e5c31af7Sopenharmony_ci }) 1347e5c31af7Sopenharmony_ci ) 1348e5c31af7Sopenharmony_ci} 1349e5c31af7Sopenharmony_ci 1350e5c31af7Sopenharmony_ci} // Performance 1351e5c31af7Sopenharmony_ci} // gles2 1352e5c31af7Sopenharmony_ci} // deqp 1353