Commit efc551f0 by Geoff Lang

Fix incorrectly named test class members and wrong shader compilation

function being used. TRAC #23776 Signed-off-by: Jamie Madill Signed-off-by: Shannon Woods
parent d5ee05cc
#include "ANGLETest.h" #include "ANGLETest.h"
ANGLETest::ANGLETest() ANGLETest::ANGLETest()
: mClientVersion(2) : mClientVersion(2),
, mWidth(1280) mWidth(1280),
, mHeight(720) mHeight(720),
, mRedBits(-1) mRedBits(-1),
, mGreenBits(-1) mGreenBits(-1),
, mBlueBits(-1) mBlueBits(-1),
, mAlphaBits(-1) mAlphaBits(-1),
, mDepthBits(-1) mDepthBits(-1),
, mStencilBits(-1) mStencilBits(-1),
, mMultisample(false) mMultisample(false)
{ {
} }
...@@ -69,21 +69,52 @@ void ANGLETest::drawQuad(GLuint program, const std::string& positionAttribName, ...@@ -69,21 +69,52 @@ void ANGLETest::drawQuad(GLuint program, const std::string& positionAttribName,
glUseProgram(0); glUseProgram(0);
} }
GLuint ANGLETest::compileShader(GLenum type, const std::string &source)
{
GLuint shader = glCreateShader(type);
const char *sourceArray[1] = { source.c_str() };
glShaderSource(shader, 1, sourceArray, NULL);
glCompileShader(shader);
GLint compileResult;
glGetShaderiv(shader, GL_COMPILE_STATUS, &compileResult);
if (compileResult == 0)
{
GLint infoLogLength;
glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &infoLogLength);
std::vector<GLchar> infoLog(infoLogLength);
glGetShaderInfoLog(shader, infoLog.size(), NULL, infoLog.data());
std::cerr << "shader compilation failed: " << infoLog.data();
glDeleteShader(shader);
shader = 0;
}
return shader;
}
GLuint ANGLETest::compileProgram(const std::string &vsSource, const std::string &fsSource) GLuint ANGLETest::compileProgram(const std::string &vsSource, const std::string &fsSource)
{ {
GLuint program = glCreateProgram(); GLuint program = glCreateProgram();
GLuint vs = glCreateShader(GL_VERTEX_SHADER); GLuint vs = compileShader(GL_VERTEX_SHADER, vsSource);
const char *vsSourceArray[1] = { vsSource.c_str() }; GLuint fs = compileShader(GL_FRAGMENT_SHADER, fsSource);
glShaderSource(vs, 1, vsSourceArray, NULL);
glCompileShader(vs); if (vs == 0 || fs == 0)
{
glDeleteShader(fs);
glDeleteShader(vs);
glDeleteProgram(program);
return 0;
}
glAttachShader(program, vs); glAttachShader(program, vs);
glDeleteShader(vs); glDeleteShader(vs);
GLuint fs = glCreateShader(GL_FRAGMENT_SHADER);
const char *fsSourceArray[1] = { fsSource.c_str() };
glShaderSource(fs, 1, fsSourceArray, NULL);
glCompileShader(fs);
glAttachShader(program, fs); glAttachShader(program, fs);
glDeleteShader(fs); glDeleteShader(fs);
...@@ -92,10 +123,18 @@ GLuint ANGLETest::compileProgram(const std::string &vsSource, const std::string ...@@ -92,10 +123,18 @@ GLuint ANGLETest::compileProgram(const std::string &vsSource, const std::string
GLint linkStatus; GLint linkStatus;
glGetProgramiv(program, GL_LINK_STATUS, &linkStatus); glGetProgramiv(program, GL_LINK_STATUS, &linkStatus);
if (!linkStatus) if (linkStatus == 0)
{ {
GLint infoLogLength;
glGetProgramiv(program, GL_INFO_LOG_LENGTH, &infoLogLength);
std::vector<GLchar> infoLog(infoLogLength);
glGetProgramInfoLog(program, infoLog.size(), NULL, infoLog.data());
std::cerr << "program link failed: " << infoLog.data();
glDeleteProgram(program); glDeleteProgram(program);
program = 0; return 0;
} }
return program; return program;
...@@ -122,32 +161,32 @@ void ANGLETest::setWindowHeight(int height) ...@@ -122,32 +161,32 @@ void ANGLETest::setWindowHeight(int height)
mHeight = height; mHeight = height;
} }
void ANGLETest::setRedBits(int bits) void ANGLETest::setConfigRedBits(int bits)
{ {
mRedBits = bits; mRedBits = bits;
} }
void ANGLETest::setGreenBits(int bits) void ANGLETest::setConfigGreenBits(int bits)
{ {
mGreenBits = bits; mGreenBits = bits;
} }
void ANGLETest::setBlueBits(int bits) void ANGLETest::setConfigBlueBits(int bits)
{ {
mBlueBits = bits; mBlueBits = bits;
} }
void ANGLETest::setAlphaBits(int bits) void ANGLETest::setConfigAlphaBits(int bits)
{ {
mAlphaBits = bits; mAlphaBits = bits;
} }
void ANGLETest::setDepthBits(int bits) void ANGLETest::setConfigDepthBits(int bits)
{ {
mDepthBits = bits; mDepthBits = bits;
} }
void ANGLETest::setStencilBits(int bits) void ANGLETest::setConfigStencilBits(int bits)
{ {
mStencilBits = bits; mStencilBits = bits;
} }
...@@ -172,37 +211,37 @@ int ANGLETest::getWindowHeight() const ...@@ -172,37 +211,37 @@ int ANGLETest::getWindowHeight() const
return mHeight; return mHeight;
} }
int ANGLETest::getRedBits() const int ANGLETest::getConfigRedBits() const
{ {
return mRedBits; return mRedBits;
} }
int ANGLETest::getGreenBits() const int ANGLETest::getConfigGreenBits() const
{ {
return mGreenBits; return mGreenBits;
} }
int ANGLETest::getBlueBits() const int ANGLETest::getConfigBlueBits() const
{ {
return mBlueBits; return mBlueBits;
} }
int ANGLETest::getAlphaBits() const int ANGLETest::getConfigAlphaBits() const
{ {
return mAlphaBits; return mAlphaBits;
} }
int ANGLETest::getDepthBits() const int ANGLETest::getConfigDepthBits() const
{ {
return mDepthBits; return mDepthBits;
} }
int ANGLETest::getStencilBits() const int ANGLETest::getConfigStencilBits() const
{ {
return mStencilBits; return mStencilBits;
} }
bool ANGLETest::multisampleEnabled() const bool ANGLETest::isMultisampleEnabled() const
{ {
return mMultisample; return mMultisample;
} }
......
...@@ -54,30 +54,31 @@ class ANGLETest : public testing::Test ...@@ -54,30 +54,31 @@ class ANGLETest : public testing::Test
virtual void swapBuffers(); virtual void swapBuffers();
static void drawQuad(GLuint program, const std::string& positionAttribName, GLfloat quadDepth); static void drawQuad(GLuint program, const std::string& positionAttribName, GLfloat quadDepth);
static GLuint compileShader(GLenum type, const std::string &source);
static GLuint compileProgram(const std::string &vsSource, const std::string &fsSource); static GLuint compileProgram(const std::string &vsSource, const std::string &fsSource);
static bool extensionEnabled(const std::string &extName); static bool extensionEnabled(const std::string &extName);
void setClientVersion(int clientVersion); void setClientVersion(int clientVersion);
void setWindowWidth(int width); void setWindowWidth(int width);
void setWindowHeight(int height); void setWindowHeight(int height);
void setRedBits(int bits); void setConfigRedBits(int bits);
void setGreenBits(int bits); void setConfigGreenBits(int bits);
void setBlueBits(int bits); void setConfigBlueBits(int bits);
void setAlphaBits(int bits); void setConfigAlphaBits(int bits);
void setDepthBits(int bits); void setConfigDepthBits(int bits);
void setStencilBits(int bits); void setConfigStencilBits(int bits);
void setMultisampleEnabled(bool enabled); void setMultisampleEnabled(bool enabled);
int getClientVersion() const; int getClientVersion() const;
int getWindowWidth() const; int getWindowWidth() const;
int getWindowHeight() const; int getWindowHeight() const;
int getRedBits() const; int getConfigRedBits() const;
int getGreenBits() const; int getConfigGreenBits() const;
int getBlueBits() const; int getConfigBlueBits() const;
int getAlphaBits() const; int getConfigAlphaBits() const;
int getDepthBits() const; int getConfigDepthBits() const;
int getStencilBits() const; int getConfigStencilBits() const;
bool multisampleEnabled() const; bool isMultisampleEnabled() const;
private: private:
bool createEGLContext(); bool createEGLContext();
......
...@@ -7,11 +7,11 @@ protected: ...@@ -7,11 +7,11 @@ protected:
{ {
setWindowWidth(256); setWindowWidth(256);
setWindowHeight(256); setWindowHeight(256);
setRedBits(8); setConfigRedBits(8);
setGreenBits(8); setConfigGreenBits(8);
setBlueBits(8); setConfigBlueBits(8);
setAlphaBits(8); setConfigAlphaBits(8);
setDepthBits(24); setConfigDepthBits(24);
mCheckerProgram = 0; mCheckerProgram = 0;
mBlueProgram = 0; mBlueProgram = 0;
......
...@@ -7,11 +7,11 @@ protected: ...@@ -7,11 +7,11 @@ protected:
{ {
setWindowWidth(128); setWindowWidth(128);
setWindowHeight(128); setWindowHeight(128);
setRedBits(8); setConfigRedBits(8);
setGreenBits(8); setConfigGreenBits(8);
setBlueBits(8); setConfigBlueBits(8);
setAlphaBits(8); setConfigAlphaBits(8);
setDepthBits(24); setConfigDepthBits(24);
} }
virtual void SetUp() virtual void SetUp()
......
...@@ -7,11 +7,11 @@ protected: ...@@ -7,11 +7,11 @@ protected:
{ {
setWindowWidth(128); setWindowWidth(128);
setWindowHeight(128); setWindowHeight(128);
setRedBits(8); setConfigRedBits(8);
setGreenBits(8); setConfigGreenBits(8);
setBlueBits(8); setConfigBlueBits(8);
setAlphaBits(8); setConfigAlphaBits(8);
setDepthBits(24); setConfigDepthBits(24);
mProgram = 0; mProgram = 0;
} }
......
...@@ -9,11 +9,11 @@ protected: ...@@ -9,11 +9,11 @@ protected:
{ {
setWindowWidth(128); setWindowWidth(128);
setWindowHeight(128); setWindowHeight(128);
setRedBits(8); setConfigRedBits(8);
setGreenBits(8); setConfigGreenBits(8);
setBlueBits(8); setConfigBlueBits(8);
setAlphaBits(8); setConfigAlphaBits(8);
setDepthBits(24); setConfigDepthBits(24);
mProgram = 0; mProgram = 0;
} }
......
...@@ -7,11 +7,11 @@ protected: ...@@ -7,11 +7,11 @@ protected:
{ {
setWindowWidth(128); setWindowWidth(128);
setWindowHeight(128); setWindowHeight(128);
setRedBits(8); setConfigRedBits(8);
setGreenBits(8); setConfigGreenBits(8);
setBlueBits(8); setConfigBlueBits(8);
setAlphaBits(8); setConfigAlphaBits(8);
setDepthBits(24); setConfigDepthBits(24);
mProgram = 0; mProgram = 0;
mTestAttrib = -1; mTestAttrib = -1;
......
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