Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Console.WriteLine(GL.GetString(StringName.Vendor));
- Console.WriteLine(GL.GetString(StringName.Renderer));
- Console.WriteLine(GL.GetString(StringName.Version));
- Console.WriteLine(GL.GetString(StringName.ShadingLanguageVersion));
- const string shaderSource =
- #region source
- @"
- #version 150
- uniform sampler2D accelerationTexture;
- uniform float timeDelta;
- in vec3 v_position;
- in vec3 v_velocity;
- in float v_deathTime;
- in float v_angle;
- in float v_angleVelocity;
- in vec2 v_size;
- in vec2 v_uv00;
- in vec2 v_uv10;
- in vec2 v_uv01;
- in vec2 v_uv11;
- in vec3 v_unitX;
- in vec3 v_unitY;
- out vec3 t_position;
- out vec3 t_velocity;
- out float t_deathTime;
- out float t_angle;
- out float t_angleVelocity;
- out vec2 t_size;
- out vec2 t_uv00;
- out vec2 t_uv10;
- out vec2 t_uv01;
- out vec2 t_uv11;
- out vec3 t_unitX;
- out vec3 t_unitY;
- void main()
- {
- const float width = 40;
- const float height = 25;
- const float xOffset = width * 0.5;
- const float yOffset = 3;
- vec2 aUV = v_position.xy;
- aUV.x = (aUV.x + xOffset) / width;
- aUV.y = (aUV.y + yOffset) / height;
- vec2 a = texture(accelerationTexture, aUV).xy;
- vec3 v = v_velocity;
- v.xy += a;
- t_position = v_position + v * timeDelta;
- t_velocity = v;
- t_deathTime = v_deathTime;
- t_angle = v_angle + v_angleVelocity * timeDelta;
- t_angleVelocity = v_angleVelocity;
- t_size = v_size;
- t_uv00 = v_uv00;
- t_uv10 = v_uv10;
- t_uv01 = v_uv01;
- t_uv11 = v_uv11;
- t_unitX = v_unitX;
- t_unitY = v_unitY;
- }
- ";
- #endregion
- string[] varyings =
- #region varyings
- {
- "t_position",
- "t_velocity",
- "t_deathTime",
- "t_angle",
- "t_angleVelocity",
- "t_size",
- "t_uv00",
- "t_uv10",
- "t_uv01",
- "t_uv11",
- "t_unitX",
- "t_unitY",
- };
- #endregion
- var vs = GL.CreateShader(ShaderType.VertexShader);
- #region compile shader
- GL.ShaderSource(vs, shaderSource);
- GL.CompileShader(vs);
- int statusCode;
- GL.GetShader(vs, ShaderParameter.CompileStatus, out statusCode);
- if (statusCode != 1)
- {
- string info;
- GL.GetShaderInfoLog(vs, out info);
- Console.WriteLine("Could not compile shader: " + info);
- }
- else
- {
- Console.WriteLine("Compiled shader.");
- }
- #endregion
- var p = GL.CreateProgram();
- #region create program
- GL.AttachShader(p, vs);
- GL.TransformFeedbackVaryings(p, varyings.Length, varyings,
- TransformFeedbackMode.InterleavedAttribs);
- GL.LinkProgram(p);
- GL.GetProgram(p, GetProgramParameterName.LinkStatus, out statusCode);
- if (statusCode != 1)
- {
- string info;
- GL.GetProgramInfoLog(p, out info);
- Console.WriteLine("Could not link program: " + info);
- }
- else
- {
- Console.WriteLine("Linked program.");
- }
- #endregion
- #region GetProgramInterface
- int i = 0;
- GL.GetProgramInterface(p, ProgramInterface.TransformFeedbackVarying,
- ProgramInterfaceParameter.MaxNameLength, out i);
- Console.WriteLine("MaxNameLength: " + i);
- Console.WriteLine(GL.GetError());
- GL.GetProgramInterface(p, ProgramInterface.TransformFeedbackVarying,
- ProgramInterfaceParameter.ActiveResources, out i);
- Console.WriteLine("ActiveResources: " + i);
- Console.WriteLine(GL.GetError());
- #endregion
- Console.WriteLine("all done");
- Console.WriteLine(GL.GetError());
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement