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.academy.energy.client.render.tile.RenderMatrix.java

License:Open Source License

@Override
public void renderAtOrigin(TileEntity te) {
    TileMatrix tm = (TileMatrix) te;/*from   w  w w  .  j a v  a  2  s  . c o  m*/
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GL11.glPushMatrix();
    {
        GL11.glTranslated(-1, 0, -1);
        double scale = 0.22;
        GL11.glScaled(scale, scale, scale);
        RenderUtils.loadTexture(tex);

        GL11.glDepthMask(true);
        model.renderPart("base");

        GL11.glPushMatrix();
        {
            GL11.glTranslated(0, 6.3, 0);
            drawCube(tm.isLoaded);
        }
        GL11.glPopMatrix();

        GL11.glDepthMask(false);

        RenderUtils.loadTexture(tex);
        model.renderPart("plate");

    }
    GL11.glPopMatrix();
}

From source file:cn.academy.energy.client.render.tile.RenderSolarGen.java

License:Open Source License

@Override
public void renderTileEntityAt(TileEntity te, double x, double y, double z, float u) {
    GL11.glPushMatrix();//from ww w  .  j  a  va  2  s. c  o  m
    GL11.glTranslated(x + .5, y, z + .5);
    double scale = 0.018;
    GL11.glScaled(scale, scale, scale);
    RenderUtils.loadTexture(tex);
    model.renderAll();
    GL11.glPopMatrix();
}

From source file:cn.academy.misc.client.render.RendererMagHook.java

License:Open Source License

@Override
public void doRender(Entity ent, double x, double y, double z, float a, float b) {
    EntityMagHook hook = (EntityMagHook) ent;
    IModelCustom realModel = model;// w w w.  ja  v  a  2 s .  c om
    if (hook.isHit) {
        realModel = model_open;
        hook.preRender();
        x = hook.posX - RenderManager.renderPosX;
        y = hook.posY - RenderManager.renderPosY;
        z = hook.posZ - RenderManager.renderPosZ;
    }

    GL11.glPushMatrix();
    RenderUtils.loadTexture(ACClientProps.TEX_MDL_MAGHOOK);
    GL11.glTranslated(x, y, z);
    GL11.glRotated(-hook.rotationYaw + 90, 0, 1, 0);
    GL11.glRotated(hook.rotationPitch - 90, 0, 0, 1);
    double scale = 0.0054;
    GL11.glScaled(scale, scale, scale);
    realModel.renderAll();
    GL11.glPopMatrix();
}

From source file:cn.academy.misc.client.render.RenderMarker.java

License:Open Source License

@Override
public void doRender(Entity ent, double x, double y, double z, float a, float b) {
    EntityMarker marker = (EntityMarker) ent;
    Entity targ = marker.target;//  www  .  j  a va 2 s . co  m
    double width = targ.width, height = targ.height;
    Tessellator t = Tessellator.instance;
    if (targ != null) {
        GL11.glDisable(GL11.GL_LIGHTING);
        GL11.glDisable(GL11.GL_TEXTURE_2D);
        GL11.glPushMatrix();
        GL11.glTranslated(x - width / 2, y, z - width / 2);
        GL11.glColor4d(marker.r, marker.g, marker.b, marker.a);
        for (int i = 0; i < 8; ++i) {
            GL11.glPushMatrix();
            boolean rev = i < 4;
            double sx = width * mulArray[i][0], sy = height * mulArray[i][1], sz = width * mulArray[i][2];
            final double len = 0.2 * width;
            GL11.glTranslated(sx, sy, sz);
            GL11.glRotated(rotArray[i], 0, 1, 0);
            GL11.glColor4d(marker.r, marker.g, marker.b, marker.a);
            GL11.glLineWidth(3f);
            OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240f, 240f);
            t.startDrawing(GL11.GL_LINES);
            t.setBrightness(15728880);
            t.addVertex(0, 0, 0);
            t.addVertex(0, rev ? len : -len, 0);
            t.addVertex(0, 0, 0);
            t.addVertex(len, 0, 0);
            t.addVertex(0, 0, 0);
            t.addVertex(0, 0, len);
            t.draw();

            GL11.glPushMatrix();
            GL11.glScaled(0.1, 0.1, 0.1);
            //ACModels.MDL_SOLAR.renderAll();
            GL11.glPopMatrix();
            GL11.glPopMatrix();
        }
        GL11.glPopMatrix();
        GL11.glEnable(GL11.GL_TEXTURE_2D);
        GL11.glEnable(GL11.GL_LIGHTING);
    }
}

