Java Code Examples for org.lwjgl.opengl.GL11

The following are top voted examples for showing how to use org.lwjgl.opengl.GL11. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: BaseClient   File: FontRenderer.java   Source Code and License 7 votes vote down vote up
/**
 * Render a single character with the default.png font at current (posX,posY) location...
 */
private float renderDefaultChar(int p_78266_1_, boolean p_78266_2_)
{
    int i = p_78266_1_ % 16 * 8;
    int j = p_78266_1_ / 16 * 8;
    int k = p_78266_2_ ? 1 : 0;
    this.bindTexture(this.locationFontTexture);
    float f = this.charWidth[p_78266_1_];
    float f1 = 7.99F;
    GL11.glBegin(GL11.GL_TRIANGLE_STRIP);
    GL11.glTexCoord2f((float)i / 128.0F, (float)j / 128.0F);
    GL11.glVertex3f(this.posX + (float)k, this.posY, 0.0F);
    GL11.glTexCoord2f((float)i / 128.0F, ((float)j + 7.99F) / 128.0F);
    GL11.glVertex3f(this.posX - (float)k, this.posY + 7.99F, 0.0F);
    GL11.glTexCoord2f(((float)i + f1 - 1.0F) / 128.0F, (float)j / 128.0F);
    GL11.glVertex3f(this.posX + f1 - 1.0F + (float)k, this.posY, 0.0F);
    GL11.glTexCoord2f(((float)i + f1 - 1.0F) / 128.0F, ((float)j + 7.99F) / 128.0F);
    GL11.glVertex3f(this.posX + f1 - 1.0F - (float)k, this.posY + 7.99F, 0.0F);
    GL11.glEnd();
    return f;
}
 
Example 2
Project: pnc-repressurized   File: ProgWidget.java   Source Code and License 7 votes vote down vote up
@Override
public void render() {
    FMLClientHandler.instance().getClient().getTextureManager().bindTexture(getTexture());
    int width = getWidth() + (getParameters() != null && getParameters().length > 0 ? 10 : 0);
    int height = getHeight() + (hasStepOutput() ? 10 : 0);
    Pair<Double, Double> maxUV = getMaxUV();
    double u = maxUV.getLeft();
    double v = maxUV.getRight();
    BufferBuilder wr = Tessellator.getInstance().getBuffer();
    wr.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX);
    wr.pos(0, 0, 0).tex(0, 0).endVertex();
    wr.pos(0, height, 0).tex(0, v).endVertex();
    wr.pos(width, height, 0).tex(u, v).endVertex();
    wr.pos(width, 0, 0).tex(u, 0).endVertex();
    Tessellator.getInstance().draw();
}
 
Example 3
Project: pnc-repressurized   File: SemiBlockRendererCropSupport.java   Source Code and License 6 votes vote down vote up
@Override
public void render(SemiBlockCropSupport semiBlock, float partialTick) {
    GL11.glPushMatrix();
    Minecraft.getMinecraft().renderEngine.bindTexture(Textures.MODEL_HEAT_FRAME);

    double brightness = 0.2;
    GL11.glColor4d(brightness, brightness, brightness, 1);

    AxisAlignedBB aabb = new AxisAlignedBB(3 / 16D, -6 / 16D, 3 / 16D, 13 / 16D, 17 / 16D, 13 / 16D);
   
    GL11.glTranslated(aabb.minX, aabb.minY, aabb.minZ);
    GL11.glScaled(aabb.maxX - aabb.minX, aabb.maxY - aabb.minY, aabb.maxZ - aabb.minZ);
    GL11.glTranslated(0.5, -0.5, 0.5);
    model.render(null, 0, 0, 0, 0, 0, 1 / 16F);
    GL11.glPopMatrix();
    GL11.glColor4d(1, 1, 1, 1);
}
 
Example 4
Project: OpenFlexiTrack   File: DefaultSleeperType.java   Source Code and License 6 votes vote down vote up
@SideOnly(Side.CLIENT)
private static final void renderTieBottom(float width){
	GL11.glTexCoord2f(tieTopMinU, tieTopMinV);
	GL11.glNormal3f(0, 1, 0);
	GL11.glVertex3f(width/2, 0, length/2);

	GL11.glTexCoord2f(tieTopMaxU, tieTopMinV);
	GL11.glNormal3f(0, 1, 0);
	GL11.glVertex3f(-width/2, 0, length/2);

	GL11.glTexCoord2f(tieTopMaxU, tieTopMaxV);
	GL11.glNormal3f(0, 1, 0);
	GL11.glVertex3f(-width/2, 0, -length/2);

	GL11.glTexCoord2f(tieTopMinU, tieTopMaxV);
	GL11.glNormal3f(0, 1, 0);
	GL11.glVertex3f(width/2, 0, -length/2);
}
 
Example 5
Project: Backmemed   File: RenderUtils.java   Source Code and License 6 votes vote down vote up
public static void emptyBlockESPBox(BlockPos blockPos) {
	double x = blockPos.getX() - Minecraft.getMinecraft().getRenderManager().renderPosX;
	double y = blockPos.getY() - Minecraft.getMinecraft().getRenderManager().renderPosY;
	double z = blockPos.getZ() - Minecraft.getMinecraft().getRenderManager().renderPosZ;
	GL11.glBlendFunc(770, 771);
	GL11.glEnable(GL_BLEND);
	GL11.glLineWidth(2.0F);
	GL11.glDisable(GL11.GL_TEXTURE_2D);
	GL11.glDisable(GL_DEPTH_TEST);
	GL11.glDepthMask(false);
	GL11.glColor4d(0, 0, 0, 0.5F);
	drawSelectionBoundingBox(new AxisAlignedBB(x, y, z, x + 1.0, y + 1.0, z + 1.0));
	GL11.glEnable(GL11.GL_TEXTURE_2D);
	GL11.glEnable(GL_DEPTH_TEST);
	GL11.glDepthMask(true);
	GL11.glDisable(GL_BLEND);
}
 
Example 6
Project: customstuff4   File: GuiContainerCS4.java   Source Code and License 6 votes vote down vote up
@Override
protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY)
{
    if (content.bg != null)
    {
        mc.getTextureManager().bindTexture(content.bg);
        int x = (width - xSize) / 2;
        int y = (height - ySize) / 2;
        drawTexturedModalRect(x, y, content.bgTexX, content.bgTexY, xSize, ySize);

        GL11.glPushMatrix();
        GL11.glTranslatef(x, y, 0f);
        for (ProgressBar bar : content.progressBars)
        {
            bar.draw(progressBarSource);
        }
        GL11.glPopMatrix();
    }
}
 
Example 7
Project: uniquecrops   File: PageImage.java   Source Code and License 6 votes vote down vote up
@Override
public void draw() {
	
	super.draw();
	
	TextureManager render = mc.renderEngine;
	render.bindTexture(resource);
	
	GlStateManager.enableBlend();
	GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
	GlStateManager.color(1F, 1F, 1F, 1F);
	int k = (gui.width - gui.WIDTH) / 2;
	gui.drawTexturedModalRect(k + 5, 5, 0, 0, gui.WIDTH, gui.HEIGHT);
	gui.drawCenteredString(mc.fontRendererObj, text, drawX + 60, drawY + 150, Color.gray.getRGB());
	GlStateManager.disableBlend();
}
 
