当前位置: 首页>>代码示例>>C++>>正文


C++ GraphicContext::get_shader_language方法代码示例

本文整理汇总了C++中GraphicContext::get_shader_language方法的典型用法代码示例。如果您正苦于以下问题:C++ GraphicContext::get_shader_language方法的具体用法?C++ GraphicContext::get_shader_language怎么用?C++ GraphicContext::get_shader_language使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在GraphicContext的用法示例。


在下文中一共展示了GraphicContext::get_shader_language方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: add_defines

std::string ShaderEffect_Impl::add_defines(GraphicContext &gc, const std::string * const code, const ShaderEffectDescription_Impl *description)
{
	if (code[gc.get_shader_language()].empty())
		return std::string();

	std::string prefix;
	if (gc.get_shader_language() == shader_glsl && description->glsl_version != 0)
		prefix += string_format("#version %1\r\n", description->glsl_version);

	for (const auto & elem : description->defines)
		prefix += string_format("#define %1 %2\r\n", elem.first, elem.second);
	prefix += "#line 0\r\n";

	return prefix + code[gc.get_shader_language()];
}
开发者ID:punkkeks,项目名称:ClanLib,代码行数:15,代码来源:shader_effect.cpp

示例2: vertex_shader

Shader::Shader(GraphicContext &gc)
{
	ShaderLanguage shader_language = gc.get_shader_language();
	ShaderObject vertex_shader(gc, shadertype_vertex, shader_language==shader_glsl ? vertex_glsl : vertex_hlsl);
	if(!vertex_shader.compile())
	{
		std::string log = vertex_shader.get_info_log();
		throw Exception(string_format("Unable to compile vertex shader object: %1", log));
	}

	ShaderObject fragment_shader(gc, shadertype_fragment, shader_language==shader_glsl ? fragment_glsl : fragment_hlsl);
	if(!fragment_shader.compile())
	{
		std::string log = fragment_shader.get_info_log();
		throw Exception(string_format("Unable to compile fragment shader object: %1", log));
	}

	program_object = ProgramObject(gc);
	program_object.attach(vertex_shader);
	program_object.attach(fragment_shader);
	program_object.bind_attribute_location(0, "InPosition");
	program_object.bind_attribute_location(1, "InNormal");
	program_object.bind_attribute_location(2, "InMaterialAmbient");
	program_object.bind_frag_data_location(0, "cl_FragColor");
	if (!program_object.link())
	{
		throw Exception(string_format("Unable to link program object: %1", program_object.get_info_log()));
	}

	program_object.set_uniform_buffer_index("ProgramUniforms", 0);

	gpu_uniforms = clan::UniformVector<ProgramUniforms>(gc, 1);

	uniforms.LightAmbient = Vec4f(0.2f, 0.2f, 0.2f, 1.0f);
	uniforms.LightVector = Vec3f(0.0f, 0.0f, -1.0f);
	uniforms.LightDiffuse = Vec4f(0.7f, 0.7f, 0.7f, 1.0f);

}
开发者ID:ARMCoderCHS,项目名称:ClanLib,代码行数:38,代码来源:shader.cpp

示例3: compile_and_link

ProgramObject LightsourceSimplePass::compile_and_link(GraphicContext &gc, const std::string &shader_path, const std::string &type)
{
	ProgramObject program;

	std::string vertex_filename = PathHelp::combine(shader_path, string_format("LightsourceSimple/vertex_%1.%2", type, gc.get_shader_language() == shader_glsl ? "glsl" : "hlsl"));
	std::string fragment_filename = PathHelp::combine(shader_path, string_format("LightsourceSimple/fragment_light.%1", gc.get_shader_language() == shader_glsl ? "glsl" : "hlsl"));

	program = ShaderSetup::compile(gc, "", vertex_filename, fragment_filename, type == "rect" ? "RECT_PASS" : "");

	program.bind_frag_data_location(0, "FragColor");

	if (!program.link())
		throw Exception("Shader linking failed!");

	program.bind_attribute_location(0, "AttrPositionInObject");
	program.set_uniform_buffer_index("Uniforms", 0);
	program.set_uniform1i("InstanceTexture", 0);
	program.set_uniform1i("NormalZTexture", 1);
	program.set_uniform1i("DiffuseColorTexture", 2);
	program.set_uniform1i("SpecularColorTexture", 3);
	program.set_uniform1i("SpecularLevelTexture", 4);
	program.set_uniform1i("ShadowMapsTexture", 5);
	program.set_uniform1i("ShadowMapsTextureSampler", 5);
	program.set_uniform1i("SelfIlluminationTexture", 6);

	return program;
}
开发者ID:Cassie90,项目名称:ClanLib,代码行数:27,代码来源:lightsource_simple_pass.cpp


注:本文中的GraphicContext::get_shader_language方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。