Ejemplo n.º 1
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();
  }
Ejemplo n.º 2
0
  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();
    }
  }
Ejemplo n.º 3
0
  @Override
  public void render() {
    super.render();

    if (move == LEFT) kirbyLeft.bind();
    else if (move == TOP) kirbyBack.bind();
    else kirbyRight.bind();
    glBegin(GL_QUADS);
    glTexCoord2f(((float) (i + 1) / 10), 1);
    glVertex3f(x - 1, 0, y);
    glTexCoord2f(((float) (i) / 10), 1);
    glVertex3f(x + 1, 0, y);
    glTexCoord2f(((float) (i) / 10), 0);
    glVertex3f(x + 1, 2, y);
    glTexCoord2f(((float) (i + 1) / 10), 0);
    glVertex3f(x - 1, 2, y);
    glEnd();
    Texture.unbind();

    t++;
    if (t >= 20) {
      if (i < 10) i++;
      else i = 0;
      t = 0;
    }
  }
Ejemplo n.º 4
0
 private float func_78277_a(char p_78277_1_, boolean p_78277_2_) {
   if (this.field_78287_e[p_78277_1_] == 0) {
     return 0.0F;
   } else {
     int var3 = p_78277_1_ / 256;
     this.func_78257_a(var3);
     int var4 = this.field_78287_e[p_78277_1_] >>> 4;
     int var5 = this.field_78287_e[p_78277_1_] & 15;
     float var6 = (float) var4;
     float var7 = (float) (var5 + 1);
     float var8 = (float) (p_78277_1_ % 16 * 16) + var6;
     float var9 = (float) ((p_78277_1_ & 255) / 16 * 16);
     float var10 = var7 - var6 - 0.02F;
     float var11 = p_78277_2_ ? 1.0F : 0.0F;
     GL11.glBegin(5);
     GL11.glTexCoord2f(var8 / 256.0F, var9 / 256.0F);
     GL11.glVertex3f(this.field_78295_j + var11, this.field_78296_k, 0.0F);
     GL11.glTexCoord2f(var8 / 256.0F, (var9 + 15.98F) / 256.0F);
     GL11.glVertex3f(this.field_78295_j - var11, this.field_78296_k + 7.99F, 0.0F);
     GL11.glTexCoord2f((var8 + var10) / 256.0F, var9 / 256.0F);
     GL11.glVertex3f(this.field_78295_j + var10 / 2.0F + var11, this.field_78296_k, 0.0F);
     GL11.glTexCoord2f((var8 + var10) / 256.0F, (var9 + 15.98F) / 256.0F);
     GL11.glVertex3f(this.field_78295_j + var10 / 2.0F - var11, this.field_78296_k + 7.99F, 0.0F);
     GL11.glEnd();
     return (var7 - var6) / 2.0F + 1.0F;
   }
 }
Ejemplo n.º 5
0
  @Override
  public void render() {
    GL11.glPushMatrix();
    GL11.glColor4f(1, 1, 1, 1); // transparent color for overlay

    GL11.glEnable(GL11.GL_TEXTURE_2D);
    GL11.glBindTexture(GL11.GL_TEXTURE_2D, this.img.getID());

    GL11.glScalef(this.scale.x, this.scale.y, 1f);
    GL11.glTranslatef(this.offset.x, this.offset.y, 0f);
    GL11.glBegin(GL11.GL_QUADS);
    GL11.glTexCoord2f(clipping[0], clipping[1]);
    GL11.glVertex2f(0, 0);

    GL11.glTexCoord2f(clipping[2], clipping[1]);
    GL11.glVertex2f(1, 0);

    GL11.glTexCoord2f(clipping[2], clipping[3]);
    GL11.glVertex2f(1, 1);

    GL11.glTexCoord2f(clipping[0], clipping[3]);
    GL11.glVertex2f(0, 1);
    GL11.glEnd();

    GL11.glDisable(GL11.GL_TEXTURE_2D);
    GL11.glPopMatrix();
  }
