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:bd.ac.seu.lwjgldemo.Renderer.java

private void drawSomething() {
    GL11.glClearColor(0, 0, 0, 1);/*w  w  w . j  a  va  2  s. c o  m*/
    GL11.glClear(GL11.GL_COLOR_BUFFER_BIT);

    GL11.glColor3f(1, 1, 0);

    GL11.glPushMatrix();
    GL11.glRotatef(angle, 0, 0, 1);
    /*
    GL11.glBegin(GL11.GL_QUADS);
    for (int row = 0; row < vertices.length; row = row + 3) {
    double x = vertices[row];
    double y = vertices[row + 1];
    double z = vertices[row + 2];
    GL11.glVertex3d(x, y, z);
    }
    GL11.glEnd();
    */

    GL30.glBindVertexArray(vaoId);
    GL20.glEnableVertexAttribArray(0);

    // Draw the vertices
    GL11.glDrawArrays(GL11.GL_QUADS, 0, vertices.length / 3);

    // Put everything back to default (deselect)
    GL20.glDisableVertexAttribArray(0);
    GL30.glBindVertexArray(0);

    GL11.glPopMatrix();

    angle = angle + .10f;
    frameCounter++;
    long currentTime = System.nanoTime();
    long timeDifference = currentTime - lastTime;
    double fps = 1000000000.0 / timeDifference;
    System.out.printf("FPS: %.3f\n", fps);
    lastTime = currentTime;
}

From source file:br.com.perin.renderEngine.Renderer.java

public void prepare() {
    GL11.glClear(GL11.GL_COLOR_BUFFER_BIT);
    GL11.glClearColor(1, 0, 0, 1);
}

From source file:br.org.archimedes.gui.opengl.OpenGLWrapper.java

License:Open Source License

/**
 * Clears the OpenGL canvas./* w  w  w .  j  a  v a  2s .  c om*/
 */
public void clear() {
    Color currentBkColor = br.org.archimedes.Utils.getWorkspace().getBackgroundColor();
    GL11.glClearColor((float) currentBkColor.getR(), (float) currentBkColor.getG(),
            (float) currentBkColor.getB(), 0);

    GL11.glClear(GL11.GL_COLOR_BUFFER_BIT);
    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glLoadIdentity();
    resize();
}

From source file:cellularautomata.CellularAutomata.java

public static void gameLoop(TrueTypeFont trueTypeTitleFont, TrueTypeFont trueTypeDimensionsFont,
        TrueTypeFont trueTypePaintBrushFont) {
    while (!Display.isCloseRequested()) {
        GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);

        int indexX = (int) Math.ceil((Mouse.getX() - 90) / 62);
        int indexY = 5 - ((int) Math.ceil(Mouse.getY() / 86));

        if (menuState == 6 && screenState == 1) {
            int dwheel = Mouse.getDWheel();
            if (dwheel < 0 && indexY < 6 && indexY >= 0 && indexX < 10 && indexX >= 0) {
                if (path[indexY][indexX] < 6) {
                    path[indexY][indexX]++;
                }/*from  ww w. jav  a2s.c om*/
            } else if (dwheel > 0 && indexY < 6 && indexY >= 0 && indexX < 10 && indexX >= 0) {
                if (path[indexY][indexX] > 1) {
                    path[indexY][indexX]--;
                }
            }
        }
        if (screenState == 2) {

            int dwheel = Mouse.getDWheel();
            if (dwheel < 0 && currentRound > 0) {
                currentRound--;

            } else if (dwheel > 0) {
                updateAlive();
            }
        }

        input(trueTypeTitleFont);

        if (screenState == 0) {
            drawTitle(trueTypeTitleFont, trueTypePaintBrushFont, trueTypeDimensionsFont);
        }
        if (screenState == 1) {
            drawMenuLoop(trueTypeTitleFont, trueTypeDimensionsFont, trueTypePaintBrushFont);
        }
        if (screenState == 2) {
            drawBoard();
        }

        Display.update();
        Display.sync(60);
    }
    Display.destroy();
}

