sdl img loading problem

i cant seem to load a jpeg using sdl_img, and i cant figure out why.

heres the code:

1
2
3
tileset = IMG_Load ("tileset.jpeg");
	if (tileset == NULL)
		return;
Last edited on
IMG_Load returns NULL?

Make sure the filename is exactly tileset.jpeg and that it is located in the working directory.
Maybe even try "./tileset.jpeg"
i have double checked the filename etc. i dont get what i have done wrong...

./tileset.jpeg didnt work either
Last edited on
Experience tells me the problem is with the file path. All the paths is relative to the working directory of the process.

If you run it from an IDE the working directory is often not the same as the directory where your executable file is located. It might be possible to change the working directory in your IDE settings. You can also move the files to the working directory instead, or change the file paths in your program.

If you run your program by double clicking on the executable file the working directory is often the same directory as the executable file.

If you run the program from the terminal you should know what the working directory is. The working directory can often be changed with the cd command. On linux you can run pwd to print the working directory. I think echo %cd% do the same on windows.
Last edited on
i rune it from the .exe file. the file is located correctly, and i know this cause i have done it like 20 times before, and it has always worked. i know the name and filetype is correct.
What does IMG_GetError() return?
Topic archived. No new replies allowed.