Ejemplo n.º 6
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();
    }
  }
Ejemplo n.º 7
0
  /**
   * Draw the sprite at the specified location
   *
   * @param x The x location at which to draw this sprite
   * @param y The y location at which to draw this sprite
   */
  public void draw(float x, float y) {
    // store the current model matrix
    glPushMatrix();

    // bind to the appropriate texture for this sprite
    texture.bind();

    // translate to the right location and prepare to draw
    glTranslatef(x, y, 0);
    // draw a quad textured to match the sprite
    glBegin(GL_QUADS);
    {
      glTexCoord2f(0, 0);
      glVertex2f(0, height);

      glTexCoord2f(texture.getWidth(), 0);
      glVertex2f(width, height);

      glTexCoord2f(texture.getWidth(), texture.getHeight());
      glVertex2f(width, 0);

      glTexCoord2f(0, texture.getHeight());
      glVertex2f(0, 0);
    }
    glEnd();

    // restore the model view matrix to prevent contamination
    glPopMatrix();
  }
Ejemplo n.º 8
0
  public void draw(float x, float y, int w, int h) {
    int s = w / width;
    int t = h / height;

    glPushMatrix();
    texture.bind();
    glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
    glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
    glTranslatef(x, y, 0);
    glBegin(GL_QUADS);
    {
      glTexCoord2f(0, 0);
      glVertex2f(0, h);

      glTexCoord2f(s, 0);
      glVertex2f(w, h);

      glTexCoord2f(s, t);
      glVertex2f(w, 0);

      glTexCoord2f(0, t);
      glVertex2f(0, 0);
    }
    glEnd();
    glPopMatrix();
  }
  private void renderBox() {
    float w = GameSettings.Display.window_width;
    float h = GameSettings.Display.window_height;
    float x = w / 2f;
    float y = h / 2f;
    x -= 6;
    y -= 6;
    float z = 0f;
    float bx = (w) / 2f;
    float by = (h) / 2f;
    bx += 2;

    glPushMatrix();

    glBegin(GL_QUADS);
    glTexCoord2f(0f, 0f); // bottom left
    glVertex3f(x - bx, y - by, z);
    glTexCoord2f(1f, 0f); // bottom right
    glVertex3f(x + bx, y - by, z);
    glTexCoord2f(1f, 1f); // top right
    glVertex3f(x + bx, y + by, z);
    glTexCoord2f(0f, 1f); // top left
    glVertex3f(x - bx, y + by, z);
    glEnd();
  }
Ejemplo n.º 10
0
  public static void drawRegion(TextureRegion tex, int x, int y, int w, int h) {
    glEnable(GL_TEXTURE_2D);
    glBindTexture(GL_TEXTURE_2D, tex.id);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);

    glEnable(GL_BLEND);
    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

    glBegin(GL_QUADS);
    {
      glTexCoord2f(tex.u, tex.v);
      glVertex2f(x, y);
      glTexCoord2f(tex.u2, tex.v);
      glVertex2f(x + w, y);
      glTexCoord2f(tex.u2, tex.v2);
      glVertex2f(x + w, y + h);
      glTexCoord2f(tex.u, tex.v2);
      glVertex2f(x, y + h);
    }
    glEnd();

    glBindTexture(GL_TEXTURE_2D, 0);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);

    glDisable(GL_BLEND);
    glDisable(GL_TEXTURE_2D);
  }
