Example usage for org.lwjgl.opengl GL11 glBlendFunc

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

Introduction

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

Prototype

public static void glBlendFunc(@NativeType("GLenum") int sfactor, @NativeType("GLenum") int dfactor) 

Source Link

Document

Specifies the weighting factors used by the blend equation, for both RGB and alpha functions and for all draw buffers.

Usage

From source file:junkdisplay.JunkDisplayLWJGL.java

private void initTextures() {

    // enable alpha blending
    GL11.glEnable(GL11.GL_BLEND);/*from www.  j a  va 2  s  . c  om*/

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

    levelmap = new TextureMapper();

    levelmap.initSheet(this.getClass().getResource("/junkimages/sky_spritesheet_5_12_2014.png"), "PNG");
    levelmap.addSpriteLocation("bluesky", new Rectangle2D.Float(0f, 0f, .195f, .195f));
    levelmap.addSpriteLocation("cloud", new Rectangle2D.Float(0.39f, 0f, .195f, .195f));
    levelmap.addSpriteLocation("sky", new Rectangle2D.Float(0f, 0.39f, .195f, .195f));
    levelmap.addSpriteLocation("night", new Rectangle2D.Float(.39f, .39f, .195f, .195f));

    charactermap = new TextureMapper();

    charactermap.initSheet(this.getClass().getResource("/junkimages/scenery_spritesheet_5_12_2014.png"), "PNG");
    charactermap.addSpriteLocation("character", new Rectangle2D.Float(.388f, .194f, .194f, .194f));
    charactermap.addSpriteLocation("missle", new Rectangle2D.Float(.388f, 0f, .194f, .194f));
    charactermap.addSpriteLocation("lightmissle", new Rectangle2D.Float(.582f, 0f, .194f, .194f));
    charactermap.addSpriteLocation("darkmissle", new Rectangle2D.Float(.582f, .194f, .194f, .194f));
    charactermap.addSpriteLocation("chaser", new Rectangle2D.Float(.194f, .582f, .194f, .194f));
    charactermap.addSpriteLocation("crawler", new Rectangle2D.Float(.194f, .582f, .194f, .194f));
    charactermap.addSpriteLocation("bulker", new Rectangle2D.Float(0f, 0f, .194f, .194f));
    charactermap.addSpriteLocation("lightitem", new Rectangle2D.Float(0f, .194f, .194f, .194f));
    charactermap.addSpriteLocation("item", new Rectangle2D.Float(.194f, 0f, .194f, .194f));
    charactermap.addSpriteLocation("darkitem", new Rectangle2D.Float(.194f, .194f, .194f, .194f));

    /*charactermap.addSpriteLocation("character", new Rectangle2D.Float(.588f, .2f, .194f, .294f));
    charactermap.addSpriteLocation("missle", new Rectangle2D.Float(.788f, .2f, .09f, .09f));
    charactermap.addSpriteLocation("lightmissle", new Rectangle2D.Float(.832f, 0f, .084f, .084f));
    charactermap.addSpriteLocation("darkmissle", new Rectangle2D.Float(.582f, .194f, .194f, .194f));
    charactermap.addSpriteLocation("chaser", new Rectangle2D.Float(.194f, .582f, .194f, .194f));
    charactermap.addSpriteLocation("crawler", new Rectangle2D.Float(.204f, .592f, .19f, .11f));
    charactermap.addSpriteLocation("bulker", new Rectangle2D.Float(0f, 0f, .554f, .594f));
    charactermap.addSpriteLocation("lightitem", new Rectangle2D.Float(0f, .194f, .194f, .194f));
    charactermap.addSpriteLocation("item", new Rectangle2D.Float(.194f, 0f, .194f, .194f));
    charactermap.addSpriteLocation("darkitem", new Rectangle2D.Float(.194f, .194f, .194f, .194f)); */

    newscenerymap = new TextureMapper();

    newscenerymap.initSheet(this.getClass().getResource("/junkimages/scenery_spritesheet_5_12_2014.png"),
            "PNG");
    newscenerymap.addSpriteLocation("floor", new Rectangle2D.Float(0f, .392f, .194f, .194f));
    newscenerymap.addSpriteLocation("block", new Rectangle2D.Float(0f, .585f, .194f, .194f));
    newscenerymap.addSpriteLocation("tallblock", new Rectangle2D.Float(.197f, .393f, .192f, .191f));
    newscenerymap.addSpriteLocation("darkblock", new Rectangle2D.Float(.585f, .39f, .194f, .194f));
    newscenerymap.addSpriteLocation("woodblock", new Rectangle2D.Float(.388f, .582f, .194f, .194f));

    scenerymap = new TextureMapper();

    scenerymap.initSheet(this.getClass().getResource("/junkimages/scenery_spritesheet_18_11_2014.png"), "PNG");
    scenerymap.addSpriteLocation("mossflat", new Rectangle2D.Float(0f, 0f, .299f, .064f));
    scenerymap.addSpriteLocation("mosscurve", new Rectangle2D.Float(0f, .0643f, .3f, .064f));
    scenerymap.addSpriteLocation("platform", new Rectangle2D.Float(0f, .13f, .3f, .05f));
    scenerymap.addSpriteLocation("iceplatform", new Rectangle2D.Float(0f, .18f, .3f, .025f));
    scenerymap.addSpriteLocation("fatplatform", new Rectangle2D.Float(0f, .205f, .295f, .075f));
    scenerymap.addSpriteLocation("largestalactite", new Rectangle2D.Float(0f, 0.293f, .29f, .52f));
    scenerymap.addSpriteLocation("largestalagmite", new Rectangle2D.Float(.3f, 0f, .285f, .52f));
    scenerymap.addSpriteLocation("smallstalagmite", new Rectangle2D.Float(.267f, .518f, .238f, .33f));
    scenerymap.addSpriteLocation("smallstalactite", new Rectangle2D.Float(.585f, 0f, .238f, .33f));
    scenerymap.addSpriteLocation("squareplatform", new Rectangle2D.Float(.587f, .33f, .197f, .197f));
    scenerymap.addSpriteLocation("leftmoss", new Rectangle2D.Float(.5f, .5275f, .181f, .064f));
    scenerymap.addSpriteLocation("rightmoss", new Rectangle2D.Float(.5f, .5915f, .181f, .064f));

    interactivemap = new TextureMapper();

    interactivemap.initSheet(this.getClass().getResource("/junkimages/interactive_spritesheet_22_11_2014.png"),
            "PNG");
    interactivemap.addSpriteLocation("iceright", new Rectangle2D.Float(0f, 0f, .1325f, .85f));
    interactivemap.addSpriteLocation("rockright", new Rectangle2D.Float(.1325f, 0f, .1325f, .85f));
    interactivemap.addSpriteLocation("iceleft", new Rectangle2D.Float(.265f, 0f, .1325f, .85f));
    interactivemap.addSpriteLocation("rockleft", new Rectangle2D.Float(.3975f, 0f, .1325f, .85f));

    decorationmap = new TextureMapper();

    decorationmap.initSheet(this.getClass().getResource("/junkimages/decoration_spritesheet_18_11_2014.png"),
            "PNG");
    decorationmap.addSpriteLocation("grass", new Rectangle2D.Float(0f, 0f, .6f, .046f));
    decorationmap.addSpriteLocation("shroom1", new Rectangle2D.Float(0f, .05f, .205f, .162f));
    decorationmap.addSpriteLocation("shroom2", new Rectangle2D.Float(0f, .212f, .205f, .162f));
    decorationmap.addSpriteLocation("shroom3", new Rectangle2D.Float(.205f, .048f, .21f, .165f));
    decorationmap.addSpriteLocation("shroom4", new Rectangle2D.Float(.205f, .216f, .21f, .165f));
    decorationmap.addSpriteLocation("grass1", new Rectangle2D.Float(.415f, .05f, .153f, .37f));
    decorationmap.addSpriteLocation("grass2", new Rectangle2D.Float(.588f, 0f, .153f, .37f));
    decorationmap.addSpriteLocation("grass3", new Rectangle2D.Float(.75f, 0f, .153f, .37f));
    decorationmap.addSpriteLocation("grass4", new Rectangle2D.Float(0f, .375f, .1528f, .37f));
    decorationmap.addSpriteLocation("shroom", new Rectangle2D.Float(.153f, .375f, .152f, .162f));

    moredecorationmap = new TextureMapper();

    moredecorationmap.initSheet(
            this.getClass().getResource("/junkimages/moredecoration_spritesheet_3_12_2014.png"), "PNG");
    moredecorationmap.addSpriteLocation("grass", new Rectangle2D.Float(0f, 0f, .6f, .046f));

    threatmap = new TextureMapper();

    //threatmap.initSheet(this.getClass().getResource("/junkimages/fire_spritesheet.png"), "PNG");
    //threatmap.addSpriteLocation("fire1", new Rectangle2D.Float(.00f, 0f, .33f, 1f));
    //threatmap.addSpriteLocation("fire2", new Rectangle2D.Float(.298f, 0f, .333333f, 1f));
    //threatmap.addSpriteLocation("fire3", new Rectangle2D.Float(.61f, 0f, .333333f, 1f));
    threatmap.initSheet(this.getClass().getResource("/junkimages/fireice_spritesheet_16_11_2014.png"), "PNG");
    threatmap.addSpriteLocation("fire1", new Rectangle2D.Float(.00f, 0f, .156f, .41f));
    threatmap.addSpriteLocation("fire2", new Rectangle2D.Float(.156f, 0f, .156f, .41f));
    threatmap.addSpriteLocation("fire3", new Rectangle2D.Float(.312f, 0f, .156f, .41f));
    threatmap.addSpriteLocation("ice1", new Rectangle2D.Float(.47f, 0f, .15f, .41f));
    threatmap.addSpriteLocation("ice2", new Rectangle2D.Float(.0f, .4f, .15f, .41f));
    threatmap.addSpriteLocation("ice3", new Rectangle2D.Float(.1f, .4f, .15f, .41f));

    healingmap = new TextureMapper();

    healingmap.initSheet(this.getClass().getResource("/junkimages/pooldrip_spritesheet_16_11_2014.png"), "PNG");
    healingmap.addSpriteLocation("pool1", new Rectangle2D.Float(0f, 0f, .39f, .085f));
    healingmap.addSpriteLocation("pool2", new Rectangle2D.Float(0f, 0f, .39f, .085f));
    healingmap.addSpriteLocation("pool3", new Rectangle2D.Float(0f, 0f, .39f, .085f));
    healingmap.addSpriteLocation("pool4", new Rectangle2D.Float(0f, 0f, .39f, .085f));
    healingmap.addSpriteLocation("pool5", new Rectangle2D.Float(0f, 0f, .39f, .085f));
    healingmap.addSpriteLocation("drop1", new Rectangle2D.Float(.0f, 0f, .15f, .1f));
    healingmap.addSpriteLocation("drop2", new Rectangle2D.Float(.0f, 0f, .15f, .1f));
    healingmap.addSpriteLocation("drop3", new Rectangle2D.Float(.0f, 0f, .15f, .1f));
    healingmap.addSpriteLocation("drop4", new Rectangle2D.Float(.0f, 0f, .15f, .1f));
    healingmap.addSpriteLocation("drop5", new Rectangle2D.Float(.0f, 0f, .15f, .1f));
    healingmap.addSpriteLocation("drop6", new Rectangle2D.Float(.0f, 0f, .15f, .1f));
    healingmap.addSpriteLocation("drop7", new Rectangle2D.Float(.0f, 0f, .15f, .1f));

    healthmap = new TextureMapper();

    healthmap.initSheet(this.getClass().getResource("/junkimages/waterhealth_spritesheet_11_11_2014.png"),
            "PNG");
    healthmap.addSpriteLocation("10", new Rectangle2D.Float(0f, 0f, .25f, .25f));
    healthmap.addSpriteLocation("20", new Rectangle2D.Float(0f, .25f, .25f, .25f));
    healthmap.addSpriteLocation("30", new Rectangle2D.Float(.25f, .25f, .25f, .25f));
    healthmap.addSpriteLocation("40", new Rectangle2D.Float(.5f, 0f, .25f, .25f));
    healthmap.addSpriteLocation("50", new Rectangle2D.Float(.5f, .25f, .25f, .25f));
    healthmap.addSpriteLocation("60", new Rectangle2D.Float(.75f, 0f, .25f, .25f));
    healthmap.addSpriteLocation("70", new Rectangle2D.Float(.75f, .25f, .25f, .25f));
    healthmap.addSpriteLocation("80", new Rectangle2D.Float(0f, .5f, .25f, .25f));
    healthmap.addSpriteLocation("90", new Rectangle2D.Float(0f, .75f, .25f, .25f));
    healthmap.addSpriteLocation("100", new Rectangle2D.Float(.25f, 0f, .25f, .25f));
    healthmap.addSpriteLocation("0", new Rectangle2D.Float(.9f, .9f, .01f, .01f));
    healthmap.addSpriteLocation("porthole", new Rectangle2D.Float(.25f, .5f, .25f, .25f));

    numbermap = new TextureMapper();

    numbermap.initSheet(this.getClass().getResource("/junkimages/number_spritesheet_11_11_2014.png"), "PNG");
    numbermap.addSpriteLocation("0", new Rectangle2D.Float(0f, 0f, .2f, .2f));
    numbermap.addSpriteLocation("1", new Rectangle2D.Float(.21f, 0f, .2f, .2f));
    numbermap.addSpriteLocation("2", new Rectangle2D.Float(.42f, 0f, .2f, .2f));
    numbermap.addSpriteLocation("3", new Rectangle2D.Float(.63f, 0f, .2f, .2f));
    numbermap.addSpriteLocation("4", new Rectangle2D.Float(0f, .206f, .2f, .2f));
    numbermap.addSpriteLocation("5", new Rectangle2D.Float(.21f, .206f, .2f, .2f));
    numbermap.addSpriteLocation("6", new Rectangle2D.Float(.42f, .206f, .2f, .206f));
    numbermap.addSpriteLocation("7", new Rectangle2D.Float(.63f, .206f, .2f, .206f));
    numbermap.addSpriteLocation("8", new Rectangle2D.Float(0f, .41f, .2f, .206f));
    numbermap.addSpriteLocation("9", new Rectangle2D.Float(.21f, .41f, .2f, .206f));
    numbermap.addSpriteLocation("blank", new Rectangle2D.Float(.63f, .41f, .2f, .206f));

    temperaturemap = new TextureMapper();

    temperaturemap.initSheet(this.getClass().getResource("/junkimages/temperature_spritesheet_17_11_2014.png"),
            "PNG");
    temperaturemap.addSpriteLocation("temp10", new Rectangle2D.Float(0f, 0f, .18f, .28f));
    temperaturemap.addSpriteLocation("temp20", new Rectangle2D.Float(.18f, 0f, .18f, .28f));
    temperaturemap.addSpriteLocation("temp30", new Rectangle2D.Float(.36f, 0f, .18f, .28f));
    temperaturemap.addSpriteLocation("temp40", new Rectangle2D.Float(.54f, 0f, .18f, .28f));
    temperaturemap.addSpriteLocation("temp50", new Rectangle2D.Float(0f, .288f, .18f, .28f));
    temperaturemap.addSpriteLocation("temp60", new Rectangle2D.Float(.18f, .288f, .18f, .28f));
    temperaturemap.addSpriteLocation("temp70", new Rectangle2D.Float(.36f, .288f, .18f, .28f));
    temperaturemap.addSpriteLocation("temp80", new Rectangle2D.Float(.54f, .288f, .18f, .28f));
    temperaturemap.addSpriteLocation("temp90", new Rectangle2D.Float(0f, .576f, .18f, .28f));

    menumap = new TextureMapper();

    menumap.initSheet(this.getClass().getResource("/junkimages/menu_spritesheet_1_12_2014.png"), "PNG");
    menumap.addSpriteLocation("levelcomplete", new Rectangle2D.Float(0f, 0f, .5f, .15f));
    menumap.addSpriteLocation("darken", new Rectangle2D.Float(0f, .2f, .1f, .1f));
    menumap.addSpriteLocation("paused", new Rectangle2D.Float(0f, .44f, .39f, .27f));
    menumap.addSpriteLocation("pressspacedark", new Rectangle2D.Float(0f, .715f, .35f, .0618f));
    menumap.addSpriteLocation("pressspacelight", new Rectangle2D.Float(0f, .78f, .35f, .0601f));
    menumap.addSpriteLocation("optionsdark", new Rectangle2D.Float(0f, .84f, .17f, .12f));
    menumap.addSpriteLocation("optionslight", new Rectangle2D.Float(0.17f, 0.84f, .17f, .12f));
    menumap.addSpriteLocation("quitlight", new Rectangle2D.Float(0.64f, .695f, .09f, .13f));
    menumap.addSpriteLocation("quitdark", new Rectangle2D.Float(0.5f, 0f, .09f, .13f));
    menumap.addSpriteLocation("d", new Rectangle2D.Float(0.39f, 0f, .39f, 1f));
    menumap.addSpriteLocation("r", new Rectangle2D.Float(0.39f, 0f, .39f, 1f));
    menumap.addSpriteLocation("drip", new Rectangle2D.Float(0.39f, 0f, .39f, 1f));
    menumap.addSpriteLocation("i", new Rectangle2D.Float(0.39f, 0f, .39f, 1f));
    menumap.addSpriteLocation("p", new Rectangle2D.Float(0.39f, 0f, .39f, 1f));

    leveleditormap = new TextureMapper();

    leveleditormap.initSheet(this.getClass().getResource("/junkimages/leveleditor_spritesheet_22_11_2014.png"),
            "PNG");
    leveleditormap.addSpriteLocation("bottombar", new Rectangle2D.Float(0f, 0f, .78f, .195f));
    leveleditormap.addSpriteLocation("sidebar", new Rectangle2D.Float(0f, .195f, .195f, .78f));

    GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL11.GL_REPEAT);

    GL11.glEnable(GL11.GL_TEXTURE_2D);
}

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

License:Open Source License

/**
 * R_RenderDlights/* ww  w. j  ava2s.  c  o m*/
 */
void R_RenderDlights() {
    if (gl_flashblend.value == 0)
        return;

    r_dlightframecount = r_framecount + 1; // because the count hasn't
    //  advanced yet for this frame
    GL11.glDepthMask(false);
    GL11.glDisable(GL11.GL_TEXTURE_2D);
    GL11.glShadeModel(GL11.GL_SMOOTH);
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_ONE, GL11.GL_ONE);

    for (int i = 0; i < r_newrefdef.num_dlights; i++) {
        R_RenderDlight(r_newrefdef.dlights[i]);
    }

    GL11.glColor3f(1, 1, 1);
    GL11.glDisable(GL11.GL_BLEND);
    GL11.glEnable(GL11.GL_TEXTURE_2D);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GL11.glDepthMask(true);
}

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);/* ww w. j  ava  2  s  .c  o  m*/
    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:kubex.KubexGame.java

License:Creative Commons License

/**
 * Inits the game resources (Images, pools, shaders, objects, etc.)
 *//*from ww  w .jav a 2  s  .co m*/
private void initResources() throws IOException {
    //Inits static pools
    FloatBufferPool.init(Chunk.CHUNK_DIMENSION * Chunk.CHUNK_DIMENSION * Chunk.CHUNK_DIMENSION * 2 * 6 * 6, 20);
    ByteArrayPool.init(Chunk.CHUNK_DIMENSION,
            (settings.RENDER_DISTANCE * 2 + 1) * World.HEIGHT * (settings.RENDER_DISTANCE * 2 + 1) * 2);
    glEnable(GL11.GL_CULL_FACE);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    glEnable(GL11.GL_BLEND);
    glClearColor(0.6f, 0.8f, 1.0f, 0f);

    //Inits shaders
    GL20.glUseProgram(0);
    textManager = new GlobalTextManager();
    this.DVSP = new DepthVoxelShaderProgram(true);
    this.VSP = new TerrainVoxelShaderProgram(true);
    this.HSP = new HudShaderProgram(true);
    this.DTSP = this.settings.SHADOWS_ENABLED ? new DeferredTerrainShaderProgram(true)
            : new DeferredTerrainUnshadowShaderProgram(true);
    this.DRSP = this.settings.REFLECTIONS_ENABLED ? new DeferredReflectionsShaderProgram(true)
            : new DeferredNoReflectionsShaderProgram(true);
    this.DUTSP = this.settings.SHADOWS_ENABLED ? new DeferredUnderwaterTerrainShaderProgram(true)
            : new DeferredUnderwaterUnshadowTerrainShaderProgram(true);
    this.DUFSP = new DeferredUnderwaterFinalShaderProgram(true);

    //Inits essential objects
    this.TM = new TimeManager();
    this.cam = new Camera(CAMERA_NEAR, CAMERA_FAR, 80f, (float) (X_RES * 3 / 4) / Y_RES); //FOV more width than height BY DESIGN, so blocks looks more "plane". Looks nicer that way, i think.
    this.camInvProjEnv = new CameraInverseProjEnvelope(this.cam);
    this.shadowsManager = new ShadowsManager(SHADOW_SPLITS, this.cam);
    this.liquidRenderer = new DepthPeelingLiquidRenderer(LIQUID_LAYERS);

    this.sunCam = new Camera(new Matrix4f());
    this.sunCam.moveTo(0, 5, 0);
    this.sunCam.setPitch(0);

    this.sky = new Sky(cam, this.sunCam);
    File mapRoute = new File(this.settings.MAP_ROUTE);
    mapRoute.mkdir(); //Creates the maps folder
    this.fileManager = new FileManager(mapRoute, settings.RENDER_DISTANCE);
    this.fileManager.getSettingsFromFile(settings); //Reads default settings from settings file.
    this.world = new World(this.VSP, this.cam, this.sunCam, this.shadowsManager, this.sky, fileManager,
            this.settings);
    this.finalDrawManager = new FinalDrawManager(this.world, this.sky, this.shadowsManager, this.liquidRenderer,
            this.camInvProjEnv.getInvProjMatrix(), CAMERA_NEAR, CAMERA_FAR);
    this.hud = new Hud(this.HSP, X_RES, Y_RES);

    //Load textures here
    glActiveTexture(TEXTURE_FETCH[TILES_TEXTURE_LOCATION]);

    //GL_NEAREST for that blocky look
    //loads the tiles textures into a array
    tilesTexture = Util.loadTextureAtlasIntoTextureArray(FileLoader.loadTileImages(), GL11.GL_NEAREST,
            GL11.GL_NEAREST_MIPMAP_LINEAR, true, settings.ANISOTROPIC_FILTERING_ENABLED);

    Util.loadPNGTexture(FileLoader.loadWaterNormalImage(), TEXTURE_FETCH[WATER_NORMAL_TEXTURE_LOCATION]); //loads the water normal texture

    glActiveTexture(GL_TEXTURE0);
    nightDomeTexture = TextureLoader.getTexture("JPG",
            ResourceLoader.getResourceAsStream("images/nightdome.jpg")); //loads the nightdome

    //Without this, text printing using Slick-Utils doesn't work. Seems it still uses some old mode OpenGL.
    GL11.glEnable(GL11.GL_TEXTURE_2D);
    GL11.glShadeModel(GL11.GL_SMOOTH);
    GL11.glDisable(GL11.GL_DEPTH_TEST);
    GL11.glDisable(GL11.GL_LIGHTING);
    GL11.glClearDepth(1);
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GL11.glViewport(0, 0, X_RES, Y_RES);
    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glLoadIdentity();
    GL11.glOrtho(0, X_RES, Y_RES, 0, 1, -1);
    GL11.glMatrixMode(GL11.GL_MODELVIEW);

    //First pass deferred rendering
    this.baseFbo = glGenFramebuffers();
    glBindFramebuffer(GL_FRAMEBUFFER, this.baseFbo);

    int colorTexture = glGenTextures();
    int brightnessNormalsTexture = glGenTextures();

    //Creates and inits the base color texture as a RGB texture
    glActiveTexture(TEXTURE_FETCH[BASEFBO_COLOR_TEXTURE_LOCATION]);
    glBindTexture(GL_TEXTURE_2D, colorTexture);
    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, X_RES, Y_RES, 0, GL_RGB, GL_UNSIGNED_BYTE, (FloatBuffer) null);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
    GL30.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, colorTexture, 0);

    //Creates and inits the brightness and normals texture as a RGBA texture
    glActiveTexture(TEXTURE_FETCH[BASEFBO_NORMALS_BRIGHTNESS_TEXTURE_LOCATION]);
    glBindTexture(GL_TEXTURE_2D, brightnessNormalsTexture);
    glTexImage2D(GL_TEXTURE_2D, 0, GL11.GL_RGBA, X_RES, Y_RES, 0, GL11.GL_RGBA, GL_UNSIGNED_BYTE,
            (FloatBuffer) null);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
    GL30.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT1, GL_TEXTURE_2D, brightnessNormalsTexture,
            0);

    //The depth buffer of this FBO will be a texture, too. This will make depth sorting slower but we will be able to access depth values later.
    int baseFboDepth = glGenTextures();

    glActiveTexture(TEXTURE_FETCH[BASEFBO_DEPTH_TEXTURE_LOCATION]);
    glBindTexture(GL_TEXTURE_2D, baseFboDepth);
    glTexImage2D(GL_TEXTURE_2D, 0, GL14.GL_DEPTH_COMPONENT24, X_RES, Y_RES, 0, GL_DEPTH_COMPONENT,
            GL_UNSIGNED_INT, (FloatBuffer) null);
    System.out.println("ERR" + GL11.glGetError());
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST);
    GL30.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, baseFboDepth, 0); //Set the depth texture as the default render depth target

    IntBuffer drawBuffers = BufferUtils.createIntBuffer(2); //Drawing to 2 textures

    drawBuffers.put(GL_COLOR_ATTACHMENT0);
    drawBuffers.put(GL_COLOR_ATTACHMENT1);

    drawBuffers.flip();
    GL20.glDrawBuffers(drawBuffers);

    //Second pass deferred rendering
    this.deferredFbo = glGenFramebuffers();
    glBindFramebuffer(GL_FRAMEBUFFER, this.deferredFbo);

    int deferredColorTex = glGenTextures();

    //Only uses one texture, a RGBA color texture
    glActiveTexture(TEXTURE_FETCH[DEFERREDFBO_COLOR_TEXTURE_LOCATION]);
    glBindTexture(GL_TEXTURE_2D, deferredColorTex);
    glTexImage2D(GL_TEXTURE_2D, 0, GL11.GL_RGBA, X_RES, Y_RES, 0, GL11.GL_RGBA, GL_UNSIGNED_BYTE,
            (FloatBuffer) null);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
    GL30.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, deferredColorTex, 0);

    drawBuffers = BufferUtils.createIntBuffer(1);

    drawBuffers.put(GL_COLOR_ATTACHMENT0);

    drawBuffers.flip();
    GL20.glDrawBuffers(drawBuffers);

    //If shadows are enabled, we init each shadow map texture, placed in an array
    if (this.settings.SHADOWS_ENABLED) {

        int shadowTexture = glGenTextures();

        glActiveTexture(TEXTURE_FETCH[SHADOW_TEXTURE_LOCATION]);

        glBindTexture(GL30.GL_TEXTURE_2D_ARRAY, shadowTexture);
        //Creates a texture array to place the shadows in
        GL12.glTexImage3D(GL30.GL_TEXTURE_2D_ARRAY, 0, GL14.GL_DEPTH_COMPONENT16, SHADOW_XRES, SHADOW_YRES,
                this.shadowsManager.getNumberSplits(), 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT,
                (FloatBuffer) null);
        System.out.println("ERR" + GL11.glGetError());
        glTexParameteri(GL30.GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR); //Needed to do hardware PCF comparisons via shader
        glTexParameteri(GL30.GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR); //Needed to do hardware PCF comparisons via shader
        glTexParameteri(GL30.GL_TEXTURE_2D_ARRAY, GL14.GL_TEXTURE_COMPARE_MODE, GL_COMPARE_REF_TO_TEXTURE); //Needed to do hardware PCF comparisons via shader

        this.shadowFbos = new int[this.shadowsManager.getNumberSplits()];
        //Creates one framebuffer per shadow map
        for (int i = 0; i < this.shadowsManager.getNumberSplits(); i++) {
            this.shadowFbos[i] = glGenFramebuffers();
            glBindFramebuffer(GL_FRAMEBUFFER, this.shadowFbos[i]);
            GL30.glFramebufferTextureLayer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, shadowTexture, 0, i); //Each framebuffer will have one texture layer (one index of the texture array created before) assigned as render target

            drawBuffers = BufferUtils.createIntBuffer(0);

            GL20.glDrawBuffers(drawBuffers);

        }
    }

    //Liquid layers depth generation. Equal to the shadows depth textures generation.
    int liquidLayers = glGenTextures();

    glActiveTexture(TEXTURE_FETCH[LIQUIDLAYERS_TEXTURE_LOCATION]);
    glBindTexture(GL30.GL_TEXTURE_2D_ARRAY, liquidLayers);
    GL12.glTexImage3D(GL30.GL_TEXTURE_2D_ARRAY, 0, GL14.GL_DEPTH_COMPONENT24, X_RES, Y_RES,
            this.liquidRenderer.getNumLayers(), 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, (FloatBuffer) null);

    glTexParameteri(GL30.GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST); //We will compare manually the depth in the shader, we will not perform PCF of any sort in this case
    glTexParameteri(GL30.GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST);

    int currentLiquidNormalTex = glGenTextures();

    glActiveTexture(KubexGame.TEXTURE_FETCH[KubexGame.CURRENT_LIQUID_NORMAL_TEXTURE_LOCATION]);
    glBindTexture(GL_TEXTURE_2D, currentLiquidNormalTex);
    glTexImage2D(GL_TEXTURE_2D, 0, GL11.GL_RGB, X_RES, Y_RES, 0, GL11.GL_RGB, GL11.GL_UNSIGNED_BYTE,
            (FloatBuffer) null);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);

    this.liquidRenderer.initResources(liquidLayers, currentLiquidNormalTex);

    //Reset active texture and fbo to the default
    glActiveTexture(GL13.GL_TEXTURE0);
    glBindFramebuffer(GL_FRAMEBUFFER, 0);
}

From source file:lyonlancer5.pfsteel.client.render.entity.RenderDesertCreeper.java

License:Open Source License

/**
 * Queries whether should render the specified pass or not.
 *///  w w  w . j av a  2s. c  o m
protected int shouldRenderPass(EntityDesertCreeper p_77032_1_, int p_77032_2_, float p_77032_3_) {
    if (p_77032_1_.getPowered()) {
        if (p_77032_1_.isInvisible()) {
            GL11.glDepthMask(false);
        } else {
            GL11.glDepthMask(true);
        }

        if (p_77032_2_ == 1) {
            float f1 = (float) p_77032_1_.ticksExisted + p_77032_3_;
            this.bindTexture(armoredCreeperTextures);
            GL11.glMatrixMode(GL11.GL_TEXTURE);
            GL11.glLoadIdentity();
            float f2 = f1 * 0.01F;
            float f3 = f1 * 0.01F;
            GL11.glTranslatef(f2, f3, 0.0F);
            this.setRenderPassModel(this.creeperModel);
            GL11.glMatrixMode(GL11.GL_MODELVIEW);
            GL11.glEnable(GL11.GL_BLEND);
            float f4 = 0.5F;
            GL11.glColor4f(f4, f4, f4, 1.0F);
            GL11.glDisable(GL11.GL_LIGHTING);
            GL11.glBlendFunc(GL11.GL_ONE, GL11.GL_ONE);
            return 1;
        }

        if (p_77032_2_ == 2) {
            GL11.glMatrixMode(GL11.GL_TEXTURE);
            GL11.glLoadIdentity();
            GL11.glMatrixMode(GL11.GL_MODELVIEW);
            GL11.glEnable(GL11.GL_LIGHTING);
            GL11.glDisable(GL11.GL_BLEND);
        }
    }

    return -1;
}

From source file:lyonlancer5.pfsteel.client.render.entity.RenderNetherCreeper.java

License:Open Source License

/**
 * Queries whether should render the specified pass or not.
 *//*  w  w  w  . j  a va 2 s  . c  om*/
protected int shouldRenderPass(EntityNetherCreeper p_77032_1_, int p_77032_2_, float p_77032_3_) {
    if (p_77032_1_.getPowered()) {
        if (p_77032_1_.isInvisible()) {
            GL11.glDepthMask(false);
        } else {
            GL11.glDepthMask(true);
        }

        if (p_77032_2_ == 1) {
            float f1 = (float) p_77032_1_.ticksExisted + p_77032_3_;
            this.bindTexture(armoredCreeperTextures);
            GL11.glMatrixMode(GL11.GL_TEXTURE);
            GL11.glLoadIdentity();
            float f2 = f1 * 0.01F;
            float f3 = f1 * 0.01F;
            GL11.glTranslatef(f2, f3, 0.0F);
            this.setRenderPassModel(this.creeperModel);
            GL11.glMatrixMode(GL11.GL_MODELVIEW);
            GL11.glEnable(GL11.GL_BLEND);
            float f4 = 0.5F;
            GL11.glColor4f(f4, f4, f4, 1.0F);
            GL11.glDisable(GL11.GL_LIGHTING);
            GL11.glBlendFunc(GL11.GL_ONE, GL11.GL_ONE);
            return 1;
        }

        if (p_77032_2_ == 2) {
            GL11.glMatrixMode(GL11.GL_TEXTURE);
            GL11.glLoadIdentity();
            GL11.glMatrixMode(GL11.GL_MODELVIEW);
            GL11.glEnable(GL11.GL_LIGHTING);
            GL11.glDisable(GL11.GL_BLEND);
        }
    }

    return -1;
}

