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.badlogic.gdx.backends.lwjgl.LwjglGL10.java
License:Apache License
public final void glOrthof(float left, float right, float bottom, float top, float zNear, float zFar) { GL11.glOrtho(left, right, bottom, top, zNear, zFar); }
From source file:com.dbi.games.fortress.ui.MainAppWindow.java
License:Open Source License
/** * Creates new form MainAppWin//from ww w . j a 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(); }
From source file:com.dyonovan.tcnodetracker.lib.truetyper.FontHelper.java
License:Open Source License
private static void set2DMode(FloatBuffer matrixData) { Minecraft mc = Minecraft.getMinecraft(); ScaledResolution sr = new ScaledResolution(mc.getMinecraft(), mc.displayWidth, mc.displayHeight); mc.entityRenderer.setupOverlayRendering(); GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glPushMatrix();//from w w w . java 2 s . c o m //GL11.glLoadMatrix(matrixData); GL11.glLoadIdentity(); GL11.glOrtho(0, mc.displayWidth, 0, mc.displayHeight, -1, 1); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glPushMatrix(); GL11.glLoadIdentity(); Matrix4f matrix = new Matrix4f(); matrix.load(matrixData); GL11.glTranslatef(matrix.m30 * sr.getScaleFactor(), -matrix.m31 * sr.getScaleFactor(), 0f); }
From source file:com.gameminers.mav.render.Rendering.java
License:Open Source License
public static void beforeFrame(int width, int height) { GL11.glViewport(0, 0, width, height); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glLoadIdentity();/*from w w w . j a v a 2s. c om*/ GL11.glOrtho(0, width, height, 0, 100, -100); GL11.glMatrixMode(GL11.GL_MODELVIEW); }
From source file:com.golden.gamedev.engine.lwjgl.LWJGLMode.java
License:Open Source License
private void initGL() { // init GL//from w w w . j a v a 2 s . c om // enable textures since we're going to use these for our sprites GL11.glEnable(GL11.GL_TEXTURE_2D); // disable the OpenGL depth test since we're rendering 2D graphics GL11.glDisable(GL11.GL_DEPTH_TEST); GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glLoadIdentity(); GL11.glOrtho(0, this.size.width, this.size.height, 0, -1, 1); // enable transparency GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); }
From source file:com.irr310.i3d.scene.I3dCamera.java
License:Open Source License
public void display(float width, float height) { this.currentWidth = width; this.currentHeight = height; GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glLoadIdentity();//from w w w. j av a 2 s .c om GL11.glOrtho(0, width, 0, height, -2000.0, 2000.0); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glLoadIdentity(); backgroundScene.display(this); GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glLoadIdentity(); initPerspective(); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glLoadIdentity(); GL11.glPushMatrix(); configureView(glu); if (!configured) { configured = true; if (cameraInitialisation != null) { cameraInitialisation.run(); cameraInitialisation = null; } } GL11.glColor3f(1, 0, 0); GL11.glBegin(GL11.GL_LINES); GL11.glVertex3d(0, 0, 0); GL11.glVertex3d(100, 100, 100); GL11.glEnd(); preDisplayScene(); if (currentScene != null) { currentScene.display(this); } postDisplayScene(); preDisplayGui(); postDisplayGui(); GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glLoadIdentity(); GL11.glOrtho(0, width, 0, height, -2000.0, 2000.0); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glLoadIdentity(); hudScene.display(this); GL11.glPopMatrix(); }
From source file:com.kauridev.lunarfever.Lunar.java
License:Open Source License
private void initOpenGL() { try {//from w w w . ja v a 2 s .com Display.setDisplayMode(new DisplayMode(TARGET_WIDTH, TARGET_HEIGHT)); Display.setTitle("Lunar Fever"); Display.setFullscreen(false); Display.create(); } catch (LWJGLException e) { e.printStackTrace(); } GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glLoadIdentity(); GL11.glOrtho(0, TARGET_WIDTH, 0, TARGET_HEIGHT, 1, -1); GL11.glMatrixMode(GL11.GL_MODELVIEW); }
From source file:com.lukke100.sbdi.Sbdi.java
License:Open Source License
public static void main(String[] args) { System.out.println("Beginning Main Method"); JyInjector jyInjector = new JyInjector(); jyInjector.main();//from www.j a va2 s . c o m try { Display.setDisplayMode(new DisplayMode(640, 480)); Display.create(); Display.setVSyncEnabled(true); } catch (LWJGLException e) { e.printStackTrace(); System.exit(0); } GL11.glOrtho(0, 640, 0, 480, 0, 1); GL11.glTranslated(.5d, .5d, 0f); RenderBuffer.init(); setActiveMap(new DebugMap(1024, 1024)); final DebugEntity player = new DebugEntity(128, 128); DebugEntity temp = new DebugEntity(130, 128); activeCamera = new Camera(0, 0, 16, 12); activeCamera.center(player); player.queueRender(RenderLayer.ENTITY0); temp.queueRender(RenderLayer.ENTITY0); Input.addKeyTotal(Keyboard.KEY_RIGHT, Keyboard.KEY_LEFT, new Execute() { @Override public void exec() { player.goRight(); } }, new Execute() { @Override public void exec() { player.idleX(); } }, new Execute() { @Override public void exec() { player.goLeft(); } }); Input.addKeyTotal(Keyboard.KEY_UP, Keyboard.KEY_DOWN, new Execute() { @Override public void exec() { player.goUp(); } }, new Execute() { @Override public void exec() { player.idleY(); } }, new Execute() { @Override public void exec() { player.goDown(); } }); System.gc(); while (!Display.isCloseRequested()) { GL11.glClear(GL11.GL_COLOR_BUFFER_BIT); Input.parseHotkeys(); activeMap.markMoving(player); activeMap.markMoving(temp); activeMap.moveAll(true); activeCamera.center(player); Display.setTitle("COORDS: " + player.getxCoord() + " (" + player.getxTile() + "), " + player.getyCoord() + " (" + player.getyTile() + "), " + " - MEM: " + memUsage('m')); RenderBuffer.process(); activeCamera.debugTiles(); FPSCounter.update(); Display.sync(240); Display.update(); } Display.destroy(); //jyInjector.exit(); }
From source file:com.mtbs3d.minecrift.VRRenderer.java
License:LGPL
public void renderGUIandWorld(float renderPartialTicks) { this.farPlaneDistance = (float) this.mc.gameSettings.ofRenderDistanceFine; if (Config.isFogFancy()) { this.farPlaneDistance *= 0.95F; }// www . jav a2 s . c om if (Config.isFogFast()) { this.farPlaneDistance *= 0.83F; } if (this.prevFarPlaneDistance != this.farPlaneDistance) { _FBOInitialised = false; this.prevFarPlaneDistance = this.farPlaneDistance; } //Ensure FBO are in place and initialized if (!setupFBOs()) return; boolean guiShowingThisFrame = false; int mouseX = 0; int mouseY = 0; ScaledResolution var15 = new ScaledResolution(this.mc.gameSettings, this.mc.displayWidth, this.mc.displayHeight); int var16 = var15.getScaledWidth(); int var17 = var15.getScaledHeight(); if ((this.mc.theWorld != null && !this.mc.gameSettings.hideGUI && this.mc.thePlayer.getSleepTimer() == 0) || this.mc.currentScreen != null || this.mc.loadingScreen.isEnabled()) { //Render all UI elements into guiFBO mouseX = Mouse.getX() * var16 / this.mc.displayWidth; mouseY = var17 - Mouse.getY() * var17 / this.mc.displayHeight - 1; guiFBO.bindRenderTarget(); GL11.glViewport(0, 0, this.mc.displayWidth, this.mc.displayHeight); GL11.glClearColor(0, 0, 0, 0); GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT); GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glLoadIdentity(); GL11.glOrtho(0.0D, var15.getScaledWidth_double(), var15.getScaledHeight_double(), 0.0D, 1000.0D, 3000.0D); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glLoadIdentity(); GL11.glTranslatef(0.0F, 0.0F, -2000.0F); guiShowingThisFrame = true; } // Display loading / progress window if necessary if (this.mc.loadingScreen.isEnabled()) { this.mc.loadingScreen.vrRender(var16, var17); GL11.glClear(GL11.GL_DEPTH_BUFFER_BIT); } else if (this.mc.theWorld != null && !this.mc.gameSettings.hideGUI && !this.blankGUIUntilWorldValid) { //Disable any forge gui crosshairs and helmet overlay (pumkinblur) if (Reflector.ForgeGuiIngame_renderCrosshairs.exists()) { Reflector.ForgeGuiIngame_renderCrosshairs.setValue(false); Reflector.ForgeGuiIngame_renderHelmet.setValue(false); } //Draw in game GUI this.mc.ingameGUI.renderGameOverlay(renderPartialTicks, this.mc.currentScreen != null, mouseX, mouseY); guiAchievement.updateAchievementWindow(); GL11.glClear(GL11.GL_DEPTH_BUFFER_BIT); } if (this.blankGUIUntilWorldValid) { if (this.mc.theWorld != null) this.blankGUIUntilWorldValid = false; } if (this.mc.loadingScreen.isEnabled() == false && this.mc.currentScreen != null && !this.blankGUIUntilWorldValid) { try { this.mc.currentScreen.drawScreen(mouseX, mouseY, renderPartialTicks); } catch (Throwable var13) { CrashReport var11 = CrashReport.makeCrashReport(var13, "Rendering screen"); throw new ReportedException(var11); } GL11.glDisable(GL11.GL_LIGHTING); //inventory messes up fog color sometimes... This fixes GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); drawMouseQuad(mouseX, mouseY); } //Setup render target if (mc.vrSettings.useDistortion) { preDistortionFBO.bindRenderTarget(); } else if (this.mc.vrSettings.useSupersample) { postDistortionFBO.bindRenderTarget(); eyeRenderParams._renderScale = 1.0f; } else { unbindFBORenderTarget(); eyeRenderParams._renderScale = 1.0f; } GL11.glClearColor(0, 0, 0, 1); GL11.glEnable(GL11.GL_SCISSOR_TEST); if (this.mc.theWorld != null) { //If we're in-game, render in-game stuff this.mc.mcProfiler.startSection("level"); if (this.mc.renderViewEntity == null) { this.mc.renderViewEntity = this.mc.thePlayer; } EntityLivingBase renderViewEntity = this.mc.renderViewEntity; this.mc.mcProfiler.endStartSection("center"); //Used by fog comparison, 3rd person camera/block collision detection renderOriginX = renderViewEntity.lastTickPosX + (renderViewEntity.posX - renderViewEntity.lastTickPosX) * (double) renderPartialTicks; renderOriginY = renderViewEntity.lastTickPosY + (renderViewEntity.posY - renderViewEntity.lastTickPosY) * (double) renderPartialTicks; renderOriginZ = renderViewEntity.lastTickPosZ + (renderViewEntity.posZ - renderViewEntity.lastTickPosZ) * (double) renderPartialTicks; if (this.mc.currentScreen == null) { this.mc.mcProfiler.endStartSection("pick"); getPointedBlock(renderPartialTicks); } // Update sound engine setSoundListenerOrientation(); } //Update gui Yaw if (guiShowingThisFrame && !guiShowingLastFrame) { guiHeadYaw = this.cameraYaw - this.mc.lookaimController.getBodyYawDegrees(); } guiShowingLastFrame = guiShowingThisFrame; //Now, actually render world for (int renderSceneNumber = 0; renderSceneNumber < 2; ++renderSceneNumber) { setupEyeViewport(renderSceneNumber); this.mc.mcProfiler.endStartSection("camera"); //transform camera with pitch,yaw,roll + neck model + game effects setupCameraTransform(renderPartialTicks, renderSceneNumber); if (this.mc.theWorld != null) { GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glPushMatrix(); this.renderWorld(renderPartialTicks, 0L, renderSceneNumber); this.disableLightmap(renderPartialTicks); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glPopMatrix(); } else { GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT); // Clear Screen And Depth Buffer on the framebuffer to black GL11.glDisable(GL11.GL_BLEND); } if (guiShowingThisFrame) { GL11.glPushMatrix(); GL11.glEnable(GL11.GL_TEXTURE_2D); guiFBO.bindTexture(); // Prevent black border at top / bottom of GUI GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL12.GL_CLAMP_TO_EDGE); GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL12.GL_CLAMP_TO_EDGE); if (this.mc.theWorld != null && this.mc.vrSettings.hudLockToHead) { GL11.glLoadIdentity(); if (renderSceneNumber == 0) GL11.glMultMatrix(eyeRenderParams.gl_getLeftViewportTransform()); else GL11.glMultMatrix(eyeRenderParams.gl_getRightViewportTransform()); GL11.glRotatef(180f - this.mc.vrSettings.hudYawOffset, 0f, 1f, 0f); GL11.glRotatef(-this.mc.vrSettings.hudPitchOffset, 1f, 0f, 0f); // GL11.glRotatef(cameraRoll, 0f, 0f, 1f); GL11.glTranslatef(0.0f, 0.0f, this.mc.vrSettings.hudDistance - this.mc.vrSettings.eyeProtrusion); GL11.glRotatef(180f, 0f, 1f, 0f);//Not sure why this is necessary... normals/backface culling maybe? } else { float guiYaw = 0f; if (this.mc.theWorld != null) { if (this.mc.vrSettings.lookMoveDecoupled) guiYaw = this.mc.lookaimController.getBodyYawDegrees(); else guiYaw = guiHeadYaw + this.mc.lookaimController.getBodyYawDegrees(); guiYaw -= this.mc.vrSettings.hudYawOffset; } else guiYaw = guiHeadYaw + this.mc.lookaimController.getBodyYawDegrees(); GL11.glRotatef(-guiYaw, 0f, 1f, 0f); float guiPitch = 0f; if (this.mc.theWorld != null) guiPitch = -this.mc.vrSettings.hudPitchOffset; // if( this.mc.vrSettings.allowMousePitchInput) // guiPitch += this.mc.lookaimController.getBodyPitchDegrees(); GL11.glRotatef(guiPitch, 1f, 0f, 0f); GL11.glTranslatef(0.0f, 0.0f, this.mc.vrSettings.hudDistance); GL11.glRotatef(180f, 0f, 1f, 0f);//Not sure why this is necessary... normals/backface culling maybe? } GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); if (this.mc.theWorld != null) GL11.glColor4f(1, 1, 1, this.mc.vrSettings.hudOpacity); else GL11.glColor4f(1, 1, 1, 1); if (!this.mc.vrSettings.hudOcclusion) GL11.glDisable(GL11.GL_DEPTH_TEST); drawQuad2(this.mc.displayWidth, this.mc.displayHeight, this.mc.vrSettings.hudScale * this.mc.vrSettings.hudDistance); GL11.glDisable(GL11.GL_BLEND); GL11.glEnable(GL11.GL_DEPTH_TEST); GL11.glPopMatrix(); unbindTexture(); //mc.checkGLError("GUI"); } if (calibrationHelper != null) { float x = lookX * mc.vrSettings.hudDistance; float y = lookY * mc.vrSettings.hudDistance; float z = lookZ * mc.vrSettings.hudDistance; GL11.glDisable(GL11.GL_DEPTH_TEST); GL11.glPushMatrix(); GL11.glTranslatef(x, y, z); GL11.glRotatef(-this.cameraYaw, 0.0F, 1.0F, 0.0F); GL11.glRotatef(this.cameraPitch, 1.0F, 0.0F, 0.0F); GL11.glRotatef(this.cameraRoll, 0.0F, 0.0F, 1.0F); float textScale = (float) Math.sqrt((x * x + y * y + z * z)); GL11.glScalef(-INITIAL_CALIBRATION_TEXT_SCALE * textScale, -INITIAL_CALIBRATION_TEXT_SCALE * textScale, -INITIAL_CALIBRATION_TEXT_SCALE * textScale); String calibrating = "Calibrating " + calibrationHelper.currentPlugin.getName() + "..."; mc.fontRenderer.drawStringWithShadow(calibrating, -mc.fontRenderer.getStringWidth(calibrating) / 2, -8, /*white*/16777215); String calibrationStep = calibrationHelper.calibrationStep; // mc.fontRenderer.drawStringWithShadow(calibrationStep, -mc.fontRenderer.getStringWidth(calibrationStep)/2, 8, /*white*/16777215); int column = 8; ArrayList<String> wrapped = new ArrayList<String>(); Utils.wordWrap(calibrationStep, CALIBRATION_TEXT_WORDWRAP_LEN, wrapped); for (String line : wrapped) { mc.fontRenderer.drawStringWithShadow(line, -mc.fontRenderer.getStringWidth(line) / 2, column, /*white*/16777215); column += 16; } GL11.glPopMatrix(); GL11.glEnable(GL11.GL_DEPTH_TEST); } } GL11.glDisable(GL11.GL_SCISSOR_TEST); doDistortionAndSuperSample(); checkLatencyTester(); // Finish frame GL11.glFinish(); // Get end frame timings endFrameTimeNanos = startVSyncPeriodNanos = System.nanoTime(); long frameTime = endFrameTimeNanos - startFrameRenderNanos; addRenderFrameTimeNanos(frameTime); mc.checkGLError("After render world and GUI"); }
From source file:com.n8lm.zener.nifty.NiftyGUISystem.java
License:Open Source License
@Override protected void processSystem() { glViewport(0, 0, Display.getDisplayMode().getWidth(), Display.getDisplayMode().getHeight()); GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glLoadIdentity();/*from ww w .j a v a 2s. c om*/ GL11.glOrtho(0, game.getContainer().getWidth(), game.getContainer().getHeight(), 0, -9999, 9999); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glLoadIdentity(); glPushAttrib(GL_ENABLE_BIT); GL11.glDisable(GL11.GL_DEPTH_TEST); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); GL11.glDisable(GL11.GL_CULL_FACE); GL11.glEnable(GL11.GL_ALPHA_TEST); GL11.glAlphaFunc(GL11.GL_NOTEQUAL, 0); GL11.glDisable(GL11.GL_LIGHTING); // Back to GL Texture 0 Unit glActiveTexture(GL_TEXTURE0); glEnable(GL_TEXTURE_2D); //glBindTexture(); nifty.update(); nifty.render(false); glPopAttrib(); GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glLoadIdentity(); }