Ejemplo n.º 11
0
  private void drawQuad(
      float drawX,
      float drawY,
      float drawX2,
      float drawY2,
      float srcX,
      float srcY,
      float srcX2,
      float srcY2) {
    float DrawWidth = drawX2 - drawX;
    float DrawHeight = drawY2 - drawY;
    float TextureSrcX = srcX / textureWidth;
    float TextureSrcY = srcY / textureHeight;
    float SrcWidth = srcX2 - srcX;
    float SrcHeight = srcY2 - srcY;
    float RenderWidth = (SrcWidth / textureWidth);
    float RenderHeight = (SrcHeight / textureHeight);

    GL11.glTexCoord2f(TextureSrcX, TextureSrcY);
    GL11.glVertex2f(drawX, drawY);
    GL11.glTexCoord2f(TextureSrcX, TextureSrcY + RenderHeight);
    GL11.glVertex2f(drawX, drawY + DrawHeight);
    GL11.glTexCoord2f(TextureSrcX + RenderWidth, TextureSrcY + RenderHeight);
    GL11.glVertex2f(drawX + DrawWidth, drawY + DrawHeight);
    GL11.glTexCoord2f(TextureSrcX + RenderWidth, TextureSrcY);
    GL11.glVertex2f(drawX + DrawWidth, drawY);
  }
Ejemplo n.º 12
0
  public static void floor() {
    glBindTexture(GL_TEXTURE_2D, Main.tex_floor);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
    FloatBuffer color = BufferUtils.createFloatBuffer(4);
    color.put(1).put(0.8f).put(0.6f).put(1).flip();
    glMaterial(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, color);
    color = BufferUtils.createFloatBuffer(4);
    color.put(0).put(0).put(0).put(1).flip();
    glMaterial(GL_FRONT, GL_SPECULAR, color);
    glBegin(GL_QUADS);
    glNormal3f(0, 1, 0);
    for (int a = ZA_FLOOR_START; a < ZA_FLOOR_END; a += ZA_FLOOR_RES) {
      for (int b = ZA_FLOOR_START; b < ZA_FLOOR_END; b += ZA_FLOOR_RES) {
        glTexCoord2f(0, 0);
        glVertex3f(a, 0, b);
        glTexCoord2f(0, 1);
        glVertex3f(a, 0, b + ZA_FLOOR_RES);
        glTexCoord2f(1, 1);
        glVertex3f(a + ZA_FLOOR_RES, 0, b + ZA_FLOOR_RES);
        glTexCoord2f(1, 0);
        glVertex3f(a + ZA_FLOOR_RES, 0, b);
      }
    }
    glEnd();

    glBindTexture(GL_TEXTURE_2D, ResourceLoader.white);
    color = BufferUtils.createFloatBuffer(4);
    color.put(1).put(0.8f).put(0.6f).put(1).flip();
    glMaterial(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, color);
  }
Ejemplo n.º 13
0
  /** R_DrawSpriteModel */
  void R_DrawSpriteModel(entity_t e) {
    float alpha = 1.0F;

    qfiles.dsprframe_t frame;
    qfiles.dsprite_t psprite;

    // don't even bother culling, because it's just a single
    // polygon without a surface cache

    psprite = (qfiles.dsprite_t) currentmodel.extradata;

    e.frame %= psprite.numframes;

    frame = psprite.frames[e.frame];

    if ((e.flags & Defines.RF_TRANSLUCENT) != 0) alpha = e.alpha;

    if (alpha != 1.0F) GL11.glEnable(GL11.GL_BLEND);

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

    GL_Bind(currentmodel.skins[e.frame].texnum);

    GL_TexEnv(GL11.GL_MODULATE);

    if (alpha == 1.0) GL11.glEnable(GL11.GL_ALPHA_TEST);
    else GL11.glDisable(GL11.GL_ALPHA_TEST);

    GL11.glBegin(GL11.GL_QUADS);

    GL11.glTexCoord2f(0, 1);
    Math3D.VectorMA(e.origin, -frame.origin_y, vup, point);
    Math3D.VectorMA(point, -frame.origin_x, vright, point);
    GL11.glVertex3f(point[0], point[1], point[2]);

    GL11.glTexCoord2f(0, 0);
    Math3D.VectorMA(e.origin, frame.height - frame.origin_y, vup, point);
    Math3D.VectorMA(point, -frame.origin_x, vright, point);
    GL11.glVertex3f(point[0], point[1], point[2]);

    GL11.glTexCoord2f(1, 0);
    Math3D.VectorMA(e.origin, frame.height - frame.origin_y, vup, point);
    Math3D.VectorMA(point, frame.width - frame.origin_x, vright, point);
    GL11.glVertex3f(point[0], point[1], point[2]);

    GL11.glTexCoord2f(1, 1);
    Math3D.VectorMA(e.origin, -frame.origin_y, vup, point);
    Math3D.VectorMA(point, frame.width - frame.origin_x, vright, point);
    GL11.glVertex3f(point[0], point[1], point[2]);

    GL11.glEnd();

    GL11.glDisable(GL11.GL_ALPHA_TEST);
    GL_TexEnv(GL11.GL_REPLACE);

    if (alpha != 1.0F) GL11.glDisable(GL11.GL_BLEND);

    GL11.glColor4f(1, 1, 1, 1);
  }
