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:rntest.Main.java

public void start(int w, int h, String t) throws IOException {
    initGL(w, h, t);//w  w  w  .  jav  a  2 s .  c o m
    init();

    while (true) {
        GL11.glClear(GL11.GL_COLOR_BUFFER_BIT);
        pollInput();

        render();
        Display.update();
        Display.sync(100);
        if (Display.isCloseRequested()) {
            Display.destroy();
            System.exit(0);
        }
    }
}

From source file:robot.animation.RobotAnimation.java

private void init() {
    GLFW.glfwInit();/*from   w ww  .j  a  v a2s .c  om*/
    robot1 = new Robot(0.5f);
    robot2 = new Robot(0.4f);
    selectedRobot = robot1;
    window = GLFW.glfwCreateWindow(800, 800, "Robot Animation", 0, 0);
    GLFW.glfwMakeContextCurrent(window);
    GL.createCapabilities();
    GL11.glClear(GL11.GL_COLOR_BUFFER_BIT);
    GLFW.glfwSwapBuffers(window);

    GLFW.glfwSetKeyCallback(window, new GLFWKeyCallback() {
        @Override
        public void invoke(long window, int key, int scancode, int action, int mods) {
            if (key == GLFW.GLFW_KEY_1)
                selectedRobot = robot1;
            if (key == GLFW.GLFW_KEY_2)
                selectedRobot = robot2;
            if (key == GLFW.GLFW_KEY_LEFT_SHIFT)
                leftShiftPressed = true;
            if (key == GLFW.GLFW_KEY_RIGHT_SHIFT)
                rightShiftPressed = true;
            if (key == GLFW.GLFW_KEY_U && mods == GLFW.GLFW_MOD_SHIFT) {
                if (leftShiftPressed)
                    selectedBodyPart = BodyPart.LEFT_UPPER_ARM;
                if (rightShiftPressed)
                    selectedBodyPart = BodyPart.RIGHT_UPPER_ARM;
                leftShiftPressed = false;
                rightShiftPressed = false;
            }
            if (key == GLFW.GLFW_KEY_F && mods == GLFW.GLFW_MOD_SHIFT) {
                if (leftShiftPressed)
                    selectedBodyPart = BodyPart.LEFT_FOREARM;
                if (rightShiftPressed)
                    selectedBodyPart = BodyPart.RIGHT_FOREARM;
                leftShiftPressed = false;
                rightShiftPressed = false;
            }
            if (key == GLFW.GLFW_KEY_ESCAPE) {
                GLFW.glfwSetWindowShouldClose(window, true);
            } else if (key == GLFW.GLFW_KEY_RIGHT) {
                switch (selectedBodyPart) {
                case LEFT_UPPER_ARM:
                    selectedRobot.decreaseLeftUpperArmTiltAngle();
                    break;
                case RIGHT_UPPER_ARM:
                    break;
                case LEFT_FOREARM:
                    break;
                case RIGHT_FOREARM:
                    break;
                case NONE:
                    selectedRobot.moveRight();
                    break;
                default:
                    break;
                }
            } else if (key == GLFW.GLFW_KEY_LEFT) {
                switch (selectedBodyPart) {
                case LEFT_UPPER_ARM:
                    selectedRobot.increaseLeftUpperArmTiltAngle();
                    break;
                case RIGHT_UPPER_ARM:
                    break;
                case LEFT_FOREARM:
                    break;
                case RIGHT_FOREARM:
                    break;
                case NONE:
                    selectedRobot.moveLeft();
                    break;
                default:
                    break;
                }
            }

            System.out.println("Selected body part " + selectedBodyPart);
        }
    });
}

From source file:robot.animation.RobotAnimation.java

private void loop() {
    while (GLFW.glfwWindowShouldClose(window) != true) {
        GL11.glClear(GL11.GL_COLOR_BUFFER_BIT);
        robot1.drawRobot();/*from  ww  w .j av  a2  s  .c  o m*/
        robot2.drawRobot();
        GLFW.glfwSwapBuffers(window);
        GLFW.glfwPollEvents();
    }

}

From source file:rtype.Prototyp.java

License:Open Source License

void render() {
    GL11.glClear(GL11.GL_COLOR_BUFFER_BIT); // Clear The Screen And The Depth Buffer        

    background.render();// w  w w  . j  a  v a  2s. c  om

    // Make backGround darker
    {
        fadeAlpha = 0.65f;
        fadeScreen(false);
        fadeAlpha = 0;
    }

    enemies.render();

    bonus.render();

    fx.render();

    // This make a copy of the screen in a texture
    // It is used later for deformations effects
    saveScreen();

    applyDistorsions();

    bullets.render();

    frontground.render();

    text.render();

    fadeScreen(true);

    //this.drawPowerBar();
    //this.renderScanLines();
}

