Example usage for org.lwjgl.opengl GL11 glLoadIdentity

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

Introduction

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

Prototype

public static native void glLoadIdentity();

Source Link

Document

Sets the current matrix to the identity matrix.

Usage

From source file:tk.jacklin213.voxelgale.rendering.BasicRenderer.java

License:Apache License

private void initGL() {
    GL11.glEnable(GL11.GL_TEXTURE_2D);//from   ww  w. j  a  va2  s .c  o  m
    GL11.glShadeModel(GL11.GL_SMOOTH);
    GL11.glClearColor(0, 0, 0, 0);
    GL11.glClearDepth(1);
    GL11.glEnable(GL11.GL_DEPTH_TEST);
    GL11.glDepthFunc(GL11.GL_LEQUAL);

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

    GLU.gluPerspective(45, (float) displayMode.getWidth() / (float) displayMode.getHeight(), 0.1f, 100);
    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glHint(GL11.GL_PERSPECTIVE_CORRECTION_HINT, GL11.GL_NICEST);
}

From source file:tk.jacklin213.voxelgale.rendering.BasicRenderer.java

License:Apache License

private void render() {
    GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);
    GL11.glLoadIdentity();

    GL11.glTranslatef(-3f, 0.0f, -20f);//from   w w w  . jav a  2  s . co m
    GL11.glRotatef(45f, 0.4f, 1.0f, 0.1f);
    GL11.glColor3f(0.5f, 0.5f, 1.0f);

    for (int x = 0; x < 3; x++) {
        for (int y = 0; y < 3; y++) {
            for (int z = 0; z < 3; z++) {
                renderCube();
                GL11.glTranslatef(0, 0, 2);
            }
            GL11.glTranslatef(0, 2, -6);
        }
        GL11.glTranslatef(2, -6, 0);
    }
}

From source file:vazkii.botania.client.render.tile.RenderTileStarfield.java

License:Open Source License

