public TransformFeedbackCalculator(int maxItemCount) { this.MaxItemCount = maxItemCount; var program = new ShaderProgram(); //program.Initialize(varyings, ShaderProgram.BufferMode.InterLeaved, vertexShader); var varyings = new string[] { "outValue" }; glTransformFeedbackVaryings(program.ProgramId, varyings.Length, varyings, GL.GL_INTERLEAVED_ATTRIBS); var vertexShader = new VertexShader(vertexCode); vertexShader.Initialize(); glAttachShader(program.ProgramId, vertexShader.ShaderId); glLinkProgram(program.ProgramId); program.CheckLinkStatus(); VertexBuffer vbo = VertexBuffer.Create(typeof(float), maxItemCount, VBOConfig.Float, BufferUsage.StaticDraw); var drawCmd = new DrawArraysCmd(DrawMode.Points, maxItemCount); var vao = new VertexArrayObject(drawCmd, program, new VertexShaderAttribute[] { new VertexShaderAttribute(vbo, "inValue") }); uint index = 0; VertexBuffer tbo = VertexBuffer.Create(typeof(float), maxItemCount, VBOConfig.Float, BufferUsage.StaticRead); glBindBufferBase(GL.GL_TRANSFORM_FEEDBACK_BUFFER, index, tbo.BufferId); { this.program = program; this.inputBuffer = vbo; this.outputBuffer = tbo; this.vao = vao; this.drawCommand = drawCmd; } }
protected override void DoInitialize() { base.DoInitialize(); { this.positionBuffer = this.RenderUnit.Methods[0].VertexArrayObjects[0].VertexAttributes[0].Buffer; this.drawCommand = this.RenderUnit.Methods[0].VertexArrayObjects[0].DrawCommand as DrawArraysCmd; } }
/// <summary> /// /// </summary> /// <returns></returns> public IEnumerable <IDrawCommand> GetDrawCommand() { if (this.drawCmd == null) { var buffer = new DrawArraysCmd(this.Mode, this.FirstVertex, this.VertexCount, this.PrimCount); this.drawCmd = buffer; } yield return(this.drawCmd); }
/// <summary> /// /// </summary> /// <returns></returns> public IEnumerable <IDrawCommand> GetDrawCommand() { if (this.drawCmd == null) { var drawCmd = new DrawArraysCmd(DrawMode.Quads, this.Capacity * 4); drawCmd.VertexCount = 0; this.drawCmd = drawCmd; } yield return(this.drawCmd); }
public IEnumerable <IDrawCommand> GetDrawCommand() { if (this.drawCmd == null) { if (faceList != null) { Face[] faces = faceList.ToArray(); IndexBuffer buffer = faces.GenIndexBuffer(IndexBufferElementType.UInt, BufferUsage.StaticDraw);//改为int以增大显示数量 this.drawCmd = new DrawElementsCmd(buffer, DrawMode.Triangles); } else { DrawArraysCmd buffer = new DrawArraysCmd(DrawMode.Points, VertexCount()); this.drawCmd = buffer; } } yield return(this.drawCmd); }
/// <summary> /// /// </summary> /// <param name="arg"></param> /// <param name="flatColorVertexId"></param> /// <param name="picker"></param> /// <returns></returns> internal override uint[] Search(PickingEventArgs arg, uint flatColorVertexId, DrawArraysPicker picker) { var cmd = picker.DrawCommand as DrawArraysCmd; // when the temp index buffer could be long, it's no longer needed. // what a great OpenGL API design! DrawArraysCmd drawCmd = new DrawArraysCmd(DrawMode.LineLoop, cmd.FirstVertex, cmd.RenderingVertexCount, cmd.InstanceCount, cmd.FrameCount); picker.Node.Render4InnerPicking(arg, IndexAccessMode.ByFrame, drawCmd); uint id = ColorCodedPicking.ReadStageVertexId(arg.X, arg.Y); if (id == cmd.FirstVertex) { return(new uint[] { (uint)(cmd.FirstVertex + cmd.RenderingVertexCount - 1), id, }); } else { return(new uint[] { id - 1, id, }); } }