@Override public void onReceiveBoundGeometryBufferTextures( final JCGLInterfaceGL33Type g, final R2GeometryBufferUsableType gbuffer, final JCGLTextureUnitType unit_albedo, final JCGLTextureUnitType unit_specular, final JCGLTextureUnitType unit_depth, final JCGLTextureUnitType unit_normals) { NullCheck.notNull(g); NullCheck.notNull(gbuffer); NullCheck.notNull(unit_albedo); NullCheck.notNull(unit_depth); NullCheck.notNull(unit_normals); NullCheck.notNull(unit_specular); /* Set each of the required G-Buffer textures. */ final JCGLShadersType g_sh = g.getShaders(); g_sh.shaderUniformPutTexture2DUnit(this.u_gbuffer_albedo, unit_albedo); g_sh.shaderUniformPutTexture2DUnit(this.u_gbuffer_normal, unit_normals); g_sh.shaderUniformPutTexture2DUnit(this.u_gbuffer_specular, unit_specular); g_sh.shaderUniformPutTexture2DUnit(this.u_gbuffer_depth, unit_depth); }
@Override public void onReceiveBoundGeometryBufferTextures( final JCGLInterfaceGL33Type g, final R2GeometryBufferUsableType gbuffer, final JCGLTextureUnitType unit_albedo, final JCGLTextureUnitType unit_specular, final JCGLTextureUnitType unit_depth, final JCGLTextureUnitType unit_normals) { NullCheck.notNull(g); NullCheck.notNull(gbuffer); NullCheck.notNull(unit_albedo); NullCheck.notNull(unit_specular); NullCheck.notNull(unit_depth); NullCheck.notNull(unit_normals); /* Upload the geometry buffer textures. */ final JCGLShadersType g_sh = g.getShaders(); g_sh.shaderUniformPutTexture2DUnit(this.u_gbuffer_albedo, unit_albedo); g_sh.shaderUniformPutTexture2DUnit(this.u_gbuffer_normal, unit_normals); g_sh.shaderUniformPutTexture2DUnit(this.u_gbuffer_specular, unit_specular); g_sh.shaderUniformPutTexture2DUnit(this.u_gbuffer_depth, unit_depth); }
@Override public void onReceiveBoundGeometryBufferTextures( final JCGLInterfaceGL33Type g, final R2GeometryBufferUsableType gbuffer, final JCGLTextureUnitType unit_albedo, final JCGLTextureUnitType unit_specular, final JCGLTextureUnitType unit_depth, final JCGLTextureUnitType unit_normals) { NullCheck.notNull(g); NullCheck.notNull(gbuffer); NullCheck.notNull(unit_albedo); NullCheck.notNull(unit_depth); NullCheck.notNull(unit_normals); NullCheck.notNull(unit_specular); /* Set each of the required G-Buffer textures. */ final JCGLShadersType g_sh = g.getShaders(); g_sh.shaderUniformPutTexture2DUnit(this.u_gbuffer_albedo, unit_albedo); g_sh.shaderUniformPutTexture2DUnit(this.u_gbuffer_normal, unit_normals); g_sh.shaderUniformPutTexture2DUnit(this.u_gbuffer_specular, unit_specular); g_sh.shaderUniformPutTexture2DUnit(this.u_gbuffer_depth, unit_depth); }
@Override public void onReceiveBoundGeometryBufferTextures( final JCGLInterfaceGL33Type g, final R2GeometryBufferUsableType gbuffer, final JCGLTextureUnitType unit_albedo, final JCGLTextureUnitType unit_specular, final JCGLTextureUnitType unit_depth, final JCGLTextureUnitType unit_normals) { NullCheck.notNull(g); NullCheck.notNull(gbuffer); NullCheck.notNull(unit_albedo); NullCheck.notNull(unit_depth); NullCheck.notNull(unit_normals); NullCheck.notNull(unit_specular); /* Set each of the required G-Buffer textures. */ final JCGLShadersType g_sh = g.getShaders(); g_sh.shaderUniformPutTexture2DUnit(this.u_gbuffer_albedo, unit_albedo); g_sh.shaderUniformPutTexture2DUnit(this.u_gbuffer_normal, unit_normals); g_sh.shaderUniformPutTexture2DUnit(this.u_gbuffer_specular, unit_specular); g_sh.shaderUniformPutTexture2DUnit(this.u_gbuffer_depth, unit_depth); }
@Override public void onReceiveBoundGeometryBufferTextures( final JCGLInterfaceGL33Type g, final R2GeometryBufferUsableType gbuffer, final JCGLTextureUnitType unit_albedo, final JCGLTextureUnitType unit_specular, final JCGLTextureUnitType unit_depth, final JCGLTextureUnitType unit_normals) { NullCheck.notNull(g); NullCheck.notNull(gbuffer); NullCheck.notNull(unit_albedo); NullCheck.notNull(unit_depth); NullCheck.notNull(unit_normals); NullCheck.notNull(unit_specular); /* Set each of the required G-Buffer textures. */ final JCGLShadersType g_sh = g.getShaders(); g_sh.shaderUniformPutTexture2DUnit(this.u_gbuffer_albedo, unit_albedo); g_sh.shaderUniformPutTexture2DUnit(this.u_gbuffer_normal, unit_normals); g_sh.shaderUniformPutTexture2DUnit(this.u_gbuffer_specular, unit_specular); g_sh.shaderUniformPutTexture2DUnit(this.u_gbuffer_depth, unit_depth); }
@Override public void onReceiveBoundGeometryBufferTextures( final JCGLInterfaceGL33Type g, final R2GeometryBufferUsableType gbuffer, final JCGLTextureUnitType unit_albedo, final JCGLTextureUnitType unit_specular, final JCGLTextureUnitType unit_depth, final JCGLTextureUnitType unit_normals) { NullCheck.notNull(g); NullCheck.notNull(gbuffer); NullCheck.notNull(unit_albedo); NullCheck.notNull(unit_depth); NullCheck.notNull(unit_normals); NullCheck.notNull(unit_specular); /* Set each of the required G-Buffer textures. */ final JCGLShadersType g_sh = g.getShaders(); g_sh.shaderUniformPutTexture2DUnit(this.u_gbuffer_albedo, unit_albedo); g_sh.shaderUniformPutTexture2DUnit(this.u_gbuffer_normal, unit_normals); g_sh.shaderUniformPutTexture2DUnit(this.u_gbuffer_specular, unit_specular); g_sh.shaderUniformPutTexture2DUnit(this.u_gbuffer_depth, unit_depth); }
@Override public void onReceiveBoundGeometryBufferTextures( final JCGLInterfaceGL33Type g, final R2GeometryBufferUsableType gbuffer, final JCGLTextureUnitType unit_albedo, final JCGLTextureUnitType unit_specular, final JCGLTextureUnitType unit_depth, final JCGLTextureUnitType unit_normals) { NullCheck.notNull(g); NullCheck.notNull(gbuffer); NullCheck.notNull(unit_albedo); NullCheck.notNull(unit_depth); NullCheck.notNull(unit_normals); NullCheck.notNull(unit_specular); /* Set each of the required G-Buffer textures. */ final JCGLShadersType g_sh = g.getShaders(); g_sh.shaderUniformPutTexture2DUnit(this.u_gbuffer_albedo, unit_albedo); g_sh.shaderUniformPutTexture2DUnit(this.u_gbuffer_normal, unit_normals); g_sh.shaderUniformPutTexture2DUnit(this.u_gbuffer_specular, unit_specular); g_sh.shaderUniformPutTexture2DUnit(this.u_gbuffer_depth, unit_depth); }
@Test public final void testProgramUniformSampler2DCorrect() { final Interfaces i = this.getInterfaces("main"); final JCGLShadersType s = i.getShaders(); final JCGLTexturesType t = i.getTextures(); final JCGLVertexShaderType v = s.shaderCompileVertex("uniforms2", this.getShaderLines("uniforms2.vert")); final JCGLFragmentShaderType f = s.shaderCompileFragment("valid0", this.getShaderLines("valid0.frag")); final JCGLProgramShaderType p = s.shaderLinkProgram("uniforms2", v, Optional.empty(), f); final Map<String, JCGLProgramUniformType> us = p.uniforms(); Assert.assertTrue(us.containsKey("s2")); final JCGLProgramUniformType u = us.get("s2"); Assert.assertEquals(JCGLType.TYPE_SAMPLER_2D, u.type()); s.shaderActivateProgram(p); s.shaderUniformPutTexture2DUnit(u, t.textureGetUnits().get(0)); }
@Test public final void testProgramUniformSampler2DWrong() { final Interfaces i = this.getInterfaces("main"); final JCGLShadersType s = i.getShaders(); final JCGLTexturesType t = i.getTextures(); final JCGLVertexShaderType v = s.shaderCompileVertex("uniforms2", this.getShaderLines("uniforms2.vert")); final JCGLFragmentShaderType f = s.shaderCompileFragment("valid0", this.getShaderLines("valid0.frag")); final JCGLProgramShaderType p = s.shaderLinkProgram("uniforms2", v, Optional.empty(), f); final Map<String, JCGLProgramUniformType> us = p.uniforms(); Assert.assertTrue(us.containsKey("s3")); final JCGLProgramUniformType u = us.get("s3"); Assert.assertEquals(JCGLType.TYPE_SAMPLER_3D, u.type()); s.shaderActivateProgram(p); this.expected.expect(JCGLExceptionProgramTypeError.class); s.shaderUniformPutTexture2DUnit(u, t.textureGetUnits().get(0)); }
@Test public final void testProgramUniformSampler2DNotActive() { final Interfaces i = this.getInterfaces("main"); final JCGLShadersType s = i.getShaders(); final JCGLTexturesType t = i.getTextures(); final JCGLVertexShaderType v = s.shaderCompileVertex("uniforms2", this.getShaderLines("uniforms2.vert")); final JCGLFragmentShaderType f = s.shaderCompileFragment("valid0", this.getShaderLines("valid0.frag")); final JCGLProgramShaderType p = s.shaderLinkProgram("uniforms2", v, Optional.empty(), f); final Map<String, JCGLProgramUniformType> us = p.getUniforms(); Assert.assertTrue(us.containsKey("s2")); final JCGLProgramUniformType u = us.get("s2"); Assert.assertEquals(JCGLType.TYPE_SAMPLER_2D, u.getType()); s.shaderDeactivateProgram(); this.expected.expect(JCGLExceptionProgramNotActive.class); s.shaderUniformPutTexture2DUnit(u, t.textureGetUnits().get(0)); }
@Test public final void testProgramUniformSampler2DCorrect() { final Interfaces i = this.getInterfaces("main"); final JCGLShadersType s = i.getShaders(); final JCGLTexturesType t = i.getTextures(); final JCGLVertexShaderType v = s.shaderCompileVertex("uniforms2", this.getShaderLines("uniforms2.vert")); final JCGLFragmentShaderType f = s.shaderCompileFragment("valid0", this.getShaderLines("valid0.frag")); final JCGLProgramShaderType p = s.shaderLinkProgram("uniforms2", v, Optional.empty(), f); final Map<String, JCGLProgramUniformType> us = p.getUniforms(); Assert.assertTrue(us.containsKey("s2")); final JCGLProgramUniformType u = us.get("s2"); Assert.assertEquals(JCGLType.TYPE_SAMPLER_2D, u.getType()); s.shaderActivateProgram(p); s.shaderUniformPutTexture2DUnit(u, t.textureGetUnits().get(0)); }
@Test public final void testProgramUniformSampler2DNotActive() { final Interfaces i = this.getInterfaces("main"); final JCGLShadersType s = i.getShaders(); final JCGLTexturesType t = i.getTextures(); final JCGLVertexShaderType v = s.shaderCompileVertex("uniforms2", this.getShaderLines("uniforms2.vert")); final JCGLFragmentShaderType f = s.shaderCompileFragment("valid0", this.getShaderLines("valid0.frag")); final JCGLProgramShaderType p = s.shaderLinkProgram("uniforms2", v, Optional.empty(), f); final Map<String, JCGLProgramUniformType> us = p.uniforms(); Assert.assertTrue(us.containsKey("s2")); final JCGLProgramUniformType u = us.get("s2"); Assert.assertEquals(JCGLType.TYPE_SAMPLER_2D, u.type()); s.shaderDeactivateProgram(); this.expected.expect(JCGLExceptionProgramNotActive.class); s.shaderUniformPutTexture2DUnit(u, t.textureGetUnits().get(0)); }
@Test public final void testProgramUniformSampler2DWrong() { final Interfaces i = this.getInterfaces("main"); final JCGLShadersType s = i.getShaders(); final JCGLTexturesType t = i.getTextures(); final JCGLVertexShaderType v = s.shaderCompileVertex("uniforms2", this.getShaderLines("uniforms2.vert")); final JCGLFragmentShaderType f = s.shaderCompileFragment("valid0", this.getShaderLines("valid0.frag")); final JCGLProgramShaderType p = s.shaderLinkProgram("uniforms2", v, Optional.empty(), f); final Map<String, JCGLProgramUniformType> us = p.getUniforms(); Assert.assertTrue(us.containsKey("s3")); final JCGLProgramUniformType u = us.get("s3"); Assert.assertEquals(JCGLType.TYPE_SAMPLER_3D, u.getType()); s.shaderActivateProgram(p); this.expected.expect(JCGLExceptionProgramTypeError.class); s.shaderUniformPutTexture2DUnit(u, t.textureGetUnits().get(0)); }
@Override public void onReceiveShadowMap( final JCGLInterfaceGL33Type g, final JCGLTextureUnitContextMutableType tc, final R2Texture2DUsableType map) { NullCheck.notNull(g); NullCheck.notNull(tc); NullCheck.notNull(map); final JCGLShadersType g_sh = g.getShaders(); final JCGLTexturesType g_tex = g.getTextures(); final JCGLTextureUnitType unit_shadow = tc.unitContextBindTexture2D(g_tex, map.texture()); g_sh.shaderUniformPutTexture2DUnit( this.u_shadow_map, unit_shadow); }
@Override public void onReceiveShadowMap( final JCGLInterfaceGL33Type g, final JCGLTextureUnitContextMutableType tc, final R2Texture2DUsableType map) { NullCheck.notNull(g); NullCheck.notNull(tc); NullCheck.notNull(map); final JCGLShadersType g_sh = g.getShaders(); final JCGLTexturesType g_tex = g.getTextures(); final JCGLTextureUnitType unit_shadow = tc.unitContextBindTexture2D(g_tex, map.texture()); g_sh.shaderUniformPutTexture2DUnit( this.u_shadow_map, unit_shadow); }
@Override public void onReceiveMaterialValues( final JCGLInterfaceGL33Type g, final R2ShaderParametersMaterialType<R2RefractionMaskedDeltaParameters> mat_parameters) { NullCheck.notNull(g); NullCheck.notNull(mat_parameters); final JCGLTexturesType g_tex = g.getTextures(); final JCGLShadersType g_sh = g.getShaders(); final JCGLTextureUnitContextMutableType tc = mat_parameters.textureUnitContext(); final R2RefractionMaskedDeltaParameters values = mat_parameters.values(); final JCGLTextureUnitType unit_mask = tc.unitContextBindTexture2D(g_tex, values.maskTexture().texture()); final JCGLTextureUnitType unit_scene = tc.unitContextBindTexture2D(g_tex, values.sceneTexture().texture()); final JCGLTextureUnitType unit_delta = tc.unitContextBindTexture2D(g_tex, values.deltaTexture().texture()); g_sh.shaderUniformPutFloat(this.u_refraction_scale, values.scale()); g_sh.shaderUniformPutVector3f(this.u_refraction_color, values.color()); g_sh.shaderUniformPutTexture2DUnit(this.u_refraction_mask, unit_mask); g_sh.shaderUniformPutTexture2DUnit(this.u_refraction_scene, unit_scene); g_sh.shaderUniformPutTexture2DUnit(this.u_refraction_delta, unit_delta); }
@Override public void onReceiveMaterialValues( final JCGLInterfaceGL33Type g, final R2ShaderParametersMaterialType<R2RefractionMaskedDeltaParameters> mat_parameters) { NullCheck.notNull(g); NullCheck.notNull(mat_parameters); final JCGLTexturesType g_tex = g.getTextures(); final JCGLShadersType g_sh = g.getShaders(); final JCGLTextureUnitContextMutableType tc = mat_parameters.textureUnitContext(); final R2RefractionMaskedDeltaParameters values = mat_parameters.values(); final JCGLTextureUnitType unit_mask = tc.unitContextBindTexture2D(g_tex, values.maskTexture().texture()); final JCGLTextureUnitType unit_scene = tc.unitContextBindTexture2D(g_tex, values.sceneTexture().texture()); final JCGLTextureUnitType unit_delta = tc.unitContextBindTexture2D(g_tex, values.deltaTexture().texture()); g_sh.shaderUniformPutFloat(this.u_refraction_scale, values.scale()); g_sh.shaderUniformPutVector3f(this.u_refraction_color, values.color()); g_sh.shaderUniformPutTexture2DUnit(this.u_refraction_mask, unit_mask); g_sh.shaderUniformPutTexture2DUnit(this.u_refraction_scene, unit_scene); g_sh.shaderUniformPutTexture2DUnit(this.u_refraction_delta, unit_delta); }
@Override public void onReceiveMaterialValues( final JCGLInterfaceGL33Type g, final R2ShaderParametersMaterialType<R2DepthShaderBasicParameters> mat_parameters) { NullCheck.notNull(g); NullCheck.notNull(mat_parameters); final JCGLTexturesType g_tex = g.getTextures(); final JCGLShadersType g_sh = g.getShaders(); final JCGLTextureUnitContextMutableType tc = mat_parameters.textureUnitContext(); final R2DepthShaderBasicParameters values = mat_parameters.values(); final JCGLTextureUnitType unit_albedo = tc.unitContextBindTexture2D(g_tex, values.albedoTexture().texture()); g_sh.shaderUniformPutTexture2DUnit( this.u_texture_albedo, unit_albedo); g_sh.shaderUniformPutFloat( this.u_alpha_discard_threshold, values.alphaDiscardThreshold()); } }
@Override public void onReceiveMaterialValues( final JCGLInterfaceGL33Type g, final R2ShaderParametersMaterialType<R2DepthShaderBasicParameters> mat_parameters) { NullCheck.notNull(g); NullCheck.notNull(mat_parameters); final JCGLTexturesType g_tex = g.getTextures(); final JCGLShadersType g_sh = g.getShaders(); final JCGLTextureUnitContextMutableType tc = mat_parameters.textureUnitContext(); final R2DepthShaderBasicParameters values = mat_parameters.values(); final JCGLTextureUnitType unit_albedo = tc.unitContextBindTexture2D(g_tex, values.albedoTexture().texture()); g_sh.shaderUniformPutTexture2DUnit( this.u_texture_albedo, unit_albedo); g_sh.shaderUniformPutFloat( this.u_alpha_discard_threshold, values.alphaDiscardThreshold()); } }
@Override public void onReceiveMaterialValues( final JCGLInterfaceGL33Type g, final R2ShaderParametersMaterialType<R2TranslucentShaderBasicParameters> mat_parameters) { NullCheck.notNull(g); NullCheck.notNull(mat_parameters); final JCGLTexturesType g_tex = g.getTextures(); final JCGLShadersType g_sh = g.getShaders(); final JCGLTextureUnitContextMutableType tc = mat_parameters.textureUnitContext(); final R2TranslucentShaderBasicParameters values = mat_parameters.values(); final JCGLTextureUnitType unit_albedo = tc.unitContextBindTexture2D(g_tex, values.albedoTexture().texture()); g_sh.shaderUniformPutTexture2DUnit( this.u_texture_albedo, unit_albedo); g_sh.shaderUniformPutVector4f( this.u_color, values.albedoColor()); g_sh.shaderUniformPutFloat( this.u_fade_positive_eye_z_far, values.fadeZFar()); g_sh.shaderUniformPutFloat( this.u_fade_positive_eye_z_near, values.fadeZNear()); }