Example usage for org.lwjgl.opengl GL11 GL_FLAT

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

Introduction

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

Prototype

int GL_FLAT

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

Click Source Link

Document

ShadingModel

Usage

From source file:kuake2.render.lwjgl.Mesh.java

License:Open Source License

/**
 * R_DrawAliasModel//from  ww  w. j  av a 2  s .co  m
 */
void R_DrawAliasModel(entity_t e) {
    if ((e.flags & Defines.RF_WEAPONMODEL) == 0) {
        if (R_CullAliasModel(e))
            return;
    }

    if ((e.flags & Defines.RF_WEAPONMODEL) != 0) {
        if (r_lefthand.value == 2.0f)
            return;
    }

    qfiles.dmdl_t paliashdr = (qfiles.dmdl_t) currentmodel.extradata;

    //
    // get lighting information
    //
    // PMM - rewrote, reordered to handle new shells & mixing
    // PMM - 3.20 code .. replaced with original way of doing it to keep mod authors happy
    //
    int i;
    if ((currententity.flags & (Defines.RF_SHELL_HALF_DAM | Defines.RF_SHELL_GREEN | Defines.RF_SHELL_RED
            | Defines.RF_SHELL_BLUE | Defines.RF_SHELL_DOUBLE)) != 0) {
        Math3D.VectorClear(shadelight);
        if ((currententity.flags & Defines.RF_SHELL_HALF_DAM) != 0) {
            shadelight[0] = 0.56f;
            shadelight[1] = 0.59f;
            shadelight[2] = 0.45f;
        }
        if ((currententity.flags & Defines.RF_SHELL_DOUBLE) != 0) {
            shadelight[0] = 0.9f;
            shadelight[1] = 0.7f;
        }
        if ((currententity.flags & Defines.RF_SHELL_RED) != 0)
            shadelight[0] = 1.0f;
        if ((currententity.flags & Defines.RF_SHELL_GREEN) != 0)
            shadelight[1] = 1.0f;
        if ((currententity.flags & Defines.RF_SHELL_BLUE) != 0)
            shadelight[2] = 1.0f;
    } else if ((currententity.flags & Defines.RF_FULLBRIGHT) != 0) {
        for (i = 0; i < 3; i++)
            shadelight[i] = 1.0f;
    } else {
        R_LightPoint(currententity.origin, shadelight);

        // player lighting hack for communication back to server
        // big hack!
        if ((currententity.flags & Defines.RF_WEAPONMODEL) != 0) {
            // pick the greatest component, which should be the same
            // as the mono value returned by software
            if (shadelight[0] > shadelight[1]) {
                if (shadelight[0] > shadelight[2])
                    r_lightlevel.value = 150 * shadelight[0];
                else
                    r_lightlevel.value = 150 * shadelight[2];
            } else {
                if (shadelight[1] > shadelight[2])
                    r_lightlevel.value = 150 * shadelight[1];
                else
                    r_lightlevel.value = 150 * shadelight[2];
            }
        }

        if (gl_monolightmap.string.charAt(0) != '0') {
            float s = shadelight[0];

            if (s < shadelight[1])
                s = shadelight[1];
            if (s < shadelight[2])
                s = shadelight[2];

            shadelight[0] = s;
            shadelight[1] = s;
            shadelight[2] = s;
        }
    }

    if ((currententity.flags & Defines.RF_MINLIGHT) != 0) {
        for (i = 0; i < 3; i++)
            if (shadelight[i] > 0.1f)
                break;
        if (i == 3) {
            shadelight[0] = 0.1f;
            shadelight[1] = 0.1f;
            shadelight[2] = 0.1f;
        }
    }

    if ((currententity.flags & Defines.RF_GLOW) != 0) { // bonus items will pulse with time
        float scale;
        float min;

        scale = (float) (0.1f * Math.sin(r_newrefdef.time * 7));
        for (i = 0; i < 3; i++) {
            min = shadelight[i] * 0.8f;
            shadelight[i] += scale;
            if (shadelight[i] < min)
                shadelight[i] = min;
        }
    }

    // =================
    // PGM   ir goggles color override
    if ((r_newrefdef.rdflags & Defines.RDF_IRGOGGLES) != 0
            && (currententity.flags & Defines.RF_IR_VISIBLE) != 0) {
        shadelight[0] = 1.0f;
        shadelight[1] = 0.0f;
        shadelight[2] = 0.0f;
    }
    // PGM
    // =================

    shadedots = r_avertexnormal_dots[((int) (currententity.angles[1] * (SHADEDOT_QUANT / 360.0)))
            & (SHADEDOT_QUANT - 1)];

    float an = (float) (currententity.angles[1] / 180 * Math.PI);
    shadevector[0] = (float) Math.cos(-an);
    shadevector[1] = (float) Math.sin(-an);
    shadevector[2] = 1;
    Math3D.VectorNormalize(shadevector);

    //
    // locate the proper data
    //

    c_alias_polys += paliashdr.num_tris;

    //
    // draw all the triangles
    //
    if ((currententity.flags & Defines.RF_DEPTHHACK) != 0) // hack the depth range to prevent view model from poking into walls
        GL11.glDepthRange(gldepthmin, gldepthmin + 0.3 * (gldepthmax - gldepthmin));

    if ((currententity.flags & Defines.RF_WEAPONMODEL) != 0 && (r_lefthand.value == 1.0f)) {
        GL11.glMatrixMode(GL11.GL_PROJECTION);
        GL11.glPushMatrix();
        GL11.glLoadIdentity();
        GL11.glScalef(-1, 1, 1);
        MYgluPerspective(r_newrefdef.fov_y, (float) r_newrefdef.width / r_newrefdef.height, 4, 4096);
        GL11.glMatrixMode(GL11.GL_MODELVIEW);

        GL11.glCullFace(GL11.GL_BACK);
    }

    GL11.glPushMatrix();
    e.angles[PITCH] = -e.angles[PITCH]; // sigh.
    R_RotateForEntity(e);
    e.angles[PITCH] = -e.angles[PITCH]; // sigh.

    image_t skin;
    // select skin
    if (currententity.skin != null)
        skin = currententity.skin; // custom player skin
    else {
        if (currententity.skinnum >= qfiles.MAX_MD2SKINS)
            skin = currentmodel.skins[0];
        else {
            skin = currentmodel.skins[currententity.skinnum];
            if (skin == null)
                skin = currentmodel.skins[0];
        }
    }
    if (skin == null)
        skin = r_notexture; // fallback...
    GL_Bind(skin.texnum);

    // draw it

    GL11.glShadeModel(GL11.GL_SMOOTH);

    GL_TexEnv(GL11.GL_MODULATE);
    if ((currententity.flags & Defines.RF_TRANSLUCENT) != 0) {
        GL11.glEnable(GL11.GL_BLEND);
    }

    if ((currententity.frame >= paliashdr.num_frames) || (currententity.frame < 0)) {
        VID.Printf(Defines.PRINT_ALL,
                "R_DrawAliasModel " + currentmodel.name + ": no such frame " + currententity.frame + '\n');
        currententity.frame = 0;
        currententity.oldframe = 0;
    }

    if ((currententity.oldframe >= paliashdr.num_frames) || (currententity.oldframe < 0)) {
        VID.Printf(Defines.PRINT_ALL, "R_DrawAliasModel " + currentmodel.name + ": no such oldframe "
                + currententity.oldframe + '\n');
        currententity.frame = 0;
        currententity.oldframe = 0;
    }

    if (r_lerpmodels.value == 0.0f)
        currententity.backlerp = 0;

    GL_DrawAliasFrameLerp(paliashdr, currententity.backlerp);

    GL_TexEnv(GL11.GL_REPLACE);
    GL11.glShadeModel(GL11.GL_FLAT);

    GL11.glPopMatrix();

    if ((currententity.flags & Defines.RF_WEAPONMODEL) != 0 && (r_lefthand.value == 1.0F)) {
        GL11.glMatrixMode(GL11.GL_PROJECTION);
        GL11.glPopMatrix();
        GL11.glMatrixMode(GL11.GL_MODELVIEW);
        GL11.glCullFace(GL11.GL_FRONT);
    }

    if ((currententity.flags & Defines.RF_TRANSLUCENT) != 0) {
        GL11.glDisable(GL11.GL_BLEND);
    }

    if ((currententity.flags & Defines.RF_DEPTHHACK) != 0)
        GL11.glDepthRange(gldepthmin, gldepthmax);

    if (gl_shadows.value != 0.0f
            && (currententity.flags & (Defines.RF_TRANSLUCENT | Defines.RF_WEAPONMODEL)) == 0) {
        GL11.glPushMatrix();
        R_RotateForEntity(e);
        GL11.glDisable(GL11.GL_TEXTURE_2D);
        GL11.glEnable(GL11.GL_BLEND);
        GL11.glColor4f(0, 0, 0, 0.5f);
        GL_DrawAliasShadow(paliashdr, currententity.frame);
        GL11.glEnable(GL11.GL_TEXTURE_2D);
        GL11.glDisable(GL11.GL_BLEND);
        GL11.glPopMatrix();
    }
    GL11.glColor4f(1, 1, 1, 1);
}

