Implements support for FRONT_AND_BACK culling.

TRAC #11331

Author:    Shannon Woods
Signed-off-by: Andrew Lewycky
Signed-off-by: Daniel Koch

git-svn-id: https://angleproject.googlecode.com/svn/trunk@57 736b8ea6-26fd-11df-bfd4-992fa37f6226
This commit is contained in:
daniel@transgaming.com 2010-03-21 04:31:20 +00:00
Родитель 5949aa10c6
Коммит ace5e66358
3 изменённых файлов: 29 добавлений и 7 удалений

Просмотреть файл

@ -283,6 +283,8 @@ class Context : public State
Texture *getIncompleteTexture(SamplerType type);
bool cullSkipsDraw(GLenum primitiveType);
const egl::Config *const mConfig;
Texture2D *mTexture2DZero;

Просмотреть файл

@ -1458,9 +1458,12 @@ void Context::drawArrays(GLenum mode, GLint first, GLsizei count)
applyShaders();
applyTextures();
device->BeginScene();
device->DrawPrimitive(primitiveType, first, primitiveCount);
device->EndScene();
if (!cullSkipsDraw(mode))
{
device->BeginScene();
device->DrawPrimitive(primitiveType, first, primitiveCount);
device->EndScene();
}
}
void Context::drawElements(GLenum mode, GLsizei count, GLenum type, const void* indices)
@ -1498,9 +1501,12 @@ void Context::drawElements(GLenum mode, GLsizei count, GLenum type, const void*
applyShaders();
applyTextures();
device->BeginScene();
device->DrawIndexedPrimitive(primitiveType, 0, 0, count, startIndex, primitiveCount);
device->EndScene();
if (!cullSkipsDraw(mode))
{
device->BeginScene();
device->DrawIndexedPrimitive(primitiveType, 0, 0, count, startIndex, primitiveCount);
device->EndScene();
}
}
void Context::finish()
@ -1771,6 +1777,20 @@ Texture *Context::getIncompleteTexture(SamplerType type)
return t;
}
bool Context::cullSkipsDraw(GLenum primitiveType)
{
if (cullFace && cullMode == GL_FRONT_AND_BACK &&
(primitiveType == GL_TRIANGLES || primitiveType == GL_TRIANGLE_FAN || primitiveType == GL_TRIANGLE_STRIP))
{
return true;
}
else
{
return false;
}
}
}
extern "C"

Просмотреть файл

@ -131,7 +131,7 @@ D3DCULL ConvertCullMode(GLenum cullFace, GLenum frontFace)
cull = (frontFace == GL_CCW ? D3DCULL_CCW : D3DCULL_CW);
break;
case GL_FRONT_AND_BACK:
UNIMPLEMENTED(); // FIXME
cull = D3DCULL_NONE; // culling will be handled during draw
break;
default: UNREACHABLE();
}