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:com.darkcart.xdolf.util.RenderUtils.java

License:Open Source License

public static void drawCircle(float cx, float cy, float r, int num_segments, int c) {
    GL11.glScalef(0.5F, 0.5F, 0.5F);
    r *= 2;//ww w  .j a v  a2  s  .  co  m
    cx *= 2;
    cy *= 2;
    float f = (float) (c >> 24 & 0xff) / 255F;
    float f1 = (float) (c >> 16 & 0xff) / 255F;
    float f2 = (float) (c >> 8 & 0xff) / 255F;
    float f3 = (float) (c & 0xff) / 255F;
    float theta = (float) (2 * 3.1415926 / (num_segments));
    float p = (float) Math.cos(theta);//calculate the sine and cosine
    float s = (float) Math.sin(theta);
    float t;
    GL11.glColor4f(f1, f2, f3, f);
    float x = r;
    float y = 0;//start at angle = 0
    GL11.glEnable(3042);
    GL11.glDisable(3553);
    GL11.glEnable(GL11.GL_LINE_SMOOTH);
    GL11.glBlendFunc(770, 771);
    GL11.glBegin(GL11.GL_LINE_LOOP);
    for (int ii = 0; ii < num_segments; ii++) {
        GL11.glVertex2f(x + cx, y + cy);//final vertex vertex

        //rotate the stuff
        t = x;
        x = p * x - s * y;
        y = s * t + p * y;
    }
    GL11.glEnd();
    GL11.glEnable(3553);
    GL11.glDisable(3042);
    GL11.glDisable(GL11.GL_LINE_SMOOTH);
    GL11.glScalef(2F, 2F, 2F);
}

From source file:com.darkcart.xdolf.util.RenderUtils.java

License:Open Source License

public static void drawFullCircle(int cx, int cy, double r, int c) {
    GL11.glScalef(0.5F, 0.5F, 0.5F);
    r *= 2;/*  ww  w . j  a v a2 s . c  om*/
    cx *= 2;
    cy *= 2;
    float f = (float) (c >> 24 & 0xff) / 255F;
    float f1 = (float) (c >> 16 & 0xff) / 255F;
    float f2 = (float) (c >> 8 & 0xff) / 255F;
    float f3 = (float) (c & 0xff) / 255F;
    GL11.glEnable(3042);
    GL11.glDisable(3553);
    GL11.glEnable(GL11.GL_LINE_SMOOTH);
    GL11.glBlendFunc(770, 771);
    GL11.glColor4f(f1, f2, f3, f);
    GL11.glBegin(GL11.GL_TRIANGLE_FAN);
    for (int i = 0; i <= 360; i++) {
        double x = Math.sin((i * Math.PI / 180)) * r;
        double y = Math.cos((i * Math.PI / 180)) * r;
        GL11.glVertex2d(cx + x, cy + y);
    }
    GL11.glEnd();
    GL11.glDisable(GL11.GL_LINE_SMOOTH);
    GL11.glEnable(3553);
    GL11.glDisable(3042);
    GL11.glScalef(2F, 2F, 2F);
}

From source file:com.darkona.adventurebackpack.client.render.CopygirlRenderUtils.java

License:Open Source License

