Java Code Examples for org.lwjgl.opengl.GL11.glPushMatrix()

The following are Jave code examples for showing how to use glPushMatrix() of the org.lwjgl.opengl.GL11 class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: bit-client   File: Wrapper.java   View Source Code Vote up 6 votes
public static void drawStringWithShadow_scaled(String str, int x, int y, int color, double scale) {
    if (str == null) return;
    double scaleFactor = (scale / 0.5) * 2;
    GL11.glPushMatrix();
    GL11.glScaled(scale, scale, scale);
    boolean blend = GL11.glIsEnabled(GL11.GL_BLEND);
    GL11.glDisable(GL11.GL_BLEND);

    if (scale < 1)
        fontRenderer().func_78261_a(str, (int) (x * scaleFactor), (int) (y * scaleFactor), color);
    else
        fontRenderer().func_78261_a(str, (int) (((x / scaleFactor) * 2)), (int) (((y / scaleFactor) * 2)), color);

    if (blend) GL11.glEnable(GL11.GL_BLEND);
    GL11.glPopMatrix();
}
 
Example 2
Project: Progetto-C   File: FBOGraphics.java   View Source Code Vote up 6 votes
/**
 * @see org.newdawn.slick.Graphics#enable()
 */
protected void enable() {
	if (!valid) {
		throw new RuntimeException("Attempt to use a destroy()ed offscreen graphics context.");
	}
	SlickCallable.enterSafeBlock();
	
	GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS);
	GL11.glPushClientAttrib(GL11.GL_ALL_CLIENT_ATTRIB_BITS);
	GL11.glMatrixMode(GL11.GL_PROJECTION);
	GL11.glPushMatrix();
	GL11.glMatrixMode(GL11.GL_MODELVIEW);
	GL11.glPushMatrix();
	
	bind();
	initGL();
}
 
Example 3
Project: pnc-repressurized   File: RenderDrone.java   View Source Code Vote up 6 votes
private void renderDrone(EntityDroneBase drone, double x, double y, double z, float yaw, float partialTicks) {
    if (drone.getHealth() <= 0) return;

    GL11.glPushMatrix();
    GL11.glTranslatef((float) x, (float) y, (float) z);

    GL11.glPushMatrix();
    GL11.glTranslatef(0, 0.76F, 0);
    GL11.glScalef(0.5F, -0.5F, -0.5F);
    bindEntityTexture(drone);
    mainModel.setLivingAnimations(drone, 0, 0, partialTicks);
    mainModel.render(drone, 0, 0, 0, 0, partialTicks, 1 / 16F);
    GL11.glPopMatrix();

    drone.renderExtras(x, y, z, partialTicks);
    GL11.glPopMatrix();
}
 
Example 4
Project: ObsidianSuite   File: Bend_Animator.java   View Source Code Vote up 6 votes
@Override
public void render(Entity entity)
{
    GL11.glPushMatrix();

    move();

    //Actually render all the bend parts.
    for (int i = 0; i < bendSplit; i++)
    {
        BendPart part = bendParts.get(i);
        boolean mainHighlight = false;
        boolean otherHighlight = false;
        if (parent.modelObj instanceof ModelObj_Animator)
        {
            ModelObj_Animator parentModel = (ModelObj_Animator) parent.modelObj;
            ModelObj_Animator childModel = (ModelObj_Animator) child.modelObj;
            mainHighlight = i < bendSplit / 2 ? parentModel.isMainHighlight(parent) : childModel.isMainHighlight(child);
            otherHighlight = i < bendSplit / 2 ? parentModel.isPartHighlighted(parent) : childModel.isPartHighlighted(child);
        }
        part.updateTextureCoordinates(entity, mainHighlight, otherHighlight, parent.modelObj);
        part.render();
    }
    GL11.glPopMatrix();
}
 
