List of usage examples for org.lwjgl.opengl GL11 GL_MODELVIEW
int GL_MODELVIEW
To view the source code for org.lwjgl.opengl GL11 GL_MODELVIEW.
Click Source Link
From source file:cn.academy.ability.electro.client.render.skill.RailgunPlaneEffect.java
License:Open Source License
@SideOnly(Side.CLIENT) @Override// w ww. ja va2 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); }
From source file:cn.academy.misc.tutorial.client.GuiTutorial.java
License:GNU General Public License
private void initUI() { frame = loaded.getWidget("frame").copy(); leftPart = frame.getWidget("leftPart"); listArea = leftPart.getWidget("list"); rightPart = frame.getWidget("rightPart"); showWindow = rightPart.getWidget("showWindow"); rightWindow = rightPart.getWidget("rightWindow"); centerPart = rightPart.getWidget("centerPart"); logo0 = rightPart.getWidget("logo0"); logo1 = rightPart.getWidget("logo1"); logo2 = rightPart.getWidget("logo2"); logo3 = rightPart.getWidget("logo3"); showArea = showWindow.getWidget("area"); tagArea = showWindow.getWidget("tag_area"); showWindow.transform.doesDraw = false; rightWindow.transform.doesDraw = false; centerPart.transform.doesDraw = false; // Event handlers centerPart.getWidget("text").listen(FrameEvent.class, (w, e) -> { if (currentTut != null) { GLMarkdownRenderer renderer = renderInfo(currentTut.tut).getContent(); glPushMatrix();/*from w ww. j a v a 2 s. co m*/ glTranslated(0, 0, 10); glColorMask(false, false, false, false); glDepthMask(true); HudUtils.colorRect(0, 0, w.transform.width, w.transform.height); glColorMask(true, true, true, true); double ht = Math.max(0, renderer.getMaxHeight() - w.transform.height + 10); double delta = VerticalDragBar.get(centerPart.getWidget("scroll_2")).getProgress() * ht; glTranslated(3, 3 - delta, 0); glDepthFunc(GL_EQUAL); renderer.render(); glDepthFunc(GL_LEQUAL); glPopMatrix(); } }); rightWindow.getWidget("text").listen(FrameEvent.class, (w, e) -> { if (currentTut != null) { CachedRenderInfo info = renderInfo(currentTut.tut); font.draw(info.title, 3, 3, fo_descTitle); glPushMatrix(); glTranslated(3, 15, 0); info.getBrief().render(); glPopMatrix(); } }); showArea.listen(FrameEvent.class, (w, e) -> { final Widget view = currentView(); if (view == null) { return; } glMatrixMode(GL11.GL_PROJECTION); glPushMatrix(); glLoadIdentity(); double scale = 366.0 / width * frame.scale; float aspect = (float) mc.displayWidth / mc.displayHeight; glTranslated(-1 + 2.0 * (w.scale + w.x) / width, 1 - 2.0 * (w.scale + w.y) / height, 0); GL11.glScaled(scale, -scale * aspect, -0.5); GLU.gluPerspective(50, 1, 1f, 100); glMatrixMode(GL11.GL_MODELVIEW); glPushMatrix(); glLoadIdentity(); // glCullFace(GL_FRONT); // glDisable(GL11.GL_DEPTH_TEST); glDisable(GL11.GL_ALPHA_TEST); glEnable(GL11.GL_BLEND); glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); glCullFace(GL_FRONT); glColor4d(1, 1, 1, 1); glTranslated(0, 0, -4); glTranslated(.55, .55, .5); glScaled(.75, -.75, .75); glRotated(-20, 1, 0, 0.1); view.post(new ViewRenderEvent()); glPopMatrix(); glMatrixMode(GL11.GL_PROJECTION); glPopMatrix(); glMatrixMode(GL11.GL_MODELVIEW); glEnable(GL11.GL_DEPTH_TEST); glEnable(GL11.GL_ALPHA_TEST); glCullFace(GL11.GL_BACK); }); // Left and right button of the preview view. // It is assumed when event is triggered, current preview is present and can be switched. showWindow.getWidget("btn_left").listen(LeftClickEvent.class, (w, e) -> { PreviewInfo info = Preconditions.checkNotNull(currentPreview()); info.viewIndex -= 1; if (info.viewIndex < 0) { info.viewIndex = info.subViews.length - 1; } updateView(); }); showWindow.getWidget("btn_right").listen(LeftClickEvent.class, (w, e) -> { PreviewInfo info = Preconditions.checkNotNull(currentPreview()); info.viewIndex = (info.viewIndex + 1) % info.subViews.length; updateView(); }); { FontOption option = new FontOption(10); tagArea.listen(FrameEvent.class, (w, evt) -> { Widget hovering = gui.getHoveringWidget(); if (hovering != null) { ViewGroupButton comp = hovering.getComponent(ViewGroupButton.class); if (comp != null) { font.draw(comp.group.getDisplayText(), 0, -8, option); } } }); } // rebuildList(); final double ln = 500, ln2 = 300, cl = 50; final float ht = 5; if (!firstOpen) { logo1.listen(FrameEvent.class, (w, e) -> { glPushMatrix(); glTranslated(logo1.transform.width / 2, logo1.transform.height / 2 + 15, 0); lineglow(ln - ln2, ln, ht); lineglow(-ln, -(ln - ln2), ht); glPopMatrix(); }); } else { listArea.transform.doesDraw = false; /* Start animation controller */ { blend(logo2, 0.65, 0.3); blend(logo0, 1.75, 0.3); blend(leftPart, 1.75, 0.3); blend(logo1, 1.3, 0.3); blend(logo3, 0.1, 0.3); blendy(logo3, 0.7, 0.4, 63, -36); long startTime = GameTimer.getAbsTime(); logo1.listen(FrameEvent.class, (__, e) -> { final double b1 = 0.3, // Blend stage 1 b2 = 0.2; // Blend stage 2 glPushMatrix(); glTranslated(logo1.transform.width / 2, logo1.transform.height / 2 + 15, 0); double dt = (GameTimer.getAbsTime() - startTime) / 1000.0 - 0.4; if (dt < 0) dt = 0; if (dt < b1) { if (dt > 0) { double len = MathUtils.lerp(0, ln, dt / b1); if (len > cl) { lineglow(cl, len, ht); lineglow(-len, -cl, ht); } } } else { double ldt = dt - b1; if (ldt > b2) { ldt = b2; } double len = ln; double len2 = MathUtils.lerp(ln - 2 * cl, ln2, ldt / b2); lineglow(ln - len2, len, ht); lineglow(-len, -(ln - len2), ht); } glPopMatrix(); listArea.transform.doesDraw = dt > 2.0; }); } } gui.addWidget("frame", frame); }
From source file:cn.academy.terminal.client.TerminalUI.java
License:GNU General Public License
@Override public void draw(ScaledResolution sr) { //Frame update selection = (int) ((mouseY - 0.01) / MAX_MY * 3) * 3 + (int) ((mouseX - 0.01) / MAX_MX * 3); if (mouseY == 0) { mouseY = 1;//from ww w. j a va2 s.co m if (scroll > 0) scroll--; } if (mouseY == MAX_MY) { mouseY -= 1; if (scroll < getMaxScroll()) scroll++; } //Draw Minecraft mc = Minecraft.getMinecraft(); long time = GameTimer.getTime(); if (lastFrameTime == 0) lastFrameTime = time; long dt = time - lastFrameTime; mouseX += helper.dx * SENSITIVITY; mouseY -= helper.dy * SENSITIVITY; mouseX = Math.max(0, Math.min(MAX_MX, mouseX)); mouseY = Math.max(0, Math.min(MAX_MY, mouseY)); buffX = balance(dt, buffX, mouseX); buffY = balance(dt, buffY, mouseY); helper.dx = helper.dy = 0; GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glPushMatrix(); GL11.glLoadIdentity(); float aspect = (float) mc.displayWidth / mc.displayHeight; GLU.gluPerspective(50, aspect, 1f, 100); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glPushMatrix(); GL11.glLoadIdentity(); GL11.glDisable(GL11.GL_DEPTH_TEST); GL11.glDisable(GL11.GL_ALPHA_TEST); GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glColor4d(1, 1, 1, 1); double scale = 1.0 / 310; GL11.glTranslated(.35 * aspect, 1.2, -4); GL11.glTranslated(1, -1.8, 0); GL11.glRotated(-1.6, 0, 0, 1); GL11.glRotated(-18 - 4 * (buffX / MAX_MX - 0.5) + 1 * Math.sin(time / 1000.0), 0, 1, 0); GL11.glRotated(7 + 4 * (buffY / MAX_MY - 0.5), 1, 0, 0); //DEBUG CODE // GL11.glPointSize(20); // GL11.glColor4d(1, 1, 1, 1); // GL11.glDisable(GL11.GL_TEXTURE_2D); // GL11.glBegin(GL11.GL_POINTS); // GL11.glVertex3f(0, 0, 0); // GL11.glEnd(); // GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glTranslated(-1, 1.8, 0); GL11.glScaled(scale, -scale, scale); gui.draw(mouseX, mouseY); { GL11.glPushMatrix(); double csize = (getSelectedApp() == null ? 1 : 1.3) * (20 + Math.sin(time / 300.0) * 2); RenderUtils.loadTexture(CURSOR); GL11.glColor4d(1, 1, 1, .4); GL11.glTranslated(0, 0, -2); GL11.glDisable(GL11.GL_ALPHA_TEST); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE); HudUtils.rect(-csize / 2 + buffX, -csize / 2 + buffY + 120, csize, csize); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glPopMatrix(); } GL11.glPopMatrix(); GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glPopMatrix(); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glEnable(GL11.GL_DEPTH_TEST); GL11.glEnable(GL11.GL_ALPHA_TEST); GL11.glCullFace(GL11.GL_BACK); }
From source file:cn.lambdalib.template.client.render.item.RenderModelItem.java
License:MIT License
public void renderEquipped(ItemStack item, RenderBlocks render, EntityLivingBase entity, ItemRenderType type) { if (item.stackTagCompound == null) item.stackTagCompound = new NBTTagCompound(); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glPushMatrix();/* w ww . j ava 2 s . c o m*/ { RenderUtils.loadTexture(texturePath); float sc2 = 0.0625F; GL11.glRotatef(40F, 0, 0, 1); if (type == ItemRenderType.EQUIPPED) this.doTransformation(thirdPersonOffset); this.doTransformation(equipOffset); this.doRotation(equipRotation); GL11.glRotatef(90, 0, -1, 0); GL11.glScaled(equipScale, equipScale, equipScale); if (type == ItemRenderType.EQUIPPED) GL11.glScaled(thirdPersonScale, thirdPersonScale, thirdPersonScale); renderAtStdPosition(getModelAttribute(item, entity)); } GL11.glPopMatrix(); }
From source file:cn.lambdalib.util.client.RenderUtils.java
License:MIT License
public static void renderOverlayEquip(ResourceLocation src) { //Setup// ww w . ja v a 2 s. c o m GL11.glDepthFunc(GL11.GL_EQUAL); GL11.glDisable(GL11.GL_LIGHTING); loadTexture(src); GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_COLOR, GL11.GL_ONE); float f7 = 0.76F; GL11.glMatrixMode(GL11.GL_TEXTURE); //Push texture mat GL11.glPushMatrix(); float f8 = 0.125F; GL11.glScalef(f8, f8, f8); float f9 = GameTimer.getAbsTime() % 3000L / 3000.0F * 8.0F; GL11.glTranslatef(f9, 0.0F, 0.0F); //xOffset loops between 0.0 and 8.0 GL11.glRotatef(-50.0F, 0.0F, 0.0F, 1.0F); ItemRenderer.renderItemIn2D(t, 0.0F, 0.0F, 1.0F, 1.0F, 256, 256, 0.0625F); GL11.glPopMatrix(); //Second pass GL11.glPushMatrix(); GL11.glScalef(f8, f8, f8); f9 = GameTimer.getAbsTime() % 4873L / 4873.0F * 8.0F; //Loop between 0 and 8, longer loop GL11.glTranslatef(-f9, 0.0F, 0.0F); //Still xOffset GL11.glRotatef(10.0F, 0.0F, 0.0F, 1.0F); //However, different rotation! ItemRenderer.renderItemIn2D(t, 0.0F, 0.0F, 1.0F, 1.0F, 256, 256, 0.0625F); GL11.glPopMatrix(); //Pop texture mat GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glDisable(GL11.GL_BLEND); GL11.glEnable(GL11.GL_LIGHTING); GL11.glDepthFunc(GL11.GL_LEQUAL); }
From source file:cn.lambdalib.util.client.RenderUtils.java
License:MIT License
public static void renderOverlayInv(ResourceLocation src) { GL11.glDepthFunc(GL11.GL_EQUAL);// ww w.j av a2 s . c o m GL11.glDisable(GL11.GL_LIGHTING); loadTexture(src); 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 = GameTimer.getAbsTime() % 3000L / 3000.0F * 8.0F; GL11.glTranslatef(f9, 0.0F, 0.0F); GL11.glRotatef(-50.0F, 0.0F, 0.0F, 1.0F); t.startDrawingQuads(); t.addVertexWithUV(0.0, 0.0, 0.0, 0.0, 0.0); t.addVertexWithUV(0.0, 16.0, 0.0, 0.0, 1.0); t.addVertexWithUV(16.0, 16.0, 0.0, 1.0, 1.0); t.addVertexWithUV(16.0, 0.0, 0.0, 1.0, 0.0); t.draw(); GL11.glPopMatrix(); GL11.glPushMatrix(); GL11.glScalef(f8, f8, f8); f9 = GameTimer.getAbsTime() % 4873L / 4873.0F * 8.0F; GL11.glTranslatef(-f9, 0.0F, 0.0F); GL11.glRotatef(10.0F, 0.0F, 0.0F, 1.0F); t.startDrawingQuads(); t.addVertexWithUV(0.0, 0.0, 0.0, 0.0, 0.0); t.addVertexWithUV(0.0, 16.0, 0.0, 0.0, 1.0); t.addVertexWithUV(16.0, 16.0, 0.0, 1.0, 1.0); t.addVertexWithUV(16.0, 0.0, 0.0, 1.0, 0.0); t.draw(); GL11.glPopMatrix(); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glDisable(GL11.GL_BLEND); GL11.glEnable(GL11.GL_LIGHTING); GL11.glDepthFunc(GL11.GL_LEQUAL); }
From source file:cn.lambdalib.util.client.RenderUtils.java
License:MIT License
public static void drawBlackout() { GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glDisable(GL11.GL_CULL_FACE);/*w w w . j av a 2 s .c o m*/ GL11.glDisable(GL11.GL_DEPTH_TEST); GL11.glPushMatrix(); GL11.glLoadIdentity(); GLU.gluOrtho2D(1, 0, 1, 0); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glPushMatrix(); GL11.glLoadIdentity(); GL11.glColor4d(0, 0, 0, 0.7); GL11.glTranslated(0, 0, 0); HudUtils.colorRect(0, 0, 1, 1); GL11.glPopMatrix(); GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glPopMatrix(); GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glColor4d(1, 1, 1, 1); GL11.glEnable(GL11.GL_DEPTH_TEST); GL11.glEnable(GL11.GL_CULL_FACE); GL11.glMatrixMode(GL11.GL_MODELVIEW); }
From source file:cn.liutils.api.draw.DrawObject.java
License:Open Source License
public void draw() { post(EventType.PRE_DRAW);//from w ww .jav a 2 s . co m GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glPushMatrix(); { post(EventType.PRE_TRANSFORM); post(EventType.POST_TRANSFORM); post(EventType.PRE_TESS); post(EventType.DO_TESS); post(EventType.POST_TESS); } GL11.glPopMatrix(); post(EventType.POST_DRAW); }
From source file:cn.liutils.api.draw.DrawObjectList.java
License:Open Source License
@Override public void draw() { postAll(EventType.PRE_DRAW);//from w ww .j av a2 s . c o m GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glPushMatrix(); { postAll(EventType.PRE_TRANSFORM); postAll(EventType.POST_TRANSFORM); postAll(EventType.PRE_TESS); postAll(EventType.DO_TESS); postAll(EventType.POST_TESS); } GL11.glPopMatrix(); postAll(EventType.POST_DRAW); }
From source file:cn.liutils.api.gui.Widget.java
License:Open Source License
/** * Should be called at this widget's draw() function. *///from w w w . ja v a 2 s . c o m protected void drawBlackout() { GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glDisable(GL11.GL_CULL_FACE); GL11.glPushMatrix(); GL11.glLoadIdentity(); GLU.gluOrtho2D(1, 0, 1, 0); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glPushMatrix(); GL11.glLoadIdentity(); GL11.glColor4d(0, 0, 0, 0.6); HudUtils.setZLevel(-1); HudUtils.drawModalRect(0, 0, 1, 1); GL11.glPopMatrix(); GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glPopMatrix(); GL11.glEnable(GL11.GL_TEXTURE_2D); RenderUtils.bindIdentity(); GL11.glEnable(GL11.GL_CULL_FACE); GL11.glMatrixMode(GL11.GL_MODELVIEW); }