Пример #1
0
 protected override void DoInitialize()
 {
     {
         // particleSimulator-fountain.comp is also OK.
         var shaderCode = new ShaderCode(File.ReadAllText(@"shaders\ParticleSimulatorRenderer\particleSimulator.comp"), ShaderType.ComputeShader);
         this.computeProgram = shaderCode.CreateProgram();
     }
     {
         BufferPtr bufferPtr = this.positionBufferPtr;
         Texture   texture   = bufferPtr.DumpBufferTexture(OpenGL.GL_RGBA32F, autoDispose: false);
         texture.Initialize();
         this.positionTexture = texture;
     }
     {
         BufferPtr bufferPtr = this.velocityBufferPtr;
         Texture   texture   = bufferPtr.DumpBufferTexture(OpenGL.GL_RGBA32F, autoDispose: false);
         texture.Initialize();
         this.velocityTexture = texture;
     }
     {
         IndependentBufferPtr bufferPtr = null;
         using (var buffer = new UniformBuffer <vec4>(BufferUsage.DynamicCopy, noDataCopyed: true))
         {
             buffer.Create(elementCount: 64);
             bufferPtr = buffer.GetBufferPtr();
         }
         bufferPtr.Bind();
         OpenGL.BindBufferBase((BindBufferBaseTarget)BufferTarget.UniformBuffer, 0, bufferPtr.BufferId);
         this.attractorBufferPtr = bufferPtr;
         bufferPtr.Unbind();
     }
 }
Пример #2
0
        /// <summary>
        ///
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="internalFormat"></param>
        /// <param name="elementCount"></param>
        /// <param name="usage"></param>
        /// <param name="noDataCopyed"></param>
        /// <returns></returns>
        public static Texture CreateBufferTexture <T>(uint internalFormat, int elementCount, BufferUsage usage, bool noDataCopyed = false) where T : struct
        {
            var buffer = new TextureBuffer <T>(usage, noDataCopyed);

            buffer.Create(elementCount);
            BufferPtr bufferPtr = buffer.GetBufferPtr();

            return(bufferPtr.DumpBufferTexture(internalFormat, autoDispose: true));
        }
Пример #3
0
        /// <summary>
        /// Dump a <see cref="Texture"/> filled with this <see cref="BufferPtr"/>.
        /// </summary>
        /// <param name="bufferPtr"></param>
        /// <param name="internalFormat"></param>
        /// <param name="autoDispose">Dispose <paramref name="bufferPtr"/> when disposing returned texture.</param>
        /// <returns></returns>
        public static Texture DumpBufferTexture(this BufferPtr bufferPtr, uint internalFormat, bool autoDispose)
        {
            var texture = new Texture(TextureTarget.TextureBuffer,
                                      new TexBufferImageFiller(internalFormat, bufferPtr, autoDispose),
                                      new NullSampler());

            texture.Initialize();
            return(texture);
        }
Пример #4
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="internalFormat"></param>
 /// <param name="bufferPtr"></param>
 /// <param name="autoDispose">Dispose <paramref name="bufferPtr"/> when disposing returned texture.</param>
 /// <returns></returns>
 public static Texture CreateBufferTexture(uint internalFormat, BufferPtr bufferPtr, bool autoDispose)
 {
     return(bufferPtr.DumpBufferTexture(internalFormat, autoDispose));
 }
Пример #5
0
 public ParticleComputeRenderer(BufferPtr positionBufferPtr, BufferPtr velocityBufferPtr)
 {
     this.positionBufferPtr = positionBufferPtr;
     this.velocityBufferPtr = velocityBufferPtr;
 }