Commit d771a5fc authored by Isaak Lim's avatar Isaak Lim
Browse files

registered ShaderModifier can now be passed to...

registered ShaderModifier can now be passed to dumpCurrentRenderObjectsToString, which will then correctly output the modified shader code

closes #1765

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@17678 383ad7c9-94d9-4d36-a494-682f7c89f535
parent d306533b
......@@ -509,11 +509,17 @@ void IRenderer::dumpRenderObjectsToFile(const char* _fileName, ACG::RenderObject
}
QString IRenderer::dumpCurrentRenderObjectsToString(ACG::RenderObject** _list, bool _outputShaders ) {
QString IRenderer::dumpCurrentRenderObjectsToString(ACG::RenderObject** _list, bool _outputShaders, std::vector<ACG::ShaderModifier*>* _modifiers) {
QString objectString;
QTextStream outStrm(&objectString);
std::vector<ACG::ShaderModifier*>::iterator it;
unsigned int usage = 0;
if (_modifiers) {
for (it = _modifiers->begin(); it != _modifiers->end(); ++it)
usage |= (*it)->getID();
}
for (int i = 0; i < getNumRenderObjects(); ++i)
{
if (_list) {
......@@ -528,7 +534,10 @@ QString IRenderer::dumpCurrentRenderObjectsToString(ACG::RenderObject** _list, b
outStrm << _list[i]->shaderDesc.toString();
ShaderProgGenerator progGen(&(_list[i]->shaderDesc));
ShaderProgGenerator progGen(&(_list[i]->shaderDesc), usage);
if (!usage)
progGen.generateShaders();
outStrm << "\n---------------------vertex-shader--------------------\n\n";
for (int i = 0; i < progGen.getVertexShaderCode().size(); ++i)
......@@ -563,7 +572,10 @@ QString IRenderer::dumpCurrentRenderObjectsToString(ACG::RenderObject** _list, b
outStrm << renderObjects_[i].shaderDesc.toString();
ShaderProgGenerator progGen(&(renderObjects_[i].shaderDesc));
ShaderProgGenerator progGen(&(renderObjects_[i].shaderDesc), usage);
if (!usage)
progGen.generateShaders();
outStrm << "\n---------------------vertex-shader--------------------\n\n";
for (int i = 0; i < progGen.getVertexShaderCode().size(); ++i)
......
......@@ -265,9 +265,10 @@ public:
*
* @param _list Pointer to a list of render objects used for output (defaults to unsorted internal list)
* @param _outputShaders Output the shaders used for the objects?
* @param _modifier Pointer to vector of registered ShaderModifier
* @return Render object data in a QString
*/
virtual QString dumpCurrentRenderObjectsToString(ACG::RenderObject** _list = 0, bool _outputShaders = false);
virtual QString dumpCurrentRenderObjectsToString(ACG::RenderObject** _list = 0, bool _outputShaders = false, std::vector<ACG::ShaderModifier*>* _modifiers = 0);
//=========================================================================
// Variables
......
......@@ -713,14 +713,16 @@ public:
bool hasGeometryShader() { return !desc_.geometryTemplateFile.isEmpty(); };
/** \brief Generates the shader code
*/
void generateShaders();
private:
/** \brief Loads external shader templates
*/
void loadShaderTemplateFromFile();
void generateShaders();
void buildVertexShader();
void buildGeometryShader();
void buildFragmentShader();
......
......@@ -104,6 +104,12 @@ void NormalRenderer::initializePlugin()
ACG::ShaderProgGenerator::setShaderDir(OpenFlipper::Options::shaderDirStr());
}
QString NormalRenderer::renderObjectsInfo(bool _outputShaderInfo) {
std::vector<ACG::ShaderModifier*> modifiers;
modifiers.push_back(&NormalFragmentModifier::instance);
return dumpCurrentRenderObjectsToString(&sortedObjects_[0], _outputShaderInfo, &modifiers);
}
void NormalRenderer::render(ACG::GLState* _glState, Viewer::ViewerProperties& _properties)
{
// collect renderobjects + prepare OpenGL state
......
......@@ -68,7 +68,7 @@ public:
public slots:
QString version() { return QString("1.0"); };
QString renderObjectsInfo(bool _outputShaderInfo) { return dumpCurrentRenderObjectsToString(&sortedObjects_[0],_outputShaderInfo); };
QString renderObjectsInfo(bool _outputShaderInfo);
private slots:
......
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