Example usage for org.lwjgl.opengl GL11 glScaled

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

Introduction

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

Prototype

public static native void glScaled(@NativeType("GLdouble") double x, @NativeType("GLdouble") double y,
        @NativeType("GLdouble") double z);

Source Link

Document

Double version of #glScalef Scalef .

Usage

From source file:cn.liutils.cgui.gui.LIGui.java

License:Open Source License

private void drawTraverse(double mx, double my, Widget cur, WidgetContainer set, Widget top) {
    try {//from  w w w.ja va  2  s  . c  o  m
        if (cur != null && cur.isVisible()) {
            GL11.glPushMatrix();
            GL11.glTranslated(cur.x, cur.y, 0);

            double px = cur.transform.pivotX * cur.scale, py = cur.transform.pivotY * cur.scale;

            GL11.glScaled(cur.scale, cur.scale, 1);
            GL11.glTranslated(-cur.transform.pivotX, -cur.transform.pivotY, 0);

            GL11.glColor4d(1, 1, 1, 1); //Force restore color for any widget
            cur.postEvent(new FrameEvent((mx - cur.x) / cur.scale, (my - cur.y) / cur.scale, cur == top));
            GL11.glPopMatrix();
        }
    } catch (Exception e) {
        LIUtils.log.error("Error occured handling widget draw. instance class: " + cur.getClass().getName()
                + ", name: " + cur.getName());
        e.printStackTrace();
    }

    if (cur == null || cur.isVisible()) {
        Iterator<Widget> iter = set.iterator();
        while (iter.hasNext()) {
            Widget wn = iter.next();
            drawTraverse(mx, my, wn, wn, top);
        }
    }
}

From source file:cn.liutils.template.client.render.item.RenderModelItem.java

License:Open Source License

public void renderEntityItem(RenderBlocks render, EntityItem ent) {

    GL11.glPushMatrix();//from w  w  w.  ja  va 2 s . c om
    {
        RenderUtils.loadTexture(texturePath);
        this.doRotation(entityItemRotation);
        GL11.glScaled(entityItemScale, entityItemScale, entityItemScale);
        renderAtStdPosition();
    }
    GL11.glPopMatrix();
}

From source file:cn.liutils.util.helper.Font.java

License:Open Source License

/**
 * Draw a string with alignment.//ww w .j av a  2 s  .  c o m
 * @param str
 * @param x
 * @param y
 * @param size
 * @param color
 * @param align
 */
public void draw(String str, double x, double y, double size, int color, Align align) {
    GL11.glEnable(GL11.GL_BLEND);
    //GL11.glDepthMask(false);
    double scale = size / mcFont().FONT_HEIGHT;
    GL11.glPushMatrix();
    {
        GL11.glTranslated(x, y, 0);
        GL11.glScaled(scale, scale, 1);
        String[] ss = str.split("\n");
        for (int i = 0; i < ss.length; ++i) {
            GL11.glPushMatrix();
            {
                double dy = i * mcFont().FONT_HEIGHT;
                GL11.glTranslated(0, dy, 0);
                drawSingleLine(ss[i], color, align);
            }
            GL11.glPopMatrix();
        }
    }
    GL11.glPopMatrix();
}

From source file:cn.liutils.util.render.Font.java

License:Open Source License

/**
 * @return Rectangle size//from w w  w.  j a  va2 s  . co  m
 */
public void drawWrapped(String str, double x, double y, double size, int color, double limit) {
    double scale = size / mcFont.FONT_HEIGHT;
    GL11.glPushMatrix();
    GL11.glTranslated(x, y, 0);
    GL11.glScaled(scale, scale, 1);
    mcFont.drawSplitString(str, 0, 0, 0xFFFFFF, (int) (limit * scale));
    GL11.glPopMatrix();
}

From source file:cn.liutils.util.render.Font.java

License:Open Source License

public void draw(String str, double x, double y, double size, int color, Align align) {
    GL11.glEnable(GL11.GL_BLEND);// w ww.j  a  v a 2s. co m
    //GL11.glDepthMask(false);
    double scale = size / mcFont.FONT_HEIGHT;
    GL11.glPushMatrix();
    {
        GL11.glTranslated(x, y, 0);
        GL11.glScaled(scale, scale, 1);
        String[] ss = str.split("\n");
        for (int i = 0; i < ss.length; ++i) {
            GL11.glPushMatrix();
            {
                double dy = i * mcFont.FONT_HEIGHT;
                GL11.glTranslated(0, dy, 0);
                drawSingleLine(ss[i], color, align);
            }
            GL11.glPopMatrix();
        }
    }
    GL11.glPopMatrix();
}

