List of usage examples for org.lwjgl.opengl GL11 glClear
public static void glClear(@NativeType("GLbitfield") int mask)
From source file:hexagonalminesweeper.HexagonalMinesweeper.java
public static void gameLoop(TrueTypeFont trueTypeTitleFont, TrueTypeFont trueTypeBylineFont) { while (!Display.isCloseRequested()) { GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT); while (Keyboard.next()) { if (Keyboard.getEventKeyState()) { if (Keyboard.getEventKey() == Keyboard.KEY_F) { setDisplayMode(800, 600, !Display.isFullscreen()); }// w w w . java 2s . com } } if (!gameStart) { titleScreen(trueTypeTitleFont, trueTypeBylineFont); if (Keyboard.isKeyDown(Keyboard.KEY_SPACE)) { gameStart = true; } } else { int dwheel = Mouse.getDWheel(); if (dwheel < 0) { if (mineNumber >= 1) { mineNumber--; if (mineNumber < 0) { mineNumber = 0; } values1 = new int[200][100]; values2 = new int[200][100]; layMines(); if (covered) { selectedHexagons = new int[200][100]; timerStart = 1; } else { uncover(); timerStart = 0; } } } else if (dwheel > 0) { mineNumber++; values1 = new int[200][100]; values2 = new int[200][100]; layMines(); if (covered) { selectedHexagons = new int[200][100]; timerStart = 1; } else { uncover(); timerStart = 0; } } time = System.nanoTime() / 1000000000; mouseClick(); keyboardInput(); flood(); tileCount(); checkWinLose(); draw(); drawMenu(trueTypeBylineFont); } Display.update(); Display.sync(60); } Display.destroy(); }
From source file:hud.UnitDisplay.java
License:Open Source License
public void draw() { GL11.glPolygonMode(GL11.GL_FRONT, GL11.GL_LINE); GL11.glColor4f(0.0f, 0.0f, 0.4f, 1.0f); GL11.glLineWidth(2.0f);/* www . ja va 2s.co m*/ GL11.glBegin(GL11.GL_QUADS); GL11.glVertex2i(x, y); GL11.glVertex2i(x, y + height); GL11.glVertex2i(x + width, y + height); GL11.glVertex2i(x + width, y); GL11.glEnd(); GL11.glPolygonMode(GL11.GL_FRONT, GL11.GL_FILL); GL11.glColor4f(0.0f, 0.5f, 1.0f, 0.8f); GL11.glEnable(GL11.GL_BLEND); GL11.glBegin(GL11.GL_QUADS); GL11.glVertex2i(x, y); GL11.glVertex2i(x, y + height); GL11.glVertex2i(x + width, y + height); GL11.glVertex2i(x + width, y); GL11.glEnd(); GL11.glDisable(GL11.GL_BLEND); int[] viewport = GLUtils.getViewport(); GL11.glClear(GL11.GL_DEPTH_BUFFER_BIT); GL11.glEnable(GL11.GL_DEPTH_TEST); GL11.glEnable(GL11.GL_LIGHTING); GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glPushMatrix(); GL11.glLoadIdentity(); GLU.gluPerspective(45, 1.0f, 0.001f, 5.0f); GL11.glViewport(getX(), viewport[3] - (getY() + height), width, height); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glPushMatrix(); GL11.glLoadIdentity(); GLU.gluLookAt(2.0f * (float) Math.cos(angle), 2.0f * (float) Math.sin(angle), 1.0f, 0, 0, 0, 0, 0, 1); // GL11.glTranslatef(x + width/2, y + height/2,0); currentUnit.draw(); GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glPopMatrix(); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glPopMatrix(); GL11.glViewport(viewport[0], viewport[1], viewport[2], viewport[3]); GL11.glDisable(GL11.GL_DEPTH_TEST); GL11.glDisable(GL11.GL_LIGHTING); }
From source file:illarion.graphics.lwjgl.MaskUtilLWJGL.java
License:Open Source License
/** * Start defining a mask. After calling this you need to use the drawer * functions to mask out the needed areas. *//*from ww w . j a va 2 s .c o m*/ @Override public void defineMask() { GL11.glDepthMask(true); GL11.glClearDepth(1); GL11.glClear(GL11.GL_DEPTH_BUFFER_BIT); GL11.glDepthFunc(GL11.GL_ALWAYS); GL11.glEnable(GL11.GL_DEPTH_TEST); GL11.glDepthMask(true); GL11.glColorMask(false, false, false, false); }
From source file:illarion.graphics.lwjgl.RenderDisplayLWJGL.java
License:Open Source License
/** * Update the display so the last drawn picture gets visible. *//*from www . j a v a 2 s.com*/ public void update() { AbstractTextureRender.finish(); Display.update(); // clean display for next render loop. GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_STENCIL_BUFFER_BIT); GL11.glLoadIdentity(); }
From source file:illarion.graphics.lwjgl.RenderDisplayLWJGL.java
License:Open Source License
/** * Setup the openGL render environment. Such as the view port the matrix for * the orthogonal view and so on.// w w w. jav a2 s. c om */ protected void setupOpenGL() { if (!Display.isCreated()) { return; } // set the basic view port of the game. This should be the full size of // the client window GL11.glViewport(0, 0, resWidth, resHeight); // enable alpha blending based on the picture alpha channel GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); // disable death test, we work in 2D anyway, there is no depth GL11.glDisable(GL11.GL_DEPTH_TEST); // switch to projection matrix to set up the orthogonal view that we // need GL11.glMatrixMode(GL11.GL_PROJECTION); // load the identity matrix to we have a clean start GL11.glLoadIdentity(); // setup the orthogonal view GLU.gluOrtho2D(0, resWidth, 0, resHeight); // set clear color to black GL11.glClearColor(0.0f, 0.0f, 0.0f, 0.0f); // sync frame (only works on windows) if (Graphics.NO_SLOWDOWN) { Display.setVSyncEnabled(false); } else { Display.setVSyncEnabled(true); } // clean up the screen GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT); // switch to model view matrix, so we can place the sprites correctly GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glLoadIdentity(); }
From source file:im.bci.jnuit.samples.AbstractSample.java
License:Open Source License
public void launch(String[] args) { try {// w ww . ja va 2 s . co m setupLibraryPath(); } catch (Throwable e) { handleError(e, "Unexpected error during startup. Check your java version and your opengl driver.\n"); return; } try { Display.setFullscreen(false); DisplayMode mode = new DisplayMode(640, 480); Display.setDisplayMode(mode); Display.create(); Display.setTitle(getClass().getSimpleName()); LwjglNuitFont font = new LwjglNuitFont(new Font("Arial", Font.BOLD, 32), true, new char[0], new HashMap<Character, BufferedImage>()); NuitTranslator translator = new NuitTranslator(); final LwjglNuitRenderer renderer = new LwjglNuitRenderer(translator, font); NuitToolkit toolkit = new NuitToolkit(new LwjglNuitDisplay(), new LwjglNuitControls(), translator, font, renderer, new OpenALNuitAudio(createVFS())); Root root = new Root(toolkit); setup(toolkit, root); while (!Display.isCloseRequested()) { toolkit.update(root); GL11.glClear(GL11.GL_COLOR_BUFFER_BIT); renderer.render(root); Display.update(false); Display.sync(60); Display.processMessages(); Mouse.poll(); Keyboard.poll(); Controllers.poll(); } } catch (Throwable e) { handleError(e, "Unexpected error during execution\n"); } }
From source file:io.flob.blackheart.DisplayDriver.java
License:Open Source License
public void prepare() { GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT); }
From source file:io.flob.blackheart.Level.java
License:Open Source License
public void tick() throws Exception { if (display_list_dirty) { load_display_list();//from w ww .j a va 2 s . co m } ByteBuffer temp = ByteBuffer.allocateDirect(16); temp.order(ByteOrder.nativeOrder()); float fog_colour[] = new float[] { 0f, 0f, 0f, 0f }; GL11.glFogi(GL11.GL_FOG_MODE, GL11.GL_EXP); temp.asFloatBuffer().put(fog_colour).flip(); GL11.glFog(GL11.GL_FOG_COLOR, temp.asFloatBuffer()); GL11.glFogf(GL11.GL_FOG_DENSITY, 0.25f); GL11.glHint(GL11.GL_FOG_HINT, GL11.GL_DONT_CARE); GL11.glFogf(GL11.GL_FOG_START, 0); GL11.glFogf(GL11.GL_FOG_END, 200); _barry.tick(); try { Collections.sort(objects_dynamic, this.sort_objects); } catch (Exception ex) { Output.error(ex.getMessage()); } if (Debug.collision_boxs) { _game._core._display.flush_texture(); for (int count = 0; count < objects_static.size(); count++) { if (objects_static.get(count) instanceof ICollidable) { ICollidable objcet = (ICollidable) objects_static.get(count); objcet.collision_box().render(); } } for (int count = 0; count < objects_dynamic.size(); count++) { if (objects_dynamic.get(count) instanceof ICollidable) { ICollidable objcet = (ICollidable) objects_dynamic.get(count); objcet.collision_box().render(); } } _barry.collision_box().render(); _barry.ray_picker().collision_box().render(); } GL11.glPushMatrix(); _game._core._texture.game_atlas.bind(); if (_game.anaglyph()) { GL11.glTranslatef(1 * 0.03f, 0, 0); GL11.glColorMask(true, false, false, true); } GL11.glBegin(GL11.GL_QUADS); GL11.glCallList(display_list); for (int count = 0; count < objects_dynamic.size(); count++) { objects_dynamic.get(count).tick(); } GL11.glEnd(); if (_game.anaglyph()) { GL11.glClear(GL11.GL_DEPTH_BUFFER_BIT); GL11.glColorMask(false, true, true, true); GL11.glTranslatef(-1 * 0.03f, 0, 0); GL11.glBegin(GL11.GL_QUADS); GL11.glCallList(display_list); for (int count = 0; count < objects_dynamic.size(); count++) { objects_dynamic.get(count)._render(); } GL11.glEnd(); GL11.glColorMask(true, true, true, true); } GL11.glPopMatrix(); for (int count = 0; count < objects_dynamic.size(); count++) { if (objects_dynamic.get(count).IRemove()) { objects_dynamic.remove(count); } } _hud.tick(); if (_barry.health() <= 0) { _game._core.state(_game._core._game_dead); } }
From source file:io.root.gfx.glutils.GL.java
License:Apache License
public static void glClear(int mask) { GL11.glClear(mask); }
From source file:ion2d.INDirector.java
License:Open Source License
protected void update() { if (Display.isActive()) { calculateDeltaTime();//from www . j av a 2s .co m if (!this.isPaused) { //INScheduler.tick(this.deltaTime); } GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT); if (this.nextScene != null) { setNextScene(); } //INKeyboard.update(); //INMouse.update(); GL11.glPushMatrix(); this.enableDefaultGLStates(); this.runningScene.visit(); if (this.displayFPS) { this.renderFPS(); } this.disableDefaultGLStates(); GL11.glPopMatrix(); System.gc(); } INDisplay.update(); }