Ejemplo n.º 14
0
  /** GL_DrawParticles */
  void GL_DrawParticles(int num_particles) {
    float origin_x, origin_y, origin_z;

    Math3D.VectorScale(vup, 1.5f, up);
    Math3D.VectorScale(vright, 1.5f, right);

    GL_Bind(r_particletexture.texnum);
    GL11.glDepthMask(false); // no z buffering
    GL11.glEnable(GL11.GL_BLEND);
    GL_TexEnv(GL11.GL_MODULATE);

    GL11.glBegin(GL11.GL_TRIANGLES);

    FloatBuffer sourceVertices = particle_t.vertexArray;
    IntBuffer sourceColors = particle_t.colorArray;
    float scale;
    int color;
    for (int j = 0, i = 0; i < num_particles; i++) {
      origin_x = sourceVertices.get(j++);
      origin_y = sourceVertices.get(j++);
      origin_z = sourceVertices.get(j++);

      // hack a scale up to keep particles from disapearing
      scale =
          (origin_x - r_origin[0]) * vpn[0]
              + (origin_y - r_origin[1]) * vpn[1]
              + (origin_z - r_origin[2]) * vpn[2];

      scale = (scale < 20) ? 1 : 1 + scale * 0.004f;

      color = sourceColors.get(i);

      GL11.glColor4ub(
          (byte) ((color) & 0xFF),
          (byte) ((color >> 8) & 0xFF),
          (byte) ((color >> 16) & 0xFF),
          (byte) ((color >>> 24)));
      // first vertex
      GL11.glTexCoord2f(0.0625f, 0.0625f);
      GL11.glVertex3f(origin_x, origin_y, origin_z);
      // second vertex
      GL11.glTexCoord2f(1.0625f, 0.0625f);
      GL11.glVertex3f(origin_x + up[0] * scale, origin_y + up[1] * scale, origin_z + up[2] * scale);
      // third vertex
      GL11.glTexCoord2f(0.0625f, 1.0625f);
      GL11.glVertex3f(
          origin_x + right[0] * scale, origin_y + right[1] * scale, origin_z + right[2] * scale);
    }
    GL11.glEnd();

    GL11.glDisable(GL11.GL_BLEND);
    GL11.glColor4f(1, 1, 1, 1);
    GL11.glDepthMask(true); // back to normal Z buffering
    GL_TexEnv(GL11.GL_REPLACE);
  }
Ejemplo n.º 15
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
    }
  }
 private static void drawBox() {
   GL11.glBegin(GL11.GL_QUADS);
   GL11.glTexCoord2f(0.0f, 0.0f);
   GL11.glVertex3f(-1.0f, -1.0f, 0.0f);
   GL11.glTexCoord2f(1.0f, 0.0f);
   GL11.glVertex3f(1.0f, -1.0f, 0.0f);
   GL11.glTexCoord2f(1.0f, 1.0f);
   GL11.glVertex3f(1.0f, 1.0f, 0.0f);
   GL11.glTexCoord2f(0.0f, 1.0f);
   GL11.glVertex3f(-1.0f, 1.0f, 0.0f);
   GL11.glEnd();
 }