From source file:kuake2.render.lwjgl.Misc.java

License:Open Source License

void GL_SetDefaultState() {
    GL11.glClearColor(1f, 0f, 0.5f, 0.5f); // original quake2
    //GL11.glClearColor(0, 0, 0, 0); // replaced with black
    GL11.glCullFace(GL11.GL_FRONT);/*from   w w w.  ja v  a  2s. com*/
    GL11.glEnable(GL11.GL_TEXTURE_2D);

    GL11.glEnable(GL11.GL_ALPHA_TEST);
    GL11.glAlphaFunc(GL11.GL_GREATER, 0.666f);

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

    GL11.glColor4f(1, 1, 1, 1);

    GL11.glPolygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_FILL);
    GL11.glShadeModel(GL11.GL_FLAT);

    GL_TextureMode(gl_texturemode.string);
    GL_TextureAlphaMode(gl_texturealphamode.string);
    GL_TextureSolidMode(gl_texturesolidmode.string);

    GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, gl_filter_min);
    GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, gl_filter_max);

    GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL11.GL_REPEAT);
    GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL11.GL_REPEAT);

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

    GL_TexEnv(GL11.GL_REPLACE);

    if (qglPointParameterfEXT) {
        // float[] attenuations = { gl_particle_att_a.value, gl_particle_att_b.value, gl_particle_att_c.value };
        FloatBuffer att_buffer = BufferUtils.createFloatBuffer(4);
        att_buffer.put(0, gl_particle_att_a.value);
        att_buffer.put(1, gl_particle_att_b.value);
        att_buffer.put(2, gl_particle_att_c.value);

        GL11.glEnable(GL11.GL_POINT_SMOOTH);
        EXTPointParameters.glPointParameterfEXT(EXTPointParameters.GL_POINT_SIZE_MIN_EXT,
                gl_particle_min_size.value);
        EXTPointParameters.glPointParameterfEXT(EXTPointParameters.GL_POINT_SIZE_MAX_EXT,
                gl_particle_max_size.value);
        EXTPointParameters.glPointParameterEXT(EXTPointParameters.GL_DISTANCE_ATTENUATION_EXT, att_buffer);
    }

    if (qglColorTableEXT && gl_ext_palettedtexture.value != 0.0f) {
        GL11.glEnable(EXTSharedTexturePalette.GL_SHARED_TEXTURE_PALETTE_EXT);

        GL_SetTexturePalette(d_8to24table);
    }

    GL_UpdateSwapInterval();

    /*
     * vertex array extension
     */
    GL11.glEnableClientState(GL11.GL_VERTEX_ARRAY);
    ARBMultitexture.glClientActiveTextureARB(GL_TEXTURE0);
    GL11.glEnableClientState(GL11.GL_TEXTURE_COORD_ARRAY);
}

From source file:lwjake2.render.lwjgl.Mesh.java

License:Open Source License

/**
 * R_DrawAliasModel/*from w w w .  j  av  a  2s. com*/
 */
void R_DrawAliasModel(entity_t e) {
    if ((e.flags & Defines.RF_WEAPONMODEL) == 0) {
        if (R_CullAliasModel(e))
            return;
    }

    if ((e.flags & Defines.RF_WEAPONMODEL) != 0) {
        if (r_lefthand.value == 2.0f)
            return;
    }

    qfiles.dmdl_t paliashdr = (qfiles.dmdl_t) currentmodel.extradata;

    //
    // get lighting information
    //
    // PMM - rewrote, reordered to handle new shells & mixing
    // PMM - 3.20 code .. replaced with original way of doing it to keep mod authors happy
    //
    int i;
    if ((currententity.flags & (Defines.RF_SHELL_HALF_DAM | Defines.RF_SHELL_GREEN | Defines.RF_SHELL_RED
            | Defines.RF_SHELL_BLUE | Defines.RF_SHELL_DOUBLE)) != 0) {
        Math3D.VectorClear(shadelight);
        if ((currententity.flags & Defines.RF_SHELL_HALF_DAM) != 0) {
            shadelight[0] = 0.56f;
            shadelight[1] = 0.59f;
            shadelight[2] = 0.45f;
        }
        if ((currententity.flags & Defines.RF_SHELL_DOUBLE) != 0) {
            shadelight[0] = 0.9f;
            shadelight[1] = 0.7f;
        }
        if ((currententity.flags & Defines.RF_SHELL_RED) != 0)
            shadelight[0] = 1.0f;
        if ((currententity.flags & Defines.RF_SHELL_GREEN) != 0)
            shadelight[1] = 1.0f;
        if ((currententity.flags & Defines.RF_SHELL_BLUE) != 0)
            shadelight[2] = 1.0f;
    }

    else if ((currententity.flags & Defines.RF_FULLBRIGHT) != 0) {
        for (i = 0; i < 3; i++)
            shadelight[i] = 1.0f;
    } else {
        R_LightPoint(currententity.origin, shadelight);

        // player lighting hack for communication back to server
        // big hack!
        if ((currententity.flags & Defines.RF_WEAPONMODEL) != 0) {
            // pick the greatest component, which should be the same
            // as the mono value returned by software
            if (shadelight[0] > shadelight[1]) {
                if (shadelight[0] > shadelight[2])
                    r_lightlevel.value = 150 * shadelight[0];
                else
                    r_lightlevel.value = 150 * shadelight[2];
            } else {
                if (shadelight[1] > shadelight[2])
                    r_lightlevel.value = 150 * shadelight[1];
                else
                    r_lightlevel.value = 150 * shadelight[2];
            }
        }

        if (gl_monolightmap.string.charAt(0) != '0') {
            float s = shadelight[0];

            if (s < shadelight[1])
                s = shadelight[1];
            if (s < shadelight[2])
                s = shadelight[2];

            shadelight[0] = s;
            shadelight[1] = s;
            shadelight[2] = s;
        }
    }

    if ((currententity.flags & Defines.RF_MINLIGHT) != 0) {
        for (i = 0; i < 3; i++)
            if (shadelight[i] > 0.1f)
                break;
        if (i == 3) {
            shadelight[0] = 0.1f;
            shadelight[1] = 0.1f;
            shadelight[2] = 0.1f;
        }
    }

    if ((currententity.flags & Defines.RF_GLOW) != 0) { // bonus items will pulse with time
        float scale;
        float min;

        scale = (float) (0.1f * Math.sin(r_newrefdef.time * 7));
        for (i = 0; i < 3; i++) {
            min = shadelight[i] * 0.8f;
            shadelight[i] += scale;
            if (shadelight[i] < min)
                shadelight[i] = min;
        }
    }

    // =================
    // PGM   ir goggles color override
    if ((r_newrefdef.rdflags & Defines.RDF_IRGOGGLES) != 0
            && (currententity.flags & Defines.RF_IR_VISIBLE) != 0) {
        shadelight[0] = 1.0f;
        shadelight[1] = 0.0f;
        shadelight[2] = 0.0f;
    }
    // PGM   
    // =================

    shadedots = r_avertexnormal_dots[((int) (currententity.angles[1] * (SHADEDOT_QUANT / 360.0)))
            & (SHADEDOT_QUANT - 1)];

    float an = (float) (currententity.angles[1] / 180 * Math.PI);
    shadevector[0] = (float) Math.cos(-an);
    shadevector[1] = (float) Math.sin(-an);
    shadevector[2] = 1;
    Math3D.VectorNormalize(shadevector);

    //
    // locate the proper data
    //

    c_alias_polys += paliashdr.num_tris;

    //
    // draw all the triangles
    //
    if ((currententity.flags & Defines.RF_DEPTHHACK) != 0) // hack the depth range to prevent view model from poking into walls
        GL11.glDepthRange(gldepthmin, gldepthmin + 0.3 * (gldepthmax - gldepthmin));

    if ((currententity.flags & Defines.RF_WEAPONMODEL) != 0 && (r_lefthand.value == 1.0f)) {
        GL11.glMatrixMode(GL11.GL_PROJECTION);
        GL11.glPushMatrix();
        GL11.glLoadIdentity();
        GL11.glScalef(-1, 1, 1);
        MYgluPerspective(r_newrefdef.fov_y, (float) r_newrefdef.width / r_newrefdef.height, 4, 4096);
        GL11.glMatrixMode(GL11.GL_MODELVIEW);

        GL11.glCullFace(GL11.GL_BACK);
    }

    GL11.glPushMatrix();
    e.angles[PITCH] = -e.angles[PITCH]; // sigh.
    R_RotateForEntity(e);
    e.angles[PITCH] = -e.angles[PITCH]; // sigh.

    image_t skin;
    // select skin
    if (currententity.skin != null)
        skin = currententity.skin; // custom player skin
    else {
        if (currententity.skinnum >= qfiles.MAX_MD2SKINS)
            skin = currentmodel.skins[0];
        else {
            skin = currentmodel.skins[currententity.skinnum];
            if (skin == null)
                skin = currentmodel.skins[0];
        }
    }
    if (skin == null)
        skin = r_notexture; // fallback...
    GL_Bind(skin.texnum);

    // draw it

    GL11.glShadeModel(GL11.GL_SMOOTH);

    GL_TexEnv(GL11.GL_MODULATE);
    if ((currententity.flags & Defines.RF_TRANSLUCENT) != 0) {
        GL11.glEnable(GL11.GL_BLEND);
    }

    if ((currententity.frame >= paliashdr.num_frames) || (currententity.frame < 0)) {
        VID.Printf(Defines.PRINT_ALL,
                "R_DrawAliasModel " + currentmodel.name + ": no such frame " + currententity.frame + '\n');
        currententity.frame = 0;
        currententity.oldframe = 0;
    }

    if ((currententity.oldframe >= paliashdr.num_frames) || (currententity.oldframe < 0)) {
        VID.Printf(Defines.PRINT_ALL, "R_DrawAliasModel " + currentmodel.name + ": no such oldframe "
                + currententity.oldframe + '\n');
        currententity.frame = 0;
        currententity.oldframe = 0;
    }

    if (r_lerpmodels.value == 0.0f)
        currententity.backlerp = 0;

    GL_DrawAliasFrameLerp(paliashdr, currententity.backlerp);

    GL_TexEnv(GL11.GL_REPLACE);
    GL11.glShadeModel(GL11.GL_FLAT);

    GL11.glPopMatrix();

    if ((currententity.flags & Defines.RF_WEAPONMODEL) != 0 && (r_lefthand.value == 1.0F)) {
        GL11.glMatrixMode(GL11.GL_PROJECTION);
        GL11.glPopMatrix();
        GL11.glMatrixMode(GL11.GL_MODELVIEW);
        GL11.glCullFace(GL11.GL_FRONT);
    }

    if ((currententity.flags & Defines.RF_TRANSLUCENT) != 0) {
        GL11.glDisable(GL11.GL_BLEND);
    }

    if ((currententity.flags & Defines.RF_DEPTHHACK) != 0)
        GL11.glDepthRange(gldepthmin, gldepthmax);

    if (gl_shadows.value != 0.0f
            && (currententity.flags & (Defines.RF_TRANSLUCENT | Defines.RF_WEAPONMODEL)) == 0) {
        GL11.glPushMatrix();
        R_RotateForEntity(e);
        GL11.glDisable(GL11.GL_TEXTURE_2D);
        GL11.glEnable(GL11.GL_BLEND);
        GL11.glColor4f(0, 0, 0, 0.5f);
        GL_DrawAliasShadow(paliashdr, currententity.frame);
        GL11.glEnable(GL11.GL_TEXTURE_2D);
        GL11.glDisable(GL11.GL_BLEND);
        GL11.glPopMatrix();
    }
    GL11.glColor4f(1, 1, 1, 1);
}

