/// <summary> /// Virtual Unbind implementation. /// </summary> /// <param name="ctx"> /// A <see cref="GraphicsContext"/> used for binding. /// </param> protected override void UnbindCore(GraphicsContext ctx) { if (ctx.Extensions.TransformFeedback2_ARB) { // Bind this feedback buffer Gl.BindTransformFeedback(Gl.TRANSFORM_FEEDBACK, InvalidObjectName); } else { base.UnbindCore(ctx); } }
/// <summary> /// Virtual Bind implementation. /// </summary> /// <param name="ctx"> /// A <see cref="GraphicsContext"/> used for binding. /// </param> protected override void BindCore(GraphicsContext ctx) { if (ctx.Extensions.TransformFeedback2_ARB) { // Bind this feedback buffer Gl.BindTransformFeedback(TransformFeedbackTarget.TransformFeedback, ObjectName); } else { base.BindCore(ctx); MapBufferObjects(ctx); } }
/// <summary> /// Actually create this GraphicsResource resources. /// </summary> /// <param name="ctx"> /// A <see cref="GraphicsContext"/> used for allocating resources. /// </param> protected override void CreateObject(GraphicsContext ctx) { if (ctx == null) { throw new ArgumentNullException("ctx"); } if (_AttachedArrays.Count == 0) { throw new InvalidOperationException("no feedback attachments"); } if (ctx.Extensions.TransformFeedback2_ARB) { // Bind/create feedback buffer Gl.BindTransformFeedback(Gl.TRANSFORM_FEEDBACK, ObjectName); // Define feedback buffer MapBufferObjects(ctx); // Reset feedback target binding Gl.BindTransformFeedback(Gl.TRANSFORM_FEEDBACK, 0); } else { ctx.Bind(this); // Define feedback buffer MapBufferObjects(ctx); } // Create queries _PrimitivesGenerated = new QueryObject(QueryTarget.PrimitivesGenerated); _PrimitivesGenerated.Create(ctx); _PrimitivesWritten = new QueryObject(QueryTarget.TransformFeedbackPrimitivesGenerated); _PrimitivesWritten.Create(ctx); }