Ejemplo n.º 17
0
  private void drawSprite(float x, float y, float width, float height) {
    GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST);

    GL11.glBegin(GL11.GL_QUADS);
    GL11.glVertex2f(x, y);
    GL11.glTexCoord2f(1, 1);
    GL11.glVertex2f(x + width, y);
    GL11.glTexCoord2f(1, 0);
    GL11.glVertex2f(x + width, y + height);
    GL11.glTexCoord2f(0, 0);
    GL11.glVertex2f(x, y + height);
    GL11.glTexCoord2f(0, 1);
    GL11.glEnd();
  }
Ejemplo n.º 18
0
  @Override
  public void draw() {
    exitButtonTex.bind();

    glBegin(GL_QUADS); // start button 100x40 box
    glTexCoord2f(0, 0);
    glVertex2d(x, y); // top left
    glTexCoord2f(1, 0);
    glVertex2d(x + width, y); // top right
    glTexCoord2f(1, 1);
    glVertex2d(x + width, y + height); // bottom right
    glTexCoord2f(0, 1);
    glVertex2d(x, y + height); // bottom left
    glEnd();
  }
Ejemplo n.º 19
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);
  }
Ejemplo n.º 20
0
  @Override
  protected void doFlush() {
    // TODO: Use fallback material modes for this
    if (!(activeMaterial.getShader() instanceof BasicShader)) {
      throw new IllegalStateException("Need Basic Shader in 1.1 mode");
    }

    GL11.glNewList(displayList, GL11.GL_COMPILE);
    ((BasicShader) activeMaterial.getShader()).assign(true);
    GL11.glPushMatrix();
    GL11.glBegin(renderMode);
    for (int i = 0; i < numVerticies; i += 1) {
      int index = i * 4;
      if (useColors) {
        GL11.glColor3f(
            colorBuffer.get(index), colorBuffer.get(index + 1), colorBuffer.get(index + 2));
      }
      if (useNormals) {
        GL11.glNormal3f(
            normalBuffer.get(index), normalBuffer.get(index + 1), normalBuffer.get(index + 2));
      }
      if (useTextures) {
        GL11.glTexCoord2f(uvBuffer.get((i * 2)), uvBuffer.get((i * 2) + 1));
      }
      GL11.glVertex4f(
          vertexBuffer.get(index),
          vertexBuffer.get(index + 1),
          vertexBuffer.get(index + 2),
          vertexBuffer.get(index + 3));
    }
    GL11.glEnd();
    GL11.glPopMatrix();
    GL11.glEndList();
  }
Ejemplo n.º 21
0
 public void render(MainClass m) {
   GL11.glPushMatrix();
   GL11.glTranslatef(location.x + 0.5f, location.z + 0.5f, 0);
   glBindTexture(GL_TEXTURE_2D, m.getPictureLoader().getImageAsInteger(getRenderID()));
   glBegin(GL_QUADS);
   GL11.glTexCoord2f(0f, 1f);
   GL11.glVertex2f(-0.5f, 0.5f);
   GL11.glTexCoord2f(1f, 1f);
   GL11.glVertex2f(0.5f, 0.5f);
   GL11.glTexCoord2f(1f, 0f);
   GL11.glVertex2f(0.5f, -0.5f);
   GL11.glTexCoord2f(0f, 0f);
   GL11.glVertex2f(-0.5f, -0.5f);
   glEnd();
   GL11.glPopMatrix();
 }