From source file:lyonlancer5.pfsteel.world.dimension.yakusoku.YakusokuSkyRenderer.java

License:Open Source License

@Override
@SideOnly(Side.CLIENT)// w  w  w  .j a v  a2 s . c  o m
public void render(float partialTicks, WorldClient world, Minecraft mc) {
    GL11.glDisable(GL11.GL_TEXTURE_2D);
    Vec3 vec3 = world.getSkyColor(mc.renderViewEntity, partialTicks);
    float f1 = (float) vec3.xCoord;
    float f2 = (float) vec3.yCoord;
    float f3 = (float) vec3.zCoord;
    float f4;
    if (mc.gameSettings.anaglyph) {
        float f5 = (f1 * 30.0F + f2 * 59.0F + f3 * 11.0F) / 100.0F;
        float f6 = (f1 * 30.0F + f2 * 70.0F) / 100.0F;
        f4 = (f1 * 30.0F + f3 * 70.0F) / 100.0F;
        f1 = f5;
        f2 = f6;
        f3 = f4;
    }
    GL11.glColor3f(f1, f2, f3);
    Tessellator tessellator1 = Tessellator.instance;
    GL11.glDepthMask(false);
    GL11.glEnable(GL11.GL_FOG);
    GL11.glColor3f(f1, f2, f3);
    GL11.glCallList(this.glSkyList);
    GL11.glDisable(GL11.GL_FOG);
    GL11.glDisable(GL11.GL_ALPHA_TEST);
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    RenderHelper.disableStandardItemLighting();
    float[] afloat = world.provider.calcSunriseSunsetColors(world.getCelestialAngle(partialTicks),
            partialTicks);
    float f7;
    float f8;
    float f9;
    float f10;
    if (afloat != null) {
        GL11.glDisable(GL11.GL_TEXTURE_2D);
        GL11.glShadeModel(GL11.GL_SMOOTH);
        GL11.glPushMatrix();
        GL11.glRotatef(90.0F, 1.0F, 0.0F, 0.0F);
        GL11.glRotatef(MathHelper.sin(world.getCelestialAngleRadians(partialTicks)) < 0.0F ? 180.0F : 0.0F,
                0.0F, 0.0F, 1.0F);
        GL11.glRotatef(90.0F, 0.0F, 0.0F, 1.0F);
        f4 = afloat[0];
        f7 = afloat[1];
        f8 = afloat[2];
        float f11;
        if (mc.gameSettings.anaglyph) {
            f9 = (f4 * 30.0F + f7 * 59.0F + f8 * 11.0F) / 100.0F;
            f10 = (f4 * 30.0F + f7 * 70.0F) / 100.0F;
            f11 = (f4 * 30.0F + f8 * 70.0F) / 100.0F;
            f4 = f9;
            f7 = f10;
            f8 = f11;
        }
        tessellator1.startDrawing(6);
        tessellator1.setColorRGBA_F(f4, f7, f8, afloat[3]);
        tessellator1.addVertex(0.0D, 100.0D, 0.0D);
        byte b0 = 16;
        tessellator1.setColorRGBA_F(afloat[0], afloat[1], afloat[2], 0.0F);
        for (int j = 0; j <= b0; ++j) {
            f11 = (float) j * (float) Math.PI * 2.0F / (float) b0;
            float f12 = MathHelper.sin(f11);
            float f13 = MathHelper.cos(f11);
            tessellator1.addVertex((double) (f12 * 120.0F), (double) (f13 * 120.0F),
                    (double) (-f13 * 40.0F * afloat[3]));
        }
        tessellator1.draw();
        GL11.glPopMatrix();
        GL11.glShadeModel(GL11.GL_FLAT);
    }
    GL11.glEnable(GL11.GL_TEXTURE_2D);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE);
    GL11.glPushMatrix();
    f4 = 1.0F - world.getRainStrength(partialTicks);
    f7 = 0.0F;
    f8 = 0.0F;
    f9 = 0.0F;
    GL11.glColor4f(1.0F, 1.0F, 1.0F, f4);
    GL11.glTranslatef(f7, f8, f9);
    GL11.glRotatef(-90.0F, 0.0F, 1.0F, 0.0F);
    GL11.glRotatef(world.getCelestialAngle(partialTicks) * 360.0F, 1.0F, 0.0F, 0.0F);

    f10 = 20.0F; // Size of sun from center
    mc.renderEngine
            .bindTexture(new ResourceLocation(ModVersion.modid, "textures/environment/yakusoku_sun.png"));

    tessellator1.startDrawingQuads();
    tessellator1.addVertexWithUV((double) (-f10), 100.0D, (double) (-f10), 0.0D, 0.0D);
    tessellator1.addVertexWithUV((double) f10, 100.0D, (double) (-f10), 1.0D, 0.0D);
    tessellator1.addVertexWithUV((double) f10, 100.0D, (double) f10, 1.0D, 1.0D);
    tessellator1.addVertexWithUV((double) (-f10), 100.0D, (double) f10, 0.0D, 1.0D);

    tessellator1.draw(); // Draw sun
    f10 = 15.0F; // Size of moon from center

    mc.renderEngine.bindTexture(
            new ResourceLocation(ModVersion.modid, "textures/environment/yakusoku_moon_phases.png"));

    int k = world.getMoonPhase();
    int l = k % 4;
    int i1 = k / 4 % 2;
    float f14 = (float) (l + 0) / 4.0F;
    float f15 = (float) (i1 + 0) / 2.0F;
    float f16 = (float) (l + 1) / 4.0F;
    float f17 = (float) (i1 + 1) / 2.0F;
    tessellator1.startDrawingQuads();
    tessellator1.addVertexWithUV((double) (-f10), -100.0D, (double) f10, (double) f16, (double) f17);
    tessellator1.addVertexWithUV((double) f10, -100.0D, (double) f10, (double) f14, (double) f17);
    tessellator1.addVertexWithUV((double) f10, -100.0D, (double) (-f10), (double) f14, (double) f15);
    tessellator1.addVertexWithUV((double) (-f10), -100.0D, (double) (-f10), (double) f16, (double) f15);
    tessellator1.draw();
    GL11.glDisable(GL11.GL_TEXTURE_2D);
    float f18 = world.getStarBrightness(partialTicks) * f4;
    if (f18 > 0.0F) {
        GL11.glColor4f(f18, f18, f18, f18);
        GL11.glCallList(this.starGLCallList);
    }
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    GL11.glDisable(GL11.GL_BLEND);
    GL11.glEnable(GL11.GL_ALPHA_TEST);
    GL11.glEnable(GL11.GL_FOG);
    GL11.glPopMatrix();
    GL11.glDisable(GL11.GL_TEXTURE_2D);
    GL11.glColor3f(0.0F, 0.0F, 0.0F);
    double d0 = mc.thePlayer.getPosition(partialTicks).yCoord - world.getHorizon();
    if (d0 < 0.0D) {
        GL11.glPushMatrix();
        GL11.glTranslatef(0.0F, 12.0F, 0.0F);
        GL11.glCallList(this.glSkyList2);
        GL11.glPopMatrix();
        f8 = 1.0F;
        f9 = -((float) (d0 + 65.0D));
        f10 = -f8;
        tessellator1.startDrawingQuads();
        tessellator1.setColorRGBA_I(0, 255);
        tessellator1.addVertex((double) (-f8), (double) f9, (double) f8);
        tessellator1.addVertex((double) f8, (double) f9, (double) f8);
        tessellator1.addVertex((double) f8, (double) f10, (double) f8);
        tessellator1.addVertex((double) (-f8), (double) f10, (double) f8);
        tessellator1.addVertex((double) (-f8), (double) f10, (double) (-f8));
        tessellator1.addVertex((double) f8, (double) f10, (double) (-f8));
        tessellator1.addVertex((double) f8, (double) f9, (double) (-f8));
        tessellator1.addVertex((double) (-f8), (double) f9, (double) (-f8));
        tessellator1.addVertex((double) f8, (double) f10, (double) (-f8));
        tessellator1.addVertex((double) f8, (double) f10, (double) f8);
        tessellator1.addVertex((double) f8, (double) f9, (double) f8);
        tessellator1.addVertex((double) f8, (double) f9, (double) (-f8));
        tessellator1.addVertex((double) (-f8), (double) f9, (double) (-f8));
        tessellator1.addVertex((double) (-f8), (double) f9, (double) f8);
        tessellator1.addVertex((double) (-f8), (double) f10, (double) f8);
        tessellator1.addVertex((double) (-f8), (double) f10, (double) (-f8));
        tessellator1.addVertex((double) (-f8), (double) f10, (double) (-f8));
        tessellator1.addVertex((double) (-f8), (double) f10, (double) f8);
        tessellator1.addVertex((double) f8, (double) f10, (double) f8);
        tessellator1.addVertex((double) f8, (double) f10, (double) (-f8));
        tessellator1.draw();
    }
    if (world.provider.isSkyColored()) {
        GL11.glColor3f(0.2F + 0.04F, f2 * 0.2F + 0.04F, f3 * 0.6F + 0.1F);
        //GL11.glColor3f(0.2F + 0.04F, f2 * 0.6F + 0.1F, f3 * 0.2F + 0.04F);
    } else {
        GL11.glColor3f(f1, f2, f3);
    }
    GL11.glPushMatrix();
    GL11.glTranslatef(0.0F, -((float) (d0 - 16.0D)), 0.0F);
    GL11.glCallList(this.glSkyList2);
    GL11.glPopMatrix();
    GL11.glEnable(GL11.GL_TEXTURE_2D);
    GL11.glDepthMask(true);
}