From source file:cn.academy.misc.tutorial.client.GuiTutorial.java

License:GNU General Public License

private void initUI() {
    frame = loaded.getWidget("frame").copy();

    leftPart = frame.getWidget("leftPart");
    listArea = leftPart.getWidget("list");

    rightPart = frame.getWidget("rightPart");

    showWindow = rightPart.getWidget("showWindow");
    rightWindow = rightPart.getWidget("rightWindow");
    centerPart = rightPart.getWidget("centerPart");
    logo0 = rightPart.getWidget("logo0");
    logo1 = rightPart.getWidget("logo1");
    logo2 = rightPart.getWidget("logo2");
    logo3 = rightPart.getWidget("logo3");

    showArea = showWindow.getWidget("area");
    tagArea = showWindow.getWidget("tag_area");

    showWindow.transform.doesDraw = false;
    rightWindow.transform.doesDraw = false;
    centerPart.transform.doesDraw = false;

    // Event handlers
    centerPart.getWidget("text").listen(FrameEvent.class, (w, e) -> {
        if (currentTut != null) {
            GLMarkdownRenderer renderer = renderInfo(currentTut.tut).getContent();

            glPushMatrix();/*w ww. j a v  a2 s .  c  om*/
            glTranslated(0, 0, 10);

            glColorMask(false, false, false, false);
            glDepthMask(true);

            HudUtils.colorRect(0, 0, w.transform.width, w.transform.height);
            glColorMask(true, true, true, true);

            double ht = Math.max(0, renderer.getMaxHeight() - w.transform.height + 10);
            double delta = VerticalDragBar.get(centerPart.getWidget("scroll_2")).getProgress() * ht;
            glTranslated(3, 3 - delta, 0);
            glDepthFunc(GL_EQUAL);
            renderer.render();
            glDepthFunc(GL_LEQUAL);
            glPopMatrix();
        }
    });

    rightWindow.getWidget("text").listen(FrameEvent.class, (w, e) -> {
        if (currentTut != null) {
            CachedRenderInfo info = renderInfo(currentTut.tut);

            font.draw(info.title, 3, 3, fo_descTitle);

            glPushMatrix();
            glTranslated(3, 15, 0);
            info.getBrief().render();
            glPopMatrix();
        }
    });

    showArea.listen(FrameEvent.class, (w, e) -> {
        final Widget view = currentView();
        if (view == null) {
            return;
        }

        glMatrixMode(GL11.GL_PROJECTION);
        glPushMatrix();
        glLoadIdentity();

        double scale = 366.0 / width * frame.scale;
        float aspect = (float) mc.displayWidth / mc.displayHeight;

        glTranslated(-1 + 2.0 * (w.scale + w.x) / width, 1 - 2.0 * (w.scale + w.y) / height, 0);
        GL11.glScaled(scale, -scale * aspect, -0.5);

        GLU.gluPerspective(50, 1, 1f, 100);

        glMatrixMode(GL11.GL_MODELVIEW);
        glPushMatrix();
        glLoadIdentity();

        // glCullFace(GL_FRONT);
        // glDisable(GL11.GL_DEPTH_TEST);
        glDisable(GL11.GL_ALPHA_TEST);
        glEnable(GL11.GL_BLEND);
        glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
        glCullFace(GL_FRONT);
        glColor4d(1, 1, 1, 1);

        glTranslated(0, 0, -4);

        glTranslated(.55, .55, .5);

        glScaled(.75, -.75, .75);

        glRotated(-20, 1, 0, 0.1);

        view.post(new ViewRenderEvent());

        glPopMatrix();

        glMatrixMode(GL11.GL_PROJECTION);
        glPopMatrix();

        glMatrixMode(GL11.GL_MODELVIEW);

        glEnable(GL11.GL_DEPTH_TEST);
        glEnable(GL11.GL_ALPHA_TEST);
        glCullFace(GL11.GL_BACK);
    });

    // Left and right button of the preview view.
    // It is assumed when event is triggered, current preview is present and can be switched.

    showWindow.getWidget("btn_left").listen(LeftClickEvent.class, (w, e) -> {
        PreviewInfo info = Preconditions.checkNotNull(currentPreview());
        info.viewIndex -= 1;
        if (info.viewIndex < 0) {
            info.viewIndex = info.subViews.length - 1;
        }

        updateView();
    });

    showWindow.getWidget("btn_right").listen(LeftClickEvent.class, (w, e) -> {
        PreviewInfo info = Preconditions.checkNotNull(currentPreview());
        info.viewIndex = (info.viewIndex + 1) % info.subViews.length;

        updateView();
    });

    {
        FontOption option = new FontOption(10);
        tagArea.listen(FrameEvent.class, (w, evt) -> {
            Widget hovering = gui.getHoveringWidget();
            if (hovering != null) {
                ViewGroupButton comp = hovering.getComponent(ViewGroupButton.class);
                if (comp != null) {
                    font.draw(comp.group.getDisplayText(), 0, -8, option);
                }
            }
        });
    }

    //

    rebuildList();

    final double ln = 500, ln2 = 300, cl = 50;
    final float ht = 5;
    if (!firstOpen) {
        logo1.listen(FrameEvent.class, (w, e) -> {
            glPushMatrix();
            glTranslated(logo1.transform.width / 2, logo1.transform.height / 2 + 15, 0);
            lineglow(ln - ln2, ln, ht);
            lineglow(-ln, -(ln - ln2), ht);
            glPopMatrix();
        });
    } else {
        listArea.transform.doesDraw = false;

        /* Start animation controller */ {
            blend(logo2, 0.65, 0.3);
            blend(logo0, 1.75, 0.3);
            blend(leftPart, 1.75, 0.3);
            blend(logo1, 1.3, 0.3);
            blend(logo3, 0.1, 0.3);
            blendy(logo3, 0.7, 0.4, 63, -36);

            long startTime = GameTimer.getAbsTime();
            logo1.listen(FrameEvent.class, (__, e) -> {
                final double b1 = 0.3, // Blend stage 1
                        b2 = 0.2; // Blend stage 2

                glPushMatrix();
                glTranslated(logo1.transform.width / 2, logo1.transform.height / 2 + 15, 0);
                double dt = (GameTimer.getAbsTime() - startTime) / 1000.0 - 0.4;
                if (dt < 0)
                    dt = 0;
                if (dt < b1) {
                    if (dt > 0) {
                        double len = MathUtils.lerp(0, ln, dt / b1);
                        if (len > cl) {
                            lineglow(cl, len, ht);
                            lineglow(-len, -cl, ht);
                        }
                    }
                } else {
                    double ldt = dt - b1;
                    if (ldt > b2) {
                        ldt = b2;
                    }
                    double len = ln;
                    double len2 = MathUtils.lerp(ln - 2 * cl, ln2, ldt / b2);
                    lineglow(ln - len2, len, ht);
                    lineglow(-len, -(ln - len2), ht);
                }

                glPopMatrix();

                listArea.transform.doesDraw = dt > 2.0;
            });
        }
    }

    gui.addWidget("frame", frame);
}

