Commit 1b2303c1 authored by Christopher Tenter's avatar Christopher Tenter

fix compile error

parent 1ac6322f
......@@ -1615,6 +1615,24 @@ void ShaderProgGenerator::buildGeometryShader()
mainCode.push_back("gl_Position = gl_in[inIdx].gl_Position;");
mainCode.push_back("gl_PrimitiveID = gl_PrimitiveIDIn;");
// built-in gl_ClipDistance[]
static int maxClipDistances = -1;
if (maxClipDistances < 0)
{
#ifdef GL_MAX_CLIP_DISTANCES
glGetIntegerv(GL_MAX_CLIP_DISTANCES, &maxClipDistances);
maxClipDistances = std::min(maxClipDistances, 32); // clamp to 32 bits
#else
maxClipDistances = 32;
#endif
}
for (int i = 0; i < maxClipDistances; ++i)
{
if (desc_.clipDistanceMask & (1 << i))
mainCode.push_back(QString("gl_ClipDistance[%1] = gl_in[inIdx].gl_ClipDistance[%1];").arg(i));
}
// custom IO
for (int i = 0; i < geometry_->getNumInputs(); ++i)
{
......@@ -2720,7 +2738,7 @@ QString ShaderGenDesc::toString() const
resStrm << "version: " << version;
resStrm << "shaderDesc.numLights: " << numLights;
resStrm << "\nshaderDesc.numLights: " << numLights;
if (numLights)
{
......
......@@ -102,6 +102,7 @@ public:
fragmentTemplateFile(""),
normalizeTexColors(true),
colorMaterialMode(GL_AMBIENT_AND_DIFFUSE),
clipDistanceMask(0),
textureTypes_(),
texGenDim(0),
texGenMode(GL_EYE_LINEAR),
......@@ -178,6 +179,11 @@ public:
// default: GL_AMBIENT_AND_DIFFUSE
GLenum colorMaterialMode;
// Bitmask of enabled hardware clip planes.
// Bit i represents the i'th clip plane starting at the least significant bit.
// This is needed to pass the gl_ClipDistance[] array through the geometry shader stage.
uint clipDistanceMask;
struct TextureType
{
GLenum type;
......@@ -279,6 +285,13 @@ public:
return false;
}
if (!geometryTemplateFile.isEmpty())
{
// clip distance mask only affects the geometry shader
if (clipDistanceMask != _rhs.clipDistanceMask)
return false;
}
if (fragmentTemplateFile != _rhs.fragmentTemplateFile)
return false;
......
......@@ -248,6 +248,8 @@ void ClippingNode::ClippingObjectModifier::apply(RenderObject* _obj)
// set shader modifier
_obj->shaderDesc.shaderMods.push_back(shaderModID);
// enable clip distance pass through in geometry shader
_obj->shaderDesc.clipDistanceMask = _obj->clipDistanceMask;
}
//=============================================================================
......
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