예제 #1
0
 public static void renderEnchantmentEffects(Tessellator tessellator) {
   GL11.glDepthFunc(GL11.GL_EQUAL);
   GL11.glDisable(GL11.GL_LIGHTING);
   FMLClientHandler.instance().getClient().renderEngine.bindTexture(ITEM_GLINT);
   GL11.glEnable(GL11.GL_BLEND);
   GL11.glBlendFunc(GL11.GL_SRC_COLOR, GL11.GL_ONE);
   float f7 = 0.76F;
   GL11.glColor4f(0.5F * f7, 0.25F * f7, 0.8F * f7, 1.0F);
   GL11.glMatrixMode(GL11.GL_TEXTURE);
   GL11.glPushMatrix();
   float f8 = 0.125F;
   GL11.glScalef(f8, f8, f8);
   float f9 = (float) (Minecraft.getSystemTime() % 3000L) / 3000.0F * 8.0F;
   GL11.glTranslatef(f9, 0.0F, 0.0F);
   GL11.glRotatef(-50.0F, 0.0F, 0.0F, 1.0F);
   RenderManager.instance.itemRenderer.renderItemIn2D(
       tessellator, 0.0F, 0.0F, 1.0F, 1.0F, 256, 256, 0.0625F);
   GL11.glPopMatrix();
   GL11.glPushMatrix();
   GL11.glScalef(f8, f8, f8);
   f9 = (float) (Minecraft.getSystemTime() % 4873L) / 4873.0F * 8.0F;
   GL11.glTranslatef(-f9, 0.0F, 0.0F);
   GL11.glRotatef(10.0F, 0.0F, 0.0F, 1.0F);
   RenderManager.instance.itemRenderer.renderItemIn2D(
       tessellator, 0.0F, 0.0F, 1.0F, 1.0F, 256, 256, 0.0625F);
   GL11.glPopMatrix();
   GL11.glMatrixMode(GL11.GL_MODELVIEW);
   GL11.glDisable(GL11.GL_BLEND);
   GL11.glEnable(GL11.GL_LIGHTING);
   GL11.glDepthFunc(GL11.GL_LEQUAL);
 }
예제 #2
0
  /** Renders the dragon model. Called by renderModel. */
  protected void renderDragonModel(
      EntityDragon par1EntityDragon,
      float par2,
      float par3,
      float par4,
      float par5,
      float par6,
      float par7) {
    if (par1EntityDragon.deathTicks > 0) {
      float f = (float) par1EntityDragon.deathTicks / 200F;
      GL11.glDepthFunc(GL11.GL_LEQUAL);
      GL11.glEnable(GL11.GL_ALPHA_TEST);
      GL11.glAlphaFunc(GL11.GL_GREATER, f);
      loadDownloadableImageTexture(par1EntityDragon.skinUrl, "/mob/enderdragon/shuffle.png");
      mainModel.render(par1EntityDragon, par2, par3, par4, par5, par6, par7);
      GL11.glAlphaFunc(GL11.GL_GREATER, 0.1F);
      GL11.glDepthFunc(GL11.GL_EQUAL);
    }

    loadDownloadableImageTexture(par1EntityDragon.skinUrl, par1EntityDragon.getTexture());
    mainModel.render(par1EntityDragon, par2, par3, par4, par5, par6, par7);

    if (par1EntityDragon.hurtTime > 0) {
      GL11.glDepthFunc(GL11.GL_EQUAL);
      GL11.glDisable(GL11.GL_TEXTURE_2D);
      GL11.glEnable(GL11.GL_BLEND);
      GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
      GL11.glColor4f(1.0F, 0.0F, 0.0F, 0.5F);
      mainModel.render(par1EntityDragon, par2, par3, par4, par5, par6, par7);
      GL11.glEnable(GL11.GL_TEXTURE_2D);
      GL11.glDisable(GL11.GL_BLEND);
      GL11.glDepthFunc(GL11.GL_LEQUAL);
    }
  }
  @Override
  protected void renderModel(
      EntityDragonMinion par1EntityDragonMinion,
      float par2,
      float par3,
      float par4,
      float par5,
      float par6,
      float par7) {
    bindEntityTexture(par1EntityDragonMinion);
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    mainModel.render(par1EntityDragonMinion, par2, par3, par4, par5, par6, par7);
    GL11.glDisable(GL11.GL_BLEND);

    if (par1EntityDragonMinion.hurtTime > 0) {
      GL11.glDepthFunc(GL11.GL_EQUAL);
      GL11.glDisable(GL11.GL_TEXTURE_2D);
      GL11.glEnable(GL11.GL_BLEND);
      GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
      GL11.glColor4f(1.0F, 0.0F, 0.0F, 0.5F);
      mainModel.render(par1EntityDragonMinion, par2, par3, par4, par5, par6, par7);
      GL11.glEnable(GL11.GL_TEXTURE_2D);
      GL11.glDisable(GL11.GL_BLEND);
      GL11.glDepthFunc(GL11.GL_LEQUAL);
    }
  }
예제 #4
0
  /** R_Clear */
  void R_Clear() {
    if (gl_ztrick.value != 0.0f) {

      if (gl_clear.value != 0.0f) {
        GL11.glClear(GL11.GL_COLOR_BUFFER_BIT);
      }

      trickframe++;
      if ((trickframe & 1) != 0) {
        gldepthmin = 0;
        gldepthmax = 0.49999f;
        GL11.glDepthFunc(GL11.GL_LEQUAL);
      } else {
        gldepthmin = 1;
        gldepthmax = 0.5f;
        GL11.glDepthFunc(GL11.GL_GEQUAL);
      }
    } else {
      if (gl_clear.value != 0.0f) GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);
      else GL11.glClear(GL11.GL_DEPTH_BUFFER_BIT);

      gldepthmin = 0;
      gldepthmax = 1;
      GL11.glDepthFunc(GL11.GL_LEQUAL);
    }
    GL11.glDepthRange(gldepthmin, gldepthmax);
  }
예제 #5
0
  /** Renders the dragon model. Called by renderModel. */
  protected void renderDragonModel(
      EntityDragonBoss par1EntityDragonBoss,
      float par2,
      float par3,
      float par4,
      float par5,
      float par6,
      float par7) {
    if (par1EntityDragonBoss.deathTicks > 0) {
      float f6 = par1EntityDragonBoss.deathTicks / 200.0F;
      GL11.glDepthFunc(GL11.GL_LEQUAL);
      GL11.glEnable(GL11.GL_ALPHA_TEST);
      GL11.glAlphaFunc(GL11.GL_GREATER, f6);
      bindTexture(field_110842_f);
      mainModel.render(par1EntityDragonBoss, par2, par3, par4, par5, par6, par7);
      GL11.glAlphaFunc(GL11.GL_GREATER, 0.1F);
      GL11.glDepthFunc(GL11.GL_EQUAL);
    }

    bindEntityTexture(par1EntityDragonBoss);
    mainModel.render(par1EntityDragonBoss, par2, par3, par4, par5, par6, par7);

    if (par1EntityDragonBoss.hurtTime > 0) {
      GL11.glDepthFunc(GL11.GL_EQUAL);
      GL11.glDisable(GL11.GL_TEXTURE_2D);
      GL11.glEnable(GL11.GL_BLEND);
      GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
      GL11.glColor4f(1.0F, 0.0F, 0.0F, 0.5F);
      mainModel.render(par1EntityDragonBoss, par2, par3, par4, par5, par6, par7);
      GL11.glEnable(GL11.GL_TEXTURE_2D);
      GL11.glDisable(GL11.GL_BLEND);
      GL11.glDepthFunc(GL11.GL_LEQUAL);
    }
  }
