Example usage for org.lwjgl.opengl GL11 GL_MODELVIEW

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

Introduction

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

Prototype

int GL_MODELVIEW

To view the source code for org.lwjgl.opengl GL11 GL_MODELVIEW.

Click Source Link

Document

MatrixMode

Usage

From source file:net.malisis.doors.door.renderer.ForcefieldRenderer.java

License:Open Source License

private void setTextureMatrix() {
    long elapsed = ar.getElapsedTime() / 50;
    int n = (int) (elapsed % 50);

    bindTexture(rl[n]);//from www  .j a  v a  2  s .com
    GL11.glMatrixMode(GL11.GL_TEXTURE);
    GL11.glLoadIdentity();

    AxisAlignedBB aabb = tileEntity.getMultiBlock().getBounds();
    double scaleX = 1, scaleY = 1;
    if (direction == ForgeDirection.UP) {
        scaleX = aabb.maxX - aabb.minX;
        scaleY = aabb.maxZ - aabb.minZ;

        if (aabb.maxZ - aabb.minZ > aabb.maxX - aabb.minX)
            GL11.glRotatef(90, 0, 0, 1);
    } else {
        scaleY = aabb.maxY - aabb.minY;
        if (direction == ForgeDirection.EAST)
            scaleX = aabb.maxZ - aabb.minZ;
        else if (direction == ForgeDirection.NORTH)
            scaleX = aabb.maxX - aabb.minX;
    }

    //GL11.glTranslatef(fx, fy, 0);
    GL11.glScaled(scaleX / 3, scaleY / 3, 1);

    GL11.glMatrixMode(GL11.GL_MODELVIEW);
}

From source file:net.minecraftforge.client.CloudRenderer.java

License:Open Source License

