List of usage examples for org.lwjgl.opengl GL11 glClear
public static void glClear(@NativeType("GLbitfield") int mask)
From source file:org.joge.core.draw.Graphics.java
License:Open Source License
protected void clear() { GL11.glClear(GL11.GL_COLOR_BUFFER_BIT); }
From source file:org.jtrfp.mtmx.tools.internal.ModelViewerConfiguration.java
License:Open Source License
@Override public void draw() { GL11.glClearColor(0.8f, 0.8f, 0.8f, 0.0f); GL11.glClear(GL11.GL_COLOR_BUFFER_BIT); GL11.glClear(GL11.GL_DEPTH_BUFFER_BIT); GL11.glLoadIdentity();//from ww w.java 2 s . c om GLU.gluLookAt(5.0f, 2.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f); GL11.glRotatef(rot, 0.0f, 1.0f, 0.0f); GL11.glRotatef(rot2, 1.0f, 0.0f, 0.0f); drawer.draw(); Keyboard.poll(); while (Keyboard.next()) { if (Keyboard.getEventKeyState()) { if (Keyboard.getEventKey() == Keyboard.KEY_ESCAPE) { return; } if (Keyboard.getEventKey() == Keyboard.KEY_RIGHT) { rot -= 15.0f; } if (Keyboard.getEventKey() == Keyboard.KEY_LEFT) { rot += 15.0f; } if (Keyboard.getEventKey() == Keyboard.KEY_UP) { rot2 -= 15.0f; } if (Keyboard.getEventKey() == Keyboard.KEY_DOWN) { rot2 += 15.0f; } if (Keyboard.getEventKey() == Keyboard.KEY_T) { if (renderMode == GL11.GL_POLYGON) { renderMode = GL11.GL_LINE_LOOP; } else { renderMode = GL11.GL_POLYGON; } } } } }
From source file:org.jtrfp.mtmx.tools.internal.TruckViewerConfiguration.java
License:Open Source License
@Override public void draw() { GL11.glClearColor(0.8f, 0.8f, 0.8f, 0.0f); GL11.glClear(GL11.GL_COLOR_BUFFER_BIT); GL11.glClear(GL11.GL_DEPTH_BUFFER_BIT); GL11.glLoadIdentity();/*from w w w . ja va 2 s . com*/ GLU.gluLookAt(5.0f, 2.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f); GL11.glRotatef(rot, 0.0f, 1.0f, 0.0f); GL11.glRotatef(rot2, 1.0f, 0.0f, 0.0f); truckDrawer.draw(); Keyboard.poll(); while (Keyboard.next()) { if (Keyboard.getEventKeyState()) { if (Keyboard.getEventKey() == Keyboard.KEY_ESCAPE) { return; } if (Keyboard.getEventKey() == Keyboard.KEY_RIGHT) { rot -= 15.0f; } if (Keyboard.getEventKey() == Keyboard.KEY_LEFT) { rot += 15.0f; } if (Keyboard.getEventKey() == Keyboard.KEY_UP) { rot2 -= 15.0f; } if (Keyboard.getEventKey() == Keyboard.KEY_DOWN) { rot2 += 15.0f; } if (Keyboard.getEventKey() == Keyboard.KEY_A) { truckDrawer.setSteerAngle(truckDrawer.getSteerAngle() + 0.1f); } if (Keyboard.getEventKey() == Keyboard.KEY_D) { truckDrawer.setSteerAngle(truckDrawer.getSteerAngle() - 0.1f); } if (Keyboard.getEventKey() == Keyboard.KEY_T) { if (truckDrawer.getRenderMode() == GL11.GL_POLYGON) { truckDrawer.setRenderMode(GL11.GL_LINE_LOOP); } else { truckDrawer.setRenderMode(GL11.GL_POLYGON); } } } } }
From source file:org.jtrfp.mtmx.tools.internal.WorldViewerConfiguration.java
License:Open Source License
@Override public void draw() { GL11.glClearColor(0.8f, 0.8f, 0.8f, 0.0f); GL11.glClear(GL11.GL_COLOR_BUFFER_BIT); GL11.glClear(GL11.GL_DEPTH_BUFFER_BIT); GL11.glLoadIdentity();//from w w w . j a v a2s . co m float e = terrainDrawer.getTerrainMap().getElevationAt(1, 1) * IDrawer.WORLD_SCALE_XZ; GLU.gluLookAt(-1.0f + lookX * IDrawer.WORLD_SCALE_XZ, 1.0f + e, -1.0f + lookZ * IDrawer.WORLD_SCALE_XZ, 0.0f + lookX * IDrawer.WORLD_SCALE_XZ, 0.0f + e, 0.0f + lookZ * IDrawer.WORLD_SCALE_XZ, 0.0f, 1.0f, 0.0f); GL11.glColor3f(0.0f, 1.0f, 0.0f); terrainDrawer.draw(); Keyboard.poll(); while (Keyboard.next()) { if (Keyboard.getEventKeyState()) { if (Keyboard.getEventKey() == Keyboard.KEY_ESCAPE) { return; } if (Keyboard.getEventKey() == Keyboard.KEY_RIGHT) { lookX -= 5; } if (Keyboard.getEventKey() == Keyboard.KEY_LEFT) { lookX += 5; } if (Keyboard.getEventKey() == Keyboard.KEY_UP) { lookZ += 5; } if (Keyboard.getEventKey() == Keyboard.KEY_DOWN) { lookZ -= 5; } if (Keyboard.getEventKey() == Keyboard.KEY_T) { if (terrainDrawer.getRenderMode() == GL11.GL_TRIANGLES) { terrainDrawer.setRenderMode(GL11.GL_LINE_LOOP); } else { terrainDrawer.setRenderMode(GL11.GL_TRIANGLES); } } } } }
From source file:org.lwjgl.info.LWJGLTestView.java
License:Open Source License
Runnable initRunnable() { return new Runnable() { int rot = 0; public void run() { if (!canvas.isDisposed() && canvas.isVisible()) { fpsstatuslineitem.renderPassStarted(); canvas.setCurrent();/*from w w w. ja v a 2 s . c o m*/ try { GLContext.useContext(canvas); } catch (LWJGLException e) { e.printStackTrace(); } GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT); GL11.glClearColor(.2f, .7f, .2f, 1.0f); GL11.glLoadIdentity(); GL11.glTranslatef(0.0f, 0.0f, -10.0f); float frot = rot; GL11.glRotatef(0.15f * rot, 2.0f * frot, 10.0f * frot, 1.0f); GL11.glRotatef(0.3f * rot, 3.0f * frot, 1.0f * frot, 1.0f); rot++; GL11.glPolygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_LINE); GL11.glColor3f(0.9f, 0.9f, 0.9f); drawTorus(1, 1.9f + ((float) Math.sin((0.004f * frot))), 15, 15); canvas.swapBuffers(); fpsstatuslineitem.renderPassFinished(); Display.getCurrent().asyncExec(this); } } }; }
From source file:org.minetweak.world.characters.Player.java
License:Apache License
@Override public void render() { GL11.glEnable(GL11.GL_DEPTH_TEST);/* w w w.j a v a 2s . co m*/ GL11.glDepthFunc(GL11.GL_LEQUAL); GL11.glEnable(GL11.GL_BLEND); GL11.glClear(GL11.GL_DEPTH_BUFFER_BIT); if (_aimedBlockPosition.y() != -1) { GL11.glClear(GL11.GL_DEPTH_BUFFER_BIT); GL11.glDisable(GL11.GL_TEXTURE_2D); _aimedBlockAABB.render(0.0f, 0.0f, 0.0f, 0.1f); GL11.glEnable(GL11.GL_TEXTURE_2D); } if (_selectedItem != null) { GL11.glPushMatrix(); GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glDisable(GL11.GL_CULL_FACE); _body.transformToRightHand(); /* Prepare the light buffer */ Chunk c = Game.getInstance().getWorld().getChunkManager().getChunkContaining( MathHelper.floor(_position.x()), MathHelper.floor(_position.y()) + 1, MathHelper.floor(_position.z()), false, false, false); if (c != null) { c.getLightBuffer().setReferencePoint(MathHelper.floor(_position.x()), MathHelper.floor(_position.y()) + 1, MathHelper.floor(_position.z())); /* Render the object, with the lightbuffer */ _selectedItem.renderHoldableObject(c.getLightBuffer()); } GL11.glEnable(GL11.GL_CULL_FACE); GL11.glPopMatrix(); } GL11.glDisable(GL11.GL_DEPTH_TEST); }
From source file:org.mkdev.ai.langton3d.core.App.java
License:GNU General Public License
private void render() { 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 .co m*/ drawBackground(); GL11.glPushMatrix(); Camera.applyRotation(); drawWireframeCube(); GL11.glTranslatef(-1.5f, -1.5f, -1.5f); drawSceneCubes(); GL11.glPopMatrix(); dt = getDeltaTime(); }
From source file:org.ode4j.drawstuff.internal.DrawStuffGL.java
License:Open Source License
@Override // void dsDrawFrame (int width, int height, dsFunctions *fn, int pause) void dsDrawFrame(int width, int height, dsFunctions fn, boolean pause) { if (current_state < 1) dsDebug("internal error"); current_state = 2;//from www . j av a 2 s .co m // setup stuff GL11.glEnable(GL11.GL_LIGHTING); GL11.glEnable(GL11.GL_LIGHT0); GL11.glDisable(GL11.GL_TEXTURE_2D); GL11.glDisable(GL11.GL_TEXTURE_GEN_S); GL11.glDisable(GL11.GL_TEXTURE_GEN_T); GL11.glShadeModel(GL11.GL_FLAT); GL11.glEnable(GL11.GL_DEPTH_TEST); GL11.glDepthFunc(GL11.GL_LESS); GL11.glEnable(GL11.GL_CULL_FACE); GL11.glCullFace(GL11.GL_BACK); GL11.glFrontFace(GL11.GL_CCW); // setup viewport GL11.glViewport(0, 0, width, height); GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glLoadIdentity(); final float vnear = 0.1f; final float vfar = 100.0f; final float k = 0.8f; // view scale, 1 = +/- 45 degrees if (width >= height) { float k2 = (float) height / (float) width; GL11.glFrustum(-vnear * k, vnear * k, -vnear * k * k2, vnear * k * k2, vnear, vfar); } else { float k2 = (float) width / (float) height; GL11.glFrustum(-vnear * k * k2, vnear * k * k2, -vnear * k, vnear * k, vnear, vfar); } // setup lights. it makes a difference whether this is done in the // GL_PROJECTION matrix mode (lights are scene relative) or the // GL_MODELVIEW matrix mode (lights are camera relative, bad!). // static GLfloat light_ambient[] = { 0.5, 0.5, 0.5, 1.0 }; // static GLfloat light_diffuse[] = { 1.0, 1.0, 1.0, 1.0 }; // static GLfloat light_specular[] = { 1.0, 1.0, 1.0, 1.0 }; GL11.glLight(GL11.GL_LIGHT0, GL11.GL_AMBIENT, light_ambient); GL11.glLight(GL11.GL_LIGHT0, GL11.GL_DIFFUSE, light_diffuse); GL11.glLight(GL11.GL_LIGHT0, GL11.GL_SPECULAR, light_specular); GL11.glColor3f(1.0f, 1.0f, 1.0f); // clear the window GL11.glClearColor(0.5f, 0.5f, 0.5f, 0); GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT); // snapshot camera position (in MS Windows it is changed by the GUI thread) float[] view2_xyz = view_xyz.clone(); float[] view2_rxyz = view_rxyz.clone(); // memcpy (view2_xyz,view_xyz);//,sizeof(float)*3); // memcpy (view2_hpr,view_hpr);//,sizeof(float)*3); // go to GL_MODELVIEW matrix mode and set the camera GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glLoadIdentity(); setCamera(view2_xyz[0], view2_xyz[1], view2_xyz[2], view2_rxyz[0], view2_rxyz[1], view2_rxyz[2]); // set the light position (for some reason we have to do this in model view. // static GLfloat light_position[] = { LIGHTX, LIGHTY, 1.0, 0.0 }; GL11.glLight(GL11.GL_LIGHT0, GL11.GL_POSITION, light_position); // draw the background (ground, sky etc) drawSky(view2_xyz); drawGround(); // draw the little markers on the ground drawPyramidGrid(); // leave openGL in a known state - flat shaded white, no textures GL11.glEnable(GL11.GL_LIGHTING); GL11.glDisable(GL11.GL_TEXTURE_2D); GL11.glShadeModel(GL11.GL_FLAT); GL11.glEnable(GL11.GL_DEPTH_TEST); GL11.glDepthFunc(GL11.GL_LESS); GL11.glColor3f(1, 1, 1); setColor(1, 1, 1, 1); // draw the rest of the objects. set drawing state first. color[0] = 1; color[1] = 1; color[2] = 1; color[3] = 1; tnum = DS_TEXTURE_NUMBER.DS_NONE; //if (fn.step) fn.step(pause); }
From source file:org.ode4j.drawstuff.internal.LwJGL.java
License:Open Source License
@Override void dsPlatformSimLoop(int window_width, int window_height, dsFunctions fn, boolean initial_pause) { pause = initial_pause;// w ww . j ava2 s . c o m createMainWindow(window_width, window_height); //glXMakeCurrent (display,win,glx_context); //TODO ? //GLContext.useContext(context); try { //Sets the context / by TZ Display.makeCurrent(); } catch (LWJGLException e) { throw new RuntimeException(e); } dsStartGraphics(window_width, window_height, fn); //TZ static bool firsttime=true; if (firsttime) { System.err.println(); System.err.print("Using ode4j version: " + OdeHelper.getVersion()); System.err.println(" [" + OdeHelper.getConfiguration() + "]"); System.err.println(); fprintf(stderr, "\n" + "Simulation test environment v%d.%02d\n" + " Ctrl-P : pause / unpause (or say `-pause' on command line).\n" + " Ctrl-O : single step when paused.\n" + " Ctrl-T : toggle textures (or say `-notex' on command line).\n" + " Ctrl-S : toggle shadows (or say `-noshadow' on command line).\n" + " Ctrl-V : print current viewpoint coordinates (x,y,z,h,p,r).\n" + " Ctrl-W : write frames to ppm files: frame/frameNNN.ppm\n" + " Ctrl-X : exit.\n" + "\n" + "Change the camera position by clicking + dragging in the window.\n" + " Left button - pan and tilt.\n" + " Right button - forward and sideways.\n" + " Left + Right button (or middle button) - sideways and up.\n" + "\n", DrawStuff.DS_VERSION >> 8, DrawStuff.DS_VERSION & 0xff); firsttime = false; } //if (fn.start) fn.start(); int frame = 1; run = true; long startTime = System.currentTimeMillis() + 5000; long fps = 0; while (run && !Display.isCloseRequested()) { // while (run) { // read in and process all pending events for the main window // XEvent event; // while (run && XPending (display)) { // XNextEvent (display,event); // handleEvent (event,fn); // } handleKeyboard(fn); handleMouse(); //processDrawFrame: This was not move into separate method for convenience GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT); dsDrawFrame(width, height, fn, pause && !singlestep); singlestep = false; Display.update(); if (startTime > System.currentTimeMillis()) { fps++; } else { long timeUsed = 5000 + (startTime - System.currentTimeMillis()); startTime = System.currentTimeMillis() + 5000; System.out.println( fps + " frames in " + (timeUsed / 1000f) + " seconds = " + (fps / (timeUsed / 1000f))); fps = 0; } // glFlush(); // glXSwapBuffers (display,win); // XSync (display,0); // capture frames if necessary if (pause == false && writeframes) { captureFrame(frame); frame++; } } //if (fn.stop) fn.stop(); dsStopGraphics(); destroyMainWindow(); }
From source file:org.oscim.gdx.LwjglGL20.java
License:Apache License
public void clear(int mask) { GL11.glClear(mask); }