예제 #6
0
  /** Renders the overlay for glowing eyes and the mouth. Called by shouldRenderPass. */
  protected int renderGlow(EntityDragon par1EntityDragon, int par2, float par3) {
    if (par2 == 1) {
      GL11.glDepthFunc(GL11.GL_LEQUAL);
    }

    if (par2 != 0) {
      return -1;
    } else {
      loadTexture("/mob/enderdragon/ender_eyes.png");
      float f = 1.0F;
      GL11.glEnable(GL11.GL_BLEND);
      GL11.glDisable(GL11.GL_ALPHA_TEST);
      GL11.glBlendFunc(GL11.GL_ONE, GL11.GL_ONE);
      GL11.glDisable(GL11.GL_LIGHTING);
      GL11.glDepthFunc(GL11.GL_EQUAL);
      int i = 61680;
      int j = i % 0x10000;
      int k = i / 0x10000;
      OpenGlHelper.setLightmapTextureCoords(
          OpenGlHelper.lightmapTexUnit, (float) j / 1.0F, (float) k / 1.0F);
      GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
      GL11.glEnable(GL11.GL_LIGHTING);
      GL11.glColor4f(1.0F, 1.0F, 1.0F, f);
      return 1;
    }
  }
  public void doRender(
      EntityTimeDisruption entity, double par2, double par3, double par4, float par5, float par6) {
    float f = -0.125F;
    float f1 = 0.025F;
    GL11.glPushMatrix();

    GL11.glDisable(GL11.GL_CULL_FACE);
    GL11.glTranslatef((float) par2, (float) par3 + f, (float) par4);
    GL11.glEnable(GL12.GL_RESCALE_NORMAL);
    GL11.glScalef(0.85F, 0.85F, 0.85F);
    GL11.glEnable(GL11.GL_ALPHA_TEST);
    GL11.glEnable(GL11.GL_NORMALIZE);
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    this.bindTexture(this.getEntityTexture(entity));
    GL11.glMatrixMode(GL11.GL_TEXTURE);
    GL11.glLoadIdentity();
    float f2 = MathHelper.cos(f1 * 0.15F) * 0.56F;
    float f3 = f1 * 0.02F;
    GL11.glTranslatef(f2, f3, 0.0F);
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glColor4f(1.1F, 1.6F, 1.1F, 0.35F);
    GL11.glDisable(GL11.GL_LIGHTING);
    GL11.glBlendFunc(GL11.GL_ONE, GL11.GL_ONE);
    GL11.glTranslatef(0.0F, 0.0F, 0.0F);
    GL11.glMatrixMode(GL11.GL_TEXTURE);
    GL11.glLoadIdentity();
    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glEnable(GL11.GL_LIGHTING);
    GL11.glDisable(GL11.GL_BLEND);
    this.model.render(entity, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, f1);
    GL11.glDepthMask(true);
    OpenGlHelper.setActiveTexture(OpenGlHelper.lightmapTexUnit);
    GL11.glDisable(GL11.GL_TEXTURE_2D);
    OpenGlHelper.setActiveTexture(OpenGlHelper.defaultTexUnit);
    GL11.glDisable(GL11.GL_TEXTURE_2D);
    GL11.glDisable(GL11.GL_ALPHA_TEST);
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GL11.glDepthFunc(GL11.GL_EQUAL);
    GL11.glDepthFunc(GL11.GL_LEQUAL);
    GL11.glDisable(GL11.GL_BLEND);
    GL11.glEnable(GL11.GL_ALPHA_TEST);
    GL11.glEnable(GL11.GL_TEXTURE_2D);
    GL11.glDisable(GL12.GL_RESCALE_NORMAL);
    OpenGlHelper.setActiveTexture(OpenGlHelper.lightmapTexUnit);
    GL11.glEnable(GL11.GL_TEXTURE_2D);
    OpenGlHelper.setActiveTexture(OpenGlHelper.defaultTexUnit);
    GL11.glEnable(GL11.GL_CULL_FACE);
    GL11.glPopMatrix();
  }
예제 #8
0
 private void renderEffectSlot(TextureManager manager, int x, int y) {
   GL11.glDepthFunc(GL11.GL_EQUAL);
   // GL11.glDisable(GL11.GL_LIGHTING);
   GL11.glDepthMask(false);
   manager.bindTexture(RES_ITEM_GLINT);
   GL11.glEnable(GL11.GL_ALPHA_TEST);
   GL11.glEnable(GL11.GL_BLEND);
   GL11.glColor4f(0.5F, 0.25F, 0.8F, 1.0F);
   // this.renderGlintSlot(x * 431278612 + y * 32178161, x - 2, y - 2, 20, 20);
   this.renderGlintSlot(x, y, 150, 20);
   OpenGlHelper.glBlendFunc(770, 771, 1, 0);
   GL11.glDepthMask(true);
   // GL11.glEnable(GL11.GL_LIGHTING);
   GL11.glDepthFunc(GL11.GL_LEQUAL);
 }
예제 #9
0
  public static void initOrtho(int width, int height) {
    glEnable(GL_TEXTURE_2D);

    glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);

    glEnable(GL_BLEND);
    //		glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
    glBlendFunc(GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    //		glBlendFunc(GL11.GL_SRC_COLOR, GL11.GL_ONE_MINUS_CONSTANT_COLOR);
    //		GL11.glDisable(GL_BLEND);
    //		GL11.glDepthMask(true);

    glEnable(GL_ALPHA_TEST);
    glAlphaFunc(GL_GREATER, 0.1f);

    glEnable(GL_DEPTH_TEST);
    glDepthFunc(GL_LEQUAL); // The Type Of Depth Testing To Do

    glViewport(0, 0, width, height);
    glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
    glLoadIdentity(); // Reset The Projection Matrix

    // Calculate The Aspect Ratio Of The Window
    glOrtho(0, width, 0, height, -99999, 99999);
    glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix

    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
  }
예제 #10
0
  @Override
  protected void init() {
    initializeProgram();

    try {
      cylinderMesh = new Mesh("UnitCylinder.xml");
      planeMesh = new Mesh("LargePlane.xml");
    } catch (Exception exception) {
      exception.printStackTrace();
      System.exit(-1);
    }

    glEnable(GL_CULL_FACE);
    glCullFace(GL_BACK);
    glFrontFace(GL_CW);

    glEnable(GL_DEPTH_TEST);
    glDepthMask(true);
    glDepthFunc(GL_LEQUAL);
    glDepthRange(0.0f, 1.0f);
    glEnable(GL_DEPTH_CLAMP);

    projectionUniformBuffer = glGenBuffers();
    glBindBuffer(GL_UNIFORM_BUFFER, projectionUniformBuffer);
    glBufferData(GL_UNIFORM_BUFFER, ProjectionBlock.SIZE, GL_DYNAMIC_DRAW);

    // Bind the static buffers.
    glBindBufferRange(
        GL_UNIFORM_BUFFER, projectionBlockIndex, projectionUniformBuffer, 0, ProjectionBlock.SIZE);

    glBindBuffer(GL_UNIFORM_BUFFER, 0);
  }
예제 #11
0
  public static void drawModel(Model m) {
    glFrontFace(GL_CCW);
    glCullFace(GL_BACK);
    glEnable(GL_CULL_FACE);

    glDepthFunc(GL_LEQUAL);
    glEnable(GL_DEPTH_TEST);

    for (Polygon p : m.mesh) {
      glBindTexture(GL_TEXTURE_2D, p.tex.id);

      glBegin(GL_TRIANGLES);
      {
        for (Vertex v : p.vertices) {
          glTexCoord2f(v.uv.x, v.uv.y);
          glNormal3f(v.norm.x, v.norm.y, v.norm.z);
          glVertex3f(v.pos.x, v.pos.y, v.pos.z);
        }
      }
      glEnd();
    }

    glDisable(GL_CULL_FACE);
    glDisable(GL_DEPTH_TEST);
  }
