示例#1
0
  @Test
  public final void testIdentities() {
    final JCGLContextType c = this.newGL33Context("main", 24, 8);
    final JCGLInterfaceGL33Type g = c.contextGetGL33();
    final JCGLTextureUnitAllocatorType a =
        JCGLTextureUnitAllocator.newAllocatorWithStack(4, g.getTextures().textureGetUnits());

    final AreaInclusiveUnsignedL area =
        AreaInclusiveUnsignedL.of(
            new UnsignedRangeInclusiveL(0L, 639L), new UnsignedRangeInclusiveL(0L, 479L));
    final R2ImageBufferDescription desc = R2ImageBufferDescription.of(area, Optional.empty());

    final R2ImageBufferType gb =
        R2ImageBuffer.newImageBuffer(
            g.getFramebuffers(), g.getTextures(), a.getRootContext(), desc);

    Assert.assertEquals(640L * 480L * 4L, gb.getRange().getInterval());
    Assert.assertFalse(gb.isDeleted());

    final R2Texture2DUsableType t_rgba = gb.getRGBATexture();
    final JCGLFramebufferUsableType fb = gb.getPrimaryFramebuffer();

    Assert.assertEquals(desc, gb.getDescription());
    Assert.assertEquals(area, gb.getArea());

    Assert.assertEquals(
        JCGLTextureFormat.TEXTURE_FORMAT_RGBA_8_4BPP, t_rgba.get().textureGetFormat());

    gb.delete(g);
    Assert.assertTrue(fb.isDeleted());
    Assert.assertTrue(gb.isDeleted());
  }
示例#2
0
  @Test
  public final void testIdentitiesWithDepth() {
    final JCGLContextType c = this.newGL33Context("main", 24, 8);
    final JCGLInterfaceGL33Type g = c.contextGetGL33();
    final JCGLTextureUnitAllocatorType a =
        JCGLTextureUnitAllocator.newAllocatorWithStack(4, g.getTextures().textureGetUnits());

    for (final R2DepthPrecision dp : R2DepthPrecision.values()) {
      final AreaInclusiveUnsignedL area =
          AreaInclusiveUnsignedL.of(
              new UnsignedRangeInclusiveL(0L, 639L), new UnsignedRangeInclusiveL(0L, 479L));
      final R2ImageBufferDescription desc = R2ImageBufferDescription.of(area, Optional.of(dp));

      final R2ImageBufferType gb =
          R2ImageBuffer.newImageBuffer(
              g.getFramebuffers(), g.getTextures(), a.getRootContext(), desc);

      long pixel_size = 4L;
      switch (dp) {
        case R2_DEPTH_PRECISION_16:
          pixel_size += 2L;
          break;
        case R2_DEPTH_PRECISION_24:
          pixel_size += 4L;
          break;
        case R2_DEPTH_PRECISION_32F:
          pixel_size += 4L;
          break;
      }

      Assert.assertEquals(640L * 480L * pixel_size, gb.getRange().getInterval());
      Assert.assertFalse(gb.isDeleted());

      final R2Texture2DUsableType t_rgba = gb.getRGBATexture();
      final JCGLFramebufferUsableType fb = gb.getPrimaryFramebuffer();

      Assert.assertEquals(desc, gb.getDescription());
      Assert.assertEquals(area, gb.getArea());

      Assert.assertEquals(
          JCGLTextureFormat.TEXTURE_FORMAT_RGBA_8_4BPP, t_rgba.get().textureGetFormat());

      gb.delete(g);
      Assert.assertTrue(fb.isDeleted());
      Assert.assertTrue(gb.isDeleted());
    }
  }