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:fi.conf.ae.gl.GLGraphicRoutines.java
License:LGPL
public static void initOrtho() { GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glLoadIdentity();//w ww.j a va 2 s . c o m //GL11.glPixelZoom( 1.0f, 1.0f ); //GL11.glViewport(0, 0, GLValues.screenWidth, GLValues.screenHeight); GL11.glOrtho(0, GLValues.glWidth, GLValues.glHeight, 0, -GLValues.glDepth, GLValues.glDepth); GL11.glMatrixMode(GL11.GL_MODELVIEW); }
From source file:fr.def.iss.vd2.lib_v3d.camera.V3DCamera.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();//w ww . j a va 2s .c o m 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; } } 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:fr.def.iss.vd2.lib_v3d.camera.V3DSimple2DCamera.java
License:Open Source License
@Override protected void initPerspective() { if (currentHeight <= 0) { // avoid a divide by zero error! currentHeight = 1;/*from w w w .j av a 2 s .c om*/ } final float h = currentWidth / currentHeight; GL11.glOrtho(-zoom * h, zoom * h, -zoom, zoom, -2000.0, 2000.0); }
From source file:fr.def.iss.vd2.lib_v3d.V3DCanvas.java
License:Open Source License
/** * The only method that you should implement by yourself. * * @see javax.media.openGL11.GLEventListener#display(javax.media.openGL11.GLAutoDrawable) *///from w w w . j a v a2 s .c o m public void display() { GL11.glClear(GL11.GL_ACCUM_BUFFER_BIT); for (V3DCameraBinding binding : cameraList) { GL11.glViewport(binding.x, binding.y, binding.width, binding.height); //Clean Background I3dColor color = binding.camera.getBackgroundColor(); GL11.glClearColor(color.r, color.g, color.b, color.a); GL11.glScissor(binding.x, binding.y, binding.width, binding.height); GL11.glEnable(GL11.GL_SCISSOR_TEST); if (color.a == 1.0f) { GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT); } else { GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glLoadIdentity(); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glLoadIdentity(); GL11.glOrtho(0, binding.width, 0, binding.height, -2000.0, 2000.0); GL11.glDisable(GL11.GL_DEPTH_TEST); GL11.glColor4f(color.r, color.g, color.b, color.a); GL11.glBegin(GL11.GL_QUADS); GL11.glVertex3f(0, 0, 0); GL11.glVertex3f(binding.width, 0, 0); GL11.glVertex3f(binding.width, binding.height, 0); GL11.glVertex3f(0, binding.height, 0); GL11.glEnd(); GL11.glEnable(GL11.GL_DEPTH_TEST); GL11.glClear(GL11.GL_DEPTH_BUFFER_BIT); } GL11.glDisable(GL11.GL_SCISSOR_TEST); binding.camera.display(binding.width, binding.height); GL11.glDisable(GL11.GL_DEPTH_TEST); // binding.getGui().display(); GL11.glEnable(GL11.GL_DEPTH_TEST); if (select && binding == focusCamera) { GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glLoadIdentity(); //glu.gluPerspective(45.0f, h, 0.1, 2000.0); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glLoadIdentity(); binding.camera.select(mouseX, mouseY); context.setMouseOverCameraBinding(binding); } } GL11.glFlush(); select = false; }
From source file:fr.theshark34.sharkengine.Game.java
License:Apache License
/** * Create the Game/*from www.j ava 2s . com*/ * * @param name * The name of the Game * @param title * The title of the Game window * @param icon * The icon of the Game window * @param firstGUI * The first displayed GUI * @param clearColor * The clear color (= background color) */ public static void create(final String name, final String title, final BufferedImage icon, GUI firstGUI, Color clearColor) { try { // Setting up things Game.name = name; Game.title = title; Game.icon = icon; Game.clearColor = clearColor; running = true; // Creating the Display, the Mouse and the Keyboard DisplayUtil.setDisplayModeAndFullscreen(); Display.setTitle(title); Display.create(); Mouse.create(); Keyboard.create(); // Initializing OpenGL GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glLoadIdentity(); GL11.glOrtho(0, Display.getWidth(), Display.getHeight(), 0, -1, 1); GL11.glMatrixMode(GL11.GL_MODELVIEW); // Displaying the first GUI setCurrentGUI(firstGUI); // Start the main loop while (running) update(); // Destroy all Display.destroy(); Mouse.destroy(); Keyboard.destroy(); } catch (LWJGLException e) { ErrorUtil.catchError(e); } }
From source file:game.engine.game.Scene.java
License:Open Source License
/** * Draws the screen contents using OpenGL. */// ww w . ja va 2 s . com public void draw() { GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glLoadIdentity(); GL11.glOrtho(0, getScreenWidthUnits(), getScreenHeightUnits(), 0, -1, 1); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glLoadIdentity(); GL11.glTranslatef(-screenX, -screenY, 0.0f); GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glClearColor(0.0f, 0.0f, 0.0f, 1.0f); GL11.glClear(GL11.GL_COLOR_BUFFER_BIT); for (GameObject gameObject : gameObjects) { gameObject.draw(); } }
From source file:game.FasT.java
License:Open Source License
private void handleKeyboard() { while (Keyboard.next()) { if (!Keyboard.getEventKeyState()) continue; log.info("Key '" + Keyboard.getEventCharacter() + "' pressed ! "); if (Keyboard.getEventKey() == Keyboard.KEY_ESCAPE) { exit();/* w ww . ja v a2 s . com*/ } if (Keyboard.getEventKey() == Keyboard.KEY_SPACE) { this.setPaused(!this.isPaused()); if (!this.pause) TIME = System.nanoTime(); } if (Keyboard.getEventKey() == Keyboard.KEY_RIGHT) { this.setPaused(true); this.updateEntities(debugtimeinseconds); } else if (Keyboard.getEventKey() == Keyboard.KEY_LEFT) { this.setPaused(true); this.updateEntities(-debugtimeinseconds); } if (Keyboard.getEventKey() == 13) { Normal.unzoom(24); this.spawnWalls(); } if (Keyboard.getEventKey() == 53) { Normal.zoom(24); this.spawnWalls(); } if (!this.log.shallLog) return; if (Keyboard.getEventKey() == Keyboard.KEY_T) { entityHandler.spawn(new Ball(new Point(10, 500).toPlan(), this.getEntityHandler())); this.period = Math.pow(10, 8) / 0.1; } if (Keyboard.getEventKey() == Keyboard.KEY_1) { entityHandler.spawn(new Ball(new Point(Mouse.getX() - Normal.x, Mouse.getY() - Normal.y).toReal(), 0.3, this.getEntityHandler())); } if (Keyboard.getEventKey() == Keyboard.KEY_2) { entityHandler.spawn(new Ball(new Point(Mouse.getX() - Normal.x, Mouse.getY() - Normal.y).toReal(), 0.70, this.getEntityHandler())); } if (Keyboard.getEventKey() == Keyboard.KEY_3) { entityHandler.spawn(new Ball(new Point(Mouse.getX() - Normal.x, Mouse.getY() - Normal.y).toReal(), 1.5, this.getEntityHandler())); } if (Keyboard.getEventKey() == Keyboard.KEY_L) { //Coup spcial : les 10 camion qui te tombe sur la tte : 19620 Newtons dans ta geulle entityHandler.get(this.theBall).applyForce(new C(new Angle(Angle.convertToRad(90)), 0.1)); } if (Keyboard.getEventKey() == Keyboard.KEY_P) { //log.info("Width : " + render.getFrame().getWidth() + " & Height = " + render.getFrame().getHeight()); try { Display.setDisplayMode( new DisplayMode(Display.getParent().getWidth(), Display.getParent().getHeight() - 1)); } catch (LWJGLException e) { e.printStackTrace(); } // Display.setLocation(Display.getParent().getX(), Display.getParent().getY()); //render.getFrame().setSize(new Dimension(render.getFrame().getWidth(), render.getFrame().getHeight()+1)); // render.getFrame().pack(); } if (Keyboard.getEventKey() == Keyboard.KEY_D) { this.entityHandler.destroy( this.entityHandler.getEntityUnder(new Point(Mouse.getEventX(), Mouse.getEventY()))); } if (Keyboard.getEventKey() == Keyboard.KEY_Z) { GL11.glOrtho(0, 5, 0, 5, -1.0, 1.0); } if (Keyboard.getEventKey() == Keyboard.KEY_Y) { GL11.glOrtho(5, 0, 5, 0, -1.0, 1.0); } if (Keyboard.getEventKey() == Keyboard.KEY_F) { this.getRender(); Render.requestToggleFullScreen(this.getRender().getFrame()); } } }
From source file:gamepadhandler.GamepadHandlerLWJGL.java
public void loop() throws InterruptedException { // This line is critical for LWJGL's interoperation with GLFW's // OpenGL context, or any context that is managed externally. // LWJGL detects the context that is current in the current thread, // creates the GLCapabilities instance and makes the OpenGL // bindings available for use. GL.createCapabilities();/* ww w . j a va 2 s . co m*/ // Set the clear color glClearColor(0.0f, 0.0f, 0.0f, 1.0f); GL11.glMatrixMode(GL_PROJECTION); GL11.glLoadIdentity(); GL11.glOrtho(0, WIDTH, 0, HEIGHT, -1, 1); GL11.glMatrixMode(GL_MODELVIEW); GL11.glDisable(GL_DEPTH_TEST); GL11.glEnable(GL_BLEND); GL11.glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); frameLooper.init(window, WIDTH, HEIGHT); boolean keepRunning = true; long currentTime = System.nanoTime(); // Run the rendering loop until the user has attempted to close // the window or has pressed the ESCAPE key. while (!glfwWindowShouldClose(window) && keepRunning) { long elapsedNanoTime; // Putting on a frame cap (of ~120fps when this comment was made) if (FPS_CAPPED) { while (System.nanoTime() - currentTime < minFrameWaitNanoTime) { Thread.sleep(2); } } elapsedNanoTime = System.nanoTime() - currentTime; currentTime = System.nanoTime(); glClear(GL_COLOR_BUFFER_BIT); // clear the framebuffer // Poll for window events. The key callback above will only be // invoked during this call. glfwPollEvents(); // Where all the game logic is handled: keepRunning = frameLooper.frame(); glfwSwapBuffers(window); // swap the color buffers } }
From source file:herzog3d.Game.java
License:Open Source License
/** * All rendering is done in here/*from ww w. ja v a 2 s .c o m*/ */ public void draw() { GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT); cam.transform(); GLUtils.glLightPos(1.0f, 1.0f, 1.0f); GL11.glColor3f(1.0f, 1.0f, 1.0f); getMap().draw(cam); for (Unit unit : units) { if (unit.isActive()) { unit.draw(); } } for (Base base : bases) { base.draw(map); } for (Effect effect : effects) { effect.draw(); } GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glLoadIdentity(); GL11.glOrtho(0, 800, 600, 0, 0, 1); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glLoadIdentity(); GL11.glDisable(GL11.GL_DEPTH_TEST); GL11.glDisable(GL11.GL_LIGHTING); Material.DEFAULT_WHITE.bind(); for (HZWidget overlay : overlays) { if (overlay.isVisible()) { overlay.draw(); } } GL11.glEnable(GL11.GL_LIGHTING); GL11.glEnable(GL11.GL_DEPTH_TEST); }
From source file:hexagonalminesweeper.HexagonalMinesweeper.java
public static void renderGL() { try {// w w w.j a va 2 s . com Display.setDisplayMode(new org.lwjgl.opengl.DisplayMode(800, 600)); Display.create(); } 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, 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(true); }