예제 #12
0
  private void initialise() {
    DisplayMode mode = new DisplayMode(WIDTH, HEIGHT);
    Display.setTitle(TITLE);

    input = new InputHandler();
    display = new CodeDisplay(input);

    try {
      Display.setDisplayMode(mode);
      Display.setResizable(false);
      Display.create();

      if (!GLContext.getCapabilities().OpenGL33)
        System.err.printf("You must have at least OpenGL 3.3 to run this program\n");
    } catch (LWJGLException e) {
      e.printStackTrace();
      System.exit(-1);
    }

    // Set clear color

    glShadeModel(GL_SMOOTH);
    glClearColor(0.0f, 0.0f, 0.0f, 0.0f);

    glEnable(GL_DEPTH_TEST);
    glDepthFunc(GL_LEQUAL); // Less than or equal
    glClearDepth(1.0);

    establishProjectionMatrix();

    // glEnable(GL_LIGHTING);
    // glEnable(GL_LIGHT0);
  }
  /**
   * *************************************************************************************************************************************************************************************************
   * Initialization stuff comes in here...
   * ************************************************************************************************************************************************************************************************
   */
  private void init() {

    try {
      Display.setDisplayMode(new DisplayMode(640, 480));
      Display.setVSyncEnabled(true);
      Display.setTitle("MS3D Loader [G36C]");
      Display.create();

      Keyboard.create();

    } catch (LWJGLException e) {
      Sys.alert("Error", "Initialization failed!\n\n" + e.getMessage());
      System.exit(0);
    }

    /* OpenGL */
    int width = Display.getDisplayMode().getWidth();
    int height = Display.getDisplayMode().getHeight();

    GL11.glViewport(0, 0, width, height); // Reset The Current Viewport
    GL11.glMatrixMode(GL11.GL_PROJECTION); // Select The Projection Matrix
    GL11.glLoadIdentity(); // Reset The Projection Matrix
    GLU.gluPerspective(
        45.0f,
        ((float) width / (float) height),
        0.1f,
        1000.0f); // Calculate The Aspect Ratio Of The Window
    GL11.glMatrixMode(GL11.GL_MODELVIEW); // Select The Modelview Matrix
    GL11.glLoadIdentity(); // Reset The Modelview Matrix

    GL11.glEnable(GL11.GL_TEXTURE_2D);
    GL11.glShadeModel(GL11.GL_SMOOTH);
    GL11.glClearColor(0.0f, 0.0f, 0.0f, 0.5f); // Background color
    GL11.glClearDepth(1.0f);
    GL11.glEnable(GL11.GL_DEPTH_TEST);
    GL11.glDepthFunc(GL11.GL_LEQUAL);
    GL11.glHint(GL11.GL_PERSPECTIVE_CORRECTION_HINT, GL11.GL_NICEST);

    // Load model
    //		g36c = new
    // MS3DModel(resourceLoader.loadResourceAsStream("models/gsg9.ms3d"),this.getClass().getResource("./data/textures").getPath());
    g36c =
        new MS3DModel(
            resourceLoader.loadResourceAsStream("models/assassin.ms3d"),
            this.getClass().getResource("./data/textures").getPath());

    //		tdsLoader=new TDSLoader();
    //		try {
    //			tdsLoader.load(resourceLoader.loadResourceAsStream("models/face.3ds"));
    //			System.out.println(tdsLoader.getObjectSize());
    //		} catch (IOException e) {
    //			e.printStackTrace();
    //		}

    // Load font
    font = new Font(resourceLoader.loadResourceAsStream("textures/font.bmp"), 12, width, height);

    // Init timer
    timer = new Timer();
  }
예제 #14
0
  public static void initPerspective(int width, int height, float zClose, float zFar) {
    fov = 55.0f;

    glEnable(GL_TEXTURE_2D);

    //		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);

    //		glEnable(GL_TEXTURE_2D);

    //		glEnable(GL_CULL_FACE);

    //		glShadeModel(GL_SMOOTH); // Enable Smooth Shading
    glClearDepth(1.0); // Depth Buffer Setup
    glEnable(GL_DEPTH_TEST); // Enables Depth Testing
    glDepthFunc(GL_LEQUAL); // The Type Of Depth Testing To Do

    glEnable(GL_CULL_FACE);
    glCullFace(GL_BACK);

    glViewport(0, 0, width, height);
    glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
    glLoadIdentity(); // Reset The Projection Matrix

    // Calculate The Aspect Ratio Of The Window
    gluPerspective(fov, (float) width / height, zClose, zFar);
    //		glOrtho(1, 1, 1, 1, -1, 1);
    glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix

    // Really Nice Perspective Calculations
    glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);

    glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); // GL_DECAL);
  }
예제 #15
0
 public void renderChildren(Context c) {
   c.setProjection(1);
   GL11.glEnable(GL11.GL_DEPTH_TEST);
   GL11.glDepthFunc(GL11.GL_GREATER);
   super.renderChildren(c);
   GL11.glDisable(GL11.GL_DEPTH_TEST);
   c.setProjection(0);
 }
예제 #16
0
  private void initGL() {
    glClearColor(0.0f, 0.0f, 0.0f, 0.0f); // sets background to grey
    glClearDepth(1.0f); // clear depth buffer
    glEnable(GL_DEPTH_TEST); // Enables depth testing
    glDepthFunc(GL_LEQUAL); // sets the type of test to use for depth testing
    glMatrixMode(GL_PROJECTION); // sets the matrix mode to project

    // GLU.gluOrtho2D(-10, 10, -10, 10);
    // GLU.gluOrtho2D(0 - COORD_WIDTH / 2, 0 + COORD_WIDTH / 2, 0 - COORD_HEIGHT / 2, 0 +
    // COORD_HEIGHT / 2);
    float fovy = 90.0f;
    float aspect = DISPLAY_MODE.getWidth() / (float) DISPLAY_MODE.getHeight();
    float zNear = 0.1f;
    float zFar = 20000.0f;
    GLU.gluPerspective(fovy, aspect, zNear, zFar);

    glViewport(0, 0, DISPLAY_MODE.getWidth(), DISPLAY_MODE.getHeight());
    // GLU.gluOrtho2D(-10, 10, -10, 10);
    // GLU.gluOrtho2D(-1, 1, -1, 1);

    glOrtho(
        0 - COORD_WIDTH / 2,
        0 + COORD_WIDTH / 2,
        0 - COORD_HEIGHT / 2,
        0 + COORD_HEIGHT / 2,
        zNear,
        zFar);

    System.out.println(COORD_WIDTH + ", " + COORD_HEIGHT);

    glMatrixMode(GL_MODELVIEW);

    glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);

    // ----------- Variables & method calls added for Lighting Test -----------//
    initLightArrays();
    glShadeModel(GL_SMOOTH);
    glMaterial(GL_FRONT, GL_SPECULAR, matSpecular); // sets specular material color
    glMaterialf(GL_FRONT, GL_SHININESS, 50.0f); // sets shininess

    glLight(GL_LIGHT0, GL_POSITION, lightPosition); // sets light position
    glLight(GL_LIGHT0, GL_SPECULAR, whiteLight); // sets specular light to white
    glLight(GL_LIGHT0, GL_DIFFUSE, whiteLight); // sets diffuse light to white
    glLightModel(GL_LIGHT_MODEL_AMBIENT, lModelAmbient); // global ambient light

    glEnable(GL_LIGHTING); // enables lighting
    glEnable(GL_LIGHT0); // enables light0

    glEnable(GL_COLOR_MATERIAL); // enables opengl to use glColor3f to define material color
    glColorMaterial(
        GL_FRONT,
        GL_AMBIENT_AND_DIFFUSE); // tell opengl glColor3f effects the ambient and diffuse properties
                                 // of material
    // ----------- END: Variables & method calls added for Lighting Test -----------//

  }
예제 #17
0
  private void doInventoryRendering(
      ItemStack item, byte[] heraldryData, IHeraldryItem heraldryItem) {

    Icon icon = heraldryItem.getBaseIcon(item);

    itemRenderer.zLevel += 100;
    if (heraldryItem.shouldDoPass(IHeraldryItem.HeraldyRenderPassess.Pattern) && icon != null) {
      glPushMatrix();

      glColor3f(1, 1, 1);
      itemRenderer.renderIcon(0, 0, icon, 16, 16);

      ResourceLocation crestLocation =
          new ResourceLocation("Small:" + HeraldryData.byteArrayToHex(heraldryData));
      TextureObject texture = Minecraft.getMinecraft().renderEngine.getTexture(crestLocation);
      if (texture == null) {
        texture = new HeraldryTextureSmall(new HeraldryData(heraldryData));
        Minecraft.getMinecraft().renderEngine.loadTexture(crestLocation, texture);
      }
      Minecraft.getMinecraft().renderEngine.bindTexture(crestLocation);

      glDepthFunc(GL11.GL_EQUAL);
      glEnable(GL_BLEND);
      glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
      renderTexturedQuad(0, 0, itemRenderer.zLevel, 16, 16);

      glDisable(GL_BLEND);
      GL11.glDepthFunc(GL11.GL_LEQUAL);

      glPopMatrix();
    }

    icon = heraldryItem.getPostRenderIcon(item);
    if (heraldryItem.shouldDoPass(IHeraldryItem.HeraldyRenderPassess.PostRenderIcon)
        && icon != null) {
      glPushMatrix();
      glColor3f(1, 1, 1);
      // itemRenderer.renderIcon(0, 0, icon, 16, 16);
      glPopMatrix();
    }

    itemRenderer.zLevel -= 100;
  }
