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(); }
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(); }
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(); }