@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();
    }
  }
Ejemplo n.º 2
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);
  }
Ejemplo n.º 3
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.º 4
0
 @Override
 public void onRenderGUI() {
   if (target == null || velocity < 0.1) return;
   glEnable(GL_BLEND);
   glDisable(GL_CULL_FACE);
   glDisable(GL_TEXTURE_2D);
   glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
   RenderUtil.setColor(new Color(8, 8, 8, 128));
   ScaledResolution sr =
       new ScaledResolution(
           Minecraft.getMinecraft(),
           Minecraft.getMinecraft().displayWidth,
           Minecraft.getMinecraft().displayHeight);
   int width = sr.getScaledWidth();
   int height = sr.getScaledHeight();
   String targetLocked = "Target locked";
   glBegin(GL_QUADS);
   {
     glVertex2d(width / 2 + 1, height / 2 + 1);
     glVertex2d(
         width / 2
             + ((WurstTheme) WurstClient.INSTANCE.gui.getTheme())
                 .getFontRenderer()
                 .getStringWidth(targetLocked)
             + 4,
         height / 2 + 1);
     glVertex2d(
         width / 2
             + ((WurstTheme) WurstClient.INSTANCE.gui.getTheme())
                 .getFontRenderer()
                 .getStringWidth(targetLocked)
             + 4,
         height / 2
             + ((WurstTheme) WurstClient.INSTANCE.gui.getTheme()).getFontRenderer().FONT_HEIGHT);
     glVertex2d(
         width / 2 + 1,
         height / 2
             + ((WurstTheme) WurstClient.INSTANCE.gui.getTheme()).getFontRenderer().FONT_HEIGHT);
   }
   glEnd();
   glEnable(GL_TEXTURE_2D);
   ((WurstTheme) WurstClient.INSTANCE.gui.getTheme())
       .getFontRenderer()
       .drawStringWithShadow(
           targetLocked, width / 2 + 2, height / 2, RenderUtil.toRGBA(Color.WHITE));
   glEnable(GL_CULL_FACE);
   glDisable(GL_BLEND);
 }
Ejemplo n.º 5
0
  public void draw() {

    tex.bind();

    GL11.glBegin(GL11.GL_QUADS);
    GL11.glTexCoord2d(0, 0);
    GL11.glVertex2d(xPos, yPos + 0);

    GL11.glTexCoord2d(tex.getWidth(), 0);
    GL11.glVertex2d(xPos + WIDTH, yPos + 0);

    GL11.glTexCoord2d(tex.getWidth(), tex.getHeight());
    GL11.glVertex2d(xPos + WIDTH, yPos + HEIGHT);

    GL11.glTexCoord2d(0, tex.getHeight());
    GL11.glVertex2d(xPos, yPos + HEIGHT);
    GL11.glEnd();
  }
Ejemplo n.º 6
0
  // TODO: considering this is all really GL code perhaps we could instead call a 'visualize'
  // function in a drawer and pass it the fft.
  public void visualizer() {
    glEnable(GL_BLEND);
    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
    glColor4d(1, 1, 1, .2);
    glPolygonMode(GL_FRONT, GL_FILL);
    int w = (int) getFftLog().specSize() / bands;
    int q = Constants.VIEW_HEIGHT;

    for (int i = 0; i < getFftLog().avgSize(); i++) {
      glBegin(GL_POLYGON);
      glVertex2d(i * w, q);
      glVertex2d(i * w + w, q);
      glVertex2d(i * w + w, q - (getFftLog().getAvg(i) * 1));
      glVertex2d(i * w, q - (getFftLog().getAvg(i) * 1));
      glEnd();
    }

    glDisable(GL_BLEND);
  }
Ejemplo n.º 7
0
  public void draw() {
    // this function draws the target on the screem
    GL11.glColor3f(0.0f, 0.0f, 0.0f);
    glPushMatrix();

    // translate to the right location and prepare to draw
    glTranslatef(x, y, 0);

    glBegin(GL11.GL_QUADS);
    {
      GL11.glVertex2d(-size, -size);
      GL11.glVertex2d(-size, size);
      GL11.glVertex2d(size, size);
      GL11.glVertex2d(size, -size);
    }
    glEnd();

    // restore the model view matrix to prevent contamination
    glPopMatrix();
  }
