@Override public boolean canRender (Renderable renderable) { final Attributes attributes = combineAttributes(renderable); if (attributes.has(BlendingAttribute.Type)) { if ((attributesMask & BlendingAttribute.Type) != BlendingAttribute.Type) return false; if (attributes.has(TextureAttribute.Diffuse) != ((attributesMask & TextureAttribute.Diffuse) == TextureAttribute.Diffuse)) return false; } final boolean skinned = ((renderable.meshPart.mesh.getVertexAttributes().getMask() & Usage.BoneWeight) == Usage.BoneWeight); if (skinned != (numBones > 0)) return false; if (!skinned) return true; int w = 0; final int n = renderable.meshPart.mesh.getVertexAttributes().size(); for (int i = 0; i < n; i++) { final VertexAttribute attr = renderable.meshPart.mesh.getVertexAttributes().get(i); if (attr.usage == Usage.BoneWeight) w |= (1 << attr.unit); } return w == weights; }
@Override public boolean canRender (Renderable renderable) { final Attributes attributes = combineAttributes(renderable); if (attributes.has(BlendingAttribute.Type)) { if ((attributesMask & BlendingAttribute.Type) != BlendingAttribute.Type) return false; if (attributes.has(TextureAttribute.Diffuse) != ((attributesMask & TextureAttribute.Diffuse) == TextureAttribute.Diffuse)) return false; } final boolean skinned = ((renderable.meshPart.mesh.getVertexAttributes().getMask() & Usage.BoneWeight) == Usage.BoneWeight); if (skinned != (numBones > 0)) return false; if (!skinned) return true; int w = 0; final int n = renderable.meshPart.mesh.getVertexAttributes().size(); for (int i = 0; i < n; i++) { final VertexAttribute attr = renderable.meshPart.mesh.getVertexAttributes().get(i); if (attr.usage == Usage.BoneWeight) w |= (1 << attr.unit); } return w == weights; }
/** Returns the first {@link VertexAttribute} having the given {@link Usage}. * * @param usage the Usage. * @return the VertexAttribute or null if no attribute with that usage was found. */ public VertexAttribute getVertexAttribute (int usage) { VertexAttributes attributes = vertices.getAttributes(); int len = attributes.size(); for (int i = 0; i < len; i++) if (attributes.get(i).usage == usage) return attributes.get(i); return null; }
/** Returns the first {@link VertexAttribute} having the given {@link Usage}. * * @param usage the Usage. * @return the VertexAttribute or null if no attribute with that usage was found. */ public VertexAttribute getVertexAttribute (int usage) { VertexAttributes attributes = vertices.getAttributes(); int len = attributes.size(); for (int i = 0; i < len; i++) if (attributes.get(i).usage == usage) return attributes.get(i); return null; }
@Override public void unbind (ShaderProgram shader, int[] locations) { final int numAttributes = attributes.size(); if (locations == null) { for (int i = 0; i < numAttributes; i++) { shader.disableVertexAttribute(attributes.get(i).alias); } } else { for (int i = 0; i < numAttributes; i++) { final int location = locations[i]; if (location >= 0) shader.disableVertexAttribute(location); } } isBound = false; }
@Override public void unbind (ShaderProgram shader, int[] locations) { final int numAttributes = attributes.size(); if (locations == null) { for (int i = 0; i < numAttributes; i++) { shader.disableVertexAttribute(attributes.get(i).alias); } } else { for (int i = 0; i < numAttributes; i++) { final int location = locations[i]; if (location >= 0) shader.disableVertexAttribute(location); } } isBound = false; }
@Override public void unbind (final ShaderProgram shader, final int[] locations) { final GL20 gl = Gdx.gl20; final int numAttributes = attributes.size(); if (locations == null) { for (int i = 0; i < numAttributes; i++) { shader.disableVertexAttribute(attributes.get(i).alias); } } else { for (int i = 0; i < numAttributes; i++) { final int location = locations[i]; if (location >= 0) shader.disableVertexAttribute(location); } } gl.glBindBuffer(GL20.GL_ARRAY_BUFFER, 0); isBound = false; }
@Override public void unbind (final ShaderProgram shader, final int[] locations) { final GL20 gl = Gdx.gl20; final int numAttributes = attributes.size(); if (locations == null) { for (int i = 0; i < numAttributes; i++) { shader.disableVertexAttribute(attributes.get(i).alias); } } else { for (int i = 0; i < numAttributes; i++) { final int location = locations[i]; if (location >= 0) shader.disableVertexAttribute(location); } } gl.glBindBuffer(GL20.GL_ARRAY_BUFFER, 0); isBound = false; }
@Override public void unbind (final ShaderProgram shader, final int[] locations) { final GL20 gl = Gdx.gl20; final int numAttributes = attributes.size(); if (locations == null) { for (int i = 0; i < numAttributes; i++) { shader.disableVertexAttribute(attributes.get(i).alias); } } else { for (int i = 0; i < numAttributes; i++) { final int location = locations[i]; if (location >= 0) shader.disableVertexAttribute(location); } } gl.glBindBuffer(GL20.GL_ARRAY_BUFFER, 0); isBound = false; }
@Override public void unbind (final ShaderProgram shader, final int[] locations) { final GL20 gl = Gdx.gl20; final int numAttributes = attributes.size(); if (locations == null) { for (int i = 0; i < numAttributes; i++) { shader.disableVertexAttribute(attributes.get(i).alias); } } else { for (int i = 0; i < numAttributes; i++) { final int location = locations[i]; if (location >= 0) shader.disableVertexAttribute(location); } } gl.glBindBuffer(GL20.GL_ARRAY_BUFFER, 0); isBound = false; }
private void bindAttributes(ShaderProgram shader, int[] locations) { final GL20 gl = Gdx.gl20; gl.glBindBuffer(GL20.GL_ARRAY_BUFFER, bufferHandle); final int numAttributes = attributes.size(); if (locations == null) { for (int i = 0; i < numAttributes; i++) { final VertexAttribute attribute = attributes.get(i); final int location = shader.getAttributeLocation(attribute.alias); if (location < 0) continue; shader.enableVertexAttribute(location); shader.setVertexAttribute(location, attribute.numComponents, attribute.type, attribute.normalized, attributes.vertexSize, attribute.offset); } } else { for (int i = 0; i < numAttributes; i++) { final VertexAttribute attribute = attributes.get(i); final int location = locations[i]; if (location < 0) continue; shader.enableVertexAttribute(location); shader.setVertexAttribute(location, attribute.numComponents, attribute.type, attribute.normalized, attributes.vertexSize, attribute.offset); } } }
public DepthShader (final Renderable renderable, final Config config, final ShaderProgram shaderProgram) { super(renderable, config, shaderProgram); final Attributes attributes = combineAttributes(renderable); this.numBones = renderable.bones == null ? 0 : config.numBones; int w = 0; final int n = renderable.meshPart.mesh.getVertexAttributes().size(); for (int i = 0; i < n; i++) { final VertexAttribute attr = renderable.meshPart.mesh.getVertexAttributes().get(i); if (attr.usage == Usage.BoneWeight) w |= (1 << attr.unit); } weights = w; alphaTestAttribute = new FloatAttribute(FloatAttribute.AlphaTest, config.defaultAlphaTest); }
if (locations == null) { for (int i = 0; i < numAttributes; i++) { final VertexAttribute attribute = attributes.get(i); final int location = shader.getAttributeLocation(attribute.alias); if (location < 0) continue; final VertexAttribute attribute = attributes.get(i); final int location = locations[i]; if (location < 0) continue;
if (locations == null) { for (int i = 0; i < numAttributes; i++) { final VertexAttribute attribute = attributes.get(i); final int location = shader.getAttributeLocation(attribute.alias); if (location < 0) continue; final VertexAttribute attribute = attributes.get(i); final int location = locations[i]; if (location < 0) continue;
if (locations == null) { for (int i = 0; i < numAttributes; i++) { final VertexAttribute attribute = attributes.get(i); final int location = shader.getAttributeLocation(attribute.alias); if (location < 0) continue; final VertexAttribute attribute = attributes.get(i); final int location = locations[i]; if (location < 0) continue;
public DepthShader (final Renderable renderable, final Config config, final ShaderProgram shaderProgram) { super(renderable, config, shaderProgram); final Attributes attributes = combineAttributes(renderable); this.numBones = renderable.bones == null ? 0 : config.numBones; int w = 0; final int n = renderable.meshPart.mesh.getVertexAttributes().size(); for (int i = 0; i < n; i++) { final VertexAttribute attr = renderable.meshPart.mesh.getVertexAttributes().get(i); if (attr.usage == Usage.BoneWeight) w |= (1 << attr.unit); } weights = w; alphaTestAttribute = new FloatAttribute(FloatAttribute.AlphaTest, config.defaultAlphaTest); }
private final int[] getAttributeLocations (final VertexAttributes attrs) { tempArray.clear(); final int n = attrs.size(); for (int i = 0; i < n; i++) { tempArray.add(attributes.get(attrs.get(i).getKey(), -1)); } tempArray.shrink(); return tempArray.items; }
private final int[] getAttributeLocations (final VertexAttributes attrs) { tempArray.clear(); final int n = attrs.size(); for (int i = 0; i < n; i++) { tempArray.add(attributes.get(attrs.get(i).getKey(), -1)); } tempArray.shrink(); return tempArray.items; }