Reputation: 11
I'm using a pre-built library and in order for me to load a texture and display it I have to use this code. I'm looking to load multiple files and store them as a struct
in an array so they can be called and displayed. I keep getting this error:
No suitable conversion function from
std
string to const char * exists
when trying to load in the section below.
for (int i=0; i<CUTSCENE; i++)
{
stringstream s;
int fileNum = i+1;
string FirstPart = "Textures/GameVideos/Game (";
string LastPart = ").png";
s << FirstPart << fileNum << LastPart << endl;
string fullfileName;
s >> fullfileName;
cutSceneMain[i]->texture = new Texture2D();
cutSceneMain[i]->texture->Load(fullfileName, false);
cutSceneMain[i]->sourceRect = new Rect(0.0f, 0.0f, 700, 700);
cutSceneMain[i]->position = new Vector2(0.0f, 0.0f());
}
Upvotes: 1
Views: 5116
Reputation: 49986
The problem is most probably with the way you call Load
, a fix is to use fullfileName.c_str()
:
cutSceneMain[i]->texture->Load(fullfileName.c_str(), false);
^^^^^^^
Load
requires const char*
Upvotes: 9