It should n't be like this since sfml use stb_image internally?
Anyway the different result are shown as the picture file attached.
If I use sfml texture class with opengl, the left half of the model is not correctly rendered, it seems as if the texture coords numbers are wrong or something, however if I change the way to read texture from sfml to directly use stb_image, this problems are gone.
The relavant codes are like this:
to read image files in sfml
else if ((ext == DATA_JPG) || (ext == DATA_PNG))
{
Image image;
if (!image.loadFromFile(path))
{
throw Exception(EX_BROKEN_DATA_FILE, name);
}
//image.createMaskFromColor(Color::White);
if (!insertAsset<Texture>(name)->loadFromImage(image))
{
throw Exception(EX_FAILED_TO_LOAD_TEXTURE, name);
}
}
to set the texture uniforms in opengl
mat->GetTexture(type, i, &str);
sf::Texture* current_tex = getAsset2<sf::Texture>(str.C_Str());
if (current_tex)
{
TextureInfo current_texture_info;
current_tex->generateMipmap();
current_texture_info.glID = current_tex->getNativeHandle();
current_texture_info.type = typeName;
current_texture_info.filename = str.C_Str();
textures.push_back(current_texture_info);
}
To bind the texture in opengl
// now set the sampler to the correct texture unit
//shader.setInt((name + number), i);
glUniform1i(glGetUniformLocation(shader.getID(), (name + number).c_str()), i);
// and finally bind the texture
glBindTexture(GL_TEXTURE_2D, textures[i].glID);