Example 8
Project: Zombe-Modpack   File: Safe.java   Source Code and License 6 votes vote down vote up
@Override
protected void onWorldDraw(float delta, float x, float y, float z) {
    float mx, my, mz;
    if (!safeShow) return;
    if (--safeUpdate < 0) {
        safeUpdate = 13;
        reCheckSafe(fix(x), fix(y), fix(z));
    }
    if (safeGhost) GL11.glDisable(GL11.GL_DEPTH_TEST);
    else           GL11.glEnable( GL11.GL_DEPTH_TEST);
    GL11.glDisable(GL11.GL_TEXTURE_2D);
    GL11.glDisable(GL11.GL_BLEND);
    GL11.glDisable(GL11.GL_FOG);
    GL11.glBegin(GL11.GL_LINES);
    for (int i = 0; i < safeCur; ++i) {
        Vec3i pos   = safePoses[i];
        Color color = safeMarks[i];
        GL11.glColor3ub(color.rb, color.gb, color.bb);
        mx = pos.getX() - x; my = pos.getY() - y; mz = pos.getZ() - z;
        GL11.glVertex3f(mx+0.9f,my+0.01f,mz+0.9f);
        GL11.glVertex3f(mx+0.1f,my+0.01f,mz+0.1f);
        GL11.glVertex3f(mx+0.9f,my+0.01f,mz+0.1f);
        GL11.glVertex3f(mx+0.1f,my+0.01f,mz+0.9f);
    }
    GL11.glEnd();
}
 
Example 9
Project: ObsidianSuite   File: GuiEntityRendererWithTranslation.java   Source Code and License 6 votes vote down vote up
@Override
protected void onControllerDrag()
{
	Part part = selectedPart;
	if(part instanceof PartObj || part instanceof PartRotation)
		super.onControllerDrag();
	else
	{
		GL11.glPushMatrix();
		if(part instanceof PartEntityPos)
			GL11.glTranslated(-entityToRender.posX, -entityToRender.posY, -entityToRender.posZ);
		int i = translationAxisPlane == 0 ? 2 : translationAxisPlane - 1;
		translationGuidePoint = getMouseVectorInPlane(i);
		processAxisDrag();
		GL11.glPopMatrix();
	}
}
 
Example 10
Project: candlelight   File: VBO.java   Source Code and License 6 votes vote down vote up
public VBO updateData(IntBuffer buffer, long offset)
{
	if (this.type != GL11.GL_UNSIGNED_INT)
	{
		throw new IllegalArgumentException("Cannot store mismatching type in buffer!");
	}

	if (offset + buffer.limit() > this.length)
	{
		int usage = GL15.glGetBufferParameteri(this.target, GL15.GL_BUFFER_USAGE);
		this.putData(buffer, this.normalized, usage);
	}

	GL15.glBindBuffer(this.target, this.handle);
	GL15.glBufferSubData(this.target, offset, buffer);

	return this;
}
 
Example 11
Project: EcoSystem-Official   File: TextureAttachment.java   Source Code and License 6 votes vote down vote up
private void setTextureParams() {
    int filterType = nearestFiltering ? GL11.GL_NEAREST : GL11.GL_LINEAR;
    GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, filterType);
    GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, filterType);
    int wrapType = clampEdges ? GL12.GL_CLAMP_TO_EDGE : GL11.GL_REPEAT;
    GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, wrapType);
    GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, wrapType);
}
 
Example 12
Project: pnc-repressurized   File: ModelGauge.java   Source Code and License 6 votes vote down vote up
@Override
protected void renderDynamic(float scale, float partialTicks) {
    shape1.render(scale);
    shape2.render(scale);

    float pressure = 0f;
    float dangerPressure = 5f;
    float critPressure = 7f;
    if (gaugeModule != null && gaugeModule.getTube() instanceof TileEntityPneumaticBase) {
        TileEntityPneumaticBase base = (TileEntityPneumaticBase) gaugeModule.getTube();
        pressure = base.getPressure();
        critPressure = base.criticalPressure;
        dangerPressure = base.dangerPressure;
    }
    GL11.glTranslated(0, 1, 0.378);
    double widgetScale = 0.007D;
    GL11.glScaled(widgetScale, widgetScale, widgetScale);
    GL11.glRotated(180, 0, 1, 0);
    GL11.glDisable(GL11.GL_LIGHTING);
    GuiUtils.drawPressureGauge(FMLClientHandler.instance().getClient().fontRenderer, -1, critPressure, dangerPressure, -1, pressure, 0, 0, 0);
    GL11.glEnable(GL11.GL_LIGHTING);
}
 
Example 13
Project: betaexpansion   File: GuiIngame.java   Source Code and License 6 votes vote down vote up
private void renderPumpkinBlur(int i, int j)
{
    GL11.glDisable(2929 /*GL_DEPTH_TEST*/);
    GL11.glDepthMask(false);
    GL11.glBlendFunc(770, 771);
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    GL11.glDisable(3008 /*GL_ALPHA_TEST*/);
    GL11.glBindTexture(3553 /*GL_TEXTURE_2D*/, mc.renderEngine.getTexture("%blur%/misc/pumpkinblur.png"));
    Tessellator tessellator = Tessellator.instance;
    tessellator.startDrawingQuads();
    tessellator.addVertexWithUV(0.0D, j, -90D, 0.0D, 1.0D);
    tessellator.addVertexWithUV(i, j, -90D, 1.0D, 1.0D);
    tessellator.addVertexWithUV(i, 0.0D, -90D, 1.0D, 0.0D);
    tessellator.addVertexWithUV(0.0D, 0.0D, -90D, 0.0D, 0.0D);
    tessellator.draw();
    GL11.glDepthMask(true);
    GL11.glEnable(2929 /*GL_DEPTH_TEST*/);
    GL11.glEnable(3008 /*GL_ALPHA_TEST*/);
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
}
 
Example 14
Project: Progetto-C   File: PBufferUniqueGraphics.java   Source Code and License 6 votes vote down vote up
/**
 * @see org.newdawn.slick.Graphics#disable()
 */
protected void disable() {
	// Bind the texture after rendering.
	GL11.glBindTexture(GL11.GL_TEXTURE_2D, image.getTexture().getTextureID());
	GL11.glCopyTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGBA, 0, 0, 
						  image.getTexture().getTextureWidth(), 
						  image.getTexture().getTextureHeight(), 0);
	
	try {
		Display.makeCurrent();
	} catch (LWJGLException e) {
		Log.error(e);
	}
	
	SlickCallable.leaveSafeBlock();
}
 
Example 15
Project: harshencastle   File: HarshenClientUtils.java   Source Code and License 6 votes vote down vote up
public static void renderGhostModel(IBakedModel model, BlockPos position, Color color, boolean noDepth, float partialTicks)
{
	GlStateManager.enableBlend();
       GL11.glBlendFunc(GL11.GL_ONE, GL11.GL_ONE_MINUS_DST_COLOR);
	BufferBuilder vb;
	if(noDepth)
	{
           GlStateManager.depthFunc(519);
		vb = prepRenderBlockDepth(partialTicks, true);
	}
	else
        vb = prepRender(partialTicks, true);
       vb.begin(7, DefaultVertexFormats.BLOCK);
       World world = Minecraft.getMinecraft().world;
       BlockRendererDispatcher dispatcher = Minecraft.getMinecraft().getBlockRendererDispatcher();
       dispatcher.getBlockModelRenderer().renderModel(world, model, Minecraft.getMinecraft().world.getBlockState(position), position.add(0, noDepth ? 500 : 0, 0), vb, false);
       for(int i = 0; i < vb.getVertexCount(); i++)
       	vb.putColorMultiplier(color.getRed() / 255f, color.getGreen() / 255f, color.getBlue() / 255f, i);
       vb.color(1, 1, 1, 0.1f);
       postRender();
       GlStateManager.depthFunc(515);
       GlStateManager.disableBlend();
}
 
