se.angergard.engine.graphics.RenderUtil.java Source code

Java tutorial

Introduction

Here is the source code for se.angergard.engine.graphics.RenderUtil.java

Source

/********************************************************************************
 *
 *   Copyright 2014 Theodor Angergard
 *
 *   Licensed under the Apache License, Version 2.0 (the "License");
 *   you may not use this file except in compliance with the License.
 *   You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 *   Unless required by applicable law or agreed to in writing, software
 *   distributed under the License is distributed on an "AS IS" BASIS,
 *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *   See the License for the specific language governing permissions and
 *   limitations under the License.
 *
 *******************************************************************************/

package se.angergard.engine.graphics;

import org.lwjgl.opengl.*;

/** A set of helper methods using in the render category
 * @author Theodor */
public class RenderUtil {

    /** Clear the screen with GL_COLOR_BUFFER_BIT */
    public static void clearScreen() {
        GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT | GL11.GL_STENCIL_BUFFER_BIT);
    }

    /** Sets the clear color
     *
     * @param red The red component 0f - 1.0f
     * @param green The green component 0f - 1.0f
     * @param blue The blue component 0f - 1.0f */
    public static void setClearColor(float red, float green, float blue) {
        setClearColor(red, green, blue, 1);
    }

    /** @param red The red component 0f - 1.0f
     * @param green The green component 0f - 1.0f
     * @param blue The blue component 0f - 1.0f
     * @param alpha */
    public static void setClearColor(float red, float green, float blue, float alpha) {
        GL11.glClearColor(red, green, blue, alpha);
    }

    /** Unbind's all textures, */
    public static void unbindTexture() {
        GL11.glBindTexture(GL11.GL_TEXTURE_2D, 0);
    }

    /** Unbind's all shaders, */
    public static void unbindShader() {
        GL20.glUseProgram(0);
    }

    public static void unbindFrameBuffer() {
        GL30.glBindFramebuffer(GL30.GL_FRAMEBUFFER, 0);
    }

}