From source file:lyonlancer5.pfsteel.client.render.entity.RenderSnowCreeper.java

License:Open Source License

/**
 * Queries whether should render the specified pass or not.
 *///from   w ww  . j ava 2 s.  c om
protected int shouldRenderPass(EntitySnowCreeper p_77032_1_, int p_77032_2_, float p_77032_3_) {
    if (p_77032_1_.getPowered()) {
        if (p_77032_1_.isInvisible()) {
            GL11.glDepthMask(false);
        } else {
            GL11.glDepthMask(true);
        }

        if (p_77032_2_ == 1) {
            float f1 = (float) p_77032_1_.ticksExisted + p_77032_3_;
            this.bindTexture(armoredCreeperTextures);
            GL11.glMatrixMode(GL11.GL_TEXTURE);
            GL11.glLoadIdentity();
            float f2 = f1 * 0.01F;
            float f3 = f1 * 0.01F;
            GL11.glTranslatef(f2, f3, 0.0F);
            this.setRenderPassModel(this.creeperModel);
            GL11.glMatrixMode(GL11.GL_MODELVIEW);
            GL11.glEnable(GL11.GL_BLEND);
            float f4 = 0.5F;
            GL11.glColor4f(f4, f4, f4, 1.0F);
            GL11.glDisable(GL11.GL_LIGHTING);
            GL11.glBlendFunc(GL11.GL_ONE, GL11.GL_ONE);
            return 1;
        }

        if (p_77032_2_ == 2) {
            GL11.glMatrixMode(GL11.GL_TEXTURE);
            GL11.glLoadIdentity();
            GL11.glMatrixMode(GL11.GL_MODELVIEW);
            GL11.glEnable(GL11.GL_LIGHTING);
            GL11.glDisable(GL11.GL_BLEND);
        }
    }

    return -1;
}