Ejemplo n.º 22
0
  public static void drawRect(int x, int y, int width, int height, Texture texture) {
    texture.bind();
    float offsets[] = texture.getImageOffsets();

    GL11.glBegin(GL11.GL_QUADS);
    {
      GL11.glVertex2f(x, y);
      GL11.glTexCoord2f(offsets[0], offsets[1]);
      GL11.glVertex2f(x + width, y);
      GL11.glTexCoord2f(offsets[0], offsets[3]);
      GL11.glVertex2f(x + width, y + height);
      GL11.glTexCoord2f(offsets[2], offsets[3]);
      GL11.glVertex2f(x, y + height);
      GL11.glTexCoord2f(offsets[2], offsets[1]);
    }
    GL11.glEnd();
  }
Ejemplo n.º 23
0
 // 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();
 }
Ejemplo n.º 24
0
  public static void drawString(UIFont font, String s, int x, int y, Color color) {
    if (s == null || s.length() <= 0) return;

    glEnable(GL_TEXTURE_2D);
    glBindTexture(GL_TEXTURE_2D, font.getFontTexture().id);
    glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);

    glEnable(GL_BLEND);
    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

    glColor4f(color.r, color.g, color.b, color.a);

    glBegin(GL_QUADS);
    {
      for (char c : s.toCharArray()) {
        if (c == '\n') y += font.getHeight();

        float width = font.charWidth(c);
        float height = font.getHeight();
        float u = 1f / font.getFontImageWidth() * font.getCharX(c);
        float v = 1f / font.getFontImageHeight() * font.getCharY(c);
        float u2 = u + 1f / font.getFontImageWidth() * width;
        float v2 = v + 1f / font.getFontImageHeight() * height;

        glTexCoord2f(u, v);
        glVertex2f(x, y);

        glTexCoord2f(u2, v);
        glVertex2f(x + width, y);

        glTexCoord2f(u2, v2);
        glVertex2f(x + width, y + height);

        glTexCoord2f(u, v2);
        glVertex2f(x, y + height);

        x += width;
      }
    }
    glEnd();

    glColor4f(1, 1, 1, 1);

    glDisable(GL_BLEND);
    glDisable(GL_TEXTURE_2D);
  }
Ejemplo n.º 25
0
  @Override
  public void render() {
    TextureBank.instance.bindTexture("gui.png");
    RenderHelper.enableAlphaMask();

    float sliderPixelHeight = 32f;
    float sliderTextureHeight = sliderPixelHeight / Map.TEXTURE_SIZE;
    float sliderPixelWidth = 4f;

    float posX = getPos().getX();
    float posY = getPos().getY();
    float sizeX = getSize().getX();
    float sizeY = getSize().getY();

    glBegin(GL_QUADS);

    glTexCoord2f(0, Map.TILE_TEXTURE_SIZE * TEX_OFFSET);
    glVertex3f(posX, posY, -1f);

    glTexCoord2f(Map.TILE_TEXTURE_SIZE * 4f, Map.TILE_TEXTURE_SIZE * TEX_OFFSET);
    glVertex3f(posX + sizeX, posY, -1f);

    glTexCoord2f(
        Map.TILE_TEXTURE_SIZE * 4f, Map.TILE_TEXTURE_SIZE * TEX_OFFSET + Map.TILE_TEXTURE_SIZE);
    glVertex3f(posX + sizeX, posY + sizeY, -1f);

    glTexCoord2f(0, Map.TILE_TEXTURE_SIZE * TEX_OFFSET + Map.TILE_TEXTURE_SIZE);
    glVertex3f(posX, posY + sizeY, -1f);

    glEnd();

    double scale = (sizeX - sliderWidth * 2f) / (max - min);
    float sliderXPos = (float) (posX + position * scale - min * scale);

    glBegin(GL_QUADS);

    glTexCoord2f(
        sliderPixelWidth * Map.TILE_TEXTURE_SIZE + sliderWidth / Map.TEXTURE_SIZE,
        Map.TILE_TEXTURE_SIZE * TEX_OFFSET + sliderTextureHeight);
    glVertex3f(sliderXPos + sliderWidth * 2f, (posY + sizeY), -1f);

    glTexCoord2f(
        sliderPixelWidth * Map.TILE_TEXTURE_SIZE + sliderWidth / Map.TEXTURE_SIZE,
        Map.TILE_TEXTURE_SIZE * TEX_OFFSET);
    glVertex3f(sliderXPos + sliderWidth * 2f, posY, -1f);

    glTexCoord2f(sliderPixelWidth * Map.TILE_TEXTURE_SIZE, Map.TILE_TEXTURE_SIZE * TEX_OFFSET);
    glVertex3f(sliderXPos, posY, -1f);

    glTexCoord2f(
        sliderPixelWidth * Map.TILE_TEXTURE_SIZE,
        Map.TILE_TEXTURE_SIZE * TEX_OFFSET + sliderTextureHeight);
    glVertex3f(sliderXPos, (posY + sizeY), -1f);

    glEnd();
  }
