Beispiel #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CurveItem"/> class.
        /// Sets up the OpenGL Objects VAO and VBO and AttribPointers
        /// </summary>
        /// <param name="pane">The pane.</param>
        /// <param name="label">The label.</param>
        /// <param name="points">The points.</param>
        /// <param name="color">The color.</param>
        /// <param name="linesShader">The lines shader.</param>
        public CurveItem(GraphPane pane, string label, RollingVec2List points, Color color, LinesShader linesShader)
        {
            _rollingV2List = points;
            _GraphVertex   = new Vector2[points.Capacity];
            _label         = label;
            _color         = color;
            _yAxisIndex    = 0;
            _linesShader   = linesShader;

            _pane = pane;

            _linesShader.Use();//use the Shader, generate and bindd VAO and VBO
            _VAO = GL.GenVertexArray();
            _VBO = GL.GenBuffer();

            GL.BindVertexArray(_VAO);
            GL.EnableVertexAttribArray(_linesShader.VertexLocation); //enable the in variable of the Shader, where the Vertices are put

            GL.BindBuffer(BufferTarget.ArrayBuffer, _VBO);           //bind the VBO and give it an empty array
            GL.BufferData <Vector2>(BufferTarget.ArrayBuffer, (IntPtr)(Vector2.SizeInBytes * _GraphVertex.Length), _GraphVertex, BufferUsageHint.StreamDraw);
            //set up the Pointer for OpenGL to interpret Vertices
            GL.VertexAttribPointer(_linesShader.VertexLocation, 2, VertexAttribPointerType.Float, false, Vector2.SizeInBytes, 0);

            GL.BindVertexArray(0);
            _linesShader.StopUse();
        }
Beispiel #2
0
        /// <summary>
        /// Adds a Curve to the <see cref="GraphPane"/>, effectively
        /// generating an entry to the <see cref="Legend"/> and the new <see cref="RollingVec2List"/>
        /// to the <see cref="CurveList"/>.
        /// </summary>
        /// <param name="label">The label.</param>
        /// <param name="points">The points.</param>
        /// <param name="color">The color.</param>
        /// <returns></returns>
        public CurveItem AddCurve(string label, RollingVec2List points, Color color)
        {
            CurveItem curve = new CurveItem(this, label, points, color, _shaders.LineShader);

            _curveList.Add(curve);
            _legend.AddItem(label, color);

            return(curve);
        }