From source file:chessMod.client.ChessModDrawBlockHighlightHandler.java

License:LGPL

public static void highlightTile(EntityPlayer player, double x, double y, double z, float partialTicks) {

    x += 0.5D;/*from w w  w  .j  a v a2  s .c  o  m*/
    y += 0.5D;
    z += 0.5D;
    double iPX = player.prevPosX + (player.posX - player.prevPosX) * partialTicks;
    double iPY = player.prevPosY + (player.posY - player.prevPosY) * partialTicks;
    double iPZ = player.prevPosZ + (player.posZ - player.prevPosZ) * partialTicks;

    float xScale = 1.0F;
    float yScale = 1;
    float zScale = 1.0F;
    float xShift = 0.0F;
    float yShift = 0.01F;
    float zShift = 0.0F;

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

    for (int i = 4; i < 5; 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(1F * xScale, 1F * yScale, 1F * zScale);
        GL11.glRotatef(90, forgeDir.offsetX, forgeDir.offsetY, forgeDir.offsetZ);
        GL11.glTranslated(0, 0, 0.5f * zCorrection);
        GL11.glClear(GL11.GL_DEPTH_BUFFER_BIT);
        drawQuad(-0.5F, -0.5F, 1F, 1F, 0F);
        GL11.glPopMatrix();
    }

    GL11.glEnable(GL11.GL_CULL_FACE);
    GL11.glDepthMask(true);
}

From source file:code.elix_x.excore.utils.client.render.wtw.WTWRenderer.java

License:Apache License

@SubscribeEvent(priority = EventPriority.LOW)
public static void renderWorldLast(RenderWorldLastEvent event) {
    GL11.glClearStencil(0);/*from w ww  . j a v  a  2  s.  com*/
    GL11.glClear(GL11.GL_STENCIL_BUFFER_BIT);
    INSTANCE.run();
}

From source file:colonialdisplay.AntDisplayGL.java

@Override
protected void renderGL() {

    GL11.glClear(GL11.GL_COLOR_BUFFER_BIT);

    GL11.glPushMatrix();
    {
        drawBackground();
        drawForeGround();
    }
    GL11.glPopMatrix();
}

From source file:com.a2client.corex.Render.java

License:Open Source License

static public void Clear(boolean color, boolean depth) {
    setDepthWrite(true);//from   ww  w  . j  av  a 2  s .c om
    int mask = 0;
    if (color)
        mask += GL11.GL_COLOR_BUFFER_BIT;
    if (depth)
        mask += GL11.GL_DEPTH_BUFFER_BIT;
    GL11.glClear(mask);
}

From source file:com.a2client.utils3d.SceneCombi.java

License:Open Source License

public void RenderSkeleton() {
    if (node == null)
        return;/*from ww w  .  j a  va 2 s.  c  om*/

    GL11.glClear(GL_DEPTH_BUFFER_BIT);
    Render.Mode = Const.RENDER_MODE.rmOpaque;
    ARBShaderObjects.glUseProgramObjectARB(0);
    skeleton_material.bind();

    node.onRenderSkeleton();
}

From source file:com.adavr.player.example.DummyHMDRenderContext.java

License:Open Source License

@Override
public void loop() {
    Matrix4f viewMatrix = new Matrix4f();
    viewMatrix = viewMatrix.translate(cameraPos);
    Matrix4f modelMatrix = new Matrix4f();
    modelMatrix = modelMatrix.scale(modelScale).translate(modelPos); // TODO: Rotate
    Matrix4f modelViewMatrix = viewMatrix.mult(modelMatrix);

    ctx.updateMatrix(projectionMatrix, modelViewMatrix);

    GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);
    ctx.loop();/* w  w  w  .j av  a 2 s . c  o m*/
}