@@ -0,0 +1,2872 @@
+/*%0A * Copyright 2017 MovingBlocks%0A *%0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0A * you may not use this file except in compliance with the License.%0A * You may obtain a copy of the License at%0A *%0A *      http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A */%0Apackage org.terasology.rendering.dag.stateChanges;%0A%0Aimport org.terasology.assets.ResourceUrn;%0Aimport org.terasology.rendering.opengl.BaseFBOsManager;%0Aimport org.terasology.rendering.opengl.FBOManagerSubscriber;%0Aimport com.google.common.base.Objects;%0Aimport org.terasology.rendering.dag.StateChange;%0A%0Aimport static org.lwjgl.opengl.EXTFramebufferObject.GL_FRAMEBUFFER_EXT;%0Aimport static org.lwjgl.opengl.EXTFramebufferObject.glBindFramebufferEXT;%0A%0A/**%0A * Binds the given FBO setting it as the FBO to read from and write to.%0A *%0A * In practice in Terasology this is normally used only to set the FBO to write to. Using an FBO to read from%0A * is usually achieved by binding one of its attachments via the SetInputFromFBO state change.%0A *%0A * When this state change is reset opengl's default framebuffer (usually the display) is bound again.%0A * Similarly, nodes that do not take advantage of this state change will normally write to the default framebuffer.%0A */%0Apublic final class BindFbo implements FBOManagerSubscriber, StateChange %7B%0A    private static StateChange defaultInstance = new UnbindFbo();%0A%0A    private ResourceUrn fboName;%0A    private BaseFBOsManager fboManager;%0A    private int fboId;%0A%0A    public BindFbo(ResourceUrn fboName, BaseFBOsManager fboManager) %7B%0A        this.fboName = fboName;%0A        this.fboManager = fboManager;%0A%0A        update(); // Cheeky way to initialise fboId%0A        fboManager.subscribe(this);%0A    %7D%0A%0A    public ResourceUrn getFboName() %7B%0A        return fboName;%0A    %7D%0A%0A    @Override%0A    public StateChange getDefaultInstance() %7B%0A        return defaultInstance;%0A    %7D%0A%0A    @Override%0A    public int hashCode() %7B%0A        return Objects.hashCode(fboName);%0A    %7D%0A%0A    @Override%0A    public boolean equals(Object obj) %7B%0A        return (obj instanceof BindFbo) && fboName.equals(((BindFbo) obj).getFboName());%0A    %7D%0A%0A    @Override%0A    public void update() %7B%0A        fboId = fboManager.get(fboName).fboId;%0A    %7D%0A%0A    @Override%0A    public String toString() %7B // TODO: used for logging purposes at the moment, investigate different methods%0A        return String.format(%22%2530s: %25s (fboId:%25s)%22, this.getClass().getSimpleName(), fboName, fboId);%0A    %7D%0A%0A    @Override%0A    public void process() %7B%0A        glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fboId);%0A    %7D%0A%7D%0A

Add BindFbo file