Example usage for org.lwjgl.opengl GL11 glScalef

List of usage examples for org.lwjgl.opengl GL11 glScalef

Introduction

In this page you can find the example usage for org.lwjgl.opengl GL11 glScalef.

Prototype

public static native void glScalef(@NativeType("GLfloat") float x, @NativeType("GLfloat") float y,
        @NativeType("GLfloat") float z);

Source Link

Document

Manipulates the current matrix with a general scaling matrix along the x-, y- and z- axes.

Usage

From source file:net.lyonlancer5.mcmp.karasu.client.renderer.entity.RenderRabbit.java

License:Apache License

@Override
protected void preRenderCallback(EntityLivingBase entityliving, float patialTickTime) {
    GL11.glScalef(0.65F, 0.65F, 0.65F);
}

From source file:net.lyonlancer5.mcmp.karasu.client.renderer.model.ModelRabbit.java

License:Apache License

@Override
public void render(Entity entityIn, float p_78088_2_, float p_78088_3_, float p_78088_4_, float p_78088_5_,
        float p_78088_6_, float scale) {
    setRotationAngles(p_78088_2_, p_78088_3_, p_78088_4_, p_78088_5_, p_78088_6_, scale, entityIn);

    if (isChild) {
        float f6 = 2.0F;
        GL11.glPushMatrix();//from w  w w  . j  a v  a 2 s.  c  o  m
        GL11.glTranslatef(0.0F, 5.0F * scale, 2.0F * scale);
        rabbitHead.render(scale);
        rabbitLeftEar.render(scale);
        rabbitRightEar.render(scale);
        rabbitNose.render(scale);
        GL11.glPopMatrix();
        GL11.glPushMatrix();
        GL11.glScalef(1.0F / f6, 1.0F / f6, 1.0F / f6);
        GL11.glTranslatef(0.0F, 24.0F * scale, 0.0F);
        rabbitLeftFoot.render(scale);
        rabbitRightFoot.render(scale);
        rabbitLeftThigh.render(scale);
        rabbitRightThigh.render(scale);
        rabbitBody.render(scale);
        rabbitLeftArm.render(scale);
        rabbitRightArm.render(scale);
        rabbitTail.render(scale);
        GL11.glPopMatrix();
    } else {
        rabbitLeftFoot.render(scale);
        rabbitRightFoot.render(scale);
        rabbitLeftThigh.render(scale);
        rabbitRightThigh.render(scale);
        rabbitBody.render(scale);
        rabbitLeftArm.render(scale);
        rabbitRightArm.render(scale);
        rabbitHead.render(scale);
        rabbitRightEar.render(scale);
        rabbitLeftEar.render(scale);
        rabbitTail.render(scale);
        rabbitNose.render(scale);
    }
}

From source file:net.malisis.core.client.gui.GuiRenderer.java

License:Open Source License

@Override
public void prepare(RenderType renderType, double... data) {
    _initialize();/*from   w  w  w.  j  a  v a2s .  co  m*/
    this.renderType = renderType;

    currentTexture = null;
    bindDefaultTexture();

    if (ignoreScale) {
        GL11.glPushMatrix();
        GL11.glScalef(1F / scaleFactor, 1F / scaleFactor, 1);
    }

    enableBlending();

    startDrawing();
}

From source file:net.malisis.core.client.gui.GuiRenderer.java

License:Open Source License

/**
 * Draws a string at the specified coordinates, with color and shadow. The string gets translated. Uses FontRenderer.drawString().
 *
 * @param text the text//w  w  w  . j  a  v  a2s.  c  o m
 * @param x the x
 * @param y the y
 * @param z the z
 * @param color the color
 * @param shadow the shadow
 */
