예제 #1
0
  public static void updateRenderInfo(EntityPlayer par0EntityPlayer, boolean par1) {
    GL11.glGetFloat(GL11.GL_MODELVIEW_MATRIX, modelview);
    GL11.glGetFloat(GL11.GL_PROJECTION_MATRIX, projection);

    // Spout start
    modelMatrix = modelview.duplicate();
    projectionMatrix = projection.duplicate();
    // Spout end

    GL11.glGetInteger(GL11.GL_VIEWPORT, viewport);
    float var2 = (float) ((viewport.get(0) + viewport.get(2)) / 2);
    float var3 = (float) ((viewport.get(1) + viewport.get(3)) / 2);
    GLU.gluUnProject(var2, var3, 0.0F, modelview, projection, viewport, objectCoords);
    objectX = objectCoords.get(0);
    objectY = objectCoords.get(1);
    objectZ = objectCoords.get(2);
    int var4 = par1 ? 1 : 0;
    float var5 = par0EntityPlayer.rotationPitch;
    float var6 = par0EntityPlayer.rotationYaw;
    rotationX = MathHelper.cos(var6 * (float) Math.PI / 180.0F) * (float) (1 - var4 * 2);
    rotationZ = MathHelper.sin(var6 * (float) Math.PI / 180.0F) * (float) (1 - var4 * 2);
    rotationYZ =
        -rotationZ * MathHelper.sin(var5 * (float) Math.PI / 180.0F) * (float) (1 - var4 * 2);
    rotationXY =
        rotationX * MathHelper.sin(var5 * (float) Math.PI / 180.0F) * (float) (1 - var4 * 2);
    rotationXZ = MathHelper.cos(var5 * (float) Math.PI / 180.0F);
  }
예제 #2
0
  // 6231529
  private static void callReset(FloatBuffer b) {
    b.position(0);
    b.mark();

    b.duplicate().reset();
    b.asReadOnlyBuffer().reset();
  }
