1
DotNet / Re: Semi-random crashes when creating Textures
« on: November 19, 2018, 11:46:47 am »
I managed to get texture loading working fine using this:
I noticed that if I pass null to glTexImage2D instead of the pixel byte array I get the same problem as before.
Seems like SFML in Texture::create, passes null to it as well:
https://github.com/SFML/SFML/blob/ff87e1c92265574f5c9785117b00907b7a61cf7d/src/SFML/Graphics/Texture.cpp#L208
Not sure why that is causing issues, or if that is the true cause or not.
Code: [Select]
private static Texture GetTexture(Stream stream, IntRect area = default(IntRect))
{
Image image = new Image(stream);
Texture texture = new Texture(image.Size.X, image.Size.Y);
if (area == default(IntRect))
area = new IntRect(0, 0, (int)image.Size.X, (int)image.Size.Y);
Texture.Bind(texture);
Gl.glTexImage2D(Gl.GL_TEXTURE_2D, 0, Gl.GL_RGBA, area.Width, area.Height, 0, Gl.GL_RGBA, Gl.GL_UNSIGNED_BYTE, image.Pixels);
Gl.glTexSubImage2D(Gl.GL_TEXTURE_2D, 0, area.Left, area.Top, area.Width, area.Height, Gl.GL_RGBA, Gl.GL_UNSIGNED_BYTE, image.Pixels);
Texture.Bind(null);
return texture;
}
I noticed that if I pass null to glTexImage2D instead of the pixel byte array I get the same problem as before.
Seems like SFML in Texture::create, passes null to it as well:
https://github.com/SFML/SFML/blob/ff87e1c92265574f5c9785117b00907b7a61cf7d/src/SFML/Graphics/Texture.cpp#L208
Not sure why that is causing issues, or if that is the true cause or not.