now, so far so good. I still gotta do the functions of the shader but so far the struct is coming
along fine. one problem though:
puu.sh/1t9g5
code:
main.cpp.
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include "SStruct.h"
using namespace std;
int main()
{
vector<string> ShaderCode;
SStruct* s = new SStruct("VS_OUTPUT");
float x = 0;
s->addValue(1, "position", "POSITION0");
s->addValue(4, "tex","TEXCOORD0");
s->update();
cout << s->getShaderCode() << endl;
return 0;
}
struct.cpp
#include "SStruct.h"
SStruct::SStruct()
{
this->name = "PUT";
this->structCode = "struct";
}
SStruct::SStruct(std::string name)
{
this->name = name;
structCode = "struct ";
structCode += name + "\n";
}
void SStruct::setName(std::string newName)
{
this->name = newName;
}
bool SStruct::addValue(int count,string valueName, string SEMANTIC)
{
this->StructValues.insert(make_pair(valueName, SEMANTIC));
string value = " ";
string semantic = " ";
map<string,string>::iterator i = this->StructValues.begin();
for(; i != StructValues.end(); ++i)
{
value = i->first;
semantic = i->second;
if(count == 1)
{
this->shaderStream << setw(9) << "float " << value << " : " << semantic << ";\n";
}
else
{
this->shaderStream << setw(8) << "float" << count << " " << value << " : " << semantic << ";\n";
}
}
return true;
}
void SStruct::update()
{
this->structCode += "{ \n";
this->structCode += this->shaderStream.str() + "\n";
this->structCode += "}; \n";
}
string SStruct::getShaderCode()
{
return this->structCode;
}
it might seem useless to do all this work but not if you are making a shader editor....