Skip to main content
GameDev.net gamedev.net
🔒 Locked

ilLoadImage

Started by BloodLust666 Jul 25, 2006 at 10:52 PM 22 replies 6.1k views
Original Post
BloodLust666
BloodLust666
There's a problem when I get to if (ilLoadImage((const ILstring)(Filename.c_str())) == IL_FALSE) it's equalling IL_FALSE for some reason... it has never done that before and I don't know why, the file is there, it's a png (like i've always been using) 128x128 size, i don't know what else is the problem
-------------------------Unless specified otherwise, my questions pertain:Windows Platform (with the mindset to keep things multi-platform as possible)C++Visual Studio 2008OpenGL with SFML
Rob Loach
Rob Loach
Did you call ilGenImages and ilBindImage before calling the function?
Rob Loach [Website] [Projects] [
BloodLust666
BloodLust666
yes, it ALWAYS worked in other programs/games I've made, but now outta no where, without me changing anything in the function, it's not working.

here's my engine's load function for a textuer

bool cWTexture::Load(std::string Filename)
{
if (IsLoaded())
Shutdown();

// Check if file exists
if (_access(Filename.c_str(), 0) == -1)
return cWUtility::ErrorLog.Write("cWTexture::Load() no file ", Filename);

ilGenImages(1, &m_ILTexID);
ilBindImage(m_ILTexID);

if (ilLoadImage((const ILstring)(Filename.c_str())) == IL_FALSE)
return cWUtility::ErrorLog.Write("cWTexture::Load() ilLoadImage() failed");

if (ilConvertImage(IL_RGBA, IL_UNSIGNED_BYTE) == IL_FALSE)
return cWUtility::ErrorLog.Write("cWTexture::Load() ilConvertImage() failed");

glGenTextures(1, &m_TexID);
glBindTexture(GL_TEXTURE_2D, m_TexID);

m_lWidth = ilGetInteger(IL_IMAGE_WIDTH);
m_lHeight = ilGetInteger(IL_IMAGE_HEIGHT);

glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);

glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, m_lWidth, m_lHeight,
0, GL_RGBA, GL_UNSIGNED_BYTE, ilGetData());

return true;
}
-------------------------Unless specified otherwise, my questions pertain:Windows Platform (with the mindset to keep things multi-platform as possible)C++Visual Studio 2008OpenGL with SFML
BloodLust666
BloodLust666
I displayed the error using:

std::string s;
s = iluErrorString(ilGetError());

cWUtility::ErrorLog.Write(s);

and it said "invalid value". what's that mean? what's an invalid value?
-------------------------Unless specified otherwise, my questions pertain:Windows Platform (with the mindset to keep things multi-platform as possible)C++Visual Studio 2008OpenGL with SFML
Gorg
Gorg
ilGetError keeps track of the last error that happened. It does not mean it was in the last function you called.

Pepper your code with ilGetError after each il calls and see where it fails.
BloodLust666
BloodLust666
i know, that's what I did, I put it before AND after where it fails

cWUtility::ErrorLog.Write(iluErrorString(ilGetError()));

if (ilLoadImage((const ILstring)(Filename.c_str())) == IL_FALSE)
cWUtility::ErrorLog.Write(iluErrorString(ilGetError()));

my output is:

no error
invalid value
-------------------------Unless specified otherwise, my questions pertain:Windows Platform (with the mindset to keep things multi-platform as possible)C++Visual Studio 2008OpenGL with SFML
BloodLust666
BloodLust666
i downloaded the source and looked through all the steps it took to load a PNG file and i found where it give an "invalid value", it fails at "iIsValidPng()", but i couldn't find the file where that was in, so i don't know why.. any ideas?
-------------------------Unless specified otherwise, my questions pertain:Windows Platform (with the mindset to keep things multi-platform as possible)C++Visual Studio 2008OpenGL with SFML
EmrldDrgn
EmrldDrgn
AIK, ilLoadImage returns false when it succeeds, and true when it fails.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~I program in C++, on MSVC++ '05 Express, and on Windows. Most of my programs are also for windows.
BloodLust666
BloodLust666
no, because I never got this error before and I haven't changed that portion of my engine is a long time; now it's not working and it's returning IL_FALSE. Plus in the source for OpenIL, I saw that it returns IL_FALSE when there's an error.
-------------------------Unless specified otherwise, my questions pertain:Windows Platform (with the mindset to keep things multi-platform as possible)C++Visual Studio 2008OpenGL with SFML
Gorg
Gorg
iIsValidPng should be in il_png.c. It simply reads the header passes it to libpng for validation.

Looks like libpng has some problem with your image.

Is it possible that you are trying to load a different image format than when it was working?
BloodLust666
BloodLust666
nope, that's impossible because the image format IS a png..
-------------------------Unless specified otherwise, my questions pertain:Windows Platform (with the mindset to keep things multi-platform as possible)C++Visual Studio 2008OpenGL with SFML
smr
smr
Maybe this seems like a stupid question to you, but does the image exist in the path that you're looking for it within? If you're using a relative path try using an absolute path.
BloodLust666
BloodLust666
that's not it either because before that in the code, i have it check to see if the file exists and it gets past that fine, so it's finding the file; it's just saying it's an "invalid value" in the IL ERROR thing
-------------------------Unless specified otherwise, my questions pertain:Windows Platform (with the mindset to keep things multi-platform as possible)C++Visual Studio 2008OpenGL with SFML
BloodLust666
BloodLust666
that was weird... i deleted the file and created a new one and it works now.. heh... but now for some reason (this never happened before either), when i draw the quad and texture it, i can see the line that cuts the quad into two triangles.. why is THAT doing that now..?
-------------------------Unless specified otherwise, my questions pertain:Windows Platform (with the mindset to keep things multi-platform as possible)C++Visual Studio 2008OpenGL with SFML
Gorg
Gorg
Quote:
Original post by EvilKnuckles666
nope, that's impossible because the image format IS a png..


I actually meant different format as in 32bits with alpha channel, only 8-bits, etc. Though from my experience with Openil it opens pretty much all of them.

Looks like you solved your problem. Sound likes the file was corrupted.

As for your new problem. Are you modulating and have different colors at the vertices? Are you blending?

BloodLust666
BloodLust666
i'm blending (glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA))and the colors of the verticies are the same color (white)
-------------------------Unless specified otherwise, my questions pertain:Windows Platform (with the mindset to keep things multi-platform as possible)C++Visual Studio 2008OpenGL with SFML
Gorg
Gorg
Try to render the quad with blending disabled (and using replace in texEnv if you modulate). Does the line disappear?

Also, try to reproduce the problem in a simple environment(I am assuming you are rendering mode than just your quads and settings different states). Nehe's code from the first of couple of tutorials is useful for that.





BloodLust666
BloodLust666
disabling works and all but i have a lot of textures that have pixels with an alpha of 0 (needing to be completely transparent) and if it's disabled I see the black part of the quad where it's supposed to be transparent.
-------------------------Unless specified otherwise, my questions pertain:Windows Platform (with the mindset to keep things multi-platform as possible)C++Visual Studio 2008OpenGL with SFML
Gorg
Gorg
Ok. Then it means it's something with blending. Does it happen only with that image or with all your images?

And what other operations do you do on that image? Multipass or you just render that texture on a quad with blending?
BloodLust666
BloodLust666
it happens with all my images. i'm only rendering the quad and texturing it with blending.
-------------------------Unless specified otherwise, my questions pertain:Windows Platform (with the mindset to keep things multi-platform as possible)C++Visual Studio 2008OpenGL with SFML

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.