From source file:ru.axialshift.programs.ClearScreenPass.java

License:Apache License

@Override
public void execute() {
    GL11.glClear(GL11.GL_COLOR_BUFFER_BIT);
}

From source file:se.angergard.engine.graphics.RenderUtil.java

License:Apache License

/** 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);
}

From source file:shadowmage.meim.client.gui.GuiModelEditor.java

License:Open Source License

@Override
public void renderExtraBackGround(int mouseX, int mouseY, float partialTime) {
    GL11.glClearColor(.2f, .2f, .2f, 1.f);
    GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);
    setupModelView();/*from  w  w  w. j a  va 2 s  . co  m*/
    if (model != null && doSelection) {
        this.doSelection();
        doSelection = false;
    }
    renderGrid();
    enableModelLighting();
    if (model != null) {
        TextureManager.bindTexture();
        model.renderForEditor(getSelectedPiece(), getSelectedPrimitive());//.renderModel();
        TextureManager.resetBoundTexture();
    }
    resetModelView();
}

From source file:shadowmage.meim.client.gui.GuiModelEditor.java

License:Open Source License

protected void doSelection() {
    int posX = Mouse.getX();
    int posY = Mouse.getY();

    GL11.glDisable(GL11.GL_TEXTURE_2D);/*from   w ww .ja  va2  s. c o m*/
    GL11.glClearColor(1.f, 1.f, 1.f, 1.f);
    GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);
    GuiModelEditor.model.renderForSelection();

    byte[] pixelColorsb = new byte[3];
    ByteBuffer pixelColors = ByteBuffer.allocateDirect(3);
    GL11.glReadPixels(posX, posY, 1, 1, GL11.GL_RGB, GL11.GL_BYTE, pixelColors);

    for (int i = 0; i < 3; i++) {
        pixelColorsb[i] = pixelColors.get(i);
    }

    int r = pixelColorsb[0];
    int g = pixelColorsb[1];
    int b = pixelColorsb[2];

    GL11.glEnable(GL11.GL_TEXTURE_2D);
    AWLog.logDebug("colors clicked on: " + r + "," + g + "," + b);
    int color = (r << 16) | (g << 8) | b;
    AWLog.logDebug("color out: " + color);

    GL11.glClearColor(.2f, .2f, .2f, 1.f);
    GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);
    Primitive p = model.getPrimitive(color);
    if (p == null) {
        this.setSelectedPiece(null);
        this.setSelectedPrimitive(null);
    } else {
        this.setSelectedPrimitive(p);
    }
}

From source file:shadowmage.meim.client.gui.GuiModelEditor.java

License:Open Source License

private void setupModelView() {
    /**/*  w  w  w. j  av a2 s  .  c  om*/
     * load a clean projection matrix
     */
    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glPushMatrix();
    GL11.glLoadIdentity();

    /**
     * set up the base projection transformation matrix, as well as view target and position
     * (camera setup)
     */
    float aspect = (float) this.mc.displayWidth / (float) this.mc.displayHeight;
    GLU.gluPerspective(60.f, aspect, 0.1f, 100.f);
    GLU.gluLookAt(viewPosX, viewPosY, viewPosZ, viewTargetX, viewTargetY, viewTargetZ, 0, 1, 0);

    /**
     * load a clean model-view matrix
     */
    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glPushMatrix();
    GL11.glLoadIdentity();

    /**
     * and finally, clear the depth buffer 
     * (we want to ignore any world/etc, as we're rendering over-top of it all anyway)
     */
    GL11.glClear(GL11.GL_DEPTH_BUFFER_BIT);
}

From source file:sokobanMod.client.HandlerLevelPreviewRenderer.java

License:LGPL

