gosu 0.10.9.pre1 → 0.11.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (136) hide show
  1. checksums.yaml +4 -4
  2. data/Gosu/Audio.hpp +35 -66
  3. data/Gosu/AutoLink.hpp +14 -16
  4. data/Gosu/Bitmap.hpp +50 -37
  5. data/Gosu/Buttons.hpp +246 -265
  6. data/Gosu/Color.hpp +32 -76
  7. data/Gosu/Directories.hpp +14 -17
  8. data/Gosu/Font.hpp +28 -34
  9. data/Gosu/Fwd.hpp +27 -31
  10. data/Gosu/Gosu.hpp +2 -5
  11. data/Gosu/Graphics.hpp +31 -48
  12. data/Gosu/GraphicsBase.hpp +27 -58
  13. data/Gosu/IO.hpp +44 -56
  14. data/Gosu/Image.hpp +29 -73
  15. data/Gosu/ImageData.hpp +13 -17
  16. data/Gosu/Input.hpp +42 -57
  17. data/Gosu/Inspection.hpp +2 -6
  18. data/Gosu/Math.hpp +32 -38
  19. data/Gosu/Platform.hpp +10 -29
  20. data/Gosu/Text.hpp +30 -39
  21. data/Gosu/TextInput.hpp +29 -36
  22. data/Gosu/Timing.hpp +14 -16
  23. data/Gosu/Utility.hpp +10 -15
  24. data/Gosu/Version.hpp +13 -14
  25. data/Gosu/Window.hpp +53 -68
  26. data/README.md +23 -11
  27. data/ext/gosu/extconf.rb +31 -81
  28. data/lib/gosu/patches.rb +35 -19
  29. data/lib/gosu/run.rb +13 -4
  30. data/rdoc/gosu.rb +24 -20
  31. data/src/ALChannelManagement.hpp +119 -0
  32. data/src/{Audio/Audio.cpp → Audio.cpp} +177 -211
  33. data/src/AudioFile.hpp +57 -0
  34. data/src/AudioToolboxFile.hpp +214 -0
  35. data/src/Bitmap.cpp +159 -0
  36. data/src/BitmapIO.cpp +141 -0
  37. data/src/BlockAllocator.cpp +133 -0
  38. data/src/{Graphics/BlockAllocator.hpp → BlockAllocator.hpp} +34 -35
  39. data/src/ClipRectStack.hpp +87 -0
  40. data/src/{Graphics/Color.cpp → Color.cpp} +30 -28
  41. data/src/DirectoriesApple.cpp +68 -0
  42. data/src/DirectoriesUnix.cpp +20 -18
  43. data/src/DirectoriesWin.cpp +40 -41
  44. data/src/DrawOp.hpp +168 -0
  45. data/src/DrawOpQueue.hpp +190 -0
  46. data/src/FileUnix.cpp +40 -46
  47. data/src/FileWin.cpp +42 -38
  48. data/src/Font.cpp +165 -0
  49. data/src/{Text/FormattedString.hpp → FormattedString.hpp} +114 -114
  50. data/src/GosuAppDelegate.cpp +30 -0
  51. data/src/{UIKit/GosuAppDelegate.h → GosuAppDelegate.h} +0 -0
  52. data/src/{UIKit/GosuGLView.mm → GosuGLView.cpp} +22 -17
  53. data/src/{UIKit/GosuGLView.h → GosuGLView.h} +0 -0
  54. data/src/GosuViewController.cpp +231 -0
  55. data/src/{UIKit/GosuViewController.h → GosuViewController.h} +0 -0
  56. data/src/Graphics.cpp +464 -0
  57. data/src/{Graphics/Common.hpp → GraphicsImpl.hpp} +29 -32
  58. data/src/IO.cpp +17 -16
  59. data/src/Iconv.hpp +13 -22
  60. data/src/Image.cpp +142 -0
  61. data/src/Input.cpp +459 -0
  62. data/src/InputUIKit.cpp +197 -0
  63. data/src/Inspection.cpp +4 -5
  64. data/src/LargeImageData.cpp +151 -0
  65. data/src/LargeImageData.hpp +43 -0
  66. data/src/{Graphics/Macro.cpp → Macro.cpp} +77 -78
  67. data/src/Macro.hpp +30 -0
  68. data/src/Math.cpp +17 -29
  69. data/src/{Audio/OggFile.hpp → OggFile.hpp} +19 -24
  70. data/src/RenderState.hpp +205 -0
  71. data/src/Resolution.cpp +86 -0
  72. data/src/ResolutionApple.cpp +25 -0
  73. data/{ext/gosu/gosu_wrap.cxx → src/RubyGosu.cxx} +2256 -1707
  74. data/{ext/gosu/gosu_wrap.h → src/RubyGosu.h} +9 -9
  75. data/src/{Audio/SndFile.hpp → SndFile.hpp} +54 -43
  76. data/src/TexChunk.cpp +117 -0
  77. data/src/{Graphics/TexChunk.hpp → TexChunk.hpp} +13 -18
  78. data/src/Text.cpp +371 -0
  79. data/src/TextApple.cpp +209 -0
  80. data/src/TextInput.cpp +278 -0
  81. data/src/TextTTFWin.cpp +251 -0
  82. data/src/{Text/TextUnix.cpp → TextUnix.cpp} +96 -92
  83. data/src/TextWin.cpp +194 -0
  84. data/src/{Graphics/Texture.cpp → Texture.cpp} +35 -38
  85. data/src/{Graphics/Texture.hpp → Texture.hpp} +9 -13
  86. data/src/TimingApple.cpp +11 -7
  87. data/src/TimingUnix.cpp +13 -7
  88. data/src/TimingWin.cpp +6 -1
  89. data/src/{Graphics/Transform.cpp → Transform.cpp} +17 -12
  90. data/src/{Graphics/TransformStack.hpp → TransformStack.hpp} +24 -25
  91. data/src/Utility.cpp +29 -70
  92. data/src/UtilityApple.cpp +52 -0
  93. data/src/UtilityWin.cpp +7 -4
  94. data/src/Version.cpp +22 -0
  95. data/src/WinMain.cpp +30 -33
  96. data/src/WinUtility.cpp +24 -22
  97. data/src/WinUtility.hpp +11 -20
  98. data/src/Window.cpp +142 -112
  99. data/src/WindowUIKit.cpp +155 -0
  100. data/src/stb_image.h +384 -173
  101. data/src/stb_vorbis.c +20 -18
  102. metadata +60 -62
  103. data/Gosu/TR1.hpp +0 -56
  104. data/src/AppleUtility.hpp +0 -66
  105. data/src/Audio/ALChannelManagement.hpp +0 -114
  106. data/src/Audio/Audio.mm +0 -1
  107. data/src/Audio/AudioFile.hpp +0 -53
  108. data/src/Audio/AudioToolboxFile.hpp +0 -207
  109. data/src/Bitmap/Bitmap.cpp +0 -183
  110. data/src/Bitmap/BitmapIO.cpp +0 -176
  111. data/src/DirectoriesApple.mm +0 -71
  112. data/src/Graphics/BlockAllocator.cpp +0 -142
  113. data/src/Graphics/ClipRectStack.hpp +0 -93
  114. data/src/Graphics/DrawOp.hpp +0 -175
  115. data/src/Graphics/DrawOpQueue.hpp +0 -188
  116. data/src/Graphics/Graphics.cpp +0 -478
  117. data/src/Graphics/Image.cpp +0 -193
  118. data/src/Graphics/LargeImageData.cpp +0 -133
  119. data/src/Graphics/LargeImageData.hpp +0 -46
  120. data/src/Graphics/Macro.hpp +0 -36
  121. data/src/Graphics/RenderState.hpp +0 -211
  122. data/src/Graphics/Resolution.cpp +0 -91
  123. data/src/Graphics/ResolutionApple.mm +0 -19
  124. data/src/Graphics/TexChunk.cpp +0 -112
  125. data/src/Input/Input.cpp +0 -463
  126. data/src/Input/InputUIKit.mm +0 -190
  127. data/src/Input/TextInput.cpp +0 -261
  128. data/src/Text/Font.cpp +0 -175
  129. data/src/Text/Text.cpp +0 -391
  130. data/src/Text/TextApple.mm +0 -227
  131. data/src/Text/TextTTFWin.cpp +0 -249
  132. data/src/Text/TextWin.cpp +0 -186
  133. data/src/UIKit/GosuAppDelegate.mm +0 -24
  134. data/src/UIKit/GosuViewController.mm +0 -211
  135. data/src/UtilityApple.mm +0 -63
  136. data/src/WindowUIKit.mm +0 -139