Example 5
Project: Machines-and-Stuff   File: RenderUtils.java   View Source Code Vote up 6 votes
public static void drawLine(double x, double y, double x2, double y2, float red, float green, float blue, float lineWidth) {
    int count = FMLClientHandler.instance().getClient().player.ticksExisted;
    float alpha = 0.3F + MathHelper.sin((float) (count + x)) * 0.3F + 0.3F;
    Tessellator tess = Tessellator.getInstance();
    VertexBuffer buff = tess.getBuffer();
    GL11.glPushMatrix();
    GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS | GL11.GL_LIGHTING_BIT);
    GL11.glLineWidth(lineWidth);
    GL11.glDisable(GL_TEXTURE_2D);
    GL11.glBlendFunc(770, 1);
    buff.begin(3, DefaultVertexFormats.POSITION_COLOR);
    buff.pos(x, y, 0).color(red, green, blue, alpha).endVertex();
    buff.pos(x2, y2, 0).color(red, green, blue, alpha).endVertex();
    tess.draw();
    GL11.glBlendFunc(770, 771);
    GL11.glDisable(32826);
    GL11.glEnable(GL_TEXTURE_2D);
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    GL11.glPopAttrib();
    GL11.glPopMatrix();
    
}
 
Example 6
Project: KraftigAudio   File: Jack.java   View Source Code Vote up 6 votes
@Override
public final void render(float alpha)
{
    GL11.glPushMatrix();
    GL11.glTranslatef(pos.x, pos.y, 0.0f);
    
    GL11.glLineWidth(1.0f);
    float color = Main.instance().getFocus() == this ? 0.75f : 1.0f;
    GL11.glColor4f(color, color, 1.0f, alpha*0.5f);
    GL11.glBegin(GL11.GL_LINE_LOOP);
    for (float t = 0.0f; t < T_END; t += DT)
    {
        Vec2 p = Util.squareDir(t).normalize().mult(radius);
        GL11.glVertex2f(p.x, p.y);
    }
    GL11.glEnd();
    
    GL11.glColor4f(color, color, 1.0f, alpha);
    renderSymbol();
    GL11.glPopMatrix();
}
 
Example 7
Project: Backmemed   File: RenderUtils.java   View Source Code Vote up 6 votes
public static void drawRect(float paramXStart, float paramYStart, float paramXEnd, float paramYEnd, int paramColor)
{
	float alpha = (float)(paramColor >> 24 & 0xFF) / 255F;
	float red = (float)(paramColor >> 16 & 0xFF) / 255F;
	float green = (float)(paramColor >> 8 & 0xFF) / 255F;
	float blue = (float)(paramColor & 0xFF) / 255F;
	GL11.glPushMatrix();
	GL11.glEnable(GL11.GL_BLEND);
	GL11.glDisable(GL11.GL_TEXTURE_2D);
	GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
	GL11.glEnable(GL11.GL_LINE_SMOOTH);

	GL11.glColor4f(red, green, blue, alpha);
	GL11.glBegin(GL11.GL_QUADS);
	GL11.glVertex2d(paramXEnd, paramYStart);
	GL11.glVertex2d(paramXStart, paramYStart);
	GL11.glVertex2d(paramXStart, paramYEnd);
	GL11.glVertex2d(paramXEnd, paramYEnd);
	GL11.glEnd();

	GL11.glEnable(GL11.GL_TEXTURE_2D);
	GL11.glDisable(GL11.GL_BLEND);
	GL11.glDisable(GL11.GL_LINE_SMOOTH);
	GL11.glPopMatrix();
}
 
Example 8
Project: ObsidianSuite   File: GuiEntityRendererWithRotation.java   View Source Code Vote up 6 votes
@Override
public void processRay()
{
	if(selectedPart != null && selectedPart instanceof PartRotation)
	{		
		if(!rotationWheelDrag)
		{
			updateWheelMouseOver();
			if(!rotationWheelMouseOver)
				super.processRay();
		}
		else
			processRotation();

		GL11.glPushMatrix();
		applyRotationTransform();
		drawRotationWheel();
		GL11.glPopMatrix();
	}
	else
		super.processRay();
}
 
Example 9
Project: KraftigAudio   File: SymbolButton.java   View Source Code Vote up 6 votes
@Override
public void render(float alpha)
{
    Vec2 pos = getPos();
    Vec2 radius = getRadius();
    
    GL11.glPushMatrix();
    GL11.glTranslatef(pos.x, pos.y, 0.0f);
    GL11.glScalef(radius.x, radius.y, 1.0f);
    
    GL11.glLineWidth(1.0f);
    float color = Main.instance().getFocus() == this ? 0.75f : 1.0f;
    GL11.glColor4f(color, color, 1.0f, alpha);
    GL11.glBegin(GL11.GL_LINE_LOOP);
    GL11.glVertex2f(-1.0f, -1.0f);
    GL11.glVertex2f(-1.0f, 1.0f);
    GL11.glVertex2f(1.0f, 1.0f);
    GL11.glVertex2f(1.0f, -1.0f);
    GL11.glEnd();
    
    symbol.run();
    
    GL11.glPopMatrix();
}
 
