/** * Fill this modifiable instance with attribute values from the provided {@link JCGLClearSpecificationType} instance. * Regular attribute values will be overridden, i.e. replaced with ones of an instance. * Any of the instance's absent optional values will not be copied (will not override current values). * @param instance The instance from which to copy values * @return {@code this} for use in a chained invocation */ public JCGLClearSpecificationMutable from(JCGLClearSpecificationType instance) { Objects.requireNonNull(instance, "instance"); Optional<VectorReadable4FType> colorBufferClearOptional = instance.getColorBufferClear(); if (colorBufferClearOptional.isPresent()) { setColorBufferClear(colorBufferClearOptional); } OptionalDouble depthBufferClearOptional = instance.getDepthBufferClear(); if (depthBufferClearOptional.isPresent()) { setDepthBufferClear(depthBufferClearOptional); } OptionalInt stencilBufferClearOptional = instance.getStencilBufferClear(); if (stencilBufferClearOptional.isPresent()) { setStencilBufferClear(stencilBufferClearOptional); } setStrictChecking(instance.getStrictChecking()); return this; }
/** * Fill a builder with attribute values from the provided {@code JCGLClearSpecificationType} instance. * Regular attribute values will be replaced with those from the given instance. * Absent optional values will not replace present values. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ public final Builder from(JCGLClearSpecificationType instance) { Objects.requireNonNull(instance, "instance"); Optional<VectorReadable4FType> colorBufferClearOptional = instance.getColorBufferClear(); if (colorBufferClearOptional.isPresent()) { setColorBufferClear(colorBufferClearOptional); } OptionalDouble depthBufferClearOptional = instance.getDepthBufferClear(); if (depthBufferClearOptional.isPresent()) { setDepthBufferClear(depthBufferClearOptional); } OptionalInt stencilBufferClearOptional = instance.getStencilBufferClear(); if (stencilBufferClearOptional.isPresent()) { setStencilBufferClear(stencilBufferClearOptional); } setStrictChecking(instance.getStrictChecking()); return this; }
@Override public void clear(final JCGLClearSpecificationType c) throws JCGLException { NullCheck.notNull(c); int buffers = 0; final Optional<VectorReadable4FType> opt_color = c.getColorBufferClear(); final OptionalDouble opt_depth = c.getDepthBufferClear(); final OptionalInt opt_stencil = c.getStencilBufferClear(); if (opt_color.isPresent()) { buffers |= GL11.GL_COLOR_BUFFER_BIT; final VectorReadable4FType cc = opt_color.get(); GL11.glClearColor(cc.getXF(), cc.getYF(), cc.getZF(), cc.getWF()); } if (opt_depth.isPresent()) { buffers |= GL11.GL_DEPTH_BUFFER_BIT; GL11.glClearDepth(opt_depth.getAsDouble()); } if (opt_stencil.isPresent()) { buffers |= GL11.GL_STENCIL_BUFFER_BIT; GL11.glClearStencil(opt_stencil.getAsInt()); } GL11.glClear(buffers); } }