@Override
public void renderTileEntityAt(TileEntity p_147500_1_, double p_147500_2_, double p_147500_4_,
        double p_147500_6_, float p_147500_8_) {
    float f1 = (float) field_147501_a.field_147560_j;
    float f2 = (float) field_147501_a.field_147561_k;
    float f3 = (float) field_147501_a.field_147558_l;
    GL11.glDisable(GL11.GL_LIGHTING);// w  w w .j a v a  2  s.c om
    field_147527_e.setSeed(31100L);
    float f4 = 0.24F;

    for (int i = 0; i < 16; ++i) {
        GL11.glPushMatrix();
        float f5 = 16 - i;
        float f6 = 0.0625F;
        float f7 = 1.0F / (f5 + 1.0F);

        if (i == 0) {
            bindTexture(field_147529_c);
            f7 = 0.1F;
            f5 = 65.0F;
            f6 = 0.125F;
            GL11.glEnable(GL11.GL_BLEND);
            GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
        }

        if (i == 1) {
            bindTexture(field_147526_d);
            GL11.glEnable(GL11.GL_BLEND);
            GL11.glBlendFunc(GL11.GL_ONE, GL11.GL_ONE);
            f6 = 0.5F;
        }

        float f8 = (float) -(p_147500_4_ + f4);
        float f9 = f8 + ActiveRenderInfo.objectY;
        float f10 = f8 + f5 + ActiveRenderInfo.objectY;
        float f11 = f9 / f10;
        f11 += (float) (p_147500_4_ + f4);
        GL11.glTranslatef(f1, f11, f3);
        GL11.glTexGeni(GL11.GL_S, GL11.GL_TEXTURE_GEN_MODE, GL11.GL_OBJECT_LINEAR);
        GL11.glTexGeni(GL11.GL_T, GL11.GL_TEXTURE_GEN_MODE, GL11.GL_OBJECT_LINEAR);
        GL11.glTexGeni(GL11.GL_R, GL11.GL_TEXTURE_GEN_MODE, GL11.GL_OBJECT_LINEAR);
        GL11.glTexGeni(GL11.GL_Q, GL11.GL_TEXTURE_GEN_MODE, GL11.GL_EYE_LINEAR);
        GL11.glTexGen(GL11.GL_S, GL11.GL_OBJECT_PLANE, func_147525_a(1.0F, 0.0F, 0.0F, 0.0F));
        GL11.glTexGen(GL11.GL_T, GL11.GL_OBJECT_PLANE, func_147525_a(0.0F, 0.0F, 1.0F, 0.0F));
        GL11.glTexGen(GL11.GL_R, GL11.GL_OBJECT_PLANE, func_147525_a(0.0F, 0.0F, 0.0F, 1.0F));
        GL11.glTexGen(GL11.GL_Q, GL11.GL_EYE_PLANE, func_147525_a(0.0F, 1.0F, 0.0F, 0.0F));
        GL11.glEnable(GL11.GL_TEXTURE_GEN_S);
        GL11.glEnable(GL11.GL_TEXTURE_GEN_T);
        GL11.glEnable(GL11.GL_TEXTURE_GEN_R);
        GL11.glEnable(GL11.GL_TEXTURE_GEN_Q);
        GL11.glPopMatrix();
        GL11.glMatrixMode(GL11.GL_TEXTURE);
        GL11.glPushMatrix();
        GL11.glLoadIdentity();
        GL11.glTranslatef(0.0F, Minecraft.getSystemTime() % 20000L / 20000.0F, 0.0F);
        GL11.glScalef(f6, f6, f6);
        GL11.glTranslatef(0.5F, 0.5F, 0.0F);
        GL11.glRotatef((i * i * 4321 + i * 9) * 2.0F, 0.0F, 0.0F, 1.0F);
        GL11.glTranslatef(-0.5F, -0.5F, 0.0F);
        GL11.glTranslatef(-f1, -f3, -f2);
        f9 = f8 + ActiveRenderInfo.objectY;
        GL11.glTranslatef(ActiveRenderInfo.objectX * f5 / f9, ActiveRenderInfo.objectZ * f5 / f9, -f2);
        Tessellator tessellator = Tessellator.instance;
        tessellator.startDrawingQuads();

        Color color = Color.getHSBColor(Minecraft.getSystemTime() / 20F % 360 / 360F, 1F, 1F);
        f11 = color.getRed() / 255F;
        float f12 = color.getGreen() / 255F;
        float f13 = color.getBlue() / 255F;

        tessellator.setColorRGBA_F(f11 * f7, f12 * f7, f13 * f7, 1.0F);
        tessellator.addVertex(p_147500_2_, p_147500_4_ + f4, p_147500_6_);
        tessellator.addVertex(p_147500_2_, p_147500_4_ + f4, p_147500_6_ + 1.0D);
        tessellator.addVertex(p_147500_2_ + 1.0D, p_147500_4_ + f4, p_147500_6_ + 1.0D);
        tessellator.addVertex(p_147500_2_ + 1.0D, p_147500_4_ + f4, p_147500_6_);
        tessellator.draw();
        GL11.glPopMatrix();
        GL11.glMatrixMode(GL11.GL_MODELVIEW);
    }

    GL11.glDisable(GL11.GL_BLEND);
    GL11.glDisable(GL11.GL_TEXTURE_GEN_S);
    GL11.glDisable(GL11.GL_TEXTURE_GEN_T);
    GL11.glDisable(GL11.GL_TEXTURE_GEN_R);
    GL11.glDisable(GL11.GL_TEXTURE_GEN_Q);
    GL11.glEnable(GL11.GL_LIGHTING);
}

From source file:vazkii.tinkerer.gui.GuiElementalDesk.java

License:Creative Commons License