예제 #18
0
  /** Renders the overlay for glowing eyes and the mouth. Called by shouldRenderPass. */
  protected int renderGlow(EntityDragonBoss par1entitydragonboss, int par2, float par3) {
    if (par2 == 1) GL11.glDepthFunc(GL11.GL_LEQUAL);

    if (par2 != 0) return -1;
    else {
      bindTexture(field_110845_h);
      float f1 = 1.0F;
      GL11.glEnable(GL11.GL_BLEND);
      GL11.glDisable(GL11.GL_ALPHA_TEST);
      GL11.glBlendFunc(GL11.GL_ONE, GL11.GL_ONE);
      GL11.glDisable(GL11.GL_LIGHTING);
      GL11.glDepthFunc(GL11.GL_EQUAL);
      char c0 = 61680;
      int j = c0 % 65536;
      int k = c0 / 65536;
      OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, j / 1.0F, k / 1.0F);
      GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
      GL11.glEnable(GL11.GL_LIGHTING);
      GL11.glColor4f(1.0F, 1.0F, 1.0F, f1);
      return 1;
    }
  }
예제 #19
0
  /** Render the item's icon or block into the GUI, including the glint effect. */
  public void renderItemAndEffectIntoGUI(
      FontRenderer par1FontRenderer,
      RenderEngine par2RenderEngine,
      ItemStack par3ItemStack,
      int par4,
      int par5) {
    if (par3ItemStack != null) {
      if (!ForgeHooksClient.renderInventoryItem(
          renderBlocks,
          par2RenderEngine,
          par3ItemStack,
          renderWithColor,
          zLevel,
          (float) par4,
          (float) par5)) {
        this.renderItemIntoGUI(par1FontRenderer, par2RenderEngine, par3ItemStack, par4, par5);
      }

      if (par3ItemStack.hasEffect()) {
        GL11.glDepthFunc(GL11.GL_GREATER);
        GL11.glDisable(GL11.GL_LIGHTING);
        GL11.glDepthMask(false);
        par2RenderEngine.bindTexture("%blur%/misc/glint.png");
        this.zLevel -= 50.0F;
        GL11.glEnable(GL11.GL_BLEND);
        GL11.glBlendFunc(GL11.GL_DST_COLOR, GL11.GL_DST_COLOR);
        GL11.glColor4f(0.5F, 0.25F, 0.8F, 1.0F);
        this.renderGlint(par4 * 431278612 + par5 * 32178161, par4 - 2, par5 - 2, 20, 20);
        GL11.glDisable(GL11.GL_BLEND);
        GL11.glDepthMask(true);
        this.zLevel += 50.0F;
        GL11.glEnable(GL11.GL_LIGHTING);
        GL11.glDepthFunc(GL11.GL_LEQUAL);
      }
    }
  }
예제 #20
0
  public void initGL() {
    // Setup Display
    try {
      if (display_parent != null) {
        Display.setParent(display_parent);
      }
      Display.setDisplayMode(new DisplayMode(1000, 1000));
      Display.create(new PixelFormat(24, 8, 24, 0, 0));
      Display.setTitle("JGE3d");

      // Create a fullscreen window with 1:1 orthographic 2D projection
      // (default)
      Display.setFullscreen(false);

      // Enable vsync if we can (due to how OpenGL works, it cannot be
      // guarenteed to always work)
      // TODO: Make Configurable by User
      Display.setVSyncEnabled(true);
    } catch (LWJGLException e) {
      e.printStackTrace();
    }
    window_manager = new WindowManager();

    // camera = (Camera) objectList.getItem(Camera.CAMERA_NAME);

    setPerspective();

    // Set default openGL for drawing
    // GL11.glShadeModel(GL11.GL_SMOOTH);
    GL11.glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
    GL11.glClearDepth(1.0f);
    GL11.glEnable(GL11.GL_DEPTH_TEST);
    GL11.glDepthFunc(GL11.GL_LEQUAL);

    // Initialize default settings
    ByteBuffer temp = ByteBuffer.allocateDirect(16);
    temp.order(ByteOrder.nativeOrder());

    if (GLContext.getCapabilities().GL_ARB_vertex_buffer_object) {
      supports_vbo = true;
    } else {
      supports_vbo = false;
    }

    // Blending functions so we can have transparency
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GL11.glEnable(GL11.GL_BLEND);
  }
예제 #21
0
 public static void initOpenGL() {
   GLPrep.resizedRefresh();
   GL11.glEnable(GL11.GL_ALPHA_TEST); // allows alpha channels or
   // transperancy
   GL11.glAlphaFunc(GL11.GL_GREATER, 0.1f); // set alpha aceptance
   GL11.glEnable(GL11.GL_COLOR_MATERIAL);
   GL11.glDisable(GL11.GL_DITHER);
   GL11.glShadeModel(GL11.GL_SMOOTH); // smooth shading
   GL11.glClearDepth(1.0); // Enables Clearing Of The Depth Buffer
   GL11.glDepthMask(true); // turn on depth mask
   GL11.glEnable(GL11.GL_DEPTH_TEST); // Enables Depth Testing
   GL11.glDepthFunc(GL11.GL_ALWAYS); // The Type Of Depth Test To Do
   GL11.glHint(GL11.GL_PERSPECTIVE_CORRECTION_HINT, GL11.GL_NICEST);
   GL11.glEnable(GL11.GL_TEXTURE_2D); // enable 2d textures
   RenderManager.registerRenders();
 }
예제 #22
0
  /** Initialisation de la fenêtre OpenGl, de la camera et des textures. */
  public final void initGL() {
    // Création de la fenetre
    try {
      if (Setting.getFullScreen()) {
        Display.setDisplayModeAndFullscreen(
            new DisplayMode(Setting.get3DWidth(), Setting.get3DHeight()));
      } else {
        Display.setDisplayMode(new DisplayMode(Setting.get3DWidth(), Setting.get3DHeight()));
      }

      Display.setTitle("Visualisation 3D");
      Display.sync(Setting.getFps());
      Display.create();

    } catch (LWJGLException e) {
      e.printStackTrace();
      System.exit(0);
    }

    float fAspect = (float) Setting.getWWidth() / (float) Setting.getWHeight();
    GL11.glViewport(0, 0, Setting.getWWidth(), Setting.getWHeight());
    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glLoadIdentity();
    GLU.gluPerspective(45.0f, fAspect, 1.0f, 1000.0f);
    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glLoadIdentity();
    GL11.glEnable(GL11.GL_DEPTH_TEST);
    GL11.glDepthFunc(GL11.GL_LEQUAL);
    GL11.glShadeModel(GL11.GL_SMOOTH);
    GL11.glEnable(GL11.GL_CULL_FACE);

    // Initialisation de la Camera
    camera = new Camera("3D");
    camera.init();
    camera.yaw(140.0f);
    camera.pitch(20.0f);

    // Récupération des textures
    textures = new Textures();
    textures.init();
    textures.loadTexture();

    wind = new Wind();

    matrice.loadImg();
  }
예제 #23
0
 public static void setupView(int width, int height) {
   glPopAttrib();
   glPushAttrib(GL_ENABLE_BIT);
   glEnable(GL_TEXTURE_2D);
   glEnable(GL_BLEND);
   glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
   setupLighting();
   glClearDepth(1D);
   glEnable(GL_DEPTH_TEST);
   glEnable(GL_CULL_FACE);
   glDepthFunc(GL_LEQUAL);
   glViewport(0, 0, width, height);
   glMatrixMode(GL_PROJECTION);
   glLoadIdentity();
   gluPerspective(60F, (float) width / height, 0.1F, 1000F);
   glMatrixMode(GL_MODELVIEW);
   glLoadIdentity();
 }
