Commit db603bdb authored by Christopher Tenter's avatar Christopher Tenter

- added toString() for text-dump debugging

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@15771 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 378f6664
......@@ -44,6 +44,7 @@
#include <string.h>
#include <iostream>
#include <stdlib.h>
#include <QTextStream>
#include <ACG/GL/gl.hh>
......@@ -161,5 +162,89 @@ RenderObject::RenderObject()
}
QString RenderObject::toString() const
{
// several mappings: (int)GLEnum -> string
const char* primitiveString[] =
{
"GL_POINTS",
"GL_LINES",
"GL_LINE_LOOP",
"GL_LINE_STRIP",
"GL_TRIANGLES",
"GL_TRIANGLE_STRIP",
"GL_TRIANGLE_FAN",
"GL_QUADS",
"GL_QUAD_STRIP",
"GL_POLYGON"
};
const char* fillModeString[] =
{
"GL_POINT",
"GL_LINE",
"GL_FILL"
};
const char* depthFunString[] =
{
"GL_NEVER",
"GL_LESS",
"GL_EQUAL",
"GL_LEQUAL",
"GL_GREATER",
"GL_NOTEQUAL",
"GL_GEQUAL",
"GL_ALWAYS"
};
QString result;
QTextStream resultStrm(&result);
resultStrm << "name: " << debugName
<< "\ndebugID: " << debugID
<< "\npriority: " << priority
<< "\nprimitiveMode: " << (primitiveMode <= GL_POLYGON ? primitiveString[primitiveMode] : "undefined")
<< "\nfillMode: " << fillModeString[fillMode - GL_POINT]
<< "\nnumIndices: " << numIndices
<< "\nindexOffset: " << indexOffset;
resultStrm << "\n" << shaderDesc.toString();
resultStrm << "\nculling: " << culling
<< "\nblending: " << blending
<< "\nalphaTest: " << alphaTest;
resultStrm << "\ndepthTest: " << depthTest
<< "\ndepthWrite: " << depthWrite
<< "\ndepthFunc: " << depthFunString[depthFunc - GL_NEVER]
<< "\ndepthRange: [" << depthRange[0] << ", " << depthRange[1] << "]"
<< "\ncolorWriteMask: " << colorWriteMask[0] << ", " << colorWriteMask[1] << ", "<< colorWriteMask[2] << ", "<< colorWriteMask[2];
resultStrm << "\ndiffuse: [" << diffuse[0] << ", " << diffuse[1] << ", " << diffuse[2] << "]";
resultStrm << "\nambient: [" << ambient[0] << ", " << ambient[1] << ", " << ambient[2] << "]";
resultStrm << "\nspecular: [" << specular[0] << ", " << specular[1] << ", " << specular[2] << "]";
resultStrm << "\nemissive: [" << emissive[0] << ", " << emissive[1] << ", " << emissive[2] << "]";
resultStrm << "\nshininess: " << shininess;
resultStrm << "\nalpha: " << alpha;
resultStrm << "\ninternalFlags: " << internalFlags_;
if (vertexDecl)
resultStrm << "\n" << vertexDecl->toString();
return result;
}
} // namespace ACG end
\ No newline at end of file
......@@ -216,6 +216,7 @@ struct ACGDLLEXPORT RenderObject
/// used internally for renderer debugging
int debugID;
const char* debugName;
/// may be used internally by the renderer
unsigned int internalFlags_;
......@@ -266,6 +267,11 @@ struct ACGDLLEXPORT RenderObject
/** \brief Fills out ShaderGenDesc parameters based on Drawmode properties
*/
void setupShaderGenFromDrawmode(const SceneGraph::DrawModes::DrawModeProperties* _props);
/** Returns a text representation of the RenderObject for debugging purposes.
*/
QString toString() const;
};
......
......@@ -900,6 +900,60 @@ ShaderModifier::ShaderModifier( void )
ShaderModifier::~ShaderModifier( void )
{}
//=============================================================================
QString ShaderGenDesc::toString() const
{
// mapping (int)ShaderGenMode -> string
const char* shadeModeString[] =
{
"SG_SHADE_UNLIT",
"SG_SHADE_FLAT",
"SG_SHADE_GOURAUD",
"SG_SHADE_PHONG"
};
QString res;
QTextStream resStrm(&res);
resStrm << "shaderDesc.numLights: " << numLights;
if (numLights)
{
resStrm << "\nshaderDesc.lightTypes[]: {";
for (int i = 0; i < numLights; ++i)
{
switch (lightTypes[i])
{
case SG_LIGHT_DIRECTIONAL: resStrm << "DIRECTIONAL"; break;
case SG_LIGHT_POINT: resStrm << "POINT"; break;
case SG_LIGHT_SPOT: resStrm << "SPOT"; break;
default: resStrm << "UNDEFINED"; break;
}
if (i + 1 < numLights)
resStrm << ", ";
else
resStrm << "}";
}
}
resStrm << "\nshaderDesc.shadeMode: " << shadeModeString[shadeMode];
resStrm << "\nshaderDesc.vertexColors: " << vertexColors;
resStrm << "\nshaderDesc.textured: " << textured;
if (vertexTemplateFile)
resStrm << "\nshaderDesc.vertexTemplateFile: " << vertexTemplateFile;
if (fragmentTemplateFile)
resStrm << "\nshaderDesc.fragmentTemplateFile: " << fragmentTemplateFile;
return res;
}
} // namespace ACG
//=============================================================================
......@@ -88,6 +88,10 @@ struct ShaderGenDesc
// optionally specify shader template file names
const char* vertexTemplateFile;
const char* fragmentTemplateFile;
/// convert ShaderGenDesc to string format for debugging
QString toString() const;
};
/**
......
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