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:lwjglapp.Renderer.java

public void preRender() {
    GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT | GL11.GL_STENCIL_BUFFER_BIT);

    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glLoadIdentity();/*w  ww . ja  v  a 2s . co  m*/

    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glLoadIdentity();
}

From source file:Main.Graphics.GameObject.java

public static void RenderGL() {

    float x = GameWorld.x;
    float y = GameWorld.y;
    float rotation = GameWorld.rotation;

    GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);

    GL11.glColor3f(0.5f, 0.5f, 1.0f);//from  w  ww  . java  2  s.  c  o  m

    GL11.glPushMatrix();
    GL11.glTranslatef(x, y, 0);
    GL11.glRotatef(rotation, 0f, 0f, 1f);
    GL11.glTranslatef(-x, -y, 0);

    GL11.glBegin(GL11.GL_QUADS);
    GL11.glVertex2f(x - 50, y - 50);
    GL11.glVertex2f(x + 50, y - 50);
    GL11.glVertex2f(x + 50, y + 50);
    GL11.glVertex2f(x - 50, y + 50);
    GL11.glEnd();
    GL11.glPopMatrix();

}

From source file:main.java.com.YeAJG.game.Game.java

License:Open Source License

/**
 * Renders the Scene.//from  w  w  w. j av a2 s .  co m
 * @param interpolation 
 */
private void render(float interpolation) {
    GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);

    // Reset view and model matrices
    Game.viewMatrix = new Matrix4f();

    // Translate camera
    Matrix4f.translate(Game.cameraPos, Game.viewMatrix, Game.viewMatrix);

    //TODO: Render Entites

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

From source file:main.MasterRenderer.java

public void prepare() {
    GL11.glEnable(GL11.GL_DEPTH_TEST);
    GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);
    GL11.glClearColor(0.3f, 0.8f, 0.8f, 1);
}

From source file:map.GameMap.java

License:Open Source License

private void renderMinimap() {
    int size = MINIMAP_SIZE;
    Texture tex = new Texture("ground");
    miniMap = new Material(name + "_minimap");
    int[] viewport = GLUtils.getViewport();
    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glLoadIdentity();/*from   w  ww.  ja  v  a2s  .  c  om*/
    GL11.glOrtho(0, size, size, 0, -10, 10);
    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glLoadIdentity();
    GL11.glViewport(0, 0, size, size);

    GL11.glClearColor(0.0f, 0, 0, 1.0f);
    GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);
    GL11.glScalef(size / tiles.length, size / tiles.length, size / tiles.length);

    GLUtils.glLightPos(1.0f, 1.0f, 1.0f);
    GL11.glEnable(GL11.GL_DEPTH_TEST);
    GL11.glDisable(GL11.GL_CULL_FACE);
    draw(null);
    GL11.glEnable(GL11.GL_CULL_FACE);

    IntBuffer addr = ByteBuffer.allocateDirect(4).order(ByteOrder.nativeOrder()).asIntBuffer();
    GL11.glGenTextures(addr);
    tex.setID(addr.get(0));
    GL11.glBindTexture(GL11.GL_TEXTURE_2D, tex.getID());

    GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL11.GL_CLAMP);
    GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL11.GL_CLAMP);
    GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR);
    GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR);
    GL11.glCopyTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGB, 0, 0, size, size, 0);

    miniMap.setTexture(0, tex);
    GL11.glViewport(viewport[0], viewport[1], viewport[2], viewport[3]);
}

From source file:me.sunchiro.game.engine.gl.Graphic.java

License:Open Source License

private synchronized void render() {
    GL11.glClearColor(bgColor.x, bgColor.y, bgColor.z, 0);
    GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);
    GL20.glUseProgram(shader.getPID());//from www. j  a va 2s .c om
    //

    GL13.glActiveTexture(GL13.GL_TEXTURE0);
    GL30.glBindVertexArray(vaoId);

    GL20.glEnableVertexAttribArray(0);
    GL20.glEnableVertexAttribArray(1);
    GL20.glEnableVertexAttribArray(2);

    GL11.glBindTexture(GL11.GL_TEXTURE_2D, texManager.getTexture(tid));
    GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, vboiId);
    long offset = 0;
    int shift = 0;
    GL11.glAlphaFunc(GL11.GL_GREATER, 0.4f);
    GL11.glDisable(GL11.GL_CULL_FACE);
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);

    for (Drawable object : objects) {
        Matrix4f finalMVP = new Matrix4f(mvpMat);
        Matrix4f modelMat = new Matrix4f();
        Matrix4f scaler = new Matrix4f();
        scaler.scale(object.scale * allScale);
        modelMat.translate(object.translation);
        modelMat.rotateXYZ(object.rotation.x, object.rotation.y, object.rotation.z);
        finalMVP.mul(modelMat);
        finalMVP.mul(scaler);
        finalMVP.get(0, matBuff);
        if (object.isChar) {
            GL11.glBindTexture(GL11.GL_TEXTURE_2D, texManager.getTexture(tid_charmap));
        }
        GL20.glUniformMatrix4fv(shader.getMVPLocation(), false, matBuff);
        GL20.glUniform1i(shader.getInverseLocation(), object.inverseAlpha ? 1 : 0);
        if (object.isVisible())
            GL32.glDrawElementsBaseVertex(GL11.GL_TRIANGLES, object.getIndices().length, GL11.GL_UNSIGNED_BYTE,
                    offset, shift);

        offset += object.getIndices().length;
        shift += object.getVertex().length;
        if (object.isChar) {
            GL11.glBindTexture(GL11.GL_TEXTURE_2D, texManager.getTexture(tid));
        }
    }
    render2d(offset, shift);
    GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, 0);
    GL20.glDisableVertexAttribArray(0);
    GL20.glDisableVertexAttribArray(1);
    GL20.glDisableVertexAttribArray(2);
    GL30.glBindVertexArray(0);
    //
    GL20.glUseProgram(0);
    glfwSwapBuffers(window);
    glfwPollEvents();

}

