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();
}
}