/// <summary> /// Creates a <see cref="RenderbufferObject"/> with the specified format. /// </summary> /// <param name="graphicsDevice">The <see cref="GraphicsDevice"/> this resource will use.</param> /// <param name="width">The width for the <see cref="RenderbufferObject"/>.</param> /// <param name="height">The height for the <see cref="RenderbufferObject"/>.</param> /// <param name="format">The format for the <see cref="RenderbufferObject"/>'s storage.</param> /// <param name="samples">The amount of samples the <see cref="RenderbufferObject"/> will have.</param> public RenderbufferObject(GraphicsDevice graphicsDevice, uint width, uint height, RenderbufferFormat format, uint samples = 0) : base(graphicsDevice) { if (!Enum.IsDefined(typeof(RenderbufferFormat), format)) { throw new ArgumentException("Invalid renderbuffer format", nameof(format)); } if (width <= 0 || width > graphicsDevice.MaxRenderbufferSize) { throw new ArgumentOutOfRangeException(nameof(width), width, "Width must be in the range (0, " + nameof(graphicsDevice.MaxRenderbufferSize) + "]"); } if (height <= 0 || height > graphicsDevice.MaxRenderbufferSize) { throw new ArgumentOutOfRangeException(nameof(height), height, "Height must be in the range (0, " + nameof(graphicsDevice.MaxRenderbufferSize) + "]"); } ValidateSampleCount(samples); Handle = GL.GenRenderbuffer(); Format = format; Width = width; Height = height; Samples = samples; graphicsDevice.ForceBindRenderbuffer(this); GL.RenderbufferStorageMultisample(RenderbufferTarget.Renderbuffer, Samples, (InternalFormat)format, Width, Height); }
/// <summary> /// Returns whether the specified <see cref="RenderbufferFormat"/> represents a color renderable format. /// </summary> public static bool IsRenderbufferFormatColorRenderable(RenderbufferFormat format) { return(format == RenderbufferFormat.Color4b || format == RenderbufferFormat.Float || format == RenderbufferFormat.Float2 || format == RenderbufferFormat.Float4 || format == RenderbufferFormat.Int || format == RenderbufferFormat.Int2 || format == RenderbufferFormat.Int4 || format == RenderbufferFormat.UnsignedInt || format == RenderbufferFormat.UnsignedInt2 || format == RenderbufferFormat.UnsignedInt4); }
public void RenderbufferStorage(RenderbufferType type, RenderbufferFormat internalFormat, int width, int height) => this.CallMethod <object>(RENDERBUFFER_STORAGE, type, internalFormat, width, height);
/// <summary> /// Gets the default valid <see cref="FramebufferAttachmentPoint"/> for a <see cref="RenderbufferFormat"/> /// (depth/stencil/depthstencil/color0). /// </summary> public static FramebufferAttachmentPoint GetCorrespondingRenderbufferFramebufferAttachmentPoint(RenderbufferFormat format) { if (IsRenderbufferFormatColorRenderable(format)) { return(FramebufferAttachmentPoint.Color0); } if (IsRenderbufferFormatDepthOnly(format)) { return(FramebufferAttachmentPoint.Depth); } if (IsRenderbufferFormatDepthStencil(format)) { return(FramebufferAttachmentPoint.DepthStencil); } if (IsRenderbufferFormatStencilOnly(format)) { return(FramebufferAttachmentPoint.Stencil); } throw new ArgumentException("Given " + nameof(RenderbufferFormat) + " has no default valid " + nameof(FramebufferAttachmentPoint)); }
/// <summary> /// Returns whether the specified <see cref="RenderbufferFormat"/> represents a depth-stencil format. /// </summary> public static bool IsRenderbufferFormatDepthStencil(RenderbufferFormat format) { return(format == RenderbufferFormat.Depth24Stencil8 || format == RenderbufferFormat.Depth32fStencil8); }
/// <summary> /// Returns whether the specified <see cref="RenderbufferFormat"/> represents a stencil-only format. /// </summary> public static bool IsRenderbufferFormatStencilOnly(RenderbufferFormat format) { return(format == RenderbufferFormat.Stencil8); }
/// <summary> /// Returns whether the specified <see cref="RenderbufferFormat"/> represents a depth-only format. /// </summary> public static bool IsRenderbufferFormatDepthOnly(RenderbufferFormat format) { return(format == RenderbufferFormat.Depth16 || format == RenderbufferFormat.Depth24 || format == RenderbufferFormat.Depth32f); }