public boolean render(int cloudTicks, float partialTicks) {
    if (!isBuilt())
        return false;

    Entity entity = mc.getRenderViewEntity();

    double totalOffset = cloudTicks + partialTicks;

    double x = entity.prevPosX + (entity.posX - entity.prevPosX) * partialTicks + totalOffset * 0.03;
    double y = mc.world.provider.getCloudHeight()
            - (entity.lastTickPosY + (entity.posY - entity.lastTickPosY) * partialTicks) + 0.33;
    double z = entity.prevPosZ + (entity.posZ - entity.prevPosZ) * partialTicks;

    int scale = getScale();

    if (cloudMode == 2)
        z += 0.33 * scale;/*from  w  w w  .j av  a2s.c o  m*/

    // Integer UVs to translate the texture matrix by.
    int offU = fullCoord(x, scale);
    int offV = fullCoord(z, scale);

    GlStateManager.pushMatrix();

    // Translate by the remainder after the UV offset.
    GlStateManager.translate((offU * scale) - x, y, (offV * scale) - z);

    // Modulo to prevent texture samples becoming inaccurate at extreme offsets.
    offU = offU % texW;
    offV = offV % texH;

    // Translate the texture.
    GlStateManager.matrixMode(GL11.GL_TEXTURE);
    GlStateManager.translate(offU * PX_SIZE, offV * PX_SIZE, 0);
    GlStateManager.matrixMode(GL11.GL_MODELVIEW);

    GlStateManager.disableCull();

    GlStateManager.enableBlend();
    GlStateManager.tryBlendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA,
            GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE,
            GlStateManager.DestFactor.ZERO);

    // Color multiplier.
    Vec3d color = mc.world.getCloudColour(partialTicks);
    float r = (float) color.x;
    float g = (float) color.y;
    float b = (float) color.z;

    if (mc.gameSettings.anaglyph) {
        float tempR = r * 0.3F + g * 0.59F + b * 0.11F;
        float tempG = r * 0.3F + g * 0.7F;
        float tempB = r * 0.3F + b * 0.7F;
        r = tempR;
        g = tempG;
        b = tempB;
    }

    if (COLOR_TEX == null)
        COLOR_TEX = new DynamicTexture(1, 1);

    // Apply a color multiplier through a texture upload if shaders aren't supported.
    COLOR_TEX.getTextureData()[0] = 255 << 24 | ((int) (r * 255)) << 16 | ((int) (g * 255)) << 8
            | (int) (b * 255);
    COLOR_TEX.updateDynamicTexture();

    GlStateManager.setActiveTexture(OpenGlHelper.lightmapTexUnit);
    GlStateManager.bindTexture(COLOR_TEX.getGlTextureId());
    GlStateManager.enableTexture2D();

    // Bind the clouds texture last so the shader's sampler2D is correct.
    GlStateManager.setActiveTexture(OpenGlHelper.defaultTexUnit);
    mc.renderEngine.bindTexture(texture);

    ByteBuffer buffer = Tessellator.getInstance().getBuffer().getByteBuffer();

    // Set up pointers for the display list/VBO.
    if (OpenGlHelper.useVbo()) {
        vbo.bindBuffer();

        int stride = FORMAT.getNextOffset();
        GlStateManager.glVertexPointer(3, GL11.GL_FLOAT, stride, 0);
        GlStateManager.glEnableClientState(GL11.GL_VERTEX_ARRAY);
        GlStateManager.glTexCoordPointer(2, GL11.GL_FLOAT, stride, 12);
        GlStateManager.glEnableClientState(GL11.GL_TEXTURE_COORD_ARRAY);
        GlStateManager.glColorPointer(4, GL11.GL_UNSIGNED_BYTE, stride, 20);
        GlStateManager.glEnableClientState(GL11.GL_COLOR_ARRAY);
    } else {
        buffer.limit(FORMAT.getNextOffset());
        for (int i = 0; i < FORMAT.getElementCount(); i++)
            FORMAT.getElements().get(i).getUsage().preDraw(FORMAT, i, FORMAT.getNextOffset(), buffer);
        buffer.position(0);
    }

    // Depth pass to prevent insides rendering from the outside.
    GlStateManager.colorMask(false, false, false, false);
    if (OpenGlHelper.useVbo())
        vbo.drawArrays(GL11.GL_QUADS);
    else
        GlStateManager.callList(displayList);

    // Full render.
    if (!mc.gameSettings.anaglyph) {
        GlStateManager.colorMask(true, true, true, true);
    } else {
        switch (EntityRenderer.anaglyphField) {
        case 0:
            GlStateManager.colorMask(false, true, true, true);
            break;
        case 1:
            GlStateManager.colorMask(true, false, false, true);
            break;
        }
    }

    // Wireframe for debug.
    if (WIREFRAME) {
        GlStateManager.glPolygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_LINE);
        GlStateManager.glLineWidth(2.0F);
        GlStateManager.disableTexture2D();
        GlStateManager.depthMask(false);
        GlStateManager.disableFog();
        if (OpenGlHelper.useVbo())
            vbo.drawArrays(GL11.GL_QUADS);
        else
            GlStateManager.callList(displayList);
        GlStateManager.glPolygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_FILL);
        GlStateManager.depthMask(true);
        GlStateManager.enableTexture2D();
        GlStateManager.enableFog();
    }

    if (OpenGlHelper.useVbo()) {
        vbo.drawArrays(GL11.GL_QUADS);
        vbo.unbindBuffer(); // Unbind buffer and disable pointers.
    } else {
        GlStateManager.callList(displayList);
    }

    buffer.limit(0);
    for (int i = 0; i < FORMAT.getElementCount(); i++)
        FORMAT.getElements().get(i).getUsage().postDraw(FORMAT, i, FORMAT.getNextOffset(), buffer);
    buffer.position(0);

    // Disable our coloring.
    GlStateManager.setActiveTexture(OpenGlHelper.lightmapTexUnit);
    GlStateManager.disableTexture2D();
    GlStateManager.setActiveTexture(OpenGlHelper.defaultTexUnit);

    // Reset texture matrix.
    GlStateManager.matrixMode(GL11.GL_TEXTURE);
    GlStateManager.loadIdentity();
    GlStateManager.matrixMode(GL11.GL_MODELVIEW);

    GlStateManager.disableBlend();
    GlStateManager.enableCull();

    GlStateManager.popMatrix();

    return true;
}

From source file:net.phatcode.rel.multimedia.Renderer.java

License:Open Source License

Renderer(int screenWidth, int screenHeight) {
    try {/*from w  w w .j  av  a2 s  .c om*/
        Display.setDisplayMode(new DisplayMode(screenWidth, screenHeight));
        Display.create();
        Display.setTitle("AnyaBasic 0.4.0 beta");
    } catch (LWJGLException e) {
        e.printStackTrace();
    }

    this.screenWidth = screenWidth;
    this.screenHeight = screenHeight;

    GL11.glViewport(0, 0, screenWidth, screenHeight);

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

    GL11.glOrtho(0, screenWidth, screenHeight, 0, 1, -1);
    GL11.glMatrixMode(GL11.GL_MODELVIEW);

    GL11.glLoadIdentity();

    GL11.glShadeModel(GL11.GL_SMOOTH); //set shading to smooth(try GL_FLAT)
    GL11.glClearColor(0.0f, 0.0f, 0.0f, 1.0f); //set Clear color to BLACK
    GL11.glClearDepth(1.0f); //Set Depth buffer to 1(z-Buffer)
    GL11.glDisable(GL11.GL_DEPTH_TEST); //Disable Depth Testing so that our z-buffer works

    GL11.glDepthFunc(GL11.GL_LEQUAL);

    GL11.glEnable(GL11.GL_COLOR_MATERIAL);

    GL11.glEnable(GL11.GL_TEXTURE_2D);

    GL11.glEnable(GL11.GL_ALPHA_TEST);
    GL11.glAlphaFunc(GL11.GL_GREATER, 0);

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

    GL11.glHint(GL11.GL_PERSPECTIVE_CORRECTION_HINT, GL11.GL_NICEST);

    GL11.glDisable(GL11.GL_CULL_FACE);

    GL11.glPolygonMode(GL11.GL_FRONT, GL11.GL_FILL);

    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glLoadIdentity();
    GL11.glTranslatef(0.375f, 0.375f, 0); // magic trick

}