Example 16
Project: interactionwheel   File: RenderHelper.java   Source Code and License 6 votes vote down vote up
public static void renderBillboardQuadWithRotation(float rot, double scale) {
    GlStateManager.pushMatrix();

    rotateToPlayer();

    GlStateManager.rotate(rot, 0, 0, 1);

    Tessellator tessellator = Tessellator.getInstance();
    VertexBuffer buffer = tessellator.getBuffer();
    buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX);
    buffer.pos(-scale, -scale, 0).tex(0, 0).endVertex();
    buffer.pos(-scale, +scale, 0).tex(0, 1).endVertex();
    ;
    buffer.pos(+scale, +scale, 0).tex(1, 1).endVertex();
    ;
    buffer.pos(+scale, -scale, 0).tex(1, 0).endVertex();
    ;
    tessellator.draw();
    GlStateManager.popMatrix();
}
 
Example 17
Project: BaseClient   File: PBufferGraphics.java   Source Code and License 6 votes vote down vote up
/**
 * Initialise the PBuffer that will be used to render to
 * 
 * @throws SlickException
 */
private void init() throws SlickException {
	try {
		Texture tex = InternalTextureLoader.get().createTexture(image.getWidth(), image.getHeight(), image.getFilter());
		
		final RenderTexture rt = new RenderTexture(false, true, false, false, RenderTexture.RENDER_TEXTURE_2D, 0);
		pbuffer = new Pbuffer(screenWidth, screenHeight, new PixelFormat(8, 0, 0), rt, null);

		// Initialise state of the pbuffer context.
		pbuffer.makeCurrent();

		initGL();
		GL.glBindTexture(GL11.GL_TEXTURE_2D, tex.getTextureID());
		pbuffer.releaseTexImage(Pbuffer.FRONT_LEFT_BUFFER);
		image.draw(0,0);
		image.setTexture(tex);
		
		Display.makeCurrent();
	} catch (Exception e) {
		Log.error(e);
		throw new SlickException("Failed to create PBuffer for dynamic image. OpenGL driver failure?");
	}
}
 
Example 18
Project: betaexpansion   File: GuiMainMenu.java   Source Code and License 6 votes vote down vote up
public void drawScreen(int i, int j, float f)
{
    drawDefaultBackground();
    Tessellator tessellator = Tessellator.instance;
    char c = '\u0112';
    int k = width / 2 - c / 2;
    byte byte0 = 30;
    GL11.glBindTexture(3553 /*GL_TEXTURE_2D*/, mc.renderEngine.getTexture("/title/mclogo.png"));
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    drawTexturedModalRect(k + 0, byte0 + 0, 0, 0, 155, 44);
    drawTexturedModalRect(k + 155, byte0 + 0, 0, 45, 155, 44);
    tessellator.setColorOpaque_I(0xffffff);
    GL11.glPushMatrix();
    GL11.glTranslatef(width / 2 + 90, 70F, 0.0F);
    GL11.glRotatef(-20F, 0.0F, 0.0F, 1.0F);
    float f1 = 1.8F - MathHelper.abs(MathHelper.sin(((float)(System.currentTimeMillis() % 1000L) / 1000F) * 3.141593F * 2.0F) * 0.1F);
    f1 = (f1 * 100F) / (float)(fontRenderer.getStringWidth(splashText) + 32);
    GL11.glScalef(f1, f1, f1);
    drawCenteredString(fontRenderer, splashText, 0, -8, 0xffff00);
    GL11.glPopMatrix();
    drawString(fontRenderer, "Minecraft Beta 1.7.3", 2, 2, 0x505050);
    drawString(fontRenderer, "BetaExpansion "+mod_BetaExpansion.version, 2, height-10, 0x505050);
    String s = "Copyright Mojang AB. Do not distribute.";
    drawString(fontRenderer, s, width - fontRenderer.getStringWidth(s) - 2, height - 10, 0xffffff);
    super.drawScreen(i, j, f);
}
 
Example 19
Project: open-world   File: WaterRegion.java   Source Code and License 6 votes vote down vote up
/**
    * Renders the world to the water framebuffer.
    * @param worldCamera
    * @param world
    */
   public void preRender(final PerspectiveCamera camera, final World world) {
GL11.glEnable(GL30.GL_CLIP_DISTANCE0);
framebuffer.bind();
GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);

// Render to reflection texture.
float verticalDistance = camera.getPosition().y - WATER_HEIGHT;
camera.getPosition().y -= verticalDistance * 2;
camera.invertPitch();
camera.update();
world.renderWithoutWater(camera, true);
camera.invertPitch();
camera.getPosition().y += verticalDistance * 2;
camera.update();

FrameBuffer.unbind();
GL11.glDisable(GL30.GL_CLIP_DISTANCE0);
   }
 
Example 20
Project: Backmemed   File: Shaders.java   Source Code and License 6 votes vote down vote up
public static void genCompositeMipmap()
{
    if (hasGlGenMipmap)
    {
        for (int i = 0; i < usedColorBuffers; ++i)
        {
            if ((activeCompositeMipmapSetting & 1 << i) != 0)
            {
                GlStateManager.setActiveTexture(33984 + colorTextureTextureImageUnit[i]);
                GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR_MIPMAP_LINEAR);
                GL30.glGenerateMipmap(3553);
            }
        }

        GlStateManager.setActiveTexture(33984);
    }
}
 
Example 21
Project: CommunityEngine-Java   File: TextureLoader.java   Source Code and License 5 votes vote down vote up
public static Texture loadTexture(String textureFile) {
		try {
//			InputStream in = TextureLoader.class.getResourceAsStream("/" + textureFile);
			InputStream in = Util.loadInternal(textureFile);
			BufferedImage image = ImageIO.read(in);
			
			int[] pixels = new int[image.getWidth() * image.getHeight()];
			image.getRGB(0, 0, image.getWidth(), image.getHeight(), pixels, 0, image.getWidth());
			ByteBuffer buffer = ByteBuffer.allocateDirect(image.getWidth() * image.getHeight() * 4);
			
			for(int h = 0; h < image.getHeight(); h++) {
				for(int w = 0; w < image.getWidth(); w++) {
					int pixel = pixels[h * image.getWidth() + w];
					
					buffer.put((byte) ((pixel >> 16) & 0xFF));
					buffer.put((byte) ((pixel >> 8) & 0xFF));
					buffer.put((byte) (pixel & 0xFF));
					buffer.put((byte) ((pixel >> 24) & 0xFF));
				}
			}
			
			buffer.flip();
			in.close();
			
			int textureID = GL11.glGenTextures();
			GL11.glBindTexture(GL11.GL_TEXTURE_2D, textureID);
			GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGBA8, image.getWidth(), image.getHeight(), 0, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, buffer);
			
			GL30.glGenerateMipmap(GL11.GL_TEXTURE_2D);
			GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR_MIPMAP_NEAREST);
			GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL14.GL_MAX_TEXTURE_LOD_BIAS, -1);
			GL11.glBindTexture(GL11.GL_TEXTURE_2D, 0);
			
			return new Texture(textureID, image.getWidth(), image.getHeight());
		} catch (Exception e) {
			e.printStackTrace();
			
			return null;
		}
	}
 
