List of usage examples for org.lwjgl.opengl GL11 glMatrixMode
public static native void glMatrixMode(@NativeType("GLenum") int mode);
From source file:$.DrawSystem.java
License:Open Source License
@Override protected void processEntities(ImmutableBag<Entity> entities) { GL11.glClearColor(0.1f, 0, 0, 1f); GL11.glClear(GL11.GL_COLOR_BUFFER_BIT); List<Entity> entititesSortedByZ = new ArrayList<>(entities.size()); for (int i = 0, n = entities.size(); i < n; ++i) { final Entity e = entities.get(i); if (e.isEnabled()) { entititesSortedByZ.add(e); }//from w w w . ja v a 2 s. c om } Collections.sort(entititesSortedByZ, zComparator); GL11.glPushAttrib(GL11.GL_ENABLE_BIT | GL11.GL_TRANSFORM_BIT | GL11.GL_HINT_BIT | GL11.GL_COLOR_BUFFER_BIT | GL11.GL_SCISSOR_BIT | GL11.GL_LINE_BIT | GL11.GL_TEXTURE_BIT); GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glPushMatrix(); GL11.glLoadIdentity(); updateViewPort(); GL11.glViewport(viewPort.x, viewPort.y, viewPort.width, viewPort.height); GLU.gluOrtho2D(-toolkit.getVirtualResolutionWidth() / 2.0f, toolkit.getVirtualResolutionWidth() / 2.0f, toolkit.getVirtualResolutionHeight() / 2.0f, -toolkit.getVirtualResolutionHeight() / 2.0f); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glPushMatrix(); GL11.glLoadIdentity(); GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glEnable(GL11.GL_BLEND); GL11.glEnable(GL11.GL_LINE_SMOOTH); GL11.glDisable(GL11.GL_DEPTH_TEST); GL11.glDisable(GL11.GL_LIGHTING); GL11.glDisable(GL11.GL_SCISSOR_TEST); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glHint(GL11.GL_LINE_SMOOTH_HINT, GL11.GL_NICEST); Game game = (Game) world; Entity hero = game.getHero(); if (null != hero) { Sprite heroSprite = spriteMapper.get(hero); Vector heroPos = spriteProjector.project(heroSprite.getPosition()); GL11.glTranslatef(-heroPos.x, -heroPos.y, 0.0f); } for (Entity e : entititesSortedByZ) { MainMenu mainMenu = mainMenuMapper.getSafe(e); if (null != mainMenu) { mainMenu.draw(); } DialogueComponent dialog = dialogMapper.getSafe(e); if (null != dialog) { dialog.draw(); } Level level = levelMapper.getSafe(e); if (null != level) { drawLevel(level); } Sprite sprite = spriteMapper.getSafe(e); if (null != sprite) { drawSprite(sprite); } } GL11.glPopMatrix(); GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glPopMatrix(); GL11.glPopAttrib(); }
From source file:a1.Main.java
License:Open Source License
private void setView(int screenWidth, int screenHeight) { GL11.glViewport(0, 0, screenWidth, screenHeight); GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glLoadIdentity();/*from ww w . ja va 2s . co m*/ GL11.glOrtho(0, screenWidth, screenHeight, 0, -1, 1); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glLoadIdentity(); }
From source file:advancedbrewing.renderer.ItemGlintOverlayRenderer.java
License:Minecraft Mod Public
private void renderItem3D(ItemRenderType type, ItemStack itemStack, Object... data) { TextureManager renderEngine = FMLClientHandler.instance().getClient().renderEngine; Tessellator tessellator = Tessellator.instance; if (this.shouldRenderOverlay(itemStack)) { // render colored overlay renderEngine.bindTexture(renderEngine.getResourceLocation(itemStack.getItemSpriteNumber())); this.setColorByItemStack(itemStack); Icon icon = this.getIcon(itemStack, 0); ItemRenderer.renderItemIn2D(tessellator, icon.getMaxU(), icon.getMinV(), icon.getMinU(), icon.getMaxV(), icon.getIconWidth(), icon.getIconHeight(), 0.0625F); // render glint if (itemStack.hasEffect(0)) { renderEngine.bindTexture(ItemGlintOverlayRenderer.RES_ITEM_GLINT); GL11.glDepthFunc(GL11.GL_EQUAL); GL11.glDisable(GL11.GL_LIGHTING); GL11.glEnable(GL11.GL_BLEND); GL11.glMatrixMode(GL11.GL_TEXTURE); GL11.glBlendFunc(GL11.GL_SRC_COLOR, GL11.GL_ONE); GL11.glColor4f(0.5F, 0.25F, 0.8F, 1.0F); // first pass GL11.glPushMatrix();/*from ww w. j av a 2 s . c o m*/ GL11.glScalef(0.125F, 0.125F, 0.125F); float f9 = Minecraft.getSystemTime() % 3000L / 3000.0F * 8.0F; GL11.glTranslatef(f9, 0.0F, 0.0F); GL11.glRotatef(-50.0F, 0.0F, 0.0F, 1.0F); ItemRenderer.renderItemIn2D(tessellator, 0.0F, 0.0F, 1.0F, 1.0F, 256, 256, 0.0625F); GL11.glPopMatrix(); // second pass GL11.glPushMatrix(); GL11.glScalef(0.125F, 0.125F, 0.125F); f9 = Minecraft.getSystemTime() % 4873L / 4873.0F * 8.0F; GL11.glTranslatef(-f9, 0.0F, 0.0F); GL11.glRotatef(10.0F, 0.0F, 0.0F, 1.0F); ItemRenderer.renderItemIn2D(tessellator, 0.0F, 0.0F, 1.0F, 1.0F, 256, 256, 0.0625F); GL11.glPopMatrix(); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glDisable(GL11.GL_BLEND); GL11.glEnable(GL11.GL_LIGHTING); GL11.glDepthFunc(GL11.GL_LEQUAL); } } // render uncolored icon renderEngine.bindTexture(renderEngine.getResourceLocation(itemStack.getItemSpriteNumber())); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); Icon icon = this.getIcon(itemStack, 1); ItemRenderer.renderItemIn2D(tessellator, icon.getMaxU(), icon.getMinV(), icon.getMinU(), icon.getMaxV(), icon.getIconWidth(), icon.getIconHeight(), 0.0625F); }
From source file:akarnokd.opengl.experiment.FontExample.java
License:Apache License
/** * Initialise the GL display/*from w w w. j ava 2s .c o m*/ * * @param width The width of the display * @param height The height of the display */ private void initGL(int width, int height) { try { Display.setDisplayMode(new DisplayMode(width, height)); Display.create(); Display.setVSyncEnabled(true); } 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, 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); }
From source file:aphelion.client.Client.java
License:Open Source License
public static void initGL() { int displayWidth = Display.getWidth(); int displayHeight = Display.getHeight(); glDisableAll();//from w w w. j a v a2 s. c om GL11.glViewport(0, 0, displayWidth, displayHeight); GL11.glMatrixMode(GL11.GL_PROJECTION); // Apply subsequent matrix operations to the projection matrix stack. GL11.glLoadIdentity(); GL11.glOrtho(0, displayWidth, displayHeight, 0, -1, 1); GL11.glMatrixMode(GL11.GL_TEXTURE); GL11.glLoadIdentity(); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glLoadIdentity(); GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_STENCIL_BUFFER_BIT); AsyncTexture.unbind(); // Enable alpha channels for images GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glEnable(GL11.GL_BLEND); Graph.g.setDimensions(displayWidth, displayHeight); Graphics.setCurrent(Graph.g); Graph.g.setDrawMode(Graphics.MODE_NORMAL); }
From source file:arg.RenderRecipe.java
License:Open Source License
public void draw() { File dir = new File(Minecraft.getMinecraft().mcDataDir, "recipes"); if (!dir.exists() && !dir.mkdirs()) { throw new RuntimeException("The recipes directory could not be created: " + dir); }//from www. j a v a 2s . c o m name = name.replace(" ", ""); File file = new File(Minecraft.getMinecraft().mcDataDir, "recipes/" + name + ".png"); if (file.exists()) return; GL11.glPushMatrix(); GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS); GL11.glPushClientAttrib(GL11.GL_ALL_CLIENT_ATTRIB_BITS); GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT); GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glLoadIdentity(); GL11.glViewport(0, 0, width, height); GL11.glOrtho(0.0D, xSize, ySize, 0.0D, 1000.0D, 3000.0D); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glLoadIdentity(); GL11.glTranslatef(0.0F, 0.0F, -2000.0F); GL11.glLineWidth(1.0F); GL11.glEnable(GL11.GL_COLOR_MATERIAL); try { drawScreen(0, 0, 0); } catch (Exception e) { e.printStackTrace(); } int[] pixels = new int[width * height]; int bindex; ByteBuffer fb = ByteBuffer.allocateDirect(width * height * 3); GL11.glReadPixels(0, 0, width, height, GL11.GL_RGB, GL11.GL_UNSIGNED_BYTE, fb); GL11.glPopMatrix(); GL11.glPopAttrib(); GL11.glPopClientAttrib(); GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT); try { Display.swapBuffers(); } catch (LWJGLException e1) { e1.printStackTrace(); } BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); for (int x = 0; x < width; x++) { for (int y = 0; y < height; y++) { int i = (x + (width * y)) * 3; int r = fb.get(i) & 0xFF; int g = fb.get(i + 1) & 0xFF; int b = fb.get(i + 2) & 0xFF; image.setRGB(x, height - (y + 1), (0xFF << 24) | (r << 16) | (g << 8) | b); } } try { ImageIO.write(image, "png", file); } catch (Exception e) { e.printStackTrace(); } }
From source file:br.org.archimedes.gui.opengl.OpenGLWrapper.java
License:Open Source License
/** * Clears the OpenGL canvas.//w w w. j ava2s . c o m */ public void clear() { Color currentBkColor = br.org.archimedes.Utils.getWorkspace().getBackgroundColor(); GL11.glClearColor((float) currentBkColor.getR(), (float) currentBkColor.getG(), (float) currentBkColor.getB(), 0); GL11.glClear(GL11.GL_COLOR_BUFFER_BIT); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glLoadIdentity(); resize(); }
From source file:ccm.placeableTools.client.ToolRenderer.java
License:Open Source License
public static void doRenderPass(int i, int meta, ItemStack stack, double x, double y, double z) { Icon icon = stack.getItem().getIcon(stack, i); if (icon == null) return;/* w w w. j a v a 2s.co m*/ GL11.glPushMatrix(); TextureManager texturemanager = Minecraft.getMinecraft().getTextureManager(); texturemanager.bindTexture(texturemanager.getResourceLocation(stack.getItemSpriteNumber())); Tessellator tessellator = Tessellator.instance; GL11.glTranslated(x, y, z); //Center to block GL11.glEnable(GL12.GL_RESCALE_NORMAL); GL11.glTranslatef(-0.5f, .5f, 0.5f); // Center on block if (stack.getItem() instanceof ItemSpade || stack.getItem() instanceof ItemHoe) { float shift = 0.3f; switch (ForgeDirection.values()[meta]) { case NORTH: GL11.glTranslatef(0, 0, -shift); GL11.glRotatef(15f, -0.5f, 0, 0); break; case SOUTH: GL11.glTranslatef(0, 0, shift); GL11.glRotatef(-15f, -0.5f, 0, 0); break; case EAST: GL11.glRotatef(90f, 0, 1, 0); GL11.glTranslatef(-1, 0, 1); GL11.glTranslatef(0, 0, shift); GL11.glRotatef(-15f, -0.5f, 0, 0); break; case WEST: GL11.glRotatef(90f, 0, 1, 0); GL11.glTranslatef(-1, 0, 1); GL11.glTranslatef(0, 0, -shift); GL11.glRotatef(15f, -0.5f, 0, 0); break; case DOWN: GL11.glRotatef(90f, 0, 1, 0); GL11.glTranslatef(-1, 0, 1); break; } GL11.glTranslatef(0, 0, -0.03f); //Icon depth of the shovel GL11.glRotatef(180f, 1, 0, 0); } else if (stack.getItem() instanceof ItemAxe || stack.getItem() instanceof ItemPickaxe) { float shift = 0.15f; switch (ForgeDirection.values()[meta]) { case NORTH: GL11.glRotatef(90f, 0, 1, 0); GL11.glTranslatef(-1, 0, 1); GL11.glTranslatef(shift, 0, 0); GL11.glRotatef(-10f, 0, 0, 1); break; case SOUTH: GL11.glRotatef(-90f, 0, 1, 0); GL11.glTranslatef(-1, 0, -1); GL11.glTranslatef(shift, 0, 0); GL11.glRotatef(-10f, 0, 0, 1); break; case EAST: GL11.glTranslatef(shift, 0, 0); GL11.glRotatef(-10f, 0, 0, 1); break; case WEST: GL11.glRotatef(180f, 0, 1, 0); GL11.glTranslatef(-2, 0, 0); GL11.glTranslatef(shift, 0, 0); GL11.glRotatef(-10f, 0, 0, 1); break; } GL11.glTranslatef(0, 0, 0.03F); } else if (stack.getItem() instanceof ItemSword) { float shift = 0.15f; switch (ForgeDirection.values()[meta]) { case NORTH: GL11.glRotatef(90f, 0, 1, 0); GL11.glTranslatef(shift, 0, 0); GL11.glRotatef(-90f, 0, 0, 1); GL11.glTranslatef(-1, 0, 1); break; case SOUTH: GL11.glRotatef(-90f, 0, 1, 0); GL11.glTranslatef(shift, 0, 0); GL11.glRotatef(-90f, 0, 0, 1); GL11.glTranslatef(-1, 0, -1); break; case EAST: GL11.glTranslatef(shift, 0, 0); GL11.glRotatef(-90f, 0, 0, 1); GL11.glTranslatef(-1, 1, 0); break; case WEST: GL11.glRotatef(180f, 0, 1, 0); GL11.glTranslatef(-1, 1, 0); GL11.glTranslatef(shift, 0, 0); GL11.glRotatef(-90f, 0, 0, 1); break; case UP: GL11.glRotatef(180f, 1, 0, 0); GL11.glTranslatef(1, 0, 1); GL11.glRotatef(90f, 0, 1, 0); break; case DOWN: GL11.glRotatef(180f, 1, 0, 0); break; } GL11.glTranslatef(-0.05f, 0, 0.03F); } GL11.glRotatef(-45f, 0, 0, 1); GL11.glScalef(1.5f, 1.5f, 1.5f); ItemRenderer.renderItemIn2D(tessellator, icon.getMaxU(), icon.getMinV(), icon.getMinU(), icon.getMaxV(), icon.getIconWidth(), icon.getIconHeight(), 0.06F / 1.5f); if (stack.hasEffect(i)) { GL11.glDepthFunc(GL11.GL_EQUAL); GL11.glDisable(GL11.GL_LIGHTING); texturemanager.bindTexture(RES_ITEM_GLINT); GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_COLOR, GL11.GL_ONE); float f7 = 0.76F; GL11.glColor4f(0.5F * f7, 0.25F * f7, 0.8F * f7, 1.0F); GL11.glMatrixMode(GL11.GL_TEXTURE); GL11.glPushMatrix(); float f8 = 0.125F; GL11.glScalef(f8, f8, f8); float f9 = (float) (Minecraft.getSystemTime() % 3000L) / 3000.0F * 8.0F; GL11.glTranslatef(f9, 0.0F, 0.0F); GL11.glRotatef(-50.0F, 0.0F, 0.0F, 1.0F); ItemRenderer.renderItemIn2D(tessellator, 0.0F, 0.0F, 1.0F, 1.0F, 256, 256, 0.06F / 1.5f); GL11.glPopMatrix(); GL11.glPushMatrix(); GL11.glScalef(f8, f8, f8); f9 = (float) (Minecraft.getSystemTime() % 4873L) / 4873.0F * 8.0F; GL11.glTranslatef(-f9, 0.0F, 0.0F); GL11.glRotatef(10.0F, 0.0F, 0.0F, 1.0F); ItemRenderer.renderItemIn2D(tessellator, 0.0F, 0.0F, 1.0F, 1.0F, 256, 256, 0.06F / 1.5f); GL11.glPopMatrix(); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glDisable(GL11.GL_BLEND); GL11.glEnable(GL11.GL_LIGHTING); GL11.glDepthFunc(GL11.GL_LEQUAL); } GL11.glDisable(GL12.GL_RESCALE_NORMAL); GL11.glPopMatrix(); }
From source file:cellularautomata.CellularAutomata.java
public static void renderGL() { try { //Trys to create a game window size 500x700. Display.setDisplayMode(new org.lwjgl.opengl.DisplayMode(800, 600)); Display.create();//w w w .ja va2s. c o m } catch (LWJGLException e) { //Catches exception if game window is not created. 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); //Sets colour to white. 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(vsync); }
From source file:cn.academy.ability.electro.client.render.skill.RailgunPlaneEffect.java
License:Open Source License
@SideOnly(Side.CLIENT) @Override/*from w w w . j ava2 s . co m*/ public void renderHandEffect(EntityPlayer player, HandRenderType type, long dt) { if (type == HandRenderType.EQUIPPED) return; if (dt < DELAY) return; dt -= DELAY; double tz = dt * dt / 3e4; double TRANS_TIME = ANIM_LEN * 0.2; double alpha = (dt < TRANS_TIME ? dt / TRANS_TIME : (dt > ANIM_LEN - TRANS_TIME ? (ANIM_LEN - dt) / TRANS_TIME : 1)); //Draw a screen-filling blackout GL11.glDisable(GL11.GL_TEXTURE_2D); GL11.glDisable(GL11.GL_CULL_FACE); GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glPushMatrix(); GL11.glLoadIdentity(); GLU.gluOrtho2D(0, 255, 0, 255); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glPushMatrix(); GL11.glDepthMask(false); GL11.glLoadIdentity(); { GL11.glTranslated(0, 0, 0); GL11.glColor4d(0, 0, 0, 0.2 * alpha); HudUtils.setZLevel(1); HudUtils.drawModalRect(0, 0, 255, 255); HudUtils.setZLevel(-90); } GL11.glDepthMask(true); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glPopMatrix(); GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glPopMatrix(); GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glEnable(GL11.GL_CULL_FACE); GL11.glMatrixMode(GL11.GL_MODELVIEW); //Restore the matrix //Draw the real effect GL11.glColor4d(1, 1, 1, alpha * 0.6); GL11.glEnable(GL11.GL_ALPHA_TEST); GL11.glAlphaFunc(GL11.GL_GREATER, 0.0f); GL11.glPushMatrix(); { GL11.glTranslated(-.4, 0.85 + tz * 0.37, tz); GL11.glRotated(-20.4, 1, 0, 0); drawSingleSide(7); // GL11.glPushMatrix(); { // GL11.glTranslated(-2.3, 0, 0); // drawSingleSide(7); // } GL11.glPopMatrix(); } GL11.glPopMatrix(); GL11.glDisable(GL11.GL_ALPHA_TEST); }