Skip to content

Commit

Permalink
Don't crash when no texture atlas can be loaded
Browse files Browse the repository at this point in the history
  • Loading branch information
Interrupt committed Sep 15, 2020
1 parent 3cc60a3 commit 469305c
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions Dungeoneer/src/com/interrupt/dungeoneer/gfx/TesselatorGroup.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,12 @@ public void render() {
TextureAtlas lastAtlas = null;

for(int i = 0; i < tesselators.size; i++) {
ShaderInfo shader = null;

// Bind the atlas for drawing
TextureAtlas atlas = TextureAtlas.bindRepeatingTextureAtlasByIndex(tesselators.getKeyAt(i));
ShaderInfo shader = atlas.getShader();
if(atlas != null)
shader = atlas.getShader();

// If there's no custom shader set, use the default one
if(shader == null)
Expand All @@ -70,14 +73,16 @@ public void render() {
shader.begin();

// Set some shader properties based on the atlas
Texture tex = atlas.texture;
if(tex != null) {
shader.setAttribute("u_tex_width", (float)atlas.spriteSize / tex.getWidth());
shader.setAttribute("u_tex_height", 1f / tex.getHeight());
if(atlas != null) {
Texture tex = atlas.texture;
if (tex != null) {
shader.setAttribute("u_tex_width", (float) atlas.spriteSize / tex.getWidth());
shader.setAttribute("u_tex_height", 1f / tex.getHeight());
}

shader.setAttribute("u_sprite_columns", atlas.columns);
shader.setAttribute("u_sprite_rows", atlas.rows);
}

shader.setAttribute("u_sprite_columns", atlas.columns);
shader.setAttribute("u_sprite_rows", atlas.rows);
}

tesselators.getValueAt(i).renderMesh(shader);
Expand Down

0 comments on commit 469305c

Please sign in to comment.