Jump to content

  • Log In with Google      Sign In   
  • Create Account

FREE SOFTWARE GIVEAWAY

We have 4 x Pro Licences (valued at $59 each) for 2d modular animation software Spriter to give away in this Thursday's GDNet Direct email newsletter.


Read more in this forum topic or make sure you're signed up (from the right-hand sidebar on the homepage) and read Thursday's newsletter to get in the running!


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


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
4 replies to this topic

#1 Enerjak   Members   -  Reputation: 235

Like
0Likes
Like

Posted 22 November 2012 - 02:14 PM

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

Sponsor:

#2 SiCrane   Moderators   -  Reputation: 9673

Like
1Likes
Like

Posted 22 November 2012 - 02:25 PM

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.

#3 Enerjak   Members   -  Reputation: 235

Like
0Likes
Like

Posted 22 November 2012 - 02:47 PM

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.

#4 SiCrane   Moderators   -  Reputation: 9673

Like
0Likes
Like

Posted 22 November 2012 - 02:52 PM

That shows the output you get. That's only half of a problem description. What is the output you expect?

#5 Enerjak   Members   -  Reputation: 235

Like
0Likes
Like

Posted 22 November 2012 - 02:59 PM

strangest thing.........i got it to work:http://puu.sh/1tadg




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS