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


C++ Timer::Start方法代码示例

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


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

示例1: BVHTest

void BVHTest()
{
    Common::Timer timer;

    Random rand = Random(1);

#define NUM_INSERTIONS 100000
    Box* pBoxes = (Box*)_aligned_malloc(NUM_INSERTIONS * sizeof(Box), 16);
    for (int i = 0; i < NUM_INSERTIONS; i++)
    {
        Vector pos = rand.GetFloat3();
        pos *= 100.0f;
        pBoxes[i] = Box(pos - Vector(0.5f, 0.5f, 0.5), pos + Vector(0.5f, 0.5f, 0.5));
    }


    Util::BVH bvh;
    timer.Start();
    for (int i = 0; i < NUM_INSERTIONS; i++)
    {
        bvh.Insert(pBoxes[i], (void*)i);
    }
    double buildTime = timer.Stop();

    Box testBox = Box(Vector(50, 50, 50), Vector(60, 60, 60));

    //__asm int 3;
}
开发者ID:nfprojects,项目名称:nfengine,代码行数:28,代码来源:test.cpp

示例2: RerecordingStart

// Start the timer when a game is booted
void RerecordingStart()
{
	g_FrameCounter = 0;
	ReRecTimer.Start();

	// Logging
	//DEBUG_LOG(CONSOLE, "RerecordingStart: %i\n", g_FrameCounter);
}
开发者ID:madnessw,项目名称:thesnow,代码行数:9,代码来源:CoreRerecording.cpp

示例3: ZeroMemory