Example 10
Project: Backmemed   File: XdolfWindow.java   View Source Code Vote up 5 votes
public void draw(int x, int y) {
	GL11.glPushMatrix();
	GL11.glPushAttrib(8256);
	int toAdd = 0;
	if(dragging) {
		drag(x, y);
	}
	
	RenderUtils.drawBorderedRect(getXAndDrag(), getYAndDrag(), getXAndDrag() + 100, getYAndDrag() + 13 + (isOpen ? (12 * buttonList.size() + 0.5F) + (19 * sliderList.size() + (sliderList.size() != 0 ? 2.5F : 0)) : 0) + toAdd, 0.5F, 0xFF000000, 0x80000000);
	Fonts.roboto18.drawStringWithShadow(title, getXAndDrag() + 3, getYAndDrag()  + 1, 0xFFFFFF);

	if(Wrapper.getMinecraft().currentScreen instanceof XdolfGuiClick) {
		RenderUtils.drawBorderedRect(getXAndDrag() + 79, getYAndDrag() + 2, getXAndDrag() + 88, getYAndDrag() + 11, 0.5F, 0xFF000000, isPinned ? 0xFFFF0000 : 0xFF383b42);
		RenderUtils.drawBorderedRect(getXAndDrag() + 89, getYAndDrag() + 2, getXAndDrag() + 98, getYAndDrag() + 11, 0.5F, 0xFF000000, isOpen ? 0xFFFF0000 : 0xFF383b42);
	}
	
	if(isOpen) {
		for(XdolfButton b : buttonList) {
			b.draw();
			if(x >= b.getX() + dragX && y >= b.getY() + dragY && x <= b.getX() + 96 + dragX && y <= b.getY() + 11 + dragY) {
				b.overButton = true;
			} else {
				b.overButton = false;
			}
		}
		for(XdolfSlider s : sliderList) {
			s.draw(x);
		} 
	}
	//GL11.glEnable(GL11.GL_BLEND);
	GL11.glPopMatrix();
	GL11.glPopAttrib();
}
 
Example 11
Project: OpenFlexiTrack   File: RenderRails.java   View Source Code Vote up 4 votes
/**
 * Draws the end caps of rails.
 * 
 * @param texPoint - Position to render the caps at.
 * @param vertices - Rail shape vertices, as returned by {@link openflextrack.api.IRailType#getRailVertices() getRailVertices()}.
 * @param texScale - {@link openflextrack.api.IRailType#getTextureScale() Texture scale} of the rail segment.
 * @param holographic - {@code true} if the track is a hologram.
 */
private static void drawRailEndCaps(float[] texPoint, Vec3f[][] vertices, float texScale, boolean holographic) {

	/* Backup face mode. */
	final int glFaceMode = GL11.glGetInteger(GL11.GL_FRONT_FACE);

	for (byte b = 1; b > -2; b-=2)
	{
		GL11.glPushMatrix();
		GL11.glScalef(texPoint[4], 1.0F, texPoint[3]);

		/* If we're rendering the second cap, invert front face mode and scale.
		 * This will mirror the cap without the need to render vertices in different order. */
		if (b == -1) {
			GL11.glScalef(-1, 1, -1);
			if (glFaceMode == GL11.GL_CCW) {
				GL11.glFrontFace(GL11.GL_CW);
			}
			else {
				GL11.glFrontFace(GL11.GL_CCW);
			}
		}

		/* Actually render face. */
		GL11.glBegin(GL11.GL_QUADS);
		{
			if (!holographic) {
				OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, texPoint[6]%65536, texPoint[6]/65536);
			}

			for (Vec3f[] verts : vertices)
			{
				/* The fourth vertex (index 3; bottom left of texture)
				 * defines x offset and minumum y value,
				 * and is the first point of the rectangle. */
				final float xOff = (verts[3].x-verts[0].x);
				final float yMin = verts[3].z;

				GL11.glTexCoord2d(0.0F, yMin + (verts[0].y-verts[3].y)*texScale);
				GL11.glVertex3d(verts[3].x, verts[3].y, verts[3].x);

				GL11.glTexCoord2d((verts[3].x-verts[2].x), yMin - (verts[3].y-verts[2].y)*texScale + (verts[1].y-verts[2].y)*texScale);
				GL11.glVertex3d(verts[2].x, verts[2].y, verts[2].x);

				GL11.glTexCoord2d(xOff + (verts[0].x-verts[1].x), yMin + (verts[0].y-verts[1].y)*texScale);
				GL11.glVertex3d(verts[1].x, verts[1].y, verts[1].x);

				GL11.glTexCoord2d(xOff, yMin);
				GL11.glVertex3d(verts[0].x, verts[0].y, verts[0].x);
			}
		}
		GL11.glEnd();
		GL11.glPopMatrix();
	}

	/* Reset face mode. */
	GL11.glFrontFace(glFaceMode);
}
 
