[fixes #977] Fix Storm sky image going blank

This commit is contained in:
Sibo Van Gool 2021-07-03 23:54:23 +02:00
parent c1281a6951
commit b3064f08b5

View File

@ -17,6 +17,7 @@ import com.jogamp.opengl.util.texture.awt.AWTTextureIO;
public class SkyBoxCross extends Sky { public class SkyBoxCross extends Sky {
private final URL imageURL; private final URL imageURL;
private GL2 previousGL = null; // GL that the textures were previously bound to
Texture north, east, south, west, up, down; Texture north, east, south, west, up, down;
public SkyBoxCross(final URL imageURL) { public SkyBoxCross(final URL imageURL) {
@ -40,6 +41,7 @@ public class SkyBoxCross extends Sky {
south = AWTTextureIO.newTexture(GLProfile.getDefault(), fixBug(i.getSubimage(dx * 3, dy, dx, dy)), true); south = AWTTextureIO.newTexture(GLProfile.getDefault(), fixBug(i.getSubimage(dx * 3, dy, dx, dy)), true);
up = AWTTextureIO.newTexture(GLProfile.getDefault(), fixBug(i.getSubimage(dx, 0, dx, dy)), true); up = AWTTextureIO.newTexture(GLProfile.getDefault(), fixBug(i.getSubimage(dx, 0, dx, dy)), true);
down = AWTTextureIO.newTexture(GLProfile.getDefault(), fixBug(i.getSubimage(dx, 2 * dy, dx, dy)), true); down = AWTTextureIO.newTexture(GLProfile.getDefault(), fixBug(i.getSubimage(dx, 2 * dy, dx, dy)), true);
previousGL = gl;
} catch (IOException e) { } catch (IOException e) {
throw new Error(e); throw new Error(e);
} }
@ -47,7 +49,7 @@ public class SkyBoxCross extends Sky {
@Override @Override
public void draw(GL2 gl, final TextureCache cache) { public void draw(GL2 gl, final TextureCache cache) {
if (north == null) { if (north == null || gl != previousGL) {
loadTextures(gl); loadTextures(gl);
} }