(#656) Added text effect to effect generator

This commit is contained in:
Magne Sjaastad 2015-11-17 16:26:07 +01:00
parent 4469d32a2d
commit 08c04f5052
5 changed files with 75 additions and 17 deletions

View File

@ -36,7 +36,7 @@
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RivGridBoxGenerator::RivGridBoxGenerator(cvf::ShaderProgram* textShaderProgram)
RivGridBoxGenerator::RivGridBoxGenerator()
: m_gridColor(cvf::Color3f::LIGHT_GRAY),
m_gridLegendColor(cvf::Color3f::BLACK)
{
@ -44,12 +44,6 @@ RivGridBoxGenerator::RivGridBoxGenerator(cvf::ShaderProgram* textShaderProgram)
m_scaleZ = 1.0;
m_displayModelOffset = cvf::Vec3d::ZERO;
m_textEffect = new cvf::Effect;
if (textShaderProgram)
{
m_textEffect->setShaderProgram(textShaderProgram);
}
}
//--------------------------------------------------------------------------------------------------
@ -562,7 +556,9 @@ void RivGridBoxGenerator::createLegend(EdgeType edge, cvf::Collection<cvf::Part>
part->setDrawable(geo.p());
part->updateBoundingBox();
part->setEffect(m_textEffect.p());
caf::TextEffectGenerator textGen;
cvf::ref<cvf::Effect> eff = textGen.generateCachedEffect();
part->setEffect(eff.p());
parts->push_back(part.p());
}

View File

@ -43,7 +43,7 @@ namespace cvf
class RivGridBoxGenerator
{
public:
RivGridBoxGenerator(cvf::ShaderProgram* textShaderProgram);
RivGridBoxGenerator();
void setScaleZ(double scaleZ);
void setDisplayModelOffset(cvf::Vec3d offset);
@ -126,7 +126,5 @@ private:
cvf::Color3f m_gridColor;
cvf::Color3f m_gridLegendColor;
cvf::ref<cvf::Effect> m_textEffect;
};

View File

@ -167,12 +167,7 @@ RiuViewer::RiuViewer(const QGLFormat& format, QWidget* parent)
// which solves the problem
setContextMenuPolicy(Qt::PreventContextMenu);
cvf::ShaderProgram* textShaderProgram = NULL;
if (format.directRendering())
{
textShaderProgram = cvfOpenGLContext()->resourceManager()->getLinkedTextShaderProgram(cvfOpenGLContext());
}
m_gridBoxGenerator = new RivGridBoxGenerator(textShaderProgram);
m_gridBoxGenerator = new RivGridBoxGenerator;
}

View File

@ -887,4 +887,54 @@ EffectGenerator* MeshEffectGenerator::copy() const
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
TextEffectGenerator::TextEffectGenerator()
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool TextEffectGenerator::isEqual(const EffectGenerator* other) const
{
const TextEffectGenerator* otherSurfaceEffect = dynamic_cast<const TextEffectGenerator*>(other);
if (otherSurfaceEffect)
{
return true;
}
return false;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
EffectGenerator* TextEffectGenerator::copy() const
{
TextEffectGenerator* effGen = new TextEffectGenerator;
return effGen;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void TextEffectGenerator::updateForShaderBasedRendering(cvf::Effect* effect) const
{
// See OpenGLResourceManager::getLinkedTextShaderProgram for code to be used here
// Detected some issues on RHEL 6 related to text, so use an empty effect for now
// Will fall back to fixed function rendering
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void TextEffectGenerator::updateForFixedFunctionRendering(cvf::Effect* effect) const
{
}
} // End namespace caf

View File

@ -253,4 +253,23 @@ private:
};
//==================================================================================================
//
// MeshEffectGenerator
//
//==================================================================================================
class TextEffectGenerator : public EffectGenerator
{
public:
TextEffectGenerator();
protected:
virtual bool isEqual(const EffectGenerator* other) const;
virtual EffectGenerator* copy() const;
virtual void updateForShaderBasedRendering(cvf::Effect* effect) const;
virtual void updateForFixedFunctionRendering(cvf::Effect* effect) const;
};
}