Exemplo n.º 1
0
  public void drawList(int mouseX, int mouseY, float tickTime) {
    if (!this.visible) {
      return;
    }
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    mc.renderEngine.bindTexture(texture);

    GuiUtils.drawContinuousTexturedBox(
        texture, this.x, this.y, 0, 0, width, height, 11, 11, 1, this.zLevel);
    // this.drawTexturedModalRect(x, y, 0, 0, width, height);

    ScaledResolution reso = new ScaledResolution(mc, mc.displayWidth, mc.displayHeight);

    double scaleWidth = (double) mc.displayWidth / reso.getScaledWidth_double();
    double scaleHeight = (double) mc.displayHeight / reso.getScaledHeight_double();

    GL11.glEnable(GL11.GL_SCISSOR_TEST);
    GL11.glScissor(
        (int) ((x + 1) * scaleWidth),
        (mc.displayHeight) - (int) ((y + height - 1) * scaleHeight),
        (int) ((width - 2) * scaleWidth),
        (int) ((height - 2) * scaleHeight));
    for (int i = 0; i < listItems.size(); i++) {
      int yLocation = y - scrollAmount + 2 + i * slotHeight;
      if (yLocation + 6 >= y & yLocation <= y + height + 1) {
        listItems
            .get(i)
            .drawListItem(
                fontRenderer, x + 2, yLocation, mouseX, mouseY, i == selectedIndex, width);
      }
    }
    GL11.glDisable(GL11.GL_SCISSOR_TEST);
  }
Exemplo n.º 2
0
 private void setupDisplay() {
   int width = Display.getWidth();
   int height = Display.getHeight();
   GL11.glMatrixMode(GL11.GL_PROJECTION);
   GL11.glLoadIdentity();
   GL11.glOrtho(0, Display.getWidth(), Display.getHeight(), 0, 1, -1);
   GL11.glMatrixMode(GL11.GL_MODELVIEW);
   GL11.glScissor(0, 0, width, height);
   GL11.glViewport(0, 0, width, height);
   renderHandler.init();
 }
Exemplo n.º 3
0
 public void setClipRect(int x, int y, int width, int height) {
   if (!context.clipRectEnabled) {
     glEnable(GL_SCISSOR_TEST);
     context.clipRectEnabled = true;
   }
   if (clipX != x || clipY != y || clipW != width || clipH != height) {
     glScissor(x, y, width, height);
     clipX = x;
     clipY = y;
     clipW = width;
     clipH = height;
   }
 }
Exemplo n.º 4
0
  /** R_SetupFrame */
  void R_SetupFrame() {
    r_framecount++;

    //	build the transformation matrix for the given view angles
    Math3D.VectorCopy(r_newrefdef.vieworg, r_origin);

    Math3D.AngleVectors(r_newrefdef.viewangles, vpn, vright, vup);

    //	current viewcluster
    mleaf_t leaf;
    if ((r_newrefdef.rdflags & Defines.RDF_NOWORLDMODEL) == 0) {
      r_oldviewcluster = r_viewcluster;
      r_oldviewcluster2 = r_viewcluster2;
      leaf = Mod_PointInLeaf(r_origin, r_worldmodel);
      r_viewcluster = r_viewcluster2 = leaf.cluster;

      // check above and below so crossing solid water doesn't draw wrong
      if (leaf.contents == 0) { // look down a bit
        Math3D.VectorCopy(r_origin, temp);
        temp[2] -= 16;
        leaf = Mod_PointInLeaf(temp, r_worldmodel);
        if ((leaf.contents & Defines.CONTENTS_SOLID) == 0 && (leaf.cluster != r_viewcluster2))
          r_viewcluster2 = leaf.cluster;
      } else { // look up a bit
        Math3D.VectorCopy(r_origin, temp);
        temp[2] += 16;
        leaf = Mod_PointInLeaf(temp, r_worldmodel);
        if ((leaf.contents & Defines.CONTENTS_SOLID) == 0 && (leaf.cluster != r_viewcluster2))
          r_viewcluster2 = leaf.cluster;
      }
    }

    for (int i = 0; i < 4; i++) v_blend[i] = r_newrefdef.blend[i];

    c_brush_polys = 0;
    c_alias_polys = 0;

    // clear out the portion of the screen that the NOWORLDMODEL defines
    if ((r_newrefdef.rdflags & Defines.RDF_NOWORLDMODEL) != 0) {
      GL11.glEnable(GL11.GL_SCISSOR_TEST);
      GL11.glClearColor(0.3f, 0.3f, 0.3f, 1.0f);
      GL11.glScissor(
          r_newrefdef.x,
          vid.height - r_newrefdef.height - r_newrefdef.y,
          r_newrefdef.width,
          r_newrefdef.height);
      GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);
      GL11.glClearColor(1.0f, 0.0f, 0.5f, 0.5f);
      GL11.glDisable(GL11.GL_SCISSOR_TEST);
    }
  }