Ejemplo n.º 26
0
 private float func_78266_a(int p_78266_1_, boolean p_78266_2_) {
   float var3 = (float) (p_78266_1_ % 16 * 8);
   float var4 = (float) (p_78266_1_ / 16 * 8);
   float var5 = p_78266_2_ ? 1.0F : 0.0F;
   this.field_78298_i.func_110577_a(this.field_111273_g);
   float var6 = (float) this.field_78286_d[p_78266_1_] - 0.01F;
   GL11.glBegin(5);
   GL11.glTexCoord2f(var3 / 128.0F, var4 / 128.0F);
   GL11.glVertex3f(this.field_78295_j + var5, this.field_78296_k, 0.0F);
   GL11.glTexCoord2f(var3 / 128.0F, (var4 + 7.99F) / 128.0F);
   GL11.glVertex3f(this.field_78295_j - var5, this.field_78296_k + 7.99F, 0.0F);
   GL11.glTexCoord2f((var3 + var6 - 1.0F) / 128.0F, var4 / 128.0F);
   GL11.glVertex3f(this.field_78295_j + var6 - 1.0F + var5, this.field_78296_k, 0.0F);
   GL11.glTexCoord2f((var3 + var6 - 1.0F) / 128.0F, (var4 + 7.99F) / 128.0F);
   GL11.glVertex3f(this.field_78295_j + var6 - 1.0F - var5, this.field_78296_k + 7.99F, 0.0F);
   GL11.glEnd();
   return (float) this.field_78286_d[p_78266_1_];
 }
Ejemplo n.º 27
0
  private void buildList() {
    glList = GL11.glGenLists(1);

    GL11.glNewList(glList, GL11.GL_COMPILE);

    GL11.glBegin(GL11.GL_QUADS);
    GL11.glTexCoord2f(0, 0);
    GL11.glVertex2f(0, 0);
    GL11.glTexCoord2f(texture.getWidth(), 0);
    GL11.glVertex2f(texture.getImageWidth(), 0);
    GL11.glTexCoord2f(texture.getWidth(), texture.getHeight());
    GL11.glVertex2f(texture.getImageWidth(), texture.getImageHeight());
    GL11.glTexCoord2f(0, texture.getHeight());
    GL11.glVertex2f(0, texture.getImageHeight());
    GL11.glEnd();

    GL11.glEndList();
  }
Ejemplo n.º 28
0
 public void render(Player player) {
   if (player.playersWorld() == world) {
     Color.white.bind();
     texture.bind();
     GL11.glBegin(GL11.GL_QUADS);
     {
       GL11.glTexCoord2f(0, 0);
       GL11.glVertex2f(x, y + world.getHEIGHT() - (y * 2) - height);
       GL11.glTexCoord2f(texture.getWidth(), 0);
       GL11.glVertex2f(x + width, y + world.getHEIGHT() - (y * 2) - height);
       GL11.glTexCoord2f(texture.getWidth(), texture.getHeight());
       GL11.glVertex2f(x + width, y + height + world.getHEIGHT() - (y * 2) - height);
       GL11.glTexCoord2f(0, texture.getHeight());
       GL11.glVertex2f(x, y + height + world.getHEIGHT() - (y * 2) - height);
     }
     GL11.glEnd();
   }
 }
