0

I'm stuck trying to upload textures here:

// The FileSystem::getPath(...) is part of the GitHub repository so we can find files on any IDE/platform; replace it with your own image path.
    unsigned char *data = stbi_load(FileSystem::getPath("resources/textures/container.jpg").c_str(), &width, &height, &nrChannels, 0);

In regards to the comment above, how do I replace it with my own image path? I tried something like this:

unsigned char *data = stbi_load("Desktop/container.jpg").c_str(), &width, &height, &nrChannels, 0);

But it didn't work, of course, my little brain is overloaded right now and I just can't think straight. So... how do I specify an image path?

UPDATE: this is the error message I'm getting: enter image description here

Rabbid76
  • 202,892
  • 27
  • 131
  • 174
justaweeb
  • 29
  • 6
  • I would assume you either need the _full_ path eg `/home/$USER/Desktop/container.jpg` or, likely the better solution, move the file into the correct project directory so the relative path will work. – Joshua Jan 13 '21 at 23:15
  • Assuming `Desktop/container.jpg` is the correct and accessible file name then just use `stbi_load("Desktop/container.jpg", &width, &height, &nrChannels, 0)` -- `c_str()` is a member of whatever type is returned by `FileSystem::getPath` . – G.M. Jan 13 '21 at 23:32
  • Hey Joshua, the error that I'm getting is: FileSystem::GetPath these two are in red. 'FileSystem' is not a class or namespace and 'getPath' identifier not found – justaweeb Jan 13 '21 at 23:32
  • Hey G.M, still nothing :( – justaweeb Jan 13 '21 at 23:34

1 Answers1

2

I found the fix: It was indeed as Joshua said, "move the file into the correct project directory so the relative path will work". So in my project I created a folder called 'Textures' and added the textures there, and I called the texture using:

unsigned char* data = stbi_load("Textures/container.jpg", &width, &height, &nrChannels, 0);

I would like to close this post by adding Joshua's answer as the correct one but Idk how to do it so I'll add this one thx everybody for the help and insight

justaweeb
  • 29
  • 6