protected int func_27006_a(GCMarsEntityCreeperBoss par1EntityCreeper, int par2, float par3) {
    if (par1EntityCreeper.headsRemaining == 1) {
      if (par2 == 1) {
        final float var4 = par1EntityCreeper.ticksExisted + par3;
        this.bindTexture(GCMarsRenderCreeperBoss.powerTexture);
        GL11.glMatrixMode(GL11.GL_TEXTURE);
        GL11.glLoadIdentity();
        final float var5 = var4 * 0.01F;
        final float var6 = var4 * 0.01F;
        GL11.glTranslatef(var5, var6, 0.0F);
        this.setRenderPassModel(this.creeperModel);
        GL11.glMatrixMode(GL11.GL_MODELVIEW);
        GL11.glEnable(GL11.GL_BLEND);
        final float var7 = 0.5F;
        GL11.glColor4f(var7, var7, var7, 1.0F);
        GL11.glDisable(GL11.GL_LIGHTING);
        GL11.glBlendFunc(GL11.GL_ONE, GL11.GL_ONE);
        return 1;
      }

      if (par2 == 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;
  }
Esempio n. 2
0
  @Override
  public void draw(boolean flip) {
    try {
      if (ladder != null) GL11.glDeleteTextures(ladder.getTextureID());
      ladder =
          TextureLoader.getTexture("PNG", ResourceLoader.getResourceAsStream("res/amobox.png"));
    } catch (IOException e) {
      e.printStackTrace();
    }
    ladder.bind();
    GL11.glLoadIdentity();
    GL11.glTranslated(x, y, 0);

    GL11.glBegin(GL11.GL_QUADS);
    GL11.glTexCoord2f(0, 0);
    GL11.glVertex2f(100, 100);
    GL11.glTexCoord2f(1, 0);
    GL11.glVertex2f(100 + ladder.getTextureWidth(), 100);
    GL11.glTexCoord2f(1, 1);
    GL11.glVertex2f(100 + ladder.getTextureWidth(), 100 + ladder.getTextureHeight());
    GL11.glTexCoord2f(0, 1);
    GL11.glVertex2f(100, 100 + ladder.getTextureHeight());
    GL11.glEnd();
    GL11.glLoadIdentity();
  }
Esempio n. 3
0
 protected void setupGLState() {
   GL11.glPushAttrib(
       GL11.GL_ENABLE_BIT
           | GL11.GL_TRANSFORM_BIT
           | GL11.GL_HINT_BIT
           | GL11.GL_COLOR_BUFFER_BIT
           | GL11.GL_SCISSOR_BIT
           | GL11.GL_LINE_BIT
           | GL11.GL_TEXTURE_BIT);
   GL11.glMatrixMode(GL11.GL_PROJECTION);
   GL11.glPushMatrix();
   GL11.glLoadIdentity();
   GL11.glOrtho(0, width, height, 0, -1.0, 1.0);
   GL11.glMatrixMode(GL11.GL_MODELVIEW);
   GL11.glPushMatrix();
   GL11.glLoadIdentity();
   GL11.glEnable(GL11.GL_TEXTURE_2D);
   GL11.glEnable(GL11.GL_BLEND);
   GL11.glEnable(GL11.GL_LINE_SMOOTH);
   GL11.glDisable(GL11.GL_DEPTH_TEST);
   GL11.glDisable(GL11.GL_LIGHTING);
   GL11.glDisable(GL11.GL_SCISSOR_TEST);
   GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
   GL11.glHint(GL11.GL_LINE_SMOOTH_HINT, GL11.GL_NICEST);
 }
Esempio n. 4
0
 /** Update the display of the achievement window to match the game window. */
 private void updateAchievementWindowScale() {
   GL11.glViewport(0, 0, this.theGame.displayWidth, this.theGame.displayHeight);
   GL11.glMatrixMode(GL11.GL_PROJECTION);
   GL11.glLoadIdentity();
   GL11.glMatrixMode(GL11.GL_MODELVIEW);
   GL11.glLoadIdentity();
   this.achievementWindowWidth = this.theGame.displayWidth;
   this.achievementWindowHeight = this.theGame.displayHeight;
   ScaledResolution var1 =
       new ScaledResolution(
           this.theGame.gameSettings, this.theGame.displayWidth, this.theGame.displayHeight);
   this.achievementWindowWidth = var1.getScaledWidth();
   this.achievementWindowHeight = var1.getScaledHeight();
   GL11.glClear(256);
   GL11.glMatrixMode(GL11.GL_PROJECTION);
   GL11.glLoadIdentity();
   GL11.glOrtho(
       0.0D,
       (double) this.achievementWindowWidth,
       (double) this.achievementWindowHeight,
       0.0D,
       1000.0D,
       3000.0D);
   GL11.glMatrixMode(GL11.GL_MODELVIEW);
   GL11.glLoadIdentity();
   GL11.glTranslatef(0.0F, 0.0F, -2000.0F);
 }
Esempio n. 5
0
 public static void resizedRefresh() {
   GL11.glMatrixMode(GL11.GL_PROJECTION);
   GL11.glLoadIdentity(); // Resets any previous projection matrices
   GL11.glOrtho(0, Display.getWidth(), 0, Display.getHeight(), 1000, -1000);
   GL11.glMatrixMode(GL11.GL_MODELVIEW);
   GL11.glLoadIdentity();
 }
Esempio n. 6
0
  public Render(Level level) {
    this.level = level;
    try {
      Display.setFullscreen(true);
    } catch (LWJGLException e) {
      e.printStackTrace();
    }

    // Enable vsync if we can
    Display.setVSyncEnabled(true);

    try {
      Display.create();
    } catch (LWJGLException e) {
      e.printStackTrace();
    }

    // Put the window into orthographic projection mode with 1:1 pixel
    // ratio.
    // We haven't used GLU here to do this to avoid an unnecessary
    // dependency.

    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    glOrtho(
        0.0,
        Display.getDisplayMode().getWidth(),
        0.0,
        Display.getDisplayMode().getHeight(),
        -1.0,
        1.0);
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
    glViewport(0, 0, Display.getDisplayMode().getWidth(), Display.getDisplayMode().getHeight());
  }
  /**
   * *************************************************************************************************************************************************************************************************
   * 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();
  }
Esempio n. 8
0
  /**
   * Initialise the game
   *
   * @throws Exception if init fails
   */
  private static void init() throws Exception {
    // Create a fullscreen window with 1:1 orthographic 2D projection, and with
    // mouse, keyboard, and gamepad inputs.
    Display.setTitle(GAME_TITLE);
    Display.setFullscreen(true);

    // Enable vsync if we can
    Display.setVSyncEnabled(true);

    Display.create();

    // Start up the sound system
    AL.create();

    // TODO: Load in your textures etc here

    // Put the window into orthographic projection mode with 1:1 pixel ratio.
    // We haven't used GLU here to do this to avoid an unnecessary dependency.
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    glOrtho(
        0.0,
        Display.getDisplayMode().getWidth(),
        0.0,
        Display.getDisplayMode().getHeight(),
        -1.0,
        1.0);
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
    glViewport(0, 0, Display.getDisplayMode().getWidth(), Display.getDisplayMode().getHeight());
  }
Esempio n. 9
0
  /**
   * Render the GL scene, this isn't efficient and if you know OpenGL I'm assuming you can see why.
   * If not, you probably don't want to use this feature anyway
   */
  public void renderGL() {
    FloatBuffer pos = BufferUtils.createFloatBuffer(4);
    pos.put(new float[] {5.0f, 5.0f, 10.0f, 0.0f}).flip();
    FloatBuffer red = BufferUtils.createFloatBuffer(4);
    red.put(new float[] {0.8f, 0.1f, 0.0f, 1.0f}).flip();

    GL11.glLight(GL11.GL_LIGHT0, GL11.GL_POSITION, pos);
    GL11.glEnable(GL11.GL_LIGHT0);

    GL11.glEnable(GL11.GL_CULL_FACE);
    GL11.glEnable(GL11.GL_DEPTH_TEST);
    GL11.glEnable(GL11.GL_LIGHTING);

    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glLoadIdentity();
    float h = (float) 600 / (float) 800;
    GL11.glFrustum(-1.0f, 1.0f, -h, h, 5.0f, 60.0f);
    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glLoadIdentity();
    GL11.glTranslatef(0.0f, 0.0f, -40.0f);
    GL11.glRotatef(rot, 0, 1, 1);

    GL11.glMaterial(GL11.GL_FRONT, GL11.GL_AMBIENT_AND_DIFFUSE, red);
    gear(0.5f, 2.0f, 2.0f, 10, 0.7f);
  }
  @Override
  public void main(int delta) {

    GameData.render();

    GL11.glLoadIdentity();
    GL11.glOrtho(0, GameSettings.getScreenX(), 0, GameSettings.getScreenY(), -1, 1);

    GL11.glColor4d(0, 0, 0, .7);
    GL11.glBegin(GL11.GL_TRIANGLE_FAN);
    GL11.glVertex2d(0, 0);
    GL11.glVertex2d(GameSettings.getScreenX(), 0);
    GL11.glVertex2d(GameSettings.getScreenX(), GameSettings.getScreenY());
    GL11.glVertex2d(0, GameSettings.getScreenY());
    GL11.glEnd();

    float ratio = ((float) (GameSettings.getScreenY()) / GameSettings.getScreenX());
    GL11.glLoadIdentity();
    GL11.glOrtho(
        -GameData.zoom,
        GameSettings.getScreenX() + GameData.zoom,
        -GameData.zoom * (ratio),
        GameSettings.getScreenY() + GameData.zoom * (ratio),
        -1,
        1);

    for (Button b : buttons) {
      b.render();
    }
  }
Esempio n. 11
0
  private void init(boolean absolutePixels, boolean testModes) {
    // find out what the current bits per pixel of the desktop is
    int currentBpp = Display.getDisplayMode().getBitsPerPixel();

    try {
      DisplayMode mode;
      if (testModes) mode = findDisplayMode(WINDOW_WIDTH, WINDOW_HEIGHT, currentBpp);
      else mode = new DisplayMode(WINDOW_WIDTH, WINDOW_HEIGHT);

      Display.setDisplayMode(mode);
      Display.setFullscreen(false);
      Display.setTitle("src");
      Display.create();
    } catch (LWJGLException e) {
      e.printStackTrace();
    }

    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    double aspectRatio = (double) WINDOW_WIDTH / WINDOW_HEIGHT;

    if (absolutePixels) {
      glOrtho(0.0d, WINDOW_WIDTH, 0.0d, WINDOW_HEIGHT, 1.0d, -1.0d);
    } else {
      glOrtho(aspectRatio, -aspectRatio, -1.0d, 1.0d, 1.0d, -1.0d);
    }

    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
  }
Esempio n. 12
0
 public static void orthoMode(Size size) {
   GL11.glDisable(GL11.GL_DEPTH_TEST);
   GL11.glMatrixMode(GL11.GL_PROJECTION);
   GL11.glPushMatrix();
   GL11.glLoadIdentity();
   GL11.glOrtho(0, size.getWidth(), 0, size.getHeight(), -10, 10);
   GL11.glMatrixMode(GL11.GL_MODELVIEW);
   GL11.glPushMatrix();
   GL11.glLoadIdentity();
 }
Esempio n. 13
0
  public void render() {
    glPushMatrix();
    glLoadIdentity();
    glOrtho(0, Juego.obtenerAnchura(), Juego.obtenerAltura(), 0, 1, -1);
    uFont.drawString(x, y, texto);

    glLoadIdentity();
    glOrtho(0, Juego.obtenerAnchura(), 0, Juego.obtenerAltura(), 1, -1);
    glPopMatrix();
  }
Esempio n. 14
0
  public void start() {
    try {
      Display.setDisplayMode(new DisplayMode(WIDTH, HEIGHT));
      Display.create();
      Display.setFullscreen(true);
    } catch (LWJGLException e) {
      e.printStackTrace();
      System.exit(0);
    }

    GL11.glEnable(GL11.GL_TEXTURE_2D);
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glEnable(GL11.GL_ALPHA);
    GL11.glEnable(GL11.GL_ALPHA_TEST);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);

    GL11.glClearAccum(0f, 0f, 0f, 1f);
    GL11.glClear(GL11.GL_ACCUM_BUFFER_BIT);

    while (!Display.isCloseRequested() && !finished) {
      if (System.currentTimeMillis() - time > 1000) {
        System.out.println(framecount + " FPS");
        time = System.currentTimeMillis();
        framecount = 0;
      }

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

      GL11.glColor3f(1, 1, 1);

      GL11.glMatrixMode(GL11.GL_MODELVIEW);
      GL11.glLoadIdentity();
      GL11.glOrtho(0, WIDTH, HEIGHT, 0, -10, 10);
      Manager.DrawBackground();

      GL11.glMatrixMode(GL11.GL_MODELVIEW);
      GL11.glLoadIdentity();
      GL11.glOrtho(0, WIDTH, HEIGHT, 0, -10, 10);

      GL11.glTranslatef(-Camera.x, -Camera.y, 0);
      Display.sync(60);

      Manager.Draw();
      Manager.Update();

      GL11.glMatrixMode(GL11.GL_MODELVIEW);
      GL11.glLoadIdentity();
      GL11.glOrtho(0, WIDTH, HEIGHT, 0, -10, 10);
      Manager.DrawForeground();

      Display.update();

      framecount++;
    }
  }
Esempio n. 15
0
  /** R_SetupGL */
  void R_SetupGL() {

    //
    // set up viewport
    //
    // int x = (int) Math.floor(r_newrefdef.x * vid.width / vid.width);
    int x = r_newrefdef.x;
    // int x2 = (int) Math.ceil((r_newrefdef.x + r_newrefdef.width) * vid.width / vid.width);
    int x2 = r_newrefdef.x + r_newrefdef.width;
    // int y = (int) Math.floor(vid.height - r_newrefdef.y * vid.height / vid.height);
    int y = vid.height - r_newrefdef.y;
    // int y2 = (int) Math.ceil(vid.height - (r_newrefdef.y + r_newrefdef.height) * vid.height /
    // vid.height);
    int y2 = vid.height - (r_newrefdef.y + r_newrefdef.height);

    int w = x2 - x;
    int h = y - y2;

    GL11.glViewport(x, y2, w, h);

    //
    // set up projection matrix
    //
    float screenaspect = (float) r_newrefdef.width / r_newrefdef.height;
    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glLoadIdentity();
    MYgluPerspective(r_newrefdef.fov_y, screenaspect, 4, 4096);

    GL11.glCullFace(GL11.GL_FRONT);

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

    GL11.glRotatef(-90, 1, 0, 0); // put Z going up
    GL11.glRotatef(90, 0, 0, 1); // put Z going up
    GL11.glRotatef(-r_newrefdef.viewangles[2], 1, 0, 0);
    GL11.glRotatef(-r_newrefdef.viewangles[0], 0, 1, 0);
    GL11.glRotatef(-r_newrefdef.viewangles[1], 0, 0, 1);
    GL11.glTranslatef(-r_newrefdef.vieworg[0], -r_newrefdef.vieworg[1], -r_newrefdef.vieworg[2]);

    GL11.glGetFloat(GL11.GL_MODELVIEW_MATRIX, r_world_matrix);
    r_world_matrix.clear();

    //
    // set drawing parms
    //
    if (gl_cull.value != 0.0f) GL11.glEnable(GL11.GL_CULL_FACE);
    else GL11.glDisable(GL11.GL_CULL_FACE);

    GL11.glDisable(GL11.GL_BLEND);
    GL11.glDisable(GL11.GL_ALPHA_TEST);
    GL11.glEnable(GL11.GL_DEPTH_TEST);
  }
  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();
  }
