/** * <code>setShadeMode</code> sets the current shading mode. * * @param shadeMode * the new shading mode. * @throws IllegalArgumentException * if shadeMode is null */ public void setShadingMode(final ShadingMode shadeMode) { if (shadeMode == null) { throw new IllegalArgumentException("shadeMode can not be null."); } _shadeMode = shadeMode; setNeedsRefresh(true); }
private static Mesh createMesh() { // create a triangle strip of 8 triangles. final Mesh mesh = new Mesh(); mesh.getMeshData().setVertexCoords(new FloatBufferData(BufferUtils.createVector2Buffer(8), 2)); mesh.getMeshData().setColorBuffer(BufferUtils.createColorBuffer(8)); mesh.getMeshData().setIndexMode(IndexMode.TriangleStrip); final IndexBufferData<?> indices = BufferUtils.createIndexBufferData(10, 7); indices.put(new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 0, 1 }); mesh.getMeshData().setIndices(indices); // set up alpha blending. final BlendState blend = new BlendState(); blend.setBlendEnabled(true); blend.setSourceFunction(SourceFunction.SourceAlpha); blend.setDestinationFunction(DestinationFunction.OneMinusSourceAlpha); mesh.setRenderState(blend); // use flat shade so our borders will have a solid color. final ShadingState shading = new ShadingState(); shading.setShadingMode(ShadingMode.Flat); mesh.setRenderState(shading); mesh.updateWorldRenderStates(false); return mesh; } }
public static void apply(final ShadingState state) { // ask for the current state record final RenderContext context = ContextManager.getCurrentContext(); final ShadingStateRecord record = (ShadingStateRecord) context.getStateRecord(StateType.Shading); context.setCurrentState(StateType.Shading, state); // If not enabled, we'll use smooth final int toApply = state.isEnabled() ? getGLShade(state.getShadingMode()) : GL11.GL_SMOOTH; // only apply if we're different. Update record to reflect any changes. if (!record.isValid() || toApply != record.lastShade) { GL11.glShadeModel(toApply); record.lastShade = toApply; } if (!record.isValid()) { record.validate(); } }
return new OffsetState(); case Shading: return new ShadingState(); case Stencil: return new StencilState();
_shadowOffsetState.setUnits(4.0f); _flat = new ShadingState(); _flat.setShadingMode(ShadingMode.Flat);
public static void apply(final JoglRenderer renderer, final ShadingState state) { final GL gl = GLContext.getCurrentGL(); // ask for the current state record final RenderContext context = ContextManager.getCurrentContext(); final ShadingStateRecord record = (ShadingStateRecord) context.getStateRecord(StateType.Shading); context.setCurrentState(StateType.Shading, state); // If not enabled, we'll use smooth final int toApply = state.isEnabled() ? getGLShade(state.getShadingMode()) : GLLightingFunc.GL_SMOOTH; // only apply if we're different. Update record to reflect any changes. if (!record.isValid() || toApply != record.lastShade) { gl.getGL2().glShadeModel(toApply); record.lastShade = toApply; } if (!record.isValid()) { record.validate(); } }