Exemplo n.º 5
0
 public void setClipRect() {
   final Rect rect = clipRectTemp;
   if (clipStack.getClipRect(rect)) {
     GL11.glScissor(
         viewportX + rect.getX() * RenderScale.scale,
         viewportBottom - rect.getBottom() * RenderScale.scale,
         rect.getWidth() * RenderScale.scale,
         rect.getHeight() * RenderScale.scale);
     if (!hasScissor) {
       GL11.glEnable(GL11.GL_SCISSOR_TEST);
       hasScissor = true;
     }
   } else if (hasScissor) {
     GL11.glDisable(GL11.GL_SCISSOR_TEST);
     hasScissor = false;
   }
 }
    void bind() {
      EXTFramebufferObject.glBindFramebufferEXT(
          EXTFramebufferObject.GL_FRAMEBUFFER_EXT, frameBuffer);

      GL11.glPushAttrib(glAttributes);
      GL11.glViewport(x0, y0, width, height);
      GL11.glEnable(GL11.GL_SCISSOR_TEST);
      GL11.glScissor(x0, y0, width, height);

      lightmapEnabled = false;
      if (gl13Supported) {
        GL13.glActiveTexture(GL13.GL_TEXTURE1);
        lightmapEnabled = GL11.glIsEnabled(GL11.GL_TEXTURE_2D);
        if (lightmapEnabled) {
          GL11.glDisable(GL11.GL_TEXTURE_2D);
        }
        GL13.glActiveTexture(GL13.GL_TEXTURE0);
      }
      GL11.glEnable(GL11.GL_TEXTURE_2D);
      GL11.glDisable(GL11.GL_DEPTH_TEST);
      GLAPI.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
      GL11.glDisable(GL11.GL_LIGHTING);
      GL11.glEnable(GL11.GL_ALPHA_TEST);
      GLAPI.glAlphaFunc(GL11.GL_GREATER, 0.01f);
      if (useGL13) {
        GL11.glDisable(GL13.GL_MULTISAMPLE);
      }

      GLAPI.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
      GL11.glClear(GL11.GL_COLOR_BUFFER_BIT);

      GL11.glMatrixMode(GL11.GL_PROJECTION);
      GL11.glPushMatrix();
      GL11.glLoadIdentity();
      GL11.glOrtho(-1.0f, 1.0f, -1.0f, 1.0f, -1.0f, 1.0f);

      GL11.glMatrixMode(GL11.GL_MODELVIEW);
      GL11.glPushMatrix();
      GL11.glLoadIdentity();
    }
Exemplo n.º 7
0
  public final void draw(int mouseX, int mouseY) {
    if (newScrollIfInside >= 0 && Guis.isPointInRegion(x, y, width, height, mouseX, mouseY)) {
      scrollbarY = newScrollIfInside;
      newScrollIfInside = -1;
    }

    float yTranslate = computeYTranslate();
    mouseX -= x;
    mouseY -= yTranslate;

    glColor3f(1, 1, 1);
    int scale = Guis.computeGuiScale();

    if (clip) {
      glScissor(0, mc.displayHeight - (y + height) * scale, (width + x) * scale, height * scale);
      glEnable(GL_SCISSOR_TEST);
    }

    glPushMatrix();

    glTranslatef(x, yTranslate, 0);

    drawInternal(mouseX, mouseY);

    glPopMatrix();

    if (clip) {
      glDisable(GL_SCISSOR_TEST);
    }

    if (needsScrollbar()) {
      int scrollbarX = x + (width - scrollbarWidth);
      drawScrollbar(
          scrollbarX,
          y + scrollbarY,
          scrollbarX + scrollbarWidth,
          y + scrollbarY + scrollbarHeight);
    }
  }
Exemplo n.º 8
0
  public static void applyScissors(final RendererRecord rendRecord) {
    final Stack<Rectangle2> clips = rendRecord.getScissorClips();

    if (clips.size() > 0) {
      final Rectangle2 init = Rectangle2.fetchTempInstance();
      init.set(-1, -1, -1, -1);
      Rectangle2 r;
      boolean first = true;
      for (int i = clips.size(); --i >= 0; ) {
        r = clips.get(i);

        if (r == null) {
          break;
        }
        if (first) {
          init.set(r);
          first = false;
        } else {
          init.intersect(r, init);
        }
        if (init.getWidth() <= 0 || init.getHeight() <= 0) {
          init.setWidth(0);
          init.setHeight(0);
          break;
        }
      }

      if (init.getWidth() == -1) {
        setClippingEnabled(rendRecord, false);
      } else {
        setClippingEnabled(rendRecord, true);
        GL11.glScissor(init.getX(), init.getY(), init.getWidth(), init.getHeight());
      }
      Rectangle2.releaseTempInstance(init);
    } else {
      // no clips, so disable
      setClippingEnabled(rendRecord, false);
    }
  }