예제 #24
0
  // ***************************************************************************
  // initGL
  // ***************************************************************************
  private static boolean initGL() {
    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glLoadIdentity();

    // Calculate the aspect ratio of the window
    GLU.gluPerspective(45.0f, ((float) targetWidth) / ((float) targetHeight), 0.1f, 100.0f);

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

    GL11.glEnable(GL11.GL_TEXTURE_2D);

    // Enable Texture Mapping (NEW)
    GL11.glShadeModel(GL11.GL_SMOOTH);
    GL11.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
    GL11.glClearDepth(1.0f);
    GL11.glEnable(GL11.GL_DEPTH_TEST);
    GL11.glDepthFunc(GL11.GL_LEQUAL);
    GL11.glHint(GL11.GL_PERSPECTIVE_CORRECTION_HINT, GL11.GL_NICEST);

    return true;
  }
예제 #25
0
파일: Vorxel.java 프로젝트: Pitzik4/Geode
  public static void init(VorxelSettings set, Geode gamep) {
    world = new World();
    game = gamep;
    try {
      DisplayMode d[] = Display.getAvailableDisplayModes();
      DisplayMode displayMode = d[0];
      Display.setDisplayMode(displayMode);
      Display.create();

      Mouse.create();
      Keyboard.create();

      GL11.glEnable(GL11.GL_TEXTURE_2D); // Enable Texture Mapping
      GL11.glShadeModel(GL11.GL_SMOOTH); // Enable Smooth Shading
      GL11.glClearColor(0.0f, 0.0f, 0.0f, 0.0f); // Black Background
      GL11.glClearDepth(1.0); // Depth Buffer Setup
      GL11.glEnable(GL11.GL_DEPTH_TEST); // Enables Depth Testing
      GL11.glDepthFunc(GL11.GL_LEQUAL); // The Type Of Depth Testing To Do

      GL11.glMatrixMode(GL11.GL_PROJECTION); // Select The Projection Matrix
      GL11.glLoadIdentity(); // Reset The Projection Matrix
      // Calculate The Aspect Ratio Of The Window
      GLU.gluPerspective(
          45.0f, (float) displayMode.getWidth() / (float) displayMode.getHeight(), 0.1f, 100.0f);
      GL11.glMatrixMode(GL11.GL_MODELVIEW); // Select The Modelview Matrix

      // Really Nice Perspective Calculations
      GL11.glHint(GL11.GL_PERSPECTIVE_CORRECTION_HINT, GL11.GL_NICEST);
      TextureHelper.init();
      Cube.dirt.texture = new VTex(4);
      Cube.grass.texture = Cube.dirt.texture;
      Cube.grass.toptexture = new VTex(1);
      Mouse.setGrabbed(true);
      world.createSpawn();
    } catch (LWJGLException e) {
      e.printStackTrace();
    }
  }
예제 #26
0
파일: GdxGL20.java 프로젝트: hanchao/vtm
 public void glDepthFunc(int func) {
   GL11.glDepthFunc(func);
 }
예제 #27
0
  protected void doRenderItem(
      ItemRenderType type, ItemStack item, Item iconItem, FluidStack fluid) {

    IIcon icon = iconItem.getIcon(item, 0);
    IIcon mask = iconItem.getIcon(item, 1);
    boolean hasFluid = fluid != null;

    IIcon fluidIcon = hasFluid ? fluid.getFluid().getIcon(fluid) : mask;
    int fluidSheet = hasFluid ? fluid.getFluid().getSpriteNumber() : 0;
    int colorMult = hasFluid ? fluid.getFluid().getColor(fluid) : 0xFFFFFF;
    boolean isFloaty = hasFluid ? fluid.getFluid().getDensity(fluid) < 0 : false;

    if (fluid == null) {
      fluidIcon = Blocks.flowing_lava.getIcon(2, 0);
      fluidSheet = 0;
      colorMult = 0x3F3F3F;
    }
    GL11.glPushMatrix();

    Tessellator tessellator = Tessellator.instance;

    float iconMinX = icon.getMinU();
    float iconMaxX = icon.getMaxU();
    float iconMinY = icon.getMinV();
    float iconMaxY = icon.getMaxV();

    float maskMinX = mask.getMinU();
    float maskMaxX = mask.getMaxU();
    float maskMinY = mask.getMinV();
    float maskMaxY = mask.getMaxV();

    float fluidMinX = fluidIcon.getMinU();
    float fluidMaxX = fluidIcon.getMaxU();
    float fluidMinY = fluidIcon.getMinV();
    float fluidMaxY = fluidIcon.getMaxV();

    if (isFloaty && canFlip) {
      iconMaxY = icon.getMinV();
      iconMinY = icon.getMaxV();

      maskMaxY = mask.getMinV();
      maskMinY = mask.getMaxV();

      fluidMaxY = fluidIcon.getMinV();
      fluidMinY = fluidIcon.getMaxV();
    }
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glEnable(GL11.GL_ALPHA_TEST);
    OpenGlHelper.glBlendFunc(
        GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ZERO);
    int texture = GL11.glGetInteger(GL11.GL_TEXTURE_BINDING_2D);

    if (type == ItemRenderType.INVENTORY) {
      GL11.glDisable(GL11.GL_LIGHTING);

      tessellator.startDrawingQuads();
      tessellator.addVertexWithUV(0, 16, 0, iconMinX, iconMaxY);
      tessellator.addVertexWithUV(16, 16, 0, iconMaxX, iconMaxY);
      tessellator.addVertexWithUV(16, 0, 0, iconMaxX, iconMinY);
      tessellator.addVertexWithUV(0, 0, 0, iconMinX, iconMinY);
      tessellator.draw();

      if (hasFluid) {
        tessellator.startDrawingQuads();
        tessellator.addVertexWithUV(0, 16, 0.001, maskMinX, maskMaxY);
        tessellator.addVertexWithUV(16, 16, 0.001, maskMaxX, maskMaxY);
        tessellator.addVertexWithUV(16, 0, 0.001, maskMaxX, maskMinY);
        tessellator.addVertexWithUV(0, 0, 0.001, maskMinX, maskMinY);
        tessellator.draw();

        GL11.glEnable(GL11.GL_CULL_FACE);
        GL11.glDepthFunc(GL11.GL_EQUAL);
        GL11.glDepthMask(false);
        GL11.glMatrixMode(GL11.GL_TEXTURE);
        bindTexture(RenderHelper.engine(), fluidSheet);
        OpenGlHelper.glBlendFunc(GL11.GL_ONE, GL11.GL_ZERO, GL11.GL_ONE, GL11.GL_ZERO);

        tessellator.startDrawingQuads();
        tessellator.setColorOpaque_I(colorMult);
        tessellator.addVertexWithUV(0, 16, 0.001, fluidMinX, fluidMaxY);
        tessellator.addVertexWithUV(16, 16, 0.001, fluidMaxX, fluidMaxY);
        tessellator.addVertexWithUV(16, 0, 0.001, fluidMaxX, fluidMinY);
        tessellator.addVertexWithUV(0, 0, 0.001, fluidMinX, fluidMinY);
        tessellator.draw();

        GL11.glMatrixMode(GL11.GL_MODELVIEW);
        GL11.glDepthMask(true);
        GL11.glDepthFunc(GL11.GL_LEQUAL);
      }

      GL11.glEnable(GL11.GL_LIGHTING);
    } else {
      GL11.glEnable(GL12.GL_RESCALE_NORMAL);

      if (type == ItemRenderType.ENTITY) {
        GL11.glTranslatef(0.5f, 4 / -16f, 0);
        GL11.glRotatef(180, 0, 1, 0);
      }
      ItemRenderer.renderItemIn2D(
          tessellator,
          iconMaxX,
          iconMinY,
          iconMinX,
          iconMaxY,
          icon.getIconWidth(),
          icon.getIconHeight(),
          0.0625F);

      if (hasFluid) {
        tessellator.startDrawingQuads();
        tessellator.setNormal(0, 0, 1);
        tessellator.addVertexWithUV(0, 0, 0.001, maskMaxX, maskMaxY);
        tessellator.addVertexWithUV(1, 0, 0.001, maskMinX, maskMaxY);
        tessellator.addVertexWithUV(1, 1, 0.001, maskMinX, maskMinY);
        tessellator.addVertexWithUV(0, 1, 0.001, maskMaxX, maskMinY);
        tessellator.draw();
        tessellator.startDrawingQuads();
        tessellator.setNormal(0, 0, -1);
        tessellator.addVertexWithUV(0, 1, -0.0635, maskMinX, maskMinY);
        tessellator.addVertexWithUV(1, 1, -0.0635, maskMaxX, maskMinY);
        tessellator.addVertexWithUV(1, 0, -0.0635, maskMaxX, maskMaxY);
        tessellator.addVertexWithUV(0, 0, -0.0635, maskMinX, maskMaxY);
        tessellator.draw();

        GL11.glEnable(GL11.GL_CULL_FACE);
        GL11.glDepthFunc(GL11.GL_EQUAL);
        GL11.glDepthMask(false);
        bindTexture(RenderHelper.engine(), fluidSheet);
        OpenGlHelper.glBlendFunc(GL11.GL_ONE, GL11.GL_ZERO, GL11.GL_ONE, GL11.GL_ZERO);

        tessellator.startDrawingQuads();
        tessellator.setNormal(0, 0, 1);
        tessellator.setColorOpaque_I(colorMult);
        tessellator.addVertexWithUV(0, 0, 0.001, fluidMaxX, fluidMaxY);
        tessellator.addVertexWithUV(1, 0, 0.001, fluidMinX, fluidMaxY);
        tessellator.addVertexWithUV(1, 1, 0.001, fluidMinX, fluidMinY);
        tessellator.addVertexWithUV(0, 1, 0.001, fluidMaxX, fluidMinY);
        tessellator.draw();

        tessellator.startDrawingQuads();
        tessellator.setNormal(0, 0, -1);
        tessellator.setColorOpaque_I(colorMult);
        tessellator.addVertexWithUV(0, 1, -0.0635, fluidMinX, fluidMinY);
        tessellator.addVertexWithUV(1, 1, -0.0635, fluidMaxX, fluidMinY);
        tessellator.addVertexWithUV(1, 0, -0.0635, fluidMaxX, fluidMaxY);
        tessellator.addVertexWithUV(0, 0, -0.0635, fluidMinX, fluidMaxY);
        tessellator.draw();

        GL11.glDepthMask(true);
        GL11.glDepthFunc(GL11.GL_LEQUAL);
      }
      GL11.glDisable(GL12.GL_RESCALE_NORMAL);
    }

    GL11.glBindTexture(GL11.GL_TEXTURE_2D, texture);
    OpenGlHelper.glBlendFunc(
        GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ZERO);
    GL11.glDisable(GL11.GL_ALPHA_TEST);
    GL11.glPopMatrix();
  }
