List of usage examples for org.lwjgl.opengl GL11 glOrtho
public static native void glOrtho(@NativeType("GLdouble") double l, @NativeType("GLdouble") double r, @NativeType("GLdouble") double b, @NativeType("GLdouble") double t, @NativeType("GLdouble") double n, @NativeType("GLdouble") double f);
(lb – n)T
and (rt – n)T
specify the points on the near clipping plane that are mapped to the lower left and upper right corners of the window, respectively (assuming that the eye is located at (0 0 0)T
). From source file:a1.Main.java
License:Open Source License
private void setView(int screenWidth, int screenHeight) { GL11.glViewport(0, 0, screenWidth, screenHeight); GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glLoadIdentity();//from ww w. j av a2s.c o m GL11.glOrtho(0, screenWidth, screenHeight, 0, -1, 1); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glLoadIdentity(); }
From source file:akarnokd.opengl.experiment.FontExample.java
License:Apache License
/** * Initialise the GL display//from w w w . java2s .c o m * * @param width The width of the display * @param height The height of the display */ private void initGL(int width, int height) { try { Display.setDisplayMode(new DisplayMode(width, height)); Display.create(); Display.setVSyncEnabled(true); } catch (LWJGLException e) { e.printStackTrace(); System.exit(0); } GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glShadeModel(GL11.GL_SMOOTH); GL11.glDisable(GL11.GL_DEPTH_TEST); GL11.glDisable(GL11.GL_LIGHTING); GL11.glClearColor(0.0f, 0.0f, 0.0f, 0.0f); GL11.glClearDepth(1); GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glViewport(0, 0, width, height); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glLoadIdentity(); GL11.glOrtho(0, width, height, 0, 1, -1); GL11.glMatrixMode(GL11.GL_MODELVIEW); }
From source file:aphelion.client.Client.java
License:Open Source License
public static void initGL() { int displayWidth = Display.getWidth(); int displayHeight = Display.getHeight(); glDisableAll();/*from w w w.j a va 2s.c o m*/ GL11.glViewport(0, 0, displayWidth, displayHeight); GL11.glMatrixMode(GL11.GL_PROJECTION); // Apply subsequent matrix operations to the projection matrix stack. GL11.glLoadIdentity(); GL11.glOrtho(0, displayWidth, displayHeight, 0, -1, 1); GL11.glMatrixMode(GL11.GL_TEXTURE); GL11.glLoadIdentity(); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glLoadIdentity(); GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_STENCIL_BUFFER_BIT); AsyncTexture.unbind(); // Enable alpha channels for images GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glEnable(GL11.GL_BLEND); Graph.g.setDimensions(displayWidth, displayHeight); Graphics.setCurrent(Graph.g); Graph.g.setDrawMode(Graphics.MODE_NORMAL); }
From source file:arg.RenderRecipe.java
License:Open Source License
public void draw() { File dir = new File(Minecraft.getMinecraft().mcDataDir, "recipes"); if (!dir.exists() && !dir.mkdirs()) { throw new RuntimeException("The recipes directory could not be created: " + dir); }/*from ww w. j a v a 2 s.c o m*/ name = name.replace(" ", ""); File file = new File(Minecraft.getMinecraft().mcDataDir, "recipes/" + name + ".png"); if (file.exists()) return; GL11.glPushMatrix(); GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS); GL11.glPushClientAttrib(GL11.GL_ALL_CLIENT_ATTRIB_BITS); GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT); GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glLoadIdentity(); GL11.glViewport(0, 0, width, height); GL11.glOrtho(0.0D, xSize, ySize, 0.0D, 1000.0D, 3000.0D); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glLoadIdentity(); GL11.glTranslatef(0.0F, 0.0F, -2000.0F); GL11.glLineWidth(1.0F); GL11.glEnable(GL11.GL_COLOR_MATERIAL); try { drawScreen(0, 0, 0); } catch (Exception e) { e.printStackTrace(); } int[] pixels = new int[width * height]; int bindex; ByteBuffer fb = ByteBuffer.allocateDirect(width * height * 3); GL11.glReadPixels(0, 0, width, height, GL11.GL_RGB, GL11.GL_UNSIGNED_BYTE, fb); GL11.glPopMatrix(); GL11.glPopAttrib(); GL11.glPopClientAttrib(); GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT); try { Display.swapBuffers(); } catch (LWJGLException e1) { e1.printStackTrace(); } BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); for (int x = 0; x < width; x++) { for (int y = 0; y < height; y++) { int i = (x + (width * y)) * 3; int r = fb.get(i) & 0xFF; int g = fb.get(i + 1) & 0xFF; int b = fb.get(i + 2) & 0xFF; image.setRGB(x, height - (y + 1), (0xFF << 24) | (r << 16) | (g << 8) | b); } } try { ImageIO.write(image, "png", file); } catch (Exception e) { e.printStackTrace(); } }
From source file:br.org.archimedes.gui.opengl.OpenGLWrapper.java
License:Open Source License
/** * Updates the window size in the workspace and resets the openGL * coordinates.//from w w w. j av a 2 s. c o m */ public void resize() { if (currentCanvas != null) { org.eclipse.swt.graphics.Rectangle rect = currentCanvas.getClientArea(); GL11.glOrtho(-rect.width / 2, rect.width / 2, -rect.height / 2, rect.height / 2, -1.0, 1.0); Rectangle window = new Rectangle(0, 0, rect.width, rect.height); GL11.glViewport(0, 0, rect.width, rect.height); br.org.archimedes.Utils.getWorkspace().setWindowSize(window); } }
From source file:cellularautomata.CellularAutomata.java
public static void renderGL() { try { //Trys to create a game window size 500x700. Display.setDisplayMode(new org.lwjgl.opengl.DisplayMode(800, 600)); Display.create();// ww w.j av a 2 s. com } catch (LWJGLException e) { //Catches exception if game window is not created. e.printStackTrace(); System.exit(0); } GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glShadeModel(GL11.GL_SMOOTH); GL11.glDisable(GL11.GL_DEPTH_TEST); GL11.glDisable(GL11.GL_LIGHTING); GL11.glClearColor(0.0f, 0.0f, 0.0f, 0.0f); //Sets colour to white. GL11.glClearDepth(1); GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glViewport(0, 0, 800, 600); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glLoadIdentity(); GL11.glOrtho(0, 800, 600, 0, 1, -1); GL11.glMatrixMode(GL11.GL_MODELVIEW); Display.setVSyncEnabled(vsync); }
From source file:colonialdisplay.AntDisplayGL.java
@Override protected void initGL() { Rectangle bounds = canvas.getClientArea(); GL11.glViewport(bounds.x, bounds.y, bounds.width, bounds.height); GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glLoadIdentity();/*w w w . j av a2 s.c o m*/ GL11.glOrtho(0, bounds.width, bounds.height, 0, 1, -1); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glLoadIdentity(); initTextures(); GL11.glClearColor(0.0f, 0.0f, 0.0f, 0.0f); createModel(); }
From source file:com.a2client.corex.Render.java
License:Open Source License
static public void set2D(int width, int height) { ResetBind();//w w w . j a v a2 s . com Clear(false, true); setBlendType(Const.BLEND_TYPE.btNormal); setDepthTest(false); setCullFace(Const.CULL_FACE.cfNone); GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glDisable(GL11.GL_LIGHTING); setDepthTest(false); GL11.glViewport(0, 0, width, height); GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glLoadIdentity(); GL11.glOrtho(0, width, height, 0, -1, 1); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glLoadIdentity(); }
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.ardor3d.renderer.lwjgl.LwjglRenderer.java
License:Open Source License
public void setOrtho() { if (_inOrthoMode) { throw new Ardor3dException("Already in Orthographic mode."); }/*from w w w.j a va2s.c om*/ // 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; }