Skip to content

Commit d2488ab

Browse files
741gCommit Bot
authored andcommitted
GLES1: glMatrixMode
BUG=angleproject:2306 Change-Id: I83e15990c10d9354c2db00766ddc7b0ab960aa5c Reviewed-on: https://chromium-review.googlesource.com/996019 Commit-Queue: Lingfeng Yang <lfy@google.com> Reviewed-by: Corentin Wallez <cwallez@chromium.org>
1 parent 5977080 commit d2488ab

File tree

8 files changed

+101
-6
lines changed

8 files changed

+101
-6
lines changed

src/libANGLE/Context.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6872,6 +6872,10 @@ bool Context::getQueryParameterInfo(GLenum pname, GLenum *type, unsigned int *nu
68726872
*type = GL_FLOAT;
68736873
*numParams = 4;
68746874
return true;
6875+
case GL_MATRIX_MODE:
6876+
*type = GL_INT;
6877+
*numParams = 1;
6878+
return true;
68756879
}
68766880
}
68776881

src/libANGLE/Context_gles_1_0.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ void Context::materialxv(GLenum face, GLenum pname, const GLfixed *param)
264264

265265
void Context::matrixMode(MatrixType mode)
266266
{
267-
UNIMPLEMENTED();
267+
mGLState.gles1().setMatrixMode(mode);
268268
}
269269

270270
void Context::multMatrixf(const GLfloat *m)

src/libANGLE/GLES1State.cpp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ GLES1State::GLES1State()
4444
mCurrentColor({0.0f, 0.0f, 0.0f, 0.0f}),
4545
mCurrentNormal({0.0f, 0.0f, 0.0f}),
4646
mClientActiveTexture(0),
47-
mCurrMatrixMode(MatrixType::Modelview),
47+
mMatrixMode(MatrixType::Modelview),
4848
mShadeModel(ShadingModel::Smooth),
4949
mAlphaTestFunc(AlphaTestFunc::AlwaysPass),
5050
mAlphaTestRef(0.0f),
@@ -88,7 +88,7 @@ void GLES1State::initialize(const Context *context)
8888
mColorMaterialEnabled = false;
8989
mReflectionMapEnabled = false;
9090

91-
mCurrMatrixMode = MatrixType::Modelview;
91+
mMatrixMode = MatrixType::Modelview;
9292

9393
mCurrentColor = {1.0f, 1.0f, 1.0f, 1.0f};
9494
mCurrentNormal = {0.0f, 0.0f, 1.0f};
@@ -200,4 +200,14 @@ const TextureCoordF &GLES1State::getCurrentTextureCoords(unsigned int unit) cons
200200
return mCurrentTextureCoords[unit];
201201
}
202202

203+
void GLES1State::setMatrixMode(MatrixType mode)
204+
{
205+
mMatrixMode = mode;
206+
}
207+
208+
MatrixType GLES1State::getMatrixMode() const
209+
{
210+
return mMatrixMode;
211+
}
212+
203213
} // namespace gl

src/libANGLE/GLES1State.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,9 @@ class GLES1State final : angle::NonCopyable
135135
void setCurrentTextureCoords(unsigned int unit, const TextureCoordF &coords);
136136
const TextureCoordF &getCurrentTextureCoords(unsigned int unit) const;
137137

138+
void setMatrixMode(MatrixType mode);
139+
MatrixType getMatrixMode() const;
140+
138141
private:
139142
friend class State;
140143

@@ -179,7 +182,7 @@ class GLES1State final : angle::NonCopyable
179182

180183
// Table 6.7
181184
using MatrixStack = std::vector<angle::Mat4>;
182-
MatrixType mCurrMatrixMode;
185+
MatrixType mMatrixMode;
183186
MatrixStack mProjMatrices;
184187
MatrixStack mModelviewMatrices;
185188
std::vector<MatrixStack> mTextureMatrices;