From source file:lyonlancer5.pfsteel.client.render.RenderDarkShield.java

License:Open Source License

protected void renderDarkMain(EntityDarkShield shield, double x, double y, double z, float yaw, float pitch) {
    GL11.glDisable(GL11.GL_LIGHTING);/*  ww w  . j  a  v  a2s  .co  m*/

    GL11.glPushMatrix();
    GL11.glDisable(GL11.GL_CULL_FACE);
    if (RenderManager.instance.getDistanceToCamera(shield.posX, shield.posY, shield.posZ) < 36.0D) {
        GL11.glDepthFunc(GL11.GL_ALWAYS);
    } else {
        GL11.glDepthMask(false);
    }
    GL11.glTranslatef((float) x, (float) y, (float) z);
    GL11.glRotatef(-renderManager.playerViewY, 0.0F, 1.0F, 0.0F);
    GL11.glRotatef(renderManager.playerViewX, 1.0F, 0.0F, 0.0F);

    Tessellator tessellator = Tessellator.instance;
    GL11.glDepthMask(false);
    GL11.glEnable(GL11.GL_BLEND);

    GL11.glBlendFunc(GL11.GL_ZERO, GL11.GL_ONE_MINUS_SRC_COLOR);
    GL11.glTranslatef(0.0F, 1.3F, 0.0F);
    this.bindTexture(darkTex);
    renderDark(tessellator, 12.0D, 12.0F, 0.0D, 1.0F, 0);
    GL11.glDisable(GL11.GL_BLEND);

    GL11.glDepthFunc(GL11.GL_LEQUAL);
    GL11.glEnable(GL11.GL_CULL_FACE);
    GL11.glDepthMask(true);
    GL11.glPopMatrix();

    GL11.glEnable(GL11.GL_LIGHTING);
}