From source file:mattparks.mods.starcraft.io.client.SCIoSkyProvider.java

License:LGPL

@Override
public void render(float partialTicks, WorldClient world, Minecraft mc) {
    GL11.glDisable(GL11.GL_TEXTURE_2D);//from   ww  w .j  a va  2s. c o  m
    Vec3 vec3 = world.getSkyColor(mc.renderViewEntity, partialTicks);
    float f1 = (float) vec3.xCoord;
    float f2 = (float) vec3.yCoord;
    float f3 = (float) vec3.zCoord;
    float f6;

    if (mc.gameSettings.anaglyph) {
        float f4 = (f1 * 30.0F + f2 * 59.0F + f3 * 11.0F) / 100.0F;
        float f5 = (f1 * 30.0F + f2 * 70.0F) / 100.0F;
        f6 = (f1 * 30.0F + f3 * 70.0F) / 100.0F;
        f1 = f4;
        f2 = f5;
        f3 = f6;
    }

    GL11.glColor3f(f1, f2, f3);
    Tessellator tessellator1 = Tessellator.instance;
    GL11.glDepthMask(false);
    GL11.glEnable(GL11.GL_FOG);
    GL11.glColor3f(f1, f2, f3);
    GL11.glCallList(this.glSkyList);
    GL11.glDisable(GL11.GL_FOG);
    GL11.glDisable(GL11.GL_ALPHA_TEST);
    GL11.glEnable(GL11.GL_BLEND);
    //        OpenGlHelper.glBlendFunc(770, 771, 1, 0);
    RenderHelper.disableStandardItemLighting();
    float[] afloat = world.provider.calcSunriseSunsetColors(world.getCelestialAngle(partialTicks),
            partialTicks);
    float f7;
    float f8;
    float f9;
    float f10;

    float f18 = world.getStarBrightness(partialTicks);

    if (f18 > 0.0F) {
        GL11.glColor4f(f18, f18, f18, f18);
        GL11.glCallList(this.starList);
    }

    afloat = new float[4];
    GL11.glDisable(GL11.GL_TEXTURE_2D);
    GL11.glShadeModel(GL11.GL_SMOOTH);
    GL11.glPushMatrix();
    GL11.glRotatef(-90.0F, 0.0F, 1.0F, 0.0F);
    GL11.glRotatef(world.getCelestialAngle(partialTicks) * 360.0F, 1.0F, 0.0F, 0.0F);
    afloat[0] = 255 / 255.0F;
    afloat[1] = 194 / 255.0F;
    afloat[2] = 180 / 255.0F;
    afloat[3] = 0.3F;
    f6 = afloat[0];
    f7 = afloat[1];
    f8 = afloat[2];
    float f11;
    float var12;

    if (mc.gameSettings.anaglyph) {
        f9 = (f6 * 30.0F + f7 * 59.0F + f8 * 11.0F) / 100.0F;
        f10 = (f6 * 30.0F + f7 * 70.0F) / 100.0F;
        f11 = (f6 * 30.0F + f8 * 70.0F) / 100.0F;
        f6 = f9;
        f7 = f10;
        f8 = f11;
    }

    final Tessellator var23 = Tessellator.instance;
    tessellator1.startDrawing(GL11.GL_TRIANGLE_FAN);
    tessellator1.setColorRGBA_F(f6, f7, f8, afloat[3] * 2);
    tessellator1.addVertex(0.0D, 100.0D, 0.0D);
    byte b0 = 16;
    tessellator1.setColorRGBA_F(afloat[0], afloat[1], afloat[2], 0.0F);

    // Render sun aura
    f10 = 20.0F;
    tessellator1.addVertex((double) -f10, 100.0D, (double) -f10);
    tessellator1.addVertex((double) 0, 100.0D, (double) -f10 * 1.5F);
    tessellator1.addVertex((double) f10, 100.0D, (double) -f10);
    tessellator1.addVertex((double) f10 * 1.5F, 100.0D, (double) 0);
    tessellator1.addVertex((double) f10, 100.0D, (double) f10);
    tessellator1.addVertex((double) 0, 100.0D, (double) f10 * 1.5F);
    tessellator1.addVertex((double) -f10, 100.0D, (double) f10);
    tessellator1.addVertex((double) -f10 * 1.5F, 100.0D, (double) 0);
    tessellator1.addVertex((double) -f10, 100.0D, (double) -f10);

    tessellator1.draw();
    tessellator1.startDrawing(GL11.GL_TRIANGLE_FAN);
    tessellator1.setColorRGBA_F(f6, f7, f8, afloat[3]);
    tessellator1.addVertex(0.0D, 100.0D, 0.0D);
    tessellator1.setColorRGBA_F(afloat[0], afloat[1], afloat[2], 0.0F);

    // Render larger sun aura
    f10 = 40.0F;
    tessellator1.addVertex((double) -f10, 100.0D, (double) -f10);
    tessellator1.addVertex((double) 0, 100.0D, (double) -f10 * 1.5F);
    tessellator1.addVertex((double) f10, 100.0D, (double) -f10);
    tessellator1.addVertex((double) f10 * 1.5F, 100.0D, (double) 0);
    tessellator1.addVertex((double) f10, 100.0D, (double) f10);
    tessellator1.addVertex((double) 0, 100.0D, (double) f10 * 1.5F);
    tessellator1.addVertex((double) -f10, 100.0D, (double) f10);
    tessellator1.addVertex((double) -f10 * 1.5F, 100.0D, (double) 0);
    tessellator1.addVertex((double) -f10, 100.0D, (double) -f10);

    tessellator1.draw();
    GL11.glPopMatrix();
    GL11.glShadeModel(GL11.GL_FLAT);

    GL11.glEnable(GL11.GL_TEXTURE_2D);
    //        OpenGlHelper.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE, GL11.GL_ZERO);
    GL11.glPushMatrix();
    f7 = 0.0F;
    f8 = 0.0F;
    f9 = 0.0F;
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    GL11.glTranslatef(f7, f8, f9);
    GL11.glRotatef(-90.0F, 0.0F, 1.0F, 0.0F);
    GL11.glRotatef(world.getCelestialAngle(partialTicks) * 360.0F, 1.0F, 0.0F, 0.0F);
    // Render sun
    f10 = 14.0F;
    mc.renderEngine.bindTexture(sunTexture);
    tessellator1.startDrawingQuads();
    tessellator1.addVertexWithUV((double) (-f10), 400.0D, (double) (-f10), 0.0D, 0.0D);
    tessellator1.addVertexWithUV((double) f10, 400.0D, (double) (-f10), 1.0D, 0.0D);
    tessellator1.addVertexWithUV((double) f10, 400.0D, (double) f10, 1.0D, 1.0D);
    tessellator1.addVertexWithUV((double) (-f10), 400.0D, (double) f10, 0.0D, 1.0D);
    tessellator1.draw();

    // JUPITER:
    var12 = 10.0F;
    final float jupiterRotation = (float) (world.getSpawnPoint().posZ - mc.thePlayer.posZ) * 0.01F;
    GL11.glRotatef(-180.0F, 0.0F, 1.0F, 0.0F);
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 5F);
    GL11.glRotatef(world.getCelestialAngle(partialTicks) * 100.0F, 1.0F, 0.0F, 0.0F);
    var12 = 30.0F;
    FMLClientHandler.instance().getClient().renderEngine.bindTexture(SCIoSkyProvider.jupiterTexture);
    var23.startDrawingQuads();
    var23.addVertexWithUV(-var12, 75.0D, -var12, 0.0D, 0.0D);
    var23.addVertexWithUV(var12, 75.0D, -var12, 1.0D, 0.0D);
    var23.addVertexWithUV(var12, 75.0D, var12, 1.0D, 1.0D);
    var23.addVertexWithUV(-var12, 75.0D, var12, 0.0D, 1.0D);
    var23.draw();

    // Render earth
    f10 = 0.5F;
    GL11.glScalef(0.6F, 0.6F, 0.6F);
    GL11.glRotatef(40.0F, 0.0F, 0.0F, 1.0F);
    GL11.glRotatef(200F, 1.0F, 0.0F, 0.0F);
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1F);
    FMLClientHandler.instance().getClient().renderEngine.bindTexture(SCIoSkyProvider.overworldTexture);
    tessellator1.startDrawingQuads();
    tessellator1.addVertexWithUV(-f10, -100.0D, f10, 0, 1);
    tessellator1.addVertexWithUV(f10, -100.0D, f10, 1, 1);
    tessellator1.addVertexWithUV(f10, -100.0D, -f10, 1, 0);
    tessellator1.addVertexWithUV(-f10, -100.0D, -f10, 0, 0);
    tessellator1.draw();

    GL11.glDisable(GL11.GL_TEXTURE_2D);

    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    GL11.glDisable(GL11.GL_BLEND);
    GL11.glEnable(GL11.GL_ALPHA_TEST);
    GL11.glEnable(GL11.GL_FOG);
    GL11.glPopMatrix();
    GL11.glDisable(GL11.GL_TEXTURE_2D);
    GL11.glColor3f(0.0F, 0.0F, 0.0F);
    double d0 = mc.thePlayer.getPosition(partialTicks).yCoord - world.getHorizon();

    if (d0 < 0.0D) {
        GL11.glPushMatrix();
        GL11.glTranslatef(0.0F, 12.0F, 0.0F);
        GL11.glCallList(this.glSkyList2);
        GL11.glPopMatrix();
        f8 = 1.0F;
        f9 = -((float) (d0 + 65.0D));
        f10 = -f8;
        tessellator1.startDrawingQuads();
        tessellator1.setColorRGBA_I(0, 255);
        tessellator1.addVertex((double) (-f8), (double) f9, (double) f8);
        tessellator1.addVertex((double) f8, (double) f9, (double) f8);
        tessellator1.addVertex((double) f8, (double) f10, (double) f8);
        tessellator1.addVertex((double) (-f8), (double) f10, (double) f8);
        tessellator1.addVertex((double) (-f8), (double) f10, (double) (-f8));
        tessellator1.addVertex((double) f8, (double) f10, (double) (-f8));
        tessellator1.addVertex((double) f8, (double) f9, (double) (-f8));
        tessellator1.addVertex((double) (-f8), (double) f9, (double) (-f8));
        tessellator1.addVertex((double) f8, (double) f10, (double) (-f8));
        tessellator1.addVertex((double) f8, (double) f10, (double) f8);
        tessellator1.addVertex((double) f8, (double) f9, (double) f8);
        tessellator1.addVertex((double) f8, (double) f9, (double) (-f8));
        tessellator1.addVertex((double) (-f8), (double) f9, (double) (-f8));
        tessellator1.addVertex((double) (-f8), (double) f9, (double) f8);
        tessellator1.addVertex((double) (-f8), (double) f10, (double) f8);
        tessellator1.addVertex((double) (-f8), (double) f10, (double) (-f8));
        tessellator1.addVertex((double) (-f8), (double) f10, (double) (-f8));
        tessellator1.addVertex((double) (-f8), (double) f10, (double) f8);
        tessellator1.addVertex((double) f8, (double) f10, (double) f8);
        tessellator1.addVertex((double) f8, (double) f10, (double) (-f8));
        tessellator1.draw();
    }

    if (world.provider.isSkyColored()) {
        GL11.glColor3f(f1 * 0.2F + 0.04F, f2 * 0.2F + 0.04F, f3 * 0.6F + 0.1F);
    } else {
        GL11.glColor3f(f1, f2, f3);
    }

    GL11.glPushMatrix();
    GL11.glTranslatef(0.0F, -((float) (d0 - 16.0D)), 0.0F);
    GL11.glCallList(this.glSkyList2);
    GL11.glPopMatrix();
    GL11.glEnable(GL11.GL_TEXTURE_2D);
    GL11.glDepthMask(true);
}