@@ -549,21 +549,23 @@ enum STBVorbisError
549
549
  #endif
550
550
 
551
551
  #ifndef STB_VORBIS_NO_CRT
552
- #include <stdlib.h>
553
- #include <string.h>
554
- #include <assert.h>
555
- #include <math.h>
556
- #if !(defined(__APPLE__) || defined(MACOSX) || defined(macintosh) || defined(Macintosh))
557
- #include <malloc.h>
558
- #if defined(__linux__) || defined(__linux) || defined(__EMSCRIPTEN__)
559
- #include <alloca.h>
560
- #endif
561
- #endif
552
+ #include <stdlib.h>
553
+ #include <string.h>
554
+ #include <assert.h>
555
+ #include <math.h>
556
+
557
+ // find definition of alloca if it's not in stdlib.h:
558
+ #ifdef _MSC_VER
559
+ #include <malloc.h>
560
+ #endif
561
+ #if defined(__linux__) || defined(__linux) || defined(__EMSCRIPTEN__)
562
+ #include <alloca.h>
563
+ #endif
562
564
  #else // STB_VORBIS_NO_CRT
563
- #define NULL 0
564
- #define malloc(s) 0
565
- #define free(s) ((void) 0)
566
- #define realloc(s) 0
565
+ #define NULL 0
566
+ #define malloc(s) 0
567
+ #define free(s) ((void) 0)
568
+ #define realloc(s) 0
567
569
  #endif // STB_VORBIS_NO_CRT
