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:com.ogrekill.Engine.java
public static void initDisplay() { try {//from w w w . ja va2 s .c o m Display.setDisplayMode(new DisplayMode(800, 600)); Display.create(); } catch (LWJGLException e) { System.exit(0); } //init OpenGL GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glLoadIdentity(); GL11.glOrtho(0, 800, 0, 600, 1, -1); GL11.glMatrixMode(GL11.GL_MODELVIEW); while (!Display.isCloseRequested()) { Display.update(); } Display.destroy(); }
From source file:com.pahimar.ee3.core.handlers.TransmutationTargetOverlayHandler.java
License:LGPL
private static void renderStoneHUD(Minecraft minecraft, EntityPlayer player, ItemStack stack, float partialTicks) { float overlayScale = ConfigurationSettings.TARGET_BLOCK_OVERLAY_SCALE; float blockScale = overlayScale / 2; float overlayOpacity = ConfigurationSettings.TARGET_BLOCK_OVERLAY_OPACITY; GL11.glPushMatrix();/*from w w w . j a va 2 s .c o m*/ ScaledResolution sr = new ScaledResolution(minecraft.gameSettings, minecraft.displayWidth, minecraft.displayHeight); GL11.glClear(256); GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glLoadIdentity(); GL11.glOrtho(0.0D, sr.getScaledWidth_double(), sr.getScaledHeight_double(), 0.0D, 1000.0D, 3000.0D); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glLoadIdentity(); GL11.glTranslatef(0.0F, 0.0F, -2000.0F); GL11.glPushMatrix(); RenderHelper.enableGUIStandardItemLighting(); GL11.glDisable(GL11.GL_LIGHTING); GL11.glEnable(GL12.GL_RESCALE_NORMAL); GL11.glEnable(GL11.GL_COLOR_MATERIAL); GL11.glEnable(GL11.GL_LIGHTING); int hudOverlayX = 0; int hudOverlayY = 0; int hudBlockX = 0; int hudBlockY = 0; switch (ConfigurationSettings.TARGET_BLOCK_OVERLAY_POSITION) { case 0: { hudOverlayX = 0; hudBlockX = (int) (16 * overlayScale / 2 - 8); hudOverlayY = 0; hudBlockY = (int) (16 * overlayScale / 2 - 8); break; } case 1: { hudOverlayX = (int) (sr.getScaledWidth() - 16 * overlayScale); hudBlockX = (int) (sr.getScaledWidth() - 16 * overlayScale / 2 - 8); hudOverlayY = 0; hudBlockY = (int) (16 * overlayScale / 2 - 8); break; } case 2: { hudOverlayX = 0; hudBlockX = (int) (16 * overlayScale / 2 - 8); hudOverlayY = (int) (sr.getScaledHeight() - 16 * overlayScale); hudBlockY = (int) (sr.getScaledHeight() - 16 * overlayScale / 2 - 8); break; } case 3: { hudOverlayX = (int) (sr.getScaledWidth() - 16 * overlayScale); hudBlockX = (int) (sr.getScaledWidth() - 16 * overlayScale / 2 - 8); hudOverlayY = (int) (sr.getScaledHeight() - 16 * overlayScale); hudBlockY = (int) (sr.getScaledHeight() - 16 * overlayScale / 2 - 8); break; } default: { break; } } RenderUtils.renderItemIntoGUI(minecraft.fontRenderer, minecraft.renderEngine, stack, hudOverlayX, hudOverlayY, overlayOpacity, overlayScale); if (TransmutationHelper.targetBlockStack != null && TransmutationHelper.targetBlockStack.getItem() instanceof ItemBlock) { RenderUtils.renderRotatingBlockIntoGUI(minecraft.fontRenderer, minecraft.renderEngine, TransmutationHelper.targetBlockStack, hudBlockX, hudBlockY, -90, blockScale); } GL11.glDisable(GL11.GL_LIGHTING); GL11.glPopMatrix(); GL11.glPopMatrix(); }
From source file:com.runescape.client.revised.editor.modelviewer.Viewport.java
License:Open Source License
public void render() { final Dimension size = this.canvas.getSize(); if ((size.width > 0) && (size.height > 0)) { if ((this.width != size.width) || (this.height != size.height)) { this.width = size.width; this.height = size.height; GL11.glViewport(0, 0, this.width, this.height); GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glLoadIdentity();/* w ww. j a va2 s.c o m*/ final float c = (float) Math .sqrt((double) (this.width * this.width) + (double) (this.height * this.height)); GL11.glOrtho(0.0F, this.width, 0.0F, this.height, -c, c); GL11.glMatrixMode(GL11.GL_MODELVIEW); final boolean useShader = this.initShader(); if (ModelConstants.ENABLE_VERTEX_SHADER && useShader) { ARBShaderObjects.glUseProgramObjectARB(this.program); } if (ModelConstants.ENABLE_LIGHTING) { GL11.glEnable(GL11.GL_LIGHTING); GL11.glEnable(GL11.GL_LIGHT0); final FloatBuffer diffuse = BufferUtils.createFloatBuffer(4) .put(new float[] { 1F, 1F, 1F, 1F }); final FloatBuffer position = BufferUtils.createFloatBuffer(4) .put(new float[] { 3F, 0F, 1F, 0F }); final FloatBuffer ambient = BufferUtils.createFloatBuffer(4) .put(new float[] { .1F, .1F, .2F, .3F }); final FloatBuffer specular = BufferUtils.createFloatBuffer(4) .put(new float[] { 1F, 1F, 1F, 1F }); GL11.glMaterial(GL11.GL_FRONT, GL11.GL_SPECULAR, (FloatBuffer) specular.flip()); GL11.glLight(GL11.GL_LIGHT0, GL11.GL_AMBIENT, (FloatBuffer) ambient.flip()); GL11.glLight(GL11.GL_LIGHT0, GL11.GL_DIFFUSE, (FloatBuffer) diffuse.flip()); GL11.glLight(GL11.GL_LIGHT0, GL11.GL_POSITION, (FloatBuffer) position.flip()); GL11.glMaterialf(GL11.GL_FRONT, GL11.GL_SHININESS, 50.0f); } } if (Mouse.isButtonDown(0) && !Mouse.isButtonDown(1)) { this.yaw -= Mouse.getDX(); this.pitch -= Mouse.getDY(); } if (Mouse.isButtonDown(0) && Mouse.isButtonDown(1)) { this.offset_z += Mouse.getDY(); } float wheel = Mouse.getDWheel() / 960.0F; if (wheel > 1.0F) { wheel = 1.0F; } else if (wheel < -1.0F) { wheel = -1.0F; } this.scale -= this.scale * wheel; if (this.scale < 0.01F) { this.scale = 0.01F; } for (final Model3D dragonModel : this.getDragonList()) { final float x = this.width / 1.2F; final float y = (-((100.0F * (this.scale))) + (this.offset_z + 0.1F)) + ((this.height - dragonModel.height()) / 2.0F); final float z = 0.0F; dragonModel.calcDimms(false); dragonModel.render(x, y, z, this.pitch, this.yaw, this.roll, this.scale, this.scale, this.scale); } for (final Model3D torvaModel : this.getTorvaList()) { final float x = this.width / 1.7F; final float y = (-((100.0F * (this.scale))) + this.offset_z) + ((this.height - torvaModel.height()) / 2.0F); final float z = 0.0F; torvaModel.calcDimms(false); torvaModel.render(x, y, z, this.pitch, this.yaw, this.roll, this.scale, this.scale, this.scale); } for (final Model3D jadModel : this.getJadList()) { final float x = this.width / 3.2F; final float y = (-((100.0F * (this.scale))) + this.offset_z) + ((this.height - jadModel.height()) / 2.0F); final float z = 0.0F; jadModel.calcDimms(false); jadModel.render(x, y, z, this.pitch, this.yaw, this.roll, this.scale, this.scale, this.scale); } for (final Model3D trollModel : this.getTrollList()) { final float x = this.width / 3.8F; final float y = (-((100.0F * (this.scale))) + this.offset_z) + ((this.height - trollModel.height()) / 2.0F); final float z = 0.0F; trollModel.calcDimms(false); trollModel.render(x, y, z, this.pitch, this.yaw, this.roll, this.scale, this.scale, this.scale); } if (ModelConstants.ENABLE_VERTEX_SHADER && this.initShader()) { ARBShaderObjects.glUseProgramObjectARB(0); } Display.update(); } }
From source file:com.rvantwisk.cnctools.opengl.View2D.java
License:Open Source License
@Override public void begin() { GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glPushMatrix();/*from w w w . j av a2s. c om*/ GL11.glLoadIdentity(); GL11.glOrtho(0, camera.getWidth(), 0, camera.getHeight(), NEAR, FAR); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glPushMatrix(); GL11.glLoadIdentity(); }
From source file:com.rvantwisk.cnctools.opengl.View2D.java
License:Open Source License
@Override public void display_transform() { // _center_on_origin GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glLoadIdentity();// w w w . j a va2 s . c o m GL11.glOrtho(-camera.getX(), camera.getX(), -camera.getY(), camera.getY(), NEAR, FAR); GL11.glMatrixMode(GL11.GL_MODELVIEW); // _center_on_origin GL11.glTranslatef(camera.getX(), camera.getY(), camera.getZ()); GL11.glRotatef(camera.getAzimuth(), 0.0f, 0.0f, 1.0f); GL11.glScalef(camera.getZoom_factor(), camera.getZoom_factor(), camera.getZoom_factor()); }
From source file:com.rvantwisk.cnctools.opengl.View3D.java
License:Open Source License
@Override public void begin() { GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glPushMatrix();/*from w ww . j a v a 2 s. co m*/ GL11.glLoadIdentity(); if (camera.isOrtho()) { GL11.glOrtho(-camera.getX(), camera.getX(), -camera.getY(), camera.getY(), -NEAR, FAR); } else { GLU.gluPerspective(camera.getFOVY(), camera.getWidth() / camera.getHeight(), NEAR, FAR); } GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glPushMatrix(); GL11.glLoadIdentity(); }
From source file:com.samrj.devil.graphics.Camera2D.java
public static void glLoadScreen(int resX, int resY) { GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glLoadIdentity();/*from w w w .j a va 2s. c o m*/ GL11.glOrtho(0f, resX, 0f, resY, -1f, 1f); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glLoadIdentity(); }
From source file:com.sriramramani.droid.inspector.ui.InspectorCanvas.java
License:Mozilla Public License
private void doResize() { // Get the aspect ratio. Rectangle bounds = getBounds(); float aspectRatio = (float) bounds.width / (float) bounds.height; // Set current. setCurrent();//from ww w .j av a2 s . c o m // Reset viewport. GL11.glViewport(0, 0, bounds.width, bounds.height); // Set the projection matrix. GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glLoadIdentity(); if (mIsOrtho) { // Changing top and bottom to make it draw in 4th quadrant. GL11.glOrtho(0, bounds.width, bounds.height, 0, mZNear, mZFar); } else { // Perspective is viewing-angle, aspect-ratio, (-z, z). GLU.gluPerspective(45.0f, aspectRatio, mZNear, mZFar); } // Set the model view matrix. GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glLoadIdentity(); refresh(); }
From source file:com.swinggl.elements.GLFrame.java
License:Open Source License
/** * This method starts the both the render and update loops. The thread that this is called on will become the render loop and occupy that thread entirely. * All glfwWindowHint's must be called before this is called while all other window attributes can be altered while the loop is running including changing * the FPS and UPS.//from ww w . j a v a 2 s . co m */ public void run() { if (fullscreen) { window = glfwCreateWindow(windowWidth, windowHeight, title, glfwGetPrimaryMonitor(), secondWindowHandle); GLFWVidMode vidmode = glfwGetVideoMode(glfwGetPrimaryMonitor()); if (!(windowWidth == vidmode.width() && windowHeight == vidmode.height())) { Debug.println("GLFWVidMode [" + windowWidth + ", " + windowHeight + "] not available, switching to GLFWVidMode [" + vidmode.width() + ", " + vidmode.height() + "]", Debug.ANSI_YELLOW); windowWidth = vidmode.width(); windowHeight = vidmode.height(); } } else window = glfwCreateWindow(windowWidth, windowHeight, title, NULL, secondWindowHandle); if (window == NULL) throw new RuntimeException("Failed to create the GLFW window"); if (windowPosition == WINDOW_POSITION_CUSTOM && !fullscreen) glfwSetWindowPos(window, windowX, windowY); else if (!fullscreen) updateWindowPosition(); glfwSetKeyCallback(window, keyCallback); glfwSetCursorPosCallback(window, cursorPosCallback); glfwSetCursorEnterCallback(window, cursorEnterCallback); glfwSetMouseButtonCallback(window, mouseButtonCallback); glfwSetScrollCallback(window, scrollCallback); glfwSetWindowPosCallback(window, windowPosCallback); glfwSetWindowSizeCallback(window, windowSizeCallback); glfwSetWindowCloseCallback(window, windowCloseCallback); glfwSetWindowRefreshCallback(window, windowRefreshCallback); glfwSetWindowFocusCallback(window, windowFocusCallback); glfwSetWindowIconifyCallback(window, windowIconifyCallback); glfwSetDropCallback(window, dropCallback); if (mouseDisabled) glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_DISABLED); else if (mouseHidden) glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_HIDDEN); else glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_NORMAL); glfwMakeContextCurrent(window); glfwSwapInterval(1); GL.createCapabilities(); GLUtil.setupDebugMessageCallback(); GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glLoadIdentity(); GL11.glOrtho(0, windowWidth, windowHeight, 0, 1, -1); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glClearColor(backgroundColor.getRed() / 255f, backgroundColor.getGreen() / 255f, backgroundColor.getBlue() / 255f, backgroundColor.getAlpha() / 255f); Debug.initialize(); if (visible) glfwShowWindow(window); new Thread(new Update(), "SwingGL | update").start(); long now = System.nanoTime(); long lastTime = now; double deltaR = 0.0; long lastRender = now; running = true; while (running) { if (glfwWindowShouldClose(window) == GL_TRUE) running = false; now = System.nanoTime(); deltaR += (now - lastTime) / renderNS; lastTime = now; if (deltaR >= 1.0) { renderDelta = (now - lastRender) / 1000000000.0f; render(renderDelta); lastRender = now; deltaR--; } } if (currentGameState != null) currentGameState.dispose(); try { glfwDestroyWindow(window); keyCallback.release(); cursorPosCallback.release(); mouseButtonCallback.release(); scrollCallback.release(); } finally { glfwTerminate(); errorCallback.release(); } }
From source file:com.swinggl.elements.GLFrame.java
License:Open Source License
/** * Sets the size of the window from frame edge to edge. If the window is fullscreen some sizes are limited by graphical capabilities. * * @param width - The width of the window * @param height - The height of the window *//*from w w w . jav a 2 s . c o m*/ public void setSize(int width, int height) { windowWidth = width; windowHeight = height; if (fullscreen) { GLFWVidMode vidmode = glfwGetVideoMode(glfwGetPrimaryMonitor()); if (!(windowWidth == vidmode.width() && windowHeight == vidmode.height())) { Debug.println("GLFWVidMode [" + windowWidth + ", " + windowHeight + "] not available, switching to GLFWVidMode [" + vidmode.width() + ", " + vidmode.height() + "]", Debug.ANSI_YELLOW); windowWidth = vidmode.width(); windowHeight = vidmode.height(); } } if (window != 0L) { glfwSetWindowSize(window, windowWidth, windowHeight); GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glLoadIdentity(); GL11.glOrtho(0, windowWidth, windowHeight, 0, 1, -1); GL11.glMatrixMode(GL11.GL_MODELVIEW); } }