public static void renderItemIn3d(ItemStack stack) {
    TextureManager textureManager = Minecraft.getMinecraft().getTextureManager();
    // Not sure why but this can be null when the world loads.
    if (textureManager == null) {
        return;/*w ww.  j  a  v  a 2 s.  c  o  m*/
    }
    Item item = stack.getItem();

    GL11.glPushMatrix();

    Tessellator tessellator = Tessellator.instance;
    GL11.glEnable(GL12.GL_RESCALE_NORMAL);
    GL11.glRotatef(180.0F, 0.0F, 0.0F, 1.0F);
    GL11.glTranslatef(-0.5F, -0.5F, 1 / 32.0F);

    int passes = item.getRenderPasses(stack.getItemDamage());
    for (int pass = 0; pass < passes; pass++) {
        textureManager.bindTexture(((stack.getItemSpriteNumber() == 0) ? TextureMap.locationBlocksTexture
                : TextureMap.locationItemsTexture));
        IIcon icon = item.getIcon(stack, pass);
        if (icon != null) {
            float minU = icon.getMinU();
            float maxU = icon.getMaxU();
            float minV = icon.getMinV();
            float maxV = icon.getMaxV();
            CopygirlRenderUtils.setColorFromInt(item.getColorFromItemStack(stack, pass));
            ItemRenderer.renderItemIn2D(tessellator, maxU, minV, minU, maxV, icon.getIconWidth(),
                    icon.getIconHeight(), 0.0625F);
        }
    }

    if (stack.hasEffect(0)) {
        GL11.glDepthFunc(GL11.GL_EQUAL);
        GL11.glDisable(GL11.GL_LIGHTING);
        textureManager.bindTexture(glint);
        GL11.glEnable(GL11.GL_BLEND);
        GL11.glBlendFunc(GL11.GL_SRC_COLOR, GL11.GL_ONE);
        float f7 = 0.76F;
        GL11.glColor4f(0.5F * f7, 0.25F * f7, 0.8F * f7, 1.0F);
        GL11.glMatrixMode(GL11.GL_TEXTURE);
        GL11.glPushMatrix();
        float f8 = 0.125F;
        GL11.glScalef(f8, f8, f8);
        float f9 = Minecraft.getSystemTime() % 3000L / 3000.0F * 8.0F;
        GL11.glTranslatef(f9, 0.0F, 0.0F);
        GL11.glRotatef(-50.0F, 0.0F, 0.0F, 1.0F);
        ItemRenderer.renderItemIn2D(tessellator, 0.0F, 0.0F, 1.0F, 1.0F, 256, 256, 0.0625F);
        GL11.glPopMatrix();
        GL11.glPushMatrix();
        GL11.glScalef(f8, f8, f8);
        f9 = Minecraft.getSystemTime() % 4873L / 4873.0F * 8.0F;
        GL11.glTranslatef(-f9, 0.0F, 0.0F);
        GL11.glRotatef(10.0F, 0.0F, 0.0F, 1.0F);
        ItemRenderer.renderItemIn2D(tessellator, 0.0F, 0.0F, 1.0F, 1.0F, 256, 256, 0.0625F);
        GL11.glPopMatrix();
        GL11.glMatrixMode(GL11.GL_MODELVIEW);
        GL11.glDisable(GL11.GL_BLEND);
        GL11.glEnable(GL11.GL_LIGHTING);
        GL11.glDepthFunc(GL11.GL_LEQUAL);
    }

    GL11.glDisable(GL12.GL_RESCALE_NORMAL);

    GL11.glPopMatrix();
}

From source file:com.dyonovan.tcnodetracker.lib.truetyper.TrueTypeFont.java

License:Open Source License

public void drawString(float x, float y, String whatchars, int startIndex, int endIndex, float scaleX,
        float scaleY, int format, float... rgba) {
    if (rgba.length == 0)
        rgba = new float[] { 1f, 1f, 1f, 1f };
    GL11.glPushMatrix();//from   w  w  w . j  a  va  2 s  .  c  o  m
    GL11.glScalef(scaleX, scaleY, 1.0f);

    FloatObject floatObject = null;
    int charCurrent;

    float totalwidth = 0;
    int i = startIndex, d, c;
    float startY = 0;

    switch (format) {
    case ALIGN_RIGHT: {
        d = -1;
        c = correctR;

        while (i < endIndex) {
            if (whatchars.charAt(i) == '\n')
                startY -= fontHeight;
            i++;
        }
        break;
    }
    case ALIGN_CENTER: {
        for (int l = startIndex; l <= endIndex; l++) {
            charCurrent = whatchars.charAt(l);
            if (charCurrent == '\n')
                break;
            if (charCurrent < 256) {
                floatObject = charArray[charCurrent];
            } else {
                floatObject = (FloatObject) customChars.get(new Character((char) charCurrent));
            }
            totalwidth += floatObject.width - correctL;
        }
        totalwidth /= -2;
    }
    case ALIGN_LEFT:
    default: {
        d = 1;
        c = correctL;
        break;
    }

    }
    GL11.glBindTexture(GL11.GL_TEXTURE_2D, fontTextureID);
    Tessellator t = Tessellator.instance;
    t.startDrawingQuads();
    //   GL11.glBegin(GL11.GL_QUADS);
    if (rgba.length == 4)
        t.setColorRGBA_F(rgba[0], rgba[1], rgba[2], rgba[3]);
    while (i >= startIndex && i <= endIndex) {

        charCurrent = whatchars.charAt(i);
        if (charCurrent < 256) {
            floatObject = charArray[charCurrent];
        } else {
            floatObject = (FloatObject) customChars.get(new Character((char) charCurrent));
        }

        if (floatObject != null) {
            if (d < 0)
                totalwidth += (floatObject.width - c) * d;
            if (charCurrent == '\n') {
                startY -= fontHeight * d;
                totalwidth = 0;
                if (format == ALIGN_CENTER) {
                    for (int l = i + 1; l <= endIndex; l++) {
                        charCurrent = whatchars.charAt(l);
                        if (charCurrent == '\n')
                            break;
                        if (charCurrent < 256) {
                            floatObject = charArray[charCurrent];
                        } else {
                            floatObject = (FloatObject) customChars.get(new Character((char) charCurrent));
                        }
                        totalwidth += floatObject.width - correctL;
                    }
                    totalwidth /= -2;
                }
                //if center get next lines total width/2;
            } else {
                drawQuad((totalwidth + floatObject.width) + x / scaleX, startY + y / scaleY,
                        totalwidth + x / scaleX, (startY + floatObject.height) + y / scaleY,
                        floatObject.storedX + floatObject.width, floatObject.storedY + floatObject.height,
                        floatObject.storedX, floatObject.storedY);
                if (d > 0)
                    totalwidth += (floatObject.width - c) * d;
            }
            i += d;

        }
    }
    t.draw();
    //   GL11.glEnd();

    GL11.glPopMatrix();
}

From source file:com.enderville.mod.client.gui.mainmenu.MenuBaseEnderVille.java

License:LGPL

/**
 * Draws the screen and all the components in it.
 *//*w  ww .ja  v  a2 s  .  co m*/
public void drawScreen(int par1, int par2, float par3) {
    this.renderSkybox(par1, par2, par3);
    Tessellator tessellator = Tessellator.instance;
    short short1 = 274;
    int k = this.width / 2 - short1 / 2;
    byte b0 = 30;
    this.drawGradientRect(0, 0, this.width, this.height, -2130706433, 16777215);
    this.drawGradientRect(0, 0, this.width, this.height, 0, Integer.MIN_VALUE);
    this.mc.getTextureManager().bindTexture(minecraftTitleTextures);
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);

    if ((double) this.updateCounter < 1.0E-4D) {
        this.drawTexturedModalRect(k + 0, b0 + 0, 0, 0, 99, 44);
        this.drawTexturedModalRect(k + 99, b0 + 0, 129, 0, 27, 44);
        this.drawTexturedModalRect(k + 99 + 26, b0 + 0, 126, 0, 3, 44);
        this.drawTexturedModalRect(k + 99 + 26 + 3, b0 + 0, 99, 0, 26, 44);
        this.drawTexturedModalRect(k + 155, b0 + 0, 0, 45, 155, 44);
    } else {
        this.drawTexturedModalRect(k + 0, b0 + 0, 0, 0, 155, 44);
        this.drawTexturedModalRect(k + 155, b0 + 0, 0, 45, 155, 44);
    }

    tessellator.setColorOpaque_I(16777215);
    GL11.glPushMatrix();
    GL11.glTranslatef((float) (this.width / 2 + 90), 70.0F, 0.0F);
    GL11.glRotatef(-20.0F, 0.0F, 0.0F, 1.0F);
    float f1 = 1.8F - MathHelper
            .abs(MathHelper.sin((float) (Minecraft.getSystemTime() % 1000L) / 1000.0F * (float) Math.PI * 2.0F)
                    * 0.1F);
    f1 = f1 * 100.0F / (float) (this.fontRenderer.getStringWidth(this.splashText) + 32);
    GL11.glScalef(f1, f1, f1);
    this.drawCenteredString(this.fontRenderer, this.splashText, 0, -8, 0x8A0868);
    GL11.glPopMatrix();
    String s = "Minecraft 1.6.4";
    this.drawString(this.fontRenderer, s, 2, this.height - (10 + 0 * (this.fontRenderer.FONT_HEIGHT + 1)),
            Color.YELLOW.getRGB());

    if (this.mc.isDemo()) {
        s = s + " Demo";
    }

    String s1 = this.getVersion();
    drawString(this.fontRenderer, s1, this.width - this.fontRenderer.getStringWidth(s1) - 2, this.height - 10,
            0x8A0868);

    if ((this.field_92025_p != null) && (this.field_92025_p.length() > 0)) {
        drawRect(this.field_92022_t - 2, this.field_92021_u - 2, this.field_92020_v + 2, this.field_92019_w - 1,
                1428160512);
        drawString(this.fontRenderer, this.field_92025_p, this.field_92022_t, this.field_92021_u, 16777215);
    }

    super.drawScreen(par1, par2, par3);
}

From source file:com.ethylamine.fsynthesis.client.renderer.item.DisintegraterItemRenderer.java

License:Open Source License

private void renderCupola(ImmutableTriple<Float, Float, Float> offset) {
    GL11.glPushMatrix();//from   www . ja va  2 s  . c  om
    GL11.glScalef(SCALE.left, SCALE.middle, SCALE.right);
    GL11.glTranslatef(offset.left, offset.middle, offset.right);

    FMLClientHandler.instance().getClient().renderEngine.bindTexture(DisintegraterTESR.TEXTURE);

    model.render();

    GL11.glPopMatrix();
}

From source file:com.ethylamine.fsynthesis.client.renderer.item.TungstenChestItemRenderer.java

License:Open Source License

private void renderPlotoniumChest(ImmutableTriple<Float, Float, Float> offset) {
    GL11.glPushMatrix();//from  w  w  w.  j av a  2 s .c  om

    GL11.glScalef(SCALE.left, SCALE.middle, SCALE.right);
    GL11.glTranslatef(offset.left, offset.middle, offset.right);
    GL11.glRotatef(180.0f, 1.0f, 0.0f, 0.0f);
    GL11.glRotatef(90.0f, 0.0f, -1.0f, 0.0f);

    FMLClientHandler.instance().getClient().renderEngine.bindTexture(TungstenChestTESR.TEXTURE);

    vanillaChest.renderAll();

    GL11.glPopMatrix();
}

From source file:com.ethylamine.fsynthesis.client.renderer.tileentity.DisintegraterTESR.java

License:Open Source License

private void renderDisintegrater(TileEntityDisintegrater te) {

    final int x = te.xCoord;
    final int y = te.yCoord;
    final int z = te.zCoord;
    final World world = te.getWorldObj();

    // Lighting/*from w w  w  .  jav  a 2 s  .co  m*/
    final float brightness = ModBlocks.disintegrater.getMixedBrightnessForBlock(world, x, y, z);
    final int skyLight = world.getLightBrightnessForSkyBlocks(x, y, z, 0);
    final int skyLightLSB = skyLight % 65536;
    final int skyLightMSB = skyLight / 65536;

    Tessellator.instance.setColorOpaque_F(brightness, brightness, brightness);
    OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, skyLightLSB, skyLightMSB);

    // Open Render buffer
    GL11.glPushMatrix();

    // Inherent adjustments to model
    GL11.glScalef(SCALE.left, SCALE.middle, SCALE.right);
    GL11.glTranslatef(OFFSET.left, OFFSET.middle, OFFSET.right);

    // Orient the model to match the placement
    final int metadata = world.getBlockMetadata(x, y, z);
    final Orientation orientation = Orientation.getdecodedOrientation(metadata);

    GL11.glRotatef(getAngleFromOrientation(orientation), 0.0F, 1.0F, 0.0F);

    // Bind the texture
    bindTexture(TEXTURE);

    // Render
    model.render();

    // Close Render Buffer
    GL11.glPopMatrix();
}

From source file:com.ethylamine.fsynthesis.client.renderer.tileentity.TungstenChestTESR.java

License:Open Source License

private void renderTungstenChest(TungstenChestTE te, float tick) {
    final int x = te.xCoord;
    final int y = te.yCoord;
    final int z = te.zCoord;
    final World world = te.getWorldObj();

    GL11.glPushMatrix();//from  w ww .j  av  a 2s  . c  o  m

    // Position Renderer
    bindTexture(TEXTURE);
    GL11.glEnable(GL12.GL_RESCALE_NORMAL);
    GL11.glScalef(1.0F, -1.0F, -1.0F); //flip & rotate
    GL11.glTranslatef(0.5F, 0.5F, 0.5F); //translate block pos around fromBLK ORG

    final int metadata = world.getBlockMetadata(x, y, z);
    final Orientation orientation = Orientation.getdecodedOrientation(metadata);
    GL11.glRotatef(getAngleFromOrientation(orientation), 0.0F, -1.0F, 0.0F);

    GL11.glTranslatef(-0.5F, -0.5F, -0.5F); //translate BLK ORG to block pos

    //lid angle.
    float adjLDAngle = te.getPrevLidAngle() + (te.getLidAngle() - te.getPrevLidAngle()) * tick;
    adjLDAngle = 1.0F - adjLDAngle;
    adjLDAngle = 1.0F - adjLDAngle * adjLDAngle * adjLDAngle;
    //noinspection NumericCastThatLosesPrecision
    vanillaChest.chestLid.rotateAngleX = -(adjLDAngle * (float) Math.PI / 2.0F);

    vanillaChest.renderAll();

    GL11.glDisable(GL12.GL_RESCALE_NORMAL);
    GL11.glPopMatrix();
}

From source file:com.freyja.FES.client.models.ModelInjector.java

License:LGPL

public void render(RoutingEntity te, double x, double y, double z) {
    GL11.glPushMatrix();//from   ww w.  j  a v  a 2  s . com

    GL11.glTranslatef((float) x + 0.5f, (float) y, (float) z + 0.5f);

    ForgeDirection orientation = te.getOrientation();

    if (orientation == ForgeDirection.DOWN) {
        GL11.glRotatef(180, 1, 0, 0);
        GL11.glTranslatef(0, -1f, 0f);
    }

    if (orientation == ForgeDirection.SOUTH) {
        GL11.glRotatef(90, 1, 0, 0);
        GL11.glTranslatef(0, -.5f, -.5f);
    }

    if (orientation == ForgeDirection.NORTH) {
        GL11.glRotatef(90, -1, 0, 0);
        GL11.glTranslatef(0, -.5f, .5f);
    }

    if (orientation == ForgeDirection.WEST) {
        GL11.glRotatef(90, 0, 0, 1);
        GL11.glTranslatef(.5f, -.5f, 0);
    }

    if (orientation == ForgeDirection.EAST) {
        GL11.glRotatef(90, 0, 0, -1);
        GL11.glTranslatef(-.5f, -.5f, 0);
    }

    GL11.glScalef(0.5f, 0.5f, 0.5f);

    FMLClientHandler.instance().

            getClient()

                    .renderEngine.bindTexture("/mods/FES/textures/injector.png");
    this.

            render();

    GL11.glPopMatrix();
}