568
570
 
569
571
  #include <limits.h>
@@ -1268,12 +1270,12 @@ static void neighbors(uint16 *x, int n, int *plow, int *phigh)
1268
1270
  typedef struct
1269
1271
  {
1270
1272
  uint16 x,y;
1271
- } Point;
1273
+ } stbv__point;
1272
1274
 
1273
1275
  static int STBV_CDECL point_compare(const void *p, const void *q)
1274
1276
  {
1275
- Point *a = (Point *) p;
1276
- Point *b = (Point *) q;
1277
+ stbv__point *a = (stbv__point *) p;
1278
+ stbv__point *b = (stbv__point *) q;
1277
1279
  return a->x < b->x ? -1 : a->x > b->x;
1278
1280
  }
1279
1281
 
@@ -3869,7 +3871,7 @@ static int start_decoder(vorb *f)
3869
3871
  g->book_list[j] = get_bits(f,8);
3870
3872
  return error(f, VORBIS_feature_not_supported);
3871
3873
  } else {
3872
- Point p[31*8+2];
3874
+ stbv__point p[31*8+2];
3873
3875
  Floor1 *g = &f->floor_config[i].floor1;
3874
3876
  int max_class = -1;
3875
3877
  g->partitions = get_bits(f, 5);
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gosu
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.9.pre1
4
+ version: 0.11.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Julian Raschke
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-09-24 00:00:00.000000000 Z
11
+ date: 2017-01-07 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: |2
14
14
  2D game development library.
@@ -44,7 +44,6 @@ files:
44
44
  - Gosu/Inspection.hpp
45
45
  - Gosu/Math.hpp
46
46
  - Gosu/Platform.hpp
47
- - Gosu/TR1.hpp
48
47
  - Gosu/Text.hpp
49
48
  - Gosu/TextInput.hpp
50
49
  - Gosu/Timing.hpp
@@ -53,8 +52,6 @@ files:
53
52
  - Gosu/Window.hpp
54
53
  - README.md
55
54
  - ext/gosu/extconf.rb
56
- - ext/gosu/gosu_wrap.cxx
57
- - ext/gosu/gosu_wrap.h
58
55
  - lib/gosu.rb
59
56
  - lib/gosu/patches.rb
60
57
  - lib/gosu/preview.rb
@@ -62,74 +59,75 @@ files:
62
59
  - lib/gosu/swig_patches.rb
63
60
  - lib/gosu/zen.rb
64
61
  - rdoc/gosu.rb
65
- - src/AppleUtility.hpp
66
- - src/Audio/ALChannelManagement.hpp
67
- - src/Audio/Audio.cpp
68
- - src/Audio/Audio.mm
69
- - src/Audio/AudioFile.hpp
70
- - src/Audio/AudioToolboxFile.hpp
71
- - src/Audio/OggFile.hpp
72
- - src/Audio/SndFile.hpp
73
- - src/Bitmap/Bitmap.cpp
74
- - src/Bitmap/BitmapIO.cpp
75
- - src/DirectoriesApple.mm
62
+ - src/ALChannelManagement.hpp
63
+ - src/Audio.cpp
64
+ - src/AudioFile.hpp
65
+ - src/AudioToolboxFile.hpp
66
+ - src/Bitmap.cpp
67
+ - src/BitmapIO.cpp
68
+ - src/BlockAllocator.cpp
69
+ - src/BlockAllocator.hpp
70
+ - src/ClipRectStack.hpp
71
+ - src/Color.cpp
72
+ - src/DirectoriesApple.cpp
76
73
  - src/DirectoriesUnix.cpp
77
74
  - src/DirectoriesWin.cpp
75
+ - src/DrawOp.hpp
76
+ - src/DrawOpQueue.hpp
78
77
  - src/FileUnix.cpp
79
78
  - src/FileWin.cpp
80
- - src/Graphics/BlockAllocator.cpp
81
- - src/Graphics/BlockAllocator.hpp
82
- - src/Graphics/ClipRectStack.hpp
83
- - src/Graphics/Color.cpp
84
- - src/Graphics/Common.hpp
85
- - src/Graphics/DrawOp.hpp
86
- - src/Graphics/DrawOpQueue.hpp
87
- - src/Graphics/Graphics.cpp
88
- - src/Graphics/Image.cpp
89
- - src/Graphics/LargeImageData.cpp
90
- - src/Graphics/LargeImageData.hpp
91
- - src/Graphics/Macro.cpp
92
- - src/Graphics/Macro.hpp
93
- - src/Graphics/RenderState.hpp
94
- - src/Graphics/Resolution.cpp
95
- - src/Graphics/ResolutionApple.mm
96
- - src/Graphics/TexChunk.cpp
97
- - src/Graphics/TexChunk.hpp
98
- - src/Graphics/Texture.cpp
99
- - src/Graphics/Texture.hpp
100
- - src/Graphics/Transform.cpp
101
- - src/Graphics/TransformStack.hpp
79
+ - src/Font.cpp
80
+ - src/FormattedString.hpp
81
+ - src/GosuAppDelegate.cpp
82
+ - src/GosuAppDelegate.h
83
+ - src/GosuGLView.cpp
84
+ - src/GosuGLView.h
85
+ - src/GosuViewController.cpp
86
+ - src/GosuViewController.h
87
+ - src/Graphics.cpp
88
+ - src/GraphicsImpl.hpp
102
89
  - src/IO.cpp
103
90
  - src/Iconv.hpp
104
- - src/Input/Input.cpp
105
- - src/Input/InputUIKit.mm
106
- - src/Input/TextInput.cpp
91
+ - src/Image.cpp
92
+ - src/Input.cpp
93
+ - src/InputUIKit.cpp
107
94
  - src/Inspection.cpp
95
+ - src/LargeImageData.cpp
96
+ - src/LargeImageData.hpp
97
+ - src/Macro.cpp
98
+ - src/Macro.hpp
108
99
  - src/Math.cpp
109
- - src/Text/Font.cpp
110
- - src/Text/FormattedString.hpp
111
- - src/Text/Text.cpp
112
- - src/Text/TextApple.mm
113
- - src/Text/TextTTFWin.cpp
114
- - src/Text/TextUnix.cpp
115
- - src/Text/TextWin.cpp
100
+ - src/OggFile.hpp
101
+ - src/RenderState.hpp
102
+ - src/Resolution.cpp
103
+ - src/ResolutionApple.cpp
104
+ - src/RubyGosu.cxx
105
+ - src/RubyGosu.h
106
+ - src/SndFile.hpp
107
+ - src/TexChunk.cpp
108
+ - src/TexChunk.hpp
109
+ - src/Text.cpp
110
+ - src/TextApple.cpp
111
+ - src/TextInput.cpp
112
+ - src/TextTTFWin.cpp
113
+ - src/TextUnix.cpp
114
+ - src/TextWin.cpp
115
+ - src/Texture.cpp
116
+ - src/Texture.hpp
116
117
  - src/TimingApple.cpp
117
118
  - src/TimingUnix.cpp
118
119
  - src/TimingWin.cpp
119
- - src/UIKit/GosuAppDelegate.h
120
- - src/UIKit/GosuAppDelegate.mm
121
- - src/UIKit/GosuGLView.h
122
- - src/UIKit/GosuGLView.mm
123
- - src/UIKit/GosuViewController.h
124
- - src/UIKit/GosuViewController.mm
120
+ - src/Transform.cpp
121
+ - src/TransformStack.hpp
125
122
  - src/Utility.cpp
126
- - src/UtilityApple.mm
123
+ - src/UtilityApple.cpp
127
124
  - src/UtilityWin.cpp
125
+ - src/Version.cpp
128
126
  - src/WinMain.cpp
129
127
  - src/WinUtility.cpp
130
128
  - src/WinUtility.hpp
131
129
  - src/Window.cpp
132
- - src/WindowUIKit.mm
130
+ - src/WindowUIKit.cpp
133
131
  - src/stb_image.h
134
132
  - src/stb_image_write.h
135
133
  - src/stb_vorbis.c
@@ -139,25 +137,25 @@ licenses:
139
137
  metadata: {}
140
138
  post_install_message:
141
139
  rdoc_options:
142
- - -m
140
+ - "-m"
143
141
  - README.md
144
- - -x
142
+ - "-x"
145
143
  - lib
146
144
  require_paths:
147
145
  - lib
148
146
  required_ruby_version: !ruby/object:Gem::Requirement
149
147
  requirements:
150
- - - '>='
148
+ - - ">="
151
149
  - !ruby/object:Gem::Version
152
150
  version: 1.8.2
153
151
  required_rubygems_version: !ruby/object:Gem::Requirement
154
152
  requirements:
155
- - - '>'
153
+ - - ">="
156
154
  - !ruby/object:Gem::Version
157
- version: 1.3.1
155
+ version: '0'
158
156
  requirements: []
159
157
  rubyforge_project:
160
- rubygems_version: 2.5.0
158
+ rubygems_version: 2.6.8
161
159
  signing_key:
162
160
  specification_version: 4
163
161
  summary: 2D game development library.
@@ -1,56 +0,0 @@
1
- //! \file TR1.hpp
2
- //! Includes all parts of C++03 (TR1) that are relevant for Gosu. It makes available the following members of the std::tr1 namespace: array, bind, function, shared_ptr, uint*_t and int*_t.
3
-
4
- #ifndef GOSU_TR1_HPP
5
- #define GOSU_TR1_HPP
6
-
7
- #include <memory>
8
-
9
- #if defined(_MSC_VER) || defined(_LIBCPP_MEMORY)
10
- #include <array>
11
- #include <functional>
12
- namespace std
13
- {
14
- namespace tr1
15
- {
16
- typedef unsigned char uint8_t;
17
- typedef unsigned short uint16_t;
18
- typedef unsigned int uint32_t;
19
- typedef unsigned long long uint64_t;
20
- typedef signed char int8_t;
21
- typedef signed short int16_t;
22
- typedef signed int int32_t;
23
- typedef signed long long int64_t;
24
-
25
- #ifdef _LIBCPP_MEMORY
26
- namespace placeholders
27
- {
28
- using namespace std::placeholders;
29
- }
30
- using std::array;
31
- using std::bind;
32
- using std::function;
33
- using std::shared_ptr;
34
- #endif
35
- }
36
- }
37
- #else
38
- #include <tr1/array>
39
- #include <tr1/memory>
40
- #include <tr1/functional>
41
- #if defined(__GNUC__) && (__GNUC__ < 4 || __GNUC_MINOR__ < 2)
42
- #include <stdint.h>
43
- namespace std
44
- {
45
- namespace tr1
46
- {
47
- using ::int8_t; using ::int16_t; using ::int32_t; using ::int64_t;
48
- using ::uint8_t; using ::uint16_t; using ::uint32_t; using ::uint64_t;
49
- }
50
- }
51
- #else
52
- #include <tr1/cstdint>
53
- #endif
54
- #endif
55
-
56
- #endif
@@ -1,66 +0,0 @@
1
- #ifndef GOSU_APPLEUTILITY_HPP
2
- #define GOSU_APPLEUTILITY_HPP
3
-
4
- #include <Gosu/Platform.hpp>
5
- #include <CoreFoundation/CoreFoundation.h>
6
-
7
- #ifdef __OBJC__
8
-
9
- #include <string>
10
- #include <stdexcept>
11
- #import <Foundation/Foundation.h>
12
-
13
- inline static void throwOSError(OSStatus status, unsigned line)
14
- {
15
- @autoreleasepool {
16
- NSError *error = [NSError errorWithDomain:NSOSStatusErrorDomain code:status userInfo:nil];
17
- throw std::runtime_error("Error on line " + std::to_string(line) +
18
- " (Code " + std::to_string(status) + "): " +
19
- error.localizedDescription.UTF8String +
20
- " (" + error.description.UTF8String + ")");
21
- }
22
- }
23
-
24
- #define CHECK_OS(status) do { if (status) throwOSError(status, __LINE__); } while (0)
25
-
26
- #endif
27
-
28
- namespace Gosu
29
- {
30
- template<typename CFRefType = CFTypeRef>
31
- class CFRef
32
- {
33
- CFRefType ref;
34
-
35
- public:
36
- CFRef(CFRefType ref)
37
- : ref(ref)
38
- {
39
- }
40
-
41
- ~CFRef()
42
- {
43
- if (ref) {
44
- CFRelease(ref);
45
- }
46
- }
47
-
48
- CFRef(const CFRef&) = delete;
49
- CFRef& operator=(const CFRef&) = delete;
50
-
51
- CFRefType get() const
52
- {
53
- return ref;
54
- }
55
-
56
- CFRefType obj() const
57
- {
58
- if (!ref) {
59
- throw std::logic_error("CoreFoundation reference is NULL");
60
- }
61
- return ref;
62
- }
63
- };
64
- }
65
-
66
- #endif
@@ -1,114 +0,0 @@
1
- #include <Gosu/Platform.hpp>
2
- #ifdef GOSU_IS_MAC
3
- #include <OpenAL/al.h>
4
- #include <OpenAL/alc.h>
5
- #include "../AppleUtility.hpp"
6
- #else
7
- #include <AL/al.h>
8
- #include <AL/alc.h>
9
- #endif
10
- #include <cstdlib>
11
- #include <algorithm>
12
- #include <memory>
13
-
14
- namespace Gosu
15
- {
16
- class ALChannelManagement
17
- {
18
- ALChannelManagement(const ALChannelManagement&);
19
- ALChannelManagement& operator=(const ALChannelManagement&);
20
-
21
- static ALCdevice* alDevice;
22
- static ALCcontext* alContext;
23
-
24
- #ifdef GOSU_IS_IPHONE
25
- // iOS system limit (possibly not for newer devices)
26
- enum { NUM_SOURCES = 32 };
27
- #else
28
- enum { NUM_SOURCES = 255 };
29
- #endif
30
- static ALuint alSources[NUM_SOURCES];
31
- static ALuint currentToken;
32
- static ALuint currentTokens[NUM_SOURCES];
33
-
34
- public:
35
- enum { NO_TOKEN = -1, NO_SOURCE = -1, NO_FREE_CHANNEL = -1 };
36
-
37
- static ALCdevice* device()
38
- {
39
- return alDevice;
40
- }
41
-
42
- static ALCcontext* context()
43
- {
44
- return alContext;
45
- }
46
-
47
- ALChannelManagement()
48
- {
49
- // Open preferred device
50
- alDevice = alcOpenDevice(0);
51
- alContext = alcCreateContext(alDevice, 0);
52
- alcMakeContextCurrent(alContext);
53
- alGenSources(NUM_SOURCES, alSources);
54
- std::fill(currentTokens, currentTokens + NUM_SOURCES,
55
- static_cast<ALuint>(NO_TOKEN));
56
- }
57
-
58
- ~ALChannelManagement()
59
- {
60
- alDeleteSources(NUM_SOURCES, alSources);
61
- alcMakeContextCurrent(0);
62
- alcDestroyContext(alContext);
63
- alcCloseDevice(alDevice);
64
- }
65
-
66
- std::pair<int, int> reserveChannel()
67
- {
68
- int i;
69
- for (i = 1; i <= NUM_SOURCES; ++i)
70
- {
71
- if (i == NUM_SOURCES)
72
- return std::make_pair<int, int>(NO_FREE_CHANNEL, NO_TOKEN);
73
- if (currentTokens[i] == NO_TOKEN)
74
- break;
75
- ALint state;
76
- alGetSourcei(alSources[i], AL_SOURCE_STATE, &state);
77
- if (state != AL_PLAYING && state != AL_PAUSED)
78
- break;
79
- }
80
- ++currentToken;
81
- currentTokens[i] = currentToken;
82
- return std::make_pair(i, int(currentToken));
83
- }
84
-
85
- int sourceIfStillPlaying(int channel, int token) const
86
- {
87
- if (channel != NO_FREE_CHANNEL && currentTokens[channel] == token)
88
- return alSources[channel];
89
- return NO_SOURCE;
90
- }
91
-
92
- int sourceForSongs() const
93
- {
94
- return alSources[0];
95
- }
96
- };
97
- ALCdevice* ALChannelManagement::alDevice = 0;
98
- ALCcontext* ALChannelManagement::alContext = 0;
99
- ALuint ALChannelManagement::alSources[NUM_SOURCES];
100
- ALuint ALChannelManagement::currentToken = 0;
101
- ALuint ALChannelManagement::currentTokens[NUM_SOURCES];
102
-
103
- GOSU_UNIQUE_PTR<ALChannelManagement> alChannelManagement;
104
-
105
- void releaseAllOpenALResources()
106
- {
107
- alChannelManagement.reset();
108
- }
109
-
110
- ALCcontext *sharedContext()
111
- {
112
- return ALChannelManagement::context();
113
- }
114
- }