Exemplo n.º 1
0
 /**
  * Construct a new set of view rays.
  *
  * @param c Preallocated storage for matrix operations
  * @return A new set of view rays
  */
 public static R2ViewRaysType newViewRays(final PMatrixM4x4F.ContextPM4F c) {
   final R2ViewRays vr =
       new R2ViewRays(
           new VectorM4F(),
           new VectorM4F(),
           new VectorM4F(),
           new VectorM4F(),
           new VectorM4F(),
           new VectorM4F(),
           new VectorM4F(),
           new VectorM4F());
   vr.recalculate(c, PMatrixI4x4F.identity());
   return vr;
 }
Exemplo n.º 2
0
  @Test
  public final void testFramebufferBindingNonDefaultNotProvided() {
    final JCGLContextType c = this.newGL33Context("main", 24, 8);
    final JCGLInterfaceGL33Type g = c.contextGetGL33();

    final JCGLFramebuffersType g_fb = g.getFramebuffers();

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

    final JCGLTextureUnitAllocatorType ta =
        JCGLTextureUnitAllocator.newAllocatorWithStack(8, g.getTextures().textureGetUnits());
    final JCGLTextureUnitContextParentType tc = ta.getRootContext();
    final R2TextureDefaultsType td = R2TextureDefaults.newDefaults(g.getTextures(), tc);

    final R2UnitSphereType sphere = R2UnitSphere.newUnitSphere8(g);
    final R2UnitQuadType quad = R2UnitQuad.newUnitQuad(g);
    final R2IDPoolType id_pool = R2IDPool.newPool();

    final JCGLProfilingType pro = JCGLProfiling.newProfiling(g.getTimers());
    final JCGLProfilingFrameType pro_frame = pro.startFrame();
    final JCGLProfilingContextType pro_root = pro_frame.getChildContext("main");

    final R2SceneLightsType s = R2LightRendererContract.newScene(g, sphere, id_pool);

    final R2ShadowMapContextUsableType shadows =
        ls -> {
          throw new UnreachableCodeException();
        };

    final R2ProjectionOrthographic proj =
        R2ProjectionOrthographic.newFrustum(JCGLProjectionMatrices.newMatrices());

    final R2ShaderSourcesType ss = R2ShaderSourcesResources.newSources(R2Shaders.class);
    final R2LightRendererType r = this.getRenderer(g, td, ss, id_pool, quad);

    final R2GeometryBufferType gbuffer =
        R2GeometryBuffer.newGeometryBuffer(
            g_fb,
            g.getTextures(),
            tc,
            R2GeometryBufferDescription.of(
                area, R2GeometryBufferComponents.R2_GEOMETRY_BUFFER_FULL));

    final R2LightBufferType lbuffer =
        R2LightBuffers.newLightBuffer(
            g_fb,
            g.getTextures(),
            tc,
            R2LightBufferDescription.of(
                area, R2LightBufferComponents.R2_LIGHT_BUFFER_DIFFUSE_AND_SPECULAR));

    g_fb.framebufferReadUnbind();
    Assert.assertTrue(g_fb.framebufferDrawIsBound(lbuffer.getPrimaryFramebuffer()));

    final R2MatricesType m = R2Matrices.newMatrices();
    m.withObserver(
        PMatrixI4x4F.identity(),
        proj,
        Unit.unit(),
        (x, y) -> {
          r.renderLights(gbuffer, area, Optional.empty(), pro_root, tc, shadows, x, s);
          return Unit.unit();
        });

    Assert.assertFalse(g_fb.framebufferReadAnyIsBound());
    Assert.assertTrue(g_fb.framebufferDrawIsBound(lbuffer.getPrimaryFramebuffer()));
  }