Ejemplo n.º 1
0
void Shader::Compile() {
	Timer timer;
	timer.Start();
	glLinkProgram(_programID);

	i32 programStatus;
	glGetProgramiv(_programID, GL_LINK_STATUS, &programStatus);

	if (programStatus == GL_FALSE) {
		c8 log[1024];
		glGetProgramInfoLog(_programID, 1024, NULL, log);
		Logger::Error("Shader program failed to compile: %s", &log);
	}

	glValidateProgram(_programID);

	glGetProgramiv(_programID, GL_VALIDATE_STATUS, &programStatus);

	if (programStatus == GL_FALSE) {
		c8 log[1024];
		glGetProgramInfoLog(_programID, 1024, NULL, log);
		Logger::Error("Shader program failed to validate: %s", &log);
	}

	for (auto& str : _uniformsToAdd) {
		RegisterUniform(str);
	}
	_uniformsToAdd.clear();

	for (auto& attribute : _attributesToAdd) {
		SetAttribLocation(attribute.first.c_str(), attribute.second);
	}
	_attributesToAdd.clear();

	_structs.clear();
	Logger::Info("Shader compiled in %.3fms", timer.DeltaMS());
}