STVG 0 Newbie Poster

i'm using Soil library to load textures,here is my function to do this:

GLuint LoadTexture(std::string file)
    {
        GLuint texture;
        texture = SOIL_load_OGL_texture(
            file.c_str(),
            SOIL_LOAD_AUTO,
            SOIL_CREATE_NEW_ID,
            SOIL_FLAG_POWER_OF_TWO
            | SOIL_FLAG_MIPMAPS
            | SOIL_FLAG_MULTIPLY_ALPHA
            | SOIL_FLAG_COMPRESS_TO_DXT
            | SOIL_FLAG_DDS_LOAD_DIRECT
            | SOIL_FLAG_INVERT_Y
            );
        glBindTexture(GL_TEXTURE_2D, texture);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
        return texture;
    }

and i use this as follows:

this->texture2DObj = vShader->LoadTexture("PlayerCar.jpg");
    glActiveTexture(GL_TEXTURE0);
    glBindTexture(GL_TEXTURE_2D, this->texture2DObj);

    // Set the sampler texture unit to 0
    glUniform1i(1, 0);
    // Wrap texture coordinates by repeating
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);

but it has an Unhandled exception in SOIL_load_OGL_texture! my first question is what's wrong with it? and the second one is after this what i have to do to show texture on screen?

Here is my error message: First-chance exception at 0x6E754A2D (msvcr120d.dll) in 06_Textures.exe: 0xC0000005: Access violation reading location 0x00000000.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.