From source file:cn.liutils.util.render.LambdaFont.java

License:Open Source License

public void draw(String str, double x, double y, double size, Align align) {
    GL11.glEnable(GL11.GL_BLEND);/*from   ww w .  ja  v a2  s . co  m*/
    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    //GL11.glDepthMask(false);
    double psx = HudUtils.SCALE_X, psy = HudUtils.SCALE_Y;
    GL11.glPushMatrix();
    {
        GL11.glTranslated(x, y, 0);
        GL11.glScaled(size, size, 1);
        String[] ss = str.split("\n");
        for (int i = 0; i < ss.length; ++i) {
            GL11.glPushMatrix();
            {
                double dy = i * (fontSize + spacing) / fontSize;
                GL11.glTranslated(0, dy, 0);
                drawSingleLine(ss[i], align);
            }
            GL11.glPopMatrix();
        }
    }
    GL11.glPopMatrix();
    //GL11.glDepthMask(true);
    HudUtils.SCALE_X = psx;
    HudUtils.SCALE_Y = psy;
}

From source file:cn.liutils.util.render.LambdaFont.java

License:Open Source License

/**
 * It must be guaranteed that the string contains no line-break characters
 * @returns area of drawing/*from  w w w.  j av  a2s.co m*/
 */
public Vector2d drawLinebreak(String str, double x, double y, double size, double cst) {
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    double psx = HudUtils.SCALE_X, psy = HudUtils.SCALE_Y;
    GL11.glPushMatrix();
    GL11.glTranslated(x, y, 0);
    GL11.glScaled(size, size, 1);

    List<Pair<String, Boolean>> arr = dlbPreProc(str, size, cst);

    double spcstp = getExtent(' ').getStep();

    double y0 = 0;
    double curLen = 0;
    double maxLen = 0;
    for (int i = 0; i < arr.size(); ++i) {
        Pair<String, Boolean> pair = arr.get(i);
        double len = widthSingleLine(pair.first);
        if (size * len < cst && size * (curLen + len) > cst) {
            --i;
            maxLen = Math.max(curLen, maxLen);
            curLen = 0;
            y0 += 1.0;
            continue;
        }

        GL11.glPushMatrix();
        {
            GL11.glTranslated(curLen, y0, 0);
            drawSingleLine(pair.first, Align.LEFT);
        }
        GL11.glPopMatrix();
        curLen += len + (pair.second ? spcstp : 0);

        if (size * len > cst) {
            maxLen = Math.max(curLen, maxLen);
            curLen = 0;
            y0 += 1.0;
        }
    }
    maxLen = Math.max(curLen, maxLen);
    GL11.glPopMatrix();
    HudUtils.SCALE_X = psx;
    HudUtils.SCALE_Y = psy;

    return new Vector2d(maxLen * size, y0 * size + size + spacing * size / fontSize);
}

From source file:cn.weaponry.impl.classic.client.animation.Muzzleflash.java

License:Open Source License

@Override
public void render(ItemInfo info, PartedModel model, boolean firstPerson) {
    double alpha = 1.0;

    if (texture == null && textures != null) {
        texture = textures[RandUtils.nextInt(textures.length)];
    }//ww w .  jav  a  2s  . c om

    //Blend in
    long dt = getTime();
    if (dt < 40) {
        alpha = dt / 40.0;
    } else if (dt > lifeTime - 40.0) {
        alpha = (lifeTime - dt) / 40.0;
    }

    GL11.glDisable(GL11.GL_CULL_FACE);
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE);
    GL11.glPushMatrix();
    RenderUtils.loadTexture(texture == null ? MISSING : texture);
    GL11.glTranslated(x, y, z);

    material.setTexture(texture);
    GL11.glScaled(size, size, size);
    material.color.a = alpha * 0.8;
    GL11.glRotatef(90, 0, 1, 0);
    mesh.draw(material);
    GL11.glColor4d(1, 1, 1, 1);

    GL11.glPopMatrix();
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GL11.glEnable(GL11.GL_CULL_FACE);
}

From source file:com.ardor3d.renderer.lwjgl.LwjglFont.java

License:Open Source License

/**
 * <code>print</code> renders the specified string to a given (x,y) location. The x, y location is in terms of
 * screen coordinates. There are currently two sets of fonts supported: NORMAL and ITALICS.
 * /*w  w  w.  j  a va2s. c  om*/
 * @param r
 * 
 * @param x
 *            the x screen location to start the string render.
 * @param y
 *            the y screen location to start the string render.
 * @param text
 *            the String to render.
 * @param set
 *            the mode of font: NORMAL or ITALICS.
 */
