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


C++ ProgramObject::set_uniform1i方法代码示例

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


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

示例1: 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

示例2: draw_image

void App::draw_image(GraphicContext &gc, Texture &image, float xpos, float ypos, ProgramObject &program_object, Vec4f &draw_color_offset)
{
	program_object.set_uniform1i("SourceTexture", 0);
	program_object.set_uniform4f("color_offset", draw_color_offset);

	gc.set_texture(0, image);
	gc.set_program_object(program_object, cl_program_matrix_modelview_projection);

	draw_texture(gc, Rectf(xpos, ypos, Sizef(image.get_width(), image.get_height())), Colorf::white, Rectf(0.0f, 0.0f, 1.0f, 1.0f));

	gc.reset_program_object();
	gc.reset_texture(0);

}
开发者ID:,项目名称:,代码行数:14,代码来源:

示例3: create_shaders

void ShaderEffect_Impl::create_shaders(GraphicContext &gc, const ShaderEffectDescription_Impl *description)
{
	std::string vertex_shader_code = add_defines(gc, description->vertex_shader_code, description);
	std::string fragment_shader_code = add_defines(gc, description->fragment_shader_code, description);
	std::string compute_shader_code = add_defines(gc, description->compute_shader_code, description);

	if (!vertex_shader_code.empty()) 
	{
		ShaderObject vertex_shader(gc, shadertype_vertex, vertex_shader_code);
		if(!vertex_shader.compile())
			throw Exception(string_format("Unable to compile vertex shader: %1", vertex_shader.get_info_log()));
		program.attach(vertex_shader);
	}

	if (!fragment_shader_code.empty()) 
	{
		ShaderObject fragment_shader(gc, shadertype_fragment, fragment_shader_code);
		if(!fragment_shader.compile())
			throw Exception(string_format("Unable to compile fragment shader: %1", fragment_shader.get_info_log()));
		program.attach(fragment_shader);
	}

	if (!compute_shader_code.empty()) 
	{
		ShaderObject compute_shader(gc, shadertype_compute, compute_shader_code);
		if(!compute_shader.compile())
			throw Exception(string_format("Unable to compile compute shader: %1", compute_shader.get_info_log()));
		program.attach(compute_shader);
	}

	int index = 0;
	for(const auto & elem : description->attributes)
	{
		program.bind_attribute_location(index++, elem.first);
	}

	index = 0;
	for(const auto & elem : description->frag_data)
	{
		program.bind_frag_data_location(index++, elem.first);
	}

	if (!program.link())
		throw Exception(string_format("Link failed: %1", program.get_info_log()));

	index = 0;
	for(auto it = description->uniform_buffers.begin(); it != description->uniform_buffers.end(); ++it, index++)
	{
		program.set_uniform_buffer_index(it->first, index);
		uniform_bindings[index] = it->second;
	}

	index = 0;
	for(auto it = description->textures.begin(); it != description->textures.end(); ++it, index++)
	{
		program.set_uniform1i(it->first, index);
		texture_bindings[index] = it->second;
	}

	index = 0;
	for(auto it = description->images.begin(); it != description->images.end(); ++it, index++)
	{
		program.set_uniform1i(it->first, index);
		image_bindings[index] = it->second;
	}

	index = 0;
	for(auto it = description->storage_buffers.begin(); it != description->storage_buffers.end(); ++it, index++)
	{
		program.set_uniform1i(it->first, index);
		storage_bindings[index] = it->second;
	}

}
开发者ID:punkkeks,项目名称:ClanLib,代码行数:74,代码来源:shader_effect.cpp


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