PDA

View Full Version : Load a Texture



BLooDBuRNiNG
07-19-2014, 04:51 AM
Hello OpenGL communauty,

I have a big problem with IMG_Load function from "SDL_image.h".

I have an image called underground.png and when I'm loading it, I'm permanently get the error : "IMG_Load : Failed loading libjpeg-9.dll specified is unfoundable".

This is strange because the file exist, as I you can see in my output. I also correctly linked my libraries, I have pain to understand why, IMG_Load is not able to load my images.


In this function I'm showing the folders of my current directory and I'm make an image load of each folder, if it work it write "worked" else it print an error message.


#include <SDL2/SDL.h>
#include <SDL2/SDL_image.h>
#include <GL\glut.h>

#include <iostream>
#include <string>
#include <cstdlib>

#include <stdio.h>
#include <sys/types.h>
#include <dirent.h>

void displayDirectory(std::string path)
{
SDL_Surface* img = nullptr;
struct dirent* lecture;
DIR* rep;

rep = opendir(path.c_str());
std::cout << "repository name : " << path.c_str() << "\n\n";
while ((lecture = readdir(rep)))
{
std::string imagePath = path + "/" + lecture->d_name;

std::cout << lecture->d_name << std::endl << imagePath << std::endl;

if (nullptr == (img = IMG_Load(imagePath.c_str()))) std::cout << "IMG_Load:" << IMG_GetError () << std::endl;
else std::cout << "worked\n";
}

while (42) std::cout << "";
//std::cout << std::endl;
closedir(rep);
}}

output :
1369

Agent D
07-19-2014, 05:38 AM
I posted a possible answer to your problem over here (http://www.opengl.org/discussion_boards/showthread.php/184510-Load-a-Texture-With-SDL?p=1260556#post1260556). Please do not cross post.

BLooDBuRNiNG
07-19-2014, 05:50 AM
Thanks you for this answer, it don't work yet, but I have a different error. I found this dll on a github project but now I have the following error :
"IMG_Load : Failed loading libpng16-16.dll"
I already put in my visual directory :
libjpeg-9.dll
libpng16-16.dll
libtiff-5.dll
libwebp-4.dll

Agent D
07-19-2014, 06:12 AM
Those libraries have to be in the same directory as the application binary.

BLooDBuRNiNG
07-19-2014, 07:23 AM
My libraries are in the same folder than my application binary. I'm asking what should I do of more

MtRoad
07-22-2014, 05:29 AM
Linking involves finding dll files (dynamic linked libraries) from specific linker paths you specify during compilation.

Post your linker flags, linker paths and the rest of your compile options. That will help figuring out what is going on.

I see you're using .dll's so I'm assuming you are using Visual Studio, or are you using something else (GCC?)?

BLooDBuRNiNG
07-23-2014, 01:05 AM
Hello MtRoad,

Yes I'm using Visual studio, I'm not using an other compiler (like GCC).

Here my linkers flags :
opengl32.lib
glut32.lib
SDL2.lib
SDL2main.lib
SDL2_image.lib