public PropertyBufferPtr GetProperty(string bufferName, string varNameInShader) { if (bufferName == strPosition) { if (positionBufferPtr == null) { using (var buffer = new PropertyBuffer <GlyphPosition>(varNameInShader, 2, OpenGL.GL_FLOAT, BufferUsage.DynamicDraw)) { buffer.Alloc(maxCharCount); positionBufferPtr = buffer.GetBufferPtr() as PropertyBufferPtr; } } return(positionBufferPtr); } else if (bufferName == strUV) { if (uvBufferPtr == null) { using (var buffer = new PropertyBuffer <GlyphTexCoord>(varNameInShader, 2, OpenGL.GL_FLOAT, BufferUsage.DynamicDraw)) { buffer.Alloc(maxCharCount); uvBufferPtr = buffer.GetBufferPtr() as PropertyBufferPtr; } } return(uvBufferPtr); } else { throw new ArgumentException(); } }
public PropertyBufferPtr GetProperty(string bufferName, string varNameInShader) { if (bufferName == position) { if (!propertyBufferPtrDict.ContainsKey(bufferName)) { using (var buffer = new PropertyBuffer <vec3>( varNameInShader, 3, OpenGL.GL_FLOAT, BufferUsage.StaticDraw)) { buffer.Alloc(this.model.positions.Length); unsafe { var array = (vec3 *)buffer.Header.ToPointer(); for (int i = 0; i < this.model.positions.Length; i++) { array[i] = this.model.positions[i]; } } propertyBufferPtrDict.Add(bufferName, buffer.GetBufferPtr() as PropertyBufferPtr); } } return(propertyBufferPtrDict[bufferName]); } else if (bufferName == color) { if (!propertyBufferPtrDict.ContainsKey(bufferName)) { using (var buffer = new PropertyBuffer <vec3>( varNameInShader, 3, OpenGL.GL_FLOAT, BufferUsage.StaticDraw)) { buffer.Alloc(this.model.colors.Length); unsafe { var array = (vec3 *)buffer.Header.ToPointer(); for (int i = 0; i < this.model.colors.Length; i++) { array[i] = this.model.colors[i]; } } propertyBufferPtrDict.Add(bufferName, buffer.GetBufferPtr() as PropertyBufferPtr); } } return(propertyBufferPtrDict[bufferName]); } else { throw new NotImplementedException(); } }
public PropertyBufferPtr GetProperty(string bufferName, string varNameInShader) { if (bufferName == strPosition) { if (!propertyBufferPtrDict.ContainsKey(bufferName)) { using (var buffer = new PropertyBuffer <vec3>(varNameInShader, 3, OpenGL.GL_FLOAT, BufferUsage.StaticDraw)) { buffer.Alloc(model.positions.Count); unsafe { var array = (vec3 *)buffer.Header.ToPointer(); for (int i = 0; i < model.positions.Count; i++) { array[i] = model.positions[i]; } } propertyBufferPtrDict.Add(bufferName, buffer.GetBufferPtr() as PropertyBufferPtr); } } return(propertyBufferPtrDict[bufferName]); } else if (bufferName == strColor) { if (!propertyBufferPtrDict.ContainsKey(bufferName)) { using (var buffer = new PropertyBuffer <vec3>(varNameInShader, 3, OpenGL.GL_FLOAT, BufferUsage.StaticDraw)) { buffer.Alloc(model.normals.Count); unsafe { var array = (vec3 *)buffer.Header.ToPointer(); for (int i = 0; i < model.normals.Count; i++) { array[i] = model.normals[i]; } } propertyBufferPtrDict.Add(bufferName, buffer.GetBufferPtr() as PropertyBufferPtr); } } return(propertyBufferPtrDict[bufferName]); } else if (bufferName == strNormal) { if (!propertyBufferPtrDict.ContainsKey(bufferName)) { using (var buffer = new PropertyBuffer <vec3>(varNameInShader, 3, OpenGL.GL_FLOAT, BufferUsage.StaticDraw)) { buffer.Alloc(model.normals.Count); unsafe { var array = (vec3 *)buffer.Header.ToPointer(); for (int i = 0; i < model.normals.Count; i++) { array[i] = model.normals[i]; } } propertyBufferPtrDict.Add(bufferName, buffer.GetBufferPtr() as PropertyBufferPtr); } } return(propertyBufferPtrDict[bufferName]); } else { return(null); } }
public PropertyBufferPtr GetProperty(string bufferName, string varNameInShader) { if (bufferName == strPosition) { if (!propertyBufferPtrDict.ContainsKey(bufferName)) { using (var buffer = new PropertyBuffer <CubeModel.CubePosition>(varNameInShader, 3, OpenGL.GL_FLOAT, BufferUsage.StaticDraw)) { buffer.Alloc(1); unsafe { var positionArray = (CubeModel.CubePosition *)buffer.Header.ToPointer(); positionArray[0] = CubeModel.position; } propertyBufferPtrDict.Add(bufferName, buffer.GetBufferPtr() as PropertyBufferPtr); } } return(propertyBufferPtrDict[bufferName]); } else if (bufferName == strColor) { if (!propertyBufferPtrDict.ContainsKey(bufferName)) { using (var buffer = new PropertyBuffer <CubeModel.CubeColor>(varNameInShader, 3, OpenGL.GL_FLOAT, BufferUsage.StaticDraw)) { buffer.Alloc(1); unsafe { var colorArray = (CubeModel.CubeColor *)buffer.Header.ToPointer(); colorArray[0] = CubeModel.color; } propertyBufferPtrDict.Add(bufferName, buffer.GetBufferPtr() as PropertyBufferPtr); } } return(propertyBufferPtrDict[bufferName]); } else if (bufferName == strNormal) { if (!propertyBufferPtrDict.ContainsKey(bufferName)) { using (var buffer = new PropertyBuffer <CubeModel.CubeNormal>(varNameInShader, 3, OpenGL.GL_FLOAT, BufferUsage.StaticDraw)) { buffer.Alloc(1); unsafe { var normalArray = (CubeModel.CubeNormal *)buffer.Header.ToPointer(); normalArray[0] = CubeModel.normal; } propertyBufferPtrDict.Add(bufferName, buffer.GetBufferPtr() as PropertyBufferPtr); } } return(propertyBufferPtrDict[bufferName]); } else { return(null); } }