Access violation error when changing texture settings in stbi

Viewed 16

My last hope to find answers. Why do I get Access violation error when changing texture settings in stbi?

//Texture
    int img_x, img_y, numcolch;

    stbi_set_flip_vertically_on_load(true);

    unsigned char* bytes = stbi_load("resource\\textures\\1.png",&img_x,&img_y,&numcolch,0);

    GLuint texture;//texture obj
        
    glGenTextures(1, &texture);

    glActiveTexture(GL_TEXTURE0);//slot
    
    glBindTexture(GL_TEXTURE_2D, texture); 

    //------------------------------------------------------------------------------------------------------------------
    
    //texture settings
    glTextureParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_NEAREST);
    glTextureParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_NEAREST);
    
    glTextureParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_CLAMP_TO_BORDER);
    glTextureParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_CLAMP_TO_BORDER);

    GLfloat bordercol[]={1.0f,1.0f,1.0f,1.0f};
    glTextureParameterfv(GL_TEXTURE_2D, GL_TEXTURE_BORDER_COLOR, bordercol);
    
    //------------------------------------------------------------------------------------------------------------------
    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, img_x, img_y, 0, GL_RGBA, GL_UNSIGNED_BYTE, bytes);

    glGenerateMipmap(GL_TEXTURE_2D);

i get error in line glTextureParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_NEAREST);

i try to comment it out but the same error propagates to the next line. somehow glTextureParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_NEAREST); doesnt show errors.

I'm using glfw,glad and imgui. I can't understand what to do now. Can anyone help please?

0 Answers
Related