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:com.shinoow.abyssalcraft.client.render.item.RenderStaff.java
License:Apache License
@Override public void renderItem(ItemRenderType type, ItemStack item, Object... data) { if (type == ItemRenderType.EQUIPPED_FIRST_PERSON || type == ItemRenderType.EQUIPPED) { GL11.glPushMatrix();//from www. jav a 2 s.c om FMLClientHandler.instance().getClient().renderEngine.bindTexture(resource); GL11.glRotatef(170F, 1.0F, 0.4F, -0.5F); if (type == ItemRenderType.EQUIPPED) GL11.glTranslatef(0.41F, -0.4F, -0.55F); else GL11.glTranslatef(0.61F, -0.4F, -0.55F); float scale = 1.1F; GL11.glScalef(scale, scale, scale); model.render((Entity) data[1], 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0625F); GL11.glPopMatrix(); } if (type == ItemRenderType.ENTITY) { GL11.glPushMatrix(); float scale = 1.5F; GL11.glScalef(scale, scale, scale); FMLClientHandler.instance().getClient().renderEngine.bindTexture(resource); GL11.glRotatef(0F, 1.0f, 0.0f, 0.0f); GL11.glRotatef(0F, 0.0f, 1.0f, 0.0f); GL11.glRotatef(90F, 0.0f, 0.0f, 1.0f); GL11.glTranslatef(0.1F, -0.5F, 0.1F); model.render((Entity) data[1], 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0625F); GL11.glPopMatrix(); } if (type == ItemRenderType.INVENTORY) { GL11.glPushMatrix(); float scale = 1.0F; GL11.glScalef(scale, scale, scale); FMLClientHandler.instance().getClient().renderEngine.bindTexture(resource); GL11.glRotatef(80F, 1.0f, 0.0f, 0.0f); GL11.glRotatef(-80F, 0.0f, 1.0f, 0.0f); GL11.glTranslatef(0.0F, 0.0F, 0F); model.render(0.0625F); GL11.glPopMatrix(); } }
From source file:com.sijobe.console.GuiConsole.java
License:Open Source License
/** * Draws the specified String flipped upside down * * @param fontrenderer// w w w . ja v a2s.co m * @param s string to draw * @param i position of the x coordinate * @param j position of the y coordinate * @param k colour of the render * @param flag if true draw with shadow, if false draw without shadow */ public void drawStringFlipped(FontRenderer fontrenderer, String s, int i, int j, int k, boolean flag) { GL11.glPushMatrix(); GL11.glScalef(-1F, -1F, 1F); GL11.glTranslatef((-i * 2) - fontrenderer.getStringWidth(s), (-j * 2) - fontrenderer.FONT_HEIGHT, 0.0F); if (flag) { fontrenderer.drawString(s, i - 1, j - 1, (k & 0xfcfcfc) >> 2 | k & 0xff000000); //Took the last argument from FrontRenderer.renderString() because it's private and I want the shadow on the correct side when flipped } fontrenderer.drawString(s, i, j, k); GL11.glPopMatrix(); }
From source file:com.sirolf2009.necroapi.NecroEntityQuadruped.java
License:LGPL
@Override public void preRender(Entity entity, BodyPart[] parts, BodyPartLocation location, ModelBase model) { if (entity.getDataWatcher().getWatchableObjectByte(16) == 1 && location == BodyPartLocation.Torso) { GL11.glRotatef(-90, 1, 0, 0);//from w w w .ja v a2 s. c o m GL11.glTranslatef(0, -0.5F, 1); } }
From source file:com.smithsmodding.smithscore.util.client.gui.GuiHelper.java
/** * Renders a texture as if it would be the center of a MultiComponentTexture. * * @param pComponent The Component to Render * @param pWidth The total width of the Component in the End * @param pHeight The total height of the Component in the End * @param pElementCoordinate The offset of the Component from the current GL Buffer Matric Origin. *///ww w . j a va 2 s . c om private static void renderCenter(TextureComponent pComponent, int pWidth, int pHeight, Coordinate2D pElementCoordinate) { GL11.glPushMatrix(); GL11.glTranslatef(pElementCoordinate.getXComponent() + pComponent.iRelativeTranslation.getXComponent(), pElementCoordinate.getYComponent() + pComponent.iRelativeTranslation.getYComponent(), 0F); pComponent.iRotation.performGLRotation(); bindTexture(pComponent.iAddress); if (pWidth <= pComponent.iWidth && pHeight <= pComponent.iHeight) { drawTexturedModalRect(0, 0, 0, pComponent.iU, pComponent.iV, pWidth, pHeight); } else { int tDrawnHeight = 0; int tDrawnWidth = 0; while (tDrawnHeight < (pHeight)) { int tHeightToRender = pHeight - tDrawnHeight; if (tHeightToRender >= pComponent.iHeight) tHeightToRender = pComponent.iHeight; if (pWidth <= pComponent.iWidth) { drawTexturedModalRect(0, tDrawnHeight, 0, pComponent.iU, pComponent.iV, pWidth, tHeightToRender); tDrawnHeight += tHeightToRender; } else { while (tDrawnWidth < (pWidth)) { int tWidthToRender = pWidth - tDrawnWidth; if (tWidthToRender >= pComponent.iWidth) tWidthToRender = pComponent.iWidth; if (pHeight <= pComponent.iHeight) { drawTexturedModalRect(tDrawnWidth, 0, 0, pComponent.iU, pComponent.iV, tWidthToRender, tHeightToRender); tDrawnWidth += tWidthToRender; } else { drawTexturedModalRect(tDrawnWidth, tDrawnHeight, 0, pComponent.iU, pComponent.iV, tWidthToRender, tHeightToRender); tDrawnWidth += pComponent.iWidth; } } tDrawnWidth = 0; tDrawnHeight += tHeightToRender; } } } GL11.glPopMatrix(); }
From source file:com.smithsmodding.smithscore.util.client.gui.GuiHelper.java
/** * Renders a texture as if it would be the corner of a MultiComponentTexture. * * @param pComponent The Component to Render * @param pElementCoordinate The offset of the Component from the current GL Buffer Matric Origin. *///from ww w. j a va 2s .c o m private static void renderCorner(TextureComponent pComponent, Coordinate2D pElementCoordinate) { GL11.glPushMatrix(); GL11.glTranslatef(pElementCoordinate.getXComponent() + pComponent.iRelativeTranslation.getXComponent(), pElementCoordinate.getYComponent() + pComponent.iRelativeTranslation.getYComponent(), 0F); pComponent.iRotation.performGLRotation(); bindTexture(pComponent.iAddress); drawTexturedModalRect(0, 0, 0, pComponent.iU, pComponent.iV, pComponent.iWidth, pComponent.iHeight); GL11.glPopMatrix(); }
From source file:com.smithsmodding.smithscore.util.client.gui.GuiHelper.java
/** * Renders a texture as if it would be the side of a MultiComponentTexture. * * @param pComponent The Component to Render * @param pWidth The total width of the Component in the End * @param pHeight The total height of the Component in the End * @param pElementCoordinate The offset of the Component from the current GL Buffer Matric Origin. */// w w w.j ava 2s . c o m private static void renderBorder(TextureComponent pComponent, int pWidth, int pHeight, Coordinate2D pElementCoordinate) { GL11.glPushMatrix(); GL11.glTranslatef(pElementCoordinate.getXComponent() + pComponent.iRelativeTranslation.getXComponent(), pElementCoordinate.getYComponent() + pComponent.iRelativeTranslation.getYComponent(), 0F); pComponent.iRotation.performGLRotation(); bindTexture(pComponent.iAddress); if (pWidth <= pComponent.iWidth && pHeight <= pComponent.iHeight) { drawTexturedModalRect(0, 0, 0, pComponent.iU, pComponent.iV, pWidth, pHeight); } else { int tDrawnHeigth = 0; int tDrawnWidth = 0; if (pWidth <= pComponent.iWidth) { while (pHeight > tDrawnHeigth) { int tDrawableHeight = pHeight - tDrawnHeigth; if (tDrawableHeight > pComponent.iHeight) tDrawableHeight = pComponent.iHeight; drawTexturedModalRect(0, tDrawnHeigth, 0, pComponent.iU, pComponent.iV, pWidth, tDrawableHeight); tDrawnHeigth += tDrawableHeight; } } else { while (tDrawnWidth < (pWidth)) { int tWidthToRender = pWidth - tDrawnWidth; if (tWidthToRender >= pComponent.iWidth) tWidthToRender = pComponent.iWidth; drawTexturedModalRect(tDrawnWidth, 0, 0, pComponent.iU, pComponent.iV, tWidthToRender, pComponent.iHeight); tDrawnWidth += tWidthToRender; } } } GL11.glPopMatrix(); }
From source file:com.spawck.hs2.client.renderer.model.ModelSoul.java
License:GNU General Public License
@Override public void render(Entity entity, float par2, float par3, float par4, float par5, float par6, float par7) { GL11.glPushMatrix();/*from w ww . j a va 2 s .c o m*/ GL11.glScalef(1.0F, 1.0F, 1.0F); GL11.glTranslatef(0.0F, -0.5F, 0.0F); if (this.base != null) { this.base.render(par7); } GL11.glEnable(2977); GL11.glEnable(3042); GL11.glBlendFunc(770, 771); GL11.glRotatef(par3, 0.0F, 1.0F, 0.0F); GL11.glTranslatef(0.0F, 0.8F + par4, 0.0F); GL11.glRotatef(60.0F, 0.7071F, 0.0F, 0.7071F); this.glass.render(par7); float var8 = 0.875F; GL11.glScalef(var8, var8, var8); GL11.glRotatef(60.0F, 0.7071F, 0.0F, 0.7071F); GL11.glRotatef(par3, 0.0F, 1.0F, 0.0F); this.glass.render(par7); GL11.glScalef(var8, var8, var8); GL11.glRotatef(60.0F, 0.7071F, 0.0F, 0.7071F); GL11.glRotatef(par3, 0.0F, 1.0F, 0.0F); this.cube.render(par7); GL11.glDepthFunc(514); GL11.glDisable(2896); GL11.glEnable(3042); GL11.glBlendFunc(768, 1); float var14 = 0.76F; GL11.glColor4f(0.5F * var14, 0.25F * var14, 0.8F * var14, 1.0F); GL11.glMatrixMode(5890); GL11.glPushMatrix(); float var15 = 0.125F; GL11.glScalef(var15, var15, var15); float var16 = (float) (Minecraft.getSystemTime() % 3000L) / 3000.0F * 8.0F; GL11.glTranslatef(var16, 0.0F, 0.0F); GL11.glRotatef(-50.0F, 0.0F, 0.0F, 1.0F); this.cube.render(par7); GL11.glPopMatrix(); GL11.glPushMatrix(); GL11.glScalef(var15, var15, var15); var16 = (float) (Minecraft.getSystemTime() % 4873L) / 4873.0F * 8.0F; GL11.glTranslatef(-var16, 0.0F, 0.0F); GL11.glRotatef(10.0F, 0.0F, 0.0F, 1.0F); this.cube.render(par7); GL11.glPopMatrix(); GL11.glMatrixMode(5888); GL11.glDisable(3042); GL11.glEnable(2896); GL11.glDepthFunc(515); GL11.glPopMatrix(); }
From source file:com.spawck.hs2.client.renderer.render.RenderSoul.java
License:GNU General Public License
private void doRenderSoulCube(EntitySoul soul, double par2, double par4, double par6, float par8, float par9) { if (this.field_76996_a != 1) { this.soulModel = new ModelSoul(); // 0.0F, true removed (were they really necessary? They were never called) this.field_76996_a = 1; }/*from w w w . j av a2 s.c o m*/ float var10 = soul.innerRotation + par9; GL11.glPushMatrix(); GL11.glTranslatef((float) par2, (float) par4, (float) par6); // TODO:loadTexture(par1EntityHSSoul.getSoulTexture()); float var11 = MathHelper.sin(var10 * 0.2F) / 2.0F + 0.5F; var11 += var11 * var11; this.soulModel.render(soul, 0.0F, var10 * 3.0F, var11 * 0.2F, 0.0F, 0.0F, 0.0625F); GL11.glPopMatrix(); }
From source file:com.sriramramani.droid.inspector.ui.InspectorCanvas.java
License:Mozilla Public License
private void doPaint() { if (isDisposed() || mNode == null) { return;/* w ww . jav a 2 s .c om*/ } setCurrent(); // Clear the color, depth and stencil buffers. GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT | GL11.GL_STENCIL_BUFFER_BIT); GL11.glLoadIdentity(); GLU.gluLookAt(0.0f, 0.0f, mCamera.z, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f); // Transformations happen in the reverse. if (mIsOrtho) { // User's translation. GL11.glTranslatef(mOrthoTranslate.x, mOrthoTranslate.y, 0.0f); // Rotate 180 degrees. GL11.glRotatef(180.0f, 1.0f, 0.0f, 0.0f); // Center the nodes. final Rectangle bounds = getBounds(); final float scaledWidth = mNode.bounds.width * mOrthoScale; final float scaledHeight = mNode.bounds.height * mOrthoScale; GL11.glTranslatef((bounds.width - scaledWidth) / 2, 0.0f, 0.0f); // Scale based on viewport size. GL11.glTranslatef(scaledWidth / 2, -scaledHeight / 2, 0.0f); GL11.glScalef(mOrthoScale, mOrthoScale, 0.0f); GL11.glTranslatef(-scaledWidth / 2, scaledHeight / 2, 0.0f); } else { // Translate all the nodes. GL11.glTranslatef(mTranslate.x, mTranslate.y, 0.0f); // Rotate. GL11.glRotatef(mRotate.x, 1.0f, 0.0f, 0.0f); GL11.glRotatef(mRotate.y, 0.0f, 1.0f, 0.0f); // Center the nodes. GL11.glTranslatef(-mNode.bounds.width / 2, mNode.bounds.height / 2, 0.0f); } final float absX = Math.abs(mRotate.x); final float absY = Math.abs(mRotate.y); mDepth = Math.max(absX, absY) * 5 / 9.0f; drawHierarchy(mNode); if (!mIsPicking && mIsOrtho && mShowOverdraw) { for (int i = 2; i <= 5; i++) { drawOverdraw(i); } } GL11.glFlush(); if (!mIsPicking) { swapBuffers(); } }
From source file:com.sriramramani.droid.inspector.ui.InspectorCanvas.java
License:Mozilla Public License
private void drawOverdraw(int level) { GL11.glPushAttrib(GL11.GL_STENCIL_BUFFER_BIT); GL11.glStencilFunc(level == 5 ? GL11.GL_LEQUAL : GL11.GL_EQUAL, level, 0xf); GL11.glStencilOp(GL11.GL_KEEP, GL11.GL_KEEP, GL11.GL_KEEP); GL11.glTranslatef(mNode.bounds.x, -mNode.bounds.y, 0.0f); if (level == 2) { loadColor(ColorType.OVERDRAW_BLUE); } else if (level == 3) { loadColor(ColorType.OVERDRAW_GREEN); } else if (level == 4) { loadColor(ColorType.OVERDRAW_RED_LOW); } else if (level > 4) { loadColor(ColorType.OVERDRAW_RED_HIGH); }//from w w w .ja va 2s . c o m GL11.glPolygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_FILL); GL11.glBegin(GL11.GL_QUADS); GL11.glVertex3f(0.0f, 0.0f, 0.0f); GL11.glVertex3f(mNode.bounds.width, 0.0f, 0.0f); GL11.glVertex3f(mNode.bounds.width, -mNode.bounds.height, 0.0f); GL11.glVertex3f(0.0f, -mNode.bounds.height, 0.0f); GL11.glEnd(); GL11.glPopAttrib(); }