void loadProgram(Program &p, const std::string& name) {

		//Initializes a Program object
		p.create();

		//Gets the path to the vertex shader (ending in ".vsh")
		string sv = rh.pathToResource(name, "vsh");
		// cout << "path of vertex shader is: " << sv << endl;

		//Compiles the vertex shader and attaches it to our Program object
		p.attach(rh.contentsOfFile(sv), GL_VERTEX_SHADER);

		//Binds attribute variables to a particular ID
		glBindAttribLocation(p.id(), posLoc, "vertexPosition");
		glBindAttribLocation(p.id(), colLoc, "vertexColor");


		//Gets the path to the fragment shader (ending in ".fsh")
		string sp = rh.pathToResource(name, "fsh");
		// cout << "path of vertex shader is: " << sp << endl;

		//Compiles the fragment shader and attaches it to our Program object
		p.attach(rh.contentsOfFile(sp), GL_FRAGMENT_SHADER);

		//Links the Program object to the GPU so that it can be activated when needed
		p.link();
	}
Exemple #2
0
  void loadProgram(Program &p, const std::string& name) {

    //can't link shaders unless a vao is bound...
    //bindDefaultVAO();

    p.create();

    string sv = rh.pathToResource(name, "vsh");

    p.attach(rh.contentsOfFile(sv), GL_VERTEX_SHADER);

    glBindAttribLocation(p.id(), posLoc, "vertexPosition");
    glBindAttribLocation(p.id(), texCoordLoc, "vertexTexCoord");


    string sg = rh.pathToResource(name, "gsh");
    cout << "path of vertex shader is: " << sg << endl;

    p.attach(rh.contentsOfFile(sg), GL_GEOMETRY_SHADER);

    string sp = rh.pathToResource(name, "fsh");

    p.attach(rh.contentsOfFile(sp), GL_FRAGMENT_SHADER);

    p.link();
  }