Example 22
Project: KraftigAudio   File: ToggleLabelButton.java   Source Code and License 5 votes vote down vote up
@Override
public void render(float alpha)
{
    Vec2 pos = getPos();
    Vec2 radius = getRadius();
    
    if (getValue())
    {
        GL11.glColor4f(1.0f, 1.0f, 1.0f, alpha*0.5f);
        GL11.glBegin(GL11.GL_QUADS);
        GL11.glVertex2f(pos.x - radius.x, pos.y - radius.y);
        GL11.glVertex2f(pos.x - radius.x, pos.y + radius.y);
        GL11.glVertex2f(pos.x + radius.x, pos.y + radius.y);
        GL11.glVertex2f(pos.x + radius.x, pos.y - radius.y);
        GL11.glEnd();
    }
    
    GL11.glLineWidth(1.0f);
    float color = Main.instance().getFocus() == this ? 0.75f : 1.0f;
    GL11.glColor4f(color, color, 1.0f, alpha);
    font.render(text, pos, size, Alignment.C);
    
    GL11.glBegin(GL11.GL_LINE_LOOP);
    GL11.glVertex2f(pos.x - radius.x, pos.y - radius.y);
    GL11.glVertex2f(pos.x - radius.x, pos.y + radius.y);
    GL11.glVertex2f(pos.x + radius.x, pos.y + radius.y);
    GL11.glVertex2f(pos.x + radius.x, pos.y - radius.y);
    GL11.glEnd();
}
 
Example 23
Project: trashjam2017   File: ImmediateModeOGLRenderer.java   Source Code and License 5 votes vote down vote up
/**
 * @see org.newdawn.slick.opengl.renderer.SGL#enterOrtho(int, int)
 */
public void enterOrtho(int xsize, int ysize) {
	GL11.glMatrixMode(GL11.GL_PROJECTION);
	GL11.glLoadIdentity();
	GL11.glOrtho(0, width, height, 0, 1, -1);
	GL11.glMatrixMode(GL11.GL_MODELVIEW);
	
	GL11.glTranslatef((width-xsize)/2,
					  (height-ysize)/2,0);
}
 
Example 24
Project: candlelight   File: Texture.java   Source Code and License 5 votes vote down vote up
public void update(ByteBuffer pixelBuffer, int width, int height, Bitmap.Format format)
{
	this.bitmap = null;
	this.width = width;
	this.height = height;
	GL11.glTexSubImage2D(GL11.GL_TEXTURE_2D, 0, 0, 0, this.width, this.height, getTextureFormat(format), getTextureBufferType(format), pixelBuffer);
}
 
Example 25
Project: interactionwheel   File: RenderHelper.java   Source Code and License 5 votes vote down vote up
/**
     * Draws a rectangle with a horizontal gradient between the specified colors.
     * x2 and y2 are not included.
     */
    public static void drawHorizontalGradientRect(int x1, int y1, int x2, int y2, int color1, int color2) {
//        this.zLevel = 300.0F;
        float zLevel = 0.0f;

        float f = (color1 >> 24 & 255) / 255.0F;
        float f1 = (color1 >> 16 & 255) / 255.0F;
        float f2 = (color1 >> 8 & 255) / 255.0F;
        float f3 = (color1 & 255) / 255.0F;
        float f4 = (color2 >> 24 & 255) / 255.0F;
        float f5 = (color2 >> 16 & 255) / 255.0F;
        float f6 = (color2 >> 8 & 255) / 255.0F;
        float f7 = (color2 & 255) / 255.0F;
        GlStateManager.disableTexture2D();
        GlStateManager.enableBlend();
        GlStateManager.disableAlpha();
        OpenGlHelper.glBlendFunc(770, 771, 1, 0);
        GlStateManager.shadeModel(GL11.GL_SMOOTH);
        Tessellator tessellator = Tessellator.getInstance();
        VertexBuffer buffer = tessellator.getBuffer();
        buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_COLOR);
        buffer.pos(x1, y1, zLevel).color(f1, f2, f3, f).endVertex();
        buffer.pos(x1, y2, zLevel).color(f1, f2, f3, f).endVertex();
        buffer.pos(x2, y2, zLevel).color(f5, f6, f7, f4).endVertex();
        buffer.pos(x2, y1, zLevel).color(f5, f6, f7, f4).endVertex();
        tessellator.draw();
        GlStateManager.shadeModel(GL11.GL_FLAT);
        GlStateManager.disableBlend();
        GlStateManager.enableAlpha();
        GlStateManager.enableTexture2D();
    }
 
Example 26
Project: BaseClient   File: Draw.java   Source Code and License 5 votes vote down vote up
public static void startClip(float x1, float y1, float x2, float y2) {
    if (y1 > y2) {
        float temp = y2;
        y2 = y1;
        y1 = temp;
    }
    GL11.glEnable((int)3089);
    GL11.glScissor((int)((int)x1), (int)((int)((float)Display.getHeight() - y2)), (int)((int)(x2 - x1)), (int)((int)(y2 - y1)));
}
 
Example 27
Project: BaseClient   File: RenderUtils.java   Source Code and License 5 votes vote down vote up
public static void enableGL2D() {
    GL11.glDisable((int)2929);
    GL11.glEnable((int)3042);
    GL11.glDisable((int)3553);
    GL11.glBlendFunc((int)770, (int)771);
    GL11.glDepthMask((boolean)true);
    GL11.glEnable((int)2848);
    GL11.glHint((int)3154, (int)4354);
    GL11.glHint((int)3155, (int)4354);
}
 
Example 28
Project: BaseClient   File: VboRenderList.java   Source Code and License 5 votes vote down vote up
private void setupArrayPointers()
{
    GL11.glVertexPointer(3, GL11.GL_FLOAT, 28, 0L);
    GL11.glColorPointer(4, GL11.GL_UNSIGNED_BYTE, 28, 12L);
    GL11.glTexCoordPointer(2, GL11.GL_FLOAT, 28, 16L);
    OpenGlHelper.setClientActiveTexture(OpenGlHelper.lightmapTexUnit);
    GL11.glTexCoordPointer(2, GL11.GL_SHORT, 28, 24L);
    OpenGlHelper.setClientActiveTexture(OpenGlHelper.defaultTexUnit);
}
 
Example 29
Project: GlobalXP   File: TileEntityXPBlockRenderer.java   Source Code and License 5 votes vote down vote up
@Override
public void render(TileEntityXPBlock te, double x, double y, double z, float partialTicks, int destroyStage, float alpha)
{
	if(GlobalXP.config.renderNameplate)
	{
		ITextComponent levelsText = new TextComponentString((int)te.getStoredLevels() + " (" + te.getStoredXP() + ")");

		if(te != null && te.getPos() != null && rendererDispatcher.cameraHitResult != null && rendererDispatcher.cameraHitResult.getBlockPos() != null && rendererDispatcher.cameraHitResult.getBlockPos().equals(te.getPos()))
		{
			setLightmapDisabled(true);
			drawNameplate(te, levelsText.getFormattedText(), x, y, z, 12);
			setLightmapDisabled(false);
		}
	}

	double offset = Math.sin((te.getWorld().getTotalWorldTime() + partialTicks) * GlobalXP.config.bobSpeed / 8.0D) / 10.0D;
	IBakedModel model = Minecraft.getMinecraft().getRenderItem().getItemModelWithOverrides(emerald, te.getWorld(), null);

	GlStateManager.enableRescaleNormal();
	GlStateManager.alphaFunc(GL11.GL_GREATER, 0.1F);
	GlStateManager.enableBlend();
	RenderHelper.enableStandardItemLighting();
	GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, 1, 0);
	GlStateManager.pushMatrix();
	GlStateManager.translate(x + 0.5D, y + 0.4D + offset, z + 0.5D);
	GlStateManager.rotate((te.getWorld().getTotalWorldTime() + partialTicks) * 4.0F * (float)GlobalXP.config.spinSpeed, 0.0F, 1.0F, 0.0F);
	model = ForgeHooksClient.handleCameraTransforms(model, TransformType.GROUND, false);
	Minecraft.getMinecraft().getTextureManager().bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
	Minecraft.getMinecraft().getRenderItem().renderItem(emerald, model);
	GlStateManager.popMatrix();
	GlStateManager.disableRescaleNormal();
	GlStateManager.disableBlend();
}
 