private void renderPreview(DrawBlockHighlightEvent event) {

    double x = event.target.blockX + 0.5F;
    double y = event.target.blockY + 0.5F;
    double z = event.target.blockZ + 0.5F;
    double iPX = event.player.prevPosX + (event.player.posX - event.player.prevPosX) * event.partialTicks;
    double iPY = event.player.prevPosY + (event.player.posY - event.player.prevPosY) * event.partialTicks;
    double iPZ = event.player.prevPosZ + (event.player.posZ - event.player.prevPosZ) * event.partialTicks;

    int baseX = event.target.blockX;
    int baseY = event.target.blockY + 1;
    int baseZ = event.target.blockZ;

    float xScale = 0.1F;
    float yScale = 0.1F;
    float zScale = 0.1F;
    float xShift = 0.0F;
    float yShift = 1.0F;
    float zShift = 0.0F;
    // determine the line color

    int[] levelBounds;
    int[] rawLevelBounds;
    ForgeDirection sideHit = ForgeDirection.UP;
    if (event.currentItem == new ItemStack(SokobanMod.ItemLevelGeneratorTutorial)) {
        rawLevelBounds = LevelRegistrator.getLevelBounds(event.currentItem.getItemDamage());
        levelBounds = rawLevelBounds.clone();
        levelBounds[0]++;//w w  w  . j a v a2 s .  c o m
        levelBounds[1]++;
        levelBounds[2]++;
        yShift += levelBounds[1] / 2;

        int orientation = SokobanUtils.determineOrientation(event.player);
        switch (orientation) {
        case 0:
            orientation = 3;
            break;
        case 3:
            orientation = 5;
            break;
        case 1:
            orientation = 4;
            break;
        }
        sideHit = ForgeDirection.getOrientation(orientation);

        xShift += (1 - levelBounds[0] % 2) / 2F;
        yShift -= (1 - levelBounds[1] % 2) / 2F;
        zShift += (1 - levelBounds[2] % 2) / 2F;

    } else {
        colliding = false; // always render the wireframe green.
        NBTTagCompound nbt = event.player.getCurrentEquippedItem().stackTagCompound;
        if (nbt != null && nbt.hasKey("x")) {
            int startX = nbt.getInteger("x");
            int startY = nbt.getInteger("y");
            int startZ = nbt.getInteger("z");
            int endX = event.target.blockX;
            int endY = event.target.blockY;
            int endZ = event.target.blockZ;

            rawLevelBounds = new int[] { Math.abs(endX - startX), Math.abs(endY - startY),
                    Math.abs(endZ - startZ) };
            levelBounds = new int[] { rawLevelBounds[0] + 1, rawLevelBounds[1] + 1, rawLevelBounds[2] + 1 };

            xShift -= (endX - startX) / 2F;
            yShift -= (endY - startY) / 2F + 1F;
            zShift -= (endZ - startZ) / 2F;
        } else {
            rawLevelBounds = new int[] { 1, 1, 1 };
            levelBounds = new int[] { 1, 1, 1 };
            yShift = 0F;
        }

    }
    switch (sideHit) {
    case NORTH:
        zShift += levelBounds[2] / 2;
        zShift -= 1 - levelBounds[2] % 2;
        zShift = -zShift;

        baseZ -= rawLevelBounds[2];// +2
        baseX -= rawLevelBounds[0] / 2;
        break;
    case SOUTH:
        zShift += levelBounds[2] / 2;
        zShift -= 1 - levelBounds[2] % 2;

        baseX -= rawLevelBounds[0] / 2;
        break;
    case EAST:
        // zShift = 0;
        xShift += levelBounds[0] / 2;
        xShift -= 1 - levelBounds[0] % 2;
        baseZ -= rawLevelBounds[2] / 2;
        break;
    case WEST:
        xShift += levelBounds[0] / 2;
        xShift -= 1 - levelBounds[0] % 2;
        xShift = -xShift;

        baseX -= rawLevelBounds[0];
        baseZ -= rawLevelBounds[2] / 2;
        break;
    default:
    }

    colliding = SokobanUtils.isCollidingWithLevel(event.player.worldObj, baseX, baseY, baseZ,
            baseX + rawLevelBounds[0], baseY + rawLevelBounds[1], baseZ + rawLevelBounds[2]);

    GL11.glDepthMask(false);
    GL11.glDisable(GL11.GL_TEXTURE_2D);
    // GL11.glDisable(GL11.GL_CULL_FACE);

    for (int i = 0; i < 6; i++) {
        ForgeDirection forgeDir = ForgeDirection.getOrientation(i);
        int zCorrection = i == 2 ? -1 : 1;
        GL11.glPushMatrix();
        GL11.glTranslated(-iPX + x + xShift, -iPY + y + yShift, -iPZ + z + zShift);
        GL11.glScalef(levelBounds[0] + xScale, levelBounds[1] + yScale, levelBounds[2] + zScale);
        GL11.glRotatef(90, forgeDir.offsetX, forgeDir.offsetY, forgeDir.offsetZ);
        GL11.glTranslated(0, 0, 0.5f * zCorrection);
        GL11.glClear(GL11.GL_DEPTH_BUFFER_BIT);
        renderPulsingQuad();
        GL11.glPopMatrix();
    }

    GL11.glDepthMask(true);
    GL11.glEnable(GL11.GL_TEXTURE_2D);

}