• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //
2 // Copyright 2018 The ANGLE Project Authors. All rights reserved.
3 // Use of this source code is governed by a BSD-style license that can be
4 // found in the LICENSE file.
5 //
6 
7 // VertexPointerTest.cpp: Tests basic usage of built-in vertex attributes of GLES1.
8 
9 #include "test_utils/ANGLETest.h"
10 #include "test_utils/gl_raii.h"
11 
12 using namespace angle;
13 
14 class VertexPointerTest : public ANGLETest
15 {
16   protected:
VertexPointerTest()17     VertexPointerTest()
18     {
19         setWindowWidth(32);
20         setWindowHeight(32);
21         setConfigRedBits(8);
22         setConfigGreenBits(8);
23         setConfigBlueBits(8);
24         setConfigAlphaBits(8);
25         setConfigDepthBits(24);
26     }
27 };
28 
29 // Checks that we can assign to client side vertex arrays
TEST_P(VertexPointerTest,AssignRetrieve)30 TEST_P(VertexPointerTest, AssignRetrieve)
31 {
32     std::vector<float> testVertexAttribute = {
33         1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f,
34         1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f,
35     };
36 
37     glVertexPointer(4, GL_FLOAT, 0, testVertexAttribute.data());
38     EXPECT_GL_NO_ERROR();
39 
40     void *ptr = nullptr;
41     glGetPointerv(GL_VERTEX_ARRAY_POINTER, &ptr);
42     EXPECT_EQ(testVertexAttribute.data(), ptr);
43 
44     glColorPointer(4, GL_FLOAT, 0, testVertexAttribute.data() + 4);
45     glGetPointerv(GL_COLOR_ARRAY_POINTER, &ptr);
46     EXPECT_EQ(testVertexAttribute.data() + 4, ptr);
47 
48     glNormalPointer(GL_FLOAT, 0, testVertexAttribute.data() + 8);
49     glGetPointerv(GL_NORMAL_ARRAY_POINTER, &ptr);
50     EXPECT_EQ(testVertexAttribute.data() + 8, ptr);
51 
52     glPointSizePointerOES(GL_FLOAT, 0, testVertexAttribute.data() + 8);
53     glGetPointerv(GL_POINT_SIZE_ARRAY_POINTER_OES, &ptr);
54     EXPECT_EQ(testVertexAttribute.data() + 8, ptr);
55 
56     GLint maxTextureUnits;
57     glGetIntegerv(GL_MAX_TEXTURE_UNITS, &maxTextureUnits);
58     for (int i = 0; i < maxTextureUnits; i++)
59     {
60         glClientActiveTexture(GL_TEXTURE0 + i);
61         glTexCoordPointer(4, GL_FLOAT, 0, testVertexAttribute.data() + i * 4);
62         glGetPointerv(GL_TEXTURE_COORD_ARRAY_POINTER, &ptr);
63         EXPECT_EQ(testVertexAttribute.data() + i * 4, ptr);
64     }
65 }
66 
67 ANGLE_INSTANTIATE_TEST_ES1(VertexPointerTest);
68