Пример #1
0
  @Override
  protected void doDisplay(I3dCamera camera) {
    float x0 = -size.x / 2;
    float y0 = -size.y / 2;
    float x1 = size.x / 2;
    float y1 = size.y / 2;

    GL11.glLineWidth(thickness);

    if (renderMode == RenderMode.SOLID) {
      GL11.glEnable(GL11.GL_LINE_STIPPLE);
      GL11.glLineStipple(stippleFactor, stipplePattern);

      GL11.glBegin(GL11.GL_LINE_LOOP);

      GL11.glVertex3d(x0, y1, 0);
      GL11.glVertex3d(x0, y0, 0);
      GL11.glVertex3d(x1, y0, 0);
      GL11.glVertex3d(x1, y1, 0);

      GL11.glEnd();

      GL11.glDisable(GL11.GL_LINE_STIPPLE);
    } else {
      GL11.glBegin(GL11.GL_QUADS);

      GL11.glVertex3d(x0, y1, 0);
      GL11.glVertex3d(x0, y0, 0);
      GL11.glVertex3d(x1, y0, 0);
      GL11.glVertex3d(x1, y1, 0);

      GL11.glEnd();
    }
  }
Пример #2
0
  public void render() {

    glBindTexture(GL_TEXTURE_2D, x_pos * 2 * (1 + y_pos * 2));

    glBegin(GL_TRIANGLES);
    glColor3f(1f, 1f, 1f);
    glTexCoord2f(0f, 1f);
    glVertex2f(x_pos + 0f, y_pos + 0f);

    glTexCoord2f(1f, 1f);
    glVertex2f(x_pos + 1f, y_pos + 0f);

    glTexCoord2f(0f, 0f);
    glVertex2f(x_pos + 0f, y_pos + 1f);
    glEnd();

    glBegin(GL_TRIANGLES);
    glTexCoord2f(1f, 1f);
    glVertex2f(x_pos + 1f, y_pos + 0f);

    glTexCoord2f(1f, 0f);
    glVertex2f(x_pos + 1f, y_pos + 1f);

    glTexCoord2f(0f, 0f);
    glVertex2f(x_pos + 0f, y_pos + 1f);
    glEnd();
  }
Пример #3
0
  @Override
  public void draw(Canvas canvas) {

    Color currColor = canvas.getColor();

    canvas.setColor(Color.GREEN);
    int width = mRect.widht() * mHealth / mMaxHelth;
    glPushMatrix();
    glTranslated(mX, mY, 0);
    glBegin(GL_QUADS);
    glVertex2d(1, 1);
    glVertex2d(width, 1);
    glVertex2d(width, mRect.height() - 1);
    glVertex2d(1, mRect.height() - 1);
    glEnd();
    glTranslated(0, 0, 0);
    glPopMatrix();
    canvas.setColor(currColor);

    canvas.setColor(Color.RED);
    glPushMatrix();
    glTranslated(mX, mY, 0);
    glBegin(GL_QUADS);
    glVertex2d(1, 1);
    glVertex2d(mRect.widht() - 1, 1);
    glVertex2d(mRect.widht() - 1, mRect.height() - 1);
    glVertex2d(1, mRect.height() - 1);
    glEnd();
    glTranslated(0, 0, 0);
    glPopMatrix();
    canvas.setColor(currColor);

    super.draw(canvas);
  }
Пример #4
0
  public static void drawSkeleton(Model m) {
    glPointSize(4);

    // Bones
    glBegin(GL_POINTS);
    {
      for (Bone b : m.bones) {
        glColor3f(0, 0, 1);
        glVertex3f(b.pos.x, b.pos.y, b.pos.z);
      }
    }
    glEnd();

    glColor3f(1, 1, 0);

    Bone b2;

    glBegin(GL_LINES);
    {
      for (Bone b : m.bones) {
        if (b.parent != null) {
          b2 = b.parent;

          glVertex3f(b.pos.x, b.pos.y, b.pos.z);
          glVertex3f(b2.pos.x, b2.pos.y, b2.pos.z);
        }
      }
    }
    glEnd();

    glColor4f(1, 1, 1, 1);
    glPointSize(1);
  }
