Yes it generates them.Here's a sample code i use
//Up to this point you should have an array with the texture data. I don't know if the SDL_surface works the same
//Also the var image is a GLuint variable that holds a texture ID
//Generate a GL texture
glGenTextures(1, &image);
//Bind GL texture
glBindTexture(GL_TEXTURE_2D, image);
//Sets wrapping style
//I use GL_REPEAT here, but you can use GL_CLAMP_TO_EDGE, GL_CLAMP is deprecated
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
//Sets mag / min filters
//The TF_NO_FILTER, etc are just enums i made for selecting the filter
switch(this->filter)
{
case TF_NO_FILTER:
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
break;
case TF_BILINEAR:
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
break;
//The this->mipmapMaxLevel is just the maximum level of mipmap to create
//If it is 4, 4 levels of mipmaps will be created
case TF_BILINEAR_MIPMAP:
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, this->mipmapMaxLevel);
break;
case TF_TRILINEAR:
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, this->mipmapMaxLevel);
break;
}
//VAR: The image format
//You should ignore this, since your texture may have a different data format
uint32 format = 0;
if(imageFormat == 0)
format = GL_RGB;
else if(imageFormat == 1)
format = GL_RGBA;
//Build the texture
glTexImage2D(GL_TEXTURE_2D,
0,
GL_RGBA, //This is the internal format in which OpenGL will store the texture
pData.width, //Your image's width
pData.height, //Your image's height
0,
format, //Your texture's data format (GL_RGB, GL_RGBA, etc)
GL_UNSIGNED_BYTE, //The size of each color component
&imageData[0]); //A pointer to your texture data (my was imageData)
//Create mipmaps
//Again only call this if you're creating mipmaps
switch (this->filter)
{
case TF_BILINEAR_MIPMAP:
case TF_TRILINEAR:
glGenerateMipmap(GL_TEXTURE_2D);
break;
}
//Cleanup here...
I don't know why your code sometimes don't work though...
Also, you are using anisotropic filtering, but i've never used that, so this code might not be exactly what you need.
Hope it helps.