public CSharpGL.VertexAttributeBufferPtr GetVertexAttributeBufferPtr(string bufferName, string varNameInShader) { if ((bufferName == position)) { if ((positionBufferPtr == null)) { using (var buffer = new VertexAttributeBuffer <vec3>(varNameInShader, VertexAttributeConfig.Vec3, BufferUsage.StaticDraw)) {// begin of using buffer.Create(this.pointCount); unsafe { var random = new Random(); var array = (vec3 *)buffer.Header.ToPointer(); 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; } } positionBufferPtr = buffer.GetBufferPtr(); }// end of using } return(positionBufferPtr); } throw new System.ArgumentException("bufferName"); }
/// <summary> /// /// </summary> /// <param name="bufferName"></param> /// <param name="varNameInShader"></param> /// <returns></returns> public CSharpGL.VertexAttributeBufferPtr GetVertexAttributeBufferPtr(string bufferName, string varNameInShader) { if ((bufferName == strposition)) { if ((positionBufferPtr == null)) { using (var buffer = new VertexAttributeBuffer <vec3>(varNameInShader, VertexAttributeConfig.Vec3, BufferUsage.StaticDraw)) {// begin of using buffer.Create(this.pointPositions.Length); unsafe { var array = (vec3 *)buffer.Header.ToPointer(); for (int i = 0; i < this.pointPositions.Length; i++) { array[i] = this.pointPositions[i]; } } positionBufferPtr = buffer.GetBufferPtr(); }// end of using } return(positionBufferPtr); } throw new System.ArgumentException("bufferName"); }