Ejemplo n.º 1
0
        public void TestDefaultPrecision(ShaderPrecisionContext ctx)
        {
            if (!HasVersion(2, 0) && !IsGlExtensionSupported("GL_ARB_vertex_shader"))
            {
                Assert.Inconclusive("OpenGL 2.0 or GL_ARB_vertex_shader not supported");
            }
            if (!HasVersion(3, 0) && !IsGlExtensionSupported("GL_EXT_transform_feedback"))
            {
                Assert.Inconclusive("OpenGL 3.0 or GL_EXT_transform_feedback not supported");
            }

            // Create resources required for test
            ctx.CreateResources();

            // Set program input
            BindShaderProgramAttrib(ctx.Program, ctx.ProgramInput, "vertexIn");
            // Set program output
            Gl.BindBuffer(BufferTargetARB.TransformFeedbackBuffer, ctx.ProgramOutput);

            // Draw on feedback buffer using program
            Gl.UseProgram(ctx.Program);

            // Transform feedback
            Gl.BeginTransformFeedback(Gl.POINTS);
            Gl.DrawArrays(PrimitiveType.Points, 0, ctx.ReferenceOutput.Length);
            Gl.EndTransformFeedback();

            // Get program computation result
            float[] feedbackData = new float[ctx.ReferenceOutput.Length];
            Gl.GetBufferSubData(BufferTargetARB.TransformFeedbackBuffer, IntPtr.Zero, (uint)feedbackData.Length, feedbackData);

            // Check precision
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Binds the array buffer attached to.
        /// </summary>
        /// <param name='index'>
        /// Index.
        /// </param>
        /// <exception cref='InvalidOperationException'>
        /// Is thrown when an operation cannot be performed.
        /// </exception>
        public void Begin(GraphicsContext ctx, PrimitiveType primitive)
        {
            CheckThisExistence(ctx);

            // Make this feedback buffer current
            ctx.Bind(this);

            // Begin transform feedback
            switch (primitive)
            {
            case PrimitiveType.Points:
                Gl.BeginTransformFeedback((int)PrimitiveType.Points);
                break;

            case PrimitiveType.Lines:
            case PrimitiveType.LineStrip:
            case PrimitiveType.LineLoop:
                Gl.BeginTransformFeedback((int)PrimitiveType.Lines);
                break;

            case PrimitiveType.Triangles:
            case PrimitiveType.TriangleStrip:
            case PrimitiveType.TriangleFan:
                Gl.BeginTransformFeedback((int)PrimitiveType.Triangles);
                break;

            default:
                throw new InvalidOperationException();
            }

            // Disable rasterizer?
            if (EnableRasterizer == false)
            {
                Gl.Enable(EnableCap.RasterizerDiscard);
            }

            // Start queries
            _PrimitivesGenerated.Begin(ctx);
            _PrimitivesWritten.Begin(ctx);
        }