public void drawString(String text, int x, int y, int z, int color, boolean shadow) {
    if (MalisisRenderer.getFontRenderer() == null)
        return;

    text = StatCollector.translateToLocal(text);
    text = text.replaceAll("\r", "");
    GL11.glPushMatrix();
    GL11.glTranslatef(x * (1 - fontScale), y * (1 - fontScale), 0);
    GL11.glScalef(fontScale, fontScale, 1);
    GL11.glTranslatef(0, 0, z);
    // GL11.glDisable(GL11.GL_DEPTH_TEST);
    GL11.glDisable(GL12.GL_RESCALE_NORMAL);

    MalisisRenderer.getFontRenderer().drawString(text, x, y, color, shadow);

    GL11.glPopMatrix();
    GL11.glEnable(GL12.GL_RESCALE_NORMAL);
    // GL11.glEnable(GL11.GL_DEPTH_TEST);
    currentTexture = null;
    bindDefaultTexture();
}

From source file:net.malisis.core.renderer.MalisisRenderer.java

License:Open Source License

/**
 * Draws a string at the specified coordinates, with color and shadow. The string gets translated. Uses FontRenderer.drawString().
 *
 * @param text the text/*from  ww  w  .  ja v  a 2  s.c o m*/
 * @param x the x
 * @param y the y
 * @param z the z
 * @param color the color
 * @param shadow the shadow
 */
public void drawString(String text, float x, float y, float z, int color, boolean shadow) {
    if (MalisisRenderer.getFontRenderer() == null)
        return;

    text = StatCollector.translateToLocal(text);
    text = text.replaceAll("\r", "");
    GL11.glPushMatrix();
    float s = 0.010F;
    GL11.glTranslatef(x, y, z);
    GL11.glScalef(s, -s, s);

    // GL11.glDisable(GL11.GL_DEPTH_TEST);
    GL11.glDisable(GL12.GL_RESCALE_NORMAL);

    getFontRenderer().drawString(text, 0, 0, color, shadow);

    GL11.glPopMatrix();
    GL11.glEnable(GL12.GL_RESCALE_NORMAL);
    // GL11.glEnable(GL11.GL_DEPTH_TEST);
}

From source file:net.malisis.doors.renderer.VanishingBlockRenderer.java

License:Open Source License

private void renderVanishingTileEntity() {
    VanishingTileEntity te = (VanishingTileEntity) this.tileEntity;

    if (!te.inTransition && !te.vibrating) {
        if (!te.powered && te.copiedTileEntity != null) {
            clean();//  w w  w  .  j  a v  a2 s  . c  om
            TileEntityRendererDispatcher.instance.renderTileEntity(te.copiedTileEntity, partialTick);
        }
        return;
    }

    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GL11.glAlphaFunc(GL11.GL_GREATER, 0);

    float fx = 0.0F;
    float fy = 0.0F;
    float fz = 0.0F;
    float scale = (float) (te.getDuration() - te.transitionTimer) / (float) te.getDuration();
    boolean rendered = te.copiedBlock != null;

    RenderParameters rp = new RenderParameters();
    rp.useBlockBounds.set(false);
    rp.interpolateUV.set(false);

    Shape shape = ShapePreset.Cube();
    // randomize position for vibrations
    if (!te.inTransition && !te.powered) {
        rp.alpha.set(200);
        fx = rand.nextFloat() * 0.05F;
        fy = rand.nextFloat() * 0.05F;
        fz = rand.nextFloat() * 0.05F;
        if (rand.nextBoolean())
            GL11.glTranslated(fx, fy, fz);
        else
            GL11.glRotatef(rand.nextInt(5), 1, 1, 1);
    } else {
        int alpha = te.copiedBlock != null ? 255 - (int) (scale * 255) : (int) (scale * 255);
        rp.alpha.set(alpha);
        shape.scale(scale - 0.001F);
    }

    if (te.copiedBlock != null) {
        RenderBlocks renderBlocks = new RenderBlocks(ProxyAccess.get(world));
        renderBlocks.renderAllFaces = true;
        try {
            boolean smbr = MalisisDoorsSettings.simpleMixedBlockRendering.get();
            MalisisDoorsSettings.simpleMixedBlockRendering.set(true);

            GL11.glPushMatrix();
            GL11.glTranslated(0.5F, 0.5F, 0.5F);
            GL11.glScalef(scale, scale, scale);
            GL11.glTranslated(-x - 0.5F, -y - 0.5F, -z - 0.5F);

            GL11.glBlendFunc(GL11.GL_CONSTANT_ALPHA, GL11.GL_ONE_MINUS_CONSTANT_ALPHA);
            GL14.glBlendColor(0, 0, 0, 1 - scale);
            renderBlocks.overrideBlockTexture = block.getIcon(blockMetadata, 0);
            rendered = renderBlocks.renderBlockByRenderType(te.copiedBlock, x, y, z);
            renderBlocks.overrideBlockTexture = null;
            next();

            if (te.copiedBlock.canRenderInPass(0)) {
                GL14.glBlendColor(0, 0, 0, scale);
                rendered |= renderBlocks.renderBlockByRenderType(te.copiedBlock, x, y, z);
                next();
            }
            if (te.copiedBlock.canRenderInPass(1)) {
                GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
                rendered |= renderBlocks.renderBlockByRenderType(te.copiedBlock, x, y, z);
                next();
            }

            if (!rendered)
                drawShape(shape, rp);

            GL11.glPopMatrix();

            if (te.copiedTileEntity != null) {
                clean();
                TileEntityRendererDispatcher.instance.renderTileEntity(te.copiedTileEntity, partialTick);
            }

            MalisisDoorsSettings.simpleMixedBlockRendering.set(smbr);

        } catch (Exception e) {
            drawShape(shape, rp);
        }

    } else
        drawShape(shape, rp);
}

