OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2010 The Chromium OS Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "base/logging.h" |
| 6 #include "main.h" |
| 7 #include "testbase.h" |
| 8 #include "utils.h" |
| 9 |
| 10 namespace glbench { |
| 11 |
| 12 |
| 13 class FillRateTest : public DrawArraysTestFunc { |
| 14 public: |
| 15 FillRateTest() {} |
| 16 virtual ~FillRateTest() {} |
| 17 virtual bool Run(); |
| 18 |
| 19 private: |
| 20 DISALLOW_COPY_AND_ASSIGN(FillRateTest); |
| 21 }; |
| 22 |
| 23 |
| 24 bool FillRateTest::Run() { |
| 25 glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT); |
| 26 glDisable(GL_DEPTH_TEST); |
| 27 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); |
| 28 |
| 29 GLfloat buffer_vertex[8] = { |
| 30 -1.f, -1.f, |
| 31 1.f, -1.f, |
| 32 -1.f, 1.f, |
| 33 1.f, 1.f, |
| 34 }; |
| 35 GLfloat buffer_texture[8] = { |
| 36 0.f, 0.f, |
| 37 1.f, 0.f, |
| 38 0.f, 1.f, |
| 39 1.f, 1.f, |
| 40 }; |
| 41 glEnableClientState(GL_VERTEX_ARRAY); |
| 42 |
| 43 GLuint vbo_vertex = SetupVBO(GL_ARRAY_BUFFER, |
| 44 sizeof(buffer_vertex), buffer_vertex); |
| 45 glVertexPointer(2, GL_FLOAT, 0, 0); |
| 46 |
| 47 GLuint vbo_texture = SetupVBO(GL_ARRAY_BUFFER, |
| 48 sizeof(buffer_texture), buffer_texture); |
| 49 glTexCoordPointer(2, GL_FLOAT, 0, 0); |
| 50 |
| 51 glColor4f(1.f, 0.f, 0.f, 1.f); |
| 52 FillRateTestNormal("fill_solid"); |
| 53 FillRateTestBlendDepth("fill_solid"); |
| 54 |
| 55 glColor4f(1.f, 1.f, 1.f, 1.f); |
| 56 glEnableClientState(GL_TEXTURE_COORD_ARRAY); |
| 57 glEnable(GL_TEXTURE_2D); |
| 58 |
| 59 GLuint texture = SetupTexture(9); |
| 60 FillRateTestNormal("fill_tex_nearest"); |
| 61 |
| 62 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); |
| 63 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); |
| 64 FillRateTestNormal("fill_tex_bilinear"); |
| 65 |
| 66 // lod = 0.5 |
| 67 glScalef(0.7071f, 0.7071f, 1.f); |
| 68 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, |
| 69 GL_LINEAR_MIPMAP_NEAREST); |
| 70 FillRateTestNormalSubWindow("fill_tex_trilinear_nearest_05", |
| 71 0.7071f * g_width, 0.7071f * g_height); |
| 72 |
| 73 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, |
| 74 GL_LINEAR_MIPMAP_LINEAR); |
| 75 FillRateTestNormalSubWindow("fill_tex_trilinear_linear_05", |
| 76 0.7071f * g_width, 0.7071f * g_height); |
| 77 |
| 78 // lod = 0.4 |
| 79 glLoadIdentity(); |
| 80 glScalef(0.758f, 0.758f, 1.f); |
| 81 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, |
| 82 GL_LINEAR_MIPMAP_LINEAR); |
| 83 FillRateTestNormalSubWindow("fill_tex_trilinear_linear_04", |
| 84 0.758f * g_width, 0.758f * g_height); |
| 85 |
| 86 // lod = 0.1 |
| 87 glLoadIdentity(); |
| 88 glScalef(0.933f, 0.933f, 1.f); |
| 89 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, |
| 90 GL_LINEAR_MIPMAP_LINEAR); |
| 91 FillRateTestNormalSubWindow("fill_tex_trilinear_linear_01", |
| 92 0.933f * g_width, 0.933f * g_height); |
| 93 |
| 94 glDeleteBuffers(1, &vbo_vertex); |
| 95 glDeleteBuffers(1, &vbo_texture); |
| 96 glDeleteTextures(1, &texture); |
| 97 |
| 98 return true; |
| 99 } |
| 100 |
| 101 TestBase* GetFillRateTest() { |
| 102 return new FillRateTest; |
| 103 } |
| 104 |
| 105 } // namespace glbench |
OLD | NEW |