Esempio n. 17
0
 /** R_SetGL2D */
 void R_SetGL2D() {
   // set 2D virtual screen size
   GL11.glViewport(0, 0, vid.width, vid.height);
   GL11.glMatrixMode(GL11.GL_PROJECTION);
   GL11.glLoadIdentity();
   GL11.glOrtho(0, vid.width, vid.height, 0, -99999, 99999);
   GL11.glMatrixMode(GL11.GL_MODELVIEW);
   GL11.glLoadIdentity();
   GL11.glDisable(GL11.GL_DEPTH_TEST);
   GL11.glDisable(GL11.GL_CULL_FACE);
   GL11.glDisable(GL11.GL_BLEND);
   GL11.glEnable(GL11.GL_ALPHA_TEST);
   GL11.glColor4f(1, 1, 1, 1);
 }
Esempio n. 18
0
  /** R_PolyBlend */
  void R_PolyBlend() {
    if (gl_polyblend.value == 0.0f) return;

    if (v_blend[3] == 0.0f) return;

    GL11.glDisable(GL11.GL_ALPHA_TEST);
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glDisable(GL11.GL_DEPTH_TEST);
    GL11.glDisable(GL11.GL_TEXTURE_2D);

    GL11.glLoadIdentity();

    // FIXME: get rid of these
    GL11.glRotatef(-90, 1, 0, 0); // put Z going up
    GL11.glRotatef(90, 0, 0, 1); // put Z going up

    GL11.glColor4f(v_blend[0], v_blend[1], v_blend[2], v_blend[3]);

    GL11.glBegin(GL11.GL_QUADS);

    GL11.glVertex3f(10, 100, 100);
    GL11.glVertex3f(10, -100, 100);
    GL11.glVertex3f(10, -100, -100);
    GL11.glVertex3f(10, 100, -100);
    GL11.glEnd();

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

    GL11.glColor4f(1, 1, 1, 1);
  }
