protected void bindMaterial (final Renderable renderable) { if (currentMaterial == renderable.material) return; int cullFace = config.defaultCullFace == -1 ? GL20.GL_BACK : config.defaultCullFace; int depthFunc = config.defaultDepthFunc == -1 ? GL20.GL_LEQUAL : config.defaultDepthFunc; float depthRangeNear = 0f; float depthRangeFar = 1f; boolean depthMask = true; currentMaterial = renderable.material; for (final Attribute attr : currentMaterial) { final long t = attr.type; if (BlendingAttribute.is(t)) { context.setBlending(true, ((BlendingAttribute)attr).sourceFunction, ((BlendingAttribute)attr).destFunction); } else if ((t & DepthTestAttribute.Type) == DepthTestAttribute.Type) { DepthTestAttribute dta = (DepthTestAttribute)attr; depthFunc = dta.depthFunc; depthRangeNear = dta.depthRangeNear; depthRangeFar = dta.depthRangeFar; depthMask = dta.depthMask; } else if (!config.ignoreUnimplemented) throw new GdxRuntimeException("Unknown material attribute: " + attr.toString()); } context.setCullFace(cullFace); context.setDepthTest(depthFunc, depthRangeNear, depthRangeFar); context.setDepthMask(depthMask); }
/** Start rendering one or more {@link Renderable}s. Use one of the render() methods to provide the renderables. Must be * followed by a call to {@link #end()}. The OpenGL context must not be altered between {@link #begin(Camera)} and * {@link #end()}. * @param cam The {@link Camera} to be used when rendering and sorting. */ public void begin (final Camera cam) { if (camera != null) throw new GdxRuntimeException("Call end() first."); camera = cam; if (ownContext) context.begin(); }
/** End rendering one or more {@link Renderable}s. Must be called after a call to {@link #begin(Camera)}. This will flush the * batch, causing any renderables provided using one of the render() methods to be rendered. After a call to this method the * OpenGL context can be altered again. */ public void end () { flush(); if (ownContext) context.end(); camera = null; }
@Override public void begin (Camera camera, RenderContext context) { program.begin(); context.setDepthTest(GL20.GL_LEQUAL, 0f, 1f); context.setDepthMask(true); set(u_projTrans, camera.combined); }
@Override public void begin (Camera camera, RenderContext context) { this.context = context; shaderProgram.begin(); shaderProgram.setUniformMatrix("u_projViewTrans", camera.combined); context.setDepthTest(GL20.GL_LEQUAL); context.setCullFace(GL20.GL_BACK); }
@Override public void begin(Camera camera, RenderContext context) { this.context = context; context.begin(); context.setCullFace(GL20.GL_BACK); this.context.setDepthTest(GL20.GL_LEQUAL, 0f, 1f); this.context.setDepthMask(true); program.begin(); set(UNIFORM_PROJ_VIEW_MATRIX, camera.combined); set(UNIFORM_CAM_POS, camera.position); }
@Override public void begin(Camera camera, RenderContext context) { this.context = context; this.context.setCullFace(GL20.GL_BACK); this.context.setDepthTest(GL20.GL_LEQUAL, 0f, 1f); this.context.setDepthMask(true); program.begin(); set(UNIFORM_PROJ_VIEW_MATRIX, camera.combined); }
@Override public void render (Renderable renderable) { set(u_pass, 0f); super.render(renderable); context.setDepthTest(GL20.GL_LESS); if (has(u_pass)) { context.setBlending(true, GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA); for (int i = 1; i < passes; ++i) { set(u_pass, (float)i / (float)passes); renderable.meshPart.render(program, false); } } } }
public void setDepthTest (final int depthFunction) { setDepthTest(depthFunction, 0f, 1f); }
@Override public void render (final Renderable renderable) { if (!renderable.material.has(BlendingAttribute.Type)) context.setBlending(false, GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA); bindMaterial(renderable); super.render(renderable); }
/** Construct a ModelBatch, using this constructor makes you responsible for calling context.begin() and context.end() yourself. * @param context The {@link RenderContext} to use. * @param shaderProvider The {@link ShaderProvider} to use, will be disposed when this ModelBatch is disposed. * @param sorter The {@link RenderableSorter} to use. */ public ModelBatch (final RenderContext context, final ShaderProvider shaderProvider, final RenderableSorter sorter) { this.sorter = (sorter == null) ? new DefaultRenderableSorter() : sorter; this.ownContext = (context == null); this.context = (context == null) ? new RenderContext(new DefaultTextureBinder(DefaultTextureBinder.WEIGHTED, 1)) : context; this.shaderProvider = (shaderProvider == null) ? new DefaultShaderProvider() : shaderProvider; }
@Override public void begin(Camera camera, RenderContext context) { this.context = context; context.begin(); this.context.setCullFace(GL20.GL_BACK); this.context.setDepthTest(GL20.GL_LEQUAL, 0f, 1f); this.context.setDepthMask(true); program.begin(); set(UNIFORM_PROJ_VIEW_MATRIX, camera.combined); set(UNIFORM_CAM_POS, camera.position); }
modelBatchMesh.getRenderContext().setBlending(true, GL30.GL_ONE, GL30.GL_ONE); modelBatchMesh.getRenderContext().setDepthTest(GL30.GL_LEQUAL, 1e11f, 1e13f); ModelBatch modelBatchGrids = new ModelBatch(spgrids, noSorter); ModelBatch modelBatchNormal = new ModelBatch(spnormal, noSorter);
public void setDepthTest (final int depthFunction) { setDepthTest(depthFunction, 0f, 1f); }
@Override public void render (final Renderable renderable) { if (!renderable.material.has(BlendingAttribute.Type)) context.setBlending(false, GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA); bindMaterial(renderable); super.render(renderable); }
/** Construct a ModelBatch, using this constructor makes you responsible for calling context.begin() and context.end() yourself. * @param context The {@link RenderContext} to use. * @param shaderProvider The {@link ShaderProvider} to use, will be disposed when this ModelBatch is disposed. * @param sorter The {@link RenderableSorter} to use. */ public ModelBatch (final RenderContext context, final ShaderProvider shaderProvider, final RenderableSorter sorter) { this.sorter = (sorter == null) ? new DefaultRenderableSorter() : sorter; this.ownContext = (context == null); this.context = (context == null) ? new RenderContext(new DefaultTextureBinder(DefaultTextureBinder.WEIGHTED, 1)) : context; this.shaderProvider = (shaderProvider == null) ? new DefaultShaderProvider() : shaderProvider; }
protected void bindMaterial (final Renderable renderable) { if (currentMaterial == renderable.material) return; int cullFace = config.defaultCullFace == -1 ? GL20.GL_BACK : config.defaultCullFace; int depthFunc = config.defaultDepthFunc == -1 ? GL20.GL_LEQUAL : config.defaultDepthFunc; float depthRangeNear = 0f; float depthRangeFar = 1f; boolean depthMask = true; currentMaterial = renderable.material; for (final Attribute attr : currentMaterial) { final long t = attr.type; if (BlendingAttribute.is(t)) { context.setBlending(true, ((BlendingAttribute)attr).sourceFunction, ((BlendingAttribute)attr).destFunction); } else if ((t & DepthTestAttribute.Type) == DepthTestAttribute.Type) { DepthTestAttribute dta = (DepthTestAttribute)attr; depthFunc = dta.depthFunc; depthRangeNear = dta.depthRangeNear; depthRangeFar = dta.depthRangeFar; depthMask = dta.depthMask; } else if (!config.ignoreUnimplemented) throw new GdxRuntimeException("Unknown material attribute: " + attr.toString()); } context.setCullFace(cullFace); context.setDepthTest(depthFunc, depthRangeNear, depthRangeFar); context.setDepthMask(depthMask); }
public void setDepthTest (final int depthFunction) { setDepthTest(depthFunction, 0f, 1f); }
@Override public void render (Renderable renderable, Attributes combinedAttributes) { if (!combinedAttributes.has(BlendingAttribute.Type)) context.setBlending(false, GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA); bindMaterial(combinedAttributes); if (lighting) bindLights(renderable, combinedAttributes); super.render(renderable, combinedAttributes); }