List of usage examples for org.lwjgl.opengl GL11 glTranslated
public static native void glTranslated(@NativeType("GLdouble") double x, @NativeType("GLdouble") double y, @NativeType("GLdouble") double z);
From source file:cn.liutils.api.gui.LIGui.java
License:Open Source License
private void drawTraverse(double mx, double my, WidgetNode cur, Iterable<WidgetNode> set, WidgetNode top) { if (cur != null && cur.widget.doesDraw) { GL11.glPushMatrix();//from w ww.java2 s .co m GL11.glTranslated(cur.x, cur.y, 0); GL11.glScaled(cur.scale, cur.scale, 1); //System.out.println(cur.widget + " " + DebugUtils.formatArray(cur.x, cur.y, cur.scale)); GL11.glColor4d(1, 1, 1, 1); //Force restore color for any widget cur.widget.draw((mx - cur.x) / cur.scale, (my - cur.y) / cur.scale, cur == top); GL11.glPopMatrix(); } if (cur == null || cur.widget.doesDraw) { if (cur != null) cur.iterating = true; Iterator<WidgetNode> iter = set.iterator(); while (iter.hasNext()) { WidgetNode wn = iter.next(); drawTraverse(mx, my, wn, wn, top); } if (cur != null) cur.iterating = false; } }
From source file:cn.liutils.api.gui.LIGuiScreen.java
License:Open Source License
@Override public void drawScreen(int mx, int my, float w) { gui.resize(width, height);//ww w .ja v a 2 s. com if (drawBack) this.drawDefaultBackground(); GL11.glPushMatrix(); { GL11.glTranslated(0, 0, 100); gui.draw(mx, my); } GL11.glPopMatrix(); }
From source file:cn.liutils.api.render.model.ModelBaseCustom.java
License:Open Source License
/** * Sets the models various rotation angles then renders the model. *//* w w w . j a v a 2s. c o m*/ @Override public final void render(Entity par1Entity, float par2, float par3, float par4, float par5, float par6, float par7) { GL11.glPushMatrix(); { GL11.glTranslated(offset.xCoord, offset.yCoord, offset.zCoord); GL11.glScalef(scale, -scale, scale); doRenderModel(par3, par5); } GL11.glPopMatrix(); }
From source file:cn.liutils.cgui.gui.component.TextBox.java
License:Open Source License
public TextBox() { super("TextBox"); addEventHandler(new KeyEventHandler() { @Override/*from w w w . j ava2 s. c o m*/ public void handleEvent(Widget w, KeyEvent event) { if (!allowEdit) return; checkCaret(); int par2 = event.keyCode; if (par2 == Keyboard.KEY_RIGHT) { caretPos++; } else if (par2 == Keyboard.KEY_LEFT) { caretPos--; } if (caretPos < 0) caretPos = 0; if (caretPos > content.length()) caretPos = content.length(); if (event.keyCode == Keyboard.KEY_V && Keyboard.isKeyDown(Keyboard.KEY_LCONTROL)) { String str1 = content.substring(0, caretPos), str2 = getClipboardContent(), str3 = content.substring(caretPos); content = str1 + str2 + str3; w.postEvent(new ChangeContentEvent()); return; } if (event.keyCode == Keyboard.KEY_C && Keyboard.isKeyDown(Keyboard.KEY_LCONTROL)) { saveClipboardContent(); return; } if (par2 == Keyboard.KEY_BACK && content.length() > 0) { if (caretPos > 0) { content = content.substring(0, caretPos - 1) + (caretPos == content.length() ? "" : content.substring(caretPos, content.length())); --caretPos; } w.postEvent(new ChangeContentEvent()); } else if (par2 == Keyboard.KEY_RETURN || par2 == Keyboard.KEY_NUMPADENTER) { w.postEvent(new ConfirmInputEvent()); } else if (par2 == Keyboard.KEY_DELETE) { content = ""; w.postEvent(new ChangeContentEvent()); } if (ChatAllowedCharacters.isAllowedCharacter(event.inputChar)) { content = content.substring(0, caretPos) + event.inputChar + (caretPos == content.length() ? "" : content.substring(caretPos, content.length())); caretPos += 1; w.postEvent(new ChangeContentEvent()); } checkCaret(); } }); addEventHandler(new MouseDownHandler() { @Override public void handleEvent(Widget w, MouseDownEvent event) { double len = 3; double[] offset = getOffset(w); double eventX = -offset[0] + event.x; for (int i = 0; i < content.length(); ++i) { double cw = Font.font.strLen(String.valueOf(content.charAt(i)), size); len += cw; if (len > eventX) { caretPos = (eventX - len + cw > cw / 2) ? i + 1 : i; return; } } caretPos = content.length(); } }); addEventHandler(new FrameEventHandler() { @Override public void handleEvent(Widget w, FrameEvent event) { double[] offset = getOffset(w); checkCaret(); String str = getProcessedContent(); GL11.glPushMatrix(); GL11.glTranslated(0, 0, zLevel); if (emit) Font.font.drawTrimmed(str, offset[0], offset[1], size, color.asHexColor(), Align.LEFT, w.transform.width - 2, "..."); else Font.font.draw(str, offset[0], offset[1], size, color.asHexColor(), Align.LEFT); GL11.glPopMatrix(); if (allowEdit && w.isFocused() && GameTimer.getAbsTime() % 1000 < 500) { double len = Font.font.strLen(str.substring(0, caretPos), size); Font.font.draw("|", len + offset[0], offset[1], size, color.asHexColor()); } } }); }
From source file:cn.liutils.cgui.gui.LIGui.java
License:Open Source License
private void drawTraverse(double mx, double my, Widget cur, WidgetContainer set, Widget top) { try {//from w w w .j a va 2 s . co m if (cur != null && cur.isVisible()) { GL11.glPushMatrix(); GL11.glTranslated(cur.x, cur.y, 0); double px = cur.transform.pivotX * cur.scale, py = cur.transform.pivotY * cur.scale; GL11.glScaled(cur.scale, cur.scale, 1); GL11.glTranslated(-cur.transform.pivotX, -cur.transform.pivotY, 0); GL11.glColor4d(1, 1, 1, 1); //Force restore color for any widget cur.postEvent(new FrameEvent((mx - cur.x) / cur.scale, (my - cur.y) / cur.scale, cur == top)); GL11.glPopMatrix(); } } catch (Exception e) { LIUtils.log.error("Error occured handling widget draw. instance class: " + cur.getClass().getName() + ", name: " + cur.getName()); e.printStackTrace(); } if (cur == null || cur.isVisible()) { Iterator<Widget> iter = set.iterator(); while (iter.hasNext()) { Widget wn = iter.next(); drawTraverse(mx, my, wn, wn, top); } } }
From source file:cn.liutils.core.client.render.RenderPlayerHook.java
License:Open Source License
@Override public void doRender(Entity ent, double x, double y, double z, float wtf, float var9) { EntityPlayerHook hook = (EntityPlayerHook) ent; GL11.glPushMatrix();//w w w . j av a 2s. c om GL11.glTranslated(x, y, z); traverse(hook, hook.blend ? EntityPlayerHook.helpers_al : EntityPlayerHook.helpers_op); GL11.glPopMatrix(); }
From source file:cn.liutils.core.client.render.RenderPlayerHook.java
License:Open Source License
private void traverse(EntityPlayerHook ent, Set<IPlayerRenderHook> hooks) { for (IPlayerRenderHook hook : hooks) { GL11.glPushMatrix();/* ww w . j a va 2 s . co m*/ GL11.glRotatef(ent.rotationYaw, 0.0F, -1.0F, 0.0F); GL11.glPushMatrix(); { GL11.glTranslated(0, -1.67, 0); hook.renderBody(ent.player, ent.worldObj); } GL11.glPopMatrix(); GL11.glTranslatef(0.0F, 0.5F, 0.0F); hook.renderHead(ent.player, ent.worldObj); GL11.glPopMatrix(); } }
From source file:cn.liutils.template.block.RenderBlockMulti.java
License:Open Source License
@Override public void renderTileEntityAt(TileEntity te, double x, double y, double z, float f) { if (!(te.getBlockType() instanceof BlockMulti)) return;//from ww w.j a v a2s . c om BlockMulti bm = (BlockMulti) te.getBlockType(); InfoBlockMulti inf = ((IMultiTile) te).getBlockInfo(); if (inf == null || !inf.isLoaded() || inf.subID != 0) return; GL11.glPushMatrix(); double[] off = bm.getPivotOffset(inf); double[] off2 = bm.rotCenters[inf.dir.ordinal()]; GL11.glTranslated(x + off[0] + off2[0], y + 0 + off2[1], z + off[1] + off2[2]); //GL11.glTranslated(x, y, z); GL11.glRotated(bm.getRotation(inf), 0, 1, 0); drawAtOrigin(te); GL11.glPopMatrix(); }
From source file:cn.liutils.template.client.render.block.RendererSidedCube.java
License:Open Source License
public void doRender(TileEntity tileEntity, double x, double y, double z, float f) { Tessellator t = Tessellator.instance; int var5 = tileEntity.getBlockMetadata(); block.setBlockBoundsBasedOnState(tileEntity.getWorldObj(), tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord);//w w w . ja va2 s.c o m setBound(block); Vec3 v1, v2, v3, v4, v5, v6, v7, v8; v1 = VecUtils.vec(minX, minY, minZ); v2 = VecUtils.vec(minX, minY, maxZ); v3 = VecUtils.vec(minX, maxY, maxZ); v4 = VecUtils.vec(minX, maxY, minZ); v5 = VecUtils.vec(maxX, minY, minZ); v6 = VecUtils.vec(maxX, minY, maxZ); v7 = VecUtils.vec(maxX, maxY, maxZ); v8 = VecUtils.vec(maxX, maxY, minZ); GL11.glPushMatrix(); GL11.glTranslated(x, y, z); RenderUtils.loadTexture(getTexture(tileEntity, 4, var5)); t.startDrawingQuads(); t.setNormal(-1, 0, 0); addVertex(v1, 0, 1); addVertex(v2, 1, 1); addVertex(v3, 1, 0); addVertex(v4, 0, 0); t.draw(); RenderUtils.loadTexture(getTexture(tileEntity, 5, var5)); t.startDrawingQuads(); t.setNormal(1, 0, 0); addVertex(v8, 1, 0); addVertex(v7, 0, 0); addVertex(v6, 0, 1); addVertex(v5, 1, 1); t.draw(); RenderUtils.loadTexture(getTexture(tileEntity, 2, var5)); t.startDrawingQuads(); t.setNormal(0, 0, -1); addVertex(v4, 1, 0); addVertex(v8, 0, 0); addVertex(v5, 0, 1); addVertex(v1, 1, 1); t.draw(); RenderUtils.loadTexture(getTexture(tileEntity, 3, var5)); t.startDrawingQuads(); t.setNormal(0, 0, 1); addVertex(v3, 0, 0); addVertex(v2, 0, 1); addVertex(v6, 1, 1); addVertex(v7, 1, 0); t.draw(); RenderUtils.loadTexture(getTexture(tileEntity, 1, var5)); t.startDrawingQuads(); t.setNormal(0, 1, 0); addVertex(v3, 0, 0); addVertex(v7, 1, 0); addVertex(v8, 1, 1); addVertex(v4, 0, 1); t.draw(); RenderUtils.loadTexture(getTexture(tileEntity, 0, var5)); t.startDrawingQuads(); t.setNormal(0, -1, 0); addVertex(v1, 0, 1); addVertex(v5, 1, 1); addVertex(v6, 1, 0); addVertex(v2, 0, 0); t.draw(); GL11.glPopMatrix(); }
From source file:cn.liutils.util.helper.Font.java
License:Open Source License
/** * Draw a string with alignment.// www. java2 s . com * @param str * @param x * @param y * @param size * @param color * @param align */ public void draw(String str, double x, double y, double size, int color, Align align) { GL11.glEnable(GL11.GL_BLEND); //GL11.glDepthMask(false); double scale = size / mcFont().FONT_HEIGHT; GL11.glPushMatrix(); { GL11.glTranslated(x, y, 0); GL11.glScaled(scale, scale, 1); String[] ss = str.split("\n"); for (int i = 0; i < ss.length; ++i) { GL11.glPushMatrix(); { double dy = i * mcFont().FONT_HEIGHT; GL11.glTranslated(0, dy, 0); drawSingleLine(ss[i], color, align); } GL11.glPopMatrix(); } } GL11.glPopMatrix(); }