/// <summary> /// /// </summary> /// <param name="bufferName"></param> /// <param name="varNameInShader"></param> /// <returns></returns> 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.Create(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.Create(maxCharCount); uvBufferPtr = buffer.GetBufferPtr() as PropertyBufferPtr; } } return(uvBufferPtr); } else { throw new ArgumentException(); } }
/// <summary> /// /// </summary> /// <param name="bufferName"></param> /// <param name="varNameInShader"></param> /// <returns></returns> public PropertyBufferPtr GetProperty(string bufferName, string varNameInShader) { if (bufferName == strPosition) { if (positionBufferPtr == null) { using (var buffer = new PropertyBuffer <vec3>(varNameInShader, 3, OpenGL.GL_FLOAT, BufferUsage.StaticDraw)) { buffer.Create(positions.Length); unsafe { var array = (vec3 *)buffer.Header.ToPointer(); for (int i = 0; i < positions.Length; i++) { array[i] = positions[i] / 2 * this.lengths; } } positionBufferPtr = buffer.GetBufferPtr() as PropertyBufferPtr; } } return(positionBufferPtr); } 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(); } }
/// <summary> /// /// </summary> /// <param name="bufferName"></param> /// <param name="varNameInShader"></param> /// <returns></returns> public PropertyBufferPtr GetProperty(string bufferName, string varNameInShader) { if (bufferName == strPosition) { if (positionBufferPtr == null) { using (var buffer = new PropertyBuffer <vec3>( varNameInShader, 3, OpenGL.GL_FLOAT, BufferUsage.StaticDraw)) { buffer.Create(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]; } } positionBufferPtr = buffer.GetBufferPtr() as PropertyBufferPtr; } } return(positionBufferPtr); } else if (bufferName == strColor) { if (colorBufferPtr == null) { using (var buffer = new PropertyBuffer <vec3>( varNameInShader, 3, OpenGL.GL_FLOAT, BufferUsage.StaticDraw)) { buffer.Create(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]; } } colorBufferPtr = buffer.GetBufferPtr() as PropertyBufferPtr; } } return(colorBufferPtr); } else { throw new NotImplementedException(); } }
/// <summary> /// /// </summary> /// <param name="bufferName"></param> /// <param name="varNameInShader"></param> /// <returns></returns> public PropertyBufferPtr GetProperty(string bufferName, string varNameInShader) { if (bufferName == strPosition) { if (positionBufferPtr == null) { using (var buffer = new PropertyBuffer <vec3>(varNameInShader, 3, OpenGL.GL_FLOAT, BufferUsage.StaticDraw)) { buffer.Create(model.positions.Length); unsafe { var array = (vec3 *)buffer.Header.ToPointer(); for (int i = 0; i < model.positions.Length; i++) { array[i] = model.positions[i]; } } positionBufferPtr = buffer.GetBufferPtr() as PropertyBufferPtr; } } return(positionBufferPtr); } else if (bufferName == strTexCoord) { if (uvBufferPtr == null) { using (var buffer = new PropertyBuffer <vec2>(varNameInShader, 2, OpenGL.GL_FLOAT, BufferUsage.StaticDraw)) { buffer.Create(model.texCoords.Length); unsafe { var array = (vec2 *)buffer.Header.ToPointer(); for (int i = 0; i < model.texCoords.Length; i++) { array[i] = model.texCoords[i]; } } uvBufferPtr = buffer.GetBufferPtr() as PropertyBufferPtr; } } return(uvBufferPtr); } else { return(null); } }
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); } }
/// <summary> /// /// </summary> /// <param name="bufferName"></param> /// <param name="varNameInShader"></param> /// <returns></returns> public PropertyBufferPtr GetProperty(string bufferName, string varNameInShader) { if (bufferName == strPosition) { if (positionBufferPtr == null) { using (var buffer = new PropertyBuffer <vec3>(varNameInShader, 3, OpenGL.GL_FLOAT, BufferUsage.StaticDraw)) { buffer.Create(TetrahedronModel.position.Length); unsafe { var array = (vec3 *)buffer.Header.ToPointer(); for (int i = 0; i < TetrahedronModel.position.Length; i++) { array[i] = TetrahedronModel.position[i]; } } positionBufferPtr = buffer.GetBufferPtr() as PropertyBufferPtr; } } return(positionBufferPtr); } else if (bufferName == strColor) { if (colorBufferPtr == null) { using (var buffer = new PropertyBuffer <vec3>(varNameInShader, 3, OpenGL.GL_FLOAT, BufferUsage.StaticDraw)) { buffer.Create(TetrahedronModel.color.Length); unsafe { var array = (vec3 *)buffer.Header.ToPointer(); for (int i = 0; i < TetrahedronModel.color.Length; i++) { array[i] = TetrahedronModel.color[i]; } } colorBufferPtr = buffer.GetBufferPtr() as PropertyBufferPtr; } } return(colorBufferPtr); } else if (bufferName == strNormal) { if (normalBufferPtr == null) { using (var buffer = new PropertyBuffer <vec3>(varNameInShader, 3, OpenGL.GL_FLOAT, BufferUsage.StaticDraw)) { buffer.Create(TetrahedronModel.normal.Length); unsafe { var array = (vec3 *)buffer.Header.ToPointer(); for (int i = 0; i < TetrahedronModel.normal.Length; i++) { array[i] = TetrahedronModel.normal[i]; } } normalBufferPtr = buffer.GetBufferPtr() as PropertyBufferPtr; } } return(normalBufferPtr); } 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); } }
/// <summary> /// /// </summary> /// <param name="bufferName"></param> /// <param name="varNameInShader"></param> /// <returns></returns> public PropertyBufferPtr GetProperty(string bufferName, string varNameInShader) { if (bufferName == strPosition) { if (positionBufferPtr == null) { using (var buffer = new PropertyBuffer <float>(varNameInShader, 3, OpenGL.GL_FLOAT, BufferUsage.StaticDraw)) { float[] positions = model.GetPositions(); buffer.Create(positions.Length); unsafe { var array = (float *)buffer.Header.ToPointer(); for (int i = 0; i < positions.Length; i++) { array[i] = positions[i]; } } positionBufferPtr = buffer.GetBufferPtr() as PropertyBufferPtr; } } return(positionBufferPtr); } else if (bufferName == strColor) { if (colorBufferPtr == null) { using (var buffer = new PropertyBuffer <float>(varNameInShader, 3, OpenGL.GL_FLOAT, BufferUsage.StaticDraw)) { float[] normals = model.GetNormals(); buffer.Create(normals.Length); unsafe { var array = (float *)buffer.Header.ToPointer(); for (int i = 0; i < normals.Length; i++) { array[i] = normals[i]; } } colorBufferPtr = buffer.GetBufferPtr() as PropertyBufferPtr; } } return(colorBufferPtr); } else if (bufferName == strNormal) { if (normalBufferPtr == null) { using (var buffer = new PropertyBuffer <float>(varNameInShader, 3, OpenGL.GL_FLOAT, BufferUsage.StaticDraw)) { float[] normals = model.GetNormals(); buffer.Create(normals.Length); unsafe { var array = (float *)buffer.Header.ToPointer(); for (int i = 0; i < normals.Length; i++) { array[i] = normals[i]; } } normalBufferPtr = buffer.GetBufferPtr() as PropertyBufferPtr; } } return(normalBufferPtr); } else { return(null); } }
/// <summary> /// /// </summary> /// <param name="bufferName"></param> /// <param name="varNameInShader"></param> /// <returns></returns> public PropertyBufferPtr GetProperty(string bufferName, string varNameInShader) { if (bufferName == strPosition) { if (positionBufferPtr == null) { using (var buffer = new PropertyBuffer <CubeModel.CubePosition>(varNameInShader, 3, OpenGL.GL_FLOAT, BufferUsage.StaticDraw)) { buffer.Create(1); unsafe { var positionArray = (CubeModel.CubePosition *)buffer.Header.ToPointer(); positionArray[0] = CubeModel.position; } positionBufferPtr = buffer.GetBufferPtr() as PropertyBufferPtr; } } return(positionBufferPtr); } else if (bufferName == strColor) { if (colorBufferPtr == null) { using (var buffer = new PropertyBuffer <CubeModel.CubeColor>(varNameInShader, 3, OpenGL.GL_FLOAT, BufferUsage.StaticDraw)) { buffer.Create(1); unsafe { var colorArray = (CubeModel.CubeColor *)buffer.Header.ToPointer(); colorArray[0] = CubeModel.color; } colorBufferPtr = buffer.GetBufferPtr() as PropertyBufferPtr; } } return(colorBufferPtr); } else if (bufferName == strNormal) { if (normalBufferPtr == null) { using (var buffer = new PropertyBuffer <CubeModel.CubeNormal>(varNameInShader, 3, OpenGL.GL_FLOAT, BufferUsage.StaticDraw)) { buffer.Create(1); unsafe { var normalArray = (CubeModel.CubeNormal *)buffer.Header.ToPointer(); normalArray[0] = CubeModel.normal; } normalBufferPtr = buffer.GetBufferPtr() as PropertyBufferPtr; } } return(normalBufferPtr); } else { return(null); } }