List of usage examples for org.lwjgl.opengl GL11 glTranslatef
public static native void glTranslatef(@NativeType("GLfloat") float x, @NativeType("GLfloat") float y, @NativeType("GLfloat") float z);
From source file:Robot.java
private void drawHead() { GL11.glColor4f(robotColor[0], robotColor[1], robotColor[2], 1); float EYE_RADIUS = HEAD_RADIUS / 5; float MOUTH_WIDTH = HEAD_RADIUS * 0.7f; // the circular face if (selected.get("HEAD")) { DrawShapes.fillCircle(HEAD_RADIUS, HEAD_SIDES); } else {/*from w w w . java 2 s .co m*/ DrawShapes.strokeCircle(HEAD_RADIUS, HEAD_SIDES); } // draw the right eye GL11.glPushMatrix(); GL11.glTranslatef(HEAD_RADIUS / 2 - EYE_RADIUS / 2, HEAD_RADIUS * 0.1f, 0); if (selected.get("HEAD")) { GL11.glColor4f(1, 1, 0, 1); DrawShapes.strokeCircle(EYE_RADIUS, HEAD_SIDES); GL11.glColor4f(1, 1, 1, 1); DrawShapes.fillCircle(EYE_RADIUS * 0.8f, HEAD_SIDES); setColor(robotColor[0], robotColor[1], robotColor[2]); } else { DrawShapes.strokeCircle(EYE_RADIUS, HEAD_SIDES); DrawShapes.strokeCircle(EYE_RADIUS * 0.8f, HEAD_SIDES); } GL11.glPopMatrix(); // draw the left eye GL11.glPushMatrix(); GL11.glTranslatef(-HEAD_RADIUS / 2 + EYE_RADIUS / 2, HEAD_RADIUS * 0.1f, 0); if (selected.get("HEAD")) { GL11.glColor4f(1, 1, 0, 1); DrawShapes.strokeCircle(EYE_RADIUS, HEAD_SIDES); GL11.glColor4f(1, 1, 1, 1); DrawShapes.fillCircle(EYE_RADIUS * 0.8f, HEAD_SIDES); setColor(robotColor[0], robotColor[1], robotColor[2]); } else { DrawShapes.strokeCircle(EYE_RADIUS, HEAD_SIDES); DrawShapes.strokeCircle(EYE_RADIUS * 0.8f, HEAD_SIDES); } GL11.glPopMatrix(); // draw the mouth GL11.glPushMatrix(); GL11.glTranslatef(0, -HEAD_RADIUS / 2, 0); if (selected.get("HEAD")) { GL11.glColor4f(1, 1, 1, 1); DrawShapes.fillRectangle(-MOUTH_WIDTH * 0.5f, 0, MOUTH_WIDTH, MOUTH_WIDTH * 0.1f); setColor(robotColor[0], robotColor[1], robotColor[2]); } else { DrawShapes.strokeRectangle(-MOUTH_WIDTH * 0.5f, 0, MOUTH_WIDTH, MOUTH_WIDTH * 0.1f); } GL11.glPopMatrix(); }
From source file:Robot.java
public void draw() { updateAngles();/* w ww.j a v a 2 s. co m*/ updateLocation(); GL11.glPushMatrix(); GL11.glScalef(0.5f, 0.5f, 0.5f); // drawing the torso GL11.glTranslatef(torsoX, torsoY, 0); GL11.glRotatef(torsoAngle[CURRENT_ANGLE], 0, 0, 1); drawTorso(); // drawing the neck GL11.glPushMatrix(); GL11.glTranslatef(0, TORSO_HEIGHT, 0); GL11.glRotatef(neckAngle[CURRENT_ANGLE], 0, 0, 1); drawNeck(); // drawing the head GL11.glTranslatef(0, NECK_HEIGHT + HEAD_RADIUS, 0); GL11.glRotatef(headAngle[CURRENT_ANGLE], 0, 0, 1); drawHead(); GL11.glPopMatrix(); // drawing the right arms GL11.glPushMatrix(); GL11.glTranslatef(TORSO_WIDTH / 2, TORSO_HEIGHT - UPPER_ARM_HEIGHT, 0); GL11.glRotatef(upperRightArmAngle[CURRENT_ANGLE], 0, 0, 1); drawUpperRightArm(); GL11.glTranslatef(UPPER_ARM_WIDTH, LOWER_ARM_HEIGHT, 0); GL11.glRotatef(lowerRightArmAngle[CURRENT_ANGLE], 0, 0, 1); drawLowerRightArm(); GL11.glPopMatrix(); // drawing the left arms GL11.glPushMatrix(); GL11.glScalef(-1, 1, 1); // same as the right arm but on the other side GL11.glTranslatef(TORSO_WIDTH / 2, TORSO_HEIGHT - UPPER_ARM_HEIGHT, 0); GL11.glRotatef(upperLeftArmAngle[CURRENT_ANGLE], 0, 0, 1); drawUpperLeftArm(); GL11.glTranslatef(UPPER_ARM_WIDTH, LOWER_ARM_HEIGHT, 0); GL11.glRotatef(lowerLeftArmAngle[CURRENT_ANGLE], 0, 0, 1); drawLowerLeftArm(); GL11.glPopMatrix(); // drawing the right leg GL11.glPushMatrix(); GL11.glTranslatef(TORSO_WIDTH / 4 - THIGH_WIDTH / 2, 0, 0); GL11.glRotatef(rightThighAngle[CURRENT_ANGLE], 0, 0, 1); drawRightThigh(); GL11.glTranslatef(0, -THIGH_HEIGHT, 0); GL11.glRotatef(rightCalfAngle[CURRENT_ANGLE], 0, 0, 1); drawRightCalf(); GL11.glPopMatrix(); // drawing the left leg GL11.glPushMatrix(); GL11.glScalef(-1, 1, 1); // same as the right arm but on the other side GL11.glTranslatef(TORSO_WIDTH / 4 - THIGH_WIDTH / 2, 0, 0); GL11.glRotatef(leftThighAngle[CURRENT_ANGLE], 0, 0, 1); drawLeftThigh(); GL11.glTranslatef(0, -THIGH_HEIGHT, 0); GL11.glRotatef(leftCalfAngle[CURRENT_ANGLE], 0, 0, 1); drawLeftCalf(); GL11.glPopMatrix(); GL11.glPopMatrix(); }
From source file:DrawShapes.java
public static void strokeCircle(float x, float y, float z, float radius, int sides) { GL11.glPushMatrix();// www .j a va2 s .c o m GL11.glTranslatef(x, y, z); strokeCircle(radius, sides); GL11.glPopMatrix(); }
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); }//w w w .j av a 2 s. com } 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:$.DrawSystem.java
License:Open Source License
private void drawSprite(Sprite sprite) { Vector pos = spriteProjector.project(sprite.getPosition()); final IPlay play = sprite.getPlay(); if (null != play) { GL11.glPushMatrix();/*from w w w. j a v a 2 s .c om*/ GL11.glTranslatef(pos.x, pos.y, 0.0f); GL11.glRotatef(sprite.getRotate(), 0, 0, 1.0f); GL11.glScalef(sprite.getScale(), sprite.getScale(), 1); final IAnimationFrame frame = play.getCurrentFrame(); final IAnimationImage image = frame.getImage(); if (image.hasAlpha()) { GL11.glEnable(GL11.GL_BLEND); } GL11.glBindTexture(GL11.GL_TEXTURE_2D, (Integer) image.getId()); final float u1, u2; if (sprite.isMirrorX()) { u1 = frame.getU2(); u2 = frame.getU1(); } else { u1 = frame.getU1(); u2 = frame.getU2(); } final float v1, v2; if (sprite.isMirrorY()) { v1 = frame.getV1(); v2 = frame.getV2(); } else { v1 = frame.getV2(); v2 = frame.getV1(); } GL11.glColor4f(sprite.getRed(), sprite.getGreen(), sprite.getBlue(), sprite.getAlpha()); float x1 = -sprite.getWidth() / 2.0f; float x2 = sprite.getWidth() / 2.0f; float y1 = -sprite.getHeight() / 2.0f; float y2 = sprite.getHeight() / 2.0f; GL11.glBegin(GL11.GL_QUADS); GL11.glTexCoord2f(u1, v1); GL11.glVertex2f(x1, y2); GL11.glTexCoord2f(u2, v1); GL11.glVertex2f(x2, y2); GL11.glTexCoord2f(u2, v2); GL11.glVertex2f(x2, y1); GL11.glTexCoord2f(u1, v2); GL11.glVertex2f(x1, y1); GL11.glEnd(); GL11.glColor3f(1f, 1f, 1f); if (image.hasAlpha()) { GL11.glDisable(GL11.GL_BLEND); } GL11.glPopMatrix(); } if (null != sprite.getLabel()) { GL11.glPushMatrix(); GL11.glTranslatef(pos.x, pos.y, 0.0f); GL11.glScalef(0.5f, -0.5f, 1f); GL11.glEnable(GL11.GL_BLEND); LwjglNuitFont font = (LwjglNuitFont) assets.getFont(""); font.drawString(sprite.getLabel(), LwjglNuitFont.Align.CENTER); GL11.glDisable(GL11.GL_BLEND); GL11.glPopMatrix(); } }
From source file:a1.gui.GUI_Map.java
License:Open Source License
public void RenderLightMap() { GL11.glBlendFunc(GL11.GL_ZERO, GL11.GL_SRC_COLOR); //Log.info("lightmap: "+LightMap); GL11.glBindTexture(GL11.GL_TEXTURE_2D, LightMap); //Resource.textures.get("core_skin").getTextureID()); GL11.glTranslatef(0, 0, 0); GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f); float texwidth = 1024; float texheight = 1024; float newTextureOffsetX = 0 / texwidth; float newTextureOffsetY = 0 / texheight; float newTextureWidth = 1024 / texwidth; float newTextureHeight = 1024 / texheight; int w = 1024; int h = 1024; GL11.glBegin(GL11.GL_QUADS);/* w w w.java 2 s . com*/ { glTexCoord2f(newTextureOffsetX, newTextureOffsetY); glVertex2i(0, 0); glTexCoord2f(newTextureOffsetX, newTextureOffsetY + newTextureHeight); glVertex2i(0, h); glTexCoord2f(newTextureOffsetX + newTextureWidth, newTextureOffsetY + newTextureHeight); glVertex2i(w, h); glTexCoord2f(newTextureOffsetX + newTextureWidth, newTextureOffsetY); glVertex2i(w, 0); } GL11.glEnd(); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); }
From source file:additionalpipes.client.gui.GuiTeleportManager.java
License:Minecraft Mod Public
private void renderPipeMap(int map, MapData mapData) { RenderHelper.disableStandardItemLighting(); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); GL11.glDisable(GL11.GL_DEPTH_TEST);/*from w ww . j av a2 s. co m*/ mc.renderEngine.bindTexture(MAP_TEXTURE); GL11.glPushMatrix(); Tessellator var4 = Tessellator.instance; var4.startDrawingQuads(); byte var5 = 7; var4.addVertexWithUV(0 - var5, 128 + var5, 0.0D, 0.0D, 1.0D); var4.addVertexWithUV(128 + var5, 128 + var5, 0.0D, 1.0D, 1.0D); var4.addVertexWithUV(128 + var5, 0 - var5, 0.0D, 1.0D, 0.0D); var4.addVertexWithUV(0 - var5, 0 - var5, 0.0D, 0.0D, 0.0D); var4.draw(); mapRenderer.renderMap(mc.thePlayer, mc.renderEngine, mapData); PropertyIntArray pipeArr = (PropertyIntArray) clientProps.propPipes.value.get(PropertyInteger.create(map)); int[] pipes = pipeArr != null ? pipeArr.value : ArrayUtils.EMPTY_INT_ARRAY; for (int p = 0; p < pipes.length / 3; p++) { int centerX = pipes[p * 3 + 1]; int centerZ = pipes[p * 3 + 2]; GL11.glPushMatrix(); GL11.glTranslatef(centerX / 2.0F + 64.0F - 4, centerZ / 2.0F + 64.0F - 4, -0.02F); GL11.glScalef(0.5F, 0.5F, 0.5F); itemRenderer.renderItemAndEffectIntoGUI(fontRenderer, mc.renderEngine, new ItemStack(getTeleportPipe(PipeType.values()[pipes[p * 3]]), 1), 0, 0); GL11.glPopMatrix(); } GL11.glPopMatrix(); }
From source file:additionalpipes.client.gui.GuiTeleportManager.java
License:Minecraft Mod Public
@Override protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { super.drawGuiContainerForegroundLayer(mouseX, mouseY); float scrollPercent = scrollLine / (float) getScrollMax(); int scrollBarLeft = guiLeft + xSize - 20; int scrollBarTop = guiTop + 18; int scrollBarBottom = scrollBarTop + 113; boolean isClicking = Mouse.isButtonDown(0); if (!wasClicking && isClicking && mouseX >= scrollBarLeft && mouseX < scrollBarLeft + 20 && mouseY >= scrollBarTop && mouseY < scrollBarBottom) { isScrolling = needsScrollBars(); }/*from ww w . java 2 s . c o m*/ if (!isClicking) { isScrolling = false; } wasClicking = isClicking; if (isScrolling) { scrollPercent = (mouseY - scrollBarTop - 7.5F) / (scrollBarBottom - scrollBarTop - 20.0F); if (scrollPercent < 0.0F) { scrollPercent = 0.0F; } else if (scrollPercent > 1.0F) { scrollPercent = 1.0F; } scrollLine = (int) (scrollPercent * getScrollMax() + 0.5D); validateScrollLine(); } fontRenderer.drawString(StringUtils.localize("container.teleportManager"), 8, 6, clientProps.propIsPublic.value ? 0x0000FF : 0x404040); fontRenderer.drawString(StringUtils.localize("gui.inventory"), 8, 130, 0x404040); RenderHelper.disableStandardItemLighting(); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); mc.renderEngine.bindTexture(CREATIVE_TEXTURE); drawTexturedModalRect(xSize - 20, 18 + (int) (93 * scrollPercent), 232 + (needsScrollBars() ? 0 : 12), 0, 12, 15); theMap = -1; int[] maps = clientProps.propMaps.value; if (maps.length == 0) { if (mouseX >= guiLeft + 8 && mouseX < guiLeft + 8 + 36 * MAPS_ROW && mouseY >= guiTop + 18 && mouseY < guiTop + 18 + 36 * MAPS_COL) { String text = StringUtils .localize(AdditionalPipes.disableLinkingUsage ? "gui.map.emptyHint.position" : "gui.map.emptyHint.link"); int width = fontRenderer.getStringWidth(text); GL11.glPushMatrix(); GL11.glTranslatef(-guiLeft, -guiTop, 0); drawCreativeTabHoveringText(text, mouseX - 12 - width / 2, mouseY - 4); GL11.glPopMatrix(); } } else if (currentMap == -1) { ItemStack mapStack = new ItemStack(Item.map, 1, 0); for (int i = 0; i < MAPS_COL; i++) { for (int j = 0; j < MAPS_ROW; j++) { int index = j + (scrollLine + i) * MAPS_ROW; if (index < maps.length) { mapStack.setItemDamage(maps[index]); MapData mapData = Item.map.getMapData(mapStack, mc.theWorld); if (mapData != null) { int x = 10 + j * 36; int y = 20 + i * 36; GL11.glPushMatrix(); GL11.glTranslatef(x, y, 0.0F); GL11.glScalef(0.25F, 0.25F, 0.25F); renderPipeMap(maps[index], mapData); GL11.glPopMatrix(); } } } } int index = getMapIndexAtPos(mouseX, mouseY); if (index >= 0 && index < maps.length) { theMap = index; mapStack.setItemDamage(maps[index]); drawItemStackTooltip(mapStack, mouseX - guiLeft + 8, mouseY - guiTop + 8); } } else { MapData mapData = Item.map.getMapData(new ItemStack(Item.map, 1, maps[currentMap]), mc.theWorld); if (mapData != null) { GL11.glPushMatrix(); GL11.glTranslatef(7, guiTop, 0.0F); GL11.glScalef(1.25F, 1.25F, 1.25F); renderPipeMap(maps[currentMap], mapData); GL11.glPopMatrix(); } } RenderHelper.enableGUIStandardItemLighting(); }
From source file:adrianton.gloptat.plotter.Displayer.java
License:Open Source License
private void surface() { GL11.glLoadIdentity();/*ww w .j a v a 2 s .c om*/ GL11.glTranslatef(posx, posy, posz); GL11.glRotatef(roty, 1, 0, 0); GL11.glRotatef(rotz, 0, 0, 1); GL11.glScaled(0.3, 0.3, 0.3); GL11.glScaled(pasz, pasz, pasz); Surface.call(); }
From source file:adrianton.gloptat.plotter.Displayer.java
License:Open Source License
private void box() { float spx = -rezx / 2f; float spy = -rezy / 2f; float epx = spx + rezx; float epy = spy + rezy; GL11.glPushMatrix();// www . ja v a 2s . c o m GL11.glTranslatef(0, 0, (float) (minc + (maxc - minc) / 2)); GL11.glScalef(rezx / 2f, rezy / 2f, (float) (maxc - minc) / 2f); Box.call(); GL11.glPopMatrix(); }