Renderer/GlslWriter: Add comment sections

This commit is contained in:
Lynix 2017-01-04 14:00:58 +01:00
parent 114c4dbf58
commit 43e23fea47
2 changed files with 13 additions and 0 deletions

View File

@ -46,6 +46,7 @@ namespace Nz
void Append(ShaderAst::ExpressionType type);
void Append(const String& txt);
void AppendCommentSection(const String& section);
void AppendFunction(Function& func);
void AppendLine(const Nz::String& txt = Nz::String());

View File

@ -34,6 +34,9 @@ namespace Nz
// Uniforms
if (!state.m_uniforms.empty())
{
AppendCommentSection("Uniforms");
AppendLine();
for (const auto& pair : state.m_uniforms)
{
Append("uniform ");
@ -258,6 +261,15 @@ namespace Nz
m_currentState->stream << txt;
}
void GlslWriter::AppendCommentSection(const String& section)
{
NazaraAssert(m_currentState, "This function should only be called while processing an AST");
String stars((section.GetSize() < 33) ? (36 - section.GetSize()) / 2 : 3, '*');
m_currentState->stream << "/*" << stars << ' ' << section << ' ' << stars << "*/";
AppendLine();
}
void GlslWriter::AppendFunction(Function& func)
{
NazaraAssert(!m_currentFunction, "A function is already being processed");