Esempio n. 1
0
        public static AxisNode Create()
        {
            // vertex buffer and index buffer.
            var model = new AxisModel();
            // vertex shader and fragment shader.
            var vs    = new VertexShader(vertexCode);
            var fs    = new FragmentShader(fragmentCode);
            var array = new ShaderArray(vs, fs);
            // which vertex buffer maps to which attribute in shader.
            var map = new AttributeMap();

            map.Add("inPosition", AxisModel.strPosition);
            map.Add("inColor", AxisModel.strColor);
            // build a render method.
            var builder = new RenderMethodBuilder(array, map, new LineWidthSwitch(3));
            // create node.
            var node = new AxisNode(model, builder);

            // initialize node.
            node.Initialize();

            return(node);
        }
        /// <summary>
        /// 根据<see cref="IndexBuffer"/>的具体类型获取一个<see cref="PickableRenderer"/>
        /// </summary>
        /// <param name="model"></param>
        /// <param name="attributeMap"></param>
        /// <param name="positionNameInIBufferable"></param>
        /// <param name="switches"></param>
        /// <returns></returns>
        public static InnerPickableRenderer GetRenderer(
            this IBufferable model,
            AttributeMap attributeMap,
            string positionNameInIBufferable,
            params GLState[] switches)
        {
            if (model == null || attributeMap == null || string.IsNullOrEmpty(positionNameInIBufferable))
            {
                throw new ArgumentNullException();
            }

            AttributeMap map = null;

            foreach (AttributeMap.NamePair item in attributeMap)
            {
                if (item.NameInIBufferable == positionNameInIBufferable)
                {
                    map = new AttributeMap();
                    map.Add(item.VarNameInShader, item.NameInIBufferable);
                    break;
                }
            }
            if (map == null)
            {
                throw new Exception(string.Format("No matching variable name in shader for [{0}]", positionNameInIBufferable));
            }

            if (model.UsesZeroIndexBuffer())
            {
                return(new ZeroIndexRenderer(model, PickingShaderHelper.GetShaderCodes(), map, positionNameInIBufferable, switches));
            }
            else
            {
                return(new OneIndexRenderer(model, PickingShaderHelper.GetShaderCodes(), map, positionNameInIBufferable, switches));
            }
        }
Esempio n. 3
0
 /// <summary>
 /// Rendering something using GLSL shader and VBO(VAO).
 /// </summary>
 /// <param name="model">model data that can be transfermed into OpenGL Buffer's pointer.</param>
 /// <param name="shaderCodes">All shader codes needed for this renderer.</param>
 /// <param name="attributeMap">Mapping relations between 'in' variables in vertex shader in <paramref name="shaderCodes"/> and buffers in <paramref name="model"/>.</param>
 ///<param name="switches">OpenGL switches.</param>
 private BoundingBoxRenderer(IBufferable model, ShaderCode[] shaderCodes,
                             AttributeMap attributeMap, params GLState[] switches)
     : base(model, shaderCodes, attributeMap, switches)
 {
     this.BoundingBoxColor = Color.White;
 }
Esempio n. 4
0
 /// <summary>
 /// 支持"拾取"的渲染器
 /// </summary>
 /// <param name="model">一种渲染方式</param>
 /// <param name="renderProgramProvider">各种类型的shader代码</param>
 /// <param name="attributeMap">关联<paramref name="model"/>和<paramref name="shaderProgramProvider"/>中的属性</param>
 /// <param name="positionNameInVertexShader">vertex shader种描述顶点位置信息的in变量的名字</param>
 ///<param name="switches"></param>
 private TranslateRenderer(IBufferable model, IShaderProgramProvider renderProgramProvider,
                           AttributeMap attributeMap, string positionNameInVertexShader,
                           params GLState[] switches)
     : base(model, renderProgramProvider, attributeMap, positionNameInVertexShader, switches)
 {
 }
Esempio n. 5
0
 private TextureRenderer(IBufferable model, ShaderCode[] shaderCodes,
                         AttributeMap attributeMap, string positionNameInIBufferable, params GLSwitch[] switches)
     : base(model, shaderCodes, attributeMap, positionNameInIBufferable, switches)
 {
 }
Esempio n. 6
0
 private FlabellumRenderer(Flabellum model, IShaderProgramProvider shaderProgramProvider,
                           AttributeMap attributeMap, params GLState[] switches)
     : base(model, shaderProgramProvider, attributeMap, switches)
 {
     this.ModelSize = model.GetModelSize();
 }
Esempio n. 7
0
 /// <summary>
 /// A smallest unit that can render somthing.
 /// </summary>
 /// <param name="programProvider"></param>
 /// <param name="map"></param>
 /// <param name="states"></param>
 public RenderMethodBuilder(IShaderProgramProvider programProvider, AttributeMap map, params GLState[] states)
 {
     this.programProvider = programProvider;
     this.map             = map;
     this.states          = states;
 }
Esempio n. 8
0
 /// <summary>
 /// Rendering something using GLSL shader and VBO(VAO).
 /// </summary>
 /// <param name="model">model data that can be transfermed into OpenGL Buffer's pointer.</param>
 /// <param name="shaderProgramProvider">All shader codes needed for this renderer.</param>
 /// <param name="attributeMap">Mapping relations between 'in' variables in vertex shader in <paramref name="shaderProgramProvider"/> and buffers in <paramref name="model"/>.</param>
 ///<param name="switches">OpenGL switches.</param>
 private BoundingBoxRenderer(IBufferable model, IShaderProgramProvider shaderProgramProvider,
                             AttributeMap attributeMap, params GLState[] switches)
     : base(model, shaderProgramProvider, attributeMap, switches)
 {
     this.BoundingBoxColor = Color.White;
 }
Esempio n. 9
0
 private TextureRenderer(IBufferable model, IShaderProgramProvider shaderProgramProvider,
                         AttributeMap attributeMap, string positionNameInIBufferable, params GLState[] switches)
     : base(model, shaderProgramProvider, attributeMap, positionNameInIBufferable, switches)
 {
 }