Jump to content
  • Advertisement
Sign in to follow this  
Enerjak

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

This topic is 2156 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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....

Share this post


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

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites
That shows the output you get. That's only half of a problem description. What is the output you expect?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!