/*
    TODO: Font rendering MUST be redesigned.
*/
Font* GuiRendererD3D11::MakeFont(const char* pPath, int height)
{
    Common::Timer timer;
    timer.Start();

    FT_Face face;
    int texWidth = 4096;
    int texHeight = 4096;

    //create pixels array
    unsigned char* pTexData = (unsigned char*)malloc(texWidth * texHeight);
    ZeroMemory(pTexData, texWidth * texHeight);

    if (FT_New_Face(mFreeTypeLibrary, pPath, 0, &face) != 0)
    {
        free(pTexData);
        // TODO
        // LOG_ERROR("Failed to load font '%s'.", pPath);
        return 0;
    }

    //FT_Set_Pixel_Sizes(face, 2*height, 2*height);
    FT_Set_Char_Size(face, 0, height * 64, 96, 96);


    Font* pFont = new Font;

    /*
    FT_Matrix Transform;
    Transform.xx = (FT_Fixed)(1.0f * 0x10000L);
    Transform.xy = (FT_Fixed)(0.0f * 0x10000L);
    Transform.yx = (FT_Fixed)(0.0f * 0x10000L);
    Transform.yy = (FT_Fixed)(1.0f * 0x10000L);
    FT_Set_Transform(face, &Transform, 0);
    */

    int Width;
    int Height;
    int OffsetX = 0;
    int OffsetY = 0;

    pFont->height = height;
    pFont->charCount = 65536;
    pFont->characters = (CharacterInfo*)malloc(sizeof(CharacterInfo) * pFont->charCount);

    int Index = 0;
    for (int ChrId = 0; ChrId < (65536); ChrId++)
    {
        // Load The Glyph For Our Character.
        unsigned int GlyphIndex = FT_Get_Char_Index(face, ChrId);
        if (GlyphIndex == 0)
        {
            pFont->characters[ChrId].exists = false;
            continue;
        }

        FT_Load_Glyph(face, GlyphIndex, FT_LOAD_DEFAULT);


        // Move The Face's Glyph Into A Glyph Object.
        FT_Glyph glyph;
        FT_Get_Glyph(face->glyph, &glyph);


        // Convert The Glyph To A Bitmap.
        FT_Glyph_To_Bitmap(&glyph, FT_RENDER_MODE_NORMAL, 0, 1);
        FT_BitmapGlyph bitmap_glyph = (FT_BitmapGlyph)glyph;

        // This Reference Will Make Accessing The Bitmap Easier.
        FT_Bitmap& bitmap = bitmap_glyph->bitmap;


        Width = bitmap.width;
        Height = bitmap.rows;

        //char won't fit to texture
        if (OffsetX + Width + 2 > texWidth)
        {
            OffsetX = 0;
            OffsetY += 2 * height;
        }

        for (int y = 0; y < Height; y++)
        {
            for (int x = 0; x < Width; x++)
            {
                unsigned char Value = bitmap.buffer[x + Width * y];

                int PxOffset = (y + OffsetY) * texWidth + x + OffsetX;
                pTexData[PxOffset] = Value;
            }
        }


        pFont->characters[ChrId].exists = true;
        pFont->characters[ChrId].top = (short)bitmap_glyph->top;
        pFont->characters[ChrId].left = (short)bitmap_glyph->left;
//.........这里部分代码省略.........
开发者ID:nfprojects,项目名称:nfengine,代码行数:101,代码来源:GuiRenderer.cpp

示例4: WinMain


//.........这里部分代码省略.........

    LightComponent* pDirLight = new LightComponent(pDirLightEnt);
    pDirLight->SetDirLight(&dirLight);
    pDirLight->SetColor(Float3(2.2, 2, 1.8));
    pDirLight->SetShadowMap(1024);

    // MINECRAFT
    Entity* pEnt = g_pScene->CreateEntity();
    pEnt->SetPosition(Vector(0, -70.0f, 0));

    MeshComponent* pMesh = new MeshComponent(pEnt);
    pMesh->SetMeshResource("minecraft.nfm");
#endif

#ifdef SCENE_SPONZA
    // SPONZA
    Entity* pEnt = g_pScene->CreateEntity();
    pEnt->SetPosition(Vector(0, 0, 0));

    MeshComponent* pMesh = new MeshComponent(pEnt);
    pMesh->SetMeshResource("sponza.nfm");

    CollisionShape* pSponzaShape = ENGINE_GET_COLLISION_SHAPE("sponza_collision_shape.nfcs");
    //pSponzaShape->Load();

    BodyComponent* pFloorBody = new BodyComponent(pEnt);
    pFloorBody->EnablePhysics(pSponzaShape);
    pFloorBody->SetMass(0.0);

    pEnt = g_pScene->CreateEntity();
    pEnt->SetPosition(Vector(0.0f, 3.5f, 0.0f));
    LightComponent* pLight = new LightComponent(pEnt);
    OmniLightDesc omni;
    omni.m_ShadowFadeStart = 12.0f;
    omni.m_ShadowFadeEnd = 120.0f;
    omni.m_Radius = 90.0f;
    pLight->SetOmniLight(&omni);
    pLight->SetColor(Float3(50, 50, 50));
    pLight->SetShadowMap(512);
    /*
    // SUNLIGHT
    Entity* pDirLightEnt = g_pScene->CreateEntity();
    XOrientation orient;
    orient.x = Vector(0.0f, -0.0f, -0.0f, 0.0f);
    orient.z = Vector(0.1, -2.3f, 1.05, 0.0f);
    orient.y = Vector(0.0f, 1.0f, 0.0f, 0.0f);
    pDirLightEnt->SetOrientation(&orient);
    DirLightDesc dirLight;
    dirLight.m_Far = 100.0f;
    dirLight.m_Splits = 4;
    dirLight.m_LightDist = 1000.0;

    LightComponent* pDirLight = new LightComponent(pDirLightEnt);
    pDirLight->SetDirLight(&dirLight);
    pDirLight->SetColor(Float3(2.2, 1.3, 0.8));
    pDirLight->SetShadowMap(2048);
    */
#endif

//performance test (many objects and shadowmaps)
#ifdef SCENE_SEGMENTS_PERF_TEST
    for (int x = -4; x < 5; x++)
    {
        for (int z = -4; z < 5; z++)
        {
            Entity* pEntity = g_pScene->CreateEntity();
开发者ID:nfprojects,项目名称:nfengine,代码行数:67,代码来源:test.cpp


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