protected override void OnLoad()
        {
            // initialize shader (load sources, create/compile/link shader program, error checking)
            // when using the factory method the shader sources are retrieved from the ShaderSourceAttributes
            _program = ProgramFactory.Create <GravityProgram>();
            // this program will be used all the time so just activate it once and for all
            _program.Use();

            // create and bind a vertex array
            _vao = new VertexArray();
            _vao.Bind();

            // create and bind transform feedback object
            _feedback = new TransformFeedback();
            _feedback.Bind();

            // Writing to a buffer while reading from it is not allowed
            // so we need two buffer objects here, which can be achieved by using the BufferPod<T> type.
            // It contains two buffers, Ping and Pong, to simplify this process.
            _buffers = new BufferPod <Particle>();
            InitializeParticles(_particleCount);

            // enable point sprite rendering
            GL.Enable(EnableCap.PointSprite);
            // enable modification of the point sprite size from the program (vertex shader in this case)
            GL.Enable(EnableCap.ProgramPointSize);
            // enable depth testing
            GL.Enable(EnableCap.DepthTest);
            // set a nice clear color
            GL.ClearColor(Color.Black);

            // set a nice camera angle
            Camera.DefaultState.Position = new Vector3(0, 2, -8);
            Camera.ResetToDefault();
        }
Пример #2
0
        /// <summary> Called by render list and executes the operation </summary>
        public override void Execute(GLMatrixCalc c)
        {
            TransformFeedback.Bind();  // bind this transformfeedback to target transform feedback
            GLStatics.Check();

            // bind these buffer at offset/set and binding index starting at 0
            for (int i = 0; i < VaryingBuffers.Length; i++)
            {
                //System.Diagnostics.Debug.WriteLine($"TF {TransformFeedback.Id} bp {i} to buf {VaryingBuffers[i].Id}");
                VaryingBuffers[i].BindTransformFeedback(i, TransformFeedback.Id, Offsets == null ? 0 : Offsets[i], Sizes == null ? 0 : Sizes[i]);
            }

            GLStatics.Check();

            GLTransformFeedback.Begin(PrimitiveType);       // and start
            GLStatics.Check();
        }
Пример #3
0
        private void OnLoad(object sender, EventArgs e)
        {
            // initialize shader (load sources, create/compile/link shader program, error checking)
            // when using the factory method the shader sources are retrieved from the ShaderSourceAttributes

            var pathToShaders = "Data\\Shaders\\";
            var shaderExt     = ".glsl";
            var shaderCode    = File.ReadAllLines(pathToShaders + "Gravity2" + shaderExt);

            var vs = new Shader(shaderCode, ShaderType.VertexShader);

            // TODO Bind stuff

            GL.UseProgram(vs.Handle);

            var fs = GL.CreateShader(ShaderType.FragmentShader);

            // create and bind a vertex array
            _vao = new VertexArray();
            _vao.Bind();

            // create and bind transform feedback object
            _feedback = new TransformFeedback();
            _feedback.Bind();

            // Writing to a buffer while reading from it is not allowed
            // so we need two buffer objects here, which can be achieved by using the BufferPod<T> type.
            // It contains two buffers, Ping and Pong, to simplify this process.
            _buffers = new BufferPod <Particle>();
            InitializeParticles(_particleCount);

            // enable point sprite rendering
            GL.Enable(EnableCap.PointSprite);
            // enable modification of the point sprite size from the program (vertex shader in this case)
            GL.Enable(EnableCap.ProgramPointSize);
            // enable depth testing
            GL.Enable(EnableCap.DepthTest);
            // set a nice clear color
            GL.ClearColor(Color.Black);

            // set a nice camera angle
            Camera.DefaultState.Position = new Vector3(0, 2, -8);
            Camera.ResetToDefault();
        }
Пример #4
0
        private void OnLoad(object sender, EventArgs e)
        {
            // initialize shader (load sources, create/compile/link shader program, error checking)
            // when using the factory method the shader sources are retrieved from the ShaderSourceAttributes
            _program = ProgramFactory.Create<GravityProgram>();
            // this program will be used all the time so just activate it once and for all
            _program.Use();

            // create and bind a vertex array
            _vao = new VertexArray();
            _vao.Bind();

            // create and bind transform feedback object
            _feedback = new TransformFeedback();
            _feedback.Bind();

            // Writing to a buffer while reading from it is not allowed
            // so we need two buffer objects here, which can be achieved by using the BufferPod<T> type.
            // It contains two buffers, Ping and Pong, to simplify this process.
            _buffers = new BufferPod<Particle>();
            InitializeParticles(_particleCount);

            // enable point sprite rendering
            GL.Enable(EnableCap.PointSprite);
            // enable modification of the point sprite size from the program (vertex shader in this case)
            GL.Enable(EnableCap.ProgramPointSize);
            // enable depth testing
            GL.Enable(EnableCap.DepthTest);
            // set a nice clear color
            GL.ClearColor(Color.Black);

            // set a nice camera angle
            Camera.DefaultState.Position = new Vector3(0,2,-8);
            Camera.ResetToDefault();
        }