From source file:net.mcmoddev.client.renderer.RenderBlockExtended.java

License:Open Source License

@Override
public void renderTileEntityAt(TileEntity tileEntity, double d, double d1, double d2, float f) {
    if (!(tileEntity instanceof TileEntityBlockExtended))
        return;//from   ww  w . j ava2  s .  c om

    TileEntityBlockExtended ext = (TileEntityBlockExtended) tileEntity;

    IModelBlockExtended model = _defaultModel;

    if (ext.getExtendedMeta() != -1
            && ((BlockExtended) tileEntity.getBlockType()).getBlockMeta(ext.getExtendedMeta()) != null)
        model = ((BlockExtended) tileEntity.getBlockType()).getBlockMeta(ext.getExtendedMeta()).getModelBlock();

    if (ext.getWorldObj() != null) {
        GL11.glPushMatrix();
        GL11.glTranslatef((float) d + 0.5F, (float) d1 + 1.5F, (float) d2 + 0.5F);
        GL11.glRotatef(0, 0.0F, 1.0F, 0.0F);
        GL11.glScalef(1.0F, -1F, -1F);
        GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
        GL11.glEnable(GL11.GL_BLEND);
        model.renderModel(this, ext, 0.0625F);
        GL11.glDisable(GL11.GL_BLEND);
        GL11.glPopMatrix();
    } else {
        GL11.glPushMatrix();
        GL11.glTranslatef((float) d + 0.5F, (float) d1 + 1.4F, (float) d2 + 0.5F);
        GL11.glRotatef(0, 0.0F, 1.0F, 0.0F);
        GL11.glScalef(1.0F, -1F, -1F);
        GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
        GL11.glEnable(GL11.GL_BLEND);
        model.renderModel(this, ext, 0.0625F);
        GL11.glDisable(GL11.GL_BLEND);
        GL11.glPopMatrix();
    }
}

From source file:net.minecraft.src.buildcraft.transport.RenderPipe.java

License:Minecraft Mod Public

public void doRenderItem(EntityPassiveItem entityitem, double d, double d1, double d2, float f1) {

    if (entityitem == null || entityitem.item == null)
        return;/*from  w  ww. j av a2  s .  co  m*/

    ItemStack itemstack = entityitem.item;
    random.setSeed(187L);

    GL11.glPushMatrix();

    byte quantity = 1;
    if (entityitem.item.stackSize > 1)
        quantity = 2;
    if (entityitem.item.stackSize > 5)
        quantity = 3;
    if (entityitem.item.stackSize > 20)
        quantity = 4;

    GL11.glTranslatef((float) d, (float) d1, (float) d2);
    GL11.glEnable(32826 /* GL_RESCALE_NORMAL_EXT */);

    IItemRenderer customRenderer = MinecraftForgeClient.getItemRenderer(itemstack, ItemRenderType.ENTITY);

    if (customRenderer != null) {

        GL11.glTranslatef(0, 0.25F, 0); // BC SPECIFIC
        loadTexture("/terrain.png");
        ForgeHooksClient.overrideTexture(itemstack.getItem());
        float f4 = 0.25F;
        f4 = 0.5F;
        GL11.glScalef(f4, f4, f4);

        for (int j = 0; j < quantity; j++) {

            GL11.glPushMatrix();

            if (j > 0) {
                float f5 = ((random.nextFloat() * 2.0F - 1.0F) * 0.2F) / f4;
                float f7 = ((random.nextFloat() * 2.0F - 1.0F) * 0.2F) / f4;
                float f9 = ((random.nextFloat() * 2.0F - 1.0F) * 0.2F) / f4;
                GL11.glTranslatef(f5, f7, f9);
            }

            RenderPipe.dummyEntityItem.item = itemstack;

            customRenderer.renderItem(ItemRenderType.ENTITY, itemstack, renderBlocks,
                    RenderPipe.dummyEntityItem);
            GL11.glPopMatrix();
        }

    } else if (itemstack.itemID < Block.blocksList.length && Block.blocksList[itemstack.itemID] != null
            && RenderBlocks.renderItemIn3d(Block.blocksList[itemstack.itemID].getRenderType())) {

        GL11.glTranslatef(0, 0.25F, 0); // BC SPECIFIC
        loadTexture("/terrain.png");
        ForgeHooksClient.overrideTexture(Block.blocksList[itemstack.itemID]);
        float f4 = 0.25F;
        int j = Block.blocksList[itemstack.itemID].getRenderType();
        if (j == 1 || j == 19 || j == 12 || j == 2)
            f4 = 0.5F;

        GL11.glScalef(f4, f4, f4);
        for (int k = 0; k < quantity; k++) {
            GL11.glPushMatrix();

            if (k > 0) {
                float f6 = ((random.nextFloat() * 2.0F - 1.0F) * 0.2F) / f4;
                float f9 = ((random.nextFloat() * 2.0F - 1.0F) * 0.2F) / f4;
                float f11 = ((random.nextFloat() * 2.0F - 1.0F) * 0.2F) / f4;
                GL11.glTranslatef(f6, f9, f11);
            }

            float f7 = 1.0F;
            renderBlocks.renderBlockAsItem(Block.blocksList[itemstack.itemID], itemstack.getItemDamage(), f7);
            GL11.glPopMatrix();
        }

    } else {
        GL11.glTranslatef(0, 0.10F, 0); // BC SPECIFIC

        if (itemstack.getItem().requiresMultipleRenderPasses()) {
            GL11.glScalef(0.5F, 0.5F, 0.5F);
            this.loadTexture(ForgeHooksClient.getTexture("/gui/items.png", Item.itemsList[itemstack.itemID]));

            for (int i = 0; i <= 1; ++i) {
                int iconIndex = itemstack.getItem().getIconFromDamageForRenderPass(itemstack.getItemDamage(),
                        i);
                float scale = 1.0F;

                if (true) {
                    int var17 = Item.itemsList[itemstack.itemID].getColorFromDamage(itemstack.getItemDamage(),
                            i);
                    float var18 = (var17 >> 16 & 255) / 255.0F;
                    float var19 = (var17 >> 8 & 255) / 255.0F;
                    float var20 = (var17 & 255) / 255.0F;
                    GL11.glColor4f(var18 * scale, var19 * scale, var20 * scale, 1.0F);
                }

                this.drawItem(iconIndex, quantity);
            }
        } else {

            GL11.glScalef(0.5F, 0.5F, 0.5F);
            int i = itemstack.getIconIndex();
            if (itemstack.itemID < Block.blocksList.length && Block.blocksList[itemstack.itemID] != null) {
                loadTexture("/terrain.png");
                ForgeHooksClient.overrideTexture(Block.blocksList[itemstack.itemID]);
            } else {
                loadTexture("/gui/items.png");
                ForgeHooksClient.overrideTexture(Item.itemsList[itemstack.itemID]);
            }

            drawItem(i, quantity);
        }

    }
    GL11.glDisable(32826 /* GL_RESCALE_NORMAL_EXT */);
    GL11.glPopMatrix();
}

From source file:net.minecraft.src.forge.ForgeHooksClient.java

License:Minecraft Forge Public License

public static void renderEquippedItem(IItemRenderer customRenderer, RenderBlocks renderBlocks,
        EntityLiving entity, ItemStack item) {
    if (customRenderer.shouldUseRenderHelper(EQUIPPED, item, EQUIPPED_BLOCK)) {
        GL11.glPushMatrix();// w w w  .  j a v a  2s  .c om
        GL11.glTranslatef(-0.5F, -0.5F, -0.5F);
        customRenderer.renderItem(EQUIPPED, item, renderBlocks, entity);
        GL11.glPopMatrix();
    } else {
        GL11.glPushMatrix();
        GL11.glEnable(GL12.GL_RESCALE_NORMAL);
        GL11.glTranslatef(0.0F, -0.3F, 0.0F);
        GL11.glScalef(1.5F, 1.5F, 1.5F);
        GL11.glRotatef(50.0F, 0.0F, 1.0F, 0.0F);
        GL11.glRotatef(335.0F, 0.0F, 0.0F, 1.0F);
        GL11.glTranslatef(-0.9375F, -0.0625F, 0.0F);
        customRenderer.renderItem(EQUIPPED, item, renderBlocks, entity);
        GL11.glDisable(GL12.GL_RESCALE_NORMAL);
        GL11.glPopMatrix();
    }
}

From source file:net.minecraft.src.wirelessredstone.presentation.TileEntityRedstoneWirelessRenderer.java

License:Open Source License

@Override
public void renderTileEntityAt(TileEntity tileentity, double d, double d1, double d2, float f) {
    try {//from w w w  .  j a v  a2  s  .  c o m
        float f4 = 0.01F;

        GL11.glPushMatrix();
        GL11.glTranslatef((float) d + 0.5F, (float) d1 + 1.5F, (float) d2 + 1F + f4);
        GL11.glScalef(f4, -f4, f4);
        GL11.glNormal3f(0.0F, 0.0F, -1F * f4);

        renderFreq((TileEntityRedstoneWireless) tileentity);
        GL11.glPopMatrix();

        GL11.glPushMatrix();
        GL11.glTranslatef((float) d + 1F + f4, (float) d1 + 1.5F, (float) d2 + 0.5F);
        GL11.glRotatef(90F, 0.0F, 1.0F, 0.0F);
        GL11.glScalef(f4, -f4, f4);
        GL11.glNormal3f(0.0F, 0.0F, -1F * f4);

        renderFreq((TileEntityRedstoneWireless) tileentity);
        GL11.glPopMatrix();

        GL11.glPushMatrix();
        GL11.glTranslatef((float) d + 0.5F, (float) d1 + 1.5F, (float) d2 - f4);
        GL11.glRotatef(180F, 0.0F, 1.0F, 0.0F);
        GL11.glScalef(f4, -f4, f4);
        GL11.glNormal3f(0.0F, 0.0F, 1F * f4);

        renderFreq((TileEntityRedstoneWireless) tileentity);
        GL11.glPopMatrix();

        GL11.glPushMatrix();
        GL11.glTranslatef((float) d - f4, (float) d1 + 1.5F, (float) d2 + 0.5F);
        GL11.glRotatef(270F, 0.0F, 1.0F, 0.0F);
        GL11.glScalef(f4, -f4, f4);
        GL11.glNormal3f(0.0F, 0.0F, -1F * f4);

        renderFreq((TileEntityRedstoneWireless) tileentity);
        GL11.glPopMatrix();
    } catch (Exception e) {
        LoggerRedstoneWireless.getInstance("WirelessRedstone: " + this.getClass().toString())
                .writeStackTrace(e);
    }
}