@Override
protected void drawGuiContainerBackgroundLayer(float var1, int var2, int var3) {
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    mc.renderEngine.bindTexture(ResourcesReference.GUI_ELEMENTAL_DESK_TEXTURE);
    int xStart = (width - xSize) / 2;
    int yStart = (height - ySize) / 2;
    drawTexturedModalRect(xStart, yStart, 0, 0, xSize, ySize);

    // Draw the Progress bar
    drawTexturedModalRect(xStart + 48, yStart + 46, 176, 0,
            (int) Math.round(deskTile.getProgress() / (TileEntityReference.ELEMENTAL_DESK_ENCHANT_TIME / 80D)),
            12);//ww  w .j ava  2s  . c  o m

    // Render the Book Model, if present
    ItemStack shouldBeABook = deskTile.getStackInSlot(4);
    if (shouldBeABook != null && (shouldBeABook.itemID == Item.book.itemID
            || shouldBeABook.itemID == ElementalTinkererItems.unboundBook.itemID)) {
        GL11.glPushMatrix();
        GL11.glMatrixMode(GL11.GL_PROJECTION);
        GL11.glPushMatrix();
        GL11.glLoadIdentity();
        ScaledResolution var7 = new ScaledResolution(mc.gameSettings, mc.displayWidth, mc.displayHeight);
        GL11.glViewport((var7.getScaledWidth() - 320) / 2 * var7.getScaleFactor(),
                (var7.getScaledHeight() - 240) / 2 * var7.getScaleFactor(), 320 * var7.getScaleFactor(),
                240 * var7.getScaleFactor());
        GL11.glTranslatef(0F, 0.25F, 0F);
        GLU.gluPerspective(90F, 1.3333334F, 9F, 80F);
        GL11.glMatrixMode(GL11.GL_MODELVIEW);
        GL11.glLoadIdentity();
        RenderHelper.enableStandardItemLighting();
        float cos = (float) (Math.cos(ClientTickHandler.elapsedClientTicks / 3D) / 10D);
        GL11.glTranslatef(0.4F, 3.65F + (deskTile.getIsAdvancing() ? cos : -0.1F), -16F);
        GL11.glScalef(1F, 1F, 1F);
        float var9 = 5.0F;
        GL11.glScalef(var9, var9, var9);
        GL11.glRotatef(180F, -0.29F, 0F, 1F);
        float var10 = 0.6F;
        GL11.glTranslatef((1F - var10) * 0.2F, (1F - var10) * 0.1F, (1F - var10) * 0.25F);
        GL11.glRotatef(-(1F - var10) * 90F - 90F, 0F, 1F, 0F);
        GL11.glRotatef(180F, 1F, 0F, 0F);
        mc.renderEngine.bindTexture(shouldBeABook.itemID == ItemIDs.unboundBook
                ? ResourcesReference.ROOT_BOOK_TEXTURES + "Unbound.png"
                : "/item/book.png");
        GL11.glEnable(GL12.GL_RESCALE_NORMAL);
        bookModel.render(null, 0F, 0F, 0F,
                (float) deskTile.getProgress() / (float) TileEntityReference.ELEMENTAL_DESK_ENCHANT_TIME, 0F,
                MiscReference.MODEL_DEFAULT_RENDER_SCALE);
        GL11.glDisable(GL12.GL_RESCALE_NORMAL);
        RenderHelper.disableStandardItemLighting();
        GL11.glMatrixMode(GL11.GL_PROJECTION);
        GL11.glViewport(0, 0, mc.displayWidth, mc.displayHeight);
        GL11.glPopMatrix();
        GL11.glMatrixMode(GL11.GL_MODELVIEW);
        GL11.glPopMatrix();
        RenderHelper.disableStandardItemLighting();
        GL11.glColor4f(1F, 1F, 1F, 1F);
    }

    // Draw the charge bars
    int color = Color.getHSBColor((float) Math.cos(
            (double) ClientTickHandler.elapsedClientTicks / ResourcesReference.SPECTRUM_DIVISOR_ELEMENTIUM_GEM),
            1F, 1F).getRGB();
    Tessellator tess = Tessellator.instance;
    GL11.glDisable(GL11.GL_TEXTURE_2D);
    for (int[] i : CHARGE_METER_COORDINATES) {
        int index = i[0];
        int x = i[1];
        int endY = i[2] + TileEntityReference.ELEMENTAL_DESK_GEM_CHARGE;
        int startY = endY - deskTile.getCharge(index);
        tess.startDrawingQuads();
        tess.setColorOpaque_I(color);
        tess.addVertex(xStart + x, yStart + startY, zLevel);
        tess.addVertex(xStart + x, yStart + endY, zLevel);
        tess.addVertex(xStart + x + 2, yStart + endY, zLevel);
        tess.addVertex(xStart + x + 2, yStart + startY, zLevel);
        tess.draw();
    }
    GL11.glEnable(GL11.GL_TEXTURE_2D);
}

From source file:vengine.VGraphicLayer.java

public void set() {
    if (!inited) {
        init();//from  ww w. j a v  a2 s .c  om
        inited = true;
    }
    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glLoadIdentity();
    GL11.glOrtho(0, Display.getWidth(), Display.getHeight(), 0, 1, -1);
    GL11.glMatrixMode(GL11.GL_MODELVIEW);
}

From source file:vengine.VGraphics.java