Ejemplo n.º 8
0
  public static void drawShape(Shape shape, Color color) {
    glDisable(GL_TEXTURE_2D);

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

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

    glBegin(GL_LINE_LOOP);
    {
      for (Point p : shape.getPoints()) glVertex2d(p.x, p.y);
    }
    glEnd();

    glColor4f(1, 1, 1, 1);

    glDisable(GL_BLEND);
    glEnable(GL_TEXTURE_2D);
  }
Ejemplo n.º 9
0
  @Override
  protected void renderComponent(Slider component) {
    translateComponent(component, false);

    // GL settings
    glEnable(GL_BLEND);
    glDisable(GL_CULL_FACE);

    // area & font
    Rectangle area = component.getArea();
    int fontSize = theme.getFontRenderer().FONT_HEIGHT;
    FontRenderer fontRenderer = theme.getFontRenderer();

    // text
    fontRenderer.drawString(
        component.getText(), 0, 0, RenderUtil.toRGBA(component.getForegroundColor()));

    // value
    String content = null;
    switch (component.getValueDisplay()) {
      case DECIMAL:
        content =
            Double.toString(
                (double)
                        (Math.round(component.getValue() / component.getIncrement())
                            * 1000000
                            * (long) (component.getIncrement() * 1000000))
                    / 1000000
                    / 1000000);
        break;
      case INTEGER:
        content = String.format("%,d", Long.valueOf(Math.round(component.getValue())));
        break;
      case PERCENTAGE:
        int percent =
            (int)
                Math.round(
                    (component.getValue() - component.getMinimumValue())
                        / (component.getMaximumValue() - component.getMinimumValue())
                        * 100D);
        content = String.format("%d%%", percent);
      default:
    }
    if (content != null) {
      String suffix = component.getContentSuffix();
      if (suffix != null && !suffix.trim().isEmpty()) content = content.concat(" ").concat(suffix);
      fontRenderer.drawString(
          content,
          component.getWidth() - fontRenderer.getStringWidth(content),
          0,
          RenderUtil.toRGBA(component.getForegroundColor()));
    }
    glDisable(GL_TEXTURE_2D);

    // line
    glColor4f(0.03125f, 0.03125f, 0.03125f, 0.25f);
    glBegin(GL_QUADS);
    {
      glVertex2d(1, fontSize + 4);
      glVertex2d(area.width - 1, fontSize + 4);
      glVertex2d(area.width - 1, area.height - 2);
      glVertex2d(1, area.height - 2);
    }
    glEnd();

    // line shadow
    glLineWidth(1.0f);
    glColor4f(0.125f, 0.125f, 0.125f, 0.5f);
    glBegin(GL_LINE_LOOP);
    {
      glVertex2d(1, fontSize + 4);
      glVertex2d(area.width - 1, fontSize + 4);
      glVertex2d(area.width - 1, area.height - 2);
      glVertex2d(1, area.height - 2);
    }
    glEnd();

    double sliderPercentage =
        (component.getValue() - component.getMinimumValue())
            / (component.getMaximumValue() - component.getMinimumValue());

    // slider
    glColor4f(0.0f + (float) sliderPercentage, 1.0f - (float) sliderPercentage, 0.0f, 0.5f);
    glBegin(GL_QUADS);
    {
      glVertex2d((area.width - 6) * sliderPercentage - 1, fontSize + 1);
      glVertex2d((area.width - 6) * sliderPercentage + 7, fontSize + 1);
      glVertex2d((area.width - 6) * sliderPercentage + 7, area.height + 1);
      glVertex2d((area.width - 6) * sliderPercentage - 1, area.height + 1);
    }
    glEnd();

    // slider shadow
    RenderUtil.boxShadow(
        (area.width - 6) * sliderPercentage - 1,
        fontSize + 1,
        (area.width - 6) * sliderPercentage + 7,
        area.height + 1);

    // GL resets
    glEnable(GL_CULL_FACE);
    glEnable(GL_TEXTURE_2D);
    glDisable(GL_BLEND);

    translateComponent(component, true);
  }
