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 async Task RegVSAssets(string name) { VertexShader vertexShader = new VertexShader(); vertexShader.Initialize(await ReadFile(assetsUri + name)); VSAssets.Add(name, vertexShader); }
protected async Task ReloadVertexShader(VertexShader vertexShader, string uri) { vertexShader.Initialize(await ReadFile(uri)); }