From source file:cn.academy.terminal.client.TerminalUI.java

License:GNU General Public License

@Override
public void draw(ScaledResolution sr) {
    //Frame update
    selection = (int) ((mouseY - 0.01) / MAX_MY * 3) * 3 + (int) ((mouseX - 0.01) / MAX_MX * 3);

    if (mouseY == 0) {
        mouseY = 1;//from w  w w .j  av  a 2s . c  o  m
        if (scroll > 0)
            scroll--;
    }
    if (mouseY == MAX_MY) {
        mouseY -= 1;
        if (scroll < getMaxScroll())
            scroll++;
    }

    //Draw
    Minecraft mc = Minecraft.getMinecraft();
    long time = GameTimer.getTime();
    if (lastFrameTime == 0)
        lastFrameTime = time;
    long dt = time - lastFrameTime;

    mouseX += helper.dx * SENSITIVITY;
    mouseY -= helper.dy * SENSITIVITY;
    mouseX = Math.max(0, Math.min(MAX_MX, mouseX));
    mouseY = Math.max(0, Math.min(MAX_MY, mouseY));

    buffX = balance(dt, buffX, mouseX);
    buffY = balance(dt, buffY, mouseY);

    helper.dx = helper.dy = 0;

    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glPushMatrix();
    GL11.glLoadIdentity();

    float aspect = (float) mc.displayWidth / mc.displayHeight;
    GLU.gluPerspective(50, aspect, 1f, 100);

    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glPushMatrix();
    GL11.glLoadIdentity();

    GL11.glDisable(GL11.GL_DEPTH_TEST);
    GL11.glDisable(GL11.GL_ALPHA_TEST);
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GL11.glColor4d(1, 1, 1, 1);

    double scale = 1.0 / 310;
    GL11.glTranslated(.35 * aspect, 1.2, -4);

    GL11.glTranslated(1, -1.8, 0);

    GL11.glRotated(-1.6, 0, 0, 1);
    GL11.glRotated(-18 - 4 * (buffX / MAX_MX - 0.5) + 1 * Math.sin(time / 1000.0), 0, 1, 0);
    GL11.glRotated(7 + 4 * (buffY / MAX_MY - 0.5), 1, 0, 0);

    //DEBUG CODE
    //        GL11.glPointSize(20);
    //        GL11.glColor4d(1, 1, 1, 1);
    //        GL11.glDisable(GL11.GL_TEXTURE_2D);
    //        GL11.glBegin(GL11.GL_POINTS);
    //        GL11.glVertex3f(0, 0, 0);
    //        GL11.glEnd();
    //        GL11.glEnable(GL11.GL_TEXTURE_2D);

    GL11.glTranslated(-1, 1.8, 0);

    GL11.glScaled(scale, -scale, scale);

    gui.draw(mouseX, mouseY);

    {
        GL11.glPushMatrix();
        double csize = (getSelectedApp() == null ? 1 : 1.3) * (20 + Math.sin(time / 300.0) * 2);
        RenderUtils.loadTexture(CURSOR);

        GL11.glColor4d(1, 1, 1, .4);
        GL11.glTranslated(0, 0, -2);
        GL11.glDisable(GL11.GL_ALPHA_TEST);
        GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE);
        HudUtils.rect(-csize / 2 + buffX, -csize / 2 + buffY + 120, csize, csize);
        GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
        GL11.glPopMatrix();
    }

    GL11.glPopMatrix();

    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glPopMatrix();

    GL11.glMatrixMode(GL11.GL_MODELVIEW);

    GL11.glEnable(GL11.GL_DEPTH_TEST);
    GL11.glEnable(GL11.GL_ALPHA_TEST);
    GL11.glCullFace(GL11.GL_BACK);
}

