public void render() {
    text = "" + StaticManager.getScore();
    if (hasFocusEffect() && hasFocus()) {
      getFocusColor().bind();
    } else {
      getNormalColor().bind();
    }
    int xoff = 0;
    System.out.println("SCORE:" + text + "/" + StaticManager.getScore());
    for (int i = 0; i < text.length(); i++) {
      String subs = text.substring(i, i + 1);
      GL11.glBindTexture(GL11.GL_TEXTURE_2D, font[getIndex(subs)].getTextureID());
      GL11.glBegin(GL11.GL_QUADS);
      GL11.glTexCoord2f(0.0f, 0.0f);
      GL11.glVertex2i(getX() + xoff, getY());

      GL11.glTexCoord2f(1.0f, 0.0f);
      GL11.glVertex2i(getX() + xoff + font[getIndex(subs)].getImageWidth(), getY());

      GL11.glTexCoord2f(1.0f, 1.0f);
      GL11.glVertex2i(
          getX() + xoff + font[getIndex(subs)].getImageWidth(),
          getY() + font[getIndex(subs)].getImageHeight());

      GL11.glTexCoord2f(0.0f, 1.0f);
      GL11.glVertex2i(getX() + xoff, getY() + font[getIndex(subs)].getImageHeight());
      GL11.glEnd();
      xoff += font[getIndex(subs)].getImageWidth();
    }
  }
Exemple #2
0
  /**
   * <code>buildDisplayList</code> sets up the 256 display lists that are used to render each font
   * character. Each list quad is 16x16, as defined by the font image size.
   */
  public void buildDisplayList() {
    float cx;
    float cy;

    base = GL11.glGenLists(256);

    for (int loop = 0; loop < 256; loop++) {
      cx = (loop % 16) / 16.0f;
      cy = (loop / 16) / 16.0f;

      GL11.glNewList(base + loop, GL11.GL_COMPILE);
      GL11.glBegin(GL11.GL_QUADS);
      GL11.glTexCoord2f(cx, 1 - cy - 0.0625f);
      GL11.glVertex2i(0, 0);
      GL11.glTexCoord2f(cx + 0.0625f, 1 - cy - 0.0625f);
      GL11.glVertex2i(16, 0);
      GL11.glTexCoord2f(cx + 0.0625f, 1 - cy);
      GL11.glVertex2i(16, 16);
      GL11.glTexCoord2f(cx, 1 - cy);
      GL11.glVertex2i(0, 16);
      GL11.glEnd();
      GL11.glTranslatef(10, 0, 0);
      GL11.glEndList();
    }
  }
Exemple #3
0
  /**
   * Build the character set display list from the given texture. Creates one quad for each
   * character, with one letter textured onto each quad. Assumes the texture is a 256x256 image
   * containing every character of the charset arranged in a 16x16 grid. Each character is 16x16
   * pixels. Call destroyFont() to release the display list memory.
   *
   * <p>Should be in ORTHO (2D) mode to render text (see setOrtho()).
   *
   * <p>Special thanks to NeHe and Giuseppe D'Agata for the "2D Texture Font" tutorial
   * (http://nehe.gamedev.net).
   *
   * @param charSetImage texture image containing 100 characters in a 10x10 grid
   * @param fontWidth how many pixels to allow per character on screen
   * @see destroyFont()
   */
  public void buildFont(int fontTxtrHandle, int textureSize, int fontSize) {
    int unitSize = fontSize; // pixel size of one block in 10x10 grid
    float usize = (float) unitSize / (float) (textureSize); // UV size of
    // one block in
    // grid
    float chU, chV; // character UV position

    // Create 100 Display Lists
    fontListBase = GL11.glGenLists(100);

    // make a quad for each character in texture
    for (int i = 0; i < 100; i++) {
      int x = (i % 10); // column
      int y = (i / 10); // row

      // make character UV coordinate
      // the character V position is tricky because we have to invert the
      // V coord
      // (char # 0 is at top of texture image, but V 0 is at bottom)
      chU = (float) (x * unitSize) / (float) textureSize;
      chV = (float) (y * unitSize) / (float) textureSize;
      // chV = (float) (textureSize - (y * unitSize) - unitSize) / (float)
      // textureSize;

      GL11.glNewList(fontListBase + i, GL11.GL_COMPILE); // start display
      // list
      {
        GL11.glBegin(GL11.GL_QUADS); // Make A unitSize square quad
        {
          GL11.glTexCoord2f(chU, chV); // Texture Coord (Bottom Left)
          GL11.glVertex2i(0, unitSize);

          GL11.glTexCoord2f(chU + usize, chV); // Texture Coord
          // (Bottom Right)
          GL11.glVertex2i(unitSize, unitSize);

          GL11.glTexCoord2f(chU + usize, chV + usize); // Texture
          // Coord
          // (Top
          // Right)
          GL11.glVertex2i(unitSize, 0);

          GL11.glTexCoord2f(chU, chV + usize); // Texture Coord (Top
          // Left)
          GL11.glVertex2i(0, 0);
        }
        GL11.glEnd();
        GL11.glTranslatef(charwidths[i], 0, 0); // shift right the width
        // of the character
      }
      GL11.glEndList(); // done display list
    }
  }
