/** Binds this VertexBufferObject for rendering via glDrawArrays or glDrawElements\r
* \r
* @param shader the shader */\r
+ /** Binds this VertexBufferObject for rendering via glDrawArrays or glDrawElements\r
+ * \r
+ * @param shader the shader */\r
+ @Override\r
public void bind (ShaderProgram shader) {\r
- GL20 gl = Gdx.gl20;\r
+ bind(shader, null);\r
+ }\r
+ \r
+ @Override\r
+ public void bind (ShaderProgram shader, int[] locations) {\r
+ final GL20 gl = Gdx.gl20;\r
\r
gl.glBindBuffer(GL20.GL_ARRAY_BUFFER, bufferHandle);\r
if (isDirty) {\r
isDirty = false;\r
}\r
\r
- int numAttributes = attributes.size();\r
- for (int i = 0; i < numAttributes; i++) {\r
- VertexAttribute attribute = attributes.get(i);\r
- shader.enableVertexAttribute(attribute.alias);\r
- int colorType = GL20.GL_FLOAT;\r
- boolean normalize = false;\r
- if (attribute.usage == Usage.ColorPacked) {\r
- colorType = GL20.GL_UNSIGNED_BYTE;\r
- normalize = true;\r
+ final int numAttributes = attributes.size();\r
+ if (locations == null) {\r
+ for (int i = 0; i < numAttributes; i++) {\r
+ final VertexAttribute attribute = attributes.get(i);\r
+ final int location = shader.getAttributeLocation(attribute.alias);\r
+ if (location < 0)\r
+ continue;\r
+ shader.enableVertexAttribute(location);\r
+ \r
+ if (attribute.usage == Usage.ColorPacked)\r
+ shader.setVertexAttribute(location, attribute.numComponents, GL20.GL_UNSIGNED_BYTE, true, attributes.vertexSize,\r
+ attribute.offset);\r
+ else\r
+ shader.setVertexAttribute(location, attribute.numComponents, GL20.GL_FLOAT, false, attributes.vertexSize,\r
+ attribute.offset);\r
+ }\r
+ } else {\r
+ for (int i = 0; i < numAttributes; i++) {\r
+ final VertexAttribute attribute = attributes.get(i);\r
+ final int location = locations[i];\r
+ if (location < 0)\r
+ continue;\r
+ shader.enableVertexAttribute(location);\r
+ \r
+ if (attribute.usage == Usage.ColorPacked)\r
+ shader.setVertexAttribute(location, attribute.numComponents, GL20.GL_UNSIGNED_BYTE, true, attributes.vertexSize,\r
+ attribute.offset);\r
+ else\r
+ shader.setVertexAttribute(location, attribute.numComponents, GL20.GL_FLOAT, false, attributes.vertexSize,\r
+ attribute.offset);\r
}\r
- shader.setVertexAttribute(attribute.alias, attribute.numComponents, colorType, normalize, attributes.vertexSize,\r
- attribute.offset);\r
}\r
isBound = true;\r
}\r
gl.glBindBuffer(GL11.GL_ARRAY_BUFFER, 0);\r
isBound = false;\r
}\r
-\r
+ \r
/** Unbinds this VertexBufferObject.\r
* \r
* @param shader the shader */\r
- public void unbind (ShaderProgram shader) {\r
- GL20 gl = Gdx.gl20;\r
- int numAttributes = attributes.size();\r
- for (int i = 0; i < numAttributes; i++) {\r
- VertexAttribute attribute = attributes.get(i);\r
- shader.disableVertexAttribute(attribute.alias);\r
+ @Override\r
+ public void unbind (final ShaderProgram shader) {\r
+ unbind(shader, null);\r
+ }\r
+ \r
+ @Override\r
+ public void unbind (final ShaderProgram shader, final int[] locations) {\r
+ final GL20 gl = Gdx.gl20;\r
+ final int numAttributes = attributes.size();\r
+ if (locations == null) {\r
+ for (int i = 0; i < numAttributes; i++) {\r
+ shader.disableVertexAttribute(attributes.get(i).alias);\r
+ }\r
+ } else {\r
+ for (int i = 0; i < numAttributes; i++) {\r
+ final int location = locations[i];\r
+ if (location >= 0)\r
+ shader.disableVertexAttribute(location);\r
+ }\r
}\r
gl.glBindBuffer(GL20.GL_ARRAY_BUFFER, 0);\r
isBound = false;\r
import com.badlogic.gdx.math.collision.BoundingBox;\r
import com.badlogic.gdx.utils.Disposable;\r
import com.badlogic.gdx.utils.GdxRuntimeException;\r
-import com.badlogic.gdx.utils.IntIntMap;\r
\r
/** <p>\r
* A Mesh holds vertices composed of attributes specified by a {@link VertexAttributes} instance. The vertices are held either in\r
* ES 2.0 and when auto-bind is disabled.\r
* \r
* @param shader the shader (does not bind the shader) \r
- * @param locations map containing the attribute locations. */\r
- public void bind (final ShaderProgram shader, final IntIntMap locations) {\r
+ * @param locations array containing the attribute locations. */\r
+ public void bind (final ShaderProgram shader, final int[] locations) {\r
if (!Gdx.graphics.isGL20Available()) throw new IllegalStateException("can't use this render method with OpenGL ES 1.x");\r
\r
vertices.bind(shader, locations);\r
* ES 1.x and when auto-bind is disabled.\r
* \r
* @param shader the shader (does not unbind the shader)\r
- * @param locations map containing the attribute locations. */\r
- public void unbind (final ShaderProgram shader, final IntIntMap locations) {\r
+ * @param locations array containing the attribute locations. */\r
+ public void unbind (final ShaderProgram shader, final int[] locations) {\r
if (!Gdx.graphics.isGL20Available()) {\r
throw new IllegalStateException("can't use this render method with OpenGL ES 1.x");\r
}\r
import com.badlogic.gdx.graphics.VertexAttributes;\r
import com.badlogic.gdx.graphics.VertexAttributes.Usage;\r
import com.badlogic.gdx.utils.BufferUtils;\r
-import com.badlogic.gdx.utils.IntIntMap;\r
\r
/** <p>\r
* Convenience class for working with OpenGL vertex arrays. It interleaves all data in the order you specified in the constructor\r
}\r
\r
@Override\r
- public void bind (final ShaderProgram shader, final IntIntMap locations) {\r
+ public void bind (final ShaderProgram shader, final int[] locations) {\r
final GL20 gl = Gdx.gl20;\r
final int numAttributes = attributes.size();\r
byteBuffer.limit(buffer.limit() * 4);\r
} else {\r
for (int i = 0; i < numAttributes; i++) {\r
final VertexAttribute attribute = attributes.get(i);\r
- final int location = locations.get(attribute.getKey(), -1);\r
+ final int location = locations[i];\r
if (location < 0)\r
continue;\r
shader.enableVertexAttribute(location);\r
}\r
\r
@Override\r
- public void unbind (ShaderProgram shader, IntIntMap locations) {\r
+ public void unbind (ShaderProgram shader, int[] locations) {\r
final GL20 gl = Gdx.gl20;\r
final int numAttributes = attributes.size();\r
if (locations == null) {\r
}\r
} else {\r
for (int i = 0; i < numAttributes; i++) {\r
- final int location = locations.get(attributes.get(i).getKey(), -1);\r
+ final int location = locations[i];\r
if (location >= 0)\r
shader.disableVertexAttribute(location);\r
}\r
import com.badlogic.gdx.graphics.VertexAttributes;\r
import com.badlogic.gdx.graphics.VertexAttributes.Usage;\r
import com.badlogic.gdx.utils.BufferUtils;\r
-import com.badlogic.gdx.utils.IntIntMap;\r
\r
/** <p>\r
* A {@link VertexData} implementation based on OpenGL vertex buffer objects.\r
/** Binds this VertexBufferObject for rendering via glDrawArrays or glDrawElements\r
* \r
* @param shader the shader */\r
+ @Override\r
public void bind (ShaderProgram shader) {\r
bind(shader, null);\r
}\r
\r
- public void bind (ShaderProgram shader, IntIntMap locations) {\r
+ @Override\r
+ public void bind (ShaderProgram shader, int[] locations) {\r
final GL20 gl = Gdx.gl20;\r
\r
gl.glBindBuffer(GL20.GL_ARRAY_BUFFER, bufferHandle);\r
} else {\r
for (int i = 0; i < numAttributes; i++) {\r
final VertexAttribute attribute = attributes.get(i);\r
- final int location = locations.get(attribute.getKey(), -1);\r
+ final int location = locations[i];\r
if (location < 0)\r
continue;\r
shader.enableVertexAttribute(location);\r
isBound = true;\r
}\r
\r
- /** {@inheritDoc} */\r
@Override\r
public void unbind () {\r
GL11 gl = Gdx.gl11;\r
}\r
\r
@Override\r
- public void unbind (final ShaderProgram shader, final IntIntMap locations) {\r
+ public void unbind (final ShaderProgram shader, final int[] locations) {\r
final GL20 gl = Gdx.gl20;\r
final int numAttributes = attributes.size();\r
if (locations == null) {\r
}\r
} else {\r
for (int i = 0; i < numAttributes; i++) {\r
- final int location = locations.get(attributes.get(i).getKey(), -1);\r
+ final int location = locations[i];\r
if (location >= 0)\r
shader.disableVertexAttribute(location);\r
}\r
import com.badlogic.gdx.graphics.VertexAttributes.Usage;\r
import com.badlogic.gdx.utils.BufferUtils;\r
import com.badlogic.gdx.utils.GdxRuntimeException;\r
-import com.badlogic.gdx.utils.IntIntMap;\r
\r
/** <p>\r
* A {@link VertexData} implementation based on OpenGL vertex buffer objects.\r
}\r
\r
@Override\r
- public void bind (final ShaderProgram shader, final IntIntMap locations) {\r
+ public void bind (final ShaderProgram shader, final int[] locations) {\r
final GL20 gl = Gdx.gl20;\r
\r
gl.glBindBuffer(GL20.GL_ARRAY_BUFFER, bufferHandle);\r
} else {\r
for (int i = 0; i < numAttributes; i++) {\r
final VertexAttribute attribute = attributes.get(i);\r
- final int location = locations.get(attribute.getKey(), -1);\r
+ final int location = locations[i];\r
if (location < 0)\r
continue;\r
shader.enableVertexAttribute(location);\r
}\r
\r
@Override\r
- public void unbind (final ShaderProgram shader, final IntIntMap locations) {\r
+ public void unbind (final ShaderProgram shader, final int[] locations) {\r
final GL20 gl = Gdx.gl20;\r
final int numAttributes = attributes.size();\r
if (locations == null) {\r
}\r
} else {\r
for (int i = 0; i < numAttributes; i++) {\r
- final int location = locations.get(attributes.get(i).getKey(), -1);\r
+ final int location = locations[i];\r
if (location >= 0)\r
shader.disableVertexAttribute(location);\r
}\r
public void bind (ShaderProgram shader);\r
\r
/** Binds this VertexData for rendering via glDrawArrays or glDrawElements.\r
- * @param locations map containing the attribute locations. */\r
- public void bind (ShaderProgram shader, IntIntMap locations);\r
+ * @param locations array containing the attribute locations. */\r
+ public void bind (ShaderProgram shader, int[] locations);\r
\r
/** Unbinds this VertexData. */\r
public void unbind (ShaderProgram shader);\r
\r
/** Unbinds this VertexData. \r
- * @param locations map containing the attribute locations. */\r
- public void unbind (ShaderProgram shader, IntIntMap locations);\r
+ * @param locations array containing the attribute locations. */\r
+ public void unbind (ShaderProgram shader, int[] locations);\r
\r
/** Disposes this VertexData and all its associated OpenGL resources. */\r
public void dispose ();\r