Example 12
Project: DecompiledMinecraft   File: GlStateManager.java   View Source Code Vote up 4 votes
public static void pushMatrix()
{
    GL11.glPushMatrix();
}
 
Example 13
Project: Zombe-Modpack   File: ZModpack.java   View Source Code Vote up 4 votes
/**
    Called on world draw
    note: used to be pingDrawGUIHandle()
*/
static void guiDraw(float delta) {
    if (!initialized) return;
    
    // show options
    checkConfigMenu();
    if (!isInMenu() && !wasInConfigMenu && wasKeyPressedThisFrame(keyShowOptions)) {
        openConfigMenu();
    }
    wasInConfigMenu = isConfigMenuOpened();
    
    // text overlay
    if (!isHideGUI() && !isInOptions()) {
        // set state
        GL11.glMatrixMode(GL11.GL_PROJECTION);
        GL11.glPushMatrix(); GL11.glLoadIdentity();
        GuiHelper.setOrtho();
        GL11.glMatrixMode(GL11.GL_MODELVIEW);
        GL11.glPushMatrix(); GL11.glLoadIdentity();
        GL11.glTranslatef(0.0F, 0.0F, -2000F);
        GL11.glDisable(GL11.GL_LIGHTING);
        
        // draw messages
        if (!isShowDebug() && (!isInMenu()
                               || getMenu() instanceof GuiContainer
                               || getMenu() instanceof GuiChat)) {
            setMessage("tags", getTags());
            printMessages(messagesTL, 2, 2);
            printMessages(messagesTR,-2, 2);
            printMessages(messagesBL, 2,-2);
            printMessages(messagesBR,-2,-2);
            
            /*
             printMessage("tags",  2,2);
             printMessage("view",  2,14);
             printMessage("info",  2,26);
             printMessage("error", 2,38);
             printMessage("radar",-2,2);
             */
        }
        
        // notify mods
        if (!isInMenu() || getMenu() instanceof GuiChat || getMenu() instanceof GuiContainer)
            for (ZMod mod : zombesMods)
                try {
                    mod.notifyGUIDraw(delta);
                } catch (Exception e) {
                    err("in mod \""+mod.getName()+"\": gui draw failed", e);
                }
        
        // restore state
        GL11.glPopMatrix();
        GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glPopMatrix();
        GL11.glMatrixMode(GL11.GL_MODELVIEW);
    }
    
    // modLoader compatibility
    if (!ML_loaded) try {
        ML_loaded = true;
        ML_OnTick = Class.forName("ModLoader").getDeclaredMethod("onTick", new Class[]{ Float.TYPE, Minecraft.class });  // ModLoader.OnTick(tick, game);
    } catch(Exception whatever) { ML_OnTick = null; }
    if (ML_OnTick != null) getResult(ML_OnTick, null, delta, getMinecraft());
}
 
