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.
- checksums.yaml +4 -4
- data/Gosu/Audio.hpp +35 -66
- data/Gosu/AutoLink.hpp +14 -16
- data/Gosu/Bitmap.hpp +50 -37
- data/Gosu/Buttons.hpp +246 -265
- data/Gosu/Color.hpp +32 -76
- data/Gosu/Directories.hpp +14 -17
- data/Gosu/Font.hpp +28 -34
- data/Gosu/Fwd.hpp +27 -31
- data/Gosu/Gosu.hpp +2 -5
- data/Gosu/Graphics.hpp +31 -48
- data/Gosu/GraphicsBase.hpp +27 -58
- data/Gosu/IO.hpp +44 -56
- data/Gosu/Image.hpp +29 -73
- data/Gosu/ImageData.hpp +13 -17
- data/Gosu/Input.hpp +42 -57
- data/Gosu/Inspection.hpp +2 -6
- data/Gosu/Math.hpp +32 -38
- data/Gosu/Platform.hpp +10 -29
- data/Gosu/Text.hpp +30 -39
- data/Gosu/TextInput.hpp +29 -36
- data/Gosu/Timing.hpp +14 -16
- data/Gosu/Utility.hpp +10 -15
- data/Gosu/Version.hpp +13 -14
- data/Gosu/Window.hpp +53 -68
- data/README.md +23 -11
- data/ext/gosu/extconf.rb +31 -81
- data/lib/gosu/patches.rb +35 -19
- data/lib/gosu/run.rb +13 -4
- data/rdoc/gosu.rb +24 -20
- data/src/ALChannelManagement.hpp +119 -0
- data/src/{Audio/Audio.cpp → Audio.cpp} +177 -211
- data/src/AudioFile.hpp +57 -0
- data/src/AudioToolboxFile.hpp +214 -0
- data/src/Bitmap.cpp +159 -0
- data/src/BitmapIO.cpp +141 -0
- data/src/BlockAllocator.cpp +133 -0
- data/src/{Graphics/BlockAllocator.hpp → BlockAllocator.hpp} +34 -35
- data/src/ClipRectStack.hpp +87 -0
- data/src/{Graphics/Color.cpp → Color.cpp} +30 -28
- data/src/DirectoriesApple.cpp +68 -0
- data/src/DirectoriesUnix.cpp +20 -18
- data/src/DirectoriesWin.cpp +40 -41
- data/src/DrawOp.hpp +168 -0
- data/src/DrawOpQueue.hpp +190 -0
- data/src/FileUnix.cpp +40 -46
- data/src/FileWin.cpp +42 -38
- data/src/Font.cpp +165 -0
- data/src/{Text/FormattedString.hpp → FormattedString.hpp} +114 -114
- data/src/GosuAppDelegate.cpp +30 -0
- data/src/{UIKit/GosuAppDelegate.h → GosuAppDelegate.h} +0 -0
- data/src/{UIKit/GosuGLView.mm → GosuGLView.cpp} +22 -17
- data/src/{UIKit/GosuGLView.h → GosuGLView.h} +0 -0
- data/src/GosuViewController.cpp +231 -0
- data/src/{UIKit/GosuViewController.h → GosuViewController.h} +0 -0
- data/src/Graphics.cpp +464 -0
- data/src/{Graphics/Common.hpp → GraphicsImpl.hpp} +29 -32
- data/src/IO.cpp +17 -16
- data/src/Iconv.hpp +13 -22
- data/src/Image.cpp +142 -0
- data/src/Input.cpp +459 -0
- data/src/InputUIKit.cpp +197 -0
- data/src/Inspection.cpp +4 -5
- data/src/LargeImageData.cpp +151 -0
- data/src/LargeImageData.hpp +43 -0
- data/src/{Graphics/Macro.cpp → Macro.cpp} +77 -78
- data/src/Macro.hpp +30 -0
- data/src/Math.cpp +17 -29
- data/src/{Audio/OggFile.hpp → OggFile.hpp} +19 -24
- data/src/RenderState.hpp +205 -0
- data/src/Resolution.cpp +86 -0
- data/src/ResolutionApple.cpp +25 -0
- data/{ext/gosu/gosu_wrap.cxx → src/RubyGosu.cxx} +2256 -1707
- data/{ext/gosu/gosu_wrap.h → src/RubyGosu.h} +9 -9
- data/src/{Audio/SndFile.hpp → SndFile.hpp} +54 -43
- data/src/TexChunk.cpp +117 -0
- data/src/{Graphics/TexChunk.hpp → TexChunk.hpp} +13 -18
- data/src/Text.cpp +371 -0
- data/src/TextApple.cpp +209 -0
- data/src/TextInput.cpp +278 -0
- data/src/TextTTFWin.cpp +251 -0
- data/src/{Text/TextUnix.cpp → TextUnix.cpp} +96 -92
- data/src/TextWin.cpp +194 -0
- data/src/{Graphics/Texture.cpp → Texture.cpp} +35 -38
- data/src/{Graphics/Texture.hpp → Texture.hpp} +9 -13
- data/src/TimingApple.cpp +11 -7
- data/src/TimingUnix.cpp +13 -7
- data/src/TimingWin.cpp +6 -1
- data/src/{Graphics/Transform.cpp → Transform.cpp} +17 -12
- data/src/{Graphics/TransformStack.hpp → TransformStack.hpp} +24 -25
- data/src/Utility.cpp +29 -70
- data/src/UtilityApple.cpp +52 -0
- data/src/UtilityWin.cpp +7 -4
- data/src/Version.cpp +22 -0
- data/src/WinMain.cpp +30 -33
- data/src/WinUtility.cpp +24 -22
- data/src/WinUtility.hpp +11 -20
- data/src/Window.cpp +142 -112
- data/src/WindowUIKit.cpp +155 -0
- data/src/stb_image.h +384 -173
- data/src/stb_vorbis.c +20 -18
- metadata +60 -62
- data/Gosu/TR1.hpp +0 -56
- data/src/AppleUtility.hpp +0 -66
- data/src/Audio/ALChannelManagement.hpp +0 -114
- data/src/Audio/Audio.mm +0 -1
- data/src/Audio/AudioFile.hpp +0 -53
- data/src/Audio/AudioToolboxFile.hpp +0 -207
- data/src/Bitmap/Bitmap.cpp +0 -183
- data/src/Bitmap/BitmapIO.cpp +0 -176
- data/src/DirectoriesApple.mm +0 -71
- data/src/Graphics/BlockAllocator.cpp +0 -142
- data/src/Graphics/ClipRectStack.hpp +0 -93
- data/src/Graphics/DrawOp.hpp +0 -175
- data/src/Graphics/DrawOpQueue.hpp +0 -188
- data/src/Graphics/Graphics.cpp +0 -478
- data/src/Graphics/Image.cpp +0 -193
- data/src/Graphics/LargeImageData.cpp +0 -133
- data/src/Graphics/LargeImageData.hpp +0 -46
- data/src/Graphics/Macro.hpp +0 -36
- data/src/Graphics/RenderState.hpp +0 -211
- data/src/Graphics/Resolution.cpp +0 -91
- data/src/Graphics/ResolutionApple.mm +0 -19
- data/src/Graphics/TexChunk.cpp +0 -112
- data/src/Input/Input.cpp +0 -463
- data/src/Input/InputUIKit.mm +0 -190
- data/src/Input/TextInput.cpp +0 -261
- data/src/Text/Font.cpp +0 -175
- data/src/Text/Text.cpp +0 -391
- data/src/Text/TextApple.mm +0 -227
- data/src/Text/TextTTFWin.cpp +0 -249
- data/src/Text/TextWin.cpp +0 -186
- data/src/UIKit/GosuAppDelegate.mm +0 -24
- data/src/UIKit/GosuViewController.mm +0 -211
- data/src/UtilityApple.mm +0 -63
- data/src/WindowUIKit.mm +0 -139
data/src/stb_vorbis.c
CHANGED
@@ -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
|
-
|
557
|
-
|
558
|
-
#
|
559
|
-
#include <
|
560
|
-
#endif
|
561
|
-
#
|
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
|
-
}
|
1273
|
+
} stbv__point;
|
1272
1274
|
|
1273
1275
|
static int STBV_CDECL point_compare(const void *p, const void *q)
|
1274
1276
|
{
|
1275
|
-
|
1276
|
-
|
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
|
-
|
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.
|
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:
|
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/
|
66
|
-
- src/Audio
|
67
|
-
- src/
|
68
|
-
- src/
|
69
|
-
- src/
|
70
|
-
- src/
|
71
|
-
- src/
|
72
|
-
- src/
|
73
|
-
- src/
|
74
|
-
- src/
|
75
|
-
- src/DirectoriesApple.
|
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/
|
81
|
-
- src/
|
82
|
-
- src/
|
83
|
-
- src/
|
84
|
-
- src/
|
85
|
-
- src/
|
86
|
-
- src/
|
87
|
-
- src/
|
88
|
-
- src/Graphics
|
89
|
-
- src/
|
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/
|
105
|
-
- src/Input
|
106
|
-
- src/
|
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/
|
110
|
-
- src/
|
111
|
-
- src/
|
112
|
-
- src/
|
113
|
-
- src/
|
114
|
-
- src/
|
115
|
-
- src/
|
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/
|
120
|
-
- src/
|
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.
|
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.
|
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:
|
155
|
+
version: '0'
|
158
156
|
requirements: []
|
159
157
|
rubyforge_project:
|
160
|
-
rubygems_version: 2.
|
158
|
+
rubygems_version: 2.6.8
|
161
159
|
signing_key:
|
162
160
|
specification_version: 4
|
163
161
|
summary: 2D game development library.
|
data/Gosu/TR1.hpp
DELETED
@@ -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
|
data/src/AppleUtility.hpp
DELETED
@@ -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
|
-
}
|