Sign in to follow this  
Enerjak

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

Recommended Posts

Enerjak    277
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:
[url="puu.sh/1t9g5"]puu.sh/1t9g5[/url]

code:

main.cpp.
[CODE]
#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;
}
[/CODE]

struct.cpp
[CODE]
#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;
}
[/CODE]

it might seem useless to do all this work but not if you are making a shader editor....

Share this post


Link to post
Share on other sites
SiCrane    11839
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.

Share this post


Link to post
Share on other sites
Enerjak    277
[quote name='SiCrane' timestamp='1353615942' post='5003308']
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.
[/quote]

well i did post a picture link it's that push.com thing, not sure why it didn't add it as a link.[url="http://puu.sh/1t9g5"]http://puu.sh/1t9g5[/url] this should be better.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this