Exemplo n.º 1
0
std::shared_ptr<TextSurface>
TextSurface::create(const std::string& text, const TextProperties& text_props)
{
  Cairo::TextExtents text_extents;
  Cairo::FontExtents font_extents;

  Cairo::RefPtr<Cairo::ImageSurface> surface = create_cairo_surface(text, text_props,
                                                                    text_extents, font_extents);
  int width  = surface->get_width();
  int height = surface->get_height();
  TexturePtr texture = create_opengl_texture(surface);

  MaterialPtr material = std::make_shared<Material>();

  material->set_program(Program::create(Shader::from_file(GL_VERTEX_SHADER,   "src/basic_texture.vert"),
                                        Shader::from_file(GL_FRAGMENT_SHADER, "src/basic_texture.frag")));

  material->enable(GL_BLEND);
  material->blend_func(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
  material->set_texture(0, texture);
  material->set_uniform("texture_diff", 0);
  material->set_uniform("MVP", UniformSymbol::ModelViewProjectionMatrix);

  return std::make_shared<TextSurface>(material, width, height,
                                       text_extents, font_extents);
}
Exemplo n.º 2
0
MaterialPtr
MaterialFactory::create_skybox()
{
  MaterialPtr material = std::make_shared<Material>();

  material->blend_func(GL_ONE, GL_ONE);
  material->enable(GL_BLEND);
  material->enable(GL_CULL_FACE);
  material->enable(GL_DEPTH_TEST);
  material->set_texture(0, Texture::cubemap_from_file("data/textures/miramar/"));
  material->set_uniform("diffuse", glm::vec4(1.0f, 1.0f, 1.0f, 1.0f));
  material->set_uniform("diffuse_texture", 0);
  material->set_uniform("MVP", UniformSymbol::ModelViewProjectionMatrix);
  material->set_program(Program::create(Shader::from_file(GL_VERTEX_SHADER, "src/cubemap.vert"),
                                        Shader::from_file(GL_FRAGMENT_SHADER, "src/cubemap.frag")));

  return material;
}