@Override protected JCGLProjectionMatricesType newProjectionMatrices() { return JCGLProjectionMatrices.newMatrices(); } }
/** * Construct an example. */ public ExampleInstancedTrianglesView() { this.m_view = MatrixDirectM4x4F.newMatrix(); this.m_projection = MatrixDirectM4x4F.newMatrix(); this.view_matrices = JCGLViewMatrices.newMatrices(); this.proj_matrices = JCGLProjectionMatrices.newMatrices(); }
/** * Construct an example. */ public ExampleSingleTriangleView() { this.m_view = MatrixHeapArrayM4x4F.newMatrix(); this.m_model = MatrixHeapArrayM4x4F.newMatrix(); this.m_projection = MatrixDirectM4x4F.newMatrix(); this.m_modelview = MatrixDirectM4x4F.newMatrix(); this.view_matrices = JCGLViewMatrices.newMatrices(); this.proj_matrices = JCGLProjectionMatrices.newMatrices(); }
@Test public final void testMatricesObserverCalled() { final R2MatricesType m = this.newMatrices(); final JCGLProjectionMatricesType pm = JCGLProjectionMatrices.newMatrices(); final Integer r = m.withObserver( PMatrixI4x4F.identity(), R2ProjectionOrthographic.newFrustum(pm), Unit.unit(), (mm, u0) -> Integer.valueOf(23)); Assert.assertEquals(Integer.valueOf(23), r); }
@Test public void testAspectNonzero() { final JCGLProjectionMatricesType pm = JCGLProjectionMatrices.newMatrices(); final R2ProjectionFOV p = R2ProjectionFOV.newFrustumWith( pm, 1.5707963267948966f, 1.0f, 1.0f, 100.0f); this.expected.expect(RangeCheckException.class); p.setAspectRatio(0.0f); }
@Override protected final R2LightProjectiveReadableType newLight( final JCGLInterfaceGL33Type g, final R2IDPoolType pool, final JCGLTextureUnitContextType uc, final R2TextureDefaultsType td) { final R2ProjectionType p = R2ProjectionFrustum.newFrustum(JCGLProjectionMatrices.newMatrices()); final R2ProjectionMeshType pm = R2ProjectionMesh.newMesh( g, p, JCGLUsageHint.USAGE_STATIC_DRAW, JCGLUsageHint.USAGE_STATIC_DRAW); return R2LightProjectiveWithoutShadow.newLight( pm, td.texture2DProjectiveWhite(), pool); } }
@Override protected final R2LightProjectiveReadableType newLight( final JCGLInterfaceGL33Type g, final R2IDPoolType pool, final JCGLTextureUnitContextType uc, final R2TextureDefaultsType td) { final R2ProjectionType p = R2ProjectionFrustum.newFrustum(JCGLProjectionMatrices.newMatrices()); final R2ProjectionMeshType pm = R2ProjectionMesh.newMesh( g, p, JCGLUsageHint.USAGE_STATIC_DRAW, JCGLUsageHint.USAGE_STATIC_DRAW); return R2LightProjectiveWithoutShadow.newLight( pm, td.texture2DProjectiveWhite(), pool); } }
@Test public void testWatchable() { final JCGLProjectionMatricesType pm = JCGLProjectionMatrices.newMatrices(); final R2ProjectionFrustum p = R2ProjectionFrustum.newFrustum(pm); final AtomicInteger called = new AtomicInteger(0); final R2WatchableType<R2ProjectionReadableType> w = p.projectionGetWatchable(); w.watchableAdd(ww -> called.incrementAndGet()); Assert.assertEquals(1L, (long) called.get()); p.projectionSetZFar(100.0f); p.projectionSetZNear(1.0f); p.projectionSetXMinimum(-1.0f); p.projectionSetXMaximum(1.0f); p.projectionSetYMinimum(-1.0f); p.projectionSetYMaximum(1.0f); Assert.assertEquals(7L, (long) called.get()); } }
@Test public final void testMatricesObserverTransformCalled() { final R2MatricesType m = this.newMatrices(); final JCGLProjectionMatricesType pm = JCGLProjectionMatrices.newMatrices(); final PMatrixReadable3x3FType<R2SpaceTextureType, R2SpaceTextureType> uv = PMatrixI3x3F.identity(); final R2TransformReadableType t = R2TransformSOT.newTransform(); final Integer r = m.withObserver( PMatrixI4x4F.identity(), R2ProjectionOrthographic.newFrustum(pm), Unit.unit(), (mm, u0) -> mm.withTransform(t, uv, u0, (mi, u1) -> Integer.valueOf(23)) ); Assert.assertEquals(Integer.valueOf(23), r); }
@Test public final void testMatricesObserverInactive0() { final R2MatricesType m = this.newMatrices(); final JCGLProjectionMatricesType pm = JCGLProjectionMatrices.newMatrices(); final R2MatricesObserverType r = m.withObserver( PMatrixI4x4F.identity(), R2ProjectionOrthographic.newFrustum(pm), Unit.unit(), (mm, u0) -> mm); this.expected.expect(PreconditionViolationException.class); r.matrixProjection(); }
@Test public final void testMatricesObserverInactive1() { final R2MatricesType m = this.newMatrices(); final JCGLProjectionMatricesType pm = JCGLProjectionMatrices.newMatrices(); final R2MatricesObserverType r = m.withObserver( PMatrixI4x4F.identity(), R2ProjectionOrthographic.newFrustum(pm), Unit.unit(), (mm, u0) -> mm); this.expected.expect(PreconditionViolationException.class); r.matrixView(); }
@Test public final void testMatricesObserverInactive2() { final R2MatricesType m = this.newMatrices(); final JCGLProjectionMatricesType pm = JCGLProjectionMatrices.newMatrices(); final R2MatricesObserverType r = m.withObserver( PMatrixI4x4F.identity(), R2ProjectionOrthographic.newFrustum(pm), Unit.unit(), (mm, u0) -> mm); this.expected.expect(PreconditionViolationException.class); r.matrixViewInverse(); }
@Test public final void testMatricesObserverInactive3() { final R2MatricesType m = this.newMatrices(); final JCGLProjectionMatricesType pm = JCGLProjectionMatrices.newMatrices(); final R2MatricesObserverType r = m.withObserver( PMatrixI4x4F.identity(), R2ProjectionOrthographic.newFrustum(pm), Unit.unit(), (mm, u0) -> mm); this.expected.expect(PreconditionViolationException.class); r.viewRays(); }
@Test public final void testMatricesObserverCalledTwice() { final R2MatricesType m = this.newMatrices(); final JCGLProjectionMatricesType pm = JCGLProjectionMatrices.newMatrices(); final R2ProjectionOrthographic pp = R2ProjectionOrthographic.newFrustum(pm); this.expected.expect(R2RendererExceptionObserverAlreadyActive.class); this.expected.expectMessage("Observer already active"); m.withObserver( PMatrixI4x4F.identity(), pp, Unit.unit(), (mm, u0) -> m.withObserver( PMatrixI4x4F.identity(), pp, u0, (mk, u1) -> { throw new UnreachableCodeException(); })); }
@Test public final void testInactive() throws Exception { final JCGLContextType c = this.newGL33Context("main", 24, 8); final JCGLInterfaceGL33Type g = c.contextGetGL33(); final R2ShaderPreprocessingEnvironmentType sources = ShaderPreprocessing.preprocessor(); final R2IDPoolType pool = R2IDPool.newPool(); final R2ShaderDepthBatchedType<T> f = this.newShaderWithVerifier(g, sources, pool); final R2ProjectionReadableType proj = R2ProjectionOrthographic.newFrustum(JCGLProjectionMatrices.newMatrices()); this.expected.expect(FSMTransitionException.class); f.onReceiveViewValues( g, R2ShaderParametersView.of(new R2EmptyObserverValues(proj), VIEWPORT)); }
@Test public void testInactive() throws Exception { final JCGLInterfaceGL33Type g = R2TestUtilities.getFakeGL(); final R2ShaderInstanceBillboardedType<Object> f = R2TestUtilities.getShaderInstanceBillboarded(g, 1L); final R2ShaderInstanceBillboardedType<Object> v = R2ShaderInstanceBillboardedVerifier.newVerifier(f); final R2ProjectionReadableType proj = R2ProjectionOrthographic.newFrustum(JCGLProjectionMatrices.newMatrices()); final AreaInclusiveUnsignedLType area = AreaInclusiveUnsignedL.of( new UnsignedRangeInclusiveL(0L, 639L), new UnsignedRangeInclusiveL(0L, 479L)); final R2ShaderParametersView vp = R2ShaderParametersView.of(new R2EmptyObserverValues(proj), area); this.expected.expect(FSMTransitionException.class); v.onReceiveViewValues(g, vp); }
@Test public void testInactive() throws Exception { final JCGLInterfaceGL33Type g = R2TestUtilities.getFakeGL(); final R2ShaderTranslucentInstanceBatchedType<Object> f = R2TestUtilities.getShaderTranslucentInstanceBatched(g, 1L); final R2ShaderTranslucentInstanceBatchedType<Object> v = R2ShaderTranslucentInstanceBatchedVerifier.newVerifier(f); final R2ProjectionReadableType proj = R2ProjectionOrthographic.newFrustum(JCGLProjectionMatrices.newMatrices()); final AreaInclusiveUnsignedLType area = AreaInclusiveUnsignedL.of( new UnsignedRangeInclusiveL(0L, 639L), new UnsignedRangeInclusiveL(0L, 479L)); final R2ShaderParametersView vp = R2ShaderParametersView.of(new R2EmptyObserverValues(proj), area); this.expected.expect(FSMTransitionException.class); v.onReceiveViewValues(g, vp); }
@Test public void testInactive() throws Exception { final JCGLInterfaceGL33Type g = R2TestUtilities.getFakeGL(); final R2ShaderTranslucentInstanceSingleType<Object> f = R2TestUtilities.getShaderTranslucentInstanceSingle(g, 1L); final R2ShaderTranslucentInstanceSingleType<Object> v = R2ShaderTranslucentInstanceSingleVerifier.newVerifier(f); final R2ProjectionReadableType proj = R2ProjectionOrthographic.newFrustum(JCGLProjectionMatrices.newMatrices()); final AreaInclusiveUnsignedLType area = AreaInclusiveUnsignedL.of( new UnsignedRangeInclusiveL(0L, 639L), new UnsignedRangeInclusiveL(0L, 479L)); final R2ShaderParametersView vp = R2ShaderParametersView.of(new R2EmptyObserverValues(proj), area); this.expected.expect(FSMTransitionException.class); v.onReceiveViewValues(g, vp); }
@Test public void testInactive() throws Exception { final JCGLInterfaceGL33Type g = R2TestUtilities.getFakeGL(); final R2ShaderInstanceBatchedType<Object> f = R2TestUtilities.getShaderInstanceBatched(g, 1L); final R2ShaderInstanceBatchedType<Object> v = R2ShaderInstanceBatchedVerifier.newVerifier(f); final R2ProjectionReadableType proj = R2ProjectionOrthographic.newFrustum(JCGLProjectionMatrices.newMatrices()); final AreaInclusiveUnsignedLType area = AreaInclusiveUnsignedL.of( new UnsignedRangeInclusiveL(0L, 639L), new UnsignedRangeInclusiveL(0L, 479L)); final R2ShaderParametersView vp = R2ShaderParametersView.of(new R2EmptyObserverValues(proj), area); this.expected.expect(FSMTransitionException.class); v.onReceiveViewValues(g, vp); }
@Test public void testInactive() throws Exception { final JCGLInterfaceGL33Type g = R2TestUtilities.getFakeGL(); final R2ShaderTranslucentInstanceBillboardedType<Object> f = R2TestUtilities.getShaderTranslucentInstanceBillboarded(g, 1L); final R2ShaderTranslucentInstanceBillboardedType<Object> v = R2ShaderTranslucentInstanceBillboardedVerifier.newVerifier(f); final R2ProjectionReadableType proj = R2ProjectionOrthographic.newFrustum(JCGLProjectionMatrices.newMatrices()); final AreaInclusiveUnsignedLType area = AreaInclusiveUnsignedL.of( new UnsignedRangeInclusiveL(0L, 639L), new UnsignedRangeInclusiveL(0L, 479L)); final R2ShaderParametersView vp = R2ShaderParametersView.of(new R2EmptyObserverValues(proj), area); this.expected.expect(FSMTransitionException.class); v.onReceiveViewValues(g, vp); }