• 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 // MatrixMultTest.cpp: Tests basic usage of glMultMatrix(f|x).
8 
9 #include "test_utils/ANGLETest.h"
10 #include "test_utils/gl_raii.h"
11 
12 #include "common/matrix_utils.h"
13 #include "util/random_utils.h"
14 
15 #include <stdint.h>
16 
17 using namespace angle;
18 
19 class MatrixMultTest : public ANGLETest
20 {
21   protected:
MatrixMultTest()22     MatrixMultTest()
23     {
24         setWindowWidth(32);
25         setWindowHeight(32);
26         setConfigRedBits(8);
27         setConfigGreenBits(8);
28         setConfigBlueBits(8);
29         setConfigAlphaBits(8);
30         setConfigDepthBits(24);
31     }
32 };
33 
34 // Multiplies identity matrix with itself.
TEST_P(MatrixMultTest,Identity)35 TEST_P(MatrixMultTest, Identity)
36 {
37     angle::Mat4 testMatrix;
38     angle::Mat4 outputMatrix;
39 
40     glMultMatrixf(testMatrix.data());
41     EXPECT_GL_NO_ERROR();
42 
43     glGetFloatv(GL_MODELVIEW_MATRIX, outputMatrix.data());
44     EXPECT_GL_NO_ERROR();
45 
46     EXPECT_EQ(angle::Mat4(), outputMatrix);
47 }
48 
49 // Multiplies translation matrix and checks matrix underneath in stack is not affected.
TEST_P(MatrixMultTest,Translation)50 TEST_P(MatrixMultTest, Translation)
51 {
52     glPushMatrix();
53 
54     angle::Mat4 testMatrix = angle::Mat4::Translate(angle::Vector3(1.0f, 0.0f, 0.0f));
55 
56     angle::Mat4 outputMatrix;
57 
58     glMultMatrixf(testMatrix.data());
59     EXPECT_GL_NO_ERROR();
60 
61     glMultMatrixf(testMatrix.data());
62     EXPECT_GL_NO_ERROR();
63 
64     glGetFloatv(GL_MODELVIEW_MATRIX, outputMatrix.data());
65     EXPECT_GL_NO_ERROR();
66 
67     EXPECT_EQ(angle::Mat4::Translate(angle::Vector3(2.0f, 0.0f, 0.0f)), outputMatrix);
68 
69     glPopMatrix();
70 
71     glGetFloatv(GL_MODELVIEW_MATRIX, outputMatrix.data());
72     EXPECT_GL_NO_ERROR();
73 
74     EXPECT_EQ(angle::Mat4(), outputMatrix);
75 }
76 
77 ANGLE_INSTANTIATE_TEST_ES1(MatrixMultTest);
78