Example #1
0
Shader::IProgramObject* CShaderHandler::CreateProgramObject(
	const std::string& poClass,
	const std::string& poName,
	const std::string& vsStr,
	const std::string& vsDefs,
	const std::string& fsStr,
	const std::string& fsDefs,
	bool arbProgram
) {
	Shader::IProgramObject* po = CreateProgramObject(poClass, poName, arbProgram);

	if (po->IsValid()) {
		return po;
	}

	Shader::IShaderObject* vso = CreateShaderObject(vsStr, vsDefs, (arbProgram? GL_VERTEX_PROGRAM_ARB: GL_VERTEX_SHADER));
	Shader::IShaderObject* fso = CreateShaderObject(fsStr, fsDefs, (arbProgram? GL_FRAGMENT_PROGRAM_ARB: GL_FRAGMENT_SHADER));

	po->AttachShaderObject(vso);
	po->AttachShaderObject(fso);
	po->Link();

	if (!po->IsValid()) {
		logOutput.Print("[CShaderHandler::CreateProgramObject]\n");
		logOutput.Print("\tprogram-object name: %s, link-log:\n%s\n", poName.c_str(), po->GetLog().c_str());
	}
	return po;
}
Example #2
0
Shader::IProgramObject* CShaderHandler::CreateProgramObject(
	const std::string& poClass,
	const std::string& poName,
	const std::string& vsStr,
	const std::string& vsDefs,
	const std::string& fsStr,
	const std::string& fsDefs,
	bool arbProgram
) {
	Shader::IProgramObject* po = CreateProgramObject(poClass, poName, arbProgram);

	if (po->IsValid()) {
		return po;
	}

	Shader::IShaderObject* vso = CreateShaderObject(vsStr, vsDefs, (arbProgram? GL_VERTEX_PROGRAM_ARB: GL_VERTEX_SHADER));
	Shader::IShaderObject* fso = CreateShaderObject(fsStr, fsDefs, (arbProgram? GL_FRAGMENT_PROGRAM_ARB: GL_FRAGMENT_SHADER));

	po->AttachShaderObject(vso);
	po->AttachShaderObject(fso);
	po->Link();
	po->Validate();

	if (!po->IsValid()) {
		const char* fmt = "[%s]\n\tprogram-object name: %s, link-log:\n%s";
		const char* log = po->GetLog().c_str();
		LOG_L(L_WARNING, fmt, __FUNCTION__, poName.c_str(), log);
	}
	return po;
}