/** @return A copy of this VertexAttribute with the same parameters. The {@link #offset} is not copied and must * be recalculated, as is typically done by the {@linkplain VertexAttributes} that owns the VertexAttribute. */ public VertexAttribute copy (){ return new VertexAttribute(usage, numComponents, type, normalized, alias, unit); }
/** @return A copy of this VertexAttribute with the same parameters. The {@link #offset} is not copied and must * be recalculated, as is typically done by the {@linkplain VertexAttributes} that owns the VertexAttribute. */ public VertexAttribute copy (){ return new VertexAttribute(usage, numComponents, type, normalized, alias, unit); }
public static VertexAttribute Tangent () { return new VertexAttribute(Usage.Tangent, 3, ShaderProgram.TANGENT_ATTRIBUTE); }
public static VertexAttribute Position () { return new VertexAttribute(Usage.Position, 3, ShaderProgram.POSITION_ATTRIBUTE); }
public static VertexAttribute ColorUnpacked () { return new VertexAttribute(Usage.ColorUnpacked, 4, GL20.GL_FLOAT, false, ShaderProgram.COLOR_ATTRIBUTE); }
public static VertexAttribute BoneWeight (int unit) { return new VertexAttribute(Usage.BoneWeight, 2, ShaderProgram.BONEWEIGHT_ATTRIBUTE + unit, unit); }
public static VertexAttribute TexCoords (int unit) { return new VertexAttribute(Usage.TextureCoordinates, 2, ShaderProgram.TEXCOORD_ATTRIBUTE + unit, unit); }
public static VertexAttribute Binormal () { return new VertexAttribute(Usage.BiNormal, 3, ShaderProgram.BINORMAL_ATTRIBUTE); }
public static VertexAttribute Normal () { return new VertexAttribute(Usage.Normal, 3, ShaderProgram.NORMAL_ATTRIBUTE); }
public static VertexAttribute Position () { return new VertexAttribute(Usage.Position, 3, ShaderProgram.POSITION_ATTRIBUTE); }
public static VertexAttribute Normal () { return new VertexAttribute(Usage.Normal, 3, ShaderProgram.NORMAL_ATTRIBUTE); }
public static VertexAttribute TexCoords (int unit) { return new VertexAttribute(Usage.TextureCoordinates, 2, ShaderProgram.TEXCOORD_ATTRIBUTE + unit, unit); }
public static VertexAttribute ColorPacked () { return new VertexAttribute(Usage.ColorPacked, 4, GL20.GL_UNSIGNED_BYTE, true, ShaderProgram.COLOR_ATTRIBUTE); }
/** Create a ShapeCache with default values */ public ShapeCache () { this(5000, 5000, new VertexAttributes(new VertexAttribute(Usage.Position, 3, "a_position"), new VertexAttribute( Usage.ColorPacked, 4, "a_color")), GL20.GL_LINES); }
/** Create a ShapeCache with default values */ public ShapeCache () { this(5000, 5000, new VertexAttributes(new VertexAttribute(Usage.Position, 3, "a_position"), new VertexAttribute( Usage.ColorPacked, 4, "a_color")), GL20.GL_LINES); }
private void createQuad () { if (quad != null) return; quad = new Mesh(true, 4, 6, new VertexAttribute(Usage.Position, 3, "a_position"), new VertexAttribute(Usage.ColorUnpacked, 4, "a_color"), new VertexAttribute(Usage.TextureCoordinates, 2, "a_texCoords")); quad.setVertices(new float[] {-1, -1, 0, 1, 1, 1, 1, 0, 1, 1, -1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, -1, 1, 0, 1, 1, 1, 1, 0, 0}); quad.setIndices(new short[] {0, 1, 2, 2, 3, 0}); }
@Override public void create () { String vertexShader = "attribute vec4 vPosition; \n" + "void main() \n" + "{ \n" + " gl_Position = vPosition; \n" + "} \n"; String fragmentShader = "#ifdef GL_ES\n" + "precision mediump float;\n" + "#endif\n" + "void main() \n" + "{ \n" + " gl_FragColor = vec4 ( 1.0, 1.0, 1.0, 1.0 );\n" + "}"; shader = new ShaderProgram(vertexShader, fragmentShader); mesh = new Mesh(true, 3, 0, new VertexAttribute(Usage.Position, 3, "vPosition")); float[] vertices = {0.0f, 0.5f, 0.0f, -0.5f, -0.5f, 0.0f, 0.5f, -0.5f, 0.0f}; mesh.setVertices(vertices); }
private VertexAttribute[] buildVertexAttributes (boolean hasNormals, boolean hasColor, int numTexCoords) { Array<VertexAttribute> attribs = new Array<VertexAttribute>(); attribs.add(new VertexAttribute(Usage.Position, 3, ShaderProgram.POSITION_ATTRIBUTE)); if (hasNormals) attribs.add(new VertexAttribute(Usage.Normal, 3, ShaderProgram.NORMAL_ATTRIBUTE)); if (hasColor) attribs.add(new VertexAttribute(Usage.ColorPacked, 4, ShaderProgram.COLOR_ATTRIBUTE)); for (int i = 0; i < numTexCoords; i++) { attribs.add(new VertexAttribute(Usage.TextureCoordinates, 2, ShaderProgram.TEXCOORD_ATTRIBUTE + i)); } VertexAttribute[] array = new VertexAttribute[attribs.size]; for (int i = 0; i < attribs.size; i++) array[i] = attribs.get(i); return array; }
private VertexAttribute[] buildVertexAttributes (boolean hasNormals, boolean hasColor, int numTexCoords) { Array<VertexAttribute> attribs = new Array<VertexAttribute>(); attribs.add(new VertexAttribute(Usage.Position, 3, ShaderProgram.POSITION_ATTRIBUTE)); if (hasNormals) attribs.add(new VertexAttribute(Usage.Normal, 3, ShaderProgram.NORMAL_ATTRIBUTE)); if (hasColor) attribs.add(new VertexAttribute(Usage.ColorPacked, 4, ShaderProgram.COLOR_ATTRIBUTE)); for (int i = 0; i < numTexCoords; i++) { attribs.add(new VertexAttribute(Usage.TextureCoordinates, 2, ShaderProgram.TEXCOORD_ATTRIBUTE + i)); } VertexAttribute[] array = new VertexAttribute[attribs.size]; for (int i = 0; i < attribs.size; i++) array[i] = attribs.get(i); return array; }
private void createScreenQuad () { if (screenQuad != null) return; screenQuad = new Mesh(true, 4, 6, new VertexAttribute(Usage.Position, 3, "a_position"), new VertexAttribute(Usage.ColorUnpacked, 4, "a_color"), new VertexAttribute(Usage.TextureCoordinates, 2, "a_texCoords")); Vector3 vec0 = new Vector3(0, 0, 0); screenCamera.unproject(vec0); Vector3 vec1 = new Vector3(Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), 0); screenCamera.unproject(vec1); screenQuad.setVertices(new float[] {vec0.x, vec0.y, 0, 1, 1, 1, 1, 0, 1, vec1.x, vec0.y, 0, 1, 1, 1, 1, 1, 1, vec1.x, vec1.y, 0, 1, 1, 1, 1, 1, 0, vec0.x, vec1.y, 0, 1, 1, 1, 1, 0, 0}); screenQuad.setIndices(new short[] {0, 1, 2, 2, 3, 0}); } }