Example #1
0
	StandardPrograms::StandardPrograms(const GraphicContextPtr &gc) : impl(std::make_shared<StandardPrograms_Impl>())
	{
		auto color_only_program = compile(gc, color_only_vertex, sizeof(color_only_vertex), color_only_fragment, sizeof(color_only_fragment));
		color_only_program->bind_attribute_location(0, "VertexPosition");
		color_only_program->bind_attribute_location(1, "VertexColor");
		link(color_only_program, "Unable to link color-only standard program");
		color_only_program->set_uniform_buffer_index("Uniforms", 0);

		auto single_texture_program = compile(gc, single_texture_vertex, sizeof(single_texture_vertex), single_texture_fragment, sizeof(single_texture_fragment));
		single_texture_program->bind_attribute_location(0, "VertexPosition");
		single_texture_program->bind_attribute_location(1, "VertexColor");
		single_texture_program->bind_attribute_location(2, "VertexTexCoord");
		link(single_texture_program, "Unable to link single-texture standard program");
		single_texture_program->set_uniform_buffer_index("Uniforms", 0);
		single_texture_program->set_uniform1i("Texture0", 0);
		single_texture_program->set_uniform1i("Sampler0", 0);

		auto sprite_program = compile(gc, sprite_vertex, sizeof(sprite_vertex), sprite_fragment, sizeof(sprite_fragment));
		sprite_program->bind_attribute_location(0, "VertexPosition");
		sprite_program->bind_attribute_location(1, "VertexColor");
		sprite_program->bind_attribute_location(2, "VertexTexCoord");
		sprite_program->bind_attribute_location(3, "VertexTexIndex");
		link(sprite_program, "Unable to link sprite standard program");
		sprite_program->set_uniform_buffer_index("Uniforms", 0);
		sprite_program->set_uniform1i("Texture0", 0);
		sprite_program->set_uniform1i("Texture1", 1);
		sprite_program->set_uniform1i("Texture2", 2);
		sprite_program->set_uniform1i("Texture3", 3);
		sprite_program->set_uniform1i("Sampler0", 0);
		sprite_program->set_uniform1i("Sampler1", 1);
		sprite_program->set_uniform1i("Sampler2", 2);
		sprite_program->set_uniform1i("Sampler3", 3);

		auto path_program = compile(gc, path_vertex, sizeof(path_vertex), path_fragment, sizeof(path_fragment));
		path_program->bind_attribute_location(0, "Vertex");
		link(path_program, "Unable to link path standard program");
		path_program->set_uniform_buffer_index("Uniforms", 0);
		path_program->set_uniform1i("mask_texture", 0);
		path_program->set_uniform1i("mask_sampler", 0);
		path_program->set_uniform1i("instance_data", 1);
		path_program->set_uniform1i("image_texture", 2);
		path_program->set_uniform1i("image_sampler", 2);

		impl->color_only_program = color_only_program;
		impl->single_texture_program = single_texture_program;
		impl->sprite_program = sprite_program;
		impl->path_program = path_program;
	}
Example #2
0
void 
program::set_cubemap(char const* varname, cubemap& c, GLint unit) const
{
  c.bind(unit);
  set_uniform1i(varname, unit);
}
Example #3
0
void 
program::set_texturearray(char const* varname, texturearray& t, GLint unit) const
{
  t.bind(unit);
  set_uniform1i(varname, unit);
}