From source file:mattparks.mods.starcraft.titan.client.SCTitanSkyProvider.java

License:LGPL

@Override
public void render(float partialTicks, WorldClient world, Minecraft mc) {
    GL11.glDisable(GL11.GL_TEXTURE_2D);/*from  ww w  .  j a va 2  s  . c o m*/
    Vec3 vec3 = world.getSkyColor(mc.renderViewEntity, partialTicks);
    float f1 = (float) vec3.xCoord;
    float f2 = (float) vec3.yCoord;
    float f3 = (float) vec3.zCoord;
    float f6;

    if (mc.gameSettings.anaglyph) {
        float f4 = (f1 * 30.0F + f2 * 59.0F + f3 * 11.0F) / 100.0F;
        float f5 = (f1 * 30.0F + f2 * 70.0F) / 100.0F;
        f6 = (f1 * 30.0F + f3 * 70.0F) / 100.0F;
        f1 = f4;
        f2 = f5;
        f3 = f6;
    }

    GL11.glColor3f(f1, f2, f3);
    Tessellator tessellator1 = Tessellator.instance;
    GL11.glDepthMask(false);
    GL11.glEnable(GL11.GL_FOG);
    GL11.glColor3f(f1, f2, f3);
    GL11.glCallList(this.glSkyList);
    GL11.glDisable(GL11.GL_FOG);
    GL11.glDisable(GL11.GL_ALPHA_TEST);
    GL11.glEnable(GL11.GL_BLEND);
    //        OpenGlHelper.glBlendFunc(770, 771, 1, 0);
    RenderHelper.disableStandardItemLighting();
    float[] afloat = world.provider.calcSunriseSunsetColors(world.getCelestialAngle(partialTicks),
            partialTicks);
    float f7;
    float f8;
    float f9;
    float f10;

    float f18 = world.getStarBrightness(partialTicks);

    if (f18 > 0.0F) {
        GL11.glColor4f(f18, f18, f18, f18);
        GL11.glCallList(this.starList);
    }

    afloat = new float[4];
    GL11.glDisable(GL11.GL_TEXTURE_2D);
    GL11.glShadeModel(GL11.GL_SMOOTH);
    GL11.glPushMatrix();
    GL11.glRotatef(-90.0F, 0.0F, 1.0F, 0.0F);
    GL11.glRotatef(world.getCelestialAngle(partialTicks) * 360.0F, 1.0F, 0.0F, 0.0F);
    afloat[0] = 255 / 255.0F;
    afloat[1] = 194 / 255.0F;
    afloat[2] = 180 / 255.0F;
    afloat[3] = 0.3F;
    f6 = afloat[0];
    f7 = afloat[1];
    f8 = afloat[2];
    float f11;
    float var12;

    if (mc.gameSettings.anaglyph) {
        f9 = (f6 * 30.0F + f7 * 59.0F + f8 * 11.0F) / 100.0F;
        f10 = (f6 * 30.0F + f7 * 70.0F) / 100.0F;
        f11 = (f6 * 30.0F + f8 * 70.0F) / 100.0F;
        f6 = f9;
        f7 = f10;
        f8 = f11;
    }

    final Tessellator var23 = Tessellator.instance;
    tessellator1.startDrawing(GL11.GL_TRIANGLE_FAN);
    tessellator1.setColorRGBA_F(f6, f7, f8, afloat[3] * 2);
    tessellator1.addVertex(0.0D, 100.0D, 0.0D);
    byte b0 = 16;
    tessellator1.setColorRGBA_F(afloat[0], afloat[1], afloat[2], 0.0F);

    // Render sun aura
    f10 = 20.0F;
    tessellator1.addVertex((double) -f10, 200.0D, (double) -f10);
    tessellator1.addVertex((double) 0, 200.0D, (double) -f10 * 1.5F);
    tessellator1.addVertex((double) f10, 200.0D, (double) -f10);
    tessellator1.addVertex((double) f10 * 1.5F, 200.0D, (double) 0);
    tessellator1.addVertex((double) f10, 200.0D, (double) f10);
    tessellator1.addVertex((double) 0, 200.0D, (double) f10 * 1.5F);
    tessellator1.addVertex((double) -f10, 200.0D, (double) f10);
    tessellator1.addVertex((double) -f10 * 1.5F, 200.0D, (double) 0);
    tessellator1.addVertex((double) -f10, 200.0D, (double) -f10);

    tessellator1.draw();
    tessellator1.startDrawing(GL11.GL_TRIANGLE_FAN);
    tessellator1.setColorRGBA_F(f6, f7, f8, afloat[3]);
    tessellator1.addVertex(0.0D, 100.0D, 0.0D);
    tessellator1.setColorRGBA_F(afloat[0], afloat[1], afloat[2], 0.0F);

    // Render larger sun aura
    f10 = 40.0F;
    tessellator1.addVertex((double) -f10, 200.0D, (double) -f10);
    tessellator1.addVertex((double) 0, 200.0D, (double) -f10 * 1.5F);
    tessellator1.addVertex((double) f10, 200.0D, (double) -f10);
    tessellator1.addVertex((double) f10 * 1.5F, 200.0D, (double) 0);
    tessellator1.addVertex((double) f10, 200.0D, (double) f10);
    tessellator1.addVertex((double) 0, 200.0D, (double) f10 * 1.5F);
    tessellator1.addVertex((double) -f10, 200.0D, (double) f10);
    tessellator1.addVertex((double) -f10 * 1.5F, 200.0D, (double) 0);
    tessellator1.addVertex((double) -f10, 200.0D, (double) -f10);

    tessellator1.draw();
    GL11.glPopMatrix();
    GL11.glShadeModel(GL11.GL_FLAT);

    GL11.glEnable(GL11.GL_TEXTURE_2D);
    //        OpenGlHelper.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE, GL11.GL_ZERO);
    GL11.glPushMatrix();
    f7 = 0.0F;
    f8 = 0.0F;
    f9 = 0.0F;
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    GL11.glTranslatef(f7, f8, f9);
    GL11.glRotatef(-90.0F, 0.0F, 1.0F, 0.0F);
    GL11.glRotatef(world.getCelestialAngle(partialTicks) * 360.0F, 1.0F, 0.0F, 0.0F);
    // Render sun
    f10 = 14.0F;
    mc.renderEngine.bindTexture(sunTexture);
    tessellator1.startDrawingQuads();
    tessellator1.addVertexWithUV((double) (-f10), 450.0D, (double) (-f10), 0.0D, 0.0D);
    tessellator1.addVertexWithUV((double) f10, 450.0D, (double) (-f10), 1.0D, 0.0D);
    tessellator1.addVertexWithUV((double) f10, 450.0D, (double) f10, 1.0D, 1.0D);
    tessellator1.addVertexWithUV((double) (-f10), 450.0D, (double) f10, 0.0D, 1.0D);
    tessellator1.draw();

    // saturn:
    var12 = 10.0F;
    final float saturnRotation = (float) (world.getSpawnPoint().posZ - mc.thePlayer.posZ) * 0.01F;
    GL11.glRotatef(-180.0F, 0.0F, 1.0F, 0.0F);
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 5F);
    GL11.glRotatef(world.getCelestialAngle(partialTicks) * 100.0F, 1.0F, 0.0F, 0.0F);
    var12 = 30.0F;
    FMLClientHandler.instance().getClient().renderEngine.bindTexture(SCTitanSkyProvider.saturnTexture);
    var23.startDrawingQuads();
    var23.addVertexWithUV(-var12, 75.0D, -var12, 0.0D, 0.0D);
    var23.addVertexWithUV(var12, 75.0D, -var12, 1.0D, 0.0D);
    var23.addVertexWithUV(var12, 75.0D, var12, 1.0D, 1.0D);
    var23.addVertexWithUV(-var12, 75.0D, var12, 0.0D, 1.0D);
    var23.draw();

    // Render earth
    f10 = 0.5F;
    GL11.glScalef(0.6F, 0.6F, 0.6F);
    GL11.glRotatef(40.0F, 0.0F, 0.0F, 1.0F);
    GL11.glRotatef(200F, 1.0F, 0.0F, 0.0F);
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1F);
    FMLClientHandler.instance().getClient().renderEngine.bindTexture(SCTitanSkyProvider.overworldTexture);
    tessellator1.startDrawingQuads();
    tessellator1.addVertexWithUV(-f10, -100.0D, f10, 0, 1);
    tessellator1.addVertexWithUV(f10, -100.0D, f10, 1, 1);
    tessellator1.addVertexWithUV(f10, -100.0D, -f10, 1, 0);
    tessellator1.addVertexWithUV(-f10, -100.0D, -f10, 0, 0);
    tessellator1.draw();

    GL11.glDisable(GL11.GL_TEXTURE_2D);

    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    GL11.glDisable(GL11.GL_BLEND);
    GL11.glEnable(GL11.GL_ALPHA_TEST);
    GL11.glEnable(GL11.GL_FOG);
    GL11.glPopMatrix();
    GL11.glDisable(GL11.GL_TEXTURE_2D);
    GL11.glColor3f(0.0F, 0.0F, 0.0F);
    double d0 = mc.thePlayer.getPosition(partialTicks).yCoord - world.getHorizon();

    if (d0 < 0.0D) {
        GL11.glPushMatrix();
        GL11.glTranslatef(0.0F, 12.0F, 0.0F);
        GL11.glCallList(this.glSkyList2);
        GL11.glPopMatrix();
        f8 = 1.0F;
        f9 = -((float) (d0 + 65.0D));
        f10 = -f8;
        tessellator1.startDrawingQuads();
        tessellator1.setColorRGBA_I(0, 255);
        tessellator1.addVertex((double) (-f8), (double) f9, (double) f8);
        tessellator1.addVertex((double) f8, (double) f9, (double) f8);
        tessellator1.addVertex((double) f8, (double) f10, (double) f8);
        tessellator1.addVertex((double) (-f8), (double) f10, (double) f8);
        tessellator1.addVertex((double) (-f8), (double) f10, (double) (-f8));
        tessellator1.addVertex((double) f8, (double) f10, (double) (-f8));
        tessellator1.addVertex((double) f8, (double) f9, (double) (-f8));
        tessellator1.addVertex((double) (-f8), (double) f9, (double) (-f8));
        tessellator1.addVertex((double) f8, (double) f10, (double) (-f8));
        tessellator1.addVertex((double) f8, (double) f10, (double) f8);
        tessellator1.addVertex((double) f8, (double) f9, (double) f8);
        tessellator1.addVertex((double) f8, (double) f9, (double) (-f8));
        tessellator1.addVertex((double) (-f8), (double) f9, (double) (-f8));
        tessellator1.addVertex((double) (-f8), (double) f9, (double) f8);
        tessellator1.addVertex((double) (-f8), (double) f10, (double) f8);
        tessellator1.addVertex((double) (-f8), (double) f10, (double) (-f8));
        tessellator1.addVertex((double) (-f8), (double) f10, (double) (-f8));
        tessellator1.addVertex((double) (-f8), (double) f10, (double) f8);
        tessellator1.addVertex((double) f8, (double) f10, (double) f8);
        tessellator1.addVertex((double) f8, (double) f10, (double) (-f8));
        tessellator1.draw();
    }

    if (world.provider.isSkyColored()) {
        GL11.glColor3f(f1 * 0.2F + 0.04F, f2 * 0.2F + 0.04F, f3 * 0.6F + 0.1F);
    } else {
        GL11.glColor3f(f1, f2, f3);
    }

    GL11.glPushMatrix();
    GL11.glTranslatef(0.0F, -((float) (d0 - 16.0D)), 0.0F);
    GL11.glCallList(this.glSkyList2);
    GL11.glPopMatrix();
    GL11.glEnable(GL11.GL_TEXTURE_2D);
    GL11.glDepthMask(true);
}

