Commit 5a7e61bb by Lingfeng Yang Committed by Commit Bot

GLES1: glNormal3(f|x)

BUG=angleproject:2306 Change-Id: I42834078b14aaa20c4d4e6b67c097c810f5a17a3 Reviewed-on: https://chromium-review.googlesource.com/987297 Commit-Queue: Lingfeng Yang <lfy@google.com> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org>
parent d104918f
......@@ -6401,6 +6401,10 @@ bool Context::getQueryParameterInfo(GLenum pname, GLenum *type, unsigned int *nu
*type = GL_FLOAT;
*numParams = 4;
return true;
case GL_CURRENT_NORMAL:
*type = GL_FLOAT;
*numParams = 3;
return true;
}
}
......
......@@ -289,12 +289,12 @@ void Context::multiTexCoord4x(GLenum texture, GLfixed s, GLfixed t, GLfixed r, G
void Context::normal3f(GLfloat nx, GLfloat ny, GLfloat nz)
{
UNIMPLEMENTED();
mGLState.gles1().setCurrentNormal({nx, ny, nz});
}
void Context::normal3x(GLfixed nx, GLfixed ny, GLfixed nz)
{
UNIMPLEMENTED();
mGLState.gles1().setCurrentNormal({FixedToFloat(nx), FixedToFloat(ny), FixedToFloat(nz)});
}
void Context::normalPointer(GLenum type, GLsizei stride, const void *ptr)
......
......@@ -159,7 +159,7 @@ unsigned int GLES1State::getClientTextureUnit() const
return mClientActiveTexture;
}
void GLES1State::setCurrentColor(ColorF color)
void GLES1State::setCurrentColor(const ColorF &color)
{
mCurrentColor = color;
}
......@@ -169,4 +169,14 @@ const ColorF &GLES1State::getCurrentColor() const
return mCurrentColor;
}
void GLES1State::setCurrentNormal(const angle::Vector3 &normal)
{
mCurrentNormal = normal;
}
const angle::Vector3 &GLES1State::getCurrentNormal() const
{
return mCurrentNormal;
}
} // namespace gl
......@@ -121,9 +121,13 @@ class GLES1State final : angle::NonCopyable
void setAlphaFunc(AlphaTestFunc func, GLfloat ref);
void setClientTextureUnit(unsigned int unit);
unsigned int getClientTextureUnit() const;
void setCurrentColor(ColorF color);
void setCurrentColor(const ColorF &color);
const ColorF &getCurrentColor() const;
void setCurrentNormal(const angle::Vector3 &normal);
const angle::Vector3 &getCurrentNormal() const;
private:
friend class State;
......
......@@ -1939,6 +1939,14 @@ void State::getFloatv(GLenum pname, GLfloat *params)
params[3] = color.alpha;
break;
}
case GL_CURRENT_NORMAL:
{
const auto &normal = mGLES1State.mCurrentNormal;
params[0] = normal[0];
params[1] = normal[1];
params[2] = normal[2];
break;
}
default:
UNREACHABLE();
break;
......
......@@ -417,13 +417,13 @@ bool ValidateMultiTexCoord4x(Context *context,
bool ValidateNormal3f(Context *context, GLfloat nx, GLfloat ny, GLfloat nz)
{
UNIMPLEMENTED();
ANGLE_VALIDATE_IS_GLES1(context);
return true;
}
bool ValidateNormal3x(Context *context, GLfixed nx, GLfixed ny, GLfixed nz)
{
UNIMPLEMENTED();
ANGLE_VALIDATE_IS_GLES1(context);
return true;
}
......
......@@ -50,6 +50,7 @@
'<(angle_path)/src/tests/gl_tests/gles1/AlphaFuncTest.cpp',
'<(angle_path)/src/tests/gl_tests/gles1/ClientActiveTextureTest.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/GLSLTest.cpp',
'<(angle_path)/src/tests/gl_tests/ImageTest.cpp',
'<(angle_path)/src/tests/gl_tests/IncompleteTextureTest.cpp',
......
......@@ -4,7 +4,7 @@
// found in the LICENSE file.
//
// CurrentColorTest.cpp: Tests basic usage of glClientActiveTexture.
// CurrentColorTest.cpp: Tests basic usage of glColor4(f|ub|x).
#include "test_utils/ANGLETest.h"
#include "test_utils/gl_raii.h"
......
//
// 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.
//
// CurrentNormalTest.cpp: Tests basic usage of glNormal3(f|x).
#include "test_utils/ANGLETest.h"
#include "test_utils/gl_raii.h"
#include "random_utils.h"
#include "common/vector_utils.h"
#include <stdint.h>
using namespace angle;
class CurrentNormalTest : public ANGLETest
{
protected:
CurrentNormalTest()
{
setWindowWidth(32);
setWindowHeight(32);
setConfigRedBits(8);
setConfigGreenBits(8);
setConfigBlueBits(8);
setConfigAlphaBits(8);
setConfigDepthBits(24);
}
};
// State query: Checks the initial state is correct.
TEST_P(CurrentNormalTest, InitialState)
{
const angle::Vector3 kUp(0.0f, 0.0f, 1.0f);
angle::Vector3 actualNormal;
glGetFloatv(GL_CURRENT_NORMAL, actualNormal.data());
EXPECT_GL_NO_ERROR();
EXPECT_EQ(kUp, actualNormal);
}
// Set test: Checks that the current normal is properly set and retrieved.
TEST_P(CurrentNormalTest, Set)
{
glNormal3f(0.1f, 0.2f, 0.3f);
EXPECT_GL_NO_ERROR();
angle::Vector3 actualNormal;
glGetFloatv(GL_CURRENT_NORMAL, actualNormal.data());
EXPECT_GL_NO_ERROR();
EXPECT_EQ(angle::Vector3(0.1f, 0.2f, 0.3f), actualNormal);
float epsilon = 0.00001f;
glNormal3x(0x10000, 0x3333, 0x5555);
EXPECT_GL_NO_ERROR();
glGetFloatv(GL_CURRENT_NORMAL, actualNormal.data());
EXPECT_GL_NO_ERROR();
EXPECT_NEAR(1.0f, actualNormal[0], epsilon);
EXPECT_NEAR(0.2f, actualNormal[1], epsilon);
EXPECT_NEAR(1.0f / 3.0f, actualNormal[2], epsilon);
}
ANGLE_INSTANTIATE_TEST(CurrentNormalTest, 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