Exemple #4
0
 public static void minimap(float playerX, float playerZ, List<Zombie> zombies) {
   glColor3f(0, 0, 0);
   glBegin(GL_QUADS);
   glVertex2i(64, 64);
   glVertex2i(192, 64);
   glVertex2i(192, 192);
   glVertex2i(64, 192);
   glEnd();
   glBegin(GL_POINTS);
   for (int i = 0; i < zombies.size(); i++) {
     glColor3f(zombies.get(i).getCr(), zombies.get(i).getCg(), zombies.get(i).getCb());
     glVertex2f(zombies.get(i).getPx() + 64, (64 - zombies.get(i).getPz()) + 128);
   }
   glColor3f(1, 1, 1);
   for (int i = -1; i <= 1; i++) {
     for (int j = -1; j <= 1; j++) {
       glVertex2f(playerX + 64 + i, (64 - playerZ) + 128 + j);
     }
   }
   glEnd();
   glColor3f(0, 1, 0);
   glBegin(GL_LINE_LOOP);
   glVertex2i(64, 64);
   glVertex2i(192, 64);
   glVertex2i(192, 192);
   glVertex2i(64, 192);
   glEnd();
 }
 // Draw
 public void Draw() {
   Texture.bind();
   glBegin(GL_QUADS);
   // Top Left
   glTexCoord2f(0, 0);
   glVertex2i(TLCorner.getX(), TLCorner.getY());
   // Top Right
   glTexCoord2f(1, 0);
   glVertex2i(TRCorner.getX(), TRCorner.getY());
   // Bottom Right
   glTexCoord2f(1, 1);
   glVertex2i(BRCorner.getX(), BRCorner.getY());
   // Bottom Left
   glTexCoord2f(0, 1);
   glVertex2i(BLCorner.getX(), BLCorner.getY());
   glEnd();
 }
Exemple #6
0
  /** Render the current frame */
  private static void render() {
    glClear(GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);

    // TODO: all your rendering goes here
    glClear(GL_COLOR_BUFFER_BIT);
    glPushMatrix();
    glTranslatef(
        Display.getDisplayMode().getWidth() / 2, Display.getDisplayMode().getHeight() / 2, 0.0f);
    glRotatef(angle, 0, 0, 1.0f);
    glBegin(GL_QUADS);
    glVertex2i(-50, -50);
    glVertex2i(50, -50);
    glVertex2i(50, 50);
    glVertex2i(-50, 50);
    glEnd();
    glPopMatrix();
  }
Exemple #7
0
  public void render() {

    for (int x = 0; x < this.Screen.length; x++)
      for (int y = 0; y < this.Screen[0].length; y++) {

        int S = Main.scale;
        GL11.glBegin(GL11.GL_QUADS);
        if (Screen[x][y] == 1) {

          GL11.glColor3f(1f, 1f, 1f);
        } else GL11.glColor3f(0f, 0f, 0f);
        GL11.glVertex2i(x * S, y * S);
        GL11.glVertex2i(x * S + S, y * S);
        GL11.glVertex2i(x * S + S, y * S + S);
        GL11.glVertex2i(x * S, y * S + S);
        GL11.glEnd();
      }
  }
