/** Binds the underlying {@link VertexBufferObject} and {@link IndexBufferObject} if indices where given. Use this with OpenGL * ES 2.0 and when auto-bind is disabled. * * @param shader the shader (does not bind the shader) * @param locations array containing the attribute locations. */ public void bind (final ShaderProgram shader, final int[] locations) { vertices.bind(shader, locations); if (indices.getNumIndices() > 0) indices.bind(); }
/** Unbinds the underlying {@link VertexBufferObject} and {@link IndexBufferObject} is indices were given. Use this with OpenGL * ES 1.x and when auto-bind is disabled. * * @param shader the shader (does not unbind the shader) * @param locations array containing the attribute locations. */ public void unbind (final ShaderProgram shader, final int[] locations) { vertices.unbind(shader, locations); if (indices.getNumIndices() > 0) indices.unbind(); }
@Override public void resume () { vbo.invalidate(); ibo.invalidate(); }
/** Draws a line using {@link ShapeType#Line} or {@link ShapeType#Filled}. The line is drawn with two colors interpolated * between the start and end points. */ public void line (float x, float y, float z, float x2, float y2, float z2, Color c1, Color c2) { if (shapeType == ShapeType.Filled) { rectLine(x, y, x2, y2, defaultRectLineWidth, c1, c2); return; } check(ShapeType.Line, null, 2); renderer.color(c1.r, c1.g, c1.b, c1.a); renderer.vertex(x, y, z); renderer.color(c2.r, c2.g, c2.b, c2.a); renderer.vertex(x2, y2, z2); }
/** 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; } }
/** Creates a new FrameBuffer with a float backing texture, having the given dimensions and potentially a depth buffer attached. * * @param width the width of the framebuffer in pixels * @param height the height of the framebuffer in pixels * @param hasDepth whether to attach a depth buffer * @throws GdxRuntimeException in case the FrameBuffer could not be created */ public FloatFrameBuffer (int width, int height, boolean hasDepth) { FloatFrameBufferBuilder bufferBuilder = new FloatFrameBufferBuilder(width, height); bufferBuilder.addFloatAttachment(GL30.GL_RGBA32F, GL30.GL_RGBA, GL30.GL_FLOAT, false); if (hasDepth) bufferBuilder.addBasicDepthRenderBuffer(); this.bufferBuilder = bufferBuilder; build(); }
private VertexData makeVertexBuffer (boolean isStatic, int maxVertices, VertexAttributes vertexAttributes) { if (Gdx.gl30 != null) { return new VertexBufferObjectWithVAO(isStatic, maxVertices, vertexAttributes); } else { return new VertexBufferObject(isStatic, maxVertices, vertexAttributes); } }
/** Binds the frame buffer and sets the viewport accordingly, so everything gets drawn to it. */ public void begin () { bind(); setFrameBufferViewport(); }
/** * Unbinds this VertexBufferObject. * * @param shader the shader */ @Override public void unbind (final ShaderProgram shader) { unbind(shader, null); }
@Override public FloatFrameBuffer build () { return new FloatFrameBuffer(this); } }
/** See {@link GLFrameBuffer#unbind()} */ public static void unbind () { GLFrameBuffer.unbind(); } }
/** Draws a line using {@link ShapeType#Line} or {@link ShapeType#Filled}. The line is drawn with two colors interpolated * between the start and end points. */ public void line (float x, float y, float z, float x2, float y2, float z2, Color c1, Color c2) { if (shapeType == ShapeType.Filled) { rectLine(x, y, x2, y2, defaultRectLineWidth, c1, c2); return; } check(ShapeType.Line, null, 2); renderer.color(c1.r, c1.g, c1.b, c1.a); renderer.vertex(x, y, z); renderer.color(c2.r, c2.g, c2.b, c2.a); renderer.vertex(x2, y2, z2); }
/** 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; } }
/** Creates a new FrameBuffer with a float backing texture, having the given dimensions and potentially a depth buffer attached. * * @param width the width of the framebuffer in pixels * @param height the height of the framebuffer in pixels * @param hasDepth whether to attach a depth buffer * @throws GdxRuntimeException in case the FrameBuffer could not be created */ public FloatFrameBuffer (int width, int height, boolean hasDepth) { FloatFrameBufferBuilder bufferBuilder = new FloatFrameBufferBuilder(width, height); bufferBuilder.addFloatAttachment(GL30.GL_RGBA32F, GL30.GL_RGBA, GL30.GL_FLOAT, false); if (hasDepth) bufferBuilder.addBasicDepthRenderBuffer(); this.bufferBuilder = bufferBuilder; build(); }
/** Binds the underlying {@link VertexBufferObject} and {@link IndexBufferObject} if indices where given. Use this with OpenGL * ES 2.0 and when auto-bind is disabled. * * @param shader the shader (does not bind the shader) * @param locations array containing the attribute locations. */ public void bind (final ShaderProgram shader, final int[] locations) { vertices.bind(shader, locations); if (indices.getNumIndices() > 0) indices.bind(); }
/** Unbinds the underlying {@link VertexBufferObject} and {@link IndexBufferObject} is indices were given. Use this with OpenGL * ES 1.x and when auto-bind is disabled. * * @param shader the shader (does not unbind the shader) * @param locations array containing the attribute locations. */ public void unbind (final ShaderProgram shader, final int[] locations) { vertices.unbind(shader, locations); if (indices.getNumIndices() > 0) indices.unbind(); }
private VertexData makeVertexBuffer (boolean isStatic, int maxVertices, VertexAttributes vertexAttributes) { if (Gdx.gl30 != null) { return new VertexBufferObjectWithVAO(isStatic, maxVertices, vertexAttributes); } else { return new VertexBufferObject(isStatic, maxVertices, vertexAttributes); } }