Example usage for org.lwjgl.opengl GL11 glMatrixMode

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

Introduction

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

Prototype

public static native void glMatrixMode(@NativeType("GLenum") int mode);

Source Link

Document

Set the current matrix mode.

Usage

From source file:cn.liutils.util.RenderUtils.java

License:Open Source License

public static void renderOverlay_Equip(ResourceLocation src) {
    //Setup/* w  w w.  java 2s  .c o  m*/
    GL11.glDepthFunc(GL11.GL_EQUAL);
    GL11.glDisable(GL11.GL_LIGHTING);
    loadTexture(src);
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_SRC_COLOR, GL11.GL_ONE);
    float f7 = 0.76F;
    GL11.glMatrixMode(GL11.GL_TEXTURE);
    //Push texture mat
    GL11.glPushMatrix();
    float f8 = 0.125F;
    GL11.glScalef(f8, f8, f8);
    float f9 = Minecraft.getSystemTime() % 3000L / 3000.0F * 8.0F;
    GL11.glTranslatef(f9, 0.0F, 0.0F); //xOffset loops between 0.0 and 8.0
    GL11.glRotatef(-50.0F, 0.0F, 0.0F, 1.0F);
    ItemRenderer.renderItemIn2D(t, 0.0F, 0.0F, 1.0F, 1.0F, 256, 256, 0.0625F);
    GL11.glPopMatrix();

    //Second pass
    GL11.glPushMatrix();
    GL11.glScalef(f8, f8, f8);
    f9 = Minecraft.getSystemTime() % 4873L / 4873.0F * 8.0F; //Loop between 0 and 8, longer loop
    GL11.glTranslatef(-f9, 0.0F, 0.0F); //Still xOffset
    GL11.glRotatef(10.0F, 0.0F, 0.0F, 1.0F); //However, different rotation!
    ItemRenderer.renderItemIn2D(t, 0.0F, 0.0F, 1.0F, 1.0F, 256, 256, 0.0625F);
    GL11.glPopMatrix();
    //Pop texture mat
    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glDisable(GL11.GL_BLEND);
    GL11.glEnable(GL11.GL_LIGHTING);
    GL11.glDepthFunc(GL11.GL_LEQUAL);
}

From source file:cn.liutils.util.RenderUtils.java

License:Open Source License

public static void renderOverlay_Inv(ResourceLocation src) {
    GL11.glDepthFunc(GL11.GL_EQUAL);//w ww.java  2 s . c  o m
    GL11.glDisable(GL11.GL_LIGHTING);
    loadTexture(src);
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_SRC_COLOR, GL11.GL_ONE);
    float f7 = 0.76F;
    //GL11.glColor4f(0.5F * f7, 0.25F * f7, 0.8F * f7, 1.0F);
    GL11.glMatrixMode(GL11.GL_TEXTURE);
    GL11.glPushMatrix();
    float f8 = 0.125F;
    GL11.glScalef(f8, f8, f8);
    float f9 = Minecraft.getSystemTime() % 3000L / 3000.0F * 8.0F;
    GL11.glTranslatef(f9, 0.0F, 0.0F);
    GL11.glRotatef(-50.0F, 0.0F, 0.0F, 1.0F);
    t.startDrawingQuads();
    t.addVertexWithUV(0.0, 0.0, 0.0, 0.0, 0.0);
    t.addVertexWithUV(0.0, 16.0, 0.0, 0.0, 1.0);
    t.addVertexWithUV(16.0, 16.0, 0.0, 1.0, 1.0);
    t.addVertexWithUV(16.0, 0.0, 0.0, 1.0, 0.0);
    t.draw();
    GL11.glPopMatrix();
    GL11.glPushMatrix();
    GL11.glScalef(f8, f8, f8);
    f9 = Minecraft.getSystemTime() % 4873L / 4873.0F * 8.0F;
    GL11.glTranslatef(-f9, 0.0F, 0.0F);
    GL11.glRotatef(10.0F, 0.0F, 0.0F, 1.0F);
    t.startDrawingQuads();
    t.addVertexWithUV(0.0, 0.0, 0.0, 0.0, 0.0);
    t.addVertexWithUV(0.0, 16.0, 0.0, 0.0, 1.0);
    t.addVertexWithUV(16.0, 16.0, 0.0, 1.0, 1.0);
    t.addVertexWithUV(16.0, 0.0, 0.0, 1.0, 0.0);
    t.draw();
    GL11.glPopMatrix();
    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glDisable(GL11.GL_BLEND);
    GL11.glEnable(GL11.GL_LIGHTING);
    GL11.glDepthFunc(GL11.GL_LEQUAL);
}

