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(); } { GLBuffer buffer = this.positionBuffer; Texture texture = buffer.DumpBufferTexture(OpenGL.GL_RGBA32F, autoDispose: false); texture.Initialize(); this.positionTexture = texture; } { GLBuffer buffer = this.velocityBuffer; Texture texture = buffer.DumpBufferTexture(OpenGL.GL_RGBA32F, autoDispose: false); texture.Initialize(); this.velocityTexture = texture; } { const int length = 64; UniformBuffer buffer = UniformBuffer.Create(typeof(vec4), length, BufferUsage.DynamicCopy); buffer.Bind(); OpenGL.BindBufferBase((BindBufferBaseTarget)BufferTarget.UniformBuffer, 0, buffer.BufferId); buffer.Unbind(); this.attractorBuffer = buffer; OpenGL.CheckError(); } }
public void UpdatePointLights(List <PointLight> lights) { var lightData = _lightDataMapper.GetPointLightData(lights, maxNumOfPointLights); if (lightsBuffer.Size < lightData.TotalSizeInBytes) { lightsBuffer.Resize(lightData.TotalSizeInBytes); } lightsBuffer.UpdateData(0, Marshal.SizeOf <LightAdditionalInfo>(), ref lightData.AdditionalInfo); lightsBuffer.UpdateData(Marshal.OffsetOf(typeof(CompletePointLightData), "LightData").ToInt32(), Marshal.SizeOf <PointLightData>() * lightData.LightData.Length, lightData.LightData); lightsBuffer.Bind(); }