map adding two of the same values (not really sure what to call it.)

Started by
3 comments, last by Enerjak 11 years, 5 months ago
So i was bored today and decided to create a shader class along with a struct class ect.
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....
Advertisement
It would probably help if you say explicitly what problem you're having. At a guess though, you might want to try a multimap rather than a regular map.

It would probably help if you say explicitly what problem you're having. At a guess though, you might want to try a multimap rather than a regular map.


well i did post a picture link it's that push.com thing, not sure why it didn't add it as a link.http://puu.sh/1t9g5 this should be better.
That shows the output you get. That's only half of a problem description. What is the output you expect?
strangest thing.........i got it to work:http://puu.sh/1tadg

This topic is closed to new replies.

Advertisement