src/libANGLE/State.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2333,6 +2333,9 @@ Error State::getIntegerv(const Context *context, GLenum pname, GLint *params)
23332333
case GL_CLIENT_ACTIVE_TEXTURE:
23342334
*params = mGLES1State.mClientActiveTexture + GL_TEXTURE0;
23352335
break;
2336+
case GL_MATRIX_MODE:
2337+
*params = ToGLenum(mGLES1State.mMatrixMode);
2338+
break;
23362339
default:
23372340
UNREACHABLE();
23382341
break;

src/libANGLE/validationES1.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -371,8 +371,17 @@ bool ValidateMaterialxv(Context *context, GLenum face, GLenum pname, const GLfix
371371

372372
bool ValidateMatrixMode(Context *context, MatrixType mode)
373373
{
374-
UNIMPLEMENTED();
375-
return true;
374+
ANGLE_VALIDATE_IS_GLES1(context);
375+
switch (mode)
376+
{
377+
case MatrixType::Projection:
378+
case MatrixType::Modelview:
379+
case MatrixType::Texture:
380+
return true;
381+
default:
382+
ANGLE_VALIDATION_ERR(context, InvalidEnum(), InvalidMatrixMode);
383+
return false;
384+
}
376385
}
377386

378387
bool ValidateMultMatrixf(Context *context, const GLfloat *m)

src/tests/angle_end2end_tests.gypi

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
'<(angle_path)/src/tests/gl_tests/gles1/CurrentColorTest.cpp',
5353
'<(angle_path)/src/tests/gl_tests/gles1/CurrentNormalTest.cpp',
5454
'<(angle_path)/src/tests/gl_tests/gles1/CurrentTextureCoordsTest.cpp',
55+
'<(angle_path)/src/tests/gl_tests/gles1/MatrixModeTest.cpp',
5556
'<(angle_path)/src/tests/gl_tests/GLSLTest.cpp',
5657
'<(angle_path)/src/tests/gl_tests/ImageTest.cpp',
5758
'<(angle_path)/src/tests/gl_tests/IncompleteTextureTest.cpp',
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
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+
// MatrixModeTest.cpp: Tests basic usage of glMatrixMode.
8+
9+
#include "test_utils/ANGLETest.h"
10+
#include "test_utils/gl_raii.h"
11+
12+
#include <vector>
13+
14+
using namespace angle;
15+
16+
class MatrixModeTest : public ANGLETest
17+
{
18+
protected:
19+
MatrixModeTest()
20+
{
21+
setWindowWidth(32);
22+
setWindowHeight(32);
23+
setConfigRedBits(8);
24+
setConfigGreenBits(8);
25+
setConfigBlueBits(8);
26+
setConfigAlphaBits(8);
27+
setConfigDepthBits(24);
28+
}
29+
};
30+
31+
// State query: Checks the initial state is correct.
32+
TEST_P(MatrixModeTest, InitialState)
33+
{
34+
GLint matrixMode;
35+
glGetIntegerv(GL_MATRIX_MODE, &matrixMode);
36+
EXPECT_GL_NO_ERROR();
37+
EXPECT_GLENUM_EQ(GL_MODELVIEW, matrixMode);
38+
}
39+
40+
// Checks for error-generating cases.
41+
TEST_P(MatrixModeTest, Negative)
42+
{
43+
glMatrixMode(0);
44+
EXPECT_GL_ERROR(GL_INVALID_ENUM);
45+
glMatrixMode(GL_TEXTURE_2D);
46+
EXPECT_GL_ERROR(GL_INVALID_ENUM);
47+
}
48+
49+
// Checks that matrix mode can be set.
50+
TEST_P(MatrixModeTest, Set)
51+
{
52+
GLint matrixMode;
53+
54+
std::vector<GLenum> modes = {GL_PROJECTION, GL_MODELVIEW, GL_TEXTURE};
55+
56+
for (auto mode : modes)
57+
{
58+
glMatrixMode(mode);
59+
EXPECT_GL_NO_ERROR();
60+
glGetIntegerv(GL_MATRIX_MODE, &matrixMode);
61+
EXPECT_GLENUM_EQ(mode, matrixMode);
62+
}
63+
}
64+
65+
ANGLE_INSTANTIATE_TEST(MatrixModeTest, ES1_D3D11(), ES1_OPENGL(), ES1_OPENGLES());

0 commit comments

Comments
 (0)