public UIText( System.Windows.Forms.AnchorStyles anchor, System.Windows.Forms.Padding margin, System.Drawing.Size size, int zNear, int zFar, FontResource fontResource = null, int maxCharCount = 100) : base(anchor, margin, size, zNear, zFar) { if (fontResource == null) { this.fontResource = FontResource.Default; } else { this.fontResource = fontResource; } this.Name = this.GetType().Name; var shaderCodes = new ShaderCode[2]; shaderCodes[0] = new ShaderCode(ManifestResourceLoader.LoadTextFile( @"Resources.UIText.vert"), ShaderType.VertexShader); shaderCodes[1] = new ShaderCode(ManifestResourceLoader.LoadTextFile( @"Resources.UIText.frag"), ShaderType.FragmentShader); var map = new PropertyNameMap(); map.Add("position", "position"); map.Add("uv", "uv"); var model = new TextModel(maxCharCount); Renderer renderer = new Renderer(model, shaderCodes, map); this.model = model; this.Renderer = renderer; }
public static ShaderCode[] GetHighlightShaderCode() { var shaderCodes = new ShaderCode[2]; shaderCodes[0] = new ShaderCode(GetShaderSource(ShaderType.VertexShader), ShaderType.VertexShader); shaderCodes[1] = new ShaderCode(GetShaderSource(ShaderType.FragmentShader), ShaderType.FragmentShader); return shaderCodes; }
/// <summary> /// 支持"拾取"的渲染器 /// </summary> /// <param name="bufferable">一种渲染方式</param> /// <param name="shaderCodes">各种类型的shader代码</param> /// <param name="propertyNameMap">关联<see cref="PropertyBufferPtr"/>和<see cref="shaderCode"/>中的属性</param> /// <param name="positionNameInIBufferable">描述顶点位置信息的buffer的名字</param> ///<param name="switches"></param> public PickableRenderer(IBufferable bufferable, ShaderCode[] shaderCodes, PropertyNameMap propertyNameMap, string positionNameInIBufferable, params GLSwitch[] switches) : base(bufferable, shaderCodes, propertyNameMap, switches) { var innerPickableRenderer = InnerPickableRendererFactory.GetRenderer( bufferable, propertyNameMap, positionNameInIBufferable); this.innerPickableRenderer = innerPickableRenderer; }
public static ShaderCode[] GetHighlightShaderCode() { var shaderCodes = new ShaderCode[2]; shaderCodes[0] = new ShaderCode(GetShaderSource(ShaderType.VertexShader), ShaderType.VertexShader); shaderCodes[1] = new ShaderCode(GetShaderSource(ShaderType.FragmentShader), ShaderType.FragmentShader); return(shaderCodes); }
/// <summary> /// 支持"拾取"的渲染器 /// </summary> /// <param name="model">一种渲染方式</param> /// <param name="shaderCodes">各种类型的shader代码</param> /// <param name="attributeMap">关联<paramref name="model"/>和<paramref name="shaderCodes"/>中的属性</param> /// <param name="positionNameInIBufferable">描述顶点位置信息的buffer的名字</param> ///<param name="switches"></param> public PickableRenderer(IBufferable model, ShaderCode[] shaderCodes, AttributeMap attributeMap, string positionNameInIBufferable, params GLState[] switches) : base(model, shaderCodes, attributeMap, switches) { var innerPickableRenderer = InnerPickableRendererFactory.GetRenderer( model, attributeMap, positionNameInIBufferable); this.innerPickableRenderer = innerPickableRenderer; }
/// <summary> /// 用Shader+VBO(VAO)进行渲染。 /// </summary> /// <param name="bufferable">将具体模型转换为可被OpenGL拿来渲染的格式</param> /// <param name="shaderCodes">各种类型的shader代码</param> /// <param name="propertyNameMap">关联<see cref="PropertyBufferPtr"/>和<see cref="shaderCodes"/>中的属性</param> /// <param name="positionNameInIBufferable">描述顶点位置信息的buffer的名字</param> ///<param name="switches"></param> public Renderer(IBufferable bufferable, ShaderCode[] shaderCodes, PropertyNameMap propertyNameMap, params GLSwitch[] switches) { this.Name = this.GetType().Name; this.bufferable = bufferable; this.shaderCodes = shaderCodes; this.propertyNameMap = propertyNameMap; this.switchList.AddRange(switches); }
/// <summary> /// /// </summary> /// <returns></returns> public static IShaderProgramProvider GetPickingShaderProgramProvider() { var shaderCodes = new ShaderCode[2]; shaderCodes[0] = new ShaderCode(GetShaderSource(ShaderType.VertexShader), ShaderType.VertexShader); shaderCodes[1] = new ShaderCode(GetShaderSource(ShaderType.FragmentShader), ShaderType.FragmentShader); var provider = new ShaderCodeArray(shaderCodes); return(provider); }
/// <summary> /// Creates a shader program object by a single shader. /// </summary> /// <param name="shaderCode"></param> /// <returns></returns> public static ShaderProgram CreateProgram(this ShaderCode shaderCode) { var program = new ShaderProgram(); Shader shader = shaderCode.CreateShader(); program.Initialize(shader); shader.Dispose(); return(program); }
public static ShaderProgram GetHighlightShaderProgram() { var shaderCodes = new ShaderCode[2]; shaderCodes[0] = new ShaderCode(GetShaderSource(ShaderType.VertexShader), ShaderType.VertexShader); shaderCodes[1] = new ShaderCode(GetShaderSource(ShaderType.FragmentShader), ShaderType.FragmentShader); var shaderProgram = new ShaderProgram(); shaderProgram.Create((from item in shaderCodes select item.CreateShader()).ToArray()); return shaderProgram; }
public DefaultRendererComponent(BuildInSceneObject buildIn, SceneObject bindingObject = null) : base(bindingObject) { var shaderCodes = new ShaderCode[2]; shaderCodes[0] = new ShaderCode(ManifestResourceLoader.LoadTextFile(@"Resources\BuildInSceneObject.vert"), ShaderType.VertexShader); shaderCodes[1] = new ShaderCode(ManifestResourceLoader.LoadTextFile(@"Resources\BuildInSceneObject.frag"), ShaderType.FragmentShader); IBufferable bufferable = GetModel(buildIn); PropertyNameMap map = GetMap(buildIn); var renderer = new Renderer(bufferable, shaderCodes, map); renderer.Initialize(); this.Renderer = renderer; }
public static QuadStripRenderer Create(QuadStripModel model) { var shaderCodes = new ShaderCode[2]; shaderCodes[0] = new ShaderCode(File.ReadAllText(@"shaders\QuadStripTexture.vert"), ShaderType.VertexShader); shaderCodes[1] = new ShaderCode(File.ReadAllText(@"shaders\QuadStripTexture.frag"), ShaderType.FragmentShader); var map = new AttributeMap(); map.Add("in_Position", QuadStripModel.position); map.Add("in_TexCoord", QuadStripModel.texCoord); var renderer = new QuadStripRenderer(model, shaderCodes, map); return renderer; }
public static ShaderProgram GetPickingShaderProgram() { ShaderCode[] shaders = new ShaderCode[2]; shaders[0] = new ShaderCode(GetShaderSource(ShaderType.VertexShader), ShaderType.VertexShader); shaders[1] = new ShaderCode(GetShaderSource(ShaderType.FragmentShader), ShaderType.FragmentShader); var shaderProgram = new ShaderProgram(); shaderProgram.Create((from item in shaders select item.CreateShader()).ToArray()); return(shaderProgram); }
public static QuadStripColoredRenderer Create(QuadStripColoredModel model) { var shaderCodes = new ShaderCode[2]; shaderCodes[0] = new ShaderCode(File.ReadAllText(@"shaders\QuadStripColor.vert"), ShaderType.VertexShader); shaderCodes[1] = new ShaderCode(File.ReadAllText(@"shaders\QuadStripColor.frag"), ShaderType.FragmentShader); var map = new AttributeMap(); map.Add("in_Position", QuadStripColoredModel.position); map.Add("in_Color", QuadStripColoredModel.color); var renderer = new QuadStripColoredRenderer(model, shaderCodes, map); renderer.quadCount = model.quadCount; return renderer; }
public static ShaderProgram GetPickingShaderProgram() { var shaderCodes = new ShaderCode[2]; shaderCodes[0] = new ShaderCode(GetShaderSource(ShaderType.VertexShader), ShaderType.VertexShader); shaderCodes[1] = new ShaderCode(GetShaderSource(ShaderType.FragmentShader), ShaderType.FragmentShader); ShaderProgram program = new ShaderProgram(); var shaders = (from item in shaderCodes select item.CreateShader()).ToArray(); program.Create(shaders); foreach (var item in shaders) { item.Delete(); } return program; }
/// <summary> /// /// </summary> public static ShaderProgram GetHighlightShaderProgram() { var shaderCodes = new ShaderCode[2]; shaderCodes[0] = new ShaderCode(GetShaderSource(ShaderType.VertexShader), ShaderType.VertexShader); shaderCodes[1] = new ShaderCode(GetShaderSource(ShaderType.FragmentShader), ShaderType.FragmentShader); var shaderProgram = new ShaderProgram(); shaderProgram.Initialize((from item in shaderCodes select item.CreateShader()).ToArray()); return(shaderProgram); }
public static CatesianGridRenderer Create(vec3 originalWorldPosition, CatesianGrid grid, Texture codedColorSampler) { var shaderCodes = new ShaderCode[2]; shaderCodes[0] = new ShaderCode(File.ReadAllText(@"shaders\HexahedronGrid.vert"), ShaderType.VertexShader); shaderCodes[1] = new ShaderCode(File.ReadAllText(@"shaders\HexahedronGrid.frag"), ShaderType.FragmentShader); var map = new AttributeMap(); map.Add("in_Position", CatesianGrid.strPosition); map.Add("in_uv", CatesianGrid.strColor); var renderer = new CatesianGridRenderer(originalWorldPosition, grid, shaderCodes, map, codedColorSampler); renderer.ModelSize = (grid.DataSource.SourceActiveBounds.MaxPosition - grid.DataSource.SourceActiveBounds.MinPosition).Abs(); renderer.WorldPosition = -grid.DataSource.Position; return renderer; }
/// <summary> /// /// </summary> /// <param name="buildIn"></param> /// <param name="bindingObject"></param> public DefaultRendererComponent(BuildInSceneObject buildIn, SceneObject bindingObject = null) : base(bindingObject) { var shaderCodes = new ShaderCode[2]; shaderCodes[0] = new ShaderCode(File.ReadAllText(@"shaders\BuildInSceneObject.vert"), ShaderType.VertexShader); shaderCodes[1] = new ShaderCode(File.ReadAllText(@"shaders\BuildInSceneObject.frag"), ShaderType.FragmentShader); IBufferable bufferable = GetModel(buildIn); PropertyNameMap map = GetMap(buildIn); var renderer = new Renderer(bufferable, shaderCodes, map); renderer.Initialize(); this.Renderer = renderer; }
/// <summary> /// /// </summary> /// <param name="model"></param> /// <returns></returns> public static PointsRenderer Create(Points model) { var shaderCodes = new ShaderCode[2]; shaderCodes[0] = new ShaderCode(ManifestResourceLoader.LoadTextFile(@"Resources\Points.vert"), ShaderType.VertexShader); shaderCodes[1] = new ShaderCode(ManifestResourceLoader.LoadTextFile(@"Resources\Points.frag"), ShaderType.FragmentShader); var map = new CSharpGL.AttributeMap(); map.Add("in_Position", Points.strposition); var renderer = new PointsRenderer(model, shaderCodes, map, Points.strposition); renderer.ModelSize = model.Lengths; renderer.WorldPosition = model.WorldPosition; renderer.stateList.Add(new PointSizeState(10)); return renderer; }
/// <summary> /// /// </summary> /// <param name="buildIn"></param> /// <returns></returns> public static SceneObject GetBuildInSceneObject(BuildInSceneObject buildIn) { var shaderCodes = new ShaderCode[2]; shaderCodes[0] = new ShaderCode(File.ReadAllText(@"shaders\BuildInSceneObject.vert"), ShaderType.VertexShader); shaderCodes[1] = new ShaderCode(File.ReadAllText(@"shaders\BuildInSceneObject.frag"), ShaderType.FragmentShader); IBufferable model = GetModel(buildIn); AttributeMap map = GetMap(buildIn); vec3 lengths = GetLengths(buildIn); var renderer = new BuildInRenderer(lengths, model, shaderCodes, map); //renderer.Initialize(); SceneObject obj = renderer.WrapToSceneObject(); return obj; }
//private vec3 scale; //public vec3 Scale //{ // get { return scale; } // set // { // if (value != scale) // { // scale = value; // if (this.initialized) // { // this.SetUniform("modelMatrix", // glm.scale(glm.translate(mat4.identity(), this.translate), this.scale)); // } // } // } //} //private vec3 translate; //public vec3 Translate //{ // get { return translate; } // set // { // if (value != translate) // { // translate = value; // if (this.initialized) // { // this.SetUniform("modelMatrix", // glm.scale(glm.translate(mat4.identity(), this.translate), this.scale)); // } // } // } //} public BoudingBoxRenderer(vec3 lengths) : base(null, null, null) { this.bufferable = new BoundingBox(lengths); var shaderCodes = new ShaderCode[2]; shaderCodes[0] = new ShaderCode(File.ReadAllText( @"shaders\BoundingBox.vert"), ShaderType.VertexShader); shaderCodes[1] = new ShaderCode(File.ReadAllText( @"shaders\BoundingBox.frag"), ShaderType.FragmentShader); this.shaderCodes = shaderCodes; var map = new PropertyNameMap(); map.Add("in_Position", BoundingBox.strPosition); this.propertyNameMap = map; this.switchList.Add(new PolygonModeSwitch(PolygonModes.Lines)); }
/// <summary> /// Gets a renderer that renders a bitmap in a square. /// </summary> /// <param name="bitmapFilename"></param> /// <returns></returns> public static TextureRenderer Create(string bitmapFilename = "") { var shaderCodes = new ShaderCode[2]; shaderCodes[0] = new ShaderCode(ManifestResourceLoader.LoadTextFile( @"Resources.SquareRenderer.vert"), ShaderType.VertexShader); shaderCodes[1] = new ShaderCode(ManifestResourceLoader.LoadTextFile( @"Resources.SquareRenderer.frag"), ShaderType.FragmentShader); var map = new AttributeMap(); map.Add("in_Position", Square.strPosition); map.Add("in_TexCoord", Square.strTexCoord); var model = new Square(); var renderer = new TextureRenderer(model, shaderCodes, map, Square.strPosition); renderer.bitmapFilename = bitmapFilename; return renderer; }
/// <summary> /// /// </summary> /// <param name="buildIn"></param> /// <returns></returns> public static SceneObject GetBuildInSceneObject(BuildInSceneObject buildIn) { var shaderCodes = new ShaderCode[2]; shaderCodes[0] = new ShaderCode(File.ReadAllText(@"shaders\BuildInSceneObject.vert"), ShaderType.VertexShader); shaderCodes[1] = new ShaderCode(File.ReadAllText(@"shaders\BuildInSceneObject.frag"), ShaderType.FragmentShader); IBufferable model = GetModel(buildIn); AttributeMap map = GetMap(buildIn); vec3 lengths = GetLengths(buildIn); var renderer = new BuildInRenderer(lengths, model, shaderCodes, map); //renderer.Initialize(); SceneObject obj = renderer.WrapToSceneObject(); return(obj); }
/// <summary> /// /// </summary> /// <param name="buildIn"></param> /// <returns></returns> public static SceneObject GetBuildInSceneObject(BuildInSceneObject buildIn) { var shaderCodes = new ShaderCode[2]; shaderCodes[0] = new ShaderCode(File.ReadAllText(@"shaders\BuildInSceneObject.vert"), ShaderType.VertexShader); shaderCodes[1] = new ShaderCode(File.ReadAllText(@"shaders\BuildInSceneObject.frag"), ShaderType.FragmentShader); IBufferable bufferable = GetModel(buildIn); PropertyNameMap map = GetMap(buildIn); var renderer = new BuildInRenderer(bufferable, shaderCodes, map); renderer.Initialize(); SceneObject obj = renderer.WrapToSceneObject(); return(obj); }
/// <summary> /// opengl UI for Axis /// </summary> /// <param name="anchor"></param> /// <param name="margin"></param> /// <param name="size"></param> /// <param name="partCount">24 as default.</param> public UIAxis( System.Windows.Forms.AnchorStyles anchor, System.Windows.Forms.Padding margin, System.Drawing.Size size, int partCount = 24) : base(anchor, margin, size, -Math.Max(size.Width, size.Height), Math.Max(size.Width, size.Height)) { var shaderCodes = new ShaderCode[2]; shaderCodes[0] = new ShaderCode(ManifestResourceLoader.LoadTextFile(@"Resources\Simple.vert"), ShaderType.VertexShader); shaderCodes[1] = new ShaderCode(ManifestResourceLoader.LoadTextFile(@"Resources\Simple.frag"), ShaderType.FragmentShader); var map = new AttributeMap(); map.Add("in_Position", Axis.strPosition); map.Add("in_Color", Axis.strColor); var renderer = new Renderer(new Axis(partCount, 0.5f), shaderCodes, map); this.Renderer = renderer; }
/// <summary> /// /// </summary> /// <param name="model"></param> /// <returns></returns> public static PointsRenderer Create(Points model) { var shaderCodes = new ShaderCode[2]; shaderCodes[0] = new ShaderCode(ManifestResourceLoader.LoadTextFile(@"Resources\Points.vert"), ShaderType.VertexShader); shaderCodes[1] = new ShaderCode(ManifestResourceLoader.LoadTextFile(@"Resources\Points.frag"), ShaderType.FragmentShader); var map = new CSharpGL.AttributeMap(); map.Add("in_Position", Points.strposition); var renderer = new PointsRenderer(model, shaderCodes, map, Points.strposition); renderer.ModelSize = model.Lengths; renderer.WorldPosition = model.WorldPosition; renderer.stateList.Add(new PointSizeState(10)); return(renderer); }
/// <summary> /// opengl UI for Axis /// </summary> /// <param name="anchor"></param> /// <param name="margin"></param> /// <param name="size"></param> /// <param name="partCount">24 as default.</param> public UIAxis( System.Windows.Forms.AnchorStyles anchor, System.Windows.Forms.Padding margin, System.Drawing.Size size, int partCount = 24) : base(anchor, margin, size, -Math.Max(size.Width, size.Height), Math.Max(size.Width, size.Height)) { var shaderCodes = new ShaderCode[2]; shaderCodes[0] = new ShaderCode(ManifestResourceLoader.LoadTextFile(@"Resources\Simple.vert"), ShaderType.VertexShader); shaderCodes[1] = new ShaderCode(ManifestResourceLoader.LoadTextFile(@"Resources\Simple.frag"), ShaderType.FragmentShader); var map = new AttributeMap(); map.Add("in_Position", Axis.strPosition); map.Add("in_Color", Axis.strColor); var axis = new Axis(partCount, 0.5f); var renderer = new Renderer(axis, shaderCodes, map); renderer.ModelSize = axis.ModelSize; this.Renderer = renderer; }
/// <summary> /// get a bounding box renderer. /// </summary> /// <param name="lengths">bounding box's length at x, y, z direction.</param> /// <returns></returns> public static BoundingBoxRenderer Create(vec3 lengths) { var model = new BoundingBoxModel(lengths); var shaderCodes = new ShaderCode[2]; shaderCodes[0] = new ShaderCode(ManifestResourceLoader.LoadTextFile( @"Resources\BoundingBox.vert"), ShaderType.VertexShader); shaderCodes[1] = new ShaderCode(ManifestResourceLoader.LoadTextFile( @"Resources\BoundingBox.frag"), ShaderType.FragmentShader); var map = new AttributeMap(); map.Add("in_Position", BoundingBoxModel.strPosition); var result = new BoundingBoxRenderer(model, shaderCodes, map, new PolygonModeState(PolygonMode.Line), new PolygonOffsetFillState()); result.ModelSize = lengths; return(result); }
public static AxisRenderer Create(int partCount = 24) { var shaderCodes = new ShaderCode[2]; shaderCodes[0] = new ShaderCode(ManifestResourceLoader.LoadTextFile( @"Resources.UIAxis.vert"), ShaderType.VertexShader); shaderCodes[1] = new ShaderCode(ManifestResourceLoader.LoadTextFile( @"Resources.UIAxis.frag"), ShaderType.FragmentShader); var map = new PropertyNameMap(); map.Add("in_Position", Axis.strPosition); map.Add("in_Color", Axis.strColor); var model = new Axis(partCount); var renderer = new AxisRenderer(model, shaderCodes, map, "position"); return(renderer); }
/// <summary> /// Creates a renderer that renders a evaluator(a bezier curve or surface) and its control points. /// </summary> /// <param name="controlPoints"></param> /// <param name="type"></param> /// <returns></returns> public static BezierRenderer Create(IList <vec3> controlPoints, BezierType type) { var shaderCodes = new ShaderCode[2]; shaderCodes[0] = new ShaderCode(ManifestResourceLoader.LoadTextFile(@"Resources\Points.vert"), ShaderType.VertexShader); shaderCodes[1] = new ShaderCode(ManifestResourceLoader.LoadTextFile(@"Resources\Points.frag"), ShaderType.FragmentShader); var map = new CSharpGL.AttributeMap(); map.Add("in_Position", Points.strposition); var model = new Points(controlPoints); var renderer = new BezierRenderer(controlPoints, type, model, shaderCodes, map, Points.strposition); renderer.Lengths = model.Lengths; renderer.WorldPosition = model.WorldPosition; renderer.switchList.Add(new PointSizeSwitch(10)); return(renderer); }
/// <summary> /// Gets a renderer that renders a bitmap in a square. /// </summary> /// <param name="bitmapFilename"></param> /// <returns></returns> public static TextureRenderer Create(string bitmapFilename = "") { var shaderCodes = new ShaderCode[2]; shaderCodes[0] = new ShaderCode(ManifestResourceLoader.LoadTextFile( @"Resources.SquareRenderer.vert"), ShaderType.VertexShader); shaderCodes[1] = new ShaderCode(ManifestResourceLoader.LoadTextFile( @"Resources.SquareRenderer.frag"), ShaderType.FragmentShader); var map = new AttributeMap(); map.Add("in_Position", Square.strPosition); map.Add("in_TexCoord", Square.strTexCoord); var model = new Square(); var renderer = new TextureRenderer(model, shaderCodes, map, Square.strPosition); renderer.bitmapFilename = bitmapFilename; return(renderer); }
public static ShaderProgram GetPickingShaderProgram() { var shaderCodes = new ShaderCode[2]; shaderCodes[0] = new ShaderCode(GetShaderSource(ShaderType.VertexShader), ShaderType.VertexShader); shaderCodes[1] = new ShaderCode(GetShaderSource(ShaderType.FragmentShader), ShaderType.FragmentShader); ShaderProgram program = new ShaderProgram(); var shaders = (from item in shaderCodes select item.CreateShader()).ToArray(); program.Create(shaders); foreach (var item in shaders) { item.Delete(); } return(program); }
/// <summary> /// opengl UI for Axis /// </summary> /// <param name="anchor"></param> /// <param name="margin"></param> /// <param name="size"></param> /// <param name="zNear"></param> /// <param name="zFar"></param> public UIAxis( System.Windows.Forms.AnchorStyles anchor, System.Windows.Forms.Padding margin, System.Drawing.Size size, int zNear, int zFar) : base(anchor, margin, size, zNear, zFar) { this.Name = typeof(UIAxis).Name; var shaderCodes = new ShaderCode[2]; shaderCodes[0] = new ShaderCode(ManifestResourceLoader.LoadTextFile( @"Resources.UIAxis.vert"), ShaderType.VertexShader); shaderCodes[1] = new ShaderCode(ManifestResourceLoader.LoadTextFile( @"Resources.UIAxis.frag"), ShaderType.FragmentShader); var map = new PropertyNameMap(); map.Add("in_Position", "position"); map.Add("in_Color", "color"); //PickableRenderer renderer = (new Axis()).GetRenderer(shaderCodes, map, "position"); PickableRenderer renderer = new PickableRenderer(new Axis(), shaderCodes, map, "position"); this.Renderer = renderer; }
/// <summary> /// get a bounding box renderer. /// </summary> /// <param name="lengths">bounding box's length at x, y, z direction.</param> /// <param name="originalWorldPosition"></param> /// <returns></returns> public static BoundingBoxRenderer Create(vec3 lengths, vec3 originalWorldPosition = new vec3()) { var bufferable = new BoundingBoxModel(lengths); var shaderCodes = new ShaderCode[2]; shaderCodes[0] = new ShaderCode(ManifestResourceLoader.LoadTextFile( @"Resources\BoundingBox.vert"), ShaderType.VertexShader); shaderCodes[1] = new ShaderCode(ManifestResourceLoader.LoadTextFile( @"Resources\BoundingBox.frag"), ShaderType.FragmentShader); var map = new PropertyNameMap(); map.Add("in_Position", BoundingBoxModel.strPosition); var result = new BoundingBoxRenderer(bufferable, shaderCodes, map, new PolygonModeSwitch(PolygonModes.Lines), new PolygonOffsetFillSwitch()); result.halfLengths = new vec4(lengths / 2, 1.0f); result.OriginalWorldPosition = originalWorldPosition; result.ModelMatrix = glm.translate(mat4.identity(), originalWorldPosition); return(result); }
/// <summary> /// /// </summary> /// <param name="maxCharCount">Max char count to display for this label. /// Careful to set this value because greater <paramref name="maxCharCount"/> means more space ocupied in GPU nemory.</param> /// <param name="labelHeight">Label height(in pixels)</param> /// <param name="fontTexture">Use which font to render text?</param> public LabelRenderer(int maxCharCount = 64, int labelHeight = 32, IFontTexture fontTexture = null) : base(null, null, null, new BlendSwitch(BlendingSourceFactor.SourceAlpha, BlendingDestinationFactor.One)) { GLSwitch blendSwitch = this.SwitchList.Find(x => x is BlendSwitch); if (blendSwitch == null) { throw new Exception(); } this.blendSwitch = blendSwitch; if (fontTexture == null) { this.fontTexture = FontTexture.Default; } // FontResource.Default; } else { this.fontTexture = fontTexture; } this.LabelHeight = labelHeight; var model = new TextModel(maxCharCount); this.bufferable = model; this.model = model; var shaderCodes = new ShaderCode[2]; shaderCodes[0] = new ShaderCode(ManifestResourceLoader.LoadTextFile( @"Resources\Label.vert"), ShaderType.VertexShader); shaderCodes[1] = new ShaderCode(ManifestResourceLoader.LoadTextFile( @"Resources\Label.frag"), ShaderType.FragmentShader); this.shaderCodes = shaderCodes; var map = new PropertyNameMap(); map.Add("in_Position", TextModel.strPosition); map.Add("in_UV", TextModel.strUV); this.propertyNameMap = map; }
/// <summary> /// opengl UI for Axis /// </summary> /// <param name="anchor"></param> /// <param name="margin"></param> /// <param name="size"></param> /// <param name="zNear"></param> /// <param name="zFar"></param> public GLAxis( System.Windows.Forms.AnchorStyles anchor, System.Windows.Forms.Padding margin, System.Drawing.Size size, int zNear, int zFar) : base(null, anchor, margin, size, zNear, zFar) { this.Name = "GLAxis"; var shaderCodes = new ShaderCode[2]; shaderCodes[0] = new ShaderCode(ManifestResourceLoader.LoadTextFile( @"Resources.GLAxis.vert"), ShaderType.VertexShader); shaderCodes[1] = new ShaderCode(ManifestResourceLoader.LoadTextFile( @"Resources.GLAxis.frag"), ShaderType.FragmentShader); var map = new PropertyNameMap(); map.Add("in_Position", "position"); map.Add("in_Color", "color"); //PickableRenderer renderer = (new Axis()).GetRenderer(shaderCodes, map, "position"); PickableRenderer renderer = new PickableRenderer(new Axis(), shaderCodes, map, "position"); this.Renderer = renderer; }
/// <summary> /// 支持"拾取"的渲染器 /// </summary> /// <param name="bufferable">一种渲染方式</param> /// <param name="shaderCodes">各种类型的shader代码</param> /// <param name="propertyNameMap">关联<see cref="PropertyBufferPtr"/>和<see cref="shaderCode"/>中的属性</param> /// <param name="positionNameInIBufferable">描述顶点位置信息的buffer的名字</param> ///<param name="switches"></param> internal InnerPickableRenderer(IBufferable bufferable, ShaderCode[] shaderCodes, PropertyNameMap propertyNameMap, string positionNameInIBufferable, params GLSwitch[] switches) : base(bufferable, shaderCodes, propertyNameMap, switches) { { this.positionNameInIBufferable = positionNameInIBufferable; } { this.switchList.Add(polygonModeSwitch); } { float min, max; OpenGL.LineWidthRange(out min, out max); this.switchList.Add(new LineWidthSwitch(max)); } { float min, max; OpenGL.PointSizeRange(out min, out max); this.switchList.Add(new PointSizeSwitch(max)); } }
private TextureRenderer(IBufferable model, ShaderCode[] shaderCodes, AttributeMap attributeMap, string positionNameInIBufferable, params GLState[] switches) : base(model, shaderCodes, attributeMap, positionNameInIBufferable, switches) { }
/// <summary> /// renders well pipeline(several cylinders) /// </summary> /// <param name="model"></param> /// <param name="shaderCodes"></param> /// <param name="attributeMap"></param> /// <param name="switches"></param> private WellRenderer(WellModel model, ShaderCode[] shaderCodes, AttributeMap attributeMap, params GLState[] switches) : base(model, shaderCodes, attributeMap, switches) { }
public static WellRenderer Create(WellModel model) { var shaderCodes = new ShaderCode[2]; shaderCodes[0] = new ShaderCode(File.ReadAllText(@"shaders\Well.vert"), ShaderType.VertexShader); shaderCodes[1] = new ShaderCode(File.ReadAllText(@"shaders\Well.frag"), ShaderType.FragmentShader); var map = new AttributeMap(); map.Add("in_Position", WellModel.strPosition); map.Add("in_Brightness", WellModel.strBrightness); var renderer = new WellRenderer(model, shaderCodes, map); return renderer; }
/// <summary> /// get a bounding box renderer. /// </summary> /// <param name="lengths">bounding box's length at x, y, z direction.</param> /// <returns></returns> public static BoundingBoxRenderer Create(vec3 lengths) { var model = new BoundingBoxModel(lengths); var shaderCodes = new ShaderCode[2]; shaderCodes[0] = new ShaderCode(ManifestResourceLoader.LoadTextFile( @"Resources\BoundingBox.vert"), ShaderType.VertexShader); shaderCodes[1] = new ShaderCode(ManifestResourceLoader.LoadTextFile( @"Resources\BoundingBox.frag"), ShaderType.FragmentShader); var map = new AttributeMap(); map.Add("in_Position", BoundingBoxModel.strPosition); var result = new BoundingBoxRenderer(model, shaderCodes, map, new PolygonModeState(PolygonMode.Line), new PolygonOffsetFillState()); result.ModelSize = lengths; return result; }
/// <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; }
static GLPositionColorNode() { shaderCodes = new ShaderCode[2]; shaderCodes[0] = new ShaderCode(ManifestResourceLoader.LoadTextFile(@"Resources\Position.Color.vert"), ShaderType.VertexShader); shaderCodes[1] = new ShaderCode(ManifestResourceLoader.LoadTextFile(@"Resources\Position.Color.frag"), ShaderType.FragmentShader); }
private void mniLoadECLGrid_Click(object sender, EventArgs e) { if (openFileDialog1.ShowDialog() != DialogResult.OK) { return; } //ModelContainer modelContainer = this.ModelContainer; string fileName = openFileDialog1.FileName; SimulationInputData inputData; try { inputData = this.LoadEclInputData(fileName); } catch (Exception err) { MessageBox.Show(String.Format("Load Error,{0}", err.Message), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } try { List<GridBlockProperty> gridProps = inputData.RootDataFile.GetGridProperties(); GridBlockProperty gbp = gridProps[0]; double axisMin, axisMax, step; ColorIndicatorAxisAutomator.Automate(gbp.MinValue, gbp.MaxValue, out axisMin, out axisMax, out step); CatesianGrid grid = inputData.DumpCatesianGrid((float)axisMin, (float)axisMax); var shaderCodes = new ShaderCode[2]; shaderCodes[0] = new ShaderCode(File.ReadAllText(@"shaders\HexahedronGrid.vert"), ShaderType.VertexShader); shaderCodes[1] = new ShaderCode(File.ReadAllText(@"shaders\HexahedronGrid.frag"), ShaderType.FragmentShader); var map = new PropertyNameMap(); map.Add("in_Position", CatesianGrid.strPosition); map.Add("in_uv", CatesianGrid.strColor); var scientificRenderer = new Renderer(grid, shaderCodes, map); var boundedRenderer = new BoundedRenderer(scientificRenderer, grid.DataSource.SourceActiveBounds.Max - grid.DataSource.SourceActiveBounds.Min); boundedRenderer.Initialize(); SceneObject sceneObject = new SceneObject(); sceneObject.Name = typeof(CatesianGrid).Name; sceneObject.Renderer = new BoundedRendererComponent(boundedRenderer); //sceneObject.Transform.Position = grid.DataSource.TranslateMatrix; this.scientificCanvas.Scene.ObjectList.Add(sceneObject); //sceneObject.Renderer=ne //SimLabGrid gridder = null; //try //{ // gridderSource = CreateGridderSource(inputData); //} //catch (Exception err) //{ // MessageBox.Show(String.Format("Create Gridder Failed,{0}", err.Message), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); // return; //} //if (gridderSource != null) //{ // string caseFileName = System.IO.Path.GetFileName(fileName); // TreeNode gridderNode = this.objectsTreeView.Nodes.Add(caseFileName); // gridderNode.ToolTipText = fileName; // List<GridBlockProperty> gridProps = inputData.RootDataFile.GetGridProperties(); // if (gridProps.Count <= 0) // { // GridBlockProperty gbp = this.CreateGridSequenceGridBlockProperty(gridderSource, "INDEX"); // gridProps.Add(gbp); // } // foreach (GridBlockProperty gbp in gridProps) // { // TreeNode propNode = gridderNode.Nodes.Add(gbp.Name); // propNode.Tag = gbp; // } // vec3 boundMin; // vec3 boundMax; // gridder = CreateGridder(gridderSource, gridProps[0], out boundMin, out boundMax); // if (gridder != null) // { // this.objectsTreeView.ExpandAll(); // //modelContainer.AddChild(gridder); // //modelContainer.BoundingBox.SetBounds(gridderSource.TransformedActiveBounds.Min, gridderSource.TransformedActiveBounds.Max); // //this.scene.ViewType = ViewTypes.UserView; // gridderNode.Tag = gridder; // gridder.Tag = gridderSource; // gridderSource.Tag = gridderNode.Nodes[0]; // gridderNode.Checked = gridder.IsEnabled; // gridderNode.Nodes[0].Checked = true; // } //List<Well> well3dList; //try //{ // well3dList = this.CreateWell3D(inputData, this.scene, gridderSource); //} //catch (Exception err) //{ // MessageBox.Show(String.Format("Create Well3d,{0}", err.Message), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); // return; //} //if (well3dList != null && well3dList.Count > 0) // this.AddWellNodes(gridderNode, this.scene, well3dList); //} } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
private QuadStripRenderer(IBufferable model, ShaderCode[] shaderCodes, AttributeMap attributeMap, params GLState[] switches) : base(model, shaderCodes, attributeMap, switches) { }
/// <summary> /// 用glDrawElements进行渲染。 /// </summary> /// <param name="bufferable">一种渲染方式</param> /// <param name="shaderCodes">各种类型的shader代码</param> /// <param name="propertyNameMap">关联<see cref="PropertyBufferPtr"/>和<see cref="shaderCode"/>中的属性</param> /// <param name="positionNameInIBufferable">描述顶点位置信息的buffer的名字</param> ///<param name="switches"></param> internal OneIndexRenderer(IBufferable bufferable, ShaderCode[] shaderCodes, PropertyNameMap propertyNameMap, string positionNameInIBufferable, params GLSwitch[] switches) : base(bufferable, shaderCodes, propertyNameMap, positionNameInIBufferable, switches) { }
private CatesianGridRenderer(vec3 originalWorldPosition, CatesianGrid catesianGrid, ShaderCode[] shaderCodes, AttributeMap attributeMap, Texture codedColorSampler, params GLState[] switches) : base(originalWorldPosition, catesianGrid, shaderCodes, attributeMap, switches) { this.codedColorSampler = codedColorSampler; }