Example 14
Project: Backmemed   File: Nametags.java   View Source Code Vote up 4 votes
private void renderTag(Entity entity, double x, double y, double z) {
    String name = entity.getName();
    if(Wrapper.getFriends().isFriend(name)) {
    	name = "\2479" + name;
    }
    if (entity instanceof EntityLivingBase) {
    name = name + " \247a" + ((double)Math.round((((EntityLivingBase) entity).getHealth() * 100) / 100) / 2);
    }
    
    for(Friend friend: Wrapper.getFriends().friendsList) {
    	name.replace(friend.getName(), friend.getAlias());
    }
    float var13 = 1.6F;
    float var14 = (float) (0.016666668F * (Wrapper.getPlayer().getDistanceToEntity(entity)) / 2);
    GL11.glPushMatrix();
    GL11.glTranslatef((float) x, (float) y + entity.height + 0.5F, (float) z);
    GL11.glNormal3f(0.0F, 1.0F, 0.0F);
    GL11.glRotatef(-RenderManager.playerViewY, 0.0F, 1.0F, 0.0F);
    GL11.glRotatef(RenderManager.playerViewX, 1.0F, 0.0F, 0.0F);
    GL11.glScalef(-var14, -var14, var14);
    GL11.glDepthMask(false);
    GL11.glDisable(GL11.GL_LIGHTING);
    Tessellator var15 = Tessellator.getInstance();
    VertexBuffer vertexbuffer = var15.getBuffer();
    int var16 = (int) -Wrapper.getPlayer().getDistanceToEntity(entity) / (int) var13;
    if (entity.isSneaking()) {
        var16 += 4;
    } else if (var16 < -14) {
        var16 = -14;
    }

    GL11.glDisable(GL11.GL_TEXTURE_2D);
    int var17 = Fonts.roboto18.getStringWidth(name) / 2;
    RenderUtils.drawBorderedRect(-var17 - 2, var16, var17 + 2, 11 + var16, 0.5F, 0xFF000000, 0x80000000);

    Fonts.roboto18.drawStringWithShadow(name, -var17, var16, 0xFFFFFF);
    
    Wrapper.getMinecraft().entityRenderer.disableLightmap();
    GL11.glLineWidth(1.0F);
    GL11.glEnable(GL11.GL_TEXTURE_2D);
    GL11.glDisable(GL11.GL_BLEND);
    GL11.glDisable(GL11.GL_LIGHTING);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GL11.glEnable(GL11.GL_DEPTH_TEST);
    GL11.glDepthMask(true);
    
    GL11.glPopMatrix();
}
 
Example 15
Project: Mods   File: RenderBall.java   View Source Code Vote up 4 votes
@Override
public void doRender(EntityBall entity, double x, double y, double z, float yaw, float partialTick) {
	GL11.glPushMatrix();
	GL11.glTranslatef((float) x, (float) y + entity.height / 2, (float) z);
	GL11.glColor4f(0.7F, 0.7F, 0.7F, 1F);
	GL11.glRotatef(entity.prevRotationYaw + (entity.rotationYaw - entity.prevRotationYaw) * partialTick - 90.0F,
			0.0F, 1.0F, 0.0F);
	GL11.glRotatef(entity.prevRotationPitch + (entity.rotationPitch - entity.prevRotationPitch) * partialTick, 0.0F,
			0.0F, 1.0F);

	bindEntityTexture(entity);

	// GL11.glTranslatef((float)entity.posX, (float)entity.posY,
	// entity.posZ);
	if (entity.getCritical() == 2) {
		// GlStateManager.disableTexture2D();
		GlStateManager.disableLighting();
		// GL11.glColor4f(0.0F, 0.0F, 1.0F, 1F);
		model.render(entity, 0F, 0F, 0.0F, 0.0F, 0.0F, 0.0625F);
		// GL11.glColor4f(1.0F, 1.0F, 1.0F, 1F);
		// GlStateManager.enableTexture2D();
		GlStateManager.enableLighting();
	} else
		model.render(entity, 0F, 0F, 0.0F, 0.0F, 0.0F, 0.0625F);

	/*
	 * GL11.glScalef(1.5f, 1.5f, 1.5f); GL11.glEnable(GL11.GL_BLEND);
	 * //GL11.glDisable(GL11.GL_ALPHA_TEST); OpenGlHelper.glBlendFunc(770,
	 * 771, 1, 0);
	 * 
	 * char c0 = 61680; int j = c0 % 65536; int k = c0 / 65536;
	 * OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit,
	 * (float)j / 1.0F, (float)k / 1.0F);
	 * 
	 * model.render(entity, 0F, 0F, 0.0F, 0.0F, 0.0F, 0.0625F);
	 * GL11.glDisable(GL11.GL_BLEND); // GL11.glEnable(GL11.GL_ALPHA_TEST);
	 */
	GL11.glColor4f(1F, 1F, 1F, 1F);
	GL11.glPopMatrix();
	/*
	 * IIcon iicon = TF2EventBusListener.pelletIcon;
	 * 
	 * if (iicon != null) { GL11.glPushMatrix();
	 * GL11.glTranslatef((float)x,(float) y,(float) z);
	 * GL11.glEnable(GL12.GL_RESCALE_NORMAL); GL11.glScalef(0.5F, 0.5F,
	 * 0.5F); this.bindTexture(TextureMap.locationItemsTexture); Tessellator
	 * tessellator = Tessellator.instance;
	 * 
	 * float f = iicon.getMinU(); float f1 = iicon.getMaxU(); float f2 =
	 * iicon.getMinV(); float f3 = iicon.getMaxV(); float f4 = 1.0F; float
	 * f5 = 0.5F; float f6 = 0.25F; GL11.glRotatef(180.0F -
	 * this.renderManager.playerViewY, 0.0F, 1.0F, 0.0F);
	 * GL11.glRotatef(-this.renderManager.playerViewX, 1.0F, 0.0F, 0.0F);
	 * tessellator.startDrawingQuads(); tessellator.setNormal(0.0F, 1.0F,
	 * 0.0F); tessellator.addVertexWithUV((double)(0.0F - f5), (double)(0.0F
	 * - f6), 0.0D, (double)f, (double)f3);
	 * tessellator.addVertexWithUV((double)(f4 - f5), (double)(0.0F - f6),
	 * 0.0D, (double)f1, (double)f3);
	 * tessellator.addVertexWithUV((double)(f4 - f5), (double)(f4 - f6),
	 * 0.0D, (double)f1, (double)f2);
	 * tessellator.addVertexWithUV((double)(0.0F - f5), (double)(f4 - f6),
	 * 0.0D, (double)f, (double)f2); tessellator.draw();
	 * GL11.glDisable(GL12.GL_RESCALE_NORMAL); GL11.glPopMatrix();
	 * 
	 * }
	 */

}
 