Esempio n. 19
0
  /*
   * If the shader was setup succesfully, we use the shader. Otherwise
   * we run normal drawing code.
   */
  public void draw() {
    if (useShader) {
      ARBShaderObjects.glUseProgramObjectARB(shader);
    }
    GL11.glLoadIdentity();
    GL11.glTranslatef(0.0f, 0.0f, -10.0f);
    GL11.glColor3f(1.0f, 1.0f, 1.0f); // red

    GL11.glBegin(GL11.GL_QUADS);
    GL11.glVertex3f(-1.0f, 1.0f, 0.0f);
    GL11.glVertex3f(1.0f, 1.0f, 0.0f);
    GL11.glVertex3f(1.0f, -1.0f, 0.0f);
    GL11.glVertex3f(-1.0f, -1.0f, 0.0f);
    GL11.glEnd();

    // GL11.glColor3f(0.0f, 1.0f, 0.0f);//green

    // if(useShader) {
    // ARBShaderObjects.glUseProgramObjectARB(fragShader);
    // }

    /*GL11.glBegin(GL11.GL_QUADS);
    GL11.glVertex3f(-1.0f, 1.0f, 0.0f);
    GL11.glVertex3f(1.0f, 1.0f, 0.0f);
    GL11.glVertex3f(1.0f, -1.0f, 0.0f);
    GL11.glVertex3f(-1.0f, -1.0f, 0.0f);
    GL11.glEnd();*/

    // release the shader
    ARBShaderObjects.glUseProgramObjectARB(0);
  }
Esempio n. 20
0
  public static void startup() {
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    // Create a new perspective with 30 degree angle (field of view), 640 / 480 aspect ratio, 0.001f
    // zNear, 100 zFar
    // Note:         +x is to the right
    //                     +y is to the top
    //                        +z is to the camera
    gluPerspective((float) 30, 640f / 480f, 0.001f, 100);
    glMatrixMode(GL_MODELVIEW);

    // To make sure the points closest to the camera are shown in front of the points that are
    // farther away.
    glEnable(GL_DEPTH_TEST);

    points = new Point[10000];
    // Iterate of every array index
    for (int i = 0; i < points.length; i++) {
      // Set the point at the array index to
      // x = random between -50 and +50
      // y = random between -50 and +50
      // z = random between  0  and -200
      points[i] =
          new Point(
              (random.nextFloat() - 0.5f) * 100f,
              (random.nextFloat() - 0.5f) * 100f,
              random.nextInt(200) - 200);
    }
    // The speed in which the "camera" travels
    speed = 0.0f;
  }
Esempio n. 21
0
  public void renderTransformed() {
    CoreRegistry.get(ShaderManager.class).enableDefault();

    if (isVisible()) {

      for (Animation animation : animations) {
        if (animation.isStarted()) {
          animation.renderBegin();
        }
      }

      if (positionType == EPositionType.RELATIVE) {
        glPushMatrix();
        glTranslatef(getPosition().x, getPosition().y, 0);
        render();
        glPopMatrix();
      } else if (positionType == EPositionType.ABSOLUTE) {
        glPushMatrix();
        glLoadIdentity();
        glTranslatef(getPosition().x, getPosition().y, 0);
        render();
        glPopMatrix();
      }

      for (Animation animation : animations) {
        if (animation.isStarted()) {
          animation.renderEnd();
        }
      }
    }
  }
