public CSharpGL.VertexBuffer GetVertexAttributeBuffer(string bufferName, string varNameInShader) { if ((bufferName == position)) { if ((this.positionBuffer == null)) { int length = this.pointCount; VertexBuffer buffer = VertexBuffer.Create(typeof(vec3), length, VBOConfig.Vec3, varNameInShader, BufferUsage.StaticDraw); unsafe { var random = new Random(); IntPtr pointer = buffer.MapBuffer(MapBufferAccess.WriteOnly); var array = (vec3*)pointer; for (int i = 0; i < this.pointCount; i++) { array[i] = (new vec3((float)random.NextDouble(), (float)random.NextDouble(), (float)random.NextDouble()) - new vec3(0.5f, 0.5f, 0.5f)) * this.Lengths; } buffer.UnmapBuffer(); } this.positionBuffer = buffer; } return positionBuffer; } else { throw new System.ArgumentException("bufferName"); } }
public CSharpGL.VertexBuffer GetVertexAttributeBuffer(string bufferName, string varNameInShader) { if ((bufferName == position)) { if ((this.positionBuffer == null)) { //int length = this.pointPositions.Count; //VertexBuffer buffer = VertexBuffer.Create(typeof(vec3), length, VBOConfig.Vec3, varNameInShader, BufferUsage.StaticDraw); //unsafe //{ // IntPtr pointer = buffer.MapBuffer(MapBufferAccess.WriteOnly); // var array = (vec3*)pointer; // for (int i = 0; i < this.pointPositions.Count; i++) // { // array[i] = this.pointPositions[i]; // } // buffer.UnmapBuffer(); //} //this.positionBuffer = buffer; this.positionBuffer = this.pointPositions.ToArray().GenVertexBuffer(VBOConfig.Vec3, varNameInShader, BufferUsage.StaticDraw); } return this.positionBuffer; } throw new System.ArgumentException("bufferName"); }