Hi, I can't figure out why this code throws me an exception. Can you help me?
TEXTURE LoadTexture(const char* file)
{
TEXTURE texture; // GLuint texture, int width, int height
if ( IMG_Load(file) )
{
SDL_Surface* surface = IMG_Load(file);
GLuint tex;
glGenTextures(1, &tex);
glBindTexture(GL_TEXTURE_2D, tex);
THROWS EXCEPTION at this point -> glTexStorage2D(GL_TEXTURE_2D, 1, GL_RGBA8, surface->w, surface->h);
glTexSubImage2D( GL_TEXTURE_2D, 0, 0, 0, surface->w, surface->h, GL_RGBA, GL_UNSIGNED_BYTE,
surface->pixels);
glGenerateMipmap(GL_TEXTURE_2D);
GLfloat maxAniso;
glGetFloatv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &maxAniso);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, maxAniso);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
texture.texture=tex;
texture.width=surface->w;
texture.height=surface->h;
SDL_FreeSurface(surface);
}
else
{
texture.texture=0;
texture.width=0;
texture.height=0;
}
return texture;
}