List of usage examples for org.lwjgl.opengl GL11 glMatrixMode
public static native void glMatrixMode(@NativeType("GLenum") int mode);
From source file:fr.mcnanotech.kevin_68.nanotechmod.main.client.renderer.RenderFlyingCreeper.java
License:Creative Commons License
protected int renderMobFlyingCreeperPassModel(MobFlyingCreeper mob, int par2, float par3) { if (mob.getPowered()) { if (par2 == 1) { float var4 = (float) mob.ticksExisted + par3; this.bindTexture(new ResourceLocation("textures/entity/creeper/creeper_armor.png")); GL11.glMatrixMode(GL11.GL_TEXTURE); GL11.glLoadIdentity();//from w w w.j ava 2 s . co m float var5 = var4 * 0.01F; float var6 = var4 * 0.01F; GL11.glTranslatef(var5, var6, 0.0F); this.setRenderPassModel(this.model); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glEnable(GL11.GL_BLEND); float var7 = 0.5F; GL11.glColor4f(var7, var7, var7, 1.0F); GL11.glDisable(GL11.GL_LIGHTING); GL11.glBlendFunc(GL11.GL_ONE, GL11.GL_ONE); return 1; } if (par2 == 2) { GL11.glMatrixMode(GL11.GL_TEXTURE); GL11.glLoadIdentity(); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glEnable(GL11.GL_LIGHTING); GL11.glDisable(GL11.GL_BLEND); } } return -1; }
From source file:fr.mcnanotech.kevin_68.nanotechmod.main.client.renderer.RenderSuperCreeper.java
License:Creative Commons License
protected int renderMobSuperCreeperPassModel(MobSuperCreeper mob, int par2, float par3) { if (mob.getPowered()) { if (par2 == 1) { float var4 = (float) mob.ticksExisted + par3; this.bindTexture(new ResourceLocation("textures/entity/creeper/creeper_armor.png")); GL11.glMatrixMode(GL11.GL_TEXTURE); GL11.glLoadIdentity();//from w w w . ja v a 2 s . c o m float var5 = var4 * 0.01F; float var6 = var4 * 0.01F; GL11.glTranslatef(var5, var6, 0.0F); this.setRenderPassModel(this.model); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glEnable(GL11.GL_BLEND); float var7 = 0.5F; GL11.glColor4f(var7, var7, var7, 1.0F); GL11.glDisable(GL11.GL_LIGHTING); GL11.glBlendFunc(GL11.GL_ONE, GL11.GL_ONE); return 1; } if (par2 == 2) { GL11.glMatrixMode(GL11.GL_TEXTURE); GL11.glLoadIdentity(); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glEnable(GL11.GL_LIGHTING); GL11.glDisable(GL11.GL_BLEND); } } return -1; }
From source file:fr.theshark34.sharkengine.Game.java
License:Apache License
/** * Create the Game/* www . j a va 2s .c o m*/ * * @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. *//*from www . ja v a 2 s. c om*/ 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.states.State_PREFAB_EDITOR.java
License:Open Source License
@Override protected void Init() { ButtonGUILayer = new GUI_Layer(); ButtonGUILayer.SetEnabled(true);/* w w w. j a va 2 s . c o m*/ MenuGUILayer = new GUI_Layer(); MenuGUILayer.SetEnabled(false); int ButtonStartX = 712; int ButtonStartY = 600; float xScale = 1.5f; float yScale = 1.5f; int Spacing = 145; int menuButtonStartX = 640 - 128; int menuButtonStartY = 150; float menuXScale = 1f; float menuYScale = 1f; int menuSpacing = 110; try { GL11.glEnable(GL11.GL_TEXTURE_2D); BackGroundImage = TextureLoader.getTexture("PNG", ResourceLoader.getResourceAsStream("res/Materials/GUI/UI/GUIPrefab.png")); Texture button1 = TextureLoader.getTexture("PNG", ResourceLoader.getResourceAsStream("res/Materials/GUI/UI/SaveIconButton.png"), false, GL11.GL_NEAREST); ButtonGUILayer.AddButton(ButtonStartX + Spacing * 0, ButtonStartY, (int) (button1.getImageWidth() * xScale), (int) (button1.getImageHeight() * yScale), button1); Texture button2 = TextureLoader.getTexture("PNG", ResourceLoader.getResourceAsStream("res/Materials/GUI/UI/LoadIconButton.png"), false, GL11.GL_NEAREST); ButtonGUILayer.AddButton(ButtonStartX + Spacing * 1, ButtonStartY, (int) (button2.getImageWidth() * xScale), (int) (button2.getImageHeight() * yScale), button2); Texture button3 = TextureLoader.getTexture("PNG", ResourceLoader.getResourceAsStream("res/Materials/GUI/UI/OptionsIconButton.png"), false, GL11.GL_NEAREST); ButtonGUILayer.AddButton(ButtonStartX + Spacing * 2, ButtonStartY, (int) (button3.getImageWidth() * xScale), (int) (button3.getImageHeight() * yScale), button3); Texture button4 = TextureLoader.getTexture("PNG", ResourceLoader.getResourceAsStream("res/Materials/GUI/UI/HelpIconButton.png"), false, GL11.GL_NEAREST); ButtonGUILayer.AddButton(ButtonStartX + Spacing * 3, ButtonStartY, (int) (button4.getImageWidth() * xScale), (int) (button4.getImageHeight() * yScale), button4); Texture mButton0 = TextureLoader.getTexture("PNG", ResourceLoader.getResourceAsStream("res/Materials/GUI/Buttons/ReturnButton.png"), false, GL11.GL_NEAREST); MenuGUILayer.AddButton(menuButtonStartX, menuButtonStartY + menuSpacing * 0, (int) (mButton0.getImageWidth() * menuXScale), (int) (mButton0.getImageHeight() * menuYScale), mButton0); Texture mButton1 = TextureLoader.getTexture("PNG", ResourceLoader.getResourceAsStream("res/Materials/GUI/Buttons/LoadButton.png"), false, GL11.GL_NEAREST); MenuGUILayer.AddButton(menuButtonStartX, menuButtonStartY + menuSpacing * 1, (int) (mButton1.getImageWidth() * menuXScale), (int) (mButton1.getImageHeight() * menuYScale), mButton1); Texture mButton2 = TextureLoader.getTexture("PNG", ResourceLoader.getResourceAsStream("res/Materials/GUI/Buttons/SaveButton.png"), false, GL11.GL_NEAREST); MenuGUILayer.AddButton(menuButtonStartX, menuButtonStartY + menuSpacing * 2, (int) (mButton2.getImageWidth() * menuXScale), (int) (mButton2.getImageHeight() * menuYScale), mButton2); Texture mButton3 = TextureLoader.getTexture("PNG", ResourceLoader.getResourceAsStream("res/Materials/GUI/Buttons/BackButton.png"), false, GL11.GL_NEAREST); MenuGUILayer.AddButton(menuButtonStartX, menuButtonStartY + menuSpacing * 3, (int) (mButton3.getImageWidth() * menuXScale), (int) (mButton3.getImageHeight() * menuYScale), mButton3); } catch (IOException e) { e.printStackTrace(); } GL11.glEnable(GL11.GL_LIGHTING); GL11.glEnable(GL11.GL_LIGHT0); GL11.glEnableClientState(GL11.GL_NORMAL_ARRAY); GL11.glEnableClientState(GL11.GL_COLOR_ARRAY); GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glLoadIdentity(); GLU.gluPerspective(45.0f, (float) Display.getWidth() / (float) Display.getHeight(), 0.1f, 600.0f); GLU.gluLookAt(0, 20, 50, 0, -2, -100, 0, -1, 0); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glLoadIdentity(); GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); }
From source file:game.states.State_SINGLEPLAYER.java
License:Open Source License
@Override protected void Init() { if (CreateNewGame) { CurrentSave = new GameSave(); Worlds = new TileMap[] { new TileMap(), new TileMap(), new TileMap(), new TileMap(), new TileMap(), new TileMap(), new TileMap(), new TileMap(), new TileMap() }; t = Worlds[0];/*from w ww .ja v a2 s .c o m*/ CreateGUI(); System.out.println("Loading worlds"); for (int i = 0; i < Worlds.length; i++) { Worlds[i].Load(i == Worlds.length - 1, i == 0, i); CurrentSave.setIntMapData(TileMapGenerator.Map, i); } } GL11.glEnable(GL11.GL_LIGHTING); GL11.glEnable(GL11.GL_LIGHT0); GL11.glEnableClientState(GL11.GL_NORMAL_ARRAY); GL11.glEnableClientState(GL11.GL_COLOR_ARRAY); GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glLoadIdentity(); GLU.gluPerspective(45.0f, (float) Display.getWidth() / (float) Display.getHeight(), 0.1f, 600.0f); GLU.gluLookAt(0, 20, 50, 0, -2, -100, 0, -1, 0); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glLoadIdentity(); if (CreateNewGame) { player = t.SpawnPlayer(); PlayerGridX = player.getX(); PlayerGridY = player.getY(); PlayerY = 52 - CameraDisplacement * (PlayerGridY - 1); PlayerX = -6 + CameraDisplacement * (PlayerGridX - 1); PlayerZ = 0; SetGUI(); } CreateNewGame = true; GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); }
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();/*from w w w.j a va 2s . c om*/ // 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:geh.Geh.java
public void initGL() { try {/*from www . j av a2 s .c o m*/ Display.setDisplayMode(new DisplayMode(WIDTH, HEIGHT)); Display.create(); } catch (LWJGLException ex) { ex.printStackTrace(); System.exit(0); } Mouse.setGrabbed(false); GL11.glClearColor(0.0f, 0.0f, 0.0f, 1.0f); GL11.glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(0.0, WIDTH, HEIGHT, 0.0, -1.0, 10.0); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); }
From source file:gravestone.models.block.memorials.ModelCreeperStatueMemorial.java
License:LGPL
private void renderCreeperCharging() { float tickModifier = (float) (Minecraft.getSystemTime() % 3000L) / 3000.0F * 48.0F; float scale = 1.2F; float f4 = 0.5F; GL11.glTranslated(0, -0.5, 0);/*from w w w .j a va 2s . c o m*/ GL11.glScalef(scale, scale, scale); TileEntityGSMemorialRenderer.instance.bindTextureByName(Resources.CREEPER_AURA); GL11.glEnable(GL11.GL_BLEND); GL11.glDepthMask(true); GL11.glBlendFunc(GL11.GL_SRC_COLOR, GL11.GL_ONE); GL11.glMatrixMode(GL11.GL_TEXTURE); for (int var21 = 0; var21 < 3; ++var21) { GL11.glLoadIdentity(); float var23 = tickModifier * (0.001F + (float) var21 * 0.0015F) * 15; GL11.glTranslatef(0, var23, 0); renderCreeper(); } GL11.glMatrixMode(GL11.GL_TEXTURE); GL11.glLoadIdentity(); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glEnable(GL11.GL_LIGHTING); GL11.glDisable(GL11.GL_BLEND); GL11.glDepthFunc(GL11.GL_LEQUAL); GL11.glBlendFunc(GL11.GL_ONE, GL11.GL_ONE); GL11.glTranslated(0, -0.19, 0); }
From source file:gravestone.models.block.ModelGraveStone.java
License:LGPL
protected void renderEnchantment() { float tickModifier = (float) (Minecraft.getSystemTime() % 3000L) / 3000.0F * 48.0F; TileEntityGSGraveStoneRenderer.instance.bindTextureByName(Resources.SWORD_AURA); GL11.glEnable(GL11.GL_BLEND);//from w ww.j av a2s . c o m GL11.glDepthMask(true); GL11.glBlendFunc(GL11.GL_SRC_COLOR, GL11.GL_ONE); GL11.glMatrixMode(GL11.GL_TEXTURE); for (int var21 = 0; var21 < 3; var21++) { GL11.glDisable(GL11.GL_LIGHTING); float var22 = 0.76F; GL11.glColor4f(0.5F * var22, 0.25F * var22, 0.8F * var22, 1.0F); GL11.glBlendFunc(GL11.GL_SRC_COLOR, GL11.GL_ONE); GL11.glMatrixMode(GL11.GL_TEXTURE); GL11.glLoadIdentity(); float var23 = tickModifier * (0.001F + (float) var21 * 0.0015F) * 15; float var24 = 0.33333334F; GL11.glScalef(var24, var24, var24); GL11.glRotatef(30 - (float) var21 * 60, 0, 0, 1); GL11.glTranslatef(0, var23, 0); GL11.glMatrixMode(GL11.GL_MODELVIEW); renderAll(); } GL11.glMatrixMode(GL11.GL_TEXTURE); GL11.glDepthMask(true); GL11.glLoadIdentity(); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glEnable(GL11.GL_LIGHTING); GL11.glDisable(GL11.GL_BLEND); GL11.glDepthFunc(GL11.GL_LEQUAL); }