List of usage examples for org.lwjgl.opengl GL11 glMatrixMode
public static native void glMatrixMode(@NativeType("GLenum") int mode);
From source file:mss.View.java
License:Open Source License
private void initOpenGL() { GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glLoadMatrix(this.buffer); GL11.glOrtho(-100, 100, -100, 100, 1, -1); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glEnable(GL11.GL_BLEND);// w w w . j av a 2 s.c om GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); }
From source file:mwisbest.openbase.Common.java
License:Open Source License
/** * Common code for rendering the Widgets to the screen. After this, customRender() is used from OpenBASE or OpenBASEApplet (whatever is calling this method). *//*from ww w.j av a 2 s. c o m*/ protected static void render(int framerateLimit) { GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glLoadIdentity(); Map<String, Widget> theWidgets = ResourceManager.getWidgets(); for (RenderPriority priority : RenderPriority.values()) { for (Entry<String, Widget> widget : theWidgets.entrySet()) { if (widget.getValue().getRenderPriority() == priority && widget.getValue().getVisible()) widget.getValue().render(); } } if (framerateLimit > 0) Display.sync(framerateLimit); }
From source file:mwisbest.openbase.OpenBASE.java
License:Open Source License
private void init() { Common.extractNatives(new File(this.dataFolder, "natives"), false); try {/*from ww w. j av a 2 s . c om*/ System.setProperty("org.lwjgl.opengl.Display.allowSoftwareOpenGL", "true"); Display.setDisplayMode(new DisplayMode(this.windowWidth, this.windowHeight)); Display.setTitle(this.windowTitle); Display.setIcon(new ByteBuffer[] { UtilsGL.loadIcon(this.windowIcon16Loc), UtilsGL.loadIcon(this.windowIcon32Loc) }); Display.setFullscreen(false); Display.create(); Display.setVSyncEnabled(this.windowVSync); Keyboard.enableRepeatEvents(true); AL.create(); try { CL.create(); } catch (LWJGLException e) { LoggerHelper.getLogger().info("OpenCL not supported: Disabling OpenCL."); } GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glDisable(GL11.GL_DEPTH_TEST); GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glLoadMatrix( FloatMatrix.glOrtho(0, this.windowWidth, this.windowHeight, 0, 1, -1).asFloatBuffer()); } catch (LWJGLException e) { e.printStackTrace(); System.exit(0); } catch (IOException e) { e.printStackTrace(); } this.loadResources(); if (OpenBASE.logFPS) { long startTime = System.currentTimeMillis(); this.oldTime = startTime; this.currentTime = startTime; } this.mainLoop(); }
From source file:mwisbest.openbase.OpenBASEApplet.java
License:Open Source License
private void startLWJGL() { new SleepThreadHackery("[OpenBASE] Sleep Thread Hackery"); this.theThread = new Thread("[OpenBASE] Main") { @Override// w w w . java2s.c o m public void run() { OpenBASEApplet.this.running = true; Common.extractNatives(new File(OpenBASEApplet.this.dataFolder, "natives"), false); try { System.setProperty("org.lwjgl.opengl.Display.allowSoftwareOpenGL", "true"); Display.setParent(OpenBASEApplet.this.displayParent); Display.create(); Keyboard.enableRepeatEvents(true); AL.create(); try { CL.create(); } catch (LWJGLException e) { LoggerHelper.getLogger().info("OpenCL not supported: Disabling OpenCL."); } GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glDisable(GL11.GL_DEPTH_TEST); GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glLoadMatrix(FloatMatrix .glOrtho(0, OpenBASEApplet.this.canvasWidth, OpenBASEApplet.this.canvasHeight, 0, 1, -1) .asFloatBuffer()); } catch (LWJGLException e) { e.printStackTrace(); System.exit(0); } OpenBASEApplet.this.loadResources(); if (OpenBASEApplet.logFPS) { long startTime = System.currentTimeMillis(); OpenBASEApplet.this.oldTime = startTime; OpenBASEApplet.this.currentTime = startTime; } OpenBASEApplet.this.mainLoop(); } }; this.theThread.start(); }
From source file:myfirstgame.Window.java
public void init(int width, int height) { Window.width = width;/* ww w . j a v a 2s .c o m*/ Window.height = height; try { //Look for a displaymode with matching width and height that supports fullscreen, set it to the displaymode we want to use. DisplayMode displayMode = null; DisplayMode[] modes = Display.getAvailableDisplayModes(); for (int i = 0; i < modes.length; i++) { if (modes[i].getWidth() == width && modes[i].getHeight() == height && modes[i].isFullscreenCapable()) { displayMode = modes[i]; } } Display.setDisplayMode(displayMode); Display.setFullscreen(true); Display.create(); } catch (Exception e) { e.printStackTrace(); System.exit(0); } GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glLoadIdentity(); GL11.glOrtho(0, 800, 0, 600, 1, -1); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST); try { Mouse.create(); Keyboard.create(); } catch (LWJGLException ex) { Logger.getLogger(Window.class.getName()).log(Level.SEVERE, null, ex); } //Mouse.setGrabbed(true); }
From source file:name.martingeisse.minimal.simulation.lwjgl.LwjglWindow.java
License:Open Source License
/** * Constructor.//from w ww . ja va 2s.com * @param width the window width * @param height the window height */ public LwjglWindow(int width, int height) { try { LwjglNativeLibraryHelper.prepareNativeLibraries(); Display.setDisplayMode(new DisplayMode(width, height)); Display.setTitle("Minimal"); Display.setFullscreen(true); Display.create(new PixelFormat(0, 24, 0)); Keyboard.create(); } catch (Exception e) { throw new RuntimeException("could not open LWJGL window", e); } 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:name.martingeisse.stackd.client.gui.Gui.java
License:Open Source License
/** * Fires the specified event.//from ww w. ja v a 2s . com * @param event the event */ public void fireEvent(GuiEvent event) { if (rootElement == null) { return; } if (event == GuiEvent.DRAW) { if (layoutRequested) { rootElement.requestSize(widthUnits, HEIGHT_UNITS); rootElement.setPosition(0, 0); layoutRequested = false; } GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glLoadIdentity(); GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glLoadIdentity(); GL11.glOrtho(0, widthUnits, HEIGHT_UNITS, 0, -1, 1); } time = (int) System.currentTimeMillis(); rootElement.handleEvent(event); }
From source file:name.martingeisse.swtlib.canvas.AbstractOpenGlBlockCanvas.java
License:Open Source License
/** * //from w ww .ja v a2 s .c om */ private void setupOpenGl() { prepareOpenGl(); GL11.glMatrixMode(GL11.GL_MODELVIEW); matrixBuffer.rewind(); GL11.glLoadMatrix(matrixBuffer); GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glLoadIdentity(); }
From source file:net.adam_keenan.voxel.hud.HUD.java
License:Creative Commons License
public static void drawCrosshairs() { float screenx = (float) Display.getWidth() / 2, screeny = (float) Display.getHeight() / 2; float x1, y1, x2, y2, width1 = 4, height1 = 20, width2 = height1, height2 = width1; x1 = screenx - width1 / 2;/*w ww . j ava 2 s. co m*/ y1 = screeny - height1 / 2; x2 = screenx - width2 / 2; y2 = screeny - height2 / 2; FloatBuffer perspectiveProjectionMatrix; FloatBuffer orthographicProjectionMatrix; perspectiveProjectionMatrix = BufferUtils.createFloatBuffer(16); orthographicProjectionMatrix = BufferUtils.createFloatBuffer(16); GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glGetFloat(GL11.GL_PROJECTION_MATRIX, perspectiveProjectionMatrix); GL11.glLoadIdentity(); GL11.glOrtho(0, Display.getWidth(), Display.getHeight(), 0, 1, -1); GL11.glGetFloat(GL11.GL_PROJECTION_MATRIX, orthographicProjectionMatrix); // GL11.glLoadMatrix(perspectiveProjectionMatrix); GL11.glMatrixMode(GL11.GL_PROJECTION); // For text drawing GL11.glLoadMatrix(orthographicProjectionMatrix); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glPushMatrix(); GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS); GL11.glLoadIdentity(); // Clears matrix GL11.glColor4f(0, 0, 0, .5f); GL11.glRectf(x1, y1, x1 + width1, y1 + height1); GL11.glRectf(x2, y2, x2 + (width2 - width1) / 2, y2 + height2); GL11.glRectf(x2 + (width2 + width1) / 2, y2, x2 + width2, y2 + height2); GL11.glPopMatrix(); GL11.glPopAttrib(); GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glLoadMatrix(perspectiveProjectionMatrix); GL11.glMatrixMode(GL11.GL_MODELVIEW); }
From source file:net.ae97.notlet.client.GameInstance.java
License:Open Source License
public static void createTextures() throws LWJGLException { Display.setDisplayMode(new DisplayMode(width, height)); Display.create();/*from ww w. j a v a 2 s . c o m*/ Display.setVSyncEnabled(true); GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glClearColor(0.0f, 0.0f, 0.0f, 0.0f); // enable alpha blending 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); Font awtFont = new Font("Times New Roman", Font.BOLD, 18); font = new TrueTypeFont(awtFont, true); try { textureMapping.put("SMALLLET", TextureLoader.getTexture("PNG", ResourceLoader.getResourceAsStream("SMALLLET.png"))); textureMapping.put("healthbar", TextureLoader.getTexture("PNG", ResourceLoader.getResourceAsStream("healthbar.png"))); textureMapping.put("score", TextureLoader.getTexture("PNG", ResourceLoader.getResourceAsStream("score.png"))); textureMapping.put("arrow", TextureLoader.getTexture("PNG", ResourceLoader.getResourceAsStream("arrow.png"))); textureMapping.put("dirt", TextureLoader.getTexture("PNG", ResourceLoader.getResourceAsStream("dirt.png"))); textureMapping.put("rangerD", TextureLoader.getTexture("PNG", ResourceLoader.getResourceAsStream("rangerD.png"))); textureMapping.put("rangerL", TextureLoader.getTexture("PNG", ResourceLoader.getResourceAsStream("rangerL.png"))); textureMapping.put("rangerR", TextureLoader.getTexture("PNG", ResourceLoader.getResourceAsStream("rangerR.png"))); textureMapping.put("rangerU", TextureLoader.getTexture("PNG", ResourceLoader.getResourceAsStream("rangerU.png"))); textureMapping.put("skele", TextureLoader.getTexture("PNG", ResourceLoader.getResourceAsStream("skele.png"))); textureMapping.put("slime", TextureLoader.getTexture("PNG", ResourceLoader.getResourceAsStream("slime.png"))); textureMapping.put("hp", TextureLoader.getTexture("PNG", ResourceLoader.getResourceAsStream("hp.png"))); textureMapping.put("pb", TextureLoader.getTexture("PNG", ResourceLoader.getResourceAsStream("pb.png"))); textureMapping.put("wall", TextureLoader.getTexture("PNG", ResourceLoader.getResourceAsStream("wall.png"))); textureMapping.put("exit", TextureLoader.getTexture("PNG", ResourceLoader.getResourceAsStream("exit.png"))); } catch (IOException ex) { throw new RuntimeException(ex); } }