/** Renders the mesh part using the specified shader, must be called in between {@link ShaderProgram#begin()} and * {@link ShaderProgram#end()}. * @param shader the shader to be used * @param autoBind overrides the autoBind member of the Mesh */ public void render (ShaderProgram shader, boolean autoBind) { mesh.render(shader, primitiveType, offset, size, autoBind); }
/** Renders the mesh part using the specified shader, must be called in between {@link ShaderProgram#begin()} and * {@link ShaderProgram#end()}. * @param shader the shader to be used */ public void render (ShaderProgram shader) { mesh.render(shader, primitiveType, offset, size); } }
/** Renders the mesh part using the specified shader, must be called in between {@link ShaderProgram#begin()} and * {@link ShaderProgram#end()}. * @param shader the shader to be used * @param autoBind overrides the autoBind member of the Mesh */ public void render (ShaderProgram shader, boolean autoBind) { mesh.render(shader, primitiveType, offset, size, autoBind); }
/** Renders the mesh part using the specified shader, must be called in between {@link ShaderProgram#begin()} and * {@link ShaderProgram#end()}. * @param shader the shader to be used */ public void render (ShaderProgram shader) { mesh.render(shader, primitiveType, offset, size); } }
/** Flushes vertices[0,verticesPosition[ to GL verticesPosition % Decal.SIZE must equal 0 * * @param verticesPosition Amount of elements from the vertices array to flush */ protected void flush (ShaderProgram shader, int verticesPosition) { mesh.setVertices(vertices, 0, verticesPosition); mesh.render(shader, GL20.GL_TRIANGLES, 0, verticesPosition / 4); }
/** Flushes vertices[0,verticesPosition[ to GL verticesPosition % Decal.SIZE must equal 0 * * @param verticesPosition Amount of elements from the vertices array to flush */ protected void flush (ShaderProgram shader, int verticesPosition) { mesh.setVertices(vertices, 0, verticesPosition); mesh.render(shader, GL20.GL_TRIANGLES, 0, verticesPosition / 4); }
/** Draws all the images defined for the specified cache ID. */ public void draw (int cacheID) { if (!drawing) throw new IllegalStateException("SpriteCache.begin must be called before draw."); Cache cache = caches.get(cacheID); int verticesPerImage = mesh.getNumIndices() > 0 ? 4 : 6; int offset = cache.offset / (verticesPerImage * VERTEX_SIZE) * 6; Texture[] textures = cache.textures; int[] counts = cache.counts; int textureCount = cache.textureCount; for (int i = 0; i < textureCount; i++) { int count = counts[i]; textures[i].bind(); if (customShader != null) mesh.render(customShader, GL20.GL_TRIANGLES, offset, count); else mesh.render(shader, GL20.GL_TRIANGLES, offset, count); offset += count; } renderCalls += textureCount; totalRenderCalls += textureCount; }
/** Draws all the images defined for the specified cache ID. */ public void draw (int cacheID) { if (!drawing) throw new IllegalStateException("SpriteCache.begin must be called before draw."); Cache cache = caches.get(cacheID); int verticesPerImage = mesh.getNumIndices() > 0 ? 4 : 6; int offset = cache.offset / (verticesPerImage * VERTEX_SIZE) * 6; Texture[] textures = cache.textures; int[] counts = cache.counts; int textureCount = cache.textureCount; for (int i = 0; i < textureCount; i++) { int count = counts[i]; textures[i].bind(); if (customShader != null) mesh.render(customShader, GL20.GL_TRIANGLES, offset, count); else mesh.render(shader, GL20.GL_TRIANGLES, offset, count); offset += count; } renderCalls += textureCount; totalRenderCalls += textureCount; }
/** <p> * Renders the mesh using the given primitive type. If indices are set for this mesh then getNumIndices() / #vertices per * primitive primitives are rendered. If no indices are set then getNumVertices() / #vertices per primitive are rendered. * </p> * * <p> * This method will automatically bind each vertex attribute as specified at construction time via {@link VertexAttributes} to * the respective shader attributes. The binding is based on the alias defined for each VertexAttribute. * </p> * * <p> * This method must only be called after the {@link ShaderProgram#begin()} method has been called! * </p> * * <p> * This method is intended for use with OpenGL ES 2.0 and will throw an IllegalStateException when OpenGL ES 1.x is used. * </p> * * @param primitiveType the primitive type */ public void render (ShaderProgram shader, int primitiveType) { render(shader, primitiveType, 0, indices.getNumMaxIndices() > 0 ? getNumIndices() : getNumVertices(), autoBind); }
public void flush () { if (numVertices == 0) return; shader.begin(); shader.setUniformMatrix("u_projModelView", projModelView); for (int i = 0; i < numTexCoords; i++) shader.setUniformi(shaderUniformNames[i], i); mesh.setVertices(vertices, 0, vertexIdx); mesh.render(shader, primitiveType); shader.end(); numSetTexCoords = 0; vertexIdx = 0; numVertices = 0; }
public void flush () { if (numVertices == 0) return; shader.begin(); shader.setUniformMatrix("u_projModelView", projModelView); for (int i = 0; i < numTexCoords; i++) shader.setUniformi(shaderUniformNames[i], i); mesh.setVertices(vertices, 0, vertexIdx); mesh.render(shader, primitiveType); shader.end(); numSetTexCoords = 0; vertexIdx = 0; numVertices = 0; }
@Override public void render () { Gdx.gl20.glViewport(0, 0, Gdx.graphics.getBackBufferWidth(), Gdx.graphics.getBackBufferHeight()); Gdx.gl20.glClear(GL20.GL_COLOR_BUFFER_BIT); shader.begin(); mesh.render(shader, GL20.GL_TRIANGLES); shader.end(); } }
public void render () { Gdx.gl20.glViewport(0, 0, Gdx.graphics.getBackBufferWidth(), Gdx.graphics.getBackBufferHeight()); Gdx.gl20.glClear(GL20.GL_COLOR_BUFFER_BIT); Gdx.gl20.glActiveTexture(GL20.GL_TEXTURE0); texture.bind(); shader.begin(); shader.setUniformf("s_texture", 0); Gdx.gl20.glTexParameteri(GL20.GL_TEXTURE_2D, GL20.GL_TEXTURE_MIN_FILTER, GL20.GL_NEAREST); shader.setUniformf("u_offset", -0.6f); mesh.render(shader, GL20.GL_TRIANGLES); Gdx.gl20.glTexParameteri(GL20.GL_TEXTURE_2D, GL20.GL_TEXTURE_MIN_FILTER, GL20.GL_LINEAR_MIPMAP_LINEAR); shader.setUniformf("u_offset", 0.6f); mesh.render(shader, GL20.GL_TRIANGLES); shader.end(); } }
@Override public void flush () { if (vertexIndex == 0) return; renderCalls++; totalRenderCalls++; int trianglesInBatch = triangleIndex; if (trianglesInBatch > maxTrianglesInBatch) maxTrianglesInBatch = trianglesInBatch; lastTexture.bind(); Mesh mesh = this.mesh; mesh.setVertices(vertices, 0, vertexIndex); mesh.setIndices(triangles, 0, triangleIndex); if (blendingDisabled) { Gdx.gl.glDisable(GL20.GL_BLEND); } else { Gdx.gl.glEnable(GL20.GL_BLEND); if (blendSrcFunc != -1) Gdx.gl.glBlendFuncSeparate(blendSrcFunc, blendDstFunc, blendSrcFuncAlpha, blendDstFuncAlpha); } mesh.render(customShader != null ? customShader : shader, GL20.GL_TRIANGLES, 0, trianglesInBatch); vertexIndex = 0; triangleIndex = 0; }
private void renderMesh (ShaderProgram shader, Matrix4 cam, Matrix4 projector, Matrix4 model, Mesh mesh, Color color) { position.set(this.projector.position); modelNormal.set(model).toNormalMatrix(); shader.setUniformMatrix("u_camera", cam); shader.setUniformMatrix("u_projector", projector); shader.setUniformf("u_projectorPos", position.x, position.y, position.z); shader.setUniformMatrix("u_model", model); shader.setUniformMatrix("u_modelNormal", modelNormal); shader.setUniformf("u_color", color.r, color.g, color.b); shader.setUniformi("u_texture", 0); mesh.render(shader, GL20.GL_TRIANGLES); }
public void render () { Gdx.gl20.glViewport(0, 0, Gdx.graphics.getBackBufferWidth(), Gdx.graphics.getBackBufferHeight()); Gdx.gl20.glClear(GL20.GL_COLOR_BUFFER_BIT); Gdx.gl20.glActiveTexture(GL20.GL_TEXTURE0); texture.bind(); Gdx.gl20.glActiveTexture(GL20.GL_TEXTURE1); texture2.bind(); shader.begin(); shader.setUniformi("s_texture", 0); shader.setUniformi("s_texture2", 1); mesh.render(shader, GL20.GL_TRIANGLES); shader.end(); }
@Override public void render () { Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT | GL20.GL_DEPTH_BUFFER_BIT); Gdx.gl.glEnable(GL20.GL_DEPTH_TEST); Gdx.gl.glDepthFunc(GL20.GL_LEQUAL); Gdx.gl.glCullFace(GL20.GL_BACK); modelView.translate(10f, 0, 10f).rotate(0, 1f, 0, 2f * Gdx.graphics.getDeltaTime()).translate(-10f, 0, -10f); cameraController.update(); textureArray.bind(); shaderProgram.begin(); shaderProgram.setUniformi("u_textureArray", 0); shaderProgram.setUniformMatrix("u_projViewTrans", camera.combined); shaderProgram.setUniformMatrix("u_modelView", modelView); terrain.render(shaderProgram, GL20.GL_TRIANGLES); shaderProgram.end(); }
@Override public void render () { Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); Gdx.gl.glEnable(GL20.GL_TEXTURE_2D); camera.update(); currTexture = hwMipMap.isChecked() ? textureHW : textureSW; currTexture.bind(); currTexture.setFilter(TextureFilter.valueOf(minFilter.getSelected()), TextureFilter.valueOf(magFilter.getSelected())); shader.begin(); shader.setUniformMatrix("u_projTrans", camera.combined); shader.setUniformi("s_texture", 0); mesh.render(shader, GL20.GL_TRIANGLE_FAN); shader.end(); ui.act(); ui.draw(); }
@Override public void render () { angle += Gdx.graphics.getDeltaTime() * 45; matrix.setToRotation(axis, angle); Mesh meshToDraw = Gdx.input.isButtonPressed(0) ? meshCustomVA : mesh; Gdx.gl20.glViewport(0, 0, Gdx.graphics.getBackBufferWidth(), Gdx.graphics.getBackBufferHeight()); Gdx.gl20.glClearColor(0.2f, 0.2f, 0.2f, 1); Gdx.gl20.glClear(GL20.GL_COLOR_BUFFER_BIT); Gdx.gl20.glEnable(GL20.GL_TEXTURE_2D); Gdx.gl20.glEnable(GL20.GL_BLEND); Gdx.gl20.glBlendFunc(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA); texture.bind(); shader.begin(); shader.setUniformMatrix("u_worldView", matrix); shader.setUniformi("u_texture", 0); meshToDraw.render(shader, GL20.GL_TRIANGLES); shader.end(); }
@Override public void render () { angle += Gdx.graphics.getDeltaTime() * 40.0f; float aspect = Gdx.graphics.getWidth() / (float)Gdx.graphics.getHeight(); projection.setToProjection(1.0f, 20.0f, 60.0f, aspect); view.idt().trn(0, 0, -2.0f); model.setToRotation(axis, angle); combined.set(projection).mul(view).mul(model); Gdx.gl20.glViewport(0, 0, Gdx.graphics.getBackBufferWidth(), Gdx.graphics.getBackBufferHeight()); Gdx.gl20.glClear(GL20.GL_COLOR_BUFFER_BIT); shader.begin(); shader.setUniformMatrix("u_mvpMatrix", combined); mesh.render(shader, GL20.GL_TRIANGLES); shader.end(); Gdx.app.log("angle", "" + angle); } }