Sha256: 4c77ce3f64f787e2eb5c17cf97ec28e0e531f860fb653495e52ba41071dbaa49

Contents?: true

Size: 630 Bytes

Versions: 54

Compression:

Stored size: 630 Bytes

Contents

#include <Gosu/Timing.hpp>
#include <unistd.h>

void Gosu::sleep(unsigned milliseconds)
{
	usleep(milliseconds * 1000);
}

// Thanks to this blog for the unconvoluted code example:
// http://shiftedbits.org/2008/10/01/mach_absolute_time-on-the-iphone/

#include <mach/mach_time.h>

unsigned long Gosu::milliseconds()
{
    static uint64_t firstTick = 0;
    static mach_timebase_info_data_t info;
    
    if (firstTick == 0)
    {
        mach_timebase_info(&info);
        firstTick = mach_absolute_time();
    }

    uint64_t runtime = mach_absolute_time() - firstTick;
	return runtime * info.numer / info.denom / 1000000.0;
}

Version data entries

54 entries across 54 versions & 1 rubygems

Version Path
gosu-0.10.9.pre1 src/TimingApple.cpp
gosu-0.10.8 src/TimingApple.cpp
gosu-0.10.7 src/TimingApple.cpp
gosu-0.10.6 src/TimingApple.cpp
gosu-0.10.5 src/TimingApple.cpp
gosu-0.10.5.pre0 src/TimingApple.cpp
gosu-0.10.5.pre1 src/TimingApple.cpp
gosu-0.10.4 src/TimingApple.cpp
gosu-0.10.3 src/TimingApple.cpp
gosu-0.10.2 src/TimingApple.cpp
gosu-0.10.2.pre1 src/TimingApple.cpp
gosu-0.10.1.2 src/TimingApple.cpp
gosu-0.10.1.1 src/TimingApple.cpp
gosu-0.10.1 src/TimingApple.cpp
gosu-0.10.0 src/TimingApple.cpp
gosu-0.9.2 src/TimingApple.cpp
gosu-0.9.2.pre1 src/TimingApple.cpp
gosu-0.9.1 src/TimingApple.cpp
gosu-0.9.0 src/TimingApple.cpp
gosu-0.9.0.pre1 src/TimingApple.cpp