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


C++ Primitive::AddBatchingSpriteList方法代码示例

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


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

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


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