Commit 4a8329f2 by Olli Etuaho

Refactoring: Split TextureTest to multiple classes

This removes the cube map setup and the draw scale parameter from the tests that don't need them, and reuses the code for setting up the window and the shader program for most of the texture tests. The tests are now structured as follows: TexCoordDrawTest: Test class that sets up a shader program for drawing with texture coordinates. Vertex shader source can be overridden in subclasses, and fragment shader source must be specified in subclasses. Texture2DTest: Inherits TexCoordDrawTest, sets up a 2D texture and a shader for drawing from it. Texture2DTestWithDrawScale: Inherits Texture2DTest, adding a scale parameter that scales the quad that gets drawn. TextureCubeTest: Inherits TexCoordDrawTest, sets up a cube map and a 2D texture and a shader for drawing from them. Texture2DArrayTestES3: Inherits TexCoordDrawTest. Reserves a texture ID and sets up an ESSL3 shader for drawing from a 2D texture array. Also add a few comments about where things being tested are specified. Also, ANGLETest::drawQuad parameter names are renamed to make their meaning clearer. The parameters affect the vertex shader attribute values, which the shader may use for other things besides setting the vertex position. BUG=angleproject:1261 TEST=angle_end2end_tests Change-Id: Id673e36d5883aaaf47f2f830c2a1ad0ca293d578 Reviewed-on: https://chromium-review.googlesource.com/321620Reviewed-by: 's avatarZhenyao Mo <zmo@chromium.org> Tested-by: 's avatarOlli Etuaho <oetuaho@nvidia.com>
parent 74f44506
...@@ -94,21 +94,30 @@ void ANGLETest::swapBuffers() ...@@ -94,21 +94,30 @@ void ANGLETest::swapBuffers()
} }
} }
void ANGLETest::drawQuad(GLuint program, const std::string& positionAttribName, GLfloat quadDepth, GLfloat quadScale) void ANGLETest::drawQuad(GLuint program,
const std::string &positionAttribName,
GLfloat positionAttribZ)
{
drawQuad(program, positionAttribName, positionAttribZ, 1.0f);
}
void ANGLETest::drawQuad(GLuint program,
const std::string &positionAttribName,
GLfloat positionAttribZ,
GLfloat positionAttribXYScale)
{ {
GLint positionLocation = glGetAttribLocation(program, positionAttribName.c_str()); GLint positionLocation = glGetAttribLocation(program, positionAttribName.c_str());
glUseProgram(program); glUseProgram(program);
const GLfloat vertices[] = const GLfloat vertices[] = {
{ -1.0f * positionAttribXYScale, 1.0f * positionAttribXYScale, positionAttribZ,
-1.0f * quadScale, 1.0f * quadScale, quadDepth, -1.0f * positionAttribXYScale, -1.0f * positionAttribXYScale, positionAttribZ,
-1.0f * quadScale, -1.0f * quadScale, quadDepth, 1.0f * positionAttribXYScale, -1.0f * positionAttribXYScale, positionAttribZ,
1.0f * quadScale, -1.0f * quadScale, quadDepth,
-1.0f * quadScale, 1.0f * quadScale, quadDepth, -1.0f * positionAttribXYScale, 1.0f * positionAttribXYScale, positionAttribZ,
1.0f * quadScale, -1.0f * quadScale, quadDepth, 1.0f * positionAttribXYScale, -1.0f * positionAttribXYScale, positionAttribZ,
1.0f * quadScale, 1.0f * quadScale, quadDepth, 1.0f * positionAttribXYScale, 1.0f * positionAttribXYScale, positionAttribZ,
}; };
glVertexAttribPointer(positionLocation, 3, GL_FLOAT, GL_FALSE, 0, vertices); glVertexAttribPointer(positionLocation, 3, GL_FLOAT, GL_FALSE, 0, vertices);
......
...@@ -82,7 +82,13 @@ class ANGLETest : public ::testing::TestWithParam<angle::PlatformParameters> ...@@ -82,7 +82,13 @@ class ANGLETest : public ::testing::TestWithParam<angle::PlatformParameters>
virtual void swapBuffers(); virtual void swapBuffers();
static void drawQuad(GLuint program, const std::string& positionAttribName, GLfloat quadDepth, GLfloat quadScale = 1.0f); static void drawQuad(GLuint program,
const std::string &positionAttribName,
GLfloat positionAttribZ);
static void drawQuad(GLuint program,
const std::string &positionAttribName,
GLfloat positionAttribZ,
GLfloat positionAttribXYScale);
static GLuint compileShader(GLenum type, const std::string &source); static GLuint compileShader(GLenum type, const std::string &source);
static bool extensionEnabled(const std::string &extName); static bool extensionEnabled(const std::string &extName);
static bool eglClientExtensionEnabled(const std::string &extName); static bool eglClientExtensionEnabled(const std::string &extName);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment