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.minecraftforge.fml.client.config.GuiUnicodeGlyphButton.java

License:Open Source License

@Override
public void drawButton(Minecraft mc, int mouseX, int mouseY) {
    if (this.visible) {
        this.hovered = mouseX >= this.xPosition && mouseY >= this.yPosition
                && mouseX < this.xPosition + this.width && mouseY < this.yPosition + this.height;
        int k = this.getHoverState(this.hovered);
        GuiUtils.drawContinuousTexturedBox(buttonTextures, this.xPosition, this.yPosition, 0, 46 + k * 20,
                this.width, this.height, 200, 20, 2, 3, 2, 2, this.zLevel);
        this.mouseDragged(mc, mouseX, mouseY);
        int color = 14737632;

        if (packedFGColour != 0) {
            color = packedFGColour;/*from  ww w  .  j av a 2  s  .co m*/
        } else if (!this.enabled) {
            color = 10526880;
        } else if (this.hovered) {
            color = 16777120;
        }

        String buttonText = this.displayString;
        int glyphWidth = (int) (mc.fontRendererObj.getStringWidth(glyph) * glyphScale);
        int strWidth = mc.fontRendererObj.getStringWidth(buttonText);
        int elipsisWidth = mc.fontRendererObj.getStringWidth("...");
        int totalWidth = strWidth + glyphWidth;

        if (totalWidth > width - 6 && totalWidth > elipsisWidth)
            buttonText = mc.fontRendererObj.trimStringToWidth(buttonText, width - 6 - elipsisWidth).trim()
                    + "...";

        strWidth = mc.fontRendererObj.getStringWidth(buttonText);
        totalWidth = glyphWidth + strWidth;

        GL11.glPushMatrix();
        GL11.glScalef(glyphScale, glyphScale, 1.0F);
        this.drawCenteredString(mc.fontRendererObj, glyph,
                (int) (((this.xPosition + (this.width / 2) - (strWidth / 2)) / glyphScale)
                        - (glyphWidth / (2 * glyphScale)) + 2),
                (int) (((this.yPosition + ((this.height - 8) / glyphScale) / 2) - 1) / glyphScale), color);
        GL11.glPopMatrix();

        this.drawCenteredString(mc.fontRendererObj, buttonText,
                (int) (this.xPosition + (this.width / 2) + (glyphWidth / glyphScale)),
                this.yPosition + (this.height - 8) / 2, color);
    }
}

From source file:net.phatcode.rel.multimedia.Graphics.java

License:Open Source License

private void drawTransformedSprite(float x, float y, float angle, float scaleX, float scaleY, int flipmode,
        SpriteGL sprite) {//from w ww.  j  a va  2s  .  c o  m

    flipmode = getflipMode(flipmode);

    float s_half_x = sprite.width / 2.0f;
    float s_half_y = sprite.height / 2.0f;

    float x1 = -s_half_x;
    float y1 = -s_half_y;

    float u1 = ((flipmode & SpriteGL.FLIP_H) == 0) ? sprite.u1 : sprite.u2;
    float v1 = ((flipmode & SpriteGL.FLIP_V) == 0) ? sprite.v1 : sprite.v2;
    float u2 = ((flipmode & SpriteGL.FLIP_H) == 0) ? sprite.u2 : sprite.u1;
    float v2 = ((flipmode & SpriteGL.FLIP_V) == 0) ? sprite.v2 : sprite.v1;

    if (sprite.textureID != currentTexture) {
        GL11.glBindTexture(GL11.GL_TEXTURE_2D, sprite.textureID);
        currentTexture = sprite.textureID;
    }

    GL11.glPushMatrix();

    GL11.glTranslatef(x, y, 0.0f);
    GL11.glScalef(scaleX, scaleY, 1.0f);
    GL11.glRotatef(angle, 0.0f, 0.0f, 1.0f);

    GL11.glBegin(GL11.GL_QUADS);

    GL11.glTexCoord2f(u1, v1);
    GL11.glVertex2f(x1, y1);
    GL11.glTexCoord2f(u1, v2);
    GL11.glVertex2f(x1, s_half_y);
    GL11.glTexCoord2f(u2, v2);
    GL11.glVertex2f(s_half_x, s_half_y);
    GL11.glTexCoord2f(u2, v1);
    GL11.glVertex2f(s_half_x, y1);

    GL11.glEnd();

    GL11.glPopMatrix();

}

From source file:net.phatcode.rel.multimedia.Graphics.java

License:Open Source License

private void drawTransformedSprite(float x, float y, float angle, float scaleX, float scaleY, float r, float g,
        float b, float a, int flipmode, SpriteGL sprite) {

    flipmode = getflipMode(flipmode);//w w w .ja v a  2 s . co  m

    float s_half_x = sprite.width / 2.0f;
    float s_half_y = sprite.height / 2.0f;

    float x1 = -s_half_x;
    float y1 = -s_half_y;

    float u1 = ((flipmode & SpriteGL.FLIP_H) == 0) ? sprite.u1 : sprite.u2;
    float v1 = ((flipmode & SpriteGL.FLIP_V) == 0) ? sprite.v1 : sprite.v2;
    float u2 = ((flipmode & SpriteGL.FLIP_H) == 0) ? sprite.u2 : sprite.u1;
    float v2 = ((flipmode & SpriteGL.FLIP_V) == 0) ? sprite.v2 : sprite.v1;

    if (sprite.textureID != currentTexture) {
        GL11.glBindTexture(GL11.GL_TEXTURE_2D, sprite.textureID);
        currentTexture = sprite.textureID;
    }

    GL11.glColor4f(r, g, b, a);

    GL11.glPushMatrix();

    GL11.glTranslatef(x, y, 0.0f);
    GL11.glScalef(scaleX, scaleY, 1.0f);
    GL11.glRotatef(angle, 0.0f, 0.0f, 1.0f);

    GL11.glBegin(GL11.GL_QUADS);

    GL11.glTexCoord2f(u1, v1);
    GL11.glVertex2f(x1, y1);
    GL11.glTexCoord2f(u1, v2);
    GL11.glVertex2f(x1, s_half_y);
    GL11.glTexCoord2f(u2, v2);
    GL11.glVertex2f(s_half_x, s_half_y);
    GL11.glTexCoord2f(u2, v1);
    GL11.glVertex2f(s_half_x, y1);

    GL11.glEnd();

    GL11.glPopMatrix();

}

From source file:net.phatcode.rel.multimedia.Graphics.java

License:Open Source License

private void drawScrolledSprite(float x, float y, float scaleX, float scaleY, float u, float v, int flipmode,
        SpriteGL sprite) {//from w w  w. j ava  2 s  .  co m

    flipmode = getflipMode(flipmode);

    float x2 = x + sprite.width;
    float y2 = y + sprite.height;

    float u1 = ((flipmode & SpriteGL.FLIP_H) == 0) ? sprite.u1 : sprite.u2;
    float v1 = ((flipmode & SpriteGL.FLIP_V) == 0) ? sprite.v1 : sprite.v2;
    float u2 = ((flipmode & SpriteGL.FLIP_H) == 0) ? sprite.u2 : sprite.u1;
    float v2 = ((flipmode & SpriteGL.FLIP_V) == 0) ? sprite.v2 : sprite.v1;

    if (sprite.textureID != currentTexture) {
        GL11.glBindTexture(GL11.GL_TEXTURE_2D, sprite.textureID);
        currentTexture = sprite.textureID;
    }

    GL11.glPushMatrix();

    GL11.glScalef(scaleX, scaleY, 1.0f);

    GL11.glBegin(GL11.GL_QUADS);

    GL11.glTexCoord2f(u1 + u, v1 + v);
    GL11.glVertex2f(x, y);
    GL11.glTexCoord2f(u1 + u, v2 + v);
    GL11.glVertex2f(x, y2);
    GL11.glTexCoord2f(u2 + u, v2 + v);
    GL11.glVertex2f(x2, y2);
    GL11.glTexCoord2f(u2 + u, v1 + v);
    GL11.glVertex2f(x2, y);

    GL11.glEnd();

    GL11.glPopMatrix();

}

From source file:net.phatcode.rel.multimedia.Graphics.java

License:Open Source License

private void drawScrolledSprite(float x, float y, float scaleX, float scaleY, float u, float v, float r,
        float g, float b, float a, int flipmode, SpriteGL sprite) {

    flipmode = getflipMode(flipmode);/*w  ww.  j ava2  s  .  c  o m*/

    float x2 = x + sprite.width;
    float y2 = y + sprite.height;

    float u1 = ((flipmode & SpriteGL.FLIP_H) == 0) ? sprite.u1 : sprite.u2;
    float v1 = ((flipmode & SpriteGL.FLIP_V) == 0) ? sprite.v1 : sprite.v2;
    float u2 = ((flipmode & SpriteGL.FLIP_H) == 0) ? sprite.u2 : sprite.u1;
    float v2 = ((flipmode & SpriteGL.FLIP_V) == 0) ? sprite.v2 : sprite.v1;

    if (sprite.textureID != currentTexture) {
        GL11.glBindTexture(GL11.GL_TEXTURE_2D, sprite.textureID);
        currentTexture = sprite.textureID;
    }

    GL11.glColor4f(r, g, b, a);

    GL11.glPushMatrix();

    GL11.glScalef(scaleX, scaleY, 1.0f);

    GL11.glBegin(GL11.GL_QUADS);

    GL11.glTexCoord2f(u1 + u, v1 + v);
    GL11.glVertex2f(x, y);
    GL11.glTexCoord2f(u1 + u, v2 + v);
    GL11.glVertex2f(x, y2);
    GL11.glTexCoord2f(u2 + u, v2 + v);
    GL11.glVertex2f(x2, y2);
    GL11.glTexCoord2f(u2 + u, v1 + v);
    GL11.glVertex2f(x2, y);

    GL11.glEnd();

    GL11.glPopMatrix();

}

From source file:net.roryclaasen.rorysmod.render.RenderPoweredChest.java

License:Apache License

public void renderTileEntityAt(TileEntityPoweredChest tile, double x, double y, double z, float partialTick) {
    if (tile == null)
        return;/*  w  ww. j av  a2 s .c o m*/
    int facing = 3;
    if (tile.hasWorldObj())
        facing = tile.getFacing();

    this.bindTexture(texture);
    GL11.glPushMatrix();
    GL11.glEnable(GL12.GL_RESCALE_NORMAL);
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    GL11.glTranslatef((float) x, (float) y + 1.0F, (float) z + 1.0F);
    GL11.glScalef(1.0F, -1.0F, -1.0F);
    GL11.glTranslatef(0.5F, 0.5F, 0.5F);

    int k = 0;
    if (facing == 2)
        k = 180;
    if (facing == 3)
        k = 0;
    if (facing == 4)
        k = 90;
    if (facing == 5)
        k = -90;

    GL11.glRotatef(k, 0.0F, 1.0F, 0.0F);
    GL11.glTranslatef(-0.5F, -0.5F, -0.5F);

    float lidangle = tile.prevLidAngle + (tile.lidAngle - tile.prevLidAngle) * partialTick;
    lidangle = 1.0F - lidangle;
    lidangle = 1.0F - lidangle * lidangle * lidangle;
    model.chestLid.rotateAngleX = (float) -((lidangle * Math.PI) / 2.0F);
    //RMLog.info(tile.lidAngle);
    //   model.chestLid.rotateAngleX = -lidangle;

    //tile.prevLidAngle = tile.lidAngle;

    model.renderAll();

    GL11.glDisable(GL12.GL_RESCALE_NORMAL);
    GL11.glPopMatrix();
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
}

From source file:net.shadowmage.ancientwarfare.structure.render.RenderGateHelper.java

License:Open Source License

@Override
public void doRender(Entity entity, double d0, double d1, double d2, float f, float f1) {
    GL11.glPushMatrix();// w  w w.  j  a  va2  s. c  o m
    EntityGate gate = (EntityGate) entity;
    int typeNum = gate.getGateType().getGlobalID();

    if (gate.hurtAnimationTicks > 0) {
        float percent = ((float) gate.hurtAnimationTicks / 20.f);
        GL11.glColor4f(1.f, 1.f - percent, 1.f - percent, 1.f);
    }
    this.bindEntityTexture(entity);
    GL11.glTranslated(d0, d1, d2);
    GL11.glRotatef(f, 0, 1, 0);
    GL11.glScalef(-1, -1, 1);
    getGateRender(typeNum).doRender(entity, d0, d1, d2, f, f1);
    GL11.glColor4f(1.f, 1.f, 1.f, 1.f);
    GL11.glPopMatrix();
}

From source file:net.slimevoid.littleblocks.client.render.blocks.LittleBlocksLittleRenderer.java

License:Open Source License

public void renderLittleBlocks(IBlockAccess iblockaccess, int x, int y, int z) {
    if (this.littleBlocksToRender.size() > 0) {
        Tessellator tessellator = Tessellator.instance;
        tessellator.draw();//w  ww.  j  av  a 2 s.  co m
        GL11.glPushMatrix();

        double xS = -((x >> 4) << 4), yS = -((y >> 4) << 4), zS = -((z >> 4) << 4);

        if (!CoreLib.OPTIFINE_INSTALLED)
            GL11.glTranslated(xS, yS, zS);
        GL11.glEnable(GL12.GL_RESCALE_NORMAL);
        float scale = 1 / (float) ConfigurationLib.littleBlocksSize;
        GL11.glScalef(scale, scale, scale);
        if (!CoreLib.OPTIFINE_INSTALLED)
            GL11.glTranslated(-xS, -yS, -zS);

        tessellator.startDrawingQuads();
        for (LittleBlockToRender littleBlockToRender : this.littleBlocksToRender) {
            try {
                this.renderBlocks.renderBlockByRenderType(littleBlockToRender.block, littleBlockToRender.x,
                        littleBlockToRender.y, littleBlockToRender.z);
            } catch (IllegalArgumentException e) {
                LoggerLittleBlocks.getInstance("LittleBlocksMod")
                        .write(true,
                                "Issue when rendering block [" + littleBlockToRender.block.getLocalizedName()
                                        + "] failed with error [" + e.getLocalizedMessage() + "]",
                                LogLevel.DEBUG);
            }
        }
        tessellator.draw();
        GL11.glDisable(GL12.GL_RESCALE_NORMAL);
        GL11.glPopMatrix();
        tessellator.startDrawingQuads();
    }
}

From source file:net.slimevoid.tmf.client.renderers.handlers.BlockGrinderRenderer.java

License:Open Source License

@Override
public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer) {
    TileEntityGrinder tile = new TileEntityGrinder();
    tile.blockType = block;// www .  ja va2  s . c o m
    GL11.glPushMatrix();
    GL11.glTranslatef(-0.2F, 0.0F, -0.3F);
    GL11.glRotatef(-5, 0, 1, 0);
    GL11.glRotatef(5, 0, 0, 1);
    GL11.glScalef(1.35F, 1.35F, 1.35F);
    TileEntityRendererDispatcher.instance.renderTileEntityAt(tile, -0.3D, -0.3D, -0.3D, 0.0F);
    GL11.glPopMatrix();
}