Example usage for org.lwjgl.opengl GL11 glClear

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

Introduction

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

Prototype

public static void glClear(@NativeType("GLbitfield") int mask) 

Source Link

Document

Sets portions of every pixel in a particular buffer to the same value.

Usage

From source file:com.gameminers.mav.Mav.java

License:Open Source License

private static void drawBasicScreen(String s, float dim) {
    Rendering.setUpGL();/*  ww w  .j  a va  2 s  . c  om*/
    Rendering.beforeFrame(Display.getWidth(), Display.getHeight());
    GL11.glClearColor(0, 0, 0, 1);
    GL11.glClear(GL11.GL_COLOR_BUFFER_BIT);
    Fonts.light[2].drawString((Display.getWidth() / 2) - (Fonts.light[2].getWidth(s) / 2), 160, s, Color.white);
    Rendering.drawTriangle(Display.getWidth() / 2f, 90, 74, 0.5f, 0.5f, 0.5f, 0.5f, 0);
    Rendering.drawTriangle(Display.getWidth() / 2f, 90, 64, 0.5f, 0.5f, 0.5f, 1, 0.5f);
    Rendering.drawTriangle(Display.getWidth() / 2f, 90, 56, 0, 0, 0, 1, 1f);
    Rendering.drawRectangle(0, 0, Display.getWidth(), Display.getHeight(), 0, 0, 0, dim, 1);
    Display.update();
}

From source file:com.gameminers.mav.personality.poly.PolygonPersonality.java

License:Open Source License

@Override
public void renderBackground() {
    /*long delta = System.currentTimeMillis()-Mav.lastInputEvent;
    if (delta > IDLE_TIME) {/* www. ja v a  2 s.c  om*/
       bgLum = (1.0f-(Math.min(delta-IDLE_TIME, IDLE_FADE_OUT_TIME)/IDLE_FADE_OUT_TIME))*0.3f;
       framesSinceFade = 0;
    } else {
       framesSinceFade++;
       bgLum = Math.min(0.3f, framesSinceFade/IDLE_FADE_IN_FRAMES);
    }*/
    float[] rgb = RenderState.getColor(bgLum);
    GL11.glClearColor(rgb[0], rgb[1], rgb[2], 1f);
    GL11.glClear(GL11.GL_COLOR_BUFFER_BIT);
}

From source file:com.github.kajdreef.mazerunnermvn.Launcher.java

/**
 * Here the game is processed.//  w  w w  .j a  v  a 2s.  co  m
 */
public void gameLoop() {
    timer0 = new Timer();
    timer0.start();
    while (!Display.isCloseRequested()) {
        checkState();

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

        state.input();
        state.logic(timer0.getDelta());
        state.render();

        Display.update();
        Display.sync(fps);
    }
}

From source file:com.github.kajdreef.mazerunnermvn.State.MazeRunner.java

@Override
public void render() {
    shaderProgram.useProgram();

    GL11.glClear(GL11.GL_COLOR_BUFFER_BIT);

    level.render();

    shaderProgram.stopProgram();
}

From source file:com.github.reisnera.gameboylfb.App.java

License:GNU General Public License

/**
 * @return Returns 0 if everything ran fine, otherwise returns 1 if the program should exit
 *///from w  w w.  j  a  v  a2s  .c  o m
public int tick() {
    if (glfwWindowShouldClose(window) == GL11.GL_TRUE) {
        glfwTerminate();
        errorCallback.release();
        // TODO: Notify someone that this should close in another way?
        return 1;
    } else {
        GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT); // clear the framebuffer
        glfwSwapBuffers(window); // swap the color buffers

        // Poll for window events. The key callback above will only be
        // invoked during this call.
        glfwPollEvents();
        return 0;
    }
}

From source file:com.google.gapid.glviewer.GeometryScene.java

License:Apache License

@Override
public void render(Renderer renderer) {
    GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);

    if (data != null && renderable != null) {
        Renderable.State state = data.shading.getState(shaders, data.winding.invertNormals);
        data.culling.apply();/*from  w  w w  .j  ava 2s .  c  o m*/
        data.winding.apply();

        state.transform.setProjection(camera.getProjection());
        state.transform.setModelView(camera.getViewTransform());
        renderable.render(renderer, state);
    }
}

