Results 1 to 2 of 2
  1. #1
    Dwar
    Dwar is offline
    Veteran Dwar's Avatar
    Join Date
    2010 Mar
    Posts
    2,222
    Thanks Thanks Given 
    211
    Thanks Thanks Received 
    2,230
    Thanked in
    292 Posts
    Rep Power
    10

    Drawing Time and Date

    Here is a nice perk i like in a D3D, so i dont lose track of time when i play
    //includes 

    #include <time.h>

    //globals

    char cTimeAndDate[80];
    time_t tValue;


    //Do the rest In EndScene

    HRESULT APIENTRY IDirect3DDevice9::EndScene()
    {

    tValue = time(NULL);
    strftime(cTimeAndDate, sizeof(cTimeAndDate), "[ %a - %b %d - %i:%m %p ]", localtime(&tValue));

    return Device->EndScene();

    }


    Here's another way you can display time using <ctime>.

    Include this at the top
    #include <ctime>

    Do this in End Scene:
    char time  [5]
    _strtime( time );
    printf( "%s", time );

    And to display it you would use your draw text function.
    In a starter kit it'll most likely look like this:
    m_pFont_new->DrawText(710,310,txtWhite,time);


    by Roverturbo
    Please, post your questions on forum, not by PM or mail

    I spend my time, so please pay a little bit of your time to keep world in equilibrium

  2. #2
    jomel590
    jomel590 is offline
    Guest
    Join Date
    2010 Dec
    Posts
    1
    Thanks Thanks Given 
    0
    Thanks Thanks Received 
    0
    Thanked in
    0 Posts
    Rep Power
    0
    Sir problems..


    1>------ Build started: Project: Time, Configuration: Debug Win32 ------
    1>Compiling...
    1>time.cpp
    1>c:\users\raquel\pictures\documents\visual studio 2008\projects\time\time\time.cpp(13) : error C2146: syntax error : missing ';' before identifier 'APIENTRY'
    1>c:\users\raquel\pictures\documents\visual studio 2008\projects\time\time\time.cpp(13) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
    1>c:\users\raquel\pictures\documents\visual studio 2008\projects\time\time\time.cpp(13) : error C2653: 'IDirect3DDevice9' : is not a class or namespace name
    1>c:\users\raquel\pictures\documents\visual studio 2008\projects\time\time\time.cpp(13) : error C2146: syntax error : missing ';' before identifier 'EndScene'
    1>c:\users\raquel\pictures\documents\visual studio 2008\projects\time\time\time.cpp(13) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
    1>c:\raquel\pictures\documents\visual studio 2008\projects\time\time\time.cpp(14) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
    1>c:\pictures\documents\visual studio 2008\projects\time\time\time.cpp(19) : error C2065: 'Device' : undeclared identifier
    1>c:\pictures\documents\visual studio 2008\projects\time\time\time.cpp(19) : error C2227: left of '->EndScene' must point to class/struct/union/generic type
    1> type is ''unknown-type''
    1>c:\pictures\documents\visual studio 2008\projects\time\time\time.cpp(19) : warning C4508: 'EndScene' : function should return a value; 'void' return type assumed
    1>Build log was saved at "file://c:\Users\raquel\Pictures\Documents\Visual Studio 2008\Projects\Time\Time\Debug\BuildLog.htm"
    1>Time - 8 error(s), 1 warning(s)
    ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •