Example usage for org.lwjgl.opengl GL11 glClearColor

List of usage examples for org.lwjgl.opengl GL11 glClearColor

Introduction

In this page you can find the example usage for org.lwjgl.opengl GL11 glClearColor.

Prototype

public static void glClearColor(@NativeType("GLfloat") float red, @NativeType("GLfloat") float green,
        @NativeType("GLfloat") float blue, @NativeType("GLfloat") float alpha) 

Source Link

Document

Sets the clear value for fixed-point and floating-point color buffers in RGBA mode.

Usage

From source file:fr.guillaume.prive.viper.core.graphic.GraphicMotor.java

private static void setupOpenGL() {
    try {/*  w  ww .  j  a v  a2  s.c o m*/
        PixelFormat pixelFormat = new PixelFormat();
        ContextAttribs contextAtrributes = new ContextAttribs(3, 2).withForwardCompatible(true)
                .withProfileCore(true);
        Display.setDisplayMode(new DisplayMode(SCREEN_WIDTH, SCREEN_HEIGHT));
        Display.setTitle(WINDOW_NAME);
        Display.create(pixelFormat, contextAtrributes);
    } catch (LWJGLException e) {
        throw new IllegalStateException("OpenGL init error", e);
    }

    GL11.glClearColor(0f, 0f, 0f, 0f);
    GL11.glViewport(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);

    GL11.glEnable(GL11.GL_DEPTH_TEST);
    GL11.glEnable(GL11.GL_BLEND);
}

From source file:fr.ign.cogit.geoxygene.appli.render.LwjglLayerRenderer.java

License:Open Source License

/**
 * Initialize layer FBO to receive GL primitives from a set of identical
 * symbolizers// www . jav  a  2  s.co  m
 * 
 * @param primitive
 * @param opacity
 * @param currentSymbolizer
 * @throws GLException
 */
private void clearFBOLayer() throws GLException {
    GLTools.glCheckError("preparing next FBO Layer");
    GL30.glBindFramebuffer(GL30.GL_DRAW_FRAMEBUFFER, this.getLayerViewPanel().getGLCanvas().getFboId());
    GL11.glDrawBuffer(GL30.GL_COLOR_ATTACHMENT0);

    GLTools.glCheckError("bind frame buffer");

    // Blending mode in FBO drawing.
    GLTools.glCheckError("finalizing FBO initialization");
    GL11.glClearColor(0f, 0f, 0f, 0f);
    GLTools.glCheckError("finalizing FBO initialization");
    GL11.glClear(GL11.GL_COLOR_BUFFER_BIT);

    GLTools.glCheckError("finalizing FBO initialization");
    glEnable(GL11.GL_BLEND);
    GLTools.glCheckError("finalizing FBO initialization");
    GL20.glBlendEquationSeparate(GL14.GL_FUNC_ADD, GL14.GL_MAX);
    GLTools.glCheckError("finalizing FBO initialization");
    GL14.glBlendFuncSeparate(GL11.GL_ONE, GL11.GL_ZERO, GL11.GL_ZERO, GL11.GL_ZERO);
    GL30.glBindFramebuffer(GL30.GL_DRAW_FRAMEBUFFER, 0);
    GLTools.glCheckError("finalizing FBO initialization");
}

From source file:fr.ign.cogit.geoxygene.util.gl.GLTools.java

License:Open Source License

/**
 * set gl clear color from a LWJGL Color object
 *//*from   ww w. j av a2s.co  m*/
public static void glClear(final Color color, int bufferId) {
    GL11.glClearColor(color.getRed() / 255f, color.getGreen() / 255f, color.getBlue() / 255f,
            color.getAlpha() / 255f);
    GL11.glClear(bufferId);
}

From source file:fr.ign.cogit.geoxygene.util.gl.GLTools.java

License:Open Source License

/**
 * set gl clear color from an AWT Color object
 *//*ww w.  j a va2 s .c  o m*/
public static void glClear(final java.awt.Color color, int bufferId) {
    GL11.glClearColor(color.getRed() / 255f, color.getGreen() / 255f, color.getBlue() / 255f,
            color.getAlpha() / 255f);
    GL11.glClear(bufferId);
}

From source file:fr.ign.cogit.geoxygene.util.gl.GLTools.java

License:Open Source License

/**
 * set gl clear color from RGBA components
 *//*from w  ww.  j  a va  2s .  c  o m*/