public static void start() {

    Thread renderingThread = new Thread("RenderingThread") {

        @Override//from   w w w  .ja v  a 2  s  . co m
        public void run() {
            try {
                Display.setDisplayMode(new DisplayMode(8000, 6000));
                Display.setTitle(VEngine.cfg.g("mod"));
                Display.setIcon(new ByteBuffer[] { new ImageIOImageData().imageToByteBuffer(
                        ImageIO.read(new File(VEngine.cfg.g("modhome") + "/icon.png")), false, false, null),

                        new ImageIOImageData().imageToByteBuffer(
                                ImageIO.read(new File(VEngine.cfg.g("modhome") + "/icon.png")), false, false,
                                null) });
                Display.setFullscreen(true);
                Display.setResizable(true);
                Display.create();
                GL11.glMatrixMode(GL11.GL_PROJECTION);
                GL11.glLoadIdentity();
                GL11.glOrtho(0, 1, 1, 0, 1, -1);
                GL11.glMatrixMode(GL11.GL_MODELVIEW);

                VGraphics g = new VGraphics();

                Random r = new Random();

                while (!Display.isCloseRequested()) {

                    GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);
                    GL11.glEnable(GL11.GL_TEXTURE_2D); // ?  ? ? ?.
                    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
                    GL11.glEnable(GL11.GL_BLEND);
                    WIDTH = Display.getWidth();
                    HEIGHT = Display.getHeight();
                    vgm.render(g);

                    Display.update();
                }
                Display.destroy();
                System.exit(0);
            } catch (LWJGLException ex) {
                Logger.getLogger(VGraphics.class.getName()).log(Level.SEVERE, null, ex);
            } catch (IOException ex) {
                Logger.getLogger(VGraphics.class.getName()).log(Level.SEVERE, null, ex);
            }
        }

    };
    renderingThread.setPriority(Thread.MAX_PRIORITY);
    renderingThread.start();

}

From source file:voxicity.Renderer.java

License:Open Source License

public void render() {
    lock.lock();/*w ww  . j  ava  2  s  .  c o m*/

    quads = 0;
    draw_calls = 0;
    batch_draw_calls = 0;

    GL11.glLoadIdentity();
    GLU.gluLookAt(camera.pos.x, camera.pos.y, camera.pos.z, camera.pos.x + camera.look.x,
            camera.pos.y + camera.look.y, camera.pos.z + camera.look.z, camera.up.x, camera.up.y, camera.up.z);

    GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);

    for (ChunkNode.Batch batch : batches)
        render_batch(batch);

    GL11.glFlush();

    lock.unlock();
}

From source file:voxicity.Renderer.java

License:Open Source License

void setup_camera(float fov, float ratio, float view_distance) {
    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glLoadIdentity();
    GLU.gluPerspective(fov, ratio, 0.01f, view_distance);
    GL11.glMatrixMode(GL11.GL_MODELVIEW);

    camera.set_attribs(fov, ratio, 0.01f, view_distance);
}

From source file:yk.myengine.optiseq.states.LWJGLFont.java

/**
 * <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.
 *
 * @param x      the x screen location to start the string render.
 * @param y      the y screen location to start the string render.
 * @param scale  scale//w  ww . jav  a 2  s  .c  om
 * @param text   the String to render.
 * @param italic the mode of font: NORMAL or ITALICS.
 */
public void print(final int x, final int y, final Vector3f scale, final String text, int italic) {
    //        RendererRecord matRecord = (RendererRecord) DisplaySystem.getDisplaySystem().getCurrentContext().getRendererRecord();
    if (italic > 1) {
        italic = 1;
    } else if (italic < 0) {
        italic = 0;
    }

    //        if (!alreadyOrtho){
    //todo move to outer function
    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glPushMatrix();
    GL11.glLoadIdentity();
    GLU.gluOrtho2D(0, Display.getDisplayMode().getWidth(), 0, Display.getDisplayMode().getHeight());
    //        }
    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glPushMatrix();
    GL11.glLoadIdentity();
    GL11.glTranslatef(x, y, 0);
    GL11.glScalef(scale.x, scale.y, scale.z);
    //todo: make italic by matrix, instead of additional data!! (matter of principle)
    //also it must be realized in transformation state together with scale factor!
    GL11.glListBase(base - 32 + (128 * italic));

    //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.x, fontColor.y, fontColor.z, fontColor.w);
    //todo move to right place
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glDisable(GL11.GL_DEPTH_TEST);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    //call the list for each letter in the string.
    GL11.glCallLists(scratch);
    GL11.glDisable(GL11.GL_BLEND);
    //        set color back to white
    //        GL11.glColor4f(fontColor.x, fontColor.y, fontColor.z, fontColor.w);

    //        if (!alreadyOrtho) {
    //todo move to outer function
    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glPopMatrix();
    //        }
    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glPopMatrix();
}

From source file:zildo.fwk.gfx.filter.BilinearFilter.java

License:Open Source License

@Override
public boolean renderFilter() {
    fbo.endRendering();//  w w w  .  j a v  a  2s  .com

    // Select right texture
    GL11.glBindTexture(GL11.GL_TEXTURE_2D, textureID);
    // Disable blend
    GL11.glDisable(GL11.GL_BLEND);

    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glLoadIdentity();
    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glPushMatrix();
    GL11.glTranslatef(0, -sizeY, 1);

    GL11.glColor3f(1.0f, 1.0f, 1.0f);

    // Draw texture with depth
    super.render();

    GL11.glPopMatrix();

    GL11.glMatrixMode(GL11.GL_MODELVIEW);

    return true;
}