OSDN Git Service

Allow renderable to be null
authorXoppa <contact@xoppa.nl>
Thu, 8 Aug 2013 22:04:42 +0000 (00:04 +0200)
committerXoppa <contact@xoppa.nl>
Thu, 8 Aug 2013 22:04:42 +0000 (00:04 +0200)
gdx/src/com/badlogic/gdx/graphics/g3d/shaders/BaseShader.java

index 7fc066e..131831b 100644 (file)
@@ -45,7 +45,7 @@ public abstract class BaseShader implements Shader {
                        this(alias, 0);
                }
                public boolean validate(final BaseShader shader, final int inputID, final Renderable renderable) {
-                       return (renderable.material.getMask() & materialMask) == materialMask;
+                       return (renderable == null ? 0 : (renderable.material.getMask() & materialMask)) == materialMask;
                }
        }
        
@@ -138,13 +138,15 @@ public abstract class BaseShader implements Shader {
                                setters.set(i, null);
                        }
                }
-               final VertexAttributes attrs = renderable.mesh.getVertexAttributes();
-               final int c = attrs.size();
-               for (int i = 0; i < c; i++) {
-                       final VertexAttribute attr = attrs.get(i);
-                       final int location = program.getAttributeLocation(attr.alias);
-                       if (location >= 0)
-                               attributes.put(attr.getKey(), location);
+               if (renderable != null) {
+                       final VertexAttributes attrs = renderable.mesh.getVertexAttributes();
+                       final int c = attrs.size();
+                       for (int i = 0; i < c; i++) {
+                               final VertexAttribute attr = attrs.get(i);
+                               final int location = program.getAttributeLocation(attr.alias);
+                               if (location >= 0)
+                                       attributes.put(attr.getKey(), location);
+                       }
                }
        }