From source file:cn.liutils.util.RenderUtils.java

License:Open Source License

public static void renderSimpleOverlay_Inv(ResourceLocation src) {
    //GL11.glDepthFunc(GL11.GL_EQUAL);
    GL11.glDisable(GL11.GL_LIGHTING);//from ww w.  j av  a 2 s .com
    RenderUtils.loadTexture(src);
    t.startDrawingQuads();
    t.addVertexWithUV(0.0, 0.0, 0.0, 0.0, 0.0);
    t.addVertexWithUV(0.0, 16.0, 0.0, 0.0, 1.0);
    t.addVertexWithUV(16.0, 16.0, 0.0, 1.0, 1.0);
    t.addVertexWithUV(16.0, 0.0, 0.0, 1.0, 0.0);
    t.draw();
    GL11.glEnable(GL11.GL_LIGHTING);
    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glDepthFunc(GL11.GL_LEQUAL);
}

From source file:cn.weaponry.api.client.render.RendererWeapon.java

License:Open Source License

private void handleHeldRender(RenderInfo info, boolean firstPerson) {
    GL11.glPushMatrix();//from w w w.  j a va 2 s .  c o m
    model.pushTransformState();
    {

        if (firstPerson) {
            doFirstPersonTansform();
            fpTransform.doTransform();
        } else {
            doThirdPersonTransform();
            tpTransform.doTransform();
        }
        stdTransform.doTransform();
        doFixedTransform();

        info.renderAll(model, firstPerson, 0);

        GL11.glMatrixMode(GL11.GL_TEXTURE);
        GL11.glPushMatrix();
        GL11.glMatrixMode(GL11.GL_MODELVIEW);
        GL11.glPushMatrix();
        info.renderAll(model, firstPerson, 1);
        GL11.glMatrixMode(GL11.GL_TEXTURE);
        GL11.glPopMatrix();
        GL11.glMatrixMode(GL11.GL_MODELVIEW);
        GL11.glPopMatrix();

        GL11.glDisable(GL11.GL_CULL_FACE);

        RenderUtils.loadTexture(texture);
        model.renderAll();
        GL11.glEnable(GL11.GL_CULL_FACE);
    }
    model.popTransformState();
    GL11.glPopMatrix();
}

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();//from w w w .  j  av  a 2  s . co m

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

    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glLoadIdentity();
    initTextures();
    GL11.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
    createModel();
}

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

License:Open Source License

public void Setup() {
    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glLoadMatrix(ProjMatrix.getBuf());

    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glLoadMatrix(ViewMatrix.getBuf());

    Mat4f m = ViewMatrix.inverse();//from   w  w w  .ja  v a  2s.  c o m
    Render.view_pos = m.getPos();
}

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();/*from  www  .  jav  a 2  s  .  c om*/
            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 ww  w .ja  v  a2 s .  co 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();
}

From source file:com.acornui.jvm.LwjglHelloWorld.java

License:Apache License

private void initMatrices() {
    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glLoadIdentity();
    GL11.glOrtho(0, 800, 0, 600, 1, -1);
    GL11.glMatrixMode(GL11.GL_MODELVIEW);
}

From source file:com.aelitis.azureus.plugins.view3d.ViewTest2.java

License:Open Source License

static void accFrustum(double left, double right, double bottom, double top, double near, double far,
        double pixdx, double pixdy, double eyedx, double eyedy, double focus) {
    double xwsize, ywsize;
    double dx, dy;
    int[] viewport = getViewport();

    xwsize = right - left;//from   ww  w .  ja  v  a  2  s  .  co m
    ywsize = top - bottom;
    dx = -(pixdx * xwsize / (double) viewport[2] + eyedx * near / focus);
    dy = -(pixdy * ywsize / (double) viewport[3] + eyedy * near / focus);

    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glLoadIdentity();
    GL11.glFrustum(left + dx, right + dx, bottom + dy, top + dy, near, far);
    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glLoadIdentity();
    GL11.glTranslated(-eyedx, -eyedy, 0.0);
}