void 
GlProgram::setUniforms() {

	int i,index,len,size;
	
	unsigned int type;
	char *name = new char [m_MaxLength + 1]; 
	GlUniform uni;

	// set all types = NOT_USED
	std::vector<GlUniform>::iterator it;
	for(it = m_Uniforms.begin(); it != m_Uniforms.end(); it++) {
		it->setType(GlUniform::NOT_USED);
	}

	// add new uniforms and reset types for previous uniforms
	
	for (i = 0; i < m_NumUniforms; i++) {

		glGetActiveUniform (m_P, i, m_MaxLength, &len, &size, &type, name);
		std::string n (name);


		index = findUniform (n);
		if (-1 != index) {
			m_Uniforms[index].setType (type);
			m_Uniforms[index].setLoc (i);
		}
		else {
			uni.reset();
            std::string ProgName (name); 
			uni.setName (ProgName);
			uni.setType (type);
			uni.setLoc (i);
			m_Uniforms.push_back (uni);
		}

		if (size > 1) {

			for (int i = 0; i < size; i++) {
				std::stringstream s;

				s << n.c_str() << "[" << i << "]";
                                				
                std::string Location = s.str();                                 

				index = findUniform (Location);
				
				int loc;

				loc = glGetUniformLocation(m_P, s.str().c_str());

				if (-1 != index) {
					m_Uniforms[index].setType (type);
					m_Uniforms[index].setLoc (loc);
				}
				else {
					uni.reset();
                    std::string ProgName (s.str());
                    uni.setName (ProgName);
					uni.setType (type);
					uni.setLoc (loc);
					m_Uniforms.push_back (uni);
				}
			}
		}

	}

	// delete all uniforms where type is NOT_USED
	for(it = m_Uniforms.begin(), i = 0; it != m_Uniforms.end(); i++ ) {
		if (it->getType() == GlUniform::NOT_USED) {
			it = m_Uniforms.erase(it);
		} else {
			++it;
		}
	}
	m_NumUniforms = m_Uniforms.size();
	for (int i = 0; i < m_NumUniforms; i++) {
		setValueOfUniform (i);
	}
}