From source file:micdoodle8.mods.galacticraft.planets.mars.client.SkyProviderMars.java

License:LGPL

@Override
public void render(float partialTicks, WorldClient world, Minecraft mc) {
    GL11.glDisable(GL11.GL_TEXTURE_2D);//  www  .j  a  va 2s.c  o  m
    Vec3 vec3 = world.getSkyColor(mc.renderViewEntity, partialTicks);
    float f1 = (float) vec3.xCoord;
    float f2 = (float) vec3.yCoord;
    float f3 = (float) vec3.zCoord;
    float f6;

    if (mc.gameSettings.anaglyph) {
        float f4 = (f1 * 30.0F + f2 * 59.0F + f3 * 11.0F) / 100.0F;
        float f5 = (f1 * 30.0F + f2 * 70.0F) / 100.0F;
        f6 = (f1 * 30.0F + f3 * 70.0F) / 100.0F;
        f1 = f4;
        f2 = f5;
        f3 = f6;
    }

    GL11.glColor3f(f1, f2, f3);
    Tessellator tessellator1 = Tessellator.instance;
    GL11.glDepthMask(false);
    GL11.glEnable(GL11.GL_FOG);
    GL11.glColor3f(f1, f2, f3);
    GL11.glCallList(this.glSkyList);
    GL11.glDisable(GL11.GL_FOG);
    GL11.glDisable(GL11.GL_ALPHA_TEST);
    GL11.glEnable(GL11.GL_BLEND);
    OpenGlHelper.glBlendFunc(770, 771, 1, 0);
    RenderHelper.disableStandardItemLighting();
    float[] afloat = world.provider.calcSunriseSunsetColors(world.getCelestialAngle(partialTicks),
            partialTicks);
    float f7;
    float f8;
    float f9;
    float f10;

    float f18 = world.getStarBrightness(partialTicks);

    if (f18 > 0.0F) {
        GL11.glColor4f(f18, f18, f18, f18);
        GL11.glCallList(this.starList);
    }

    afloat = new float[4];
    GL11.glDisable(GL11.GL_TEXTURE_2D);
    GL11.glShadeModel(GL11.GL_SMOOTH);
    GL11.glPushMatrix();
    GL11.glRotatef(-90.0F, 0.0F, 1.0F, 0.0F);
    GL11.glRotatef(world.getCelestialAngle(partialTicks) * 360.0F, 1.0F, 0.0F, 0.0F);
    afloat[0] = 255 / 255.0F;
    afloat[1] = 194 / 255.0F;
    afloat[2] = 180 / 255.0F;
    afloat[3] = 0.3F;
    f6 = afloat[0];
    f7 = afloat[1];
    f8 = afloat[2];
    float f11;

    if (mc.gameSettings.anaglyph) {
        f9 = (f6 * 30.0F + f7 * 59.0F + f8 * 11.0F) / 100.0F;
        f10 = (f6 * 30.0F + f7 * 70.0F) / 100.0F;
        f11 = (f6 * 30.0F + f8 * 70.0F) / 100.0F;
        f6 = f9;
        f7 = f10;
        f8 = f11;
    }

    tessellator1.startDrawing(GL11.GL_TRIANGLE_FAN);
    tessellator1.setColorRGBA_F(f6, f7, f8, afloat[3] * 2);
    tessellator1.addVertex(0.0D, 100.0D, 0.0D);
    byte b0 = 16;
    tessellator1.setColorRGBA_F(afloat[0], afloat[1], afloat[2], 0.0F);

    // Render sun aura
    f10 = 20.0F;
    tessellator1.addVertex(-f10, 100.0D, -f10);
    tessellator1.addVertex(0, 100.0D, (double) -f10 * 1.5F);
    tessellator1.addVertex(f10, 100.0D, -f10);
    tessellator1.addVertex((double) f10 * 1.5F, 100.0D, 0);
    tessellator1.addVertex(f10, 100.0D, f10);
    tessellator1.addVertex(0, 100.0D, (double) f10 * 1.5F);
    tessellator1.addVertex(-f10, 100.0D, f10);
    tessellator1.addVertex((double) -f10 * 1.5F, 100.0D, 0);
    tessellator1.addVertex(-f10, 100.0D, -f10);

    tessellator1.draw();
    tessellator1.startDrawing(GL11.GL_TRIANGLE_FAN);
    tessellator1.setColorRGBA_F(f6, f7, f8, afloat[3]);
    tessellator1.addVertex(0.0D, 100.0D, 0.0D);
    tessellator1.setColorRGBA_F(afloat[0], afloat[1], afloat[2], 0.0F);

    // Render larger sun aura
    f10 = 40.0F;
    tessellator1.addVertex(-f10, 100.0D, -f10);
    tessellator1.addVertex(0, 100.0D, (double) -f10 * 1.5F);
    tessellator1.addVertex(f10, 100.0D, -f10);
    tessellator1.addVertex((double) f10 * 1.5F, 100.0D, 0);
    tessellator1.addVertex(f10, 100.0D, f10);
    tessellator1.addVertex(0, 100.0D, (double) f10 * 1.5F);
    tessellator1.addVertex(-f10, 100.0D, f10);
    tessellator1.addVertex((double) -f10 * 1.5F, 100.0D, 0);
    tessellator1.addVertex(-f10, 100.0D, -f10);

    tessellator1.draw();
    GL11.glPopMatrix();
    GL11.glShadeModel(GL11.GL_FLAT);

    GL11.glEnable(GL11.GL_TEXTURE_2D);
    OpenGlHelper.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE, GL11.GL_ZERO);
    GL11.glPushMatrix();
    f7 = 0.0F;
    f8 = 0.0F;
    f9 = 0.0F;
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    GL11.glTranslatef(f7, f8, f9);
    GL11.glRotatef(-90.0F, 0.0F, 1.0F, 0.0F);
    GL11.glRotatef(world.getCelestialAngle(partialTicks) * 360.0F, 1.0F, 0.0F, 0.0F);
    // Render sun
    f10 = 14.0F;
    mc.renderEngine.bindTexture(SkyProviderMars.sunTexture);
    tessellator1.startDrawingQuads();
    tessellator1.addVertexWithUV(-f10, 100.0D, -f10, 0.0D, 0.0D);
    tessellator1.addVertexWithUV(f10, 100.0D, -f10, 1.0D, 0.0D);
    tessellator1.addVertexWithUV(f10, 100.0D, f10, 1.0D, 1.0D);
    tessellator1.addVertexWithUV(-f10, 100.0D, f10, 0.0D, 1.0D);
    tessellator1.draw();

    // Render earth
    f10 = 0.5F;
    GL11.glScalef(0.6F, 0.6F, 0.6F);
    GL11.glRotatef(40.0F, 0.0F, 0.0F, 1.0F);
    GL11.glRotatef(200F, 1.0F, 0.0F, 0.0F);
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1F);
    FMLClientHandler.instance().getClient().renderEngine.bindTexture(SkyProviderMars.overworldTexture);
    tessellator1.startDrawingQuads();
    tessellator1.addVertexWithUV(-f10, -100.0D, f10, 0, 1);
    tessellator1.addVertexWithUV(f10, -100.0D, f10, 1, 1);
    tessellator1.addVertexWithUV(f10, -100.0D, -f10, 1, 0);
    tessellator1.addVertexWithUV(-f10, -100.0D, -f10, 0, 0);
    tessellator1.draw();

    GL11.glDisable(GL11.GL_TEXTURE_2D);

    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    GL11.glDisable(GL11.GL_BLEND);
    GL11.glEnable(GL11.GL_ALPHA_TEST);
    GL11.glEnable(GL11.GL_FOG);
    GL11.glPopMatrix();
    GL11.glDisable(GL11.GL_TEXTURE_2D);
    GL11.glColor3f(0.0F, 0.0F, 0.0F);
    double d0 = mc.thePlayer.getPosition(partialTicks).yCoord - world.getHorizon();

    if (d0 < 0.0D) {
        GL11.glPushMatrix();
        GL11.glTranslatef(0.0F, 12.0F, 0.0F);
        GL11.glCallList(this.glSkyList2);
        GL11.glPopMatrix();
        f8 = 1.0F;
        f9 = -((float) (d0 + 65.0D));
        f10 = -f8;
        tessellator1.startDrawingQuads();
        tessellator1.setColorRGBA_I(0, 255);
        tessellator1.addVertex(-f8, f9, f8);
        tessellator1.addVertex(f8, f9, f8);
        tessellator1.addVertex(f8, f10, f8);
        tessellator1.addVertex(-f8, f10, f8);
        tessellator1.addVertex(-f8, f10, -f8);
        tessellator1.addVertex(f8, f10, -f8);
        tessellator1.addVertex(f8, f9, -f8);
        tessellator1.addVertex(-f8, f9, -f8);
        tessellator1.addVertex(f8, f10, -f8);
        tessellator1.addVertex(f8, f10, f8);
        tessellator1.addVertex(f8, f9, f8);
        tessellator1.addVertex(f8, f9, -f8);
        tessellator1.addVertex(-f8, f9, -f8);
        tessellator1.addVertex(-f8, f9, f8);
        tessellator1.addVertex(-f8, f10, f8);
        tessellator1.addVertex(-f8, f10, -f8);
        tessellator1.addVertex(-f8, f10, -f8);
        tessellator1.addVertex(-f8, f10, f8);
        tessellator1.addVertex(f8, f10, f8);
        tessellator1.addVertex(f8, f10, -f8);
        tessellator1.draw();
    }

    if (world.provider.isSkyColored()) {
        GL11.glColor3f(f1 * 0.2F + 0.04F, f2 * 0.2F + 0.04F, f3 * 0.6F + 0.1F);
    } else {
        GL11.glColor3f(f1, f2, f3);
    }

    GL11.glPushMatrix();
    GL11.glTranslatef(0.0F, -((float) (d0 - 16.0D)), 0.0F);
    GL11.glCallList(this.glSkyList2);
    GL11.glPopMatrix();
    GL11.glEnable(GL11.GL_TEXTURE_2D);
    GL11.glDepthMask(true);
}