Example 16
Project: OpenFlexiTrack   File: RenderTrack.java   View Source Code Vote up 4 votes
@Override
public void renderTileEntityAt(TileEntityTrack tileTrack, double x, double y, double z, float partialTicks, int destroyStage) {

	super.renderTileEntityAt(tileTrack, x, y, z, partialTicks, destroyStage);

	/*
	 * If there's nothing to render, don't render.
	 */
	if (tileTrack.curve == null) {
		return;
	}

	/*
	 * Sometimes the TE's don't break evenly. Make sure this doesn't happen and we try to render a flag here.
	 */
	TileEntity tile = tileTrack.getWorld().getTileEntity(tileTrack.getPos().add(tileTrack.curve.endPos));
	if( !(tile instanceof TileEntityTrack) ) {
		return;
	}
	TileEntityTrack otherEnd = (TileEntityTrack) tile;

	/* Quick check to see if connection is still valid. */
	if (tileTrack.connectedTrack != null && tileTrack.connectedTrack.isInvalid()) {

		// Reset the other track as well, if existent.
		if (tileTrack.connectedTrack.connectedTrack == tileTrack) {
			tileTrack.connectedTrack.connectedTrack = null;
			tileTrack.connectedTrack.hasTriedToConnectToOtherSegment = false;
		}

		// Then reset this track.
		tileTrack.connectedTrack = null;
		tileTrack.hasTriedToConnectToOtherSegment = false;
	}

	/* If this Tile Entity is not connected, and has not tried to connect, do so now. */
	if (!tileTrack.hasTriedToConnectToOtherSegment) {
		tileTrack.hasTriedToConnectToOtherSegment = connectToAdjacentTracks(tileTrack);
	}

	/*
	 * Try to keep the same track rendering if possible. If the track isn't null, render that one instead.
	 */
	if (isTrackPrimary(otherEnd, tileTrack)) {
		this.renderTileEntityAt(otherEnd, x + otherEnd.getPos().getX() - tileTrack.getPos().getX(), y + otherEnd.getPos().getY() - tileTrack.getPos().getY(), z + otherEnd.getPos().getZ() - tileTrack.getPos().getZ(), partialTicks, destroyStage);
		return;
	}

	/*
	 * Otherwise render this track.
	 */
	GL11.glPushMatrix();
	{
		/* Translate render position. */
		GL11.glTranslated(x, y, z);

		/* Render the finished track, including track beds and rails. */
		GL11.glPushMatrix();
		{
			renderTrackFromCurve(tileTrack, tileTrack.connectedTrack, otherEnd.connectedTrack);
		}
		GL11.glPopMatrix();

		/* Render ballast at start and end (block) position of track, respectively. */
		Minecraft.getMinecraft().getTextureManager().bindTexture(ballastTexture);
		GL11.glPushMatrix();
		{
			int lightValue = tileTrack.getWorld().getCombinedLight(tileTrack.getPos(), 0);
			OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, lightValue%65536, lightValue/65536);
			drawBallastBox();

			GL11.glTranslatef(tileTrack.curve.endPos.getX(), tileTrack.curve.endPos.getY(), tileTrack.curve.endPos.getZ());
			lightValue = tileTrack.getWorld().getCombinedLight(tileTrack.getPos().add(tileTrack.curve.endPos), 0);
			OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, lightValue%65536, lightValue/65536);
			drawBallastBox();
		}
		GL11.glPopMatrix();
	}
	GL11.glPopMatrix();
}
 