From source file:lyonlancer5.pfsteel.client.render.RenderMagicCircle.java

License:Open Source License

public void renderSpellCardCircle(EntityMagicCircle circle, double x, double y, double z, float yaw,
        float pitch) {
    GL11.glPushMatrix();// w w w.j  av  a 2 s .c om
    bindEntityTexture(circle);
    GL11.glTranslatef((float) x, (float) y, (float) z);
    GL11.glDisable(GL11.GL_LIGHTING);
    GL11.glDisable(GL11.GL_CULL_FACE);
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_COLOR);
    float size = circle.getCircleSize() * 6.0F;
    GL11.glScalef(size, size, size);
    Tessellator tessellator = Tessellator.instance;
    float umin = 0.0F;
    float umax = 1.0F;
    float vmin = 0.0F;
    float vmax = 1.0F;

    boolean rainbow = false;
    int color = circle.getCircleType();

    if (color >= 16) {
        float angle = MathHelper.sin(2F * (float) circle.getAnimationCount() / 180F * (float) Math.PI) * 40F;
        GL11.glRotatef(180F - renderManager.playerViewY + angle, 0.0F, 1.0F, 0.0F);
        GL11.glRotatef(-renderManager.playerViewX - angle, 1.0F, 0.0F, 0.0F);
        GL11.glRotatef(circle.getAnimationCount() * 5F, 0.0F, 0.0F, 1.0F);
        color %= 16;
    } else {
        GL11.glRotatef(90F, 1.0F, 0.0F, 0.0F);
        GL11.glRotatef(circle.getAnimationCount() * 5F, 0.0F, 0.0F, 1.0F);
    }

    if (color == 9) {
        rainbow = true;
    } else {
        color %= 8;
    }

    tessellator.startDrawingQuads();

    if (rainbow) {
        float rainbowTime = circle.ticksExisted / 3.0F;
        tessellator.setColorRGBA_F(MathHelper.sin(rainbowTime), MathHelper.cos(rainbowTime),
                -MathHelper.sin(rainbowTime) * 2F, 1.0F);
    } else {
        tessellator.setColorRGBA_F(colorR[color], colorG[color], colorB[color], 1.0F);
    }
    tessellator.setNormal(0.0F, 1.0F, 0.0F);
    tessellator.addVertexWithUV(-0.6F, -0.6F, 0.0D, umin, vmax);
    tessellator.addVertexWithUV(0.6F, -0.6F, 0.0D, umax, vmax);
    tessellator.addVertexWithUV(0.6F, 0.6F, 0.0D, umax, vmin);
    tessellator.addVertexWithUV(-0.6F, 0.6F, 0.0D, umin, vmin);
    tessellator.draw();
    GL11.glDisable(GL11.GL_BLEND);
    GL11.glEnable(GL11.GL_LIGHTING);
    GL11.glEnable(GL11.GL_CULL_FACE);
    GL11.glPopMatrix();
}

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

License:Open Source License

@Override
@SideOnly(Side.CLIENT)/*from  w w  w. j a va 2s  .  co 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);
}