From source file:net.malisis.core.client.gui.component.interaction.UICheckBox.java

License:Open Source License

@Override
public void drawBackground(GuiRenderer renderer, int mouseX, int mouseY, float partialTick) {
    shape.resetState();//from w  ww.j  a v a2s  .c o m
    shape.setSize(10, 10);
    shape.setPosition(1, 0);
    rp.icon.set(isDisabled() ? bgIconDisabled : bgIcon);
    renderer.drawShape(shape, rp);

    renderer.next();

    // draw the white shade over the slot
    if (hovered) {
        GL11.glDisable(GL11.GL_TEXTURE_2D);
        GL11.glEnable(GL11.GL_BLEND);
        GL11.glDisable(GL11.GL_ALPHA_TEST);
        OpenGlHelper.glBlendFunc(770, 771, 1, 0);
        GL11.glShadeModel(GL11.GL_SMOOTH);

        rp.colorMultiplier.set(0xFFFFFF);
        rp.alpha.set(80);
        rp.useTexture.set(false);

        shape.resetState();
        shape.setSize(8, 8);
        shape.setPosition(2, 1);
        renderer.drawShape(shape, rp);
        renderer.next();

        GL11.glShadeModel(GL11.GL_FLAT);
        GL11.glDisable(GL11.GL_BLEND);
        GL11.glEnable(GL11.GL_ALPHA_TEST);
        GL11.glEnable(GL11.GL_TEXTURE_2D);
    }

    if (label != null) {
        renderer.drawText(label, 14, 2, 0x404040, false);
    }
}