Example 17
Project: Backmemed   File: Tracers.java   View Source Code Vote up 4 votes
@Override
public void onRender() {
	if(isEnabled()) {
		try {
			GL11.glPushMatrix();
			GL11.glEnable(GL11.GL_LINE_SMOOTH);
			GL11.glDisable(GL11.GL_DEPTH_TEST);
			GL11.glDisable(GL11.GL_TEXTURE_2D);
			GL11.glDepthMask(false);
			GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
			GL11.glEnable(GL11.GL_BLEND);
			GL11.glLineWidth(1.5F);
			for (Entity entities : Client.mc.world.loadedEntityList) {
				if (entities != Client.mc.player && entities != null) {
					if (entities instanceof EntityPlayer) {
						float distance = Client.mc.renderViewEntity.getDistanceToEntity(entities);
						double posX = ((entities.lastTickPosX + (entities.posX - entities.lastTickPosX)
								- RenderManager.renderPosX));
						double posY = ((entities.lastTickPosY + (entities.posY - entities.lastTickPosY)
								- RenderManager.renderPosY));
						double posZ = ((entities.lastTickPosZ + (entities.posZ - entities.lastTickPosZ)
								- RenderManager.renderPosZ));
	
						if(Wrapper.getFriends().isFriend(entities.getName())) {
	    					GL11.glColor3f(0.0F, 1.0F, 0.0F);
	    				}else{
							if (distance <= 6F) {
								GL11.glColor3f(1.0F, 0.0F, 0.0F);
							} else if (distance <= 96F) {
								GL11.glColor3f(1.0F, (distance / 100F), 0.0F);
							} else if (distance > 96F) {
								GL11.glColor3f(0.1F, 0.6F, 255.0F);
							}
	    				}
						Vec3d eyes = new Vec3d(0, 0, 1).rotatePitch(-(float) Math.toRadians(Wrapper.getPlayer().rotationPitch)).rotateYaw(-(float) Math.toRadians(Wrapper.getPlayer().rotationYaw));
						
						GL11.glBegin(GL11.GL_LINE_LOOP);
						
						GL11.glVertex3d(eyes.xCoord, Wrapper.getPlayer().getEyeHeight() + eyes.yCoord, eyes.zCoord);
						GL11.glVertex3d(posX, posY, posZ);
	
						GL11.glEnd();
					}
				}
			}
			GL11.glDisable(GL11.GL_BLEND);
			GL11.glDepthMask(true);
			GL11.glEnable(GL11.GL_TEXTURE_2D);
			GL11.glEnable(GL11.GL_DEPTH_TEST);
			GL11.glDisable(GL11.GL_LINE_SMOOTH);
			GL11.glPopMatrix();
		} catch (Exception e) {}
	}
}
 