예제 #28
0
  public void display() {
    GL11.glViewport(0, 0, width, height);
    GL11.glClearColor(0.5f, 0.5f, 0.5f, 0.1f);

    GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);

    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glLoadIdentity();
    float widthHeightRatio = width / height;
    GLU.gluPerspective(45, widthHeightRatio, 1, 1000);
    GLU.gluLookAt(
        player.getX(),
        player.getY(),
        player.getZ(),
        player.getCamX(),
        player.getCamY(),
        player.getCamZ(),
        0,
        1,
        0);
    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glLoadIdentity();
    // Level

    GL11.glDepthFunc(GL11.GL_LEQUAL);
    GL11.glEnable(GL11.GL_DEPTH_TEST);

    for (byte i = 0; i < level.getSizeX(); i += 1) {
      for (byte j = 0; j < level.getSizeY(); j += 1) {
        for (byte k = 0; k < level.getSizeZ(); k += 1) {
          if (level.getCubeName(i, j, k).equals(Cube.CUBE_BOMB)) {
            objects.DrawCubeBomb(i * SIZE_OF_CUBE, j * SIZE_OF_CUBE, k * SIZE_OF_CUBE);
          } else if (level.getCubeName(i, j, k).equals(Cube.CUBE_EXPLOSION)) {
            objects.DrawCubeExplosion(i * SIZE_OF_CUBE, j * SIZE_OF_CUBE, k * SIZE_OF_CUBE);
          } else if (level.getCubeName(i, j, k).equals(Cube.CUBE_EXPLOSION_HIDE_EXIT)) {
            objects.DrawCubeExplosion(i * SIZE_OF_CUBE, j * SIZE_OF_CUBE, k * SIZE_OF_CUBE);
          } else if (level.getCubeName(i, j, k).equals(Cube.CUBE_EXPLOSION_HIDE_ITEM)) {
            objects.DrawCubeExplosion(i * SIZE_OF_CUBE, j * SIZE_OF_CUBE, k * SIZE_OF_CUBE);
          } else if (level.getCubeName(i, j, k).equals(Cube.CUBE_ITEM_HEALTH)) {
            objects.DrawCubeItemHealth(i * SIZE_OF_CUBE, j * SIZE_OF_CUBE, k * SIZE_OF_CUBE);
          } else if (level.getCubeName(i, j, k).equals(Cube.CUBE_ITEM_XTRA_BOMB)) {
            objects.DrawCubeItemXtraBomb(i * SIZE_OF_CUBE, j * SIZE_OF_CUBE, k * SIZE_OF_CUBE);
          } else if (level.getCubeName(i, j, k).equals(Cube.CUBE_ITEM_BOMB_RANGE)) {
            objects.DrawCubeItemBombRange(i * SIZE_OF_CUBE, j * SIZE_OF_CUBE, k * SIZE_OF_CUBE);
          } else if (level.getCubeName(i, j, k).equals(Cube.CUBE_ITEM_BOMB_STRENGTH)) {
            objects.DrawCubeItemBombStrength(i * SIZE_OF_CUBE, j * SIZE_OF_CUBE, k * SIZE_OF_CUBE);
          } else if (level.getCubeName(i, j, k).equals(Cube.CUBE_ITEM_PORTAL)) {
            objects.DrawCubeItemPortal(i * SIZE_OF_CUBE, j * SIZE_OF_CUBE, k * SIZE_OF_CUBE);
          } else if (level.getCubeName(i, j, k).equals(Cube.CUBE_ITEM_DOUBLE_SCORE)) {
            objects.DrawCubeItemDoubleScore(i * SIZE_OF_CUBE, j * SIZE_OF_CUBE, k * SIZE_OF_CUBE);
          } else if (level.getCubeName(i, j, k).equals(Cube.CUBE_SOLID)) {
            objects.DrawCubeSolid(i * SIZE_OF_CUBE, j * SIZE_OF_CUBE, k * SIZE_OF_CUBE);
          } else if (level.getCubeName(i, j, k).equals(Cube.CUBE_OUTSIDE)) {
            objects.DrawCubeOutside(i * SIZE_OF_CUBE, j * SIZE_OF_CUBE, k * SIZE_OF_CUBE);
          } else if (level.getCubeName(i, j, k).equals(Cube.CUBE_OBSTACLE)) {
            objects.DrawCubeObstacle(i * SIZE_OF_CUBE, j * SIZE_OF_CUBE, k * SIZE_OF_CUBE);
          } else if (level.getCubeName(i, j, k).equals(Cube.CUBE_OBSTACLE_HIDE_EXIT)) {
            objects.DrawCubeObstacle(i * SIZE_OF_CUBE, j * SIZE_OF_CUBE, k * SIZE_OF_CUBE);
          } else if (level.getCubeName(i, j, k).equals(Cube.CUBE_EXIT)) {
            objects.DrawCubeExit(i * SIZE_OF_CUBE, j * SIZE_OF_CUBE, k * SIZE_OF_CUBE);
          } else if (level.getCubeName(i, j, k).equals(Cube.CUBE_SOLID_RAMP)) {
            objects.DrawCubeRamp(i * SIZE_OF_CUBE, j * SIZE_OF_CUBE, k * SIZE_OF_CUBE);
            // Menüwürfel
          } else if (level.getCubeName(i, j, k).equals(Cube.MENU_CUBE_NEW_GAME)) {
            objects.DrawMenuCubeNewGame(i * SIZE_OF_CUBE, j * SIZE_OF_CUBE, k * SIZE_OF_CUBE);
          } else if (level.getCubeName(i, j, k).equals(Cube.MENU_CUBE_NEW_GAME_GRAVITY)) {
            objects.DrawMenuCubeNewGameGravity(
                i * SIZE_OF_CUBE, j * SIZE_OF_CUBE, k * SIZE_OF_CUBE);
          } else if (level.getCubeName(i, j, k).equals(Cube.MENU_CUBE_EXIT_PROGRAM)) {
            objects.DrawMenuCubeExitProgram(i * SIZE_OF_CUBE, j * SIZE_OF_CUBE, k * SIZE_OF_CUBE);
          } else if (level.getCubeName(i, j, k).equals(Cube.MENU_CUBE_MULTI)) {
            objects.DrawMenuCubeMulti(i * SIZE_OF_CUBE, j * SIZE_OF_CUBE, k * SIZE_OF_CUBE);
          } else if (level.getCubeName(i, j, k).equals(Cube.MENU_CUBE_SERVER)) {
            objects.DrawMenuCubeServer(i * SIZE_OF_CUBE, j * SIZE_OF_CUBE, k * SIZE_OF_CUBE);
          } else if (level.getCubeName(i, j, k).equals(Cube.MENU_CUBE_OPTIONS)) {
            objects.DrawMenuCubeOptions(i * SIZE_OF_CUBE, j * SIZE_OF_CUBE, k * SIZE_OF_CUBE);
          } else if (level.getCubeName(i, j, k).equals(Cube.MENU_CUBE_LOAD_LEVEL)) {
            objects.DrawMenuCubeLoadLevel(i * SIZE_OF_CUBE, j * SIZE_OF_CUBE, k * SIZE_OF_CUBE);
          }
        }
      }
    }
    if (listPlayer != null) {
      for (int i = 0; i < listPlayer.size(); i++) {
        if (listPlayer.get(i).getNumber() != player.getNumber()) {
          objects.DrawPlayer(
              listPlayer.get(i).getX() - (SIZE_OF_CUBE / 2),
              listPlayer.get(i).getY() - (SIZE_OF_CUBE / 2),
              listPlayer.get(i).getZ() - (SIZE_OF_CUBE / 2));
        }
      }
    }

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

    // GL11.glOrtho(-CLIPSIZE, +CLIPSIZE, -CLIPSIZE, +CLIPSIZE, -CLIPSIZE *
    // 100.0f, +CLIPSIZE * 100.0f);
    // GL11.glOrtho(-CLIPSIZE, +CLIPSIZE, -CLIPSIZE, +CLIPSIZE, -CLIPSIZE,
    // +CLIPSIZE);
    GL11.glOrtho(
        -Window.width / 2,
        +Window.width / 2,
        -Window.height / 2,
        +Window.height / 2,
        -CLIPSIZE,
        +CLIPSIZE);

    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glLoadIdentity();
    // GL11.glTranslatef(1f, 1f, 0.0f);

    GL11.glDisable(GL11.GL_DEPTH_TEST);

    hud.renderHUD();

    GL11.glFlush();
  }
