public ShapeRenderer (int maxVertices, ShaderProgram defaultShader) { if (defaultShader == null) { renderer = new ImmediateModeRenderer20(maxVertices, false, true, 0); } else { renderer = new ImmediateModeRenderer20(maxVertices, false, true, 0, defaultShader); } projectionMatrix.setToOrtho2D(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); matrixDirty = true; }
public ImmediateModeRenderer20 (boolean hasNormals, boolean hasColors, int numTexCoords) { this(5000, hasNormals, hasColors, numTexCoords, createDefaultShader(hasNormals, hasColors, numTexCoords)); ownsShader = true; }
/** Returns a new instance of the default shader used by SpriteBatch for GL2 when no shader is specified. */ static public ShaderProgram createDefaultShader (boolean hasNormals, boolean hasColors, int numTexCoords) { String vertexShader = createVertexShader(hasNormals, hasColors, numTexCoords); String fragmentShader = createFragmentShader(hasNormals, hasColors, numTexCoords); ShaderProgram program = new ShaderProgram(vertexShader, fragmentShader); return program; } }
ImmediateModeRenderer20 lineRenderer = new ImmediateModeRenderer20(false, true, 0); float x2, float y2, float z2, float r, float g, float b, float a) { lineRenderer.color(r, g, b, a); lineRenderer.vertex(x1, y1, z1); lineRenderer.color(r, g, b, a); lineRenderer.vertex(x2, y2, z2);
public ImmediateModeRenderer20 (int maxVertices, boolean hasNormals, boolean hasColors, int numTexCoords, ShaderProgram shader) { this.maxVertices = maxVertices; this.numTexCoords = numTexCoords; this.shader = shader; VertexAttribute[] attribs = buildVertexAttributes(hasNormals, hasColors, numTexCoords); mesh = new Mesh(false, maxVertices, 0, attribs); vertices = new float[maxVertices * (mesh.getVertexAttributes().vertexSize / 4)]; vertexSize = mesh.getVertexAttributes().vertexSize / 4; normalOffset = mesh.getVertexAttribute(Usage.Normal) != null ? mesh.getVertexAttribute(Usage.Normal).offset / 4 : 0; colorOffset = mesh.getVertexAttribute(Usage.ColorPacked) != null ? mesh.getVertexAttribute(Usage.ColorPacked).offset / 4 : 0; texCoordOffset = mesh.getVertexAttribute(Usage.TextureCoordinates) != null ? mesh .getVertexAttribute(Usage.TextureCoordinates).offset / 4 : 0; shaderUniformNames = new String[numTexCoords]; for (int i = 0; i < numTexCoords; i++) { shaderUniformNames[i] = "u_sampler" + i; } }
@Override public void render(float delta) { renderer.begin(Engine.getDefaultCamera().combined, GL20.GL_TRIANGLE_STRIP); renderer.color(1, 1, 1, 1); renderer.vertex(0, 0, 0); renderer.color(1, 1, 1, 1); renderer.vertex(400, 0, 0); renderer.color(255 / 255f, 0 / 255f, 0 / 255f, 1); renderer.vertex(0, 400, 0); renderer.color(0 / 255f, 255 / 255f, 0 / 255f, 1); renderer.vertex(400, 400, 0); renderer.end(); }
public ImmediateModeRenderer20 (int maxVertices, boolean hasNormals, boolean hasColors, int numTexCoords, ShaderProgram shader) { this.maxVertices = maxVertices; this.numTexCoords = numTexCoords; this.shader = shader; VertexAttribute[] attribs = buildVertexAttributes(hasNormals, hasColors, numTexCoords); mesh = new Mesh(false, maxVertices, 0, attribs); vertices = new float[maxVertices * (mesh.getVertexAttributes().vertexSize / 4)]; vertexSize = mesh.getVertexAttributes().vertexSize / 4; normalOffset = mesh.getVertexAttribute(Usage.Normal) != null ? mesh.getVertexAttribute(Usage.Normal).offset / 4 : 0; colorOffset = mesh.getVertexAttribute(Usage.ColorPacked) != null ? mesh.getVertexAttribute(Usage.ColorPacked).offset / 4 : 0; texCoordOffset = mesh.getVertexAttribute(Usage.TextureCoordinates) != null ? mesh .getVertexAttribute(Usage.TextureCoordinates).offset / 4 : 0; shaderUniformNames = new String[numTexCoords]; for (int i = 0; i < numTexCoords; i++) { shaderUniformNames[i] = "u_sampler" + i; } }
public void draw(Camera cam) { if (tristrip.size <= 0) return; gl20.begin(cam.combined, GL20.GL_TRIANGLE_STRIP); for (int i = 0; i < tristrip.size; i++) { if (i == batchSize) { gl20.end(); gl20.begin(cam.combined, GL20.GL_TRIANGLE_STRIP); } Vector2 point = tristrip.get(i); Vector2 tc = texcoord.get(i); gl20.color(color.r, color.g, color.b, color.a); gl20.texCoord(tc.x, 0f); gl20.vertex(point.x, point.y, 0f); } gl20.end(); }
public ShapeRenderer (int maxVertices, ShaderProgram defaultShader) { if (defaultShader == null) { renderer = new ImmediateModeRenderer20(maxVertices, false, true, 0); } else { renderer = new ImmediateModeRenderer20(maxVertices, false, true, 0, defaultShader); } projectionMatrix.setToOrtho2D(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); matrixDirty = true; }
/** Returns a new instance of the default shader used by SpriteBatch for GL2 when no shader is specified. */ static public ShaderProgram createDefaultShader (boolean hasNormals, boolean hasColors, int numTexCoords) { String vertexShader = createVertexShader(hasNormals, hasColors, numTexCoords); String fragmentShader = createFragmentShader(hasNormals, hasColors, numTexCoords); ShaderProgram program = new ShaderProgram(vertexShader, fragmentShader); return program; } }
public ImmediateModeRenderer20 (int maxVertices, boolean hasNormals, boolean hasColors, int numTexCoords) { this(maxVertices, hasNormals, hasColors, numTexCoords, createDefaultShader(hasNormals, hasColors, numTexCoords)); ownsShader = true; }
public ImmediateModeRenderer20 (int maxVertices, boolean hasNormals, boolean hasColors, int numTexCoords, ShaderProgram shader) { this.maxVertices = maxVertices; this.numTexCoords = numTexCoords; this.shader = shader; VertexAttribute[] attribs = buildVertexAttributes(hasNormals, hasColors, numTexCoords); mesh = new Mesh(false, maxVertices, 0, attribs); vertices = new float[maxVertices * (mesh.getVertexAttributes().vertexSize / 4)]; vertexSize = mesh.getVertexAttributes().vertexSize / 4; normalOffset = mesh.getVertexAttribute(Usage.Normal) != null ? mesh.getVertexAttribute(Usage.Normal).offset / 4 : 0; colorOffset = mesh.getVertexAttribute(Usage.ColorPacked) != null ? mesh.getVertexAttribute(Usage.ColorPacked).offset / 4 : 0; texCoordOffset = mesh.getVertexAttribute(Usage.TextureCoordinates) != null ? mesh .getVertexAttribute(Usage.TextureCoordinates).offset / 4 : 0; shaderUniformNames = new String[numTexCoords]; for (int i = 0; i < numTexCoords; i++) { shaderUniformNames[i] = "u_sampler" + i; } }
dbg.begin(camPersp.combined, GL20.GL_TRIANGLES); dbg.color(r, g, b, alpha); dbg.vertex(corners[0].x, corners[0].y, corners[0].z + offset); dbg.color(r, g, b, alpha); dbg.vertex(corners[1].x, corners[1].y, corners[1].z + offset); dbg.color(r, g, b, alpha); dbg.vertex(corners[4].x, corners[4].y, corners[4].z); dbg.color(r, g, b, alpha); dbg.vertex(corners[1].x, corners[1].y, corners[1].z + offset); dbg.color(r, g, b, alpha); dbg.vertex(corners[4].x, corners[4].y, corners[4].z); dbg.color(r, g, b, alpha); dbg.vertex(corners[5].x, corners[5].y, corners[5].z); dbg.color(r, g, b, alpha); dbg.vertex(corners[1].x, corners[1].y, corners[1].z + offset); dbg.color(r, g, b, alpha); dbg.vertex(corners[2].x, corners[2].y, corners[2].z + offset); dbg.color(r, g, b, alpha); dbg.vertex(corners[5].x, corners[5].y, corners[5].z); dbg.color(r, g, b, alpha); dbg.vertex(corners[2].x, corners[2].y, corners[2].z + offset); dbg.color(r, g, b, alpha); dbg.vertex(corners[5].x, corners[5].y, corners[5].z); dbg.color(r, g, b, alpha); dbg.vertex(corners[6].x, corners[6].y, corners[6].z);
@Override public void create () { renderer = new ImmediateModeRenderer20(false, true, 1); texture = new Texture(Gdx.files.internal("data/badlogic.jpg")); } }
/** Returns a new instance of the default shader used by SpriteBatch for GL2 when no shader is specified. */ static public ShaderProgram createDefaultShader (boolean hasNormals, boolean hasColors, int numTexCoords) { String vertexShader = createVertexShader(hasNormals, hasColors, numTexCoords); String fragmentShader = createFragmentShader(hasNormals, hasColors, numTexCoords); ShaderProgram program = new ShaderProgram(vertexShader, fragmentShader); return program; } }
public ImmediateModeRenderer20 (boolean hasNormals, boolean hasColors, int numTexCoords) { this(5000, hasNormals, hasColors, numTexCoords, createDefaultShader(hasNormals, hasColors, numTexCoords)); ownsShader = true; }
@Override public void create () { renderer = new ImmediateModeRenderer20(false, false, 0); spriteBatch = new SpriteBatch(); obj = new Sprite(new Texture(Gdx.files.internal("data/badlogicsmall.jpg"))); obj.setSize(40, 40); obj.setOriginCenter(); obj2 = new Sprite(new Texture(Gdx.files.internal("data/bobrgb888-32x32.png"))); obj2.setSize(40, 40); obj2.setOriginCenter(); ZIGZAG_SCALE = Gdx.graphics.getDensity() * 96; // 96DP float w = Gdx.graphics.getWidth() - obj.getWidth(); float h = Gdx.graphics.getHeight() - obj.getHeight(); paths.add(new Bezier<Vector2>(new Vector2(0, 0), new Vector2(w, h))); paths.add(new Bezier<Vector2>(new Vector2(0, 0), new Vector2(0, h), new Vector2(w, h))); paths.add(new Bezier<Vector2>(new Vector2(0, 0), new Vector2(w, 0), new Vector2(0, h), new Vector2(w, h))); Vector2 cp[] = new Vector2[] {new Vector2(0, 0), new Vector2(w * 0.25f, h * 0.5f), new Vector2(0, h), new Vector2(w * 0.5f, h * 0.75f), new Vector2(w, h), new Vector2(w * 0.75f, h * 0.5f), new Vector2(w, 0), new Vector2(w * 0.5f, h * 0.25f)}; paths.add(new BSpline<Vector2>(cp, 3, true)); paths.add(new CatmullRomSpline<Vector2>(cp, true)); pathLength = paths.get(currentPath).approxLength(500); avg_speed = speed * pathLength; Gdx.input.setInputProcessor(this); }
public ImmediateModeRenderer20 (int maxVertices, boolean hasNormals, boolean hasColors, int numTexCoords) { this(maxVertices, hasNormals, hasColors, numTexCoords, createDefaultShader(hasNormals, hasColors, numTexCoords)); ownsShader = true; }
public SwipeTriStrip() { gl20 = new ImmediateModeRenderer20(false, true, 1); }