Esempio n. 22
0
  public void start() {
    System.out.println("SplitMan starting...");
    try {
      Display.setDisplayMode(new DisplayMode(WIDTH, HEIGHT));
      Display.setResizable(false);
      Display.setVSyncEnabled(true);
      Display.setTitle("SplitMan");
      Display.create();
    } catch (Exception e) {
      e.printStackTrace();
      Display.destroy();
      System.exit(1);
    }
    WIDTH = Display.getWidth();
    HEIGHT = Display.getHeight();
    System.out.println("Display: " + WIDTH + " x " + HEIGHT);

    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glLoadIdentity();
    GL11.glOrtho(0, WIDTH, HEIGHT, 0, 1, -1);
    GL11.glMatrixMode(GL11.GL_MODELVIEW);

    Resources.load();

    setScreen(new GuiGame());
    System.out.println("SplitMan started");
  }
Esempio n. 23
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);
  }
Esempio n. 24
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);
  }
Esempio n. 25
0
 public static void render() {
   GL11.glClearColor(0f, 255f / 191f, 1f, 0f);
   GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);
   GL11.glColor3f(0.5f, 0.5f, 1.0f);
   GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST);
   GL11.glLoadIdentity();
   lookThrough();
   /*doPicking();
   namemap = new HashMap<Integer, Location>();
   Render.renderArray(world.getSpawn());
   GL11.glLoadIdentity();
   game.render();
   stopPicking();*/
   // Picking junk
   /*GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);
   GL11.glColor3f(0.5f,0.5f,1.0f);
   GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST);
   GL11.glLoadIdentity();
   lookThrough();*/
   Render.renderArray(world.getSpawn());
   Render.renderEntities(world.entities);
   /*GL11.glLoadIdentity();
   game.render();*/
   Display.update();
 }