From source file:cn.academy.vanilla.electromaster.client.effect.SubArcHandler.java

License:GNU General Public License

public void drawAll() {
    Iterator<SubArc> iter = list.iterator();

    GL11.glDepthMask(false);// w  w w  .  j a  va  2s  . c  o  m
    while (iter.hasNext()) {
        SubArc arc = iter.next();
        if (!arc.dead && arc.draw) {

            GL11.glPushMatrix();
            RenderUtils.glTranslate(arc.pos);
            GL11.glRotated(arc.rotZ, 0, 0, 1);
            GL11.glRotated(arc.rotY, 0, 1, 0);
            GL11.glRotated(arc.rotX, 1, 0, 0);

            final double scale = 0.3;
            GL11.glScaled(scale, scale, scale);
            GL11.glTranslated(-arcs[arc.texID].length / 2, 0, 0);
            arcs[arc.texID].draw();
            GL11.glPopMatrix();
        }
    }
    GL11.glDepthMask(true);
}

From source file:cn.academy.vanilla.electromaster.client.renderer.RendererMagHook.java

License:GNU General Public License

@Override
public void doRender(Entity ent, double x, double y, double z, float a, float b) {
    EntityMagHook hook = (EntityMagHook) ent;
    IModelCustom realModel = model;//from  w  w w  . j  a  va 2s  . c o m
    if (hook.isHit) {
        realModel = model_open;
        hook.preRender();
        x = hook.posX - RenderManager.renderPosX;
        y = hook.posY - RenderManager.renderPosY;
        z = hook.posZ - RenderManager.renderPosZ;
    }

    GL11.glPushMatrix();
    RenderUtils.loadTexture(texture);
    GL11.glTranslated(x, y, z);
    GL11.glRotated(-hook.rotationYaw + 90, 0, 1, 0);
    GL11.glRotated(hook.rotationPitch - 90, 0, 0, 1);
    double scale = 0.0054;
    GL11.glScaled(scale, scale, scale);
    realModel.renderAll();
    GL11.glPopMatrix();
}

From source file:cn.academy.vanilla.teleporter.client.MarkRender.java

License:GNU General Public License

