public TerrainShader(IOpenGL33 gl) { vertexShader = new VertexShader(gl, GetEmbeddedResourceAsString("VertexShader.vs")); fragmentShader = new FragmentShader(gl, GetEmbeddedResourceAsString("FragmentShader.fs")); var p = new ModGL.ObjectModel.Shaders.Program(gl, vertexShader, fragmentShader); p.BindVertexAttributeLocations(PositionNormalTexCoord.Descriptor); // Bind output fragment to the specified nme gl.BindFragDataLocation(p.Handle, 0, "Color"); // Compile program and shaders p.Compile(); program = p; // Get the uniforms used by the shader program. diffuseUniform = p.GetUniform<Vector4fUniform, Vector4f>("DiffuseColor"); modelViewProjection = p.GetUniform<MatrixUniform, Matrix4f>("ModelViewProjection"); viewProjection = p.GetUniform<MatrixUniform, Matrix4f>("ViewProjection"); textureUnitUniform = p.GetUniform<IntUniform, int>("Texture"); }
public CubeShader(IOpenGL30 gl) { // Create the vertex shader vertexShader = new VertexShader(gl, GetEmbeddedResourceAsString("cube.vs")); // Create the fragmet shader fragmentShader = new FragmentShader(gl, GetEmbeddedResourceAsString("cube.fs")); // Create the program for both shaders var p = new ModGL.ObjectModel.Shaders.Program(gl, vertexShader, fragmentShader); // Tell the shader what field names to use (taken from the vertex Descriptor) p.BindVertexAttributeLocations(PositionNormalTexCoord.Descriptor); // Bind output fragment to the specified nme gl.BindFragDataLocation(p.Handle, 0, "Color"); // Compile program and shaders p.Compile(); program = p; // Get the uniforms used by the shader program. modelViewProjection = p.GetUniform<MatrixUniform, Matrix4f>("ModelViewProjection"); viewProjection = p.GetUniform<MatrixUniform, Matrix4f>("ViewProjection"); diffuseUniform = p.GetUniform<Vector4fUniform, Vector4f>("DiffuseColor"); }