Commit d2488aba by Lingfeng Yang Committed by Commit Bot

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: 's avatarCorentin Wallez <cwallez@chromium.org>
parent 59770806
...@@ -6872,6 +6872,10 @@ bool Context::getQueryParameterInfo(GLenum pname, GLenum *type, unsigned int *nu ...@@ -6872,6 +6872,10 @@ bool Context::getQueryParameterInfo(GLenum pname, GLenum *type, unsigned int *nu
*type = GL_FLOAT; *type = GL_FLOAT;
*numParams = 4; *numParams = 4;
return true; return true;
case GL_MATRIX_MODE:
*type = GL_INT;
*numParams = 1;
return true;
} }
} }
......
...@@ -264,7 +264,7 @@ void Context::materialxv(GLenum face, GLenum pname, const GLfixed *param) ...@@ -264,7 +264,7 @@ void Context::materialxv(GLenum face, GLenum pname, const GLfixed *param)
void Context::matrixMode(MatrixType mode) void Context::matrixMode(MatrixType mode)
{ {
UNIMPLEMENTED(); mGLState.gles1().setMatrixMode(mode);
} }
void Context::multMatrixf(const GLfloat *m) void Context::multMatrixf(const GLfloat *m)
......
...@@ -44,7 +44,7 @@ GLES1State::GLES1State() ...@@ -44,7 +44,7 @@ GLES1State::GLES1State()
mCurrentColor({0.0f, 0.0f, 0.0f, 0.0f}), mCurrentColor({0.0f, 0.0f, 0.0f, 0.0f}),
mCurrentNormal({0.0f, 0.0f, 0.0f}), mCurrentNormal({0.0f, 0.0f, 0.0f}),
mClientActiveTexture(0), mClientActiveTexture(0),
mCurrMatrixMode(MatrixType::Modelview), mMatrixMode(MatrixType::Modelview),
mShadeModel(ShadingModel::Smooth), mShadeModel(ShadingModel::Smooth),
mAlphaTestFunc(AlphaTestFunc::AlwaysPass), mAlphaTestFunc(AlphaTestFunc::AlwaysPass),
mAlphaTestRef(0.0f), mAlphaTestRef(0.0f),
...@@ -88,7 +88,7 @@ void GLES1State::initialize(const Context *context) ...@@ -88,7 +88,7 @@ void GLES1State::initialize(const Context *context)
mColorMaterialEnabled = false; mColorMaterialEnabled = false;
mReflectionMapEnabled = false; mReflectionMapEnabled = false;
mCurrMatrixMode = MatrixType::Modelview; mMatrixMode = MatrixType::Modelview;
mCurrentColor = {1.0f, 1.0f, 1.0f, 1.0f}; mCurrentColor = {1.0f, 1.0f, 1.0f, 1.0f};
mCurrentNormal = {0.0f, 0.0f, 1.0f}; mCurrentNormal = {0.0f, 0.0f, 1.0f};
...@@ -200,4 +200,14 @@ const TextureCoordF &GLES1State::getCurrentTextureCoords(unsigned int unit) cons ...@@ -200,4 +200,14 @@ const TextureCoordF &GLES1State::getCurrentTextureCoords(unsigned int unit) cons
return mCurrentTextureCoords[unit]; return mCurrentTextureCoords[unit];
} }
void GLES1State::setMatrixMode(MatrixType mode)
{
mMatrixMode = mode;
}
MatrixType GLES1State::getMatrixMode() const
{
return mMatrixMode;
}
} // namespace gl } // namespace gl
...@@ -135,6 +135,9 @@ class GLES1State final : angle::NonCopyable ...@@ -135,6 +135,9 @@ class GLES1State final : angle::NonCopyable
void setCurrentTextureCoords(unsigned int unit, const TextureCoordF &coords); void setCurrentTextureCoords(unsigned int unit, const TextureCoordF &coords);
const TextureCoordF &getCurrentTextureCoords(unsigned int unit) const; const TextureCoordF &getCurrentTextureCoords(unsigned int unit) const;
void setMatrixMode(MatrixType mode);
MatrixType getMatrixMode() const;
private: private:
friend class State; friend class State;
...@@ -179,7 +182,7 @@ class GLES1State final : angle::NonCopyable ...@@ -179,7 +182,7 @@ class GLES1State final : angle::NonCopyable
// Table 6.7 // Table 6.7
using MatrixStack = std::vector<angle::Mat4>; using MatrixStack = std::vector<angle::Mat4>;
MatrixType mCurrMatrixMode; MatrixType mMatrixMode;
MatrixStack mProjMatrices; MatrixStack mProjMatrices;
MatrixStack mModelviewMatrices; MatrixStack mModelviewMatrices;
std::vector<MatrixStack> mTextureMatrices; std::vector<MatrixStack> mTextureMatrices;
......
...@@ -2333,6 +2333,9 @@ Error State::getIntegerv(const Context *context, GLenum pname, GLint *params) ...@@ -2333,6 +2333,9 @@ Error State::getIntegerv(const Context *context, GLenum pname, GLint *params)
case GL_CLIENT_ACTIVE_TEXTURE: case GL_CLIENT_ACTIVE_TEXTURE:
*params = mGLES1State.mClientActiveTexture + GL_TEXTURE0; *params = mGLES1State.mClientActiveTexture + GL_TEXTURE0;
break; break;
case GL_MATRIX_MODE:
*params = ToGLenum(mGLES1State.mMatrixMode);
break;
default: default:
UNREACHABLE(); UNREACHABLE();
break; break;
......
...@@ -371,8 +371,17 @@ bool ValidateMaterialxv(Context *context, GLenum face, GLenum pname, const GLfix ...@@ -371,8 +371,17 @@ bool ValidateMaterialxv(Context *context, GLenum face, GLenum pname, const GLfix
bool ValidateMatrixMode(Context *context, MatrixType mode) bool ValidateMatrixMode(Context *context, MatrixType mode)
{ {
UNIMPLEMENTED(); ANGLE_VALIDATE_IS_GLES1(context);
return true; switch (mode)
{
case MatrixType::Projection:
case MatrixType::Modelview:
case MatrixType::Texture:
return true;
default:
ANGLE_VALIDATION_ERR(context, InvalidEnum(), InvalidMatrixMode);
return false;
}
} }
bool ValidateMultMatrixf(Context *context, const GLfloat *m) bool ValidateMultMatrixf(Context *context, const GLfloat *m)
......
...@@ -52,6 +52,7 @@ ...@@ -52,6 +52,7 @@
'<(angle_path)/src/tests/gl_tests/gles1/CurrentColorTest.cpp', '<(angle_path)/src/tests/gl_tests/gles1/CurrentColorTest.cpp',
'<(angle_path)/src/tests/gl_tests/gles1/CurrentNormalTest.cpp', '<(angle_path)/src/tests/gl_tests/gles1/CurrentNormalTest.cpp',
'<(angle_path)/src/tests/gl_tests/gles1/CurrentTextureCoordsTest.cpp', '<(angle_path)/src/tests/gl_tests/gles1/CurrentTextureCoordsTest.cpp',
'<(angle_path)/src/tests/gl_tests/gles1/MatrixModeTest.cpp',
'<(angle_path)/src/tests/gl_tests/GLSLTest.cpp', '<(angle_path)/src/tests/gl_tests/GLSLTest.cpp',
'<(angle_path)/src/tests/gl_tests/ImageTest.cpp', '<(angle_path)/src/tests/gl_tests/ImageTest.cpp',
'<(angle_path)/src/tests/gl_tests/IncompleteTextureTest.cpp', '<(angle_path)/src/tests/gl_tests/IncompleteTextureTest.cpp',
......
//
// Copyright 2018 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// MatrixModeTest.cpp: Tests basic usage of glMatrixMode.
#include "test_utils/ANGLETest.h"
#include "test_utils/gl_raii.h"
#include <vector>
using namespace angle;
class MatrixModeTest : public ANGLETest
{
protected:
MatrixModeTest()
{
setWindowWidth(32);
setWindowHeight(32);
setConfigRedBits(8);
setConfigGreenBits(8);
setConfigBlueBits(8);
setConfigAlphaBits(8);
setConfigDepthBits(24);
}
};
// State query: Checks the initial state is correct.
TEST_P(MatrixModeTest, InitialState)
{
GLint matrixMode;
glGetIntegerv(GL_MATRIX_MODE, &matrixMode);
EXPECT_GL_NO_ERROR();
EXPECT_GLENUM_EQ(GL_MODELVIEW, matrixMode);
}
// Checks for error-generating cases.
TEST_P(MatrixModeTest, Negative)
{
glMatrixMode(0);
EXPECT_GL_ERROR(GL_INVALID_ENUM);
glMatrixMode(GL_TEXTURE_2D);
EXPECT_GL_ERROR(GL_INVALID_ENUM);
}
// Checks that matrix mode can be set.
TEST_P(MatrixModeTest, Set)
{
GLint matrixMode;
std::vector<GLenum> modes = {GL_PROJECTION, GL_MODELVIEW, GL_TEXTURE};
for (auto mode : modes)
{
glMatrixMode(mode);
EXPECT_GL_NO_ERROR();
glGetIntegerv(GL_MATRIX_MODE, &matrixMode);
EXPECT_GLENUM_EQ(mode, matrixMode);
}
}
ANGLE_INSTANTIATE_TEST(MatrixModeTest, ES1_D3D11(), ES1_OPENGL(), ES1_OPENGLES());
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment