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:minesweeperMod.client.MinesweeperDrawBlockHighlightHandler.java

License:LGPL

public static void highlightTile(EntityPlayer player, double x, double y, double z, float partialTicks,
        int tile) {
    x += 0.5D;//from   w w w .j a v  a  2  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, tile);
        GL11.glPopMatrix();
    }

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

From source file:modeledit.ModelView3D.java

License:Open Source License

public void draw() {
    GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);
    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glLoadIdentity();//from  w w w . j a v a  2 s  . c  o m

    GL11.glMatrixMode(GL11.GL_VIEWPORT);
    GL11.glViewport(0, 0, getWidth(), getHeight());

    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glLoadIdentity();
    GLU.gluPerspective(40, ((float) this.getWidth()) / ((float) this.getHeight()), 1, 100);
    GL11.glMatrixMode(GL11.GL_MODELVIEW);

    GL11.glTranslatef(panX, panY, 0);

    //(float)(camDist*Math.sin(camTheta)*Math.cos(camPhi))
    GLU.gluLookAt((float) (camDist * Math.sin(camTheta) * Math.sin(camPhi)),
            (float) (camDist * Math.cos(camTheta) * Math.sin(camPhi)), (float) (camDist * Math.cos(camPhi)), 0,
            0, 0, 0, 0, 1);
    if (model != null) {
        model.draw(state);
    }
}

From source file:mss.View.java

License:Open Source License

public void init() {
    this.modul.registerObserver("view", this);
    updateComboBoxes();// w w w .  j  a  v a  2s. co m

    try {
        Display.setParent(this.canvas);
        Keyboard.enableRepeatEvents(true);
        this.frame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
        this.frame.setLayout(new BorderLayout());
        this.frame.add(this.tabbedPane, BorderLayout.LINE_START);
        this.frame.add(this.canvas, BorderLayout.CENTER);
        this.frame.add(this.panel, BorderLayout.PAGE_END);
        this.frame.setPreferredSize(new Dimension(1024, 786));
        this.frame.setMinimumSize(new Dimension(800, 600));
        this.frame.pack();

        this.frame.setVisible(true);

        Display.setTitle(this.title);
        Display.setResizable(true);
        Display.setFullscreen(false);
        Display.create();
        this.initOpenGL();
        this.wasInitialized = true;
        LWJGLRenderer renderer = new LWJGLRenderer();

        Dimension newDim;

        while (!Display.isCloseRequested() && !View.closeRequested) {
            if (this.shouldReInit) {
                this.initOpenGL();
                this.shouldReInit = false;
            }

            if (this.shouldTakeScreenshot) {
                this.saveScreenshot();
                this.shouldTakeScreenshot = false;
            }

            GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);
            newDim = newCanvasSize.getAndSet(null);
            checkKeyInput();
            if (newDim != null) {
                GL11.glViewport(0, 0, newDim.width, newDim.height);
                renderer.syncViewportSize();
            }

            for (int i = 0; i < this.planets.size(); i++) {
                this.planets.get(i).draw2D(this.debug);
            }

            if (!this.isPaused && this.results != null && this.currentIndex < this.results.size() - 1
                    && this.getDelta() / this.deltaT >= this.speed) {
                this.planets = this.results.get(this.currentIndex);
                int add = (int) (1 / deltaT);
                if (add == 0) {
                    add = 1;
                }
                this.time = this.getTime();
                this.currentIndex += add;
                this.slider.setValue(this.slider.getValue() + add);
            }

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

        Display.destroy();
        this.frame.dispose();
    } catch (LWJGLException e) {
        System.out.println(e.getMessage());
        System.exit(-1);
    }
}

From source file:mwisbest.openbase.Common.java

License:Open Source License

/**
 * Common code for rendering the Widgets to the screen. After this, customRender() is used from OpenBASE or OpenBASEApplet (whatever is calling this method).
 *//*from  w  w w  .  j  a v  a  2 s .com*/
protected static void render(int framerateLimit) {
    GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);
    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glLoadIdentity();
    Map<String, Widget> theWidgets = ResourceManager.getWidgets();
    for (RenderPriority priority : RenderPriority.values()) {
        for (Entry<String, Widget> widget : theWidgets.entrySet()) {
            if (widget.getValue().getRenderPriority() == priority && widget.getValue().getVisible())
                widget.getValue().render();
        }
    }
    if (framerateLimit > 0)
        Display.sync(framerateLimit);
}

From source file:myfirstgame.Myfirstgame.java

public Myfirstgame() throws FileNotFoundException, IOException {

    try {/*w ww  .  j a  va  2s.  c o  m*/
        AL.create();
    } catch (LWJGLException ex) {
        Logger.getLogger(Game.class.getName()).log(Level.SEVERE, null, ex);
    }

    window.init(screenX, screenY);
    game.initGame();

    while (!window.closeReq) {

        GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT); //important to clear depth buffer and color buffer bits when using alpha blends for transparency.
        Input.update();
        game.update();
        window.update();

    }
    AL.destroy();
    Window.cleanUp();
}

From source file:naftoreiclag.splendidanimator.EasyGraphics.java

License:MIT License

private void clearGPU() {
    GL11.glClear(GL11.GL_COLOR_BUFFER_BIT);
}

From source file:net.ae97.notlet.client.GameInstance.java

License:Open Source License

private static void renderBackground() {
    GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);
    if (GameInstance.getMap() == null) {
        return;/*ww  w . ja  v a 2s .  c o  m*/
    }
    boolean[][] map = GameInstance.getMap();
    textureMapping.get("dirt").bind();
    for (int i = 0; i < map.length; i++) {
        for (int j = 0; j < map.length; j++) {
            if (map[i][j]) {
                renderFG(i * 32, j * 32);
            }
        }
    }

    textureMapping.get("wall").bind();
    for (int i = 0; i < map.length; i++) {
        for (int j = 0; j < map.length; j++) {
            if (!map[i][j]) {
                renderFG(i * 32, j * 32);
            }
        }
    }

    textureMapping.get("exit").bind();
    renderFG((map.length - 1) * 32, (map.length - 1) * 32);
}

From source file:net.BiggerOnTheInside.Binder.engine.world.World.java

License:Open Source License

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

    //Render();//from ww w. j  a  v a  2 s .  c  om
    c.render();
    //switchTo3D();
    //render3D();
    //glColor3f(1, 1, 1);
    //switchTo2D();
    //render2D();
}

From source file:net.BiggerOnTheInside.Binder.GameLoop.java

License:Open Source License

public void render() {
    if (state == GameState.Playing) {
        GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT); // Clear The Screen And The Depth Buffer
        render3D();/*from  ww w .j  a v a  2s.co  m*/

        ViewHelper.setOrthoOn();
        render2D();
        ViewHelper.setOrthoOff();
    }
}

From source file:net.bryanbergen.lwjgl.display.Window.java

public void clear() {
    GL11.glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
}