예제 #29
0
  public void doRenderLiving(
      EntityLiving par1EntityLiving,
      double par2,
      double par4,
      double par6,
      float par8,
      float par9) {
    GL11.glPushMatrix();
    GL11.glDisable(GL11.GL_CULL_FACE);
    mainModel.onGround = renderSwingProgress(par1EntityLiving, par9);

    if (renderPassModel != null) {
      renderPassModel.onGround = mainModel.onGround;
    }

    mainModel.isRiding = par1EntityLiving.isRiding();

    if (renderPassModel != null) {
      renderPassModel.isRiding = mainModel.isRiding;
    }

    mainModel.isChild = par1EntityLiving.isChild();

    if (renderPassModel != null) {
      renderPassModel.isChild = mainModel.isChild;
    }

    try {
      float f =
          func_48418_a(
              par1EntityLiving.prevRenderYawOffset, par1EntityLiving.renderYawOffset, par9);
      float f1 =
          func_48418_a(
              par1EntityLiving.prevRotationYawHead, par1EntityLiving.rotationYawHead, par9);
      float f2 =
          par1EntityLiving.prevRotationPitch
              + (par1EntityLiving.rotationPitch - par1EntityLiving.prevRotationPitch) * par9;
      renderLivingAt(par1EntityLiving, par2, par4, par6);
      float f3 = handleRotationFloat(par1EntityLiving, par9);
      rotateCorpse(par1EntityLiving, f3, f, par9);
      float f4 = 0.0625F;
      GL11.glEnable(GL12.GL_RESCALE_NORMAL);
      GL11.glScalef(-1F, -1F, 1.0F);
      preRenderCallback(par1EntityLiving, par9);
      if (!bobbing) {
        GL11.glTranslatef(0.0F, -24F * f4 - 0.0078125F, 0.0F);
      }
      float f5 =
          par1EntityLiving.field_705_Q
              + (par1EntityLiving.field_704_R - par1EntityLiving.field_705_Q) * par9;
      float f6;
      if (bobbing) {
        f6 =
            par1EntityLiving.field_9359_x
                + (par1EntityLiving.field_9360_w - par1EntityLiving.field_9359_x) * par9;
        if (par1EntityLiving.isChild()) {
          f6 *= 3F;
        }
        float bobStrength = 0F;
        if ((par1EntityLiving instanceof EntityZombie
                || par1EntityLiving instanceof EntitySkeleton
                || par1EntityLiving instanceof EntityCreeper
                || par1EntityLiving instanceof EntityPig
                || par1EntityLiving instanceof EntitySheep
                || par1EntityLiving instanceof EntityPlayer
                || par1EntityLiving instanceof EntityOtherPlayerMP)
            && !par1EntityLiving.isChild()) {
          bobStrength = 1.0F;
        }
        float f32 =
            par1EntityLiving.field_9362_u
                + (par1EntityLiving.field_9361_v - par1EntityLiving.field_9362_u) * par9;
        float bob = -Math.abs(MathHelper.cos(f6 * 0.6662F)) * 5F * f32 * bobStrength - 23F;
        GL11.glTranslatef(0.0F, bob * f4 - 0.0078125F, 0.0F);
      } else {
        f6 = par1EntityLiving.field_703_S - par1EntityLiving.field_704_R * (1.0F - par9);
        if (par1EntityLiving.isChild()) {
          f6 *= 3F;
        }
      }

      if (f5 > 1.0F) {
        f5 = 1.0F;
      }

      GL11.glEnable(GL11.GL_ALPHA_TEST);
      mainModel.setLivingAnimations(par1EntityLiving, f6, f5, par9);
      renderModel(par1EntityLiving, f6, f5, f3, f1 - f, f2, f4);

      for (int i = 0; i < 4; i++) {
        int j = shouldRenderPass(par1EntityLiving, i, par9);

        if (j <= 0) {
          continue;
        }

        renderPassModel.setLivingAnimations(par1EntityLiving, f6, f5, par9);
        renderPassModel.render(par1EntityLiving, f6, f5, f3, f1 - f, f2, f4);

        if (j == 15) {
          float f8 = (float) par1EntityLiving.ticksExisted + par9;
          loadTexture("%blur%/misc/glint.png");
          GL11.glEnable(GL11.GL_BLEND);
          float f10 = 0.5F;
          GL11.glColor4f(f10, f10, f10, 1.0F);
          GL11.glDepthFunc(GL11.GL_EQUAL);
          GL11.glDepthMask(false);

          for (int i1 = 0; i1 < 2; i1++) {
            GL11.glDisable(GL11.GL_LIGHTING);
            float f13 = 0.76F;
            GL11.glColor4f(0.5F * f13, 0.25F * f13, 0.8F * f13, 1.0F);
            GL11.glBlendFunc(GL11.GL_SRC_COLOR, GL11.GL_ONE);
            GL11.glMatrixMode(GL11.GL_TEXTURE);
            GL11.glLoadIdentity();
            float f15 = f8 * (0.001F + (float) i1 * 0.003F) * 20F;
            float f16 = 0.3333333F;
            GL11.glScalef(f16, f16, f16);
            GL11.glRotatef(30F - (float) i1 * 60F, 0.0F, 0.0F, 1.0F);
            GL11.glTranslatef(0.0F, f15, 0.0F);
            GL11.glMatrixMode(GL11.GL_MODELVIEW);
            renderPassModel.render(par1EntityLiving, f6, f5, f3, f1 - f, f2, f4);
          }

          GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
          GL11.glMatrixMode(GL11.GL_TEXTURE);
          GL11.glDepthMask(true);
          GL11.glLoadIdentity();
          GL11.glMatrixMode(GL11.GL_MODELVIEW);
          GL11.glEnable(GL11.GL_LIGHTING);
          GL11.glDisable(GL11.GL_BLEND);
          GL11.glDepthFunc(GL11.GL_LEQUAL);
        }

        GL11.glDisable(GL11.GL_BLEND);
        GL11.glEnable(GL11.GL_ALPHA_TEST);
      }

      renderEquippedItems(par1EntityLiving, par9);
      float f7 = par1EntityLiving.getBrightness(par9);
      int k = getColorMultiplier(par1EntityLiving, f7, par9);
      OpenGlHelper.setActiveTexture(OpenGlHelper.lightmapTexUnit);
      GL11.glDisable(GL11.GL_TEXTURE_2D);
      OpenGlHelper.setActiveTexture(OpenGlHelper.defaultTexUnit);

      if ((k >> 24 & 0xff) > 0 || par1EntityLiving.hurtTime > 0 || par1EntityLiving.deathTime > 0) {
        GL11.glDisable(GL11.GL_TEXTURE_2D);
        GL11.glDisable(GL11.GL_ALPHA_TEST);
        GL11.glEnable(GL11.GL_BLEND);
        GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
        GL11.glDepthFunc(GL11.GL_EQUAL);

        if (par1EntityLiving.hurtTime > 0 || par1EntityLiving.deathTime > 0) {
          GL11.glColor4f(f7, 0.0F, 0.0F, 0.4F);
          mainModel.render(par1EntityLiving, f6, f5, f3, f1 - f, f2, f4);

          for (int l = 0; l < 4; l++) {
            if (inheritRenderPass(par1EntityLiving, l, par9) >= 0) {
              GL11.glColor4f(f7, 0.0F, 0.0F, 0.4F);
              renderPassModel.render(par1EntityLiving, f6, f5, f3, f1 - f, f2, f4);
            }
          }
        }

        if ((k >> 24 & 0xff) > 0) {
          float f9 = (float) (k >> 16 & 0xff) / 255F;
          float f11 = (float) (k >> 8 & 0xff) / 255F;
          float f12 = (float) (k & 0xff) / 255F;
          float f14 = (float) (k >> 24 & 0xff) / 255F;
          GL11.glColor4f(f9, f11, f12, f14);
          mainModel.render(par1EntityLiving, f6, f5, f3, f1 - f, f2, f4);

          for (int j1 = 0; j1 < 4; j1++) {
            if (inheritRenderPass(par1EntityLiving, j1, par9) >= 0) {
              GL11.glColor4f(f9, f11, f12, f14);
              renderPassModel.render(par1EntityLiving, f6, f5, f3, f1 - f, f2, f4);
            }
          }
        }

        GL11.glDepthFunc(GL11.GL_LEQUAL);
        GL11.glDisable(GL11.GL_BLEND);
        GL11.glEnable(GL11.GL_ALPHA_TEST);
        GL11.glEnable(GL11.GL_TEXTURE_2D);
      }

      GL11.glDisable(GL12.GL_RESCALE_NORMAL);
    } catch (Exception exception) {
      exception.printStackTrace();
    }

    OpenGlHelper.setActiveTexture(OpenGlHelper.lightmapTexUnit);
    GL11.glEnable(GL11.GL_TEXTURE_2D);
    OpenGlHelper.setActiveTexture(OpenGlHelper.defaultTexUnit);
    GL11.glEnable(GL11.GL_CULL_FACE);
    GL11.glPopMatrix();
    passSpecialRender(par1EntityLiving, par2, par4, par6);
  }