Example 30
Project: KraftigAudio   File: Crosshair.java   Source Code and License 5 votes vote down vote up
public void renderCrosshair()
{
    GL11.glLineWidth(1.0f);
    GL11.glColor4f(1.0f, 1.0f, 1.0f, 0.5f);
    GL11.glBegin(GL11.GL_LINES);
    GL11.glVertex2f(-CROSSHAIR_WIDTH, -0.5f);
    GL11.glVertex2f(-CROSSHAIR_INNER_WIDTH, -0.5f);
    GL11.glVertex2f(CROSSHAIR_WIDTH + 1.0f, -0.5f);
    GL11.glVertex2f(CROSSHAIR_INNER_WIDTH + 1.0f, -0.5f);
    GL11.glVertex2f(0.5f, -CROSSHAIR_WIDTH - 1.0f);
    GL11.glVertex2f(0.5f, -CROSSHAIR_INNER_WIDTH - 1.0f);
    GL11.glVertex2f(0.5f, CROSSHAIR_WIDTH);
    GL11.glVertex2f(0.5f, CROSSHAIR_INNER_WIDTH);
    GL11.glEnd();
}
 
Example 31
Project: Wurst-MC-1.12   File: WurstLogo.java   Source Code and License 5 votes vote down vote up
private void drawQuads(int x1, int y1, int x2, int y2)
{
	GL11.glBegin(GL11.GL_QUADS);
	GL11.glVertex2i(x1, y1);
	GL11.glVertex2i(x2, y1);
	GL11.glVertex2i(x2, y2);
	GL11.glVertex2i(x1, y2);
	GL11.glEnd();
}
 
Example 32
Project: BaseClient   File: GlStateManager.java   Source Code and License 5 votes vote down vote up
public static void shadeModel(int mode)
{
    if (mode != activeShadeModel)
    {
        activeShadeModel = mode;
        GL11.glShadeModel(mode);
    }
}
 
Example 33
Project: NanoUI   File: Background.java   Source Code and License 5 votes vote down vote up
@Override
public void render(float alpha) {
	AppUI.clearBuffer(GL11.GL_COLOR_BUFFER_BIT);
	AppUI.clearColors(0f, 0f, 0f, 1);
	window.beingNVGFrame();
	Theme.renderBox(window.getNVGID(), 0, 0, window.getWidth(), window.getHeight(),
			Theme.setColor(1, 1, 1, 1, Theme.colorA), 0, 0, 0, 0);
	Theme.renderImage(window.getNVGID(), 0, 0, window.getWidth(), window.getHeight(), wallpaper, 1);
	window.endNVGFrame();
}
 
Example 34
Project: BaseClient   File: Shaders.java   Source Code and License 5 votes vote down vote up
public static void preWater()
{
    if (usedDepthBuffers >= 2)
    {
        GlStateManager.setActiveTexture(33995);
        checkGLError("pre copy depth");
        GL11.glCopyTexSubImage2D(GL11.GL_TEXTURE_2D, 0, 0, 0, 0, 0, renderWidth, renderHeight);
        checkGLError("copy depth");
        GlStateManager.setActiveTexture(33984);
    }

    ShadersTex.bindNSTextures(defaultTexture.getMultiTexID());
}
 
Example 35
Project: CustomWorldGen   File: GlStateManager.java   Source Code and License 5 votes vote down vote up
private static void setFog(int param)
{
    if (param != fogState.mode)
    {
        fogState.mode = param;
        GL11.glFogi(GL11.GL_FOG_MODE, param);
    }
}
 
Example 36
Project: minecraft-quiverbow   File: Render_FlyingAA.java   Source Code and License 5 votes vote down vote up
@Override
protected void renderEquippedItems(EntityLivingBase entity, float unknown)
   {
	GL11.glColor3f(1.0F, 1.0F, 1.0F);
       super.renderEquippedItems(entity, unknown);
       
       ItemStack itemstack = entity.getHeldItem();	// The weapon you're holding
       
       if (itemstack != null && itemstack.getItem() != null) 
       { 
       	 GL11.glPushMatrix();

            GL11.glTranslatef(-0.0625F, 0.4375F, 0.0625F);

            float scale = 0.625F;

            GL11.glTranslatef(0.3F, 0.2F, -0.25F);		// 0.0F, 0.1875F, 0.0F, left/right, up/down, forward/backward?
            GL11.glScalef(scale, -scale, scale);
            GL11.glRotatef(-20.0F, 1.0F, 0.0F, 0.0F);	// -100
            GL11.glRotatef(45.0F, 0.0F, 1.0F, 0.0F);

            int color = itemstack.getItem().getColorFromItemStack(itemstack, 0);
            float colorR = (float) (color >> 16 & 255) / 255.0F;
            float colorB = (float) (color >> 8 & 255) / 255.0F;
            float colorG = (float) (color & 255) / 255.0F;
            GL11.glColor4f(colorR, colorB, colorG, 1.0F);
           
            this.renderManager.itemRenderer.renderItem(entity, itemstack, 0);

            GL11.glPopMatrix();
       }
       
       this.renderStoredItems((Entity_BB) entity);
   }
 
Example 37
Project: EndermanEvolution   File: ModelSkullBase.java   Source Code and License 5 votes vote down vote up
public void renderLightMapOnPlayerHead(World world, EntityLivingBase wearer) {
	GlStateManager.pushMatrix();
	GlStateManager.enableBlend();
	GlStateManager.blendFunc(GL11.GL_ONE, GL11.GL_ONE);
	GlStateManager.depthMask(true);
	float brightnessX = OpenGlHelper.lastBrightnessX;
	float brightnessY = OpenGlHelper.lastBrightnessY;
	OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 61680, 0);
	head.render(0.01F);
	OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, brightnessX, brightnessY);
	GlStateManager.disableBlend();
	GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
	GlStateManager.popMatrix();
}
 
Example 38
Project: interactionwheel   File: RenderHelper.java   Source Code and License 5 votes vote down vote up
/**
 * Draw with the WorldRenderer
 */
private static void draw(VertexBuffer renderer, int x, int y, int width, int height, int red, int green, int blue, int alpha) {
    renderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_COLOR);
    renderer.pos((x + 0), (y + 0), 0.0D).color(red, green, blue, alpha).endVertex();
    renderer.pos((x + 0), (y + height), 0.0D).color(red, green, blue, alpha).endVertex();
    renderer.pos((x + width), (y + height), 0.0D).color(red, green, blue, alpha).endVertex();
    renderer.pos((x + width), (y + 0), 0.0D).color(red, green, blue, alpha).endVertex();
    Tessellator.getInstance().draw();
}
 
Example 39
Project: LowPolyWater   File: TextureAttachment.java   Source Code and License 5 votes vote down vote up
private void indicateStorageType(int width, int height){
	if(isDepthAttachment()){
		GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, format, width, height, 0, GL11.GL_DEPTH_COMPONENT, GL11.GL_FLOAT, (ByteBuffer) null);
	}else{
		GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, format, width, height, 0, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, (ByteBuffer) null);
	}
}
 
Example 40
Project: BaseClient   File: TextureUtil.java   Source Code and License 5 votes vote down vote up
private static void setTextureClamped(boolean p_110997_0_)
{
    if (p_110997_0_)
    {
        GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL12.GL_CLAMP_TO_EDGE);
        GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL12.GL_CLAMP_TO_EDGE);
    }
    else
    {
        GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL11.GL_REPEAT);
        GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL11.GL_REPEAT);
    }
}
 
