Beispiel #1
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();
  }
Beispiel #2
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();
  }
Beispiel #3
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();
  }
  public void updateMap() {
    GL11.glClear(GL11.GL_COLOR_BUFFER_BIT);

    for (int c = 0; c < Generation.chunklist.chunks.size(); c++) {
      int cx = Generation.chunklist.chunks.get(c).chunkY;
      int cy = Generation.chunklist.chunks.get(c).chunkX;
      int[][] top = Generation.chunklist.chunks.get(c).TOPBLOCK;

      for (int x = 0; x < 16; x++) {
        for (int y = 0; y < 16; y++) {
          int id = top[x][y];

          GL11.glPushMatrix();
          GL11.glTranslatef(x * 2 + (cx * 32), y * 2 + (cy * 32), 0);
          getColor(id, c, x, y);

          GL11.glBegin(GL11.GL_QUADS);
          GL11.glVertex2f(x * 2 + (cx * 32), y * 2 + (cy * 32) + 4);
          GL11.glVertex2f(x * 2 + (cx * 32), y * 2 + (cy * 32));
          GL11.glVertex2f(x * 2 + (cx * 32) + 4, y * 2 + (cy * 32));
          GL11.glVertex2f(x * 2 + (cx * 32) + 4, y * 2 + (cy * 32) + 4);
          GL11.glEnd();
          GL11.glPopMatrix();
        }
      }
    }
  }
  @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();
  }
Beispiel #6
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();
 }
  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);
  }
Beispiel #8
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);
  }
Beispiel #9
0
  /**
   * Renders a rectangle over the are covered by the QuadtreeNode. Note that glBegin and glEnd must
   * be called before and after this function, as it only generates vertecies.
   */
  public void render() {
    GL11.glVertex2f(x1, y1);
    GL11.glVertex2f(x2, y1);
    GL11.glVertex2f(x2, y2);
    GL11.glVertex2f(x1, y2);

    for (QuadtreeNode q : children) if (q != null) q.render();
  }
Beispiel #10
0
 public void makeRectangle(int x, int y, int length, int height) {
   glBegin(GL_QUADS);
   glVertex2f(x, y);
   glVertex2f(x + length, y);
   glVertex2f(x + length, y + height);
   glVertex2f(x, y + height);
   glEnd();
 }
  private void drawLine(int X1, int Y1, int X2, int Y2, float color[]) {
    GL11.glColor3f(color[0], color[1], color[2]);

    GL11.glBegin(GL11.GL_LINES);
    GL11.glVertex2f(X1, Y1);
    GL11.glVertex2f(X2, Y2);
    GL11.glEnd();
  }
Beispiel #12
0
 public static void draw(FloatRect rect, float width) {
   glLineWidth(width);
   glBegin(GL_LINE_LOOP);
   glVertex2f(rect.x, rect.y);
   glVertex2f(rect.x + rect.w, rect.y);
   glVertex2f(rect.x + rect.w, rect.y + rect.h);
   glVertex2f(rect.x, rect.y + rect.h);
   glEnd();
 }
 private void drawBackground() {
   glColor3f(0, 0, 0);
   glBegin(GL_QUADS);
   glVertex2f(0, 0);
   glVertex2f(800, 0);
   glVertex2f(800, 600);
   glVertex2f(0, 600);
   glEnd();
 }
Beispiel #14
0
 public void drawMe() {
   glBegin(GL_QUADS);
   glColor3f(0.0f, 0.0f, 0.2f);
   glVertex2f(-1, 1);
   glVertex2f(-0.5f, 1);
   glVertex2f(-0.5f, 0.5f);
   glVertex2f(-1, 0.5f);
   glEnd();
 }
Beispiel #15
0
 public static void drawRect(int x, int y, int width, int height) {
   GL11.glBegin(GL11.GL_QUADS);
   {
     GL11.glVertex2f(x, y);
     GL11.glVertex2f(x + width, y);
     GL11.glVertex2f(x + width, y + height);
     GL11.glVertex2f(x, y + height);
   }
   GL11.glEnd();
 }
Beispiel #16
0
 @Override
 public void draw() {
   GL11.glColor3f(0.2f, 0.2f, 0.2f);
   GL11.glBegin(GL11.GL_QUADS);
   GL11.glVertex2f(posX, posY);
   GL11.glVertex2f(posX + SIZE, posY);
   GL11.glVertex2f(posX + SIZE, posY + SIZE);
   GL11.glVertex2f(posX, posY + SIZE);
   GL11.glEnd();
 }
 private void renderLine() {
   glColor3f(1, 0, 1);
   glBegin(GL_LINES);
   for (Particle p : particles) {
     p.color.bind();
     glVertex2f(p.prevx, p.prevy);
     glVertex2f(p.x, p.y);
   }
   glEnd();
 }
