Ejemplo n.º 1
0
 public void BindVertexBuffer(VertexBuffer buffer)
 {
     forwarding.BindVertexBuffer(buffer);
     CheckGLError();
     GLCALLS++;
 }
Ejemplo n.º 2
0
        private void SetupShaderProgram(ref Matrix4 projection, ShaderProgram program)
        {
            IGraphicsContext context = program.GraphicsContext;

            context.UseShaderProgram(program);

            program.SetUniform(PROJ_MAT, ref projection);
            program.SetUniform(FORCES, ref this.settings.Forces);

            program.SetUniform(START_COLOR, settings.StartColor);
            program.SetUniform(END_COLOR, settings.EndColor);
            program.SetUniform(START_SIZE, settings.StartSize);
            program.SetUniform(END_SIZE, settings.EndSize);
            program.SetUniform(START_ANGULAR_VELOCITY, settings.StartAngularVelocity);
            program.SetUniform(END_ANGULAR_VELOCITY, settings.EndAngularVelocity);
            program.SetUniform(COLOR_VARIANCE, settings.ColorVariance);
            program.SetUniform(SIZE_VARIANCE, settings.SizeVariance);

            Vector3 g = new Vector3(500, 500, -0);

            program.SetUniform("gravity_well_1", ref g);
            g = new Vector3(1550, 500, 0);
            program.SetUniform("gravity_well_2", ref g);


            program.SetUniform(START_ALPHA, 1.5f);
            program.SetUniform(END_ALPHA, 0f);

            program.SetUniform(LIFE_TIME, settings.LifeTime);
            program.SetUniform(CURRENT_TIME, this.currentTime);

            program.SetUniform(TEXTURE, 0);


            GL.BindVertexArray(this.vba);

            int posIndex    = program.GetAttributeLocation(IN_POS);
            int veloIndex   = program.GetAttributeLocation(IN_VEL);
            int randomIndex = program.GetAttributeLocation(IN_RANDOM);
            int offsetIndex = program.GetAttributeLocation(IN_OFFSET);
            int coordIndex  = program.GetAttributeLocation(IN_COORDS);
            int timeIndex   = program.GetAttributeLocation(IN_TIME);



            context.BindVertexBuffer(this.vertexBuffer);

            context.EnableVertexAttribArray(posIndex);
            context.EnableVertexAttribArray(veloIndex);
            context.EnableVertexAttribArray(randomIndex);
            context.EnableVertexAttribArray(offsetIndex);
            context.EnableVertexAttribArray(coordIndex);
            context.EnableVertexAttribArray(timeIndex);

            context.VertexAttribPointer(posIndex, 2, VertexAttribPointerType.Float,
                                        false, this.queue[0].SizeInBytes, 0);

            context.VertexAttribPointer(veloIndex, 2, VertexAttribPointerType.Float,
                                        false, this.queue[0].SizeInBytes, Vector2.SizeInBytes);

            context.VertexAttribPointer(randomIndex, 2, VertexAttribPointerType.Float,
                                        false, this.queue[0].SizeInBytes, Vector2.SizeInBytes * 2);


            context.VertexAttribPointer(offsetIndex, 2, VertexAttribPointerType.Float,
                                        false, this.queue[0].SizeInBytes, Vector2.SizeInBytes * 3);


            context.VertexAttribPointer(coordIndex, 2, VertexAttribPointerType.Float,
                                        false, this.queue[0].SizeInBytes, Vector2.SizeInBytes * 4);


            context.VertexAttribPointer(timeIndex, 1, VertexAttribPointerType.Float,
                                        false, this.queue[0].SizeInBytes, Vector2.SizeInBytes * 5);


            GL.BindVertexArray(0);
        }