Esempio n. 26
0
  public void render() {
    lock.lock();

    quads = 0;
    draw_calls = 0;
    batch_draw_calls = 0;

    GL11.glLoadIdentity();
    GLU.gluLookAt(
        camera.pos.x,
        camera.pos.y,
        camera.pos.z,
        camera.pos.x + camera.look.x,
        camera.pos.y + camera.look.y,
        camera.pos.z + camera.look.z,
        camera.up.x,
        camera.up.y,
        camera.up.z);

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

    for (ChunkNode.Batch batch : batches) render_batch(batch);

    GL11.glFlush();

    lock.unlock();
  }
Esempio n. 27
0
  /** Renders a quad filling the whole currently set viewport. */
  public void renderFullscreenQuad() {
    glMatrixMode(GL_MODELVIEW);
    glPushMatrix();
    glLoadIdentity();

    glMatrixMode(GL_PROJECTION);
    glPushMatrix();
    glLoadIdentity();

    renderQuad();

    glPopMatrix();

    glMatrixMode(GL_MODELVIEW);
    glPopMatrix();
  }
Esempio n. 28
0
 private void initGL() {
   try {
     Display.setDisplayMode(new DisplayMode(GS.FRAMEWIDTH, GS.FRAMEHEIGHT));
     Display.setFullscreen(true);
     Display.create();
     Display.setVSyncEnabled(true);
   } catch (LWJGLException e) {
     e.printStackTrace();
     Display.destroy();
     System.exit(1);
   }
   GL11.glEnable(GL11.GL_TEXTURE_2D);
   // GL11.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
   GL11.glClearDepth(1.0f);
   // GL11.glEnable(GL11.GL_DEPTH_TEST);
   // GL11.glDepthFunc(GL11.GL_ADD); //Wenn nicht auskommentiert führt es zu Exception
   GL11.glMatrixMode(GL11.GL_PROJECTION);
   GL11.glViewport(0, 0, GS.FRAMEWIDTH, GS.FRAMEHEIGHT);
   GL11.glOrtho(0, GS.FRAMEWIDTH, GS.FRAMEHEIGHT, 0, 0, 128);
   GL11.glEnable(GL11.GL_BLEND);
   GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
   // GL11.glBlendEquation( BLENDING_EQUATIONS[blendingEquationIndex]);
   GL11.glShadeModel(GL11.GL_FLAT);
   GL11.glMatrixMode(GL11.GL_MODELVIEW);
   GL11.glEnable(GL11.GL_ALPHA_TEST);
   GL11.glAlphaFunc(GL11.GL_GREATER, 0);
   GL11.glCullFace(GL11.GL_BACK);
   glEnable(GL_CULL_FACE);
   glCullFace(GL_BACK);
   GL11.glLoadIdentity();
 }
 /**
  * Replaces the projection matrix by the one generated by the camera. The matrix mode will be
  * returned it its previous value. to GL_MODELVIEW.
  */
 public void applyPerspectiveMatrix() {
   int previousMatrixMode = glGetInteger(GL_MATRIX_MODE);
   glMatrixMode(GL_PROJECTION);
   glLoadIdentity();
   GLU.gluPerspective(fov, aspectRatio, zNear, zFar);
   glMatrixMode(previousMatrixMode);
 }