Пример #5
0
  public static void renderSphere(Vector3f center, float radius, Vector3f colour) {
    glPushAttrib(GL_ENABLE_BIT);
    {
      glDisable(GL_TEXTURE_2D); // Texture 2D is disabled so no textures are incorporated
      glDisable(GL_LIGHTING); // Lighting is turned off for 2D
      glBegin(GL_LINE_LOOP);
      {
        glColor3f(colour.x, colour.y, colour.z);
        for (int i = 0; i < 360; i++) {
          double degInRad = i * Math.PI / 180;
          glVertex3f(
              (float) (center.x + Math.cos(degInRad) * radius),
              (float) (center.y + Math.sin(degInRad) * radius),
              center.z);
        }
      }
      glEnd();

      glBegin(GL_LINE_LOOP);
      {
        glColor3f(colour.x, colour.y, colour.z);
        for (int i = 0; i < 360; i++) {
          double degInRad = i * Math.PI / 180;
          glVertex3f(
              center.x,
              (float) (center.y + Math.cos(degInRad) * radius),
              (float) (center.z + Math.sin(degInRad) * radius));
        }
      }
      glEnd();
    }
    glPopAttrib();
  }
Пример #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();
 }
Пример #7
0
 public final void debugRenderRegions(float landscape_x, float landscape_y) {
   int RADIUS = 30;
   int center_x = toGridCoordinate(landscape_x);
   int center_y = toGridCoordinate(landscape_y);
   int start_x = StrictMath.max(0, center_x - RADIUS);
   int end_x = StrictMath.min(occupants.length - 0, center_x + RADIUS);
   int start_y = StrictMath.max(0, center_y - RADIUS);
   int end_y = StrictMath.min(occupants.length - 0, center_y + RADIUS);
   GL11.glDisable(GL11.GL_TEXTURE_2D);
   GL11.glPointSize(3f);
   GL11.glBegin(GL11.GL_POINTS);
   Region last_region = null;
   for (int y = start_y; y < end_y; y++)
     for (int x = start_x; x < end_x; x++) {
       float xf = coordinateFromGrid(x);
       float yf = coordinateFromGrid(y);
       Region region = getRegion(x, y);
       if (region == null) {
         GL11.glColor3f(1f, 0f, 0f);
       } else {
         last_region = region;
         DebugRender.setColor(region.hashCode());
       }
       GL11.glVertex3f(xf, yf, heightmap.getNearestHeight(xf, yf) + 2f);
     }
   GL11.glEnd();
   GL11.glBegin(GL11.GL_LINES);
   GL11.glColor3f(1f, 0f, 0f);
   if (last_region != null) {
     last_region.debugRenderConnections(heightmap);
     last_region.debugRenderConnectionsReset();
   }
   GL11.glEnd();
   GL11.glEnable(GL11.GL_TEXTURE_2D);
 }
Пример #8
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();
 }
Пример #9
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();
  }
Пример #10
0
  public void initializeDisplayList() {
    list = glGenLists(1);
    glNewList(list, GL_COMPILE);
    {
      glBegin(GL_TRIANGLES);
      {
        // glColor3f(1.0f, 1.0f, 0.0f);
        for (int i = 0; i < triFaces.size(); i++) {
          // glColor3f(1.0f, 0.0f, 0.0f);
          Vector3f n1 = normals.get((int) (triFaces.get(i).normal.x - 1));
          glNormal3f(n1.x, n1.y, n1.z);
          Vector3f v1 = verticies.get((int) (triFaces.get(i).vertex.x - 1));
          glVertex3f(v1.x, v1.y, v1.z);
          // glColor3f(0.0f, 1.0f, 0.0f);
          Vector3f n2 = normals.get((int) (triFaces.get(i).normal.y - 1));
          glNormal3f(n2.x, n2.y, n2.z);
          Vector3f v2 = verticies.get((int) (triFaces.get(i).vertex.y - 1));
          glVertex3f(v2.x, v2.y, v2.z);
          // glColor3f(0.0f, 0.0f, 1.0f);
          Vector3f n3 = normals.get((int) (triFaces.get(i).normal.z - 1));
          glNormal3f(n3.x, n3.y, n3.z);
          Vector3f v3 = verticies.get((int) (triFaces.get(i).vertex.z - 1));
          glVertex3f(v3.x, v3.y, v3.z);
        }
      }
      glEnd();

      glBegin(GL_QUADS);
      {
        // glColor3f(1.0f, 0.0f, 0.0f);
        for (int i = 0; i < quadFaces.size(); i++) {
          // glColor3f(1.0f, 0.0f, 0.0f);
          Vector3f n1 = normals.get((int) (quadFaces.get(i).normal.x - 1));
          glNormal3f(n1.x, n1.y, n1.z);
          Vector3f v1 = verticies.get((int) (quadFaces.get(i).vertex.x - 1));
          glVertex3f(v1.x, v1.y, v1.z);
          // glColor3f(0.0f, 1.0f, 0.0f);
          Vector3f n2 = normals.get((int) (quadFaces.get(i).normal.y - 1));
          glNormal3f(n2.x, n2.y, n2.z);
          Vector3f v2 = verticies.get((int) (quadFaces.get(i).vertex.y - 1));
          glVertex3f(v2.x, v2.y, v2.z);
          // glColor3f(0.0f, 0.0f, 1.0f);
          Vector3f n3 = normals.get((int) (quadFaces.get(i).normal.z - 1));
          glNormal3f(n3.x, n3.y, n3.z);
          Vector3f v3 = verticies.get((int) (quadFaces.get(i).vertex.z - 1));
          glVertex3f(v3.x, v3.y, v3.z);
          Vector3f n4 = normals.get((int) (quadFaces.get(i).normal.w - 1));
          glNormal3f(n4.x, n4.y, n4.z);
          Vector3f v4 = verticies.get((int) (quadFaces.get(i).vertex.w - 1));
          glVertex3f(v4.x, v4.y, v4.z);
        }
      }
      glEnd();
    }
    glEndList();
  }
