Results 1 to 9 of 9

Thread: function Now()

  1. #1

    function Now()

    when I want to measure some timing, i used function Now() and I was surprised, that it returns always same value !

    Instead of, I used GetTickCount() and It works.
    How it is possible ?

  2. #2

    function Now()

    The function now() returns the current date and time. It shouldn't return always the same value, unless you check it every millisecond.

    GetTickCount() is much better, asuming you're using it for your gameloop and sprite movements.

  3. #3

    function Now()

    I was calling the function in AsphyreTimer.OnRender event.
    Simple drawing current time to screen and it doesn't changed !
    Maybe there is something wrong with my computer...

  4. #4

    function Now()

    Now value should be changed every second (based on manual, that's its precision). However, GetTickCount() might not be that precise also, for timing applications you should consider using QueryPerformanceCounter (as an example, check TAsphyreTimer source code).

  5. #5

    function Now()

    I do some exploration of the problem and result is, that if i am using Direct3D renderer, value of Now() DOES NOT CHANGE, if used any else renderer, it is OK and value DOES CHANGE. Try this with plasma demo - i added one marked line:
    [pascal]
    procedure TMainForm.TimerRender(Sender: TObject);
    var
    i, j: Integer;
    begin
    with PowerDraw.Device do
    begin
    Clear($FFFF0000);
    BeginScene();

    for j:= 0 to (PowerDraw.Height div 256) do
    for i:= 0 to (PowerDraw.Width div 256) do
    RenderEffect(Images[0], (i * 256), (j * 256), 0, effectNone);

    Fonts[0].TextOut('FPS: ' + IntToStr(Timer.FrameRate), 4, 4, $FFFFFFFF, effectNone);
    {added line} Fonts[0].TextOut('Time: ' + FormatDateTime('HH:MMS.ZZZ', Now()), 4, 40, $FFFFFFFF, effectNone);

    EndScene();
    Present();
    end;
    end;
    [/pascal]

    second mystery is, that on my computer in Direct3D mode minutes are 3 minutes sooner than right time (and of course doesnt change) :?:

  6. #6

    function Now()

    Notify that function Now() returns time AND date (help says "Now returns the current date and time, corresponding to Date + Time"), so if you try to convert it to HH:MMS value, convert error comes up. Result is clear - value which is rendered on screen is still same (beacause of date included in outcome Double value). To avoid that, use only Time() function to get current time, or Date() to get current date, or Now() to get time and date together.
    I hope that I explained it cleary. If I didn't, I'm sorry

  7. #7

    function Now()

    I dont understand, why convert error may occur when PowerDraw is switched into Direct3D mode and NOT when it is switched to Software mode.
    Now() returns TDateTime, it can be converted by function FormatDateTime, i dont see any problem in this....

  8. #8

    function Now()

    Quote Originally Posted by jansoft
    I dont understand, why convert error may occur when PowerDraw is switched into Direct3D mode and NOT when it is switched to Software mode.
    Now() returns TDateTime, it can be converted by function FormatDateTime, i dont see any problem in this....
    Yes, it is strange, but when I used Time instead of now, it worked :?

  9. #9

    function Now()

    It seems that problem is somewhere in adding
    time and date part.
    I was trying this part of code:
    [pascal]
    var
    tttouble=0;
    procedure TMainForm.DoIt;
    var
    t4ouble;
    begin
    ttt:=ttt+1/10000;
    t4:=10000000+ttt;
    end;
    {...call this procedure from AsphyreTimer.OnRender...}
    [/pascal]
    and again, in Direct3D value of t4 is "jumping", in Software mode its OK.

    My favorite victim is some flag of FPU is set to some wrong value
    (MMX instructions are sharing registers of FPU, so maybe it is a problem; but my home PC has no MMX and problem is there also)

    Lifepower should know more ? :roll:

Bookmarks

Posting Permissions

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