Example 41
Project: EcoSystem-Official   File: OpenGlUtils.java   Source Code and License 5 votes vote down vote up
public static void cullBackFaces(boolean cull) {
    if (cull && !cullingBackFace) {
        GL11.glEnable(GL11.GL_CULL_FACE);
        GL11.glCullFace(GL11.GL_BACK);
        cullingBackFace = true;
    } else if (!cull && cullingBackFace) {
        GL11.glDisable(GL11.GL_CULL_FACE);
        cullingBackFace = false;
    }
}
 
Example 42
Project: BaseClient   File: TextureUtil.java   Source Code and License 5 votes vote down vote up
private static void setTextureBlurMipmap(boolean p_147954_0_, boolean p_147954_1_)
{
    if (p_147954_0_)
    {
        GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, p_147954_1_ ? GL11.GL_LINEAR_MIPMAP_LINEAR : GL11.GL_LINEAR);
        GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR);
    }
    else
    {
        int i = Config.getMipmapType();
        GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, p_147954_1_ ? i : GL11.GL_NEAREST);
        GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST);
    }
}
 
Example 43
Project: ExtraAcC   File: RenderWindBlade.java   Source Code and License 5 votes vote down vote up
public void doRender(Entity entity, double x, double y, double z, float p_76986_8_, float p_76986_9_) {
if (!(entity instanceof EntityWindBlade)) {
	return;
}
this.bindEntityTexture(entity);
GL11.glPushMatrix();
      GL11.glTranslated(x, y, z);
      //原点移到实体中心
      GL11.glRotatef(entity.rotationYaw - 90.0F, 0.0F, 1.0F, 0.0F);
      GL11.glRotatef(entity.rotationPitch, 0.0F, 0.0F, 1.0F);
      
      Tessellator tessellator = Tessellator.instance;
      GL11.glEnable(GL12.GL_RESCALE_NORMAL);

      GL11.glScalef(1, 0.1f, 1);
      for (int i = 0; i < 180; ++i)
      {
          GL11.glRotatef(1F, 1.0F, 0.0F, 0.0F);
          //GL11.glNormal3f(0.0F, 0.0F, f10);
          tessellator.startDrawingQuads();
          tessellator.addVertexWithUV(-1D, -1D, 0.0D, 0, 1); // 左下
          tessellator.addVertexWithUV( 1D, -1D, 0.0D, 0, 0); // 左上
          tessellator.addVertexWithUV( 1D,  1D, 0.0D, 1, 0); // 右上
          tessellator.addVertexWithUV(-1D,  1D, 0.0D, 1, 1); // 右下
          tessellator.draw();
      }

      GL11.glDisable(GL12.GL_RESCALE_NORMAL);
      GL11.glPopMatrix();
  }
 
Example 44
Project: Lector   File: RenderHelper.java   Source Code and License 5 votes vote down vote up
private static void renderItemStackInWorld(Vec3d offset, boolean selected, boolean crafting, ItemStack ghosted, ItemStack stack, float scale) {
    scale *= .6f;
    if (ItemStackTools.isValid(ghosted)) {
        stack = ghosted;
    }
    if (ItemStackTools.isValid(stack)) {
        net.minecraft.client.renderer.RenderHelper.enableStandardItemLighting();
        GlStateManager.translate(offset.xCoord, offset.yCoord, offset.zCoord);

        boolean ghostly = ItemStackTools.isValid(ghosted) || crafting;
        if (ghostly) {
            GlStateManager.enableBlend();
            GlStateManager.blendFunc(GL11.GL_ONE, GL11.GL_ONE);
        }
        renderItemCustom(stack, 0, 0.3f * scale, !ghostly);
        if (selected && ItemStackTools.isEmpty(ghosted)) {
            GlStateManager.enableBlend();
            GlStateManager.blendFunc(GL11.GL_ONE, GL11.GL_ONE);
            GlStateManager.depthFunc(GL11.GL_EQUAL);
            renderItemCustom(stack, 0, 0.3f * scale, false);
            GlStateManager.depthFunc(GL11.GL_LEQUAL);
            GlStateManager.disableBlend();
        }
        if (ghostly) {
            GlStateManager.disableBlend();
        }

        GlStateManager.translate(-offset.xCoord, -offset.yCoord, -offset.zCoord);
    }
}
 
Example 45
Project: bit-client   File: RenderUtil.java   Source Code and License 5 votes vote down vote up
public static void drawLine2D(double x1, double y1, double x2, double y2, float width, int color) {
    enableRender2D();
    glColor(color);
    GL11.glLineWidth(width);
    GL11.glBegin(1);
    GL11.glVertex2d(x1, y1);
    GL11.glVertex2d(x2, y2);
    GL11.glEnd();
    disableRender2D();
}
 
Example 46
Project: ModularMachinery   File: BlockArrayPreviewRenderHelper.java   Source Code and License 5 votes vote down vote up
void renderTranslucentBlocks() {
    Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
    GlStateManager.pushMatrix();

    float partialTicks = Minecraft.getMinecraft().getRenderPartialTicks();
    Entity rView = Minecraft.getMinecraft().getRenderViewEntity();
    if(rView == null) rView = Minecraft.getMinecraft().player;
    Entity entity = rView;
    double tx = entity.lastTickPosX + ((entity.posX - entity.lastTickPosX) * partialTicks);
    double ty = entity.lastTickPosY + ((entity.posY - entity.lastTickPosY) * partialTicks);
    double tz = entity.lastTickPosZ + ((entity.posZ - entity.lastTickPosZ) * partialTicks);
    GlStateManager.translate(-tx, -ty, -tz);

    GlStateManager.color(1F, 1F, 1F, 1F);

    if(batchDList == -1) {
        batchBlocks();
        hash = hashBlocks();
    } else {
        int currentHash = hashBlocks();
        if(hash != currentHash) {
            GLAllocation.deleteDisplayLists(batchDList);
            batchBlocks();
            hash = currentHash;
        }
    }
    GlStateManager.enableBlend();
    Blending.ALPHA.applyStateManager();
    GlStateManager.callList(batchDList);
    Blending.DEFAULT.applyStateManager();
    GlStateManager.popMatrix();

    //Color desync on block rendering - prevent that, resync
    GlStateManager.color(1F, 1F, 1F, 1F);
    GL11.glColor4f(1F, 1F, 1F, 1F);
}
 
Example 47
Project: pnc-repressurized   File: ModuleRegulatorTube.java   Source Code and License 5 votes vote down vote up
@SideOnly(Side.CLIENT)
private void renderPreview() {
    if (!hasTicked) {
        TileEntityPneumaticBase tile = (TileEntityPneumaticBase) getTube();
        NetworkHandler.sendToServer(new PacketDescriptionPacketRequest(tile.getPos()));
        TileEntity neighbor = tile.getWorld().getTileEntity(tile.getPos().offset(dir));
        inLine = neighbor instanceof IPneumaticMachine;
        if (inLine) {
            IAirHandler neighborHandler = ((IPneumaticMachine) neighbor).getAirHandler(dir);
            inverted = neighborHandler != null && neighborHandler.getPressure() > tile.getAirHandler(null).getPressure();
            NetworkHandler.sendToServer(new PacketDescriptionPacketRequest(neighbor.getPos()));
        }
        hasTicked = true;
    }

    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    if (inLine && !inverted) {
        GL11.glColor4d(0, 1, 0, 0.3);
    } else {
        GL11.glColor4d(1, 0, 0, 0.3);
    }
    GL11.glPushMatrix();
    GL11.glTranslated(0, 1, 0.2 + ClientTickHandler.TICKS % 20 * 0.015);
    GL11.glRotated(90, 1, 0, 0);

    RenderUtils.render3DArrow();
    GL11.glColor4d(1, 1, 1, 0.5);  // 0.5 because we're rendering a preview
    GL11.glPopMatrix();
    GL11.glDisable(GL11.GL_BLEND);
}
 
Example 48
Project: pnc-repressurized   File: GuiThermopneumaticProcessingPlant.java   Source Code and License 5 votes vote down vote up
@Override
protected void drawGuiContainerForegroundLayer(int x, int y) {
    fontRenderer.drawString(I18n.format("gui.tab.upgrades"), 91, 83, 4210752);
    String containerName = I18n.format(te.getName() + ".name");
    GL11.glPushMatrix();
    GL11.glScaled(0.95, 0.97, 1);
    fontRenderer.drawString(containerName, xSize / 2 - fontRenderer.getStringWidth(containerName) / 2 + 1, 5, 4210752);
    GL11.glPopMatrix();
    super.drawGuiContainerForegroundLayer(x, y);

}
 
Example 49
Project: MRCEngine   File: ShaderProgram.java   Source Code and License 5 votes vote down vote up
private static int loadShader(String filename, int type) {
	
	StringBuilder shaderSource = new StringBuilder();
	
	try {
		BufferedReader reader = new BufferedReader(new FileReader(filename));
		String line;
		while((line = reader.readLine()) != null) {
			shaderSource.append(line).append("\n");
		}
		reader.close();
	} catch (IOException e) {
		System.err.println("Could not read shader file!");
		e.printStackTrace();
		System.exit(-1);
	}
	
	int shaderID = GL20.glCreateShader(type);
	GL20.glShaderSource(shaderID, shaderSource);
	GL20.glCompileShader(shaderID);
	
	if(GL20.glGetShader(shaderID, GL20.GL_COMPILE_STATUS) == GL11.GL_FALSE) {
		System.out.println(GL20.glGetShaderInfoLog(shaderID, 500));
		System.err.println("Could not compile shader!");
		System.exit(-1);
	}
	
	return shaderID;
}
 
Example 50
Project: Technical   File: GuiElectricFurnace.java   Source Code and License 5 votes vote down vote up
public void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) {
	GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
	this.mc.getTextureManager().bindTexture(machineGuiTextures);
	int k = (this.width - this.xSize) / 2;
	int l = (this.height - this.ySize) / 2;
	this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize);

	if (this.tileEntity.isBurning()) {
		int i = this.tileEntity.getBurnTimeRemainingScaled(13);
		this.drawTexturedModalRect(k + 56, l + 36 + 12 - i, 176, 12 - i, 14, i + 1);
		i = this.tileEntity.getCookProgressScaled(24);
		this.drawTexturedModalRect(k + 79, l + 34, 176, 14, i + 1, 16);
	}
}
 
Example 51
Project: Never-Enough-Currency   File: GuiWallet.java   Source Code and License 5 votes vote down vote up
/**
 * This renders the player model in standard inventory position (in later
 * versions of Minecraft / Forge, you can simply call
 * GuiInventory.drawEntityOnScreen directly instead of copying this code)
 */
public static void drawPlayerModel(int x, int y, int scale, float yaw, float pitch, EntityLivingBase entity) {
	GL11.glEnable(GL11.GL_COLOR_MATERIAL);
	GL11.glPushMatrix();
	GL11.glTranslatef(x, y, 50.0F);
	GL11.glScalef(-scale, scale, scale);
	GL11.glRotatef(180.0F, 0.0F, 0.0F, 1.0F);
	float f2 = entity.renderYawOffset;
	float f3 = entity.rotationYaw;
	float f4 = entity.rotationPitch;
	float f5 = entity.prevRotationYawHead;
	float f6 = entity.rotationYawHead;
	GL11.glRotatef(135.0F, 0.0F, 1.0F, 0.0F);
	RenderHelper.enableStandardItemLighting();
	GL11.glRotatef(-135.0F, 0.0F, 1.0F, 0.0F);
	GL11.glRotatef(-((float) Math.atan(pitch / 40.0F)) * 20.0F, 1.0F, 0.0F, 0.0F);
	entity.renderYawOffset = (float) Math.atan(yaw / 40.0F) * 20.0F;
	entity.rotationYaw = (float) Math.atan(yaw / 40.0F) * 40.0F;
	entity.rotationPitch = -((float) Math.atan(pitch / 40.0F)) * 20.0F;
	entity.rotationYawHead = entity.rotationYaw;
	entity.prevRotationYawHead = entity.rotationYaw;
	Minecraft.getMinecraft().getRenderManager().playerViewY = 180.0F;
	Minecraft.getMinecraft().getRenderManager().setRenderShadow(false);
	Minecraft.getMinecraft().getRenderManager().renderEntity(entity, 0.0D, 0.0D, 0.0D, 0.0F, 1.0F, false);
	Minecraft.getMinecraft().getRenderManager().setRenderShadow(true);
	entity.renderYawOffset = f2;
	entity.rotationYaw = f3;
	entity.rotationPitch = f4;
	entity.prevRotationYawHead = f5;
	entity.rotationYawHead = f6;
	GL11.glPopMatrix();
	RenderHelper.disableStandardItemLighting();
	GL11.glDisable(GL12.GL_RESCALE_NORMAL);
	OpenGlHelper.setActiveTexture(OpenGlHelper.lightmapTexUnit);
	GL11.glDisable(GL11.GL_TEXTURE_2D);
	OpenGlHelper.setActiveTexture(OpenGlHelper.defaultTexUnit);
}
 
Example 52
Project: OcclusionQueries   File: WaterFrameBuffers.java   Source Code and License 5 votes vote down vote up
private int createTextureAttachment( int width, int height) {
	int texture = GL11.glGenTextures();
	GL11.glBindTexture(GL11.GL_TEXTURE_2D, texture);
	GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGB, width, height,
			0, GL11.GL_RGB, GL11.GL_UNSIGNED_BYTE, (ByteBuffer) null);
	GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR);
	GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR);
	GL32.glFramebufferTexture(GL30.GL_FRAMEBUFFER, GL30.GL_COLOR_ATTACHMENT0,
			texture, 0);
	return texture;
}
 
Example 53
Project: Wurst-MC-1.12   File: ClickGui.java   Source Code and License 5 votes vote down vote up
private void renderTitleBarButton(int x1, int y1, int x2, int y2,
	boolean hovering)
{
	int x3 = x2 + 2;
	
	// button background
	GL11.glColor4f(bgColor[0], bgColor[1], bgColor[2],
		hovering ? 0.75F : 0.5F);
	GL11.glBegin(GL11.GL_QUADS);
	GL11.glVertex2i(x1, y1);
	GL11.glVertex2i(x1, y2);
	GL11.glVertex2i(x2, y2);
	GL11.glVertex2i(x2, y1);
	GL11.glEnd();
	
	// background between buttons
	GL11.glColor4f(acColor[0], acColor[1], acColor[2], 0.5F);
	GL11.glBegin(GL11.GL_QUADS);
	GL11.glVertex2i(x2, y1);
	GL11.glVertex2i(x2, y2);
	GL11.glVertex2i(x3, y2);
	GL11.glVertex2i(x3, y1);
	GL11.glEnd();
	
	// button outline
	GL11.glBegin(GL11.GL_LINE_LOOP);
	GL11.glVertex2i(x1, y1);
	GL11.glVertex2i(x1, y2);
	GL11.glVertex2i(x2, y2);
	GL11.glVertex2i(x2, y1);
	GL11.glEnd();
}
 
Example 54
Project: Solar   File: RenderHelper.java   Source Code and License 5 votes vote down vote up
public static void drawCube(int color, float alpha) {
	float r = (color >> 16 & 255) / 255.0F;
	float g = (color >> 8 & 255) / 255.0F;
	float b = (color & 255) / 255.0F;

	GlStateManager.color(r, g, b, alpha);
	GL11.glCallList(cube);
}
 
Example 55
Project: SerenityCE   File: GLUProjectionUpdater.java   Source Code and License 5 votes vote down vote up
@Override
public void call(RenderWorld event) {
    GL11.glGetFloat(GL11.GL_MODELVIEW_MATRIX, MODELVIEW_BUFFER);
    GL11.glGetFloat(GL11.GL_PROJECTION_MATRIX, PROJECTION_BUFFER);
    GL11.glGetInteger(GL11.GL_VIEWPORT, VIEWPORT_BUFFER);

    ScaledResolution scaledResolution = new ScaledResolution(mc, mc.displayWidth, mc.displayHeight);
    GLUProjection.getInstance().updateMatrices(VIEWPORT_BUFFER, MODELVIEW_BUFFER, PROJECTION_BUFFER,
            scaledResolution.getScaledWidth() / (double) mc.displayWidth,
            scaledResolution.getScaledHeight() / (double) mc.displayHeight);
}
 
Example 56
Project: BaseClient   File: GuiMainMenu.java   Source Code and License 5 votes vote down vote up
/**
 * Rotate and blurs the skybox view in the main menu
 */
private void rotateAndBlurSkybox(float p_73968_1_)
{
    this.mc.getTextureManager().bindTexture(this.backgroundTexture);
    GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR);
    GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR);
    GL11.glCopyTexSubImage2D(GL11.GL_TEXTURE_2D, 0, 0, 0, 0, 0, 256, 256);
    GlStateManager.enableBlend();
    GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
    GlStateManager.colorMask(true, true, true, false);
    Tessellator tessellator = Tessellator.getInstance();
    WorldRenderer worldrenderer = tessellator.getWorldRenderer();
    worldrenderer.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR);
    GlStateManager.disableAlpha();
    int i = 3;

    for (int j = 0; j < i; ++j)
    {
        float f = 1.0F / (float)(j + 1);
        int k = this.width;
        int l = this.height;
        float f1 = (float)(j - i / 2) / 256.0F;
        worldrenderer.pos((double)k, (double)l, (double)this.zLevel).tex((double)(0.0F + f1), 1.0D).color(1.0F, 1.0F, 1.0F, f).endVertex();
        worldrenderer.pos((double)k, 0.0D, (double)this.zLevel).tex((double)(1.0F + f1), 1.0D).color(1.0F, 1.0F, 1.0F, f).endVertex();
        worldrenderer.pos(0.0D, 0.0D, (double)this.zLevel).tex((double)(1.0F + f1), 0.0D).color(1.0F, 1.0F, 1.0F, f).endVertex();
        worldrenderer.pos(0.0D, (double)l, (double)this.zLevel).tex((double)(0.0F + f1), 0.0D).color(1.0F, 1.0F, 1.0F, f).endVertex();
    }

    tessellator.draw();
    GlStateManager.enableAlpha();
    GlStateManager.colorMask(true, true, true, true);
}
 
Example 57
Project: ObsidianSuite   File: GuiEntityRendererWithTranslation.java   Source Code and License 4 votes vote down vote up
@Override
public void processRay()
{
	if(selectedPart != null)
	{
		GL11.glPushMatrix();

		if(selectedPart instanceof PartRotation)
		{
			GL11.glPopMatrix();
			super.processRay();
			return;
		} else if (selectedPart instanceof PartPropTranslation || selectedPart instanceof PartPropScale)
		{
			EnumHandSide handSide = selectedPart.getName().equals("prop_trans") || selectedPart.getName().equals("prop_scale") ? EnumHandSide.RIGHT : EnumHandSide.LEFT;
			ModelHandler.modelRenderer.transformToHand(handSide);
		}


		drawTranslationAxis();

		translationAxisMouseOver = false;
		if(!translationAxisDrag)
		{
			updateAxisMouseOver();
			//If it isn't being moused over, hand over ray processing to GuiEntityRenderer, which will test for hovering over parts.
			if(!translationAxisMouseOver)
			{
				GL11.glPopMatrix();
				super.processRay();
				return;
			}
			//If it is being hovered over, ensure there is no part highlighted for selection.
			else
				hoveredPart = null;
		}
		else
			onControllerDrag();

		GL11.glPopMatrix();
	}
	else
		super.processRay();
}
 
Example 58
Project: trashjam2017   File: ImmediateModeOGLRenderer.java   Source Code and License 4 votes vote down vote up
/**
 * @see org.newdawn.slick.opengl.renderer.SGL#glBindTexture(int, int)
 */
public void glBindTexture(int target, int id) {
	GL11.glBindTexture(target, id);
}
 
Example 59
Project: trashjam2017   File: ImmediateModeOGLRenderer.java   Source Code and License 4 votes vote down vote up
/**
 * @see org.newdawn.slick.opengl.renderer.SGL#glBlendFunc(int, int)
 */
public void glBlendFunc(int src, int dest) {
	GL11.glBlendFunc(src, dest);
}
 
Example 60
Project: betaexpansion   File: FontRenderer.java   Source Code and License 4 votes vote down vote up
public void renderString_do(String s, int i, int j, int k, boolean flag)
{
	if(s == null)
    {
        return;
    }
    if(flag)
    {
        int l = k & 0xff000000;
        k = (k & 0xfcfcfc) >> 2;
        k += l;
    }
    GL11.glBindTexture(3553 /*GL_TEXTURE_2D*/, fontTextureName);
    float f = (float)(k >> 16 & 0xff) / 255F;
    float f1 = (float)(k >> 8 & 0xff) / 255F;
    float f2 = (float)(k & 0xff) / 255F;
    float f3 = (float)(k >> 24 & 0xff) / 255F;
    if(f3 == 0.0F)
    {
        f3 = 1.0F;
    }
    GL11.glColor4f(f, f1, f2, f3);
    buffer.clear();
    GL11.glPushMatrix();
    GL11.glTranslatef(i, j, 0.0F);
    for(int i1 = 0; i1 < s.length(); i1++)
    {
    	if(s.charAt(i1) == '\247' && s.length() > i1 + 1)
    	{
    		buffer.flip();
    		GL11.glCallLists(buffer);
    		buffer.clear();
            int j1 = "0123456789abcdef".indexOf(s.toLowerCase().charAt(i1 + 1));
            if(j1 < 0 || j1 > 15)
            {
                j1 = 15;
            }
            GL11.glColor4f(f*color[j1][0], f1*color[j1][1], f2*color[j1][2], f3);
    		i1+=1;
    		continue;
    	}
        buffer.flip();
        GL11.glCallLists(buffer);
        buffer.clear();
        if(i1 < s.length())
        {
            int k1 = ChatAllowedCharacters.allowedCharacters.indexOf(s.charAt(i1));
            if(k1 >= 0)
            {
                buffer.put(fontDisplayLists + k1 + 32);
            }
        }
        if(buffer.remaining() == 0)
        {
            buffer.flip();
            GL11.glCallLists(buffer);
            buffer.clear();
        }
    }

    buffer.flip();
    GL11.glCallLists(buffer);
    GL11.glPopMatrix();	
}