From source file:com.google.gapid.glviewer.gl.Renderer.java

License:Apache License

/** Clears the viewport with the given solid color */
public static void clear(Color c) {
    GL11.glClearColor(c.getRed() / 255f, c.getGreen() / 255f, c.getBlue() / 255f, 1f);
    GL11.glClear(GL11.GL_COLOR_BUFFER_BIT);
}

From source file:com.google.gapid.glviewer.Viewer.java

License:Apache License

@Override
public void display() {
    GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);

    if (newRenderable != null) {
        if (renderable != null) {
            renderable.dispose();// w w  w  .  j ava 2  s.  c  o m
        }
        renderable = newRenderable;
        renderable.init();
        newRenderable = null;
    }

    if (renderable != null) {
        Renderable.State state = shading.getState(shaders, winding.invertNormals);
        culling.apply();
        winding.apply();

        state.transform.setProjection(camera.getProjection());
        state.transform.setModelView(camera.getViewTransform());
        renderable.render(state);
    }
}

From source file:com.grillecube.client.opengl.window.GLFWWindow.java

/** should be call before rendering */
public void clearScreen() {
    GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);
}

From source file:com.jmex.bui.BGeomView.java

License:Open Source License

/**
 * Documentation Inherited//from  w  w  w  . j a  va  2s  .  com
 *
 * @param renderer Renderer
 * @see BComponent#renderComponent
 */
@Override
protected void renderComponent(final Renderer renderer) {
    super.renderComponent(renderer);
    if (_geom == null) {
        return;
    }

    applyDefaultStates();
    Camera cam = renderer.getCamera();

    int x = getAbsoluteX();
    int y = getAbsoluteY();

    boolean useOrtho = (_geom.getRenderQueueMode() == Renderer.QUEUE_ORTHO);

    try {
        if (!useOrtho) {
            renderer.unsetOrtho();

            // create or resize our camera if necessary
            DisplaySystem display = DisplaySystem.getDisplaySystem();
            int swidth = display.getWidth(), sheight = display.getHeight();
            boolean updateDisplay = false;
            if (_camera == null || _swidth != swidth || _sheight != sheight) {
                _swidth = swidth;
                _sheight = sheight;
                if (_camera == null) {
                    _camera = createCamera(display);
                } else {
                    _camera.resize(_swidth, _sheight);
                }
                updateDisplay = true;
            }

            // set up our camera viewport if it has changed
            Insets insets = getInsets();

            int ax = x + insets.left;
            int ay = y + insets.bottom;
            int width = _width - insets.getHorizontal();
            int height = _height - insets.getVertical();

            if (updateDisplay || _cx != ax || _cy != ay || _cwidth != width || _cheight != height) {
                _cx = ax;
                _cy = ay;
                _cwidth = width;
                _cheight = height;
                float left = _cx / _swidth, right = left + _cwidth / _swidth;
                float bottom = _cy / _sheight;
                float top = bottom + _cheight / _sheight;
                _camera.setViewPort(left, right, bottom, top);
                _camera.setFrustumPerspective(45.0f, _width / (float) _height, 1, 1000);
            }

            // clear the z buffer over the area to which we will be drawing
            boolean scissored = intersectScissorBox(_srect, ax, ay, width, height);
            GL11.glClear(GL11.GL_DEPTH_BUFFER_BIT);
            restoreScissorState(scissored, _srect);

            // now set up the custom camera and render our geometry
            renderer.setCamera(_camera);
            _camera.apply();
            _camera.update();
        }

        // actually render the geometry
        renderer.draw(_geom);
    } finally {
        if (!useOrtho) {
            // restore the camera
            renderer.setCamera(cam);
            cam.apply();
            cam.update();
            renderer.setOrtho();

            // we need to restore the GL translation as that got wiped out when we left and
            // re-entered ortho mode
            GL11.glTranslatef(x, y, 0);
        }
    }
}