PDA

View Full Version : Qt5 and OpenGL



sajis997
27th August 2015, 10:28
Hello forum,


I am having the following compilation error:



Model.cpp:233: error: 'glGenerateMipmap' was not declared in this scope
glGenerateMipmap(GL_TEXTURE_2D);
^


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





GLint Model::TextureFromFile(const char* path, string directory, bool gamma)
{
//Generate texture ID and load texture data
string filename = string(path);
filename = directory + '/' + filename;
GLuint textureID;
glGenTextures(1, &textureID);
int width,height;
unsigned char* image = SOIL_load_image(filename.c_str(), &width, &height, 0, SOIL_LOAD_RGB);
// Assign texture to ID
glBindTexture(GL_TEXTURE_2D, textureID);
glTexImage2D(GL_TEXTURE_2D, 0, gamma ? GL_SRGB : GL_RGB, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE, image);
glTexParameteri(GL_TEXTURE_2D,GL_GENERATE_MIPMAP,G L_TRUE);

glGenerateMipmap(GL_TEXTURE_2D);

// Parameters
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glBindTexture(GL_TEXTURE_2D, 0);
SOIL_free_image_data(image);
return textureID;
}



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

d_stranz
27th August 2015, 23:52
If you're compiling on Windows using Microsoft's OpenGL headers, then it looks like this function is not included in the core, but rather as an extension. See this stackoverflow post (http://stackoverflow.com/questions/5168798/glgeneratemipmap-identifier-not-found). You'll probably need to download and install glew or a similar extension library.