private static void configureBlending( final JCGLInterfaceGL33Type g, final JCGLRenderStateType r) { final JCGLBlendingType g_b = g.blending(); final Optional<JCGLBlendStateType> blend_opt = r.blendState(); if (blend_opt.isPresent()) { final JCGLBlendStateType blend_state = blend_opt.get(); g_b.blendingEnableSeparateWithEquationSeparate( blend_state.blendFunctionSourceRGB(), blend_state.blendFunctionSourceAlpha(), blend_state.blendFunctionTargetRGB(), blend_state.blendFunctionTargetAlpha(), blend_state.blendEquationRGB(), blend_state.blendEquationAlpha()); } else { g_b.blendingDisable(); } }
@Test public final void testBlend() { final JCGLInterfaceGL33Type g = this.getGL33("main", 24, 8); final JCGLRenderStateMutable r = JCGLRenderStateMutable.create(); final JCGLBlendStateMutable bs = JCGLBlendStateMutable.create(); bs.setBlendEquationRGB(JCGLBlendEquation.BLEND_EQUATION_ADD); bs.setBlendEquationAlpha(JCGLBlendEquation.BLEND_EQUATION_MAXIMUM); bs.setBlendFunctionSourceAlpha(JCGLBlendFunction.BLEND_SOURCE_ALPHA); bs.setBlendFunctionSourceRGB(JCGLBlendFunction.BLEND_ONE); bs.setBlendFunctionTargetAlpha(JCGLBlendFunction.BLEND_CONSTANT_ALPHA); bs.setBlendFunctionTargetRGB(JCGLBlendFunction.BLEND_DESTINATION_COLOR); r.setBlendState(Optional.of(bs)); JCGLRenderStates.activate(g, r); final JCGLBlendingType g_b = g.blending(); Assert.assertTrue(g_b.blendingIsEnabled()); }
@Test public final void testInitialState() { final JCGLInterfaceGL33Type g = this.getGL33("main", 24, 8); final JCGLRenderStateMutable r = JCGLRenderStateMutable.create(); JCGLRenderStates.activate(g, r); final JCGLBlendingType g_b = g.blending(); final JCGLCullingType g_c = g.culling(); final JCGLDepthBuffersType g_d = g.depthBuffers(); final JCGLColorBufferMaskingType g_cm = g.colorBufferMasking(); final JCGLPolygonModesType g_p = g.polygonModes(); final JCGLScissorType g_s = g.scissor(); Assert.assertFalse(g_b.blendingIsEnabled()); Assert.assertFalse(g_c.cullingIsEnabled()); Assert.assertTrue(g_cm.colorBufferMaskStatusRed()); Assert.assertTrue(g_cm.colorBufferMaskStatusGreen()); Assert.assertTrue(g_cm.colorBufferMaskStatusBlue()); Assert.assertTrue(g_cm.colorBufferMaskStatusAlpha()); Assert.assertFalse(g_d.depthBufferTestIsEnabled()); Assert.assertFalse(g_d.depthBufferWriteIsEnabled()); Assert.assertFalse(g_d.depthClampingIsEnabled()); Assert.assertEquals(JCGLPolygonMode.POLYGON_FILL, g_p.polygonGetMode()); Assert.assertFalse(g_s.scissorIsEnabled()); }