use of com.badlogic.gdx.graphics.g3d.Renderable in project libgdx by libgdx.
the class BillboardParticleBatch method allocRenderable.
protected Renderable allocRenderable() {
Renderable renderable = new Renderable();
renderable.meshPart.primitiveType = GL20.GL_TRIANGLES;
renderable.meshPart.offset = 0;
renderable.material = new Material(this.blendingAttribute, this.depthTestAttribute, TextureAttribute.createDiffuse(texture));
renderable.meshPart.mesh = new Mesh(false, MAX_VERTICES_PER_MESH, MAX_PARTICLES_PER_MESH * 6, currentAttributes);
renderable.meshPart.mesh.setIndices(indices);
renderable.shader = shader;
return renderable;
}
use of com.badlogic.gdx.graphics.g3d.Renderable in project libgdx by libgdx.
the class BillboardParticleBatch method setTexture.
public void setTexture(Texture texture) {
renderablePool.freeAll(renderables);
renderables.clear();
for (int i = 0, free = renderablePool.getFree(); i < free; ++i) {
Renderable renderable = renderablePool.obtain();
TextureAttribute attribute = (TextureAttribute) renderable.material.get(TextureAttribute.Diffuse);
attribute.textureDescription.texture = texture;
}
this.texture = texture;
}
use of com.badlogic.gdx.graphics.g3d.Renderable in project libgdx by libgdx.
the class BillboardParticleBatch method allocShader.
private void allocShader() {
Renderable newRenderable = allocRenderable();
shader = newRenderable.shader = getShader(newRenderable);
renderablePool.free(newRenderable);
}
use of com.badlogic.gdx.graphics.g3d.Renderable in project libgdx by libgdx.
the class BillboardParticleBatch method clearRenderablesPool.
private void clearRenderablesPool() {
renderablePool.freeAll(renderables);
for (int i = 0, free = renderablePool.getFree(); i < free; ++i) {
Renderable renderable = renderablePool.obtain();
renderable.meshPart.mesh.dispose();
}
renderables.clear();
}
use of com.badlogic.gdx.graphics.g3d.Renderable in project libgdx by libgdx.
the class MultipleRenderTargetTest method render.
@Override
public void render() {
track += Gdx.graphics.getDeltaTime();
Gdx.gl.glClearColor(0f, 0f, 0f, 1f);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT | GL20.GL_DEPTH_BUFFER_BIT);
cameraController.update(Gdx.graphics.getDeltaTime());
renderContext.begin();
frameBuffer.begin();
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT | GL20.GL_DEPTH_BUFFER_BIT);
renerablePool.flush();
renderables.clear();
modelCache.begin(camera);
modelCache.add(cannon);
modelCache.add(floorInstance);
for (Light light : lights) {
light.update(Gdx.graphics.getDeltaTime());
modelCache.add(light.lightInstance);
}
modelCache.end();
modelCache.getRenderables(renderables, renerablePool);
for (Renderable renderable : renderables) {
renderable.shader = shaderProvider.getShader(renderable);
}
renderableSorter.sort(camera, renderables);
Shader currentShader = null;
for (int i = 0; i < renderables.size; i++) {
final Renderable renderable = renderables.get(i);
if (currentShader != renderable.shader) {
if (currentShader != null)
currentShader.end();
currentShader = renderable.shader;
currentShader.begin(camera, renderContext);
}
currentShader.render(renderable);
}
if (currentShader != null)
currentShader.end();
frameBuffer.end();
mrtSceneShader.begin();
mrtSceneShader.setUniformi("u_diffuseTexture", renderContext.textureBinder.bind(frameBuffer.getColorBufferTexture(DIFFUSE_ATTACHMENT)));
mrtSceneShader.setUniformi("u_normalTexture", renderContext.textureBinder.bind(frameBuffer.getColorBufferTexture(NORMAL_ATTACHMENT)));
mrtSceneShader.setUniformi("u_positionTexture", renderContext.textureBinder.bind(frameBuffer.getColorBufferTexture(POSITION_ATTACHMENT)));
mrtSceneShader.setUniformi("u_depthTexture", renderContext.textureBinder.bind(frameBuffer.getColorBufferTexture(DEPTH_ATTACHMENT)));
for (int i = 0; i < lights.size; i++) {
Light light = lights.get(i);
mrtSceneShader.setUniformf("lights[" + i + "].lightPosition", light.position);
mrtSceneShader.setUniformf("lights[" + i + "].lightColor", light.color);
}
mrtSceneShader.setUniformf("u_viewPos", camera.position);
mrtSceneShader.setUniformMatrix("u_inverseProjectionMatrix", camera.invProjectionView);
quad.render(mrtSceneShader, GL30.GL_TRIANGLE_FAN);
mrtSceneShader.end();
renderContext.end();
batch.disableBlending();
batch.begin();
batch.draw(frameBuffer.getColorBufferTexture(DIFFUSE_ATTACHMENT), 0, 0, Gdx.graphics.getWidth() / 4f, Gdx.graphics.getHeight() / 4f, 0f, 0f, 1f, 1f);
batch.draw(frameBuffer.getColorBufferTexture(NORMAL_ATTACHMENT), Gdx.graphics.getWidth() / 4f, 0, Gdx.graphics.getWidth() / 4f, Gdx.graphics.getHeight() / 4f, 0f, 0f, 1f, 1f);
batch.draw(frameBuffer.getColorBufferTexture(POSITION_ATTACHMENT), 2 * Gdx.graphics.getWidth() / 4f, 0, Gdx.graphics.getWidth() / 4f, Gdx.graphics.getHeight() / 4f, 0f, 0f, 1f, 1f);
batch.draw(frameBuffer.getColorBufferTexture(DEPTH_ATTACHMENT), 3 * Gdx.graphics.getWidth() / 4f, 0, Gdx.graphics.getWidth() / 4f, Gdx.graphics.getHeight() / 4f, 0f, 0f, 1f, 1f);
batch.end();
}
Aggregations