List of usage examples for org.lwjgl.opengl GL11 glLoadIdentity
public static native void glLoadIdentity();
From source file:com.a2client.utils3d.SceneCombi.java
License:Open Source License
public void Switch2D(boolean forced, boolean need_rescale) { if (forced || !is_2d_switched) { Render.set2D(Config.getScreenWidth(), Config.getScreenHeight()); GL11.glLoadIdentity(); if (need_rescale) GL11.glScalef(scale, scale, 1f); // ?? /* w ww . ja va 2 s .co m*/ node = null; is_2d_switched = true; } }
From source file:com.acornui.jvm.LwjglHelloWorld.java
License:Apache License
private void initMatrices() { GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glLoadIdentity(); GL11.glOrtho(0, 800, 0, 600, 1, -1); GL11.glMatrixMode(GL11.GL_MODELVIEW); }
From source file:com.aelitis.azureus.plugins.view3d.ViewTest2.java
License:Open Source License
static void accFrustum(double left, double right, double bottom, double top, double near, double far, double pixdx, double pixdy, double eyedx, double eyedy, double focus) { double xwsize, ywsize; double dx, dy; int[] viewport = getViewport(); xwsize = right - left;//from w w w . j av a2s .c o m ywsize = top - bottom; dx = -(pixdx * xwsize / (double) viewport[2] + eyedx * near / focus); dy = -(pixdy * ywsize / (double) viewport[3] + eyedy * near / focus); GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glLoadIdentity(); GL11.glFrustum(left + dx, right + dx, bottom + dy, top + dy, near, far); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glLoadIdentity(); GL11.glTranslated(-eyedx, -eyedy, 0.0); }
From source file:com.aelitis.azureus.plugins.view3d.ViewTest2.java
License:Open Source License
public static void main(String[] args) { final Display display = new Display(); Shell shell = new Shell(display); shell.setLayout(new FillLayout()); Composite comp = new Composite(shell, SWT.NONE); comp.setLayout(new FillLayout()); GLData data = new GLData(); data.doubleBuffer = true;/*from w ww .j a v a 2s . co m*/ data.accumAlphaSize = 8; data.accumBlueSize = 8; data.accumGreenSize = 8; data.accumRedSize = 8; final GLCanvas canvas = new GLCanvas(comp, SWT.NONE, data); canvas.setCurrent(); try { GLContext.useContext(canvas); } catch (LWJGLException e) { e.printStackTrace(); } canvas.addListener(SWT.Resize, new Listener() { public void handleEvent(Event event) { Rectangle bounds = canvas.getBounds(); float fAspect = (float) bounds.width / (float) bounds.height; canvas.setCurrent(); try { GLContext.useContext(canvas); } catch (LWJGLException e) { e.printStackTrace(); } GL11.glViewport(0, 0, bounds.width, bounds.height); GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glLoadIdentity(); GLU.gluPerspective(45.0f, fAspect, 0.5f, 400.0f); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glLoadIdentity(); } }); GL11.glLineWidth(1); GL11.glHint(GL11.GL_LINE_SMOOTH_HINT, GL11.GL_NICEST); GL11.glEnable(GL11.GL_LINE_SMOOTH); GL11.glEnable(GL11.GL_BLEND); GL11.glHint(GL11.GL_PERSPECTIVE_CORRECTION_HINT, GL11.GL_NICEST); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glClearColor(1.0f, 1.0f, 1.0f, 1.0f); GL11.glColor3f(1.0f, 0.0f, 0.0f); GL11.glHint(GL11.GL_PERSPECTIVE_CORRECTION_HINT, GL11.GL_NICEST); GL11.glClearDepth(1.0); GL11.glLineWidth(2); GL11.glEnable(GL11.GL_DEPTH_TEST); GL11.glShadeModel(GL11.GL_FLAT); GL11.glClearColor(0.0f, 0.0f, 0.0f, 0.0f); GL11.glClearAccum(0.0f, 0.0f, 0.0f, 0.0f); shell.setText("SWT/LWJGL Example"); shell.setSize(640, 480); shell.open(); final Runnable run = new Runnable() { float rot = 0; public void run() { if (!canvas.isDisposed()) { canvas.setCurrent(); try { GLContext.useContext(canvas); } catch (LWJGLException e) { e.printStackTrace(); } int ACSIZE = 8; int[] viewport = getViewport(); GL11.glClear(GL11.GL_ACCUM_BUFFER_BIT); for (int jitter = 0; jitter < ACSIZE; jitter++) { GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT); double jit_x = jits[jitter][0]; double jit_y = jits[jitter][1]; accPerspective(50.0, (double) viewport[2] / (double) viewport[3], 1.0, 15.0, jit_x, jit_y, 0.0, 0.0, 1.0); { GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT); GL11.glClearColor(.3f, .5f, .8f, 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); GL11.glPolygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_FILL); GL11.glColor3f(0.9f, 0.9f, 0.9f); drawCylinder(2, 3, 50, 0); drawTorus(1, 1.9f + ((float) Math.sin((0.004f * frot))), 15, 15); } GL11.glAccum(GL11.GL_ACCUM, 1.0f / ACSIZE); } GL11.glAccum(GL11.GL_RETURN, 1.0f); GL11.glFlush(); rot += 0.1; canvas.swapBuffers(); display.asyncExec(this); } } }; canvas.addListener(SWT.Paint, new Listener() { public void handleEvent(Event event) { run.run(); } }); display.asyncExec(run); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:com.ardor3d.renderer.lwjgl.LwjglFont.java
License:Open Source License
/** * <code>print</code> renders the specified string to a given (x,y) location. The x, y location is in terms of * screen coordinates. There are currently two sets of fonts supported: NORMAL and ITALICS. * //from w w w .j a v a 2 s . c o m * @param r * * @param x * the x screen location to start the string render. * @param y * the y screen location to start the string render. * @param text * the String to render. * @param set * the mode of font: NORMAL or ITALICS. */ public void print(final Renderer r, final double x, final double y, final ReadOnlyVector3 scale, final StringBuffer text, int set) { final RendererRecord matRecord = ContextManager.getCurrentContext().getRendererRecord(); if (set > 1) { set = 1; } else if (set < 0) { set = 0; } final boolean alreadyOrtho = r.isInOrthoMode(); if (!alreadyOrtho) { r.setOrtho(); } else { LwjglRendererUtil.switchMode(matRecord, GL11.GL_MODELVIEW); GL11.glPushMatrix(); GL11.glLoadIdentity(); } GL11.glTranslated(x, y, 0); GL11.glScaled(scale.getX(), scale.getY(), scale.getZ()); GL11.glListBase(base - 32 + (128 * set)); // Put the string into a "pointer" if (text.length() > scratch.capacity()) { scratch = BufferUtils.createByteBuffer(text.length()); } else { scratch.clear(); } final int charLen = text.length(); for (int z = 0; z < charLen; z++) { scratch.put((byte) text.charAt(z)); } scratch.flip(); GL11.glColor4f(fontColor.getRed(), fontColor.getGreen(), fontColor.getBlue(), fontColor.getAlpha()); // call the list for each letter in the string. GL11.glCallLists(scratch); // set color back to white GL11.glColor4f(1, 1, 1, 1); if (!alreadyOrtho) { r.unsetOrtho(); } else { LwjglRendererUtil.switchMode(matRecord, GL11.GL_MODELVIEW); GL11.glPopMatrix(); } }
From source file:com.ardor3d.renderer.lwjgl.LwjglRenderer.java
License:Open Source License
public void setOrtho() { if (_inOrthoMode) { throw new Ardor3dException("Already in Orthographic mode."); }// w w w. j av a 2 s. com // set up ortho mode final RendererRecord matRecord = ContextManager.getCurrentContext().getRendererRecord(); LwjglRendererUtil.switchMode(matRecord, GL11.GL_PROJECTION); GL11.glPushMatrix(); GL11.glLoadIdentity(); final Camera camera = Camera.getCurrentCamera(); final double viewportWidth = camera.getWidth() * (camera.getViewPortRight() - camera.getViewPortLeft()); final double viewportHeight = camera.getHeight() * (camera.getViewPortTop() - camera.getViewPortBottom()); GL11.glOrtho(0, viewportWidth, 0, viewportHeight, -1, 1); LwjglRendererUtil.switchMode(matRecord, GL11.GL_MODELVIEW); GL11.glPushMatrix(); GL11.glLoadIdentity(); _inOrthoMode = true; }
From source file:com.ardor3d.scene.state.lwjgl.LwjglTextureStateUtil.java
License:Open Source License
public static void applyTextureTransforms(final Texture texture, final int unit, final TextureStateRecord record, final ContextCapabilities caps) { final boolean needsReset = !record.units[unit].identityMatrix; // Should we apply the transform? final boolean doTrans = !texture.getTextureMatrix().isIdentity(); // Now do them. final RendererRecord matRecord = ContextManager.getCurrentContext().getRendererRecord(); if (doTrans) { checkAndSetUnit(unit, record, caps); LwjglRendererUtil.switchMode(matRecord, GL11.GL_TEXTURE); record.tmp_matrixBuffer.rewind(); texture.getTextureMatrix().toDoubleBuffer(record.tmp_matrixBuffer, true); record.tmp_matrixBuffer.rewind(); GL11.glLoadMatrix(record.tmp_matrixBuffer); record.units[unit].identityMatrix = false; } else if (needsReset) { checkAndSetUnit(unit, record, caps); LwjglRendererUtil.switchMode(matRecord, GL11.GL_TEXTURE); GL11.glLoadIdentity(); record.units[unit].identityMatrix = true; }// w w w .j a va 2 s . c om // Switch back to the modelview matrix for further operations LwjglRendererUtil.switchMode(matRecord, GL11.GL_MODELVIEW); }
From source file:com.badlogic.gdx.backends.lwjgl.LwjglGL10.java
License:Apache License
public final void glLoadIdentity() { GL11.glLoadIdentity(); }
From source file:com.dbi.games.fortress.engine.MainEngine.java
License:Open Source License
/** * Should ONLY be invoked from the GL thread! *///from w ww . jav a 2s . c o m public void renderScene(long deltaNanos) { if (!isReady) return; currentTickLengthNanos += deltaNanos; nanosSinceStatsUpdate += deltaNanos; framesSinceStatsUpdate++; if (currentTickLengthNanos >= targetTickLengthNanos) { tick(); } GL11.glClear(GL11.GL_COLOR_BUFFER_BIT); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glLoadIdentity(); graphicsEngine.renderMap(currentMap); for (Entity ent : entityEngine.findAll()) { graphicsEngine.renderEntity(ent); } if (nanosSinceStatsUpdate > NANOS_PER_STAT_UPDATE) { controlWindow.setFPS(framesSinceStatsUpdate * 4); controlWindow.setTPS(ticksSinceStatsUpdate * 4, ticksPerSecondTarget); framesSinceStatsUpdate = 0; ticksSinceStatsUpdate = 0; nanosSinceStatsUpdate = 0; } }
From source file:com.dbi.games.fortress.ui.MainAppWindow.java
License:Open Source License
/** * Creates new form MainAppWin//from w ww .ja v a 2 s . co m */ public MainAppWindow() { initComponents(); glCanvas.addComponentListener(new ComponentListener() { public void componentShown(ComponentEvent e) { setNeedValidation(); } public void componentResized(ComponentEvent e) { setNeedValidation(); } public void componentMoved(ComponentEvent e) { setNeedValidation(); } public void componentHidden(ComponentEvent e) { setNeedValidation(); } }); File currentDir = new File("lib/natives"); if (!currentDir.exists()) { // JOptionPane.showMessageDialog(null, "directory location: "+currentDir.getAbsolutePath()+" does not exist!"); currentDir = new File("build/libs/natives"); } Logger.getLogger("LWJGLThread").log(Level.INFO, "LWJGL directory is " + currentDir.getAbsolutePath()); System.setProperty("org.lwjgl.librarypath", currentDir.getAbsolutePath()); Thread glThread = new Thread("GLThread") { @Override public void run() { long lastFrame = System.nanoTime(); long currentFrame; try { Display.setParent(glCanvas); Display.create(); GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glDisable(GL11.GL_DEPTH_TEST); GL11.glClearColor(0f, 0f, 0f, 0f); GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glLoadIdentity(); GL11.glOrtho(0f, (float) glCanvas.getWidth(), (float) glCanvas.getHeight(), 0f, -1, 1); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glLoadIdentity(); GL11.glViewport(0, 0, glCanvas.getWidth(), glCanvas.getHeight()); MainEngine.get().graphicsEngine().buildDefaultRenderers(); while (MainEngine.get().isRunning()) { try { currentFrame = System.nanoTime(); MainEngine.get().renderScene(currentFrame - lastFrame); lastFrame = currentFrame; Display.update(); if (needUpdateViewport) { needUpdateViewport = false; GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glLoadIdentity(); GL11.glOrtho(0, glCanvas.getWidth(), glCanvas.getHeight(), 0, -1, 1); GL11.glViewport(0, 0, glCanvas.getWidth(), glCanvas.getHeight()); } } catch (Throwable ex) { ex.printStackTrace(); Logger.getLogger("LWJGLThread").log(Level.SEVERE, "There was a SEROUS uncaught error in the render thread. Shutting down. Please restart!", ex); MainEngine.get().shutdown(); } } } catch (Throwable ex) { throw new RuntimeException("There was an issue starting LWJGL!", ex); } } }; glThread.start(); }