コード例 #1
0
        /// <summary>
        /// Help function to draw a single, texture quad on the screen
        /// </summary>
        /// <param name="left"></param>
        /// <param name="right"></param>
        /// <param name="top"></param>
        /// <param name="bottom"></param>
        /// <param name="shader"></param>
        void DrawTexturedQuad(float left, float right, float top, float bottom, TexturedShader shader)
        {
            Vector2[] texCoords = new Vector2[]
            {
                new Vector2(0, 0),
                new Vector2(1, 0),
                new Vector2(1, 1),
                new Vector2(0, 1)
            };

            Vector3[] positions = new Vector3[]
            {
                new Vector3(left, bottom, 0),
                new Vector3(right, bottom, 0),
                new Vector3(right, top, 0),
                new Vector3(left, top, 0),
            };

            uint[] indices = new uint[]
            {
                0, 1, 2, 0, 2, 3
            };

            shader.SetIndices(indices);
            shader.SetVertexPositions(positions);
            shader.SetTextureCoordinates(texCoords);
            shader.DrawElements(BeginMode.Triangles);
        }
コード例 #2
0
        /// <summary>
        /// Constructs the DiffusionRenderer to draw the editor's current frame. DiffusionRenderer
        /// can only start drawing when OpenGL has finished loading.
        /// </summary>
        /// <param name="editorState">Used as a reference to draw the currently selected point</param>
        /// <param name="pathsContainer">Used as a reference to draw all the paths in the current frame</param>
        public DiffusionRenderer(RenderState renderState,
                                 EditorState currentState, DiffusionBuffers buffers,
                                 DefaultShader pointShader, TexturedShader imageShader, TexturedShader diffuseShader,
                                 NormalShader lineShader, NormalShader endPointShader)
        {
            this.renderState    = renderState;
            this.currentState   = currentState;
            this.buffers        = buffers;
            this.pointShader    = pointShader;
            this.imageShader    = imageShader;
            this.diffuseShader  = diffuseShader;
            this.lineShader     = lineShader;
            this.endPointShader = endPointShader;

            this.renderState.PropertyChanged += renderState_PropertyChanged;
        }