Esempio n. 30
0
  private void draw() {

    // Clear the screen and depth buffer
    GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);
    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glLoadIdentity();

    // set up GameContext.getCamera()
    GL11.glPushMatrix();

    GL11.glScalef(scale, scale, scale);
    GL11.glTranslatef(
        -GameContext.getCamera().getPosition().getx(),
        -GameContext.getCamera().getPosition().gety(),
        0);
    GL11.glTranslatef(4f, 3f, 0);

    map.draw();

    if (editorMode) {
      Quad q = new Quad(editorTag.getPosition(), map.getLookupTile(currentEditorTile).getTexture());
      GameContext.getPipe().addDrawable(q);
    }

    for (Entity ae : entities) {
      ae.draw();
    }

    GameContext.getPipe().renderContent();

    GL11.glPopMatrix();

    // overlay console text

    GL11.glPushMatrix();
    GL11.glScalef(2f, 2f, 2f);

    if (console.isEnabled()) {
      gtest.drawing.util.drawString(new Coord(0, 0), "> " + console.getText());
    }

    if (GameContext.isDebugMode()) {
      gtest.drawing.util.drawString(
          new Coord(0, 285), "tiles drawn " + GameContext.getFromLog("tilesLastDrawn"));
      gtest.drawing.util.drawString(
          new Coord(0, 275), "textures bound " + GameContext.getFromLog("textureBinds"));
      gtest.drawing.util.drawString(new Coord(0, 265), "FPS " + GameContext.getFromLog("fps"));
    }

    GL11.glPopMatrix();

    Display.update();

    // clean up

    GameContext.getPipe().clear();
    GameContext.addToLog("tilesLastDrawn", "0");
    GameContext.addToLog("textureBinds", "0");
  }