Beispiel #18
0
 private static void drawLineAsQuad(float x0, float y0, float x1, float y1, float w) {
   float dx = x1 - x0;
   float dy = y1 - y0;
   float l = (float) Math.sqrt(dx * dx + dy * dy) / w;
   dx /= l;
   dy /= l;
   GL11.glVertex2f(x0 - dx + dy, y0 - dy - dx);
   GL11.glVertex2f(x0 - dx - dy, y0 - dy + dx);
   GL11.glVertex2f(x1 + dx - dy, y1 + dy + dx);
   GL11.glVertex2f(x1 + dx + dy, y1 + dy - dx);
 }
Beispiel #19
0
 /** Draw a chatbox from the bottom of the screen to ChatTop, and fill the screen horizontally */
 private void drawChatBox() {
   glBegin(GL_QUADS);
   {
     glColor4f(0.0f, 0.0f, 0.0f, 0.5f);
     glVertex2f(0.0f, Display.getHeight());
     glVertex2f(0.0f, ChatTop);
     glVertex2f(Display.getWidth(), ChatTop);
     glVertex2f(Display.getWidth(), Display.getHeight());
   }
   glEnd();
 }
  private void drawQuad(int x, int y, int h, int w, float color[], float alpha) {
    GL11.glColor4f(color[0], color[1], color[2], alpha);

    // draw quad
    GL11.glBegin(GL11.GL_QUADS);
    GL11.glVertex2f(x, y);
    GL11.glVertex2f(x + w, y);
    GL11.glVertex2f(x + w, y + h);
    GL11.glVertex2f(x, y + h);
    GL11.glEnd();
  }
Beispiel #21
0
  public static void draw(FloatRect rect, Color3f color, float width) {
    color.drawWith();

    glLineWidth(width);
    glBegin(GL_LINE_LOOP);
    glVertex2f(rect.x, rect.y);
    glVertex2f(rect.x + rect.w, rect.y);
    glVertex2f(rect.x + rect.w, rect.y + rect.h);
    glVertex2f(rect.x, rect.y + rect.h);
    glEnd();

    color.drawWithout();
  }
Beispiel #22
0
 /** Draws a basic loading splash screen. */
 public void drawLoading() {
   // setup
   String s = "Loading...";
   int sWidth = fontManager.s.getWidth(s);
   int sHeight = fontManager.s.getLineHeight();
   int x = -sWidth / 2;
   int y = -sHeight / 2;
   // draw
   gameWindow.clearScreen();
   glDisable(GL_TEXTURE_2D);
   // bottom fade
   glBegin(GL_QUADS);
   glColor3f(0.0f, 0.0f, 0.0f);
   {
     glVertex2f(-gameWindow.getGameWidth() / 2, -gameWindow.getWindowHeight() / 2);
     glVertex2f(gameWindow.getGameWidth() / 2, -gameWindow.getWindowHeight() / 2);
     glVertex2f(gameWindow.getGameWidth() / 2, gameWindow.getWindowHeight() / 2);
     glVertex2f(-gameWindow.getGameWidth() / 2, gameWindow.getWindowHeight() / 2);
   }
   glEnd();
   // center stripe
   glBegin(GL_QUADS);
   glColor3f(0.2f, 0.2f, 0.2f);
   {
     glVertex2f(-gameWindow.getGameWidth() / 2, y - sHeight * 2);
     glVertex2f(gameWindow.getGameWidth() / 2, y - sHeight * 2);
     glVertex2f(gameWindow.getGameWidth() / 2, y + fontManager.s.getLineHeight() + sHeight * 2);
     glVertex2f(-gameWindow.getGameWidth() / 2, y + fontManager.s.getLineHeight() + sHeight * 2);
   }
   glEnd();
   // text
   fontManager.s.drawString(x, y, s, Color.black);
   gameWindow.update();
 }
