Hello forum,


I am having the following compilation error:

Qt Code:
  1. Model.cpp:233: error: 'glGenerateMipmap' was not declared in this scope
  2. glGenerateMipmap(GL_TEXTURE_2D);
  3. ^
To copy to clipboard, switch view to plain text mode 

I have a Model class with a member function to generate texture object.


Qt Code:
  1. GLint Model::TextureFromFile(const char* path, string directory, bool gamma)
  2. {
  3. //Generate texture ID and load texture data
  4. string filename = string(path);
  5. filename = directory + '/' + filename;
  6. GLuint textureID;
  7. glGenTextures(1, &textureID);
  8. int width,height;
  9. unsigned char* image = SOIL_load_image(filename.c_str(), &width, &height, 0, SOIL_LOAD_RGB);
  10. // Assign texture to ID
  11. glBindTexture(GL_TEXTURE_2D, textureID);
  12. glTexImage2D(GL_TEXTURE_2D, 0, gamma ? GL_SRGB : GL_RGB, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE, image);
  13. glTexParameteri(GL_TEXTURE_2D,GL_GENERATE_MIPMAP,GL_TRUE);
  14.  
  15. glGenerateMipmap(GL_TEXTURE_2D);
  16.  
  17. // Parameters
  18. glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT );
  19. glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT );
  20. glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR );
  21. glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
  22. glBindTexture(GL_TEXTURE_2D, 0);
  23. SOIL_free_image_data(image);
  24. return textureID;
  25. }
To copy to clipboard, switch view to plain text mode 

rest of the gl functions do not end up with the compilation error. Any idea ?