Exemple #8
0
  private void setPoints() {
    for (int i = 0; i < 20; i++) {
      for (int j = 0; j < 20; j++) {
        GL11.glColor3d(255, 255, 255);
        GL11.glPushMatrix();
        GL11.glTranslatef((i * 50), (j * 50), 0.5f);

        // rotate square according to angle
        GL11.glRotatef(0, 0, 0, 1.0f);
        GL11.glBegin(GL11.GL_QUADS);
        GL11.glVertex2i(-1, -1);
        GL11.glVertex2i(+1, -1);
        GL11.glVertex2i(+1, +1);
        GL11.glVertex2i(-1, +1);
        GL11.glEnd();

        GL11.glPopMatrix();
      }
    }
  }
  public static void drawLiquidBar(
      int x, int y, int width, int height, int fluidID, int percentage) {
    Fluid fluid = FluidRegistry.getFluid(fluidID);
    if (fluid == null) return;

    Icon icon = fluid.getIcon();

    if (icon == null) return;

    // Bind SpriteNumber=0,texture "/terrain.png"
    TextureManager texturemanager = Minecraft.getMinecraft().getTextureManager();
    texturemanager.bindTexture(texturemanager.getResourceLocation(0));

    double u = icon.getInterpolatedU(3.0D);
    double u2 = icon.getInterpolatedU(13.0D);
    double v = icon.getInterpolatedV(1.0D);
    double v2 = icon.getInterpolatedV(15.0D);

    int z = height * percentage / 100;

    GL11.glEnable(3553);
    GL11.glColor4d(1.0D, 1.0D, 1.0D, 1.0D);

    GL11.glBegin(7);
    GL11.glTexCoord2d(u, v);
    GL11.glVertex2i(x, y + height - z);

    GL11.glTexCoord2d(u, v2);
    GL11.glVertex2i(x, y + height);

    GL11.glTexCoord2d(u2, v2);
    GL11.glVertex2i(x + width, y + height);

    GL11.glTexCoord2d(u2, v);
    GL11.glVertex2i(x + width, y + height - z);
    GL11.glEnd();
  }
  @Override
  /** Draw the button */
  public void draw() {
    GL11.glColor3f(1.0f, 1.0f, 1.0f);
    if (this.isVisible) {
      currentImage.texture().bind();
      GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
      GL11.glBegin(GL11.GL_QUADS);
      {
        /*
         * currentImage.getWidth() and currentImage.getHeight() return the actual height of the texture.
         * My best guess is that the image gets put into the smallest possible texture that has dimensions that are
         * powers of 2 by Slick, because OpenGL can handle those much better.
         */
        GL11.glTexCoord2f(0, 0);
        GL11.glVertex2i(x, y);

        GL11.glTexCoord2f(currentImage.texture().getWidth(), 0);
        GL11.glVertex2i(x + width, y);

        GL11.glTexCoord2f(currentImage.texture().getWidth(), currentImage.texture().getHeight());
        GL11.glVertex2i(x + width, y + height);

        GL11.glTexCoord2f(0, currentImage.texture().getHeight());
        GL11.glVertex2i(x, y + height);
      }
      GL11.glEnd();

      int textWidth = Debug.font.getWidth(text);
      int textHeight = Debug.font.getAscent();

      int textX = this.x + ((this.width - textWidth) / 2);
      int textY = this.y + ((this.height - textHeight) / 2) - 2;

      Debug.font.drawString(textX, textY, text, Color.cyan);
    }
  }
  public void select() {
    text = "" + StaticManager.getScore();
    System.out.println("selecting: " + getId());
    GL11.glDisable(GL11.GL_TEXTURE_2D);
    Color c = new Color(getId(), 255, 255, 255);
    c.bind();
    int xoff = 0;
    for (int i = 0; i < text.length(); i++) {
      String subs = text.substring(i, i + 1);
      GL11.glBegin(GL11.GL_QUADS);
      GL11.glVertex2i(getX() + xoff, getY());

      GL11.glVertex2i(getX() + xoff + font[getIndex(subs)].getImageWidth(), getY());

      GL11.glVertex2i(
          getX() + xoff + font[getIndex(subs)].getImageWidth(),
          getY() + font[getIndex(subs)].getImageHeight());

      GL11.glVertex2i(getX() + xoff, getY() + font[getIndex(subs)].getImageHeight());
      GL11.glEnd();
      xoff += font[getIndex(subs)].getImageWidth();
    }
    GL11.glEnable(GL11.GL_TEXTURE_2D);
  }
Exemple #12
0
 public static void glVertex(Vector2i v) {
   GL11.glVertex2i(v.x, v.y);
 }