Implemented gl_FrontFacing for lines and points

TRAC #11419 Lines and points are always considered front-facing Signed-off-by: Shannon Woods Signed-off-by: Daniel Koch Author: Nicolas Capens git-svn-id: https://angleproject.googlecode.com/svn/trunk@153 736b8ea6-26fd-11df-bfd4-992fa37f6226
parent e007896b
......@@ -104,7 +104,8 @@ void OutputHLSL::header()
out << "uniform float4 gl_Window;\n"
"uniform float2 gl_Depth;\n"
"uniform bool gl_frontCCW;\n"
"uniform bool gl_PointsOrLines;\n"
"uniform bool gl_FrontCCW;\n"
"\n";
out << uniforms;
out << "\n"
......@@ -546,7 +547,7 @@ void OutputHLSL::footer()
" gl_FragCoord.y = (input.gl_FragCoord.y * rhw) * gl_Window.y + gl_Window.w;\n"
" gl_FragCoord.z = (input.gl_FragCoord.z * rhw) * gl_Depth.x + gl_Depth.y;\n"
" gl_FragCoord.w = rhw;\n"
" gl_FrontFacing = gl_frontCCW ? (input.vFace >= 0.0) : (input.vFace <= 0.0);\n";
" gl_FrontFacing = gl_PointsOrLines || (gl_FrontCCW ? (input.vFace >= 0.0) : (input.vFace <= 0.0));\n";
for (TSymbolTableLevel::const_iterator namedSymbol = symbols->begin(); namedSymbol != symbols->end(); namedSymbol++)
{
......
......@@ -1256,15 +1256,19 @@ bool Context::applyRenderTarget(bool ignoreViewport)
}
// Applies the fixed-function state (culling, depth test, alpha blending, stenciling, etc) to the Direct3D 9 device
void Context::applyState()
void Context::applyState(GLenum drawMode)
{
IDirect3DDevice9 *device = getDevice();
Program *programObject = getCurrentProgram();
GLint frontCCW = programObject->getUniformLocation("gl_frontCCW");
GLint frontCCW = programObject->getUniformLocation("gl_FrontCCW");
GLint ccw = (frontFace == GL_CCW);
programObject->setUniform1iv(frontCCW, 1, &ccw);
GLint pointsOrLines = programObject->getUniformLocation("gl_PointsOrLines");
GLint alwaysFront = !isTriangleMode(drawMode);
programObject->setUniform1iv(pointsOrLines, 1, &alwaysFront);
if (cullFace)
{
device->SetRenderState(D3DRS_CULLMODE, es2dx::ConvertCullMode(cullMode, frontFace));
......@@ -1854,7 +1858,7 @@ void Context::drawArrays(GLenum mode, GLint first, GLsizei count)
return error(GL_INVALID_FRAMEBUFFER_OPERATION);
}
applyState();
applyState(mode);
applyVertexBuffer(first, count);
applyShaders();
applyTextures();
......@@ -1896,7 +1900,7 @@ void Context::drawElements(GLenum mode, GLsizei count, GLenum type, const void*
return error(GL_INVALID_FRAMEBUFFER_OPERATION);
}
applyState();
applyState(mode);
TranslatedIndexData indexInfo = applyIndexBuffer(indices, count, mode, type);
applyVertexBuffer(indexInfo);
applyShaders();
......@@ -2189,19 +2193,29 @@ Texture *Context::getIncompleteTexture(SamplerType type)
return t;
}
bool Context::cullSkipsDraw(GLenum primitiveType)
bool Context::cullSkipsDraw(GLenum drawMode)
{
if (cullFace && cullMode == GL_FRONT_AND_BACK &&
(primitiveType == GL_TRIANGLES || primitiveType == GL_TRIANGLE_FAN || primitiveType == GL_TRIANGLE_STRIP))
return cullFace && cullMode == GL_FRONT_AND_BACK && isTriangleMode(drawMode);
}
bool Context::isTriangleMode(GLenum drawMode)
{
switch (drawMode)
{
case GL_TRIANGLES:
case GL_TRIANGLE_FAN:
case GL_TRIANGLE_STRIP:
return true;
}
else
{
case GL_POINTS:
case GL_LINES:
case GL_LINE_LOOP:
case GL_LINE_STRIP:
return false;
default: UNREACHABLE();
}
}
return false;
}
}
extern "C"
......
......@@ -264,7 +264,7 @@ class Context : public State
bool getQueryParameterInfo(GLenum pname, GLenum *type, unsigned int *numParams);
bool applyRenderTarget(bool ignoreViewport);
void applyState();
void applyState(GLenum drawMode);
void applyVertexBuffer(GLint first, GLsizei count);
void applyVertexBuffer(const TranslatedIndexData &indexInfo);
TranslatedIndexData applyIndexBuffer(const void *indices, GLsizei count, GLenum mode, GLenum type);
......@@ -304,7 +304,8 @@ class Context : public State
Texture *getIncompleteTexture(SamplerType type);
bool cullSkipsDraw(GLenum primitiveType);
bool cullSkipsDraw(GLenum drawMode);
bool isTriangleMode(GLenum drawMode);
const egl::Config *const mConfig;
......
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