Пример #11
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();
  }
Пример #12
0
  @Override
  public void create() {
    Arrays.fill(heights, defaultHeight);

    Core.interval(.0005).onEvent(this::step).addChild(this);

    //        onUpdate(dt -> {
    //            Util.repeat(detail, i -> heights[i] += dt * speeds[i]);
    //            Util.repeat(detail - 1, i -> {
    //                deltas[i] = heights[i + 1] - heights[i];
    //                speeds[i] += deltas[i] * dt * 3000;
    //                speeds[i + 1] -= deltas[i] * dt * 3000;
    //            });
    //            Util.repeat(detail, i -> speeds[i] = speeds[i] * Math.pow(.1, dt * dt) + dt * 10 *
    // (defaultHeight - heights[i]));
    //            Util.repeat(detail - 1, i -> {
    //                heights[i] += deltas[i] * dt;
    //                heights[i + 1] -= deltas[i] * dt;
    //            });
    //        });
    onRender(
        () -> {
          glDisable(GL_TEXTURE_2D);
          glBegin(GL_TRIANGLE_STRIP);
          Util.repeat(
              detail,
              i -> {
                double x = position.x + width * (2. * i / detail - 1);
                new Color4(0, 0, .6).glColor();
                new Vec2(x, bottom).glVertex();
                new Color4(0, .2, 1).glColor();
                new Vec2(x, heights[i]).glVertex();
              });
          glEnd();
        });
    Core.renderLayer(1)
        .onEvent(
            () -> {
              glDisable(GL_TEXTURE_2D);
              glBegin(GL_TRIANGLE_STRIP);
              Util.repeat(
                  detail,
                  i -> {
                    double x = position.x + width * (2. * i / detail - 1);
                    new Color4(0, 0, .6, .5).glColor();
                    new Vec2(x, bottom).glVertex();
                    new Color4(0, .2, 1, .5).glColor();
                    new Vec2(x, heights[i]).glVertex();
                  });
              glEnd();
            })
        .addChild(this);
  }
Пример #13
0
  private void drawLightningBolt(Entity entity) {
    glDisable(GL_TEXTURE_2D);
    glDisable(GL_LIGHTING);

    glColor3f(0, 0.6f, 1);
    glBegin(GL_QUADS);
    int lastX = 0;
    int lastY = 0;
    for (int i = 0; i < 60; i++) {
      int x = i * 2;
      int y = (int) (Math.sin(i * (Math.PI / 4) - entity.ticksExisted * 2.05f) * 2.5f);

      glColor3f(1, 1f, 1);
      glVertex3d(x + 0, y + 0, 0);
      glVertex3d(x + 0, y + 1, 0);
      glVertex3d(lastX, lastY + 1, 0);
      glVertex3d(lastX, lastY, 0);

      glColor3f(0, 0.6f, 1);
      glVertex3d(x + 0, y + 1, 0);
      glVertex3d(x + 0, y + 1.25, 0);
      glVertex3d(lastX, lastY + 1.25, 0);
      glVertex3d(lastX, lastY + 1, 0);

      glVertex3d(x + 0, y - 0.25, 0);
      glVertex3d(x + 0, y, 0);
      glVertex3d(lastX, lastY, 0);
      glVertex3d(lastX, lastY - 0.25, 0);
      lastX = x;
      lastY = y;
    }
    glEnd();
    glEnable(GL_LIGHTING);
    glEnable(GL_TEXTURE_2D);
  }