예제 #30
0
  public void applyRenderState(RenderState state) {
    if (state.isWireframe() && !context.wireframe) {
      glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
      context.wireframe = true;
    } else if (!state.isWireframe() && context.wireframe) {
      glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
      context.wireframe = false;
    }

    if (state.isDepthTest() && !context.depthTestEnabled) {
      glEnable(GL_DEPTH_TEST);
      glDepthFunc(GL_LEQUAL);
      context.depthTestEnabled = true;
    } else if (!state.isDepthTest() && context.depthTestEnabled) {
      glDisable(GL_DEPTH_TEST);
      context.depthTestEnabled = false;
    }

    if (state.isAlphaTest()) {
      setFixedFuncBinding(FixedFuncBinding.AlphaTestFallOff, state.getAlphaFallOff());
    } else {
      setFixedFuncBinding(FixedFuncBinding.AlphaTestFallOff, 0f); // disable it
    }

    if (state.isDepthWrite() && !context.depthWriteEnabled) {
      glDepthMask(true);
      context.depthWriteEnabled = true;
    } else if (!state.isDepthWrite() && context.depthWriteEnabled) {
      glDepthMask(false);
      context.depthWriteEnabled = false;
    }

    if (state.isColorWrite() && !context.colorWriteEnabled) {
      glColorMask(true, true, true, true);
      context.colorWriteEnabled = true;
    } else if (!state.isColorWrite() && context.colorWriteEnabled) {
      glColorMask(false, false, false, false);
      context.colorWriteEnabled = false;
    }

    if (state.isPointSprite()) {
      logger.log(Level.WARNING, "Point Sprite unsupported!");
    }

    if (state.isPolyOffset()) {
      if (!context.polyOffsetEnabled) {
        glEnable(GL_POLYGON_OFFSET_FILL);
        glPolygonOffset(state.getPolyOffsetFactor(), state.getPolyOffsetUnits());
        context.polyOffsetEnabled = true;
        context.polyOffsetFactor = state.getPolyOffsetFactor();
        context.polyOffsetUnits = state.getPolyOffsetUnits();
      } else {
        if (state.getPolyOffsetFactor() != context.polyOffsetFactor
            || state.getPolyOffsetUnits() != context.polyOffsetUnits) {
          glPolygonOffset(state.getPolyOffsetFactor(), state.getPolyOffsetUnits());
          context.polyOffsetFactor = state.getPolyOffsetFactor();
          context.polyOffsetUnits = state.getPolyOffsetUnits();
        }
      }
    } else {
      if (context.polyOffsetEnabled) {
        glDisable(GL_POLYGON_OFFSET_FILL);
        context.polyOffsetEnabled = false;
        context.polyOffsetFactor = 0;
        context.polyOffsetUnits = 0;
      }
    }
    if (state.getFaceCullMode() != context.cullMode) {
      if (state.getFaceCullMode() == RenderState.FaceCullMode.Off) {
        glDisable(GL_CULL_FACE);
      } else {
        glEnable(GL_CULL_FACE);
      }

      switch (state.getFaceCullMode()) {
        case Off:
          break;
        case Back:
          glCullFace(GL_BACK);
          break;
        case Front:
          glCullFace(GL_FRONT);
          break;
        case FrontAndBack:
          glCullFace(GL_FRONT_AND_BACK);
          break;
        default:
          throw new UnsupportedOperationException(
              "Unrecognized face cull mode: " + state.getFaceCullMode());
      }

      context.cullMode = state.getFaceCullMode();
    }

    if (state.getBlendMode() != context.blendMode) {
      if (state.getBlendMode() == RenderState.BlendMode.Off) {
        glDisable(GL_BLEND);
      } else {
        glEnable(GL_BLEND);
        switch (state.getBlendMode()) {
          case Off:
            break;
          case Additive:
            glBlendFunc(GL_ONE, GL_ONE);
            break;
          case AlphaAdditive:
            glBlendFunc(GL_SRC_ALPHA, GL_ONE);
            break;
          case Color:
            glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_COLOR);
            break;
          case Alpha:
            glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
            break;
          case PremultAlpha:
            glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
            break;
          case Modulate:
            glBlendFunc(GL_DST_COLOR, GL_ZERO);
            break;
          case ModulateX2:
            glBlendFunc(GL_DST_COLOR, GL_SRC_COLOR);
            break;
          default:
            throw new UnsupportedOperationException(
                "Unrecognized blend mode: " + state.getBlendMode());
        }
      }

      context.blendMode = state.getBlendMode();
    }

    if (state.isStencilTest()) {
      throw new UnsupportedOperationException(
          "OpenGL 1.1 doesn't support two sided stencil operations.");
    }
  }