I don't know if the problem is related to SFML at all, but i'm posting it here either way!
A project of mine is using SFML to create a window as well as load imagefiles, and so far this has been going great! I'm currently working on drawing planet earth using highresolution textures and shaders, currently I have 3 textures I want to use, all of wich are 8192x4096:
- Normal/Daylight
- Night-texture
- Cloudmap
Regardless of the order I'm loading these in, the third one always fails with GL_OUT_OF_MEMORY after the methodcall gluBuild2DMipmaps. Remember I dont use sf::Texture or sf::Shader here, only sf::RenderWindow and sf::Image. The program still runs but the third texture seems to contain no pixeldata, making it transparent.
If I load the night-texture last:
https://legacy.sfmluploads.org/cache/pics/243_earthclouds.pngIf I load the cloud-texture last:
https://legacy.sfmluploads.org/cache/pics/244_earthnight.pngI suspect it being a missing glcontext or something, therefore I wanted to use ensureGlContext to ensure it but noticed that method is protected :/ Is there anyone who knows what it might be?
The max texture size on my system is 16K, so that passes.
Full code to create a texture:
de::Texture::Texture(de::Base* r, std::string name,std::string path){
std::cout << "Loading texture from " << path.c_str() << "..";
this->Root = r;
this->Name = "__not_ready";
this->Handle = 0;
this->IsReady = false;
sf::Image c;
if(c.loadFromFile(path)){
glGenTextures(1, &this->Handle);
glBindTexture(GL_TEXTURE_2D, this->Handle);
gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGBA, c.getSize().x, c.getSize().y, GL_RGBA, GL_UNSIGNED_BYTE, c.getPixelsPtr());
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
if(this->Root->GetGLSystem()->GetHardware()->Anisotrophy){
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, this->Root->GetGLSystem()->GetHardware()->Anisotrophy);
}
this->IsReady = true;
this->Name = name;
std::cout << "Created texture!" << std::endl;
}else{
std::cout << "Couldn't load texture from file." << std::endl;
throw(de::Exception("Couldn't create a texture, image not valid!"));
}
}
de::Texture::Handle is a GLuint