예제 #3
0
  public static void test(int level, final FloatBuffer b, boolean direct) {

    show(level, b);

    if (direct != b.isDirect()) fail("Wrong direction", b);

    // Gets and puts

    relPut(b);
    relGet(b);
    absGet(b);
    bulkGet(b);

    absPut(b);
    relGet(b);
    absGet(b);
    bulkGet(b);

    bulkPutArray(b);
    relGet(b);

    bulkPutBuffer(b);
    relGet(b);

    // Compact

    relPut(b);
    b.position(13);
    b.compact();
    b.flip();
    relGet(b, 13);

    // Exceptions

    relPut(b);
    b.limit(b.capacity() / 2);
    b.position(b.limit());

    tryCatch(
        b,
        BufferUnderflowException.class,
        new Runnable() {
          public void run() {
            b.get();
          }
        });

    tryCatch(
        b,
        BufferOverflowException.class,
        new Runnable() {
          public void run() {
            b.put((float) 42);
          }
        });

    // The index must be non-negative and lesss than the buffer's limit.
    tryCatch(
        b,
        IndexOutOfBoundsException.class,
        new Runnable() {
          public void run() {
            b.get(b.limit());
          }
        });
    tryCatch(
        b,
        IndexOutOfBoundsException.class,
        new Runnable() {
          public void run() {
            b.get(-1);
          }
        });

    tryCatch(
        b,
        IndexOutOfBoundsException.class,
        new Runnable() {
          public void run() {
            b.put(b.limit(), (float) 42);
          }
        });

    tryCatch(
        b,
        InvalidMarkException.class,
        new Runnable() {
          public void run() {
            b.position(0);
            b.mark();
            b.compact();
            b.reset();
          }
        });

    // Values

    b.clear();
    b.put((float) 0);
    b.put((float) -1);
    b.put((float) 1);
    b.put(Float.MAX_VALUE);
    b.put(Float.MIN_VALUE);

    b.put(-Float.MAX_VALUE);
    b.put(-Float.MIN_VALUE);
    b.put(Float.NEGATIVE_INFINITY);
    b.put(Float.POSITIVE_INFINITY);
    b.put(Float.NaN);
    b.put(0.91697687f); // Changes value if incorrectly swapped

    float v;
    b.flip();
    ck(b, b.get(), 0);
    ck(b, b.get(), (float) -1);
    ck(b, b.get(), 1);
    ck(b, b.get(), Float.MAX_VALUE);
    ck(b, b.get(), Float.MIN_VALUE);

    ck(b, b.get(), -Float.MAX_VALUE);
    ck(b, b.get(), -Float.MIN_VALUE);
    ck(b, b.get(), Float.NEGATIVE_INFINITY);
    ck(b, b.get(), Float.POSITIVE_INFINITY);
    if (Float.floatToRawIntBits(v = b.get()) != Float.floatToRawIntBits(Float.NaN))
      fail(b, (long) Float.NaN, (long) v);
    ck(b, b.get(), 0.91697687f);

    // Comparison
    b.rewind();
    FloatBuffer b2 = FloatBuffer.allocate(b.capacity());
    b2.put(b);
    b2.flip();
    b.position(2);
    b2.position(2);
    if (!b.equals(b2)) {
      for (int i = 2; i < b.limit(); i++) {
        float x = b.get(i);
        float y = b2.get(i);
        if (x != y || Float.compare(x, y) != 0) out.println("[" + i + "] " + x + " != " + y);
      }
      fail("Identical buffers not equal", b, b2);
    }
    if (b.compareTo(b2) != 0) fail("Comparison to identical buffer != 0", b, b2);

    b.limit(b.limit() + 1);
    b.position(b.limit() - 1);
    b.put((float) 99);
    b.rewind();
    b2.rewind();
    if (b.equals(b2)) fail("Non-identical buffers equal", b, b2);
    if (b.compareTo(b2) <= 0) fail("Comparison to shorter buffer <= 0", b, b2);
    b.limit(b.limit() - 1);

    b.put(2, (float) 42);
    if (b.equals(b2)) fail("Non-identical buffers equal", b, b2);
    if (b.compareTo(b2) <= 0) fail("Comparison to lesser buffer <= 0", b, b2);

    // Check equals and compareTo with interesting values
    for (float x : VALUES) {
      FloatBuffer xb = FloatBuffer.wrap(new float[] {x});
      if (xb.compareTo(xb) != 0) {
        fail("compareTo not reflexive", xb, xb, x, x);
      }
      if (!xb.equals(xb)) {
        fail("equals not reflexive", xb, xb, x, x);
      }
      for (float y : VALUES) {
        FloatBuffer yb = FloatBuffer.wrap(new float[] {y});
        if (xb.compareTo(yb) != -yb.compareTo(xb)) {
          fail("compareTo not anti-symmetric", xb, yb, x, y);
        }
        if ((xb.compareTo(yb) == 0) != xb.equals(yb)) {
          fail("compareTo inconsistent with equals", xb, yb, x, y);
        }
        if (xb.compareTo(yb) != Float.compare(x, y)) {

          if (x == 0.0 && y == 0.0) continue;

          fail("Incorrect results for FloatBuffer.compareTo", xb, yb, x, y);
        }
        if (xb.equals(yb) != ((x == y) || ((x != x) && (y != y)))) {
          fail("Incorrect results for FloatBuffer.equals", xb, yb, x, y);
        }
      }
    }

    // Sub, dup

    relPut(b);
    relGet(b.duplicate());
    b.position(13);
    relGet(b.duplicate(), 13);
    relGet(b.duplicate().slice(), 13);
    relGet(b.slice(), 13);
    relGet(b.slice().duplicate(), 13);

    // Slice

    b.position(5);
    FloatBuffer sb = b.slice();
    checkSlice(b, sb);
    b.position(0);
    FloatBuffer sb2 = sb.slice();
    checkSlice(sb, sb2);

    if (!sb.equals(sb2)) fail("Sliced slices do not match", sb, sb2);
    if ((sb.hasArray()) && (sb.arrayOffset() != sb2.arrayOffset()))
      fail("Array offsets do not match: " + sb.arrayOffset() + " != " + sb2.arrayOffset(), sb, sb2);

    // Read-only views

    b.rewind();
    final FloatBuffer rb = b.asReadOnlyBuffer();
    if (!b.equals(rb)) fail("Buffer not equal to read-only view", b, rb);
    show(level + 1, rb);

    tryCatch(
        b,
        ReadOnlyBufferException.class,
        new Runnable() {
          public void run() {
            relPut(rb);
          }
        });

    tryCatch(
        b,
        ReadOnlyBufferException.class,
        new Runnable() {
          public void run() {
            absPut(rb);
          }
        });

    tryCatch(
        b,
        ReadOnlyBufferException.class,
        new Runnable() {
          public void run() {
            bulkPutArray(rb);
          }
        });

    tryCatch(
        b,
        ReadOnlyBufferException.class,
        new Runnable() {
          public void run() {
            bulkPutBuffer(rb);
          }
        });

    // put(FloatBuffer) should not change source position
    final FloatBuffer src = FloatBuffer.allocate(1);
    tryCatch(
        b,
        ReadOnlyBufferException.class,
        new Runnable() {
          public void run() {
            rb.put(src);
          }
        });
    ck(src, src.position(), 0);

    tryCatch(
        b,
        ReadOnlyBufferException.class,
        new Runnable() {
          public void run() {
            rb.compact();
          }
        });

    if (rb.getClass().getName().startsWith("java.nio.Heap")) {

      tryCatch(
          b,
          ReadOnlyBufferException.class,
          new Runnable() {
            public void run() {
              rb.array();
            }
          });

      tryCatch(
          b,
          ReadOnlyBufferException.class,
          new Runnable() {
            public void run() {
              rb.arrayOffset();
            }
          });

      if (rb.hasArray()) fail("Read-only heap buffer's backing array is accessible", rb);
    }

    // Bulk puts from read-only buffers

    b.clear();
    rb.rewind();
    b.put(rb);

    relPut(b); // Required by testViews
  }