public static void glClear(float r, float g, float b, float a, int bufferId) {
    GL11.glClearColor(r, g, b, a);
    GL11.glClear(bufferId);
}

From source file:fr.theshark34.sharkengine.Game.java

License:Apache License

/**
 * Update the window, called by the main loop of the create() method
 *///from   w w  w.j  a  va  2  s  . c  o  m
private static void update() {
    // Clear all
    GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);
    GL11.glClearColor((float) clearColor.getRed() / 255, (float) clearColor.getGreen() / 255,
            (float) clearColor.getBlue() / 255, (float) clearColor.getAlpha() / 255);

    // Draw the current GUI
    if (currentGUI != null)
        currentGUI.draw();

    // Check if user requested close
    if (Display.isCloseRequested())
        stop();

    // Update the Display
    Display.update();
}

From source file:game.engine.game.Scene.java

License:Open Source License

/**
 * Draws the screen contents using OpenGL.
 *///ww w.j a  v  a 2s.c  om
public void draw() {
    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glLoadIdentity();
    GL11.glOrtho(0, getScreenWidthUnits(), getScreenHeightUnits(), 0, -1, 1);
    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glLoadIdentity();
    GL11.glTranslatef(-screenX, -screenY, 0.0f);
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GL11.glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
    GL11.glClear(GL11.GL_COLOR_BUFFER_BIT);
    for (GameObject gameObject : gameObjects) {
        gameObject.draw();
    }
}

From source file:geh.Geh.java

public void initGL() {
    try {//ww  w .j a v  a 2  s.  c o m
        Display.setDisplayMode(new DisplayMode(WIDTH, HEIGHT));
        Display.create();
    } catch (LWJGLException ex) {
        ex.printStackTrace();
        System.exit(0);
    }
    Mouse.setGrabbed(false);
    GL11.glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
    GL11.glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    glOrtho(0.0, WIDTH, HEIGHT, 0.0, -1.0, 10.0);
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();

}

From source file:hexagonalminesweeper.HexagonalMinesweeper.java

public static void renderGL() {
    try {//w  ww.j a  v  a2s  . c om
        Display.setDisplayMode(new org.lwjgl.opengl.DisplayMode(800, 600));
        Display.create();
    } catch (LWJGLException e) {
        e.printStackTrace();
        System.exit(0);
    }

    GL11.glEnable(GL11.GL_TEXTURE_2D);
    GL11.glShadeModel(GL11.GL_SMOOTH);
    GL11.glDisable(GL11.GL_DEPTH_TEST);
    GL11.glDisable(GL11.GL_LIGHTING);

    GL11.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
    GL11.glClearDepth(1);

    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);

    GL11.glViewport(0, 0, 800, 600);
    GL11.glMatrixMode(GL11.GL_MODELVIEW);

    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glLoadIdentity();
    GL11.glOrtho(0, 800, 600, 0, 1, -1);
    GL11.glMatrixMode(GL11.GL_MODELVIEW);

    Display.setVSyncEnabled(true);
}

From source file:illarion.graphics.lwjgl.RenderDisplayLWJGL.java

License:Open Source License

/**
 * Setup the openGL render environment. Such as the view port the matrix for
 * the orthogonal view and so on.//from  w  w  w  . j  a v a2s .co  m
 */
protected void setupOpenGL() {
    if (!Display.isCreated()) {
        return;
    }

    // set the basic view port of the game. This should be the full size of
    // the client window
    GL11.glViewport(0, 0, resWidth, resHeight);

    // enable alpha blending based on the picture alpha channel
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);

    // disable death test, we work in 2D anyway, there is no depth
    GL11.glDisable(GL11.GL_DEPTH_TEST);

    // switch to projection matrix to set up the orthogonal view that we
    // need
    GL11.glMatrixMode(GL11.GL_PROJECTION);

    // load the identity matrix to we have a clean start
    GL11.glLoadIdentity();

    // setup the orthogonal view
    GLU.gluOrtho2D(0, resWidth, 0, resHeight);

    // set clear color to black
    GL11.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);

    // sync frame (only works on windows)
    if (Graphics.NO_SLOWDOWN) {
        Display.setVSyncEnabled(false);
    } else {
        Display.setVSyncEnabled(true);
    }

    // clean up the screen
    GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);

    // switch to model view matrix, so we can place the sprites correctly
    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glLoadIdentity();
}