Ejemplo n.º 10
0
  public static void main(String[] args) {
    Window window = new Window(1280, 720, "Test", false);
    double rotAngle = 0;
    double X = 0;
    Cube cube = new Cube(0, 0, 0, 1);
    Logger log = Logger.getInstance();
    Axis axis = new Axis(0, 10, 0, 50);

    window.drawOn3D();
    // Cullface
    glCullFace(GL_BACK);
    glEnable(GL_CULL_FACE);

    // depth
    glEnable(GL_DEPTH_TEST);

    //
    glClearDepth(1.0f);
    glDepthFunc(GL_LEQUAL);
    //
    glEnable(GL_LIGHT0);
    glEnable(GL_LIGHTING);

    while (!window.isCloseRequested()) {
      window.drawOn3D();
      // Clear the contents of the window (try disabling this and resizing the window � fun
      // guaranteed)
      glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

      // Polls the user input. This is very important, because it prevents your application from
      // becoming unresponsive
      glfwPollEvents();

      rotAngle = (glfwGetKey(window.getWindowID(), GLFW_KEY_RIGHT) == 1) ? rotAngle + 5 : rotAngle;
      rotAngle = (glfwGetKey(window.getWindowID(), GLFW_KEY_LEFT) == 1) ? rotAngle - 5 : rotAngle;

      X = (glfwGetKey(window.getWindowID(), GLFW_KEY_UP) == 1) ? X + .5 : X;
      X = (glfwGetKey(window.getWindowID(), GLFW_KEY_DOWN) == 1) ? X - .5 : X;

      log.debug("" + X);

      glPushMatrix();
      glTranslated(0, 0, -40 + X);
      //			glRotated(rotAngle, 0, 1, 0);

      axis.draw();
      glColor3d(0, 1, 1);
      glRotated(rotAngle, 0, 1, 0);
      cube.draw();
      glPopMatrix();

      window.drawOn2D();
      glPushMatrix();
      glColor3d(1, 1, 1);

      glBegin(GL_QUADS);
      glVertex2d(0, 0);
      glVertex2d(0, 100);
      glVertex2d(200, 100);
      glVertex2d(200, 0);
      glEnd();

      glPopMatrix();

      // Swaps the front and back framebuffers, this is a very technical process which you don't
      // necessarily
      // need to understand. You can simply see this method as updating the window contents.
      glfwSwapBuffers(window.getWindowID());
    }

    window.destroyWindow();
  }
Ejemplo n.º 11
0
  public void render() {
    if (isAlive()) {

      // body
      Sprites.tubsBodyAnim.get(frame).bind();
      GL11.glPushMatrix();
      // GL11.glDisable(GL11.GL_TEXTURE_2D);
      GL11.glTranslated((x + bodyw / 2), (y + bodyh / 2), 0);
      GL11.glRotated(Math.toDegrees(angle), 0, 0, 1);
      GL11.glTranslated(-(x + bodyw / 2), -(y + bodyh / 2), 0);
      GL11.glBegin(GL11.GL_QUADS);
      GL11.glTexCoord2d(0, 0);
      GL11.glVertex2d(x, y);
      GL11.glTexCoord2d(1, 0);
      GL11.glVertex2d(x + bodyw, y);
      GL11.glTexCoord2d(1, 1);
      GL11.glVertex2d(x + bodyw, y + bodyh);
      GL11.glTexCoord2d(0, 1);
      GL11.glVertex2d(x, y + bodyh);
      GL11.glEnd();

      GL11.glDisable(GL11.GL_TEXTURE_2D);
      if (isHurt()) {
        GL11.glColor3d(0, 0, 0);
        GL11.glBegin(GL11.GL_QUADS);
        GL11.glVertex2d(x, y - 3);
        GL11.glVertex2d(x - 1 + w, y - 3);
        GL11.glVertex2d(x + w, y - 3 - 3);
        GL11.glVertex2d(x - 1, y - 3 - 3);
        GL11.glEnd();
        GL11.glColor3d(0, 1, 0);
        GL11.glBegin(GL11.GL_QUADS);
        GL11.glVertex2d(x, y - 3);
        GL11.glVertex2d(x - 1 + (health * w / maxHealth) + 2, y - 3);
        GL11.glVertex2d(x + (health * w / maxHealth) + 2, y - 3 - 3);
        GL11.glVertex2d(x - 1, y - 3 - 3);
        GL11.glEnd();
      }
      GL11.glEnable(GL11.GL_TEXTURE_2D);
      GL11.glColor3d(1, 1, 1);
      GL11.glPopMatrix();
    }
  }