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:arg.RenderRecipe.java

License:Open Source License

public void draw() {

    File dir = new File(Minecraft.getMinecraft().mcDataDir, "recipes");
    if (!dir.exists() && !dir.mkdirs()) {
        throw new RuntimeException("The recipes directory could not be created: " + dir);
    }/*from w ww  .ja v  a2s  . c o  m*/

    name = name.replace(" ", "");
    File file = new File(Minecraft.getMinecraft().mcDataDir, "recipes/" + name + ".png");

    if (file.exists())
        return;

    GL11.glPushMatrix();
    GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS);
    GL11.glPushClientAttrib(GL11.GL_ALL_CLIENT_ATTRIB_BITS);
    GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);

    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glLoadIdentity();
    GL11.glViewport(0, 0, width, height);
    GL11.glOrtho(0.0D, xSize, ySize, 0.0D, 1000.0D, 3000.0D);
    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glLoadIdentity();
    GL11.glTranslatef(0.0F, 0.0F, -2000.0F);
    GL11.glLineWidth(1.0F);

    GL11.glEnable(GL11.GL_COLOR_MATERIAL);

    try {
        drawScreen(0, 0, 0);
    } catch (Exception e) {
        e.printStackTrace();
    }

    int[] pixels = new int[width * height];
    int bindex;

    ByteBuffer fb = ByteBuffer.allocateDirect(width * height * 3);

    GL11.glReadPixels(0, 0, width, height, GL11.GL_RGB, GL11.GL_UNSIGNED_BYTE, fb);
    GL11.glPopMatrix();
    GL11.glPopAttrib();
    GL11.glPopClientAttrib();
    GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);
    try {
        Display.swapBuffers();
    } catch (LWJGLException e1) {
        e1.printStackTrace();
    }

    BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);

    for (int x = 0; x < width; x++) {
        for (int y = 0; y < height; y++) {
            int i = (x + (width * y)) * 3;
            int r = fb.get(i) & 0xFF;
            int g = fb.get(i + 1) & 0xFF;
            int b = fb.get(i + 2) & 0xFF;
            image.setRGB(x, height - (y + 1), (0xFF << 24) | (r << 16) | (g << 8) | b);
        }
    }

    try {
        ImageIO.write(image, "png", file);
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:br.org.archimedes.gui.opengl.OpenGLWrapper.java

License:Open Source License

/**
 * Clears the OpenGL canvas.//  ww  w.j  a  v a 2  s . c o m
 */
public void clear() {
    Color currentBkColor = br.org.archimedes.Utils.getWorkspace().getBackgroundColor();
    GL11.glClearColor((float) currentBkColor.getR(), (float) currentBkColor.getG(),
            (float) currentBkColor.getB(), 0);

    GL11.glClear(GL11.GL_COLOR_BUFFER_BIT);
    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glLoadIdentity();
    resize();
}

From source file:cellularautomata.CellularAutomata.java

public static void renderGL() {
    try { //Trys to create a game window size 500x700.
        Display.setDisplayMode(new org.lwjgl.opengl.DisplayMode(800, 600));
        Display.create();/*w w w . ja v  a2 s  .com*/
    } catch (LWJGLException e) { //Catches exception if game window is not created.
        e.printStackTrace();
        System.exit(0);
    }

    GL11.glEnable(GL11.GL_TEXTURE_2D);
    GL11.glShadeModel(GL11.GL_SMOOTH);
    GL11.glDisable(GL11.GL_DEPTH_TEST);
    GL11.glDisable(GL11.GL_LIGHTING);

    GL11.glClearColor(0.0f, 0.0f, 0.0f, 0.0f); //Sets colour to white.
    GL11.glClearDepth(1);

    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);

    GL11.glViewport(0, 0, 800, 600);
    GL11.glMatrixMode(GL11.GL_MODELVIEW);

    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glLoadIdentity();
    GL11.glOrtho(0, 800, 600, 0, 1, -1);
    GL11.glMatrixMode(GL11.GL_MODELVIEW);

    Display.setVSyncEnabled(vsync);
}

