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


C++ Test::RenderManager方法代码示例

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


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

示例1: on_application_initialized

void on_application_initialized ()
{
  try
  {
    common::LogFilter log_filter ("render.manager*", &log_print);

    Test test (L"Effect loader test", false);

    RenderManager render_manager = test.RenderManager ();

    render_manager.LoadResource (LIBRARY_NAME);

    printf ("Effects loaded\n");
  }
  catch (std::exception& e)
  {
    printf ("%s\n", e.what ());
  }

  syslib::Application::Exit (0);
}
开发者ID:untgames,项目名称:funner,代码行数:21,代码来源:effect_loader.cpp

示例2: on_application_initialized

void on_application_initialized ()
{
  try
  {
    printf ("--- Create device ---\n");
    
    Test test (L"Material cache test", true);            
    
    RenderManager render_manager = test.RenderManager ();    
    
      //создание материала и примитива
      
    printf ("--- Load resources ---\n");

    render_manager.LoadResource ("data/test.xmesh");
    render_manager.LoadResource ("data/test.xmtl");
    render_manager.LoadResource (LIBRARY_NAME);
    render_manager.LoadResource ("data/bottom.jpg");
    render_manager.LoadResource ("data/pic1.dds");
    
    printf ("--- Create primitive & material ---\n");
    
    Primitive primitive = render_manager.CreateSharedPrimitive ("mesh2");
    Material  material  = render_manager.CreateSharedMaterial ("canyon.stn_2");
    
    printf ("--- Update primitive cache ---\n");    

    primitive.UpdateCache ();

      //обновление полного состояния материала
      
    printf ("--- Update full material state ---\n");        
    
    media::rfx::Material src_mtl;
    
    src_mtl.Properties ().SetProperty ("A", 1.0f);
    src_mtl.Properties ().SetProperty ("B", 2);
    
    src_mtl.SetTags ("solid");
    
    src_mtl.SetProgram ("phong");
    
    media::rfx::Texmap diffuse_map;
    
    diffuse_map.SetSemantic ("diffuse");
    diffuse_map.SetImage    ("data/bottom.jpg");
    diffuse_map.SetSampler  ("default");    
    
    src_mtl.AddTexmap (diffuse_map);
    
    material.Update (src_mtl);
    
    primitive.UpdateCache ();

      //обновление свойств материала с сохранение их структуры
      
    printf ("--- Update material properties (with same layout) ---\n");
      
    src_mtl.Properties ().SetProperty ("A", 2.0f);
    
    primitive.UpdateCache ();
    
      //обновление свойств материала с изменением их структуры        
    
    printf ("--- Update material properties (with new layout) ---\n");
      
    src_mtl.Properties ().SetProperty ("C", math::mat4f (3.0f));
    src_mtl.Properties ().SetProperty ("D", math::mat4f (4.0f));    
    src_mtl.Properties ().SetProperty ("E", math::mat4f (5.0f));    
    
    primitive.UpdateCache ();

      //обновление текстур
      
    printf ("--- Unload texture ---\n");      
      
    render_manager.UnloadResource ("data/bottom.jpg");
    
    try
    {
      primitive.UpdateCache ();    
    }
    catch (std::exception& e)
    {
      printf ("%s\n", e.what ());
    }

    printf ("--- Load texture ---\n");      

    render_manager.LoadResource ("data/bottom.jpg");        

    primitive.UpdateCache ();        

      //обновление программы
      
    printf ("--- Update program ---\n");            
      
    src_mtl.SetProgram ("helper");
    
    material.Update (src_mtl);
//.........这里部分代码省略.........
开发者ID:untgames,项目名称:funner,代码行数:101,代码来源:cache_material.cpp

示例3: main

int main ()
{
  printf ("Results of sprite1_test:\n");
  
  try
  {
    Test test (L"Sprite 1", true);

    RenderManager render_manager = test.RenderManager ();
        
    render_manager.LoadResource ("data/sprites.rfx");    
    render_manager.LoadResource ("data/bottom.jpg");
    render_manager.LoadResource ("data/sprites.xmtl");
    
    Entity     entity    = render_manager.CreateEntity ();
    Primitive  primitive = render_manager.CreatePrimitive ();
//    SpriteList sprites   = primitive.AddStandaloneSpriteList (SpriteMode_Oriented, math::vec3f (0, 1.0f, 0));
//    SpriteList sprites   = primitive.AddStandaloneSpriteList (SpriteMode_Billboard, math::vec3f (0, 1.0f, 0));
//    SpriteList sprites   = primitive.AddBatchingSpriteList (SpriteMode_Oriented, math::vec3f (0, 1.0f, 0));
    SpriteList sprites   = primitive.AddBatchingSpriteList (SpriteMode_Oriented, math::vec3f (0, 1.0f, 0));
    Sprite     sprite;

    primitive.Buffers ().ReserveDynamicBuffers (8192, 8192);

    entity.SetWorldScissor (Box (math::vec3f (0.0f), math::vec3f (1.0f)));
    entity.EnableScissor ();

    sprite.position   = math::vec3f (0.0f);
    sprite.size       = math::vec2f (1.0f);
    sprite.color      = math::vec4f (1.0f);
    sprite.tex_offset = math::vec2f (0.0f);
    sprite.tex_size   = math::vec2f (1.0f);
    sprite.normal     = math::vec3f (0, 0, 1.0f);
    sprite.rotation   = math::anglef ();

    sprites.SetMaterial ("sprite");
    sprites.Add (1, &sprite);

    entity.SetPrimitive (primitive);

    entity.SetWorldMatrix (math::rotate (math::degree (45.0f), math::vec3f (0, 0, 1)));
    
    Frame frame = render_manager.CreateFrame ();

    frame.DisableAutoCleanup ();
    frame.SetRenderTarget ("main_color_target", test.Window ().ColorBuffer ());
    frame.SetRenderTarget ("main_depth_stencil_target", test.Window ().DepthStencilBuffer ());
    frame.SetEffect ("main");
    frame.SetClearColor (math::vec4f (0.0f, 0.0f, 1.0f, 1.0f));
    frame.SetEntityDrawHandler (&update_entity_frame_transformations);

    common::PropertyMap entity_dependent_properties;

    frame.SetEntityDependentProperties (entity_dependent_properties);

    entity_dependent_properties.SetProperty ("myObjectMatrix", math::mat4f (1.0f));
    
    common::PropertyMap frame_properties = frame.Properties ();
    common::PropertyMap entity_properties = entity.Properties ();
    
    frame_properties.SetProperty ("myProjMatrix", get_ortho_proj (-2, 2, -2, 2, -15, 15));
    frame_properties.SetProperty ("myViewMatrix", inverse (math::lookat (math::vec3f (0, 0, 10), math::vec3f (0.0f), math::vec3f (0, 1, 0))));

    frame.SetViewProjectionMatrix (frame_properties.GetMatrix ("myProjMatrix") * frame_properties.GetMatrix ("myViewMatrix"));
    
    frame.AddEntity (entity); 
    
    test.ShowWindow ();
    
    syslib::Application::RegisterEventHandler (syslib::ApplicationEvent_OnIdle, xtl::bind (&idle, xtl::ref (test), xtl::ref (entity), xtl::ref (frame)));
            
    return test.Run ();
  }
  catch (std::exception& e)
  {
    printf ("%s\n", e.what ());
  }

  return 0;
}
开发者ID:untgames,项目名称:funner,代码行数:80,代码来源:sprite1.cpp


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