Ejemplo n.º 1
0
 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");
 }