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 // Checks that we can assign to client side vertex arrays with color vertex attributes of type
68 // GLubyte
TEST_P(VertexPointerTest,AssignRetrieveColorUnsignedByte)69 TEST_P(VertexPointerTest, AssignRetrieveColorUnsignedByte)
70 {
71 std::vector<float> testVertexAttribute = {
72 1.0f,
73 1.0f,
74 1.0f,
75 1.0f,
76 };
77
78 std::vector<GLubyte> testColorAttribute = {
79 1,
80 1,
81 1,
82 1,
83 };
84
85 glVertexPointer(4, GL_FLOAT, 0, testVertexAttribute.data());
86 EXPECT_GL_NO_ERROR();
87
88 void *ptr = nullptr;
89 glGetPointerv(GL_VERTEX_ARRAY_POINTER, &ptr);
90 EXPECT_EQ(testVertexAttribute.data(), ptr);
91
92 glColorPointer(4, GL_UNSIGNED_BYTE, 0, testColorAttribute.data());
93 glGetPointerv(GL_COLOR_ARRAY_POINTER, &ptr);
94 EXPECT_EQ(testColorAttribute.data(), ptr);
95 ASSERT_GL_NO_ERROR();
96 }
97
98 ANGLE_INSTANTIATE_TEST_ES1(VertexPointerTest);
99