@Override
public void doRender(Entity ent, double x, double y, double z, float var8, float var9) {
    if (RenderUtils.isInShadowPass())
        return;// w  ww.  j  a va 2  s  .  com

    EntityTPMarking mark = (EntityTPMarking) ent;
    if (!mark.firstUpdated())
        return;

    int texID = (int) ((mark.ticksExisted / 2.5) % tex.length);

    GL11.glEnable(GL11.GL_BLEND);
    GL11.glDisable(GL11.GL_LIGHTING);
    GL11.glDisable(GL11.GL_CULL_FACE);
    GL11.glDisable(GL11.GL_DEPTH_TEST);

    GL11.glPushMatrix();
    {
        GL11.glTranslated(x, y, z);

        GL11.glRotated(-mark.rotationYaw, 0, 1, 0);
        GL11.glScaled(-1, -1, 1);
        ShaderSimple.instance().useProgram();
        RenderUtils.loadTexture(tex[texID]);

        if (!mark.available) {
            GL11.glColor4d(1, 0.2, 0.2, 1);
        } else {
            GL11.glColor4d(1, 1, 1, 1);
        }

        model.draw();
        GL20.glUseProgram(0);
    }
    GL11.glPopMatrix();
    GL11.glEnable(GL11.GL_DEPTH_TEST);
    GL11.glEnable(GL11.GL_LIGHTING);
    GL11.glEnable(GL11.GL_CULL_FACE);
}

From source file:cn.lambdacraft.deathmatch.client.HEVRenderingUtils.java

License:Open Source License

public static void drawPlayerHud(EntityPlayer player, ScaledResolution resolution, float partialTickTime) {

    int k = resolution.getScaledWidth();
    int l = resolution.getScaledHeight();
    int i2 = k / 2 - 91;
    int k2 = l - 32 + 3;
    Minecraft mc = Minecraft.getMinecraft();
    TextureManager engine = mc.renderEngine;
    GL11.glEnable(GL11.GL_BLEND);/*w w w  .  ja  v a  2  s . c  om*/
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GL11.glColor4f(1.0F, 0.5F, 0.0F, 0.6F);
    engine.bindTexture(ClientProps.HEV_HUD_PATH);

    GL11.glPushMatrix();

    double scale = 0.00026 * mc.displayWidth + 0.3;

    float xOffset, yOffset;
    xOffset = 10;
    yOffset = l - 20;
    GL11.glTranslatef(xOffset, yOffset, 0.0F);

    GL11.glScaled(scale, scale, 1.0);
    //Health Section
    HudUtils.setTextureResolution(TEX_WIDTH, TEX_HEIGHT);

    GL11.glColor4f(0.7F, 0.7F, 0.7F, 0.6F);
    HudUtils.drawTexturedModalRect(0, 0, 64, 64, 24, 24, 64, 64);
    GL11.glColor4f(1.0F, 0.5F, 0.0F, 0.6F);
    int h = (int) (player.getHealth() * 16 / 20);
    HudUtils.drawTexturedModalRect(0, 24 - (int) (h * 1.5), 192, 128 - 4 * h, 24, (int) (1.5 * h), 64, 4 * h);
    if (player.getHealth() <= 5)
        GL11.glColor4f(0.9F, 0.1F, 0.1F, 0.6F);
    drawNumberAt((byte) (player.getHealth() * 5), 18, 0);
    GL11.glColor4f(1.0F, 0.5F, 0.0F, 0.9F);

    //Armor Section
    GL11.glColor4f(0.7F, 0.7F, 0.7F, 0.6F);
    HudUtils.drawTexturedModalRect(70, 0, 0, 64, 24, 24, 64, 64);
    GL11.glColor4f(1.0F, 0.5F, 0.0F, 0.6F);
    h = player.getTotalArmorValue() * 16 / 20;
    if (h > 16)
        h = 16;
    HudUtils.drawTexturedModalRect(70, 24 - (int) (h * 1.5), 128, 128 - 4 * h, 24, (int) (h * 1.5), 64, 4 * h);

    drawNumberAt(player.getTotalArmorValue() * 5, 70 + 12, 0);

    GL11.glPopMatrix();

    //Other section
    drawArmorTip(player, engine, k, l);
    if (LCClientPlayer.drawArmorTip)
        drawWeaponTip(player, engine, k, l);

    engine.bindTexture(engine.getResourceLocation(1));
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GL11.glColor4f(1.0F, 0.5F, 0.0F, 0.7F);
}