Example 18
Project: SerenityCE   File: BlockListSelector.java   View Source Code Vote up 4 votes
@Override
public void draw(int mouseX, int mouseY, float partialTicks) {
    Block hoveredBlock = getHoveringOver(mouseX, mouseY);

    ttfRenderer.drawString(label, getX() + 2, getY() + 1);
    RenderUtilities.drawRect(getX(), getY() + 18, getX() + getWidth(), getY() + getHeight(), 0xFF232323);

    prepareScissorBox(getX(), getY() + 18, getX() + getWidth(), getY() + getHeight() - 2);
    GL11.glEnable(GL11.GL_SCISSOR_TEST);

    int x = 0;
    int y = 0;
    RenderHelper.enableGUIStandardItemLighting();
    GL11.glPushMatrix();
    GL11.glTranslated(0, -scrollValue.getValue(), 0);
    for (Block block : blocks) {
        try {
            if (x + 18 > getWidth()) {
                x = 0;
                y += 18;
            }

            /* if (isMouseWithin(getX() + x - 1, getY() + y + 17, getX() + x + 17, getY() + y + 35, mouseX, mouseY)) */
            boolean hovered = hoveredBlock == block;
            boolean selected = value.containsBlock(block);
            if (hovered || selected)
                RenderUtilities.drawRect(getX() + 2 + x - 1, getY() + 20 + y - 1, getX() + 2 + x + 17, getY() + 20 + y + 17, hovered && selected ? 0xFF787878 : hovered ? 0xFF494949 : selected ? 0xFF363636 : 0);
            mc.getRenderItem().renderItemIntoGUI(new ItemStack(block), getX() + 2 + x, getY() + 20 + y);
            x += 18;
        } catch (Exception e) {}
    }
    GL11.glPopMatrix();

    scrollValue.update(partialTicks);

    double wheel = Math.signum(-Mouse.getDWheel()) * 2;
    if (isHovering(mouseX, mouseY)) {
        if (wheel > 0) {
            scrollValue.applyForce(wheel);
        } else if (wheel < 0) {
            scrollValue.applyForce(wheel);
        }
    }

    if (scrollValue.getValue() < 0) {
        scrollValue.setValue(0);
    }
    if (scrollValue.getValue() > y - getHeight() + 36) {
        scrollValue.setValue(y - getHeight() + 36);
    }
    RenderHelper.disableStandardItemLighting();

    GL11.glDisable(GL11.GL_SCISSOR_TEST);
}
 
Example 19
Project: minecraft-quiverbow   File: Render_Projectile.java   View Source Code Vote up 4 votes
public void doRender_LightningRed(_ProjectileBase entity, double x, double y, double z, float yaw, float tick, double length, double width) 
{
	GL11.glPushMatrix();
    
    this.bindEntityTexture(entity);
    
    GL11.glDisable(GL11.GL_LIGHTING);			// For proper world lighting, not internal lighting. Otherwise the entity is too dark
    GL11.glDisable(GL11.GL_CULL_FACE);			// Disables the culling of back faces. Good for not having to draw front and back of a thing
    GL11.glEnable(GL12.GL_RESCALE_NORMAL);
    
    GL11.glTranslatef((float)x, (float)y, (float)z);
    GL11.glScalef(0.5F, 0.5F, 0.5F);
    
    Tessellator tes = Tessellator.instance;		// Grab a instance of the tesselator here (non-static, as they say)
    
    GL11.glRotatef(entity.prevRotationYaw + (entity.rotationYaw - entity.prevRotationYaw) * tick - 90.0F, 0.0F, 1.0F, 0.0F);
    GL11.glRotatef(entity.prevRotationPitch + (entity.rotationPitch - entity.prevRotationPitch) * tick, 0.0F, 0.0F, 1.0F);

    float f10 = 0.05625F;
    
    GL11.glRotatef(45.0F, 1.0F, 0.0F, 0.0F);
    GL11.glScalef(f10, f10, f10);
    GL11.glTranslatef(-4.0F, 0.0F, 0.0F);
    GL11.glNormal3f(f10, 0.0F, 0.0F);
    
    for (int i = 0; i < 2; ++i)
    {
        GL11.glRotatef(90.0F, 1.0F, 0.0F, 0.0F);
        GL11.glNormal3f(0.0F, 0.0F, f10);
        
        tes.startDrawingQuads();
        //			 		 X      Y     Z     TX,   TY
        tes.addVertexWithUV(-length, -width, 0.0D, 0, 0);
        tes.addVertexWithUV( length, -width, 0.0D, 0, 1);
        tes.addVertexWithUV( length,  width, 0.0D, 1, 1);
        tes.addVertexWithUV(-length,  width, 0.0D, 1, 0);
        tes.draw();
    }

    GL11.glDisable(GL12.GL_RESCALE_NORMAL);
    GL11.glEnable(GL11.GL_CULL_FACE);
    GL11.glEnable(GL11.GL_LIGHTING);

    GL11.glPopMatrix();
}
 
Example 20
Project: Backmemed   File: GlStateManager.java   View Source Code Vote up 4 votes
public static void pushMatrix()
{
    GL11.glPushMatrix();
}