From source file:net.slimevoid.tmf.client.renderers.ItemRendererToolBelt.java

License:Open Source License

private void renderItem(EntityLivingBase entityliving, ItemStack itemstack, int index,
        TextureManager texturemanager) {
    GL11.glPushMatrix();/* w  ww . ja va 2  s .c o  m*/
    IIcon icon = entityliving.getItemIcon(itemstack, index);

    if (icon == null) {
        GL11.glPopMatrix();
        return;
    }

    texturemanager.bindTexture(texturemanager.getResourceLocation(itemstack.getItemSpriteNumber()));
    Tessellator tessellator = Tessellator.instance;
    float f = icon.getMinU();
    float f1 = icon.getMaxU();
    float f2 = icon.getMinV();
    float f3 = icon.getMaxV();
    float f4 = 0.0F;
    float f5 = 0.3F;
    GL11.glEnable(GL12.GL_RESCALE_NORMAL);
    /*
     * GL11.glTranslatef( -f4, -f5, 0.0F); float f6 = 1.5F; GL11.glScalef(
     * f6, f6, f6); GL11.glRotatef( 50.0F, 0.0F, 1.0F, 0.0F);
     * GL11.glRotatef( 335.0F, 0.0F, 0.0F, 1.0F); GL11.glTranslatef(
     * -0.9375F, -0.0625F, 0.0F);
     */
    ItemRenderer.renderItemIn2D(tessellator, f1, f2, f, f3, icon.getIconWidth(), icon.getIconHeight(), 0.0625F);

    if (itemstack.hasEffect(index)) {
        GL11.glDepthFunc(GL11.GL_EQUAL);
        GL11.glDisable(GL11.GL_LIGHTING);
        texturemanager.bindTexture(RES_ITEM_GLINT);
        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);
        ItemRenderer.renderItemIn2D(tessellator, 0.0F, 0.0F, 1.0F, 1.0F, 256, 256, 0.0625F);
        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);
        ItemRenderer.renderItemIn2D(tessellator, 0.0F, 0.0F, 1.0F, 1.0F, 256, 256, 0.0625F);
        GL11.glPopMatrix();
        GL11.glMatrixMode(GL11.GL_MODELVIEW);
        GL11.glDisable(GL11.GL_BLEND);
        GL11.glEnable(GL11.GL_LIGHTING);
        GL11.glDepthFunc(GL11.GL_LEQUAL);
    }
    GL11.glPopMatrix();
}

From source file:net.smert.frameworkgl.opengl.OpenGL1.java

License:Apache License

public OpenGL1 setModelViewIdentity() {
    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glLoadIdentity();
    return this;
}

From source file:net.smert.frameworkgl.opengl.OpenGL1.java

License:Apache License

public OpenGL1 switchModelView() {
    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    return this;
}

From source file:nightkosh.gravestone.models.block.ModelCreeperStatue.java

License:LGPL

private void renderCreeperCharging() {
    float tickModifier = (float) (Minecraft.getSystemTime() % 3000L) / 3000 * 48;
    float scale = 1.2F;

    GL11.glTranslated(0, 0.3, 0);// w  w w.  jav a 2 s . co m
    GL11.glScalef(scale, scale, scale);
    TileEntityGraveStoneRenderer.instance.bindTextureByName(Resources.CREEPER_AURA);

    GlStateManager.depthMask(true);
    GlStateManager.matrixMode(GL11.GL_TEXTURE);
    GlStateManager.enableBlend();
    GlStateManager.disableLighting();
    GlStateManager.blendFunc(GL11.GL_SRC_COLOR, GL11.GL_ONE);

    for (int var21 = 0; var21 < 3; var21++) {
        GlStateManager.loadIdentity();
        float var23 = tickModifier * (0.001F + (float) var21 * 0.0015F) * 15;
        GL11.glTranslatef(0, var23, 0);
        renderCreeper();
    }

    GlStateManager.matrixMode(GL11.GL_TEXTURE);
    GlStateManager.loadIdentity();
    GlStateManager.matrixMode(GL11.GL_MODELVIEW);
    GlStateManager.enableLighting();
    GlStateManager.disableBlend();
    GlStateManager.depthFunc(GL11.GL_LEQUAL);
    GlStateManager.blendFunc(GL11.GL_ONE, GL11.GL_ONE);
}

