-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathPixelToasterApple.h
More file actions
executable file
·129 lines (99 loc) · 2.65 KB
/
PixelToasterApple.h
File metadata and controls
executable file
·129 lines (99 loc) · 2.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
// Apple MacOS X Platform
// Copyright © 2004-2007 Glenn Fiedler
// Part of the PixelToaster Framebuffer Library - http://www.pixeltoaster.com
// native Cocoa output implemented by Thorsten Schaaps <bitpull@aixplosive.de>
#ifndef PIXELTOASTER_APPLE_USE_X11
#define PIXELTOASTER_APPLE_USE_X11 0
#endif
#include "CoreServices/CoreServices.h"
#if PIXELTOASTER_APPLE_USE_X11
#define PIXELTOASTER_NO_UNIX_TIMER
#include "PixelToasterUnix.h"
#endif
// display implementation
namespace PixelToaster
{
#if !PIXELTOASTER_APPLE_USE_X11
class AppleDisplay : public DisplayAdapter
{
class AppleDisplayPrivate;
public:
AppleDisplay();
virtual ~AppleDisplay();
virtual bool open( const char title[],
int width, int height,
Output output,
Mode mode );
virtual void close();
virtual bool update( const TrueColorPixel * trueColorPixels,
const FloatingPointPixel * floatingPointPixels,
const Rectangle * dirtyBox );
virtual void title( const char title[] );
virtual bool windowed();
virtual bool fullscreen();
virtual void listener( Listener * listener );
void setShouldClose() { _shouldClose = true; }
void setShouldToggle() { _shouldToggle = true; }
void shutdown();
protected:
virtual void defaults();
private:
AppleDisplayPrivate* _private;
bool _shouldClose;
bool _shouldToggle;
};
#else
class AppleDisplay : public UnixDisplay
{
// ...
};
#endif
// timer implementation
class AppleTimer : public TimerInterface
{
public:
AppleTimer()
{
reset();
}
void reset()
{
Microseconds( (UnsignedWide*) &_timeCounter );
_deltaCounter = _timeCounter;
_time = 0;
}
double time()
{
UInt64 counter;
Microseconds( (UnsignedWide*) &counter );
UInt64 delta = counter - _timeCounter;
_timeCounter = counter;
_time += delta / 1000000.0;
return _time;
}
double delta()
{
UInt64 counter;
Microseconds( (UnsignedWide*) &counter );
UInt64 delta = counter - _deltaCounter;
_deltaCounter = counter;
return delta / 1000000.0;
}
double resolution()
{
return 1.0 / 1000000.0; // microseconds
}
void wait( double seconds )
{
UInt64 counter;
Microseconds( (UnsignedWide*) &counter );
UInt64 finish = counter + UInt64( seconds*1000000 );
while ( counter < finish )
Microseconds( (UnsignedWide*) &counter );
}
private:
double _time; ///< current time in seconds
UInt64 _timeCounter; ///< time counter in microseconds
UInt64 _deltaCounter; ///< delta counter in microseconds
};
}