Beispiel #23
0
  public void renderGL() {
    GL11.glClear(
        GL11.GL_COLOR_BUFFER_BIT
            | GL11.GL_DEPTH_BUFFER_BIT); // Clear The Screen And The Depth Buffer

    GL11.glColor3f(0.5f, 0.5f, 1.0f); // set the color of the quad (R,G,B,A)
    GL11.glBegin(GL11.GL_QUADS); // draw quad
    GL11.glVertex2f(100, 100);
    GL11.glVertex2f(100 + 200, 100);
    GL11.glVertex2f(100 + 200, 100 + 200);
    GL11.glVertex2f(100, 100 + 200);
    GL11.glEnd();

    font.draw_str("HELLO", 150, 150);

    s.draw(100, 400, 2f);
    s.draw(300, 400, 2.23f);

    GL11.glColor3f(0.5f, 0.5f, 1.0f); // R,G,B,A Set The Color To Blue One Time Only
    GL11.glPushMatrix(); // draw quad
    GL11.glTranslatef(x, y, 0);
    GL11.glRotatef(rotation, 0f, 0f, 1f);
    GL11.glTranslatef(-x, -y, 0);

    GL11.glBegin(GL11.GL_QUADS);
    GL11.glVertex2f(x - 50, y - 50);
    GL11.glVertex2f(x + 50, y - 50);
    GL11.glVertex2f(x + 50, y + 50);
    GL11.glVertex2f(x - 50, y + 50);
    GL11.glEnd();
    GL11.glPopMatrix();
  }
Beispiel #24
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();
  }
Beispiel #25
0
 @Override
 public void RenderImageSecond(int x, int y, int Sprite) {
   if (MainRoop.Debug) {
     GL11.glDisable(GL11.GL_BLEND);
     GL11.glColor4f(1.f, 0.f, 0.f, 0.5f);
     GL11.glDisable(GL11.GL_TEXTURE);
     GL11.glBegin(GL11.GL_LINE_LOOP);
     GL11.glVertex2f(collision[0].x, collision[0].y);
     GL11.glVertex2f(collision[0].x + collision[0].width, collision[0].y);
     GL11.glVertex2f(collision[0].x + collision[0].width, collision[0].y + collision[0].height);
     GL11.glVertex2f(collision[0].x, collision[0].y + collision[0].height);
     GL11.glEnd();
   }
 }
Beispiel #26
0
 public void renderBackground(float paramRed, float paramGreen, float paramBlue) {
   glPushMatrix();
   glDisable(GL_BLEND);
   glBegin(GL_QUADS);
   glColor3f(paramRed, paramGreen, paramBlue);
   glEnable(GL_COLOR_MATERIAL);
   glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE);
   glNormal3f(0f, 0f, 1.0f);
   glVertex2f(0, 0);
   glVertex2f(Display.getWidth(), 0);
   glVertex2f(Display.getWidth(), Display.getHeight());
   glVertex2f(0, Display.getHeight());
   glEnd();
   glPopMatrix();
 }
Beispiel #27
0
 @Override
 public void render() {
   getColor().apply();
   GL11.glBegin(GL11.GL_POINTS);
   GL11.glVertex2f(0f, 0f);
   GL11.glEnd();
 }
Beispiel #28
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();
 }
Beispiel #29
0
  @Override
  protected void drawGuiContainerForegroundLayer(int x, int y) {
    GL11.glPushMatrix();
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glDisable(GL11.GL_DEPTH_TEST);
    GL11.glDisable(GL11.GL_TEXTURE_2D);
    GL11.glDisable(GL11.GL_LIGHTING);

    GL11.glPushMatrix();

    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);

    // GL11.glBegin(GL11.GL_TRIANGLE_FAN);
    GL11.glBegin(GL11.GL_LINE_LOOP);
    for (int ii = 0; ii < 50; ii++) {
      float theta = 2.0f * 3.1415926f * ii / 50; // get the current angle

      float xLocation = 50 * (float) Math.cos(theta); // calculate the x component
      float yLocation = 50 * (float) Math.sin(theta); // calculate the y component

      GL11.glVertex2f(xLocation + 60f, yLocation + 60f); // output vertex
    }
    GL11.glEnd();

    GL11.glPopMatrix();

    GL11.glEnable(GL11.GL_TEXTURE_2D);
    GL11.glDisable(GL11.GL_BLEND);
    GL11.glEnable(GL11.GL_DEPTH_TEST);
    GL11.glEnable(GL11.GL_LIGHTING);
    GL11.glPopMatrix();

    super.drawGuiContainerForegroundLayer(x, y);
  }
 private void renderPoint() {
   glBegin(GL_POINTS);
   for (Particle p : particles) {
     glVertex2f(p.x, p.y);
   }
   glEnd();
 }