Beispiel #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Scale"/> class.
        /// </summary>
        /// <param name="ownerAxis">The owner axis.</param>
        /// <param name="TextInstance">The text instance.</param>
        public Scale(Axis ownerAxis, TextInstance TextInstance)
        {
            _ownerAxis    = ownerAxis;
            _textInstance = TextInstance;

            _min = 0.0;
            _max = 10.0;

            _majorStep         = 1;
            _minorStep         = 0.1;
            _targetXSteps      = 7;
            _targetYSteps      = 7;
            _targetMinorXSteps = 5;
            _targetMinorYSteps = 5;

            _VBO = GL.GenBuffer(); //generate VBO, VAO and setting them up here
            _VAO = GL.GenVertexArray();

            _linesShader = TextInstance.Shaders.LineShader;
            _linesShader.Use();

            GL.BindVertexArray(_VAO);

            GL.EnableVertexAttribArray(_linesShader.VertexLocation);

            GL.BindBuffer(BufferTarget.ArrayBuffer, _VBO);

            _mat = Matrix4.Identity;
            GL.UniformMatrix4(_linesShader.MatrixLocation, false, ref _mat);

            GL.VertexAttribPointer(_linesShader.VertexLocation, 2, VertexAttribPointerType.Float, false, 2 * sizeof(float), 0);

            GL.BindVertexArray(0);
            _linesShader.StopUse();
        }
Beispiel #2
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 #3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Legend"/> class.
        /// </summary>
        /// <param name="textInstance">The text instance.</param>
        public Legend(TextInstance textInstance)
        {
            _legendEntries = new List <LegendEntry>();
            _border        = new GL_Border(Color.Black, textInstance.Shaders);
            _textInstance  = textInstance;
            _linesShader   = textInstance.Shaders.LineShader;
            _rect          = new GLRectangleF(0, 0, 0, 0);
            _innerRect     = new GLRectangleF(0, 0, 0, 0);
            _entryGapX     = 2;
            _nEntriesVert  = 5;
            _margin        = new Margin();
            _margin.Left   = 10;
            _margin.Right  = 10;
            _margin.Top    = 2;
            _margin.Bottom = 5;
            _lineHeight    = textInstance.FontSize * 0.8;

            _VBOLine = GL.GenBuffer();//set up OpenGL by generating buffers and using the shader
            _VAOLine = GL.GenVertexArray();
            _linesShader.Use();

            GL.BindVertexArray(_VAOLine);//setting up VAO states and binding the VBO

            GL.EnableVertexAttribArray(_linesShader.VertexLocation);

            GL.BindBuffer(BufferTarget.ArrayBuffer, _VBOLine);
            _mat = Matrix4.Identity;
            GL.UniformMatrix4(_linesShader.MatrixLocation, false, ref _mat);

            GL.VertexAttribPointer(_linesShader.VertexLocation, 2, VertexAttribPointerType.Float, false, 2 * sizeof(float), 0);

            GL.BindVertexArray(0);
            _linesShader.StopUse();
        }