public abstract class LwjglFogStateUtil {
public static void apply(final FogState state) {
// ask for the current state record
final RenderContext context = ContextManager.getCurrentContext();
final FogStateRecord record = (FogStateRecord) context.getStateRecord(StateType.Fog);
context.setCurrentState(StateType.Fog, state);
if (state.isEnabled()) {
enableFog(true, record);
if (record.isValid()) {
if (record.fogStart != state.getStart()) {
GL11.glFogf(GL11.GL_FOG_START, state.getStart());
record.fogStart = state.getStart();
}
if (record.fogEnd != state.getEnd()) {
GL11.glFogf(GL11.GL_FOG_END, state.getEnd());
record.fogEnd = state.getEnd();
}
if (record.density != state.getDensity()) {
GL11.glFogf(GL11.GL_FOG_DENSITY, state.getDensity());
record.density = state.getDensity();
}
} else {
GL11.glFogf(GL11.GL_FOG_START, state.getStart());
record.fogStart = state.getStart();
GL11.glFogf(GL11.GL_FOG_END, state.getEnd());
record.fogEnd = state.getEnd();
GL11.glFogf(GL11.GL_FOG_DENSITY, state.getDensity());
record.density = state.getDensity();
}
final ReadOnlyColorRGBA fogColor = state.getColor();
applyFogColor(fogColor, record);
applyFogMode(state.getDensityFunction(), record);
applyFogHint(state.getQuality(), record);
applyFogSource(state.getSource(), record, context.getCapabilities());
} else {
enableFog(false, record);
}
if (!record.isValid()) {