Geoff Lang | d191317 | 2013-10-18 16:15:10 -0400 | [diff] [blame] | 1 | #include "ANGLETest.h" |
| 2 | |
| 3 | class ClearTest : public ANGLETest |
| 4 | { |
| 5 | protected: |
| 6 | ClearTest() |
| 7 | { |
| 8 | setWindowWidth(128); |
| 9 | setWindowHeight(128); |
Geoff Lang | efc551f | 2013-10-31 10:20:28 -0400 | [diff] [blame] | 10 | setConfigRedBits(8); |
| 11 | setConfigGreenBits(8); |
| 12 | setConfigBlueBits(8); |
| 13 | setConfigAlphaBits(8); |
| 14 | setConfigDepthBits(24); |
Geoff Lang | d191317 | 2013-10-18 16:15:10 -0400 | [diff] [blame] | 15 | } |
| 16 | |
| 17 | virtual void SetUp() |
| 18 | { |
| 19 | ANGLETest::SetUp(); |
| 20 | |
| 21 | const std::string vertexShaderSource = SHADER_SOURCE |
| 22 | ( |
| 23 | precision highp float; |
| 24 | attribute vec4 position; |
| 25 | |
| 26 | void main() |
| 27 | { |
| 28 | gl_Position = position; |
| 29 | } |
| 30 | ); |
| 31 | |
| 32 | const std::string fragmentShaderSource = SHADER_SOURCE |
| 33 | ( |
| 34 | precision highp float; |
| 35 | |
| 36 | void main() |
| 37 | { |
| 38 | gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0); |
| 39 | } |
| 40 | ); |
| 41 | |
| 42 | mProgram = compileProgram(vertexShaderSource, fragmentShaderSource); |
| 43 | if (mProgram == 0) |
| 44 | { |
| 45 | FAIL() << "shader compilation failed."; |
| 46 | } |
| 47 | } |
| 48 | |
| 49 | virtual void TearDown() |
| 50 | { |
| 51 | glDeleteProgram(mProgram); |
| 52 | |
| 53 | ANGLETest::TearDown(); |
| 54 | } |
| 55 | |
| 56 | GLuint mProgram; |
| 57 | }; |
| 58 | |
Jamie Madill | b759a74 | 2014-07-17 10:40:49 -0400 | [diff] [blame^] | 59 | TEST_F(ClearTest, ClearIssue) |
Geoff Lang | d191317 | 2013-10-18 16:15:10 -0400 | [diff] [blame] | 60 | { |
| 61 | EXPECT_GL_NO_ERROR(); |
| 62 | |
| 63 | glEnable(GL_DEPTH_TEST); |
| 64 | glDepthFunc(GL_LEQUAL); |
| 65 | |
| 66 | glClearColor(0.0, 1.0, 0.0, 1.0); |
| 67 | glClearDepthf(0.0); |
| 68 | glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); |
| 69 | |
| 70 | EXPECT_GL_NO_ERROR(); |
| 71 | |
| 72 | GLuint fbo; |
| 73 | glGenFramebuffers(1, &fbo); |
| 74 | glBindFramebuffer(GL_FRAMEBUFFER, fbo); |
| 75 | |
| 76 | GLuint rbo; |
| 77 | glGenRenderbuffers(1, &rbo); |
| 78 | glBindRenderbuffer(GL_RENDERBUFFER, rbo); |
| 79 | glRenderbufferStorage(GL_RENDERBUFFER, GL_RGB565, 16, 16); |
| 80 | |
| 81 | EXPECT_GL_NO_ERROR(); |
| 82 | |
| 83 | glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, rbo); |
| 84 | |
| 85 | EXPECT_GL_NO_ERROR(); |
| 86 | |
| 87 | glClearColor(1.0f, 0.0f, 0.0f, 1.0f); |
| 88 | glClearDepthf(1.0f); |
| 89 | glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); |
| 90 | |
| 91 | EXPECT_GL_NO_ERROR(); |
| 92 | |
| 93 | glBindFramebuffer(GL_FRAMEBUFFER, 0); |
| 94 | glBindBuffer(GL_ARRAY_BUFFER, 0); |
| 95 | |
| 96 | drawQuad(mProgram, "position", 0.5f); |
| 97 | |
| 98 | EXPECT_PIXEL_EQ(0, 0, 0, 255, 0, 255); |
| 99 | } |