Commit a455a217 authored by Jan Möbius's avatar Jan Möbius
Browse files

Merge branch 'renderobject_tostring' into 'master'

Extend render object info

See merge request !3
parents 8b1648d7 07256bf7
......@@ -350,6 +350,10 @@ QString RenderObject::toString() const
resultStrm << "\nalphaFunc: " << depthFunString[alphaFunc - GL_NEVER]
<< "\nalphaRef: " << alphaRef;
resultStrm << "\nclipDistanceMask: " << QString::number(clipDistanceMask, 2);
resultStrm << "\nprogramPointSize: " << programPointSize;
resultStrm << "\npointSize: " << pointSize;
resultStrm << "\ndiffuse: [" << diffuse[0] << ", " << diffuse[1] << ", " << diffuse[2] << "]";
resultStrm << "\nambient: [" << ambient[0] << ", " << ambient[1] << ", " << ambient[2] << "]";
resultStrm << "\nspecular: [" << specular[0] << ", " << specular[1] << ", " << specular[2] << "]";
......@@ -408,6 +412,8 @@ QString RenderObject::toString() const
if (vertexDecl)
resultStrm << "\n" << vertexDecl->toString();
if (!uniformPool_.empty())
resultStrm << "\n" << uniformPool_.toString();
return result;
}
......
......@@ -48,6 +48,7 @@
\*===========================================================================*/
#include <iostream>
#include <QTextStream>
#include <ACG/GL/acg_glew.hh>
#include <ACG/GL/GLError.hh>
......@@ -102,6 +103,19 @@ namespace GLSL {
return pool_.empty();
}
QString UniformPool::toString() const {
QString result;
QTextStream resultStrm(&result);
for (UniformList::const_iterator it = pool_.begin(); it != pool_.end(); ++it) {
resultStrm << (*it)->toString() << "\n";
}
return result;
}
/** \brief Send all stored uniforms to program
*
* @param _prog receiving GLSL program
......@@ -200,6 +214,23 @@ namespace GLSL {
checkGLError2(id.c_str());
}
/** \brief print float vector to string
*
*/
QString UniformPool::UniformVecf::toString() const {
const char* fmt = size > 1 ? "uniform vec%2 %1 = vec%2(" : "uniform float %1 = ";
QString str = QString(fmt).arg(id.c_str()).arg(size);
for (int i = 0; i < size; ++i) {
str += QString::number(val[i]);
if (i + 1 < size)
str += ", ";
}
if (size > 1)
str += ");";
return str;
}
/** \brief Bind uniform int vector to shader
*
* @param _progID GL Program ID
......@@ -231,6 +262,23 @@ namespace GLSL {
checkGLError2(id.c_str());
}
/** \brief print int vector to string
*
*/
QString UniformPool::UniformVeci::toString() const {
const char* fmt = size > 1 ? "uniform ivec%2 %1 = ivec%2(" : "uniform int %1 = ";
QString str = QString(fmt).arg(id.c_str()).arg(size);
for (int i = 0; i < size; ++i) {
str += QString::number(val[i]);
if (i + 1 < size)
str += ", ";
}
if (size > 1)
str += ");";
return str;
}
/** \brief Bind uniform uint vector to shader
*
* @param _progID GL Program ID
......@@ -262,6 +310,23 @@ namespace GLSL {
checkGLError2(id.c_str());
}
/** \brief print uint vector to string
*
*/
QString UniformPool::UniformVecui::toString() const {
const char* fmt = size > 1 ? "uniform uvec%2 %1 = uvec%2(" : "uniform uint %1 = ";
QString str = QString(fmt).arg(id.c_str()).arg(size);
for (int i = 0; i < size; ++i) {
str += QString::number(val[i]);
if (i + 1 < size)
str += ", ";
}
if (size > 1)
str += ");";
return str;
}
/** \brief Bind uniform matrix to shader
*
* @param _progID GL Program ID
......@@ -298,6 +363,27 @@ namespace GLSL {
checkGLError2(id.c_str());
}
/** \brief print matrix to string
*
*/
QString UniformPool::UniformMat::toString() const {
QString str = QString("uniform mat%2 %1 = {").arg(id.c_str()).arg(size);
for (int y = 0; y < size; ++y) {
str += "{";
for (int x = 0; x < size; ++x) {
str += QString::number(val(y,x));
if (x + 1 < size)
str += ", ";
}
str += "}";
if (y + 1 < size)
str += ", ";
}
str += "};";
return str;
}
/** \brief Bind uniform array to shader
*
* @param _progID GL Program ID
......@@ -317,6 +403,24 @@ namespace GLSL {
checkGLError2(id.c_str());
}
/** \brief print buffer id to string
*
*/
QString UniformPool::UniformBuf::toString() const {
QString str = QString("uniform %3 %2[%1] = {").arg(id.c_str()).arg(size).arg(integer ? "int" : "float");
for (int y = 0; y < size; ++y) {
if (integer)
str += QString::number(((GLint*)val)[y]);
else
str += QString::number(val[y]);
if (y + 1 < size)
str += ", ";
}
str += "};";
return str;
}
/** \brief Creates a copy of input data
*/
UniformPool::UniformBuf::UniformBuf()
......
......@@ -121,6 +121,11 @@ namespace GLSL {
*/
bool empty() const;
/** \brief print to string for debugging
*
*/
QString toString() const;
/** \brief copy
*
*/
......@@ -135,6 +140,8 @@ namespace GLSL {
virtual ~UniformBase() {}
virtual void bind(GLuint _progID) const {}
virtual QString toString() const { return QString(""); }
};
struct UniformVecf : public UniformBase {
......@@ -142,6 +149,8 @@ namespace GLSL {
int size;
void bind(GLuint _progID) const;
virtual QString toString() const;
};
// separate float int vector because sizeof(int) != sizeof(float) for some compilers
......@@ -150,6 +159,8 @@ namespace GLSL {
int size;
void bind(GLuint _progID) const;
virtual QString toString() const;
};
struct UniformVecui : public UniformBase {
......@@ -157,6 +168,8 @@ namespace GLSL {
int size;
void bind(GLuint _progID) const;
virtual QString toString() const;
};
......@@ -167,6 +180,8 @@ namespace GLSL {
int size;
void bind(GLuint _progID) const;
virtual QString toString() const;
};
struct UniformBuf : public UniformBase {
......@@ -179,6 +194,8 @@ namespace GLSL {
~UniformBuf();
void bind(GLuint _progID) const;
virtual 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