Ejemplo n.º 29
0
  /**
   * Used to draw a string of text on the current GLPanel
   *
   * @param text - The text
   * @param x - The x coordinate
   * @param y - The y coordinate
   * @param color - The color of the text (GLColor)
   */
  public void drawString(String text, float x, float y, GLColor color) {
    glEnable(GL_BLEND);
    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

    glBindTexture(GL_TEXTURE_2D, textureID);
    glColor4f(
        color.getRed() / 255f,
        color.getGreen() / 255f,
        color.getBlue() / 255f,
        color.getAlpha() / 255f);

    glPushMatrix();
    glTranslatef(x, y + fontHeight, 0f);

    xbuf.put(0, 0.0f);
    ybuf.put(0, 0.0f);
    glBegin(GL_QUADS);
    for (int i = 0; i < text.length(); i++) {
      char c = text.charAt(i);
      if (c == '\n') {
        ybuf.put(0, ybuf.get(0) + fontHeight);
        xbuf.put(0, 0.0f);
        continue;
      } else if (c < 32 || 128 <= c) continue;

      STBTruetype.stbtt_GetBakedQuad(cdata, BITMAP_W, BITMAP_H, c - 32, xbuf, ybuf, quad, 1);

      glTexCoord2f(quad.s0(), quad.t0());
      glVertex2f(quad.x0(), quad.y0());

      glTexCoord2f(quad.s1(), quad.t0());
      glVertex2f(quad.x1(), quad.y0());

      glTexCoord2f(quad.s1(), quad.t1());
      glVertex2f(quad.x1(), quad.y1());

      glTexCoord2f(quad.s0(), quad.t1());
      glVertex2f(quad.x0(), quad.y1());
    }
    glEnd();

    glPopMatrix();
    glDisable(GL_BLEND);
  }
Ejemplo n.º 30
0
  /**
   * Method called by the World Class to render the Tile.
   *
   * @param x : location to where the Tile is going to be rendered.
   * @param y : location to where the Tile is going to be rendered.
   * @param w : instance of the World Class
   * @param ent : List of entities that emit light.
   */
  public void render(int x, int y, World w, ArrayList<Entity> ent) {
    // Binding the Uniforms to make the light effects.
    bindUniforms(w, ent);

    // Setting up OpenGL for render
    glEnable(GL_BLEND);
    glBlendFunc(GL_SRC_ALPHA, GL_ZERO);

    // Updating the Tile coordinates.
    this.x = x;
    this.y = y;
    glTranslatef(x, y, 0);
    // Activating and Binding the Tile Texture.
    glActiveTexture(GL_TEXTURE0);
    glBindTexture(GL_TEXTURE_2D, this.tex);
    // Sending the texture to the shader.
    glUniform1i(glGetUniformLocation(shade.getShader(), "texture"), 0);

    // Drawing the QUAD.
    glBegin(GL_QUADS);
    {
      glTexCoord2f(0, 0);
      glVertex2f(0, 0);

      glTexCoord2f(0, 1);
      glVertex2f(0, this.height);

      glTexCoord2f(1, 1);
      glVertex2f(this.width, this.height);

      glTexCoord2f(1, 0);
      glVertex2f(this.width, 0);
    }
    glEnd();
    // Releasing the Texture.
    glBindTexture(GL_TEXTURE_2D, 0);
    // Getting the location back to the inicial coordinates.
    glTranslatef(-x, -y, 0);

    // Disabling BLEND and releasing shader for next render.
    glDisable(GL_BLEND);
    shade.release();
    glClear(GL_STENCIL_BUFFER_BIT);
  }