public void print(final Renderer r, final double x, final double y, final ReadOnlyVector3 scale,
        final StringBuffer text, int set) {
    final RendererRecord matRecord = ContextManager.getCurrentContext().getRendererRecord();
    if (set > 1) {
        set = 1;
    } else if (set < 0) {
        set = 0;
    }

    final boolean alreadyOrtho = r.isInOrthoMode();
    if (!alreadyOrtho) {
        r.setOrtho();
    } else {
        LwjglRendererUtil.switchMode(matRecord, GL11.GL_MODELVIEW);
        GL11.glPushMatrix();
        GL11.glLoadIdentity();
    }
    GL11.glTranslated(x, y, 0);
    GL11.glScaled(scale.getX(), scale.getY(), scale.getZ());
    GL11.glListBase(base - 32 + (128 * set));

    // Put the string into a "pointer"
    if (text.length() > scratch.capacity()) {
        scratch = BufferUtils.createByteBuffer(text.length());
    } else {
        scratch.clear();
    }

    final int charLen = text.length();
    for (int z = 0; z < charLen; z++) {
        scratch.put((byte) text.charAt(z));
    }
    scratch.flip();
    GL11.glColor4f(fontColor.getRed(), fontColor.getGreen(), fontColor.getBlue(), fontColor.getAlpha());
    // call the list for each letter in the string.
    GL11.glCallLists(scratch);
    // set color back to white
    GL11.glColor4f(1, 1, 1, 1);

    if (!alreadyOrtho) {
        r.unsetOrtho();
    } else {
        LwjglRendererUtil.switchMode(matRecord, GL11.GL_MODELVIEW);
        GL11.glPopMatrix();
    }
}

From source file:com.bluepowermod.client.render.RenderEngine.java

License:Open Source License

@SuppressWarnings("cast")
@Override/*from  ww w . jav a2  s .  c  o  m*/
public void renderTileEntityAt(TileEntity engine, double x, double y, double z, float f) {

    if (engine instanceof TileEngine) {

        GL11.glPushMatrix();
        GL11.glDisable(GL11.GL_LIGHTING);
        TileEngine tile = (TileEngine) engine.getWorldObj().getTileEntity(engine.xCoord, engine.yCoord,
                engine.zCoord);

        ForgeDirection direction = tile.getOrientation();

        GL11.glTranslated(x, y, z);
        GL11.glScaled(.0315, .0315, .0315);

        if (direction == ForgeDirection.UP) {
            GL11.glTranslated(16, 28, 16);
            GL11.glRotatef(180, 1, 0, 0);
        }
        if (direction == ForgeDirection.DOWN) {
            GL11.glTranslated(16, 4, 16);
            GL11.glRotatef(0, 0, 0, 0);
        }
        if (direction == ForgeDirection.EAST) {
            GL11.glTranslated(28, 16, 16);
            GL11.glRotatef(90, 0, 0, 1);
        }
        if (direction == ForgeDirection.WEST) {
            GL11.glTranslated(4, 16, 16);
            GL11.glRotatef(90, 0, 0, -1);
        }
        if (direction == ForgeDirection.NORTH) {
            GL11.glTranslated(16, 16, 4);
            GL11.glRotatef(90, 1, 0, 0);
        }
        if (direction == ForgeDirection.SOUTH) {
            GL11.glTranslated(16, 16, 28);
            GL11.glRotatef(90, -1, 0, 0);
        }
        if (tile.isActive) {
            bindTexture(textureLocationOn);
        } else {
            bindTexture(textureLocationOff);
        }
        engineModel.renderAllExcept("gear", "glider");

        if (tile.isActive) {
            f += tile.pumpTick;
            if (tile.pumpSpeed > 0) {
                f /= tile.pumpSpeed;
            }
        } else {
            f = 0;
        }
        f = (float) ((float) 6 * (.5 - .5 * Math.cos(3.1415926535897931D * (double) f)));
        GL11.glTranslatef(0, f, 0);

        engineModel.renderPart("glider");

        GL11.glTranslatef(0, -f, 0);

        if (tile.isActive) {
            if (tile.getWorldObj().isRemote) {
                rotateAmount++;

                GL11.glRotated(tile.gearTick * 19, 0, 1.5707963267948966D * (double) f, 0);
            }
        }
        engineModel.renderPart("gear");

        GL11.glEnable(GL11.GL_LIGHTING);

        GL11.glPopMatrix();
    }
}