Commit 59af4b94 by Nicolas Capens

Implement glShadeModel() for OpenGL ES 1.1.

Change-Id: I9b360f92c0b93a854abfd686cdcdd9b2a1dd6a13 Reviewed-on: https://swiftshader-review.googlesource.com/2700Tested-by: 's avatarNicolas Capens <capn@google.com> Reviewed-by: 's avatarGreg Hartman <ghartman@google.com> Tested-by: 's avatarGreg Hartman <ghartman@google.com> Reviewed-by: 's avatarNicolas Capens <capn@google.com>
parent 029d3539
...@@ -81,6 +81,7 @@ Context::Context(const egl::Config *config, const Context *shareContext) ...@@ -81,6 +81,7 @@ Context::Context(const egl::Config *config, const Context *shareContext)
mState.sampleCoverageInvert = false; mState.sampleCoverageInvert = false;
mState.scissorTest = false; mState.scissorTest = false;
mState.dither = true; mState.dither = true;
mState.shadeModel = GL_SMOOTH;
mState.generateMipmapHint = GL_DONT_CARE; mState.generateMipmapHint = GL_DONT_CARE;
mState.lineWidth = 1.0f; mState.lineWidth = 1.0f;
...@@ -493,7 +494,7 @@ bool Context::isSampleCoverageEnabled() const ...@@ -493,7 +494,7 @@ bool Context::isSampleCoverageEnabled() const
void Context::setSampleCoverageParams(GLclampf value, bool invert) void Context::setSampleCoverageParams(GLclampf value, bool invert)
{ {
if(mState.sampleCoverageValue != value || if(mState.sampleCoverageValue != value ||
mState.sampleCoverageInvert != invert) mState.sampleCoverageInvert != invert)
{ {
mState.sampleCoverageValue = value; mState.sampleCoverageValue = value;
mState.sampleCoverageInvert = invert; mState.sampleCoverageInvert = invert;
...@@ -511,6 +512,11 @@ bool Context::isScissorTestEnabled() const ...@@ -511,6 +512,11 @@ bool Context::isScissorTestEnabled() const
return mState.scissorTest; return mState.scissorTest;
} }
void Context::setShadeModel(GLenum mode)
{
mState.shadeModel = mode;
}
void Context::setDither(bool enabled) void Context::setDither(bool enabled)
{ {
if(mState.dither != enabled) if(mState.dither != enabled)
...@@ -1673,6 +1679,13 @@ void Context::applyState(GLenum drawMode) ...@@ -1673,6 +1679,13 @@ void Context::applyState(GLenum drawMode)
mDitherStateDirty = false; mDitherStateDirty = false;
} }
switch(mState.shadeModel)
{
default: UNREACHABLE();
case GL_SMOOTH: device->setShadingMode(sw::SHADING_GOURAUD); break;
case GL_FLAT: device->setShadingMode(sw::SHADING_FLAT); break;
}
device->setLightingEnable(lighting); device->setLightingEnable(lighting);
device->setGlobalAmbient(sw::Color<float>(globalAmbient.red, globalAmbient.green, globalAmbient.blue, globalAmbient.alpha)); device->setGlobalAmbient(sw::Color<float>(globalAmbient.red, globalAmbient.green, globalAmbient.blue, globalAmbient.alpha));
......
...@@ -218,6 +218,7 @@ struct State ...@@ -218,6 +218,7 @@ struct State
bool sampleCoverageInvert; bool sampleCoverageInvert;
bool scissorTest; bool scissorTest;
bool dither; bool dither;
GLenum shadeModel;
GLfloat lineWidth; GLfloat lineWidth;
...@@ -303,6 +304,7 @@ public: ...@@ -303,6 +304,7 @@ public:
bool isSampleCoverageEnabled() const; bool isSampleCoverageEnabled() const;
void setSampleCoverageParams(GLclampf value, bool invert); void setSampleCoverageParams(GLclampf value, bool invert);
void setShadeModel(GLenum mode);
void setDither(bool enabled); void setDither(bool enabled);
bool isDitherEnabled() const; bool isDitherEnabled() const;
void setLighting(bool enabled); void setLighting(bool enabled);
......
...@@ -3160,7 +3160,21 @@ void GL_APIENTRY glScissor(GLint x, GLint y, GLsizei width, GLsizei height) ...@@ -3160,7 +3160,21 @@ void GL_APIENTRY glScissor(GLint x, GLint y, GLsizei width, GLsizei height)
void GL_APIENTRY glShadeModel(GLenum mode) void GL_APIENTRY glShadeModel(GLenum mode)
{ {
UNIMPLEMENTED(); switch(mode)
{
case GL_FLAT:
case GL_SMOOTH:
break;
default:
return error(GL_INVALID_ENUM);
}
es1::Context *context = es1::getContext();
if(context)
{
context->setShadeModel(mode);
}
} }
void GL_APIENTRY glStencilFunc(GLenum func, GLint ref, GLuint mask) void GL_APIENTRY glStencilFunc(GLenum func, GLint ref, GLuint mask)
......
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