Пример #14
0
 static void drawTorus(float r, float R, int nsides, int rings) {
   float ringDelta = 2.0f * (float) Math.PI / rings;
   float sideDelta = 2.0f * (float) Math.PI / nsides;
   float theta = 0.0f, cosTheta = 1.0f, sinTheta = 0.0f;
   for (int i = rings - 1; i >= 0; i--) {
     float theta1 = theta + ringDelta;
     float cosTheta1 = (float) Math.cos(theta1);
     float sinTheta1 = (float) Math.sin(theta1);
     GL11.glBegin(GL11.GL_QUAD_STRIP);
     float phi = 0.0f;
     for (int j = nsides; j >= 0; j--) {
       phi += sideDelta;
       float cosPhi = (float) Math.cos(phi);
       float sinPhi = (float) Math.sin(phi);
       float dist = R + r * cosPhi;
       GL11.glNormal3f(cosTheta1 * cosPhi, -sinTheta1 * cosPhi, sinPhi);
       GL11.glVertex3f(cosTheta1 * dist, -sinTheta1 * dist, r * sinPhi);
       GL11.glNormal3f(cosTheta * cosPhi, -sinTheta * cosPhi, sinPhi);
       GL11.glVertex3f(cosTheta * dist, -sinTheta * dist, r * sinPhi);
     }
     GL11.glEnd();
     theta = theta1;
     cosTheta = cosTheta1;
     sinTheta = sinTheta1;
   }
 }
  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();
  }
Пример #16
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);
  }
Пример #17
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);
  }
Пример #18
0
  /** R_DrawBeam */
  void R_DrawBeam(entity_t e) {
    oldorigin[0] = e.oldorigin[0];
    oldorigin[1] = e.oldorigin[1];
    oldorigin[2] = e.oldorigin[2];

    origin[0] = e.origin[0];
    origin[1] = e.origin[1];
    origin[2] = e.origin[2];

    normalized_direction[0] = direction[0] = oldorigin[0] - origin[0];
    normalized_direction[1] = direction[1] = oldorigin[1] - origin[1];
    normalized_direction[2] = direction[2] = oldorigin[2] - origin[2];

    if (Math3D.VectorNormalize(normalized_direction) == 0.0f) return;

    Math3D.PerpendicularVector(perpvec, normalized_direction);
    Math3D.VectorScale(perpvec, e.frame / 2, perpvec);

    for (int i = 0; i < 6; i++) {
      Math3D.RotatePointAroundVector(
          start_points[i], normalized_direction, perpvec, (360.0f / NUM_BEAM_SEGS) * i);

      Math3D.VectorAdd(start_points[i], origin, start_points[i]);
      Math3D.VectorAdd(start_points[i], direction, end_points[i]);
    }

    GL11.glDisable(GL11.GL_TEXTURE_2D);
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glDepthMask(false);

    float r = (d_8to24table[e.skinnum & 0xFF]) & 0xFF;
    float g = (d_8to24table[e.skinnum & 0xFF] >> 8) & 0xFF;
    float b = (d_8to24table[e.skinnum & 0xFF] >> 16) & 0xFF;

    r *= 1 / 255.0f;
    g *= 1 / 255.0f;
    b *= 1 / 255.0f;

    GL11.glColor4f(r, g, b, e.alpha);

    GL11.glBegin(GL11.GL_TRIANGLE_STRIP);

    float[] v;

    for (int i = 0; i < NUM_BEAM_SEGS; i++) {
      v = start_points[i];
      GL11.glVertex3f(v[0], v[1], v[2]);
      v = end_points[i];
      GL11.glVertex3f(v[0], v[1], v[2]);
      v = start_points[(i + 1) % NUM_BEAM_SEGS];
      GL11.glVertex3f(v[0], v[1], v[2]);
      v = end_points[(i + 1) % NUM_BEAM_SEGS];
      GL11.glVertex3f(v[0], v[1], v[2]);
    }
    GL11.glEnd();

    GL11.glEnable(GL11.GL_TEXTURE_2D);
    GL11.glDisable(GL11.GL_BLEND);
    GL11.glDepthMask(true);
  }
