com.mbrlabs.mundus.editor.utils.GlUtils.java Source code

Java tutorial

Introduction

Here is the source code for com.mbrlabs.mundus.editor.utils.GlUtils.java

Source

/*
 * Copyright (c) 2016. See AUTHORS file.
 *
 * 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 com.mbrlabs.mundus.editor.utils;

import org.lwjgl.opengl.GL11;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.GL20;

/**
 * @author Marcus Brummer
 * @version 22-11-2015
 */
public class GlUtils {

    public static void clearScreen(Color color) {
        Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT | GL20.GL_DEPTH_BUFFER_BIT);
        Gdx.gl.glClearColor(color.r, color.g, color.b, 1);
    }

    /**
     * OpenGL functionality, that goes beyond OpenGL ES.
     *
     * It's not 'unsafe' to run this on a desktop, but this kind of
     * functionality uses raw LWJGL and is not available on mobile devices or in
     * the browser.
     */
    public static class Unsafe {

        public static void polygonModeFill() {
            GL11.glPolygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_FILL);
        }

        public static void polygonModeWireframe() {
            GL11.glPolygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_LINE);
        }

    }

}