From source file:nightkosh.gravestone.models.block.ModelGraveStone.java

License:LGPL

protected void renderEnchantment() {
    float tickModifier = (float) (Minecraft.getSystemTime() % 3000L) / 3000F * 48;
    TileEntityGraveStoneRenderer.instance.bindTextureByName(Resources.SWORD_AURA);

    GlStateManager.enableBlend();/* w ww.java 2 s.c om*/
    GlStateManager.depthFunc(GL11.GL_EQUAL);
    GlStateManager.depthMask(false);
    float color = 0.5F;
    GlStateManager.color(color, color, color, 1);

    for (int i = 0; i < 3; i++) {
        GlStateManager.disableLighting();
        GlStateManager.blendFunc(GL11.GL_SRC_COLOR, GL11.GL_ONE);
        float color2 = 0.76F;
        GlStateManager.color(0.5F * color2, 0.25F * color2, 0.8F * color2, 1);
        GlStateManager.matrixMode(GL11.GL_TEXTURE);
        GlStateManager.loadIdentity();

        float var23 = tickModifier * (0.001F + i * 0.0015F) * 15;
        float scale = 0.33F;
        GlStateManager.scale(scale, scale, scale);
        GlStateManager.rotate(30 - i * 60, 0, 0, 1);
        GlStateManager.translate(0, var23, 0);
        GlStateManager.matrixMode(GL11.GL_MODELVIEW);

        renderAll();
    }

    GlStateManager.matrixMode(GL11.GL_TEXTURE);
    GlStateManager.loadIdentity();
    GlStateManager.matrixMode(GL11.GL_MODELVIEW);
    GlStateManager.enableLighting();
    GlStateManager.depthMask(true);
    GlStateManager.depthFunc(GL11.GL_LEQUAL);
    GlStateManager.disableBlend();
}

From source file:nightkosh.gravestone_extended.models.block.memorials.ModelCreeperStatueMemorial.java

License:LGPL

private void renderCreeperCharging() {
    float tickModifier = (float) (Minecraft.getSystemTime() % 3000L) / 3000 * 48;
    float scale = 1.2F;
    float f4 = 0.5F;

    GL11.glTranslated(0, -0.5, 0);//from w  w  w  .  j av a2s.co m
    GL11.glScalef(scale, scale, scale);
    TileEntityMemorialRenderer.instance.bindTextureByName(Resources.CREEPER_AURA);

    GlStateManager.depthMask(true);
    GlStateManager.matrixMode(GL11.GL_TEXTURE);
    GlStateManager.enableBlend();
    GlStateManager.disableLighting();
    GlStateManager.blendFunc(GL11.GL_SRC_COLOR, GL11.GL_ONE);

    for (int var21 = 0; var21 < 3; ++var21) {
        GlStateManager.loadIdentity();
        float var23 = tickModifier * (0.001F + (float) var21 * 0.0015F) * 15;
        GL11.glTranslatef(0, var23, 0);
        renderCreeper();
    }

    GlStateManager.matrixMode(GL11.GL_TEXTURE);
    GlStateManager.loadIdentity();
    GlStateManager.matrixMode(GL11.GL_MODELVIEW);
    GlStateManager.enableLighting();
    GlStateManager.disableBlend();
    GlStateManager.depthFunc(GL11.GL_LEQUAL);
    GlStateManager.blendFunc(GL11.GL_ONE, GL11.GL_ONE);

    GL11.glTranslated(0, -0.19, 0);
}

From source file:org.agpu.oc.common.tileentity.AdvancedMonitor.java

public void startDrawing3D(int x, int y, int width, int height, float fov, float zNear, float zFar) {
    if (worldObj.isRemote) {
        GL30.glBindFramebuffer(GL30.GL_FRAMEBUFFER, frameBufferID);

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

        GL11.glMatrixMode(GL11.GL_PROJECTION);
        GL11.glPushMatrix();/*from  w ww .  j  av a 2s  .  co  m*/
        GL11.glLoadIdentity();
        GLU.gluPerspective(fov, (float) width / (float) height, zNear, zFar);

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

        GL11.glClearColor(cr, cg, cb, ca);
        GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);
    }
}