Exemplo n.º 9
0
 public void glScissor(int x, int y, int width, int height) {
   GL11.glScissor(x, y, width, height);
 }
Exemplo n.º 10
0
 public static void clipRect(int x, int y, int w, int h) {
   glScissor(x, Runtime.screen_height - y - h, w, h);
 }
Exemplo n.º 11
0
  @Override
  public void drawScreen(int mouseX, int mouseY, float par3) {
    if (DEBUG_RENDERING) {
      renderTimes[renderTimesIndex++] = System.currentTimeMillis();
      if (renderTimesIndex == renderTimes.length) {
        renderTimesIndex = 0;
        double elapsed = 0;
        for (int i = 0; i < renderTimes.length - 1; i++) {
          elapsed += renderTimes[i + 1] - renderTimes[i];
        }
        System.out.printf("GuiAtlas avg. render time: %.3f\n", elapsed / renderTimes.length);
      }
    }

    GL11.glColor4f(1, 1, 1, 1);
    GL11.glAlphaFunc(GL11.GL_GREATER, 0); // So light detail on tiles is visible
    AtlasRenderHelper.drawFullTexture(Textures.BOOK, getGuiX(), getGuiY(), WIDTH, HEIGHT);

    if (stack == null || biomeData == null) return;

    if (state.is(DELETING_MARKER)) {
      GL11.glColor4f(1, 1, 1, 0.5f);
    }
    GL11.glEnable(GL11.GL_SCISSOR_TEST);
    GL11.glScissor(
        (getGuiX() + CONTENT_X) * screenScale,
        mc.displayHeight - (getGuiY() + CONTENT_Y + MAP_HEIGHT) * screenScale,
        MAP_WIDTH * screenScale,
        MAP_HEIGHT * screenScale);
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    // Find chunk coordinates of the top left corner of the map.
    // The 'roundToBase' is required so that when the map scales below the
    // threshold the tiles don't change when map position changes slightly.
    // The +-2 at the end provide margin so that tiles at the edges of
    // the page have their stitched texture correct.
    int mapStartX =
        MathUtil.roundToBase(
            (int)
                Math.floor(
                    -((double) MAP_WIDTH / 2d + mapOffsetX + 2 * tileHalfSize) / mapScale / 16d),
            tile2ChunkScale);
    int mapStartZ =
        MathUtil.roundToBase(
            (int)
                Math.floor(
                    -((double) MAP_HEIGHT / 2d + mapOffsetY + 2 * tileHalfSize) / mapScale / 16d),
            tile2ChunkScale);
    int mapEndX =
        MathUtil.roundToBase(
            (int)
                Math.ceil(
                    ((double) MAP_WIDTH / 2d - mapOffsetX + 2 * tileHalfSize) / mapScale / 16d),
            tile2ChunkScale);
    int mapEndZ =
        MathUtil.roundToBase(
            (int)
                Math.ceil(
                    ((double) MAP_HEIGHT / 2d - mapOffsetY + 2 * tileHalfSize) / mapScale / 16d),
            tile2ChunkScale);
    int mapStartScreenX = getGuiX() + WIDTH / 2 + (int) ((mapStartX << 4) * mapScale) + mapOffsetX;
    int mapStartScreenY = getGuiY() + HEIGHT / 2 + (int) ((mapStartZ << 4) * mapScale) + mapOffsetY;

    TileRenderIterator iter = new TileRenderIterator(biomeData);
    iter.setScope(
        new Rect().setOrigin(mapStartX, mapStartZ).set(mapStartX, mapStartZ, mapEndX, mapEndZ));
    iter.setStep(tile2ChunkScale);
    while (iter.hasNext()) {
      SubTileQuartet subtiles = iter.next();
      for (SubTile subtile : subtiles) {
        if (subtile == null || subtile.tile == null) continue;
        AtlasRenderHelper.drawAutotileCorner(
            BiomeTextureMap.instance().getTexture(subtile.tile),
            mapStartScreenX + subtile.x * tileHalfSize,
            mapStartScreenY + subtile.y * tileHalfSize,
            subtile.getTextureU(),
            subtile.getTextureV(),
            tileHalfSize);
      }
    }

    if (!state.is(HIDING_MARKERS)) {
      int markersStartX =
          MathUtil.roundToBase(mapStartX, MarkersData.CHUNK_STEP) / MarkersData.CHUNK_STEP - 1;
      int markersStartZ =
          MathUtil.roundToBase(mapStartZ, MarkersData.CHUNK_STEP) / MarkersData.CHUNK_STEP - 1;
      int markersEndX =
          MathUtil.roundToBase(mapEndX, MarkersData.CHUNK_STEP) / MarkersData.CHUNK_STEP + 1;
      int markersEndZ =
          MathUtil.roundToBase(mapEndZ, MarkersData.CHUNK_STEP) / MarkersData.CHUNK_STEP + 1;
      double iconScale = getIconScale();

      // Draw global markers:
      for (int x = markersStartX; x <= markersEndX; x++) {
        for (int z = markersStartZ; z <= markersEndZ; z++) {
          List<Marker> markers = globalMarkersData.getMarkersAtChunk(x, z);
          if (markers == null) continue;
          for (Marker marker : markers) {
            renderMarker(marker, iconScale);
          }
        }
      }

      // Draw local markers:
      if (localMarkersData != null) {
        for (int x = markersStartX; x <= markersEndX; x++) {
          for (int z = markersStartZ; z <= markersEndZ; z++) {
            List<Marker> markers = localMarkersData.getMarkersAtChunk(x, z);
            if (markers == null) continue;
            for (Marker marker : markers) {
              renderMarker(marker, iconScale);
            }
          }
        }
      }
    }

    GL11.glDisable(GL11.GL_SCISSOR_TEST);

    // Overlay the frame so that edges of the map are smooth:
    GL11.glColor4f(1, 1, 1, 1);
    AtlasRenderHelper.drawFullTexture(Textures.BOOK_FRAME, getGuiX(), getGuiY(), WIDTH, HEIGHT);
    double iconScale = getIconScale();

    // Draw player icon:
    if (!state.is(HIDING_MARKERS)) {
      // How much the player has moved from the top left corner of the map, in pixels:
      int playerOffsetX = (int) (player.posX * mapScale) + mapOffsetX;
      int playerOffsetZ = (int) (player.posZ * mapScale) + mapOffsetY;
      if (playerOffsetX < -MAP_WIDTH / 2) playerOffsetX = -MAP_WIDTH / 2;
      if (playerOffsetX > MAP_WIDTH / 2) playerOffsetX = MAP_WIDTH / 2;
      if (playerOffsetZ < -MAP_HEIGHT / 2) playerOffsetZ = -MAP_HEIGHT / 2;
      if (playerOffsetZ > MAP_HEIGHT / 2 - 2) playerOffsetZ = MAP_HEIGHT / 2 - 2;
      // Draw the icon:
      GL11.glColor4f(1, 1, 1, state.is(PLACING_MARKER) ? 0.5f : 1);
      GL11.glPushMatrix();
      GL11.glTranslated(
          getGuiX() + WIDTH / 2 + playerOffsetX, getGuiY() + HEIGHT / 2 + playerOffsetZ, 0);
      float playerRotation =
          (float) Math.round(player.rotationYaw / 360f * PLAYER_ROTATION_STEPS)
              / PLAYER_ROTATION_STEPS
              * 360f;
      GL11.glRotatef(180 + playerRotation, 0, 0, 1);
      GL11.glTranslated(-PLAYER_ICON_WIDTH / 2 * iconScale, -PLAYER_ICON_HEIGHT / 2 * iconScale, 0);
      AtlasRenderHelper.drawFullTexture(
          Textures.PLAYER,
          0,
          0,
          (int) Math.round(PLAYER_ICON_WIDTH * iconScale),
          (int) Math.round(PLAYER_ICON_HEIGHT * iconScale));
      GL11.glPopMatrix();
      GL11.glColor4f(1, 1, 1, 1);
    }

    // Draw buttons:
    super.drawScreen(mouseX, mouseY, par3);

    // Draw the semi-transparent marker attached to the cursor when placing a new marker:
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    if (state.is(PLACING_MARKER)) {
      GL11.glColor4f(1, 1, 1, 0.5f);
      AtlasRenderHelper.drawFullTexture(
          MarkerTextureMap.instance().getTexture(markerFinalizer.selectedType),
          mouseX - MARKER_SIZE / 2 * iconScale,
          mouseY - MARKER_SIZE / 2 * iconScale,
          (int) Math.round(MARKER_SIZE * iconScale),
          (int) Math.round(MARKER_SIZE * iconScale));
      GL11.glColor4f(1, 1, 1, 1);
    }

    // Draw progress overlay:
    if (state.is(EXPORTING_IMAGE)) {
      drawDefaultBackground();
      progressBar.draw((width - 100) / 2, height / 2 - 34);
    }
  }