Пример #19
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();
  }
  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();
        }
      }
    }
  }
Пример #21
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();
  }
  @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();
    }
  }
Пример #23
0
  public void draw() {
    float x = 0, y = 0, z = 0, X = (float) -Math.PI, Y = 0.0f, Z = 0.0f;
    Vector3f first = new Vector3f();
    Vector3f second = new Vector3f();
    Vector3f thrird = new Vector3f();

    glPushMatrix();
    {
      glTranslatef(translate.getX(), translate.getY(), translate.getZ());
      glRotatef(angleOfRotation, rotate.getX(), rotate.getY(), rotate.getZ());
      glScalef(scale.getX(), scale.getY(), scale.getZ());
      glColor3f(color.getX(), color.getY(), color.getY());
      glDisable(GL_CULL_FACE);
      glLineWidth(10);

      glBegin(GL_LINE_STRIP);
      {
        while (X < 2 * Math.PI) {
          while (Y < 2 * Math.PI) {
            x = size * (float) Math.cos(X) * (float) Math.cos(Y);
            y = size * (float) Math.cos(X) * (float) Math.sin(Y);
            z = size * (float) Math.sin(X);
            glVertex3f(x, y, z);

            first.setX(x);
            first.setY(y);
            first.setZ(z);

            x = size * (float) Math.cos(X) * (float) Math.cos(Y);
            y = size * (float) Math.cos(X) * (float) Math.sin(Y);
            z = size * (float) Math.sin(X);
            glVertex3f(x, y, z);

            second.setX(x);
            second.setY(y);
            second.setZ(z);

            x = size * (float) Math.cos(X) * (float) Math.cos(Y);
            y = size * (float) Math.cos(X) * (float) Math.sin(Y);
            z = size * (float) Math.sin(X);
            glVertex3f(x, y, z);
            Y += 0.1;

            thrird.setX(x);
            thrird.setY(y);
            thrird.setZ(z);

            first = thrird.crossProduct(first, second, thrird);
            glNormal3f(first.getX(), first.getY(), first.getZ());
          }
          Y = 0;
          X += 0.1;
        }
      }
      glEnd();
      glEnable(GL_CULL_FACE);
      glLineWidth(1);
    }
    glPopMatrix();
  }
Пример #24
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;
    }
  }
Пример #25
0
 private void renderMask() {
   glBegin(GL_QUADS);
   {
     // glColor3f(1.0f, 0.0f, 0.0f);
     for (int i = 0; i < maskFaces.size(); i++) {
       Vector3f n1 = maskNormals.get((int) (maskFaces.get(i).normal.x));
       glNormal3f(n1.x, n1.y, n1.z);
       Vector3f v1 = maskVerticies.get((int) (maskFaces.get(i).vertex.x));
       glVertex3f(v1.x, v1.y, v1.z);
       Vector3f n2 = maskNormals.get((int) (maskFaces.get(i).normal.y));
       glNormal3f(n2.x, n2.y, n2.z);
       Vector3f v2 = maskVerticies.get((int) (maskFaces.get(i).vertex.y));
       glVertex3f(v2.x, v2.y, v2.z);
       Vector3f n3 = maskNormals.get((int) (maskFaces.get(i).normal.z));
       glNormal3f(n3.x, n3.y, n3.z);
       Vector3f v3 = maskVerticies.get((int) (maskFaces.get(i).vertex.z));
       glVertex3f(v3.x, v3.y, v3.z);
       Vector3f n4 = maskNormals.get((int) (maskFaces.get(i).normal.w));
       glNormal3f(n4.x, n4.y, n4.z);
       Vector3f v4 = maskVerticies.get((int) (maskFaces.get(i).vertex.w));
       glVertex3f(v4.x, v4.y, v4.z);
     }
   }
   glEnd();
 }
Пример #26
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();
    }
  }
Пример #27
0
 @Override
 public void render() {
   getColor().apply();
   GL11.glBegin(GL11.GL_POINTS);
   GL11.glVertex2f(0f, 0f);
   GL11.glEnd();
 }
Пример #28
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();
  }
Пример #29
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;
   }
 }
Пример #30
0
 private void renderPoint() {
   glBegin(GL_POINTS);
   for (Particle p : particles) {
     glVertex2f(p.x, p.y);
   }
   glEnd();
 }