From source file:me.thehutch.fusion.engine.render.opengl.GLContext.java

License:Open Source License

public void clearCurrentBuffer() {
    ensureCreated("Can not clear the current buffer if the context has not been created");
    GL11.glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
}

From source file:me.thehutch.fusion.engine.render.Renderer.java

License:Open Source License

@Override
public void begin() {
    // Clear the colour and depth buffers
    GL11.glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
}

From source file:me.ukl.api.gui.renderer.GuiRendererDepth.java

License:MIT License

@Override
public void clearClip() {
    GL11.glClear(GL11.GL_DEPTH_BUFFER_BIT);
}

From source file:minesweeperMod.client.FieldStatHandler.java

License:LGPL

@SubscribeEvent
public void tickEnd(TickEvent.RenderTickEvent event) {
    if (MinesweeperMod.instance.configStatEnabled) {
        Minecraft minecraft = FMLClientHandler.instance().getClient();
        EntityPlayer player = minecraft.thePlayer;
        if (player != null) {
            World world = minecraft.theWorld;
            boolean shouldUpdate = false;
            if (!isTriggeredThisTick && player.ticksExisted % 20 == 0) {
                isTriggeredThisTick = true;
                shouldUpdate = true;/*from  w w  w  .  j a  v  a2 s  .  c  o  m*/
            } else if (player.ticksExisted % 20 != 0) {
                isTriggeredThisTick = false;
            }
            ScaledResolution sr = new ScaledResolution(minecraft, minecraft.displayWidth,
                    minecraft.displayHeight);
            GL11.glDepthMask(false);
            GL11.glDisable(GL11.GL_CULL_FACE);
            GL11.glDisable(GL11.GL_TEXTURE_2D);
            GL11.glPushMatrix();
            GL11.glClear(GL11.GL_DEPTH_BUFFER_BIT);
            GL11.glColor4d(0, 1, 0, 0.8D);

            if (minesweeperStat == null) {
                minesweeperStat = new GuiAnimatedStat("Minefield Statistics:", sr.getScaledWidth() - 2, 2,
                        0x3000AA00, null, true);
                minesweeperStat.setMinDimensionsAndReset(0, 0);
            }
            List<String> textList = new ArrayList<String>();
            if (world.getBlock(x, y, z) == MinesweeperMod.blockMinesweeper) {
                minesweeperStat.openWindow();
                if (shouldUpdate || forceUpdate) {
                    List<int[]> tiles = new ArrayList<int[]>();
                    ((BlockMinesweeper) MinesweeperMod.blockMinesweeper).getAccessoryTiles(tiles, world, x, y,
                            z);
                    flagCount = 0;
                    bombCount = 0;
                    int hardcoreBombCount = 0;
                    for (int[] tile : tiles) {
                        if (MinesweeperUtils.isTileBomb(world.getBlockMetadata(tile[0], tile[1], tile[2])))
                            bombCount++;
                        if (MinesweeperUtils.isTileFlagged(world.getBlockMetadata(tile[0], tile[1], tile[2])))
                            flagCount++;
                        if (MinesweeperUtils
                                .isTileHardcoreBomb(world.getBlockMetadata(tile[0], tile[1], tile[2])))
                            hardcoreBombCount++;

                    }
                    tileBombRatio = (double) bombCount / (double) tiles.size();
                    hardcoreBombPercentage = (double) hardcoreBombCount / (double) bombCount;
                    statHoldTimer--;
                    if (forceUpdate)
                        statHoldTimer = MinesweeperMod.instance.configStatDuration;
                    forceUpdate = false;
                    if (statHoldTimer <= 0) {
                        x = 0;
                        y = 0;
                        z = 0;
                    }
                }
                textList.add("   Mines: " + bombCount);
                textList.add("Flagged: " + flagCount);
                textList.add("           -- -");
                textList.add("    Left: " + (bombCount - flagCount));
                if (tileBombRatio > 1D / 6D && hardcoreBombPercentage > 0.5D) {
                    textList.add("Difficulty: Hardcore");
                } else if (tileBombRatio > 1D / 6D) {
                    textList.add("Difficulty: Hard");
                } else if (tileBombRatio > 1D / 8D) {
                    textList.add("Difficulty: Medium");
                } else {
                    textList.add("Difficulty: Easy");
                }
            } else {
                minesweeperStat.closeWindow();
            }

            int xPos = 0;
            int yPos = 1;

            switch (MinesweeperMod.instance.configStatXPos) {
            case 0:
                xPos = 2;
                minesweeperStat.leftSided = false;
                break;
            case 1:
                xPos = sr.getScaledWidth() / 2 - 55;
                minesweeperStat.leftSided = false;
                break;
            case 2:
                xPos = sr.getScaledWidth() - 2;
                minesweeperStat.leftSided = true;
                break;
            }

            switch (MinesweeperMod.instance.configStatYPos) {
            case 0:
                yPos = 2;
                break;
            case 1:
                yPos = sr.getScaledHeight() / 2 - 40;
                break;
            case 2:
                yPos = sr.getScaledHeight() - 68;
                break;
            }

            minesweeperStat.updateResolution(xPos, yPos);
            minesweeperStat.render(minecraft.fontRenderer, textList, 0);
            GL11.glPopMatrix();
            GL11.glEnable(GL11.GL_CULL_FACE);
            GL11.glDepthMask(true);
            GL11.glEnable(GL11.GL_TEXTURE_2D);
        }
    }
}