Unhandled exception.

closed account (2NywAqkS)
I'm trying to load multiple textures like:
1
2
3
4
5
6
7
8
9
10
11
void LoadGLTextures(const char * filename, GLuint &texture)
{
	glEnable(GL_BLEND);
	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

    texture = SOIL_load_OGL_texture(filename, SOIL_LOAD_AUTO, SOIL_CREATE_NEW_ID, NULL);

    glBindTexture(GL_TEXTURE_2D, texture);
    glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
    glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR); 
}


1
2
3
4
GLuint Vietcong_texture;
GLuint Vietcong_Firing_texture;
GLuint Tree_1_texture;
GLuint Tree_2_texture;


1
2
3
4
LoadGLTextures("Vietcong.png",Vietcong_texture);
	LoadGLTextures("Vietcong_Firing.png",Vietcong_Firing_texture);
	LoadGLTextures("Tree 1.png",Tree_1_texture);
	LoadGLTextures("Tree 2.png",Tree_2_texture);


but this gives me a Unhandled exeption at 0x6525ca8e... error. I cant begin to figure out how to debug it because I don't know what a Unhandled exception is.
What is it and why do I get one?

Thanks Rowan.
That error means that something, somewhere, threw an exception. Unless your debugger has a different definition of an exception, the code you posted isn't the cause. Exceptions are part of C++, not C.
closed account (2NywAqkS)
If I take out the third section of code I don't get the error. So surely it must be the code. It compiles fine its just when I run it that I get the error. if it helps I'm using MVC++ 2010
Perhaps the graphics couldn't be loaded properly? You never check for a NULL value before you use texture in LoadGLTextures()..., so that may be the issue.
closed account (2NywAqkS)
How do I check before loading the file. And I have tried a number of ways now to load the Textures and it appaers its the line
SOIL_load_OGL_texture(filename, SOIL_LOAD_AUTO, SOIL_CREATE_NEW_ID, NULL);
that is causing the problem. it seems to work fine in examples so i guess it must be the PNG files. So what am I doing wrong with them?
Silly question but.. Have you verified that the files exist... in the correct directory?
closed account (2NywAqkS)
Yes, it defiantly does exist. In fact if I type the directory in wrong I don't get the error so i guess that proves it. I've decided to try a different texture loading program, DevIL.
May you can try to catch the exception by "try - catch". Anyway, not bad to change to another way.


b2ee
Last edited on
Topic archived. No new replies allowed.