From source file:cn.academy.ability.electro.client.render.skill.RailgunPlaneEffect.java

License:Open Source License

@SideOnly(Side.CLIENT)
@Override//from   w  ww.j  a  va2s .co m
public void renderHandEffect(EntityPlayer player, HandRenderType type, long dt) {
    if (type == HandRenderType.EQUIPPED)
        return;
    if (dt < DELAY)
        return;
    dt -= DELAY;

    double tz = dt * dt / 3e4;
    double TRANS_TIME = ANIM_LEN * 0.2;
    double alpha = (dt < TRANS_TIME ? dt / TRANS_TIME
            : (dt > ANIM_LEN - TRANS_TIME ? (ANIM_LEN - dt) / TRANS_TIME : 1));

    //Draw a screen-filling blackout
    GL11.glDisable(GL11.GL_TEXTURE_2D);
    GL11.glDisable(GL11.GL_CULL_FACE);

    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glPushMatrix();
    GL11.glLoadIdentity();
    GLU.gluOrtho2D(0, 255, 0, 255);

    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glPushMatrix();
    GL11.glDepthMask(false);
    GL11.glLoadIdentity();
    {
        GL11.glTranslated(0, 0, 0);
        GL11.glColor4d(0, 0, 0, 0.2 * alpha);
        HudUtils.setZLevel(1);
        HudUtils.drawModalRect(0, 0, 255, 255);
        HudUtils.setZLevel(-90);
    }
    GL11.glDepthMask(true);

    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glPopMatrix();

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

    GL11.glEnable(GL11.GL_TEXTURE_2D);
    GL11.glEnable(GL11.GL_CULL_FACE);
    GL11.glMatrixMode(GL11.GL_MODELVIEW); //Restore the matrix

    //Draw the real effect

    GL11.glColor4d(1, 1, 1, alpha * 0.6);
    GL11.glEnable(GL11.GL_ALPHA_TEST);
    GL11.glAlphaFunc(GL11.GL_GREATER, 0.0f);
    GL11.glPushMatrix();
    {
        GL11.glTranslated(-.4, 0.85 + tz * 0.37, tz);
        GL11.glRotated(-20.4, 1, 0, 0);

        drawSingleSide(7);

        //         GL11.glPushMatrix(); {
        //            GL11.glTranslated(-2.3, 0, 0);
        //            drawSingleSide(7);
        //         } GL11.glPopMatrix();
    }
    GL11.glPopMatrix();

    GL11.glDisable(GL11.GL_ALPHA_TEST);
}

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  www .  j  a  v  a 2 s.c om*/
        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.lambdalib.util.client.RenderUtils.java

License:MIT License

public static void drawBlackout() {
    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glDisable(GL11.GL_CULL_FACE);/*from  ww  w .j a v  a2s  .  c  om*/
    GL11.glDisable(GL11.GL_DEPTH_TEST);
    GL11.glPushMatrix();
    GL11.glLoadIdentity();
    GLU.gluOrtho2D(1, 0, 1, 0);

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

    GL11.glColor4d(0, 0, 0, 0.7);
    GL11.glTranslated(0, 0, 0);
    HudUtils.colorRect(0, 0, 1, 1);

    GL11.glPopMatrix();

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

    GL11.glEnable(GL11.GL_TEXTURE_2D);
    GL11.glColor4d(1, 1, 1, 1);

    GL11.glEnable(GL11.GL_DEPTH_TEST);
    GL11.glEnable(GL11.GL_CULL_FACE);
    GL11.glMatrixMode(GL11.GL_MODELVIEW);
}

From source file:cn.liutils.api.gui.Widget.java

License:Open Source License

/**
 * Should be called at this widget's draw() function.
 *//*from   w ww  . ja v a 2 s.co  m*/
protected void drawBlackout() {

    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glDisable(GL11.GL_CULL_FACE);
    GL11.glPushMatrix();
    GL11.glLoadIdentity();
    GLU.gluOrtho2D(1, 0, 1, 0);

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

    GL11.glColor4d(0, 0, 0, 0.6);
    HudUtils.setZLevel(-1);
    HudUtils.drawModalRect(0, 0, 1, 1);

    GL11.glPopMatrix();

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

    GL11.glEnable(GL11.GL_TEXTURE_2D);
    RenderUtils.bindIdentity();

    GL11.glEnable(GL11.GL_CULL_FACE);
    GL11.glMatrixMode(GL11.GL_MODELVIEW);
}

From source file:colonialdisplay.AntDisplayGL.java

@Override
protected void initGL() {
    Rectangle bounds = canvas.getClientArea();
    GL11.glViewport(bounds.x, bounds.y, bounds.width, bounds.height);

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

    GL11.glOrtho(0, bounds.width, bounds.height, 0, 1, -1);

    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glLoadIdentity();//from w w  w .  ja v a2  s . c o m
    initTextures();
    GL11.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
    createModel();
}

From source file:com.a2client.corex.Material.java

License:Open Source License

public void bind() {
    Material mat = ModeMat.get(Render.Mode);
    if (mat != null) {
        Render.setCullFace(params.CullFace);
        Render.setBlendType(params.BlendType);
        Render.setDepthWrite(params.DepthWrite);
        Render.setAlphaTest(params.AlphaTest);

        if (shader != null) {
            shader.bind();/*w  w  w . j  ava  2 s  . co  m*/
            uniform[muModelMatrix_idx].setValue(Render.ModelMatrix);

            if (Render.Mode == RENDER_MODE.rmOpaque || Render.Mode == RENDER_MODE.rmOpacity) {
                GL13.glActiveTexture(GL13.GL_TEXTURE0);
                GL11.glMatrixMode(GL11.GL_TEXTURE);
                GL11.glLoadIdentity();

                GL11.glMatrixMode(GL11.GL_MODELVIEW);

                //   ?   ??  ?    
                // ?     ? ?
                uniform[muLightPos_idx].setValue(Render.um_light_pos);
                uniform[muLightParam_idx].setValue(Render.um_light_param);
                uniform[muViewPos_idx].setValue(Render.view_pos);
                uniform[muAmbient_idx].setValue(Render.ambient);
                uniform[muTexOffset_idx].setValue(Render.tex_offset);
                uniform[muFog_idx].setValue(Render.fog);

                uniform[muMaterial_idx].setValue(params.Uniform);

                if (params.ReceiveShadow) {
                    uniform[muLightMatrix_idx].setValue(Render.lights[0].matrix);
                    textures[SamplerID[MATERIAL_SAMPLER.msShadow.ordinal()].ID] = Render.lights[0].shadow_map;
                }

            } else if (Render.Mode == RENDER_MODE.rmShadow) {
                uniform[muLightPos_idx].setValue(Render.lights[0].pos);
                // TODO : shadow mode
                // ???? Uniform[muMaterial].Value(Params.Uniform, 1);   ??  4f  ? diffuse
                uniform[muMaterial_idx].setValue(params.Diffuse);
            }
        }

        for (int i = 0; i < textures.length; i++) {
            if (textures[i] != null)
                textures[i].bind(i);
        }
    }
}

From source file:com.a2client.corex.Render.java

License:Open Source License

static public void set2D(int width, int height) {
    ResetBind();/*from www . j a v  a2 s  . c  o  m*/
    Clear(false, true);
    setBlendType(Const.BLEND_TYPE.btNormal);
    setDepthTest(false);
    setCullFace(Const.CULL_FACE.cfNone);

    GL11.glEnable(GL11.GL_TEXTURE_2D);
    GL11.glDisable(GL11.GL_LIGHTING);

    setDepthTest(false);

    GL11.glViewport(0, 0, width, height);

    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glLoadIdentity();
    GL11.glOrtho(0, width, height, 0, -1, 1);

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