From source file:net.malisis.core.client.gui.component.interaction.UIRadioButton.java

License:Open Source License

@Override
public void drawBackground(GuiRenderer renderer, int mouseX, int mouseY, float partialTick) {
    shape.resetState();// w ww  .ja  v a 2 s  .c  o m
    shape.setSize(8, 8);
    shape.translate(1, 0, 0);
    rp.icon.set(isDisabled() ? bgIconDisabled : bgIcon);
    renderer.drawShape(shape, rp);

    renderer.next();

    // draw the white shade over the slot
    if (hovered) {
        GL11.glDisable(GL11.GL_TEXTURE_2D);
        GL11.glDisable(GL11.GL_ALPHA_TEST);
        renderer.enableBlending();

        rp = new RenderParameters();
        rp.colorMultiplier.set(0xFFFFFF);
        rp.alpha.set(80);
        rp.useTexture.set(false);

        shape.resetState();
        shape.setSize(6, 6);
        shape.setPosition(2, 1);
        renderer.drawShape(shape, rp);
        renderer.next();

        GL11.glShadeModel(GL11.GL_FLAT);
        GL11.glDisable(GL11.GL_BLEND);
        GL11.glEnable(GL11.GL_ALPHA_TEST);
        GL11.glEnable(GL11.GL_TEXTURE_2D);
    }

    if (label != null) {
        renderer.drawText(label, 12, 0, 0x404040, false);
    }
}

From source file:net.malisis.core.client.gui.component.UISlot.java

License:Open Source License

@Override
public void drawForeground(GuiRenderer renderer, int mouseX, int mouseY, float partialTick) {
    MalisisInventoryContainer container = MalisisGui.currentGui().getInventoryContainer();
    if (container == null)
        return;// ww w.  j  a  va 2 s.  com

    ItemStack itemStack = slot.getItemStack() != null ? slot.getItemStack().copy() : null;
    ItemStack draggedItemStack = slot.getDraggedItemStack();

    // if dragged slots contains an itemStack for this slot, add the stack size
    EnumChatFormatting format = null;
    if (itemStack == null)
        itemStack = draggedItemStack;
    else if (draggedItemStack != null) {
        itemStack.stackSize += draggedItemStack.stackSize;
        if (itemStack.stackSize == itemStack.getMaxStackSize())
            format = EnumChatFormatting.YELLOW;
    }

    if (itemStack != null)
        renderer.drawItemStack(itemStack, screenX() + 1, screenY() + 1, format);

    // draw the white shade over the slot
    if (hovered || draggedItemStack != null) {
        GL11.glDisable(GL11.GL_TEXTURE_2D);
        GL11.glEnable(GL11.GL_BLEND);
        GL11.glDisable(GL11.GL_ALPHA_TEST);
        OpenGlHelper.glBlendFunc(770, 771, 1, 0);
        GL11.glShadeModel(GL11.GL_SMOOTH);

        RenderParameters rp = new RenderParameters();
        rp.colorMultiplier.set(0xFFFFFF);
        rp.alpha.set(80);
        rp.useTexture.set(false);

        shape.resetState();
        shape.setSize(16, 16);
        shape.translate(1, 1, 100);
        renderer.drawShape(shape, rp);
        renderer.next();

        GL11.glShadeModel(GL11.GL_FLAT);
        GL11.glDisable(GL11.GL_BLEND);
        GL11.glEnable(GL11.GL_TEXTURE_2D);
    }
    GL11.glEnable(GL11.GL_ALPHA_TEST);

    // Dirty fix because Mojang can't count and masks overflow the slots
    shape.resetState();
    shape.setSize(1, 18);
    shape.translate(0, 0, 50);
    rp.icon.set(iconLeft);
    renderer.drawShape(shape, rp);
    shape.resetState();
    shape.setSize(18, 1);
    shape.translate(0, 0, 50);
    rp.icon.set(iconTop);
    renderer.drawShape(shape, rp);

}