gosu 0.7.27.1 → 0.7.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/{COPYING.txt → COPYING} +10 -7
- data/Gosu/Bitmap.hpp +7 -5
- data/Gosu/ButtonsWin.hpp +0 -0
- data/Gosu/Image.hpp +2 -2
- data/Gosu/ImageData.hpp +3 -0
- data/Gosu/Version.hpp +2 -2
- data/GosuImpl/Graphics/BitmapApple.mm +132 -0
- data/GosuImpl/Graphics/BitmapBMP.cpp +2 -1
- data/GosuImpl/Graphics/BitmapPNG.cpp +8 -6
- data/GosuImpl/Graphics/BitmapUtils.cpp +15 -6
- data/GosuImpl/Graphics/DrawOpQueue.hpp +4 -0
- data/GosuImpl/Graphics/Graphics.cpp +5 -7
- data/GosuImpl/Graphics/Image.cpp +7 -7
- data/GosuImpl/Graphics/LargeImageData.cpp +7 -0
- data/GosuImpl/Graphics/LargeImageData.hpp +1 -0
- data/GosuImpl/Graphics/Macro.hpp +31 -13
- data/GosuImpl/Graphics/TexChunk.cpp +31 -0
- data/GosuImpl/Graphics/TexChunk.hpp +1 -0
- data/GosuImpl/Graphics/Texture.cpp +2 -5
- data/GosuImpl/Graphics/Texture.hpp +1 -2
- data/GosuImpl/MacUtility.hpp +1 -1
- data/GosuImpl/RubyGosu.swg +29 -11
- data/GosuImpl/RubyGosu_wrap.cxx +83 -22
- data/GosuImpl/Utility.cpp +0 -0
- data/README.txt +20 -11
- metadata +7 -8
- data/GosuImpl/Graphics/BitmapTouch.mm +0 -69
data/{COPYING.txt → COPYING}
RENAMED
|
@@ -18,14 +18,17 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
|
18
18
|
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
19
19
|
DEALINGS IN THE SOFTWARE.
|
|
20
20
|
|
|
21
|
-
Julian Raschke
|
|
21
|
+
Julian Raschke julian@raschke.de
|
|
22
|
+
Jan Lücker jan.luecker@gmx.de
|
|
23
|
+
http://www.libgosu.org/
|
|
22
24
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
http://www.libgosu.org/
|
|
26
|
-
|
|
27
|
-
***
|
|
25
|
+
***
|
|
28
26
|
|
|
29
27
|
This does NOT apply to audiere.dll shipped with the Windows versions of
|
|
30
28
|
Gosu. Audiere is a separate library licensed under the Lesser General
|
|
31
|
-
Public License. Please consult audiere.sf.net for more details.
|
|
29
|
+
Public License. Please consult http://audiere.sf.net/ for more details.
|
|
30
|
+
|
|
31
|
+
This does also NOT apply to libogg and libvorbis, which are included in
|
|
32
|
+
all source and binary distributions of Gosu, sometimes via audiere. These
|
|
33
|
+
projects are licensed under a BSD-like license, and their copyright terms
|
|
34
|
+
need to be supplied even with binary redistributions (e.g. Gosu games).
|
data/Gosu/Bitmap.hpp
CHANGED
|
@@ -68,18 +68,20 @@ namespace Gosu
|
|
|
68
68
|
Reader loadFromPNG(Bitmap& bmp, Reader reader);
|
|
69
69
|
//! Saves the contents of the given bitmap into PNG file data, 24 bits.
|
|
70
70
|
Writer saveToPNG(const Bitmap& bmp, Writer writer);
|
|
71
|
-
|
|
71
|
+
|
|
72
72
|
//! Set the alpha value of all pixels which are equal to the color key
|
|
73
73
|
//! to zero. Color values are adjusted so that no borders show up when
|
|
74
74
|
//! the image is stretched or rotated.
|
|
75
75
|
void applyColorKey(Bitmap& bitmap, Color key);
|
|
76
|
-
|
|
76
|
+
|
|
77
77
|
void applyBorderFlags(Bitmap& dest, const Bitmap& source,
|
|
78
78
|
unsigned srcX, unsigned srcY, unsigned srcWidth, unsigned srcHeight,
|
|
79
79
|
unsigned borderFlags);
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
Bitmap
|
|
80
|
+
|
|
81
|
+
//! Loads any supported image into a Bitmap object.
|
|
82
|
+
Bitmap loadImageFile(const std::wstring& filename);
|
|
83
|
+
//! Loads any supported image into a Bitmap object.
|
|
84
|
+
Bitmap loadImageFile(Gosu::Reader input);
|
|
83
85
|
}
|
|
84
86
|
|
|
85
87
|
#endif
|
data/Gosu/ButtonsWin.hpp
CHANGED
|
File without changes
|
data/Gosu/Image.hpp
CHANGED
|
@@ -77,7 +77,7 @@ namespace Gosu
|
|
|
77
77
|
AlphaMode mode = amDefault) const;
|
|
78
78
|
|
|
79
79
|
//! Provides access to the underlying image data object.
|
|
80
|
-
|
|
80
|
+
ImageData& getData() const;
|
|
81
81
|
};
|
|
82
82
|
|
|
83
83
|
//! Convenience function that splits a BMP or PNG file into an array
|
|
@@ -92,7 +92,7 @@ namespace Gosu
|
|
|
92
92
|
void imagesFromTiledBitmap(Graphics& graphics, const std::wstring& filename,
|
|
93
93
|
int tileWidth, int tileHeight, bool tileable, Container& appendTo)
|
|
94
94
|
{
|
|
95
|
-
imagesFromTiledBitmap(graphics,
|
|
95
|
+
imagesFromTiledBitmap(graphics, loadImageFile(filename), tileWidth, tileHeight, tileable, appendTo);
|
|
96
96
|
}
|
|
97
97
|
|
|
98
98
|
//! Convenience function that splits a bitmap into an area of array
|
data/Gosu/ImageData.hpp
CHANGED
data/Gosu/Version.hpp
CHANGED
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
#if defined(GOSU_IS_IPHONE) || defined(__LP64__)
|
|
2
|
+
|
|
3
|
+
#include <Gosu/Graphics.hpp>
|
|
4
|
+
#include <Gosu/Bitmap.hpp>
|
|
5
|
+
#include <Gosu/IO.hpp>
|
|
6
|
+
#include <Gosu/Platform.hpp>
|
|
7
|
+
#include <Gosu/Utility.hpp>
|
|
8
|
+
#include <GosuImpl/MacUtility.hpp>
|
|
9
|
+
#include <boost/algorithm/string.hpp>
|
|
10
|
+
#include <boost/lexical_cast.hpp>
|
|
11
|
+
#include <stdexcept>
|
|
12
|
+
|
|
13
|
+
#ifdef GOSU_IS_IPHONE
|
|
14
|
+
#import <UIKit/UIKit.h>
|
|
15
|
+
#else
|
|
16
|
+
#import <AppKit/AppKit.h>
|
|
17
|
+
#endif
|
|
18
|
+
|
|
19
|
+
namespace Gosu
|
|
20
|
+
{
|
|
21
|
+
void CGImageToBitmap(CGImageRef imageRef, Bitmap& bitmap)
|
|
22
|
+
{
|
|
23
|
+
bitmap.resize(CGImageGetWidth(imageRef), CGImageGetHeight(imageRef));
|
|
24
|
+
|
|
25
|
+
static CFRef<CGColorSpaceRef> colorSpace(CGColorSpaceCreateDeviceRGB());
|
|
26
|
+
|
|
27
|
+
// Use a temporary context to draw the CGImage to the buffer.
|
|
28
|
+
CFRef<CGContextRef> context(CGBitmapContextCreate(bitmap.data(), bitmap.width(), bitmap.height(),
|
|
29
|
+
8, bitmap.width() * 4, colorSpace.obj(), kCGImageAlphaPremultipliedLast));
|
|
30
|
+
CGContextDrawImage(context.obj(), CGRectMake(0.0, 0.0, bitmap.width(), bitmap.height()), imageRef);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
#ifdef GOSU_IS_IPHONE
|
|
34
|
+
#define APPLE_IMAGE UIImage
|
|
35
|
+
void appleImageToBitmap(UIImage* image, Bitmap& bitmap)
|
|
36
|
+
{
|
|
37
|
+
CGImageToBitmap([image CGImage], bitmap);
|
|
38
|
+
}
|
|
39
|
+
#else
|
|
40
|
+
#define APPLE_IMAGE NSImage
|
|
41
|
+
void appleImageToBitmap(NSImage* image, Bitmap& bitmap)
|
|
42
|
+
{
|
|
43
|
+
//#ifdef __LP64__
|
|
44
|
+
CGImageToBitmap([image CGImageForProposedRect:NULL context:nil hints:nil], bitmap);
|
|
45
|
+
//#else
|
|
46
|
+
|
|
47
|
+
// The code below causes colors to be slightly off on my machine (64-bit, 10.6), but should
|
|
48
|
+
// do the same thing and work on 10.4 & 10.5.
|
|
49
|
+
// This may be due to http://stackoverflow.com/questions/2239785/nsimage-color-shift-on-snow-leopard
|
|
50
|
+
// TODO: As soon as I have a 10.4/10.5 machine to verify, use above code on 10.6 and the code
|
|
51
|
+
// below otherwise. If it works, BitmapBMP and BitmapPNG can be kicked out on OS X.
|
|
52
|
+
|
|
53
|
+
// id anyRep = [image bestRepresentationForDevice:nil];
|
|
54
|
+
// if (![anyRep isKindOfClass:[NSBitmapImageRep class]])
|
|
55
|
+
// throw std::logic_error("Cannot read vector graphics files");
|
|
56
|
+
// NSBitmapImageRep* rep = (NSBitmapImageRep*)anyRep;
|
|
57
|
+
//
|
|
58
|
+
// bitmap.resize([rep pixelsWide], [rep pixelsHigh]);
|
|
59
|
+
//
|
|
60
|
+
// CFRef<CGColorSpaceRef> colorSpace(CGColorSpaceCreateWithName(kCGColorSpaceGenericRGBLinear));
|
|
61
|
+
//
|
|
62
|
+
// // Use a temporary context to draw the NSImage to the buffer.
|
|
63
|
+
// CFRef<CGContextRef> context(CGBitmapContextCreate(bitmap.data(), bitmap.width(), bitmap.height(),
|
|
64
|
+
// 8, bitmap.width() * 4,
|
|
65
|
+
// colorSpace.obj(), kCGImageAlphaPremultipliedLast)); // kCGBitmapByteOrder32Host?
|
|
66
|
+
// [NSGraphicsContext saveGraphicsState];
|
|
67
|
+
// [NSGraphicsContext setCurrentContext:[NSGraphicsContext graphicsContextWithGraphicsPort:context.obj() flipped:NO]];
|
|
68
|
+
// [image drawInRect:NSMakeRect(0, 0, bitmap.width(), bitmap.height()) fromRect:NSZeroRect operation:NSCompositeCopy fraction:1.0];
|
|
69
|
+
// [NSGraphicsContext restoreGraphicsState];
|
|
70
|
+
//#endif
|
|
71
|
+
}
|
|
72
|
+
#endif
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
Gosu::Reader Gosu::loadFromBMP(Bitmap& bitmap, Reader reader)
|
|
76
|
+
{
|
|
77
|
+
return loadFromPNG(bitmap, reader);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
Gosu::Reader Gosu::loadFromPNG(Bitmap& bitmap, Reader reader)
|
|
81
|
+
{
|
|
82
|
+
ObjRef<NSAutoreleasePool> pool([NSAutoreleasePool new]);
|
|
83
|
+
|
|
84
|
+
std::size_t length = reader.resource().size() - reader.position();
|
|
85
|
+
ObjRef<NSMutableData> buffer([[NSMutableData alloc] initWithLength: length]);
|
|
86
|
+
reader.read([buffer.get() mutableBytes], length);
|
|
87
|
+
|
|
88
|
+
ObjRef<APPLE_IMAGE> image([[APPLE_IMAGE alloc] initWithData: buffer.get()]);
|
|
89
|
+
appleImageToBitmap(image.obj(), bitmap);
|
|
90
|
+
return reader;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// OS X still completely uses the libpng based saveToPNG.
|
|
94
|
+
#ifdef GOSU_IS_IPHONE
|
|
95
|
+
Gosu::Writer Gosu::saveToPNG(const Bitmap& bmp, Writer writer)
|
|
96
|
+
{
|
|
97
|
+
ObjRef<NSAutoreleasePool> pool([NSAutoreleasePool new]);
|
|
98
|
+
|
|
99
|
+
CGDataProviderRef dataProvider =
|
|
100
|
+
CGDataProviderCreateWithData(0, bmp.data(), bmp.width() * bmp.height() * 4, 0);
|
|
101
|
+
|
|
102
|
+
static CGColorSpaceRef colorspace = CGColorSpaceCreateDeviceRGB();
|
|
103
|
+
|
|
104
|
+
CGImageRef imageRef =
|
|
105
|
+
CGImageCreate(bmp.width(), bmp.height(), 8, 32, bmp.width() * 4, colorspace,
|
|
106
|
+
kCGImageAlphaLast, dataProvider, 0, false, kCGRenderingIntentDefault);
|
|
107
|
+
|
|
108
|
+
ObjRef<UIImage> image([[UIImage alloc] initWithCGImage: imageRef]);
|
|
109
|
+
|
|
110
|
+
NSData* pngRef = UIImagePNGRepresentation(image.get());
|
|
111
|
+
writer.write([pngRef bytes], [pngRef length]);
|
|
112
|
+
image.reset();
|
|
113
|
+
|
|
114
|
+
CGImageRelease(imageRef);
|
|
115
|
+
|
|
116
|
+
CGDataProviderRelease(dataProvider);
|
|
117
|
+
|
|
118
|
+
return writer;
|
|
119
|
+
}
|
|
120
|
+
#endif
|
|
121
|
+
|
|
122
|
+
Gosu::Bitmap Gosu::loadImageFile(const std::wstring& filename)
|
|
123
|
+
{
|
|
124
|
+
ObjRef<NSString> filenameRef([[NSString alloc] initWithUTF8String: wstringToUTF8(filename).c_str()]);
|
|
125
|
+
ObjRef<APPLE_IMAGE> image([[APPLE_IMAGE alloc] initWithContentsOfFile: filenameRef.obj()]);
|
|
126
|
+
Bitmap bitmap;
|
|
127
|
+
appleImageToBitmap(image.obj(), bitmap);
|
|
128
|
+
if (boost::iends_with(filename, L".bmp"))
|
|
129
|
+
applyColorKey(bitmap, Color::FUCHSIA);
|
|
130
|
+
return bitmap;
|
|
131
|
+
}
|
|
132
|
+
#endif
|
|
@@ -33,6 +33,9 @@ namespace Gosu
|
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
+
// iOS does not include this file, OS X 64-bit uses NSImage/ImageIO instead.
|
|
37
|
+
// OS X does still use saveToPNG though.
|
|
38
|
+
#if !defined(GOSU_IS_MAC) || (!defined(GOSU_IS_IPHONE) && !defined(__LP64__))
|
|
36
39
|
Gosu::Reader Gosu::loadFromPNG(Bitmap& out, Reader reader)
|
|
37
40
|
{
|
|
38
41
|
#if 0
|
|
@@ -83,7 +86,7 @@ Gosu::Reader Gosu::loadFromPNG(Bitmap& out, Reader reader)
|
|
|
83
86
|
bitDepth = png_get_bit_depth(pngPtr, infoPtr);
|
|
84
87
|
|
|
85
88
|
png_bytep trans;
|
|
86
|
-
int numTrans =
|
|
89
|
+
int numTrans = -1;
|
|
87
90
|
if (png_get_valid(pngPtr, infoPtr, PNG_INFO_tRNS))
|
|
88
91
|
png_get_tRNS(pngPtr, infoPtr, &trans, &numTrans, NULL);
|
|
89
92
|
// This function only understands palette images with a bit depth <= 8 and
|
|
@@ -183,11 +186,9 @@ Gosu::Reader Gosu::loadFromPNG(Bitmap& out, Reader reader)
|
|
|
183
186
|
}
|
|
184
187
|
|
|
185
188
|
int alpha = 255;
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
alpha = 0;
|
|
190
|
-
}
|
|
189
|
+
if (palIndex <= numTrans)
|
|
190
|
+
alpha = trans[palIndex];
|
|
191
|
+
|
|
191
192
|
c.setAlpha(alpha);
|
|
192
193
|
c.setRed (palColors[palIndex].red);
|
|
193
194
|
c.setGreen(palColors[palIndex].green);
|
|
@@ -213,6 +214,7 @@ Gosu::Reader Gosu::loadFromPNG(Bitmap& out, Reader reader)
|
|
|
213
214
|
|
|
214
215
|
return reader; // TODO: Does this point to the right location?
|
|
215
216
|
}
|
|
217
|
+
#endif
|
|
216
218
|
|
|
217
219
|
Gosu::Writer Gosu::saveToPNG(const Bitmap& bmp, Writer writer)
|
|
218
220
|
{
|
|
@@ -3,21 +3,30 @@
|
|
|
3
3
|
#include <Gosu/IO.hpp>
|
|
4
4
|
#include <Gosu/Platform.hpp>
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
// OS X 64-bit and iOS use Apple APIs.
|
|
7
|
+
#if !defined(GOSU_IS_MAC) || (!defined(GOSU_IS_IPHONE) && !defined(__LP64__))
|
|
8
|
+
Gosu::Bitmap Gosu::loadImageFile(const std::wstring& filename)
|
|
9
|
+
{
|
|
10
|
+
Buffer buffer;
|
|
11
|
+
loadFile(buffer, filename);
|
|
12
|
+
return loadImageFile(buffer.frontReader());
|
|
13
|
+
}
|
|
14
|
+
#endif
|
|
15
|
+
|
|
16
|
+
Gosu::Bitmap Gosu::loadImageFile(Gosu::Reader reader)
|
|
7
17
|
{
|
|
8
|
-
Buffer buf;
|
|
9
|
-
loadFile(buf, filename);
|
|
10
18
|
Bitmap bmp;
|
|
11
19
|
|
|
12
20
|
char formatTester[2];
|
|
13
|
-
|
|
21
|
+
reader.read(formatTester, sizeof formatTester);
|
|
22
|
+
reader.setPosition(0);
|
|
14
23
|
if (formatTester[0] == 'B' && formatTester[1] == 'M')
|
|
15
24
|
{
|
|
16
|
-
loadFromBMP(bmp,
|
|
25
|
+
loadFromBMP(bmp, reader);
|
|
17
26
|
applyColorKey(bmp, Color::FUCHSIA);
|
|
18
27
|
}
|
|
19
28
|
else
|
|
20
|
-
loadFromPNG(bmp,
|
|
29
|
+
loadFromPNG(bmp, reader);
|
|
21
30
|
return bmp;
|
|
22
31
|
}
|
|
23
32
|
|
|
@@ -109,7 +109,11 @@ public:
|
|
|
109
109
|
{
|
|
110
110
|
// Allows us to make some assumptions.
|
|
111
111
|
if (ops.empty())
|
|
112
|
+
{
|
|
113
|
+
BOOST_FOREACH (const CodeMap::value_type& fn, code)
|
|
114
|
+
fn.second();
|
|
112
115
|
return;
|
|
116
|
+
}
|
|
113
117
|
|
|
114
118
|
// Apply Z-Ordering.
|
|
115
119
|
std::stable_sort(ops.begin(), ops.end());
|
|
@@ -297,7 +297,7 @@ std::auto_ptr<Gosu::ImageData> Gosu::Graphics::endRecording()
|
|
|
297
297
|
if (pimpl->queues.size() == 1)
|
|
298
298
|
throw std::logic_error("No macro recording in progress that can be captured");
|
|
299
299
|
|
|
300
|
-
std::auto_ptr<ImageData> result(new Macro(pimpl->queues.back()));
|
|
300
|
+
std::auto_ptr<ImageData> result(new Macro(*this, pimpl->queues.back()));
|
|
301
301
|
pimpl->queues.pop_back();
|
|
302
302
|
return result;
|
|
303
303
|
}
|
|
@@ -413,16 +413,14 @@ std::auto_ptr<Gosu::ImageData> Gosu::Graphics::createImage(
|
|
|
413
413
|
if (srcX == 0 && srcWidth == src.width() &&
|
|
414
414
|
srcY == 0 && srcHeight == src.height())
|
|
415
415
|
{
|
|
416
|
-
data = texture->tryAlloc(*this, pimpl->absoluteTransforms, pimpl->queues, texture,
|
|
417
|
-
src, 0, 0, src.width(), src.height(), 0);
|
|
416
|
+
data = texture->tryAlloc(*this, pimpl->absoluteTransforms, pimpl->queues, texture, src, 0);
|
|
418
417
|
}
|
|
419
418
|
else
|
|
420
419
|
{
|
|
421
420
|
Bitmap trimmedSrc;
|
|
422
421
|
trimmedSrc.resize(srcWidth, srcHeight);
|
|
423
422
|
trimmedSrc.insert(src, 0, 0, srcX, srcY, srcWidth, srcHeight);
|
|
424
|
-
data = texture->tryAlloc(*this, pimpl->absoluteTransforms, pimpl->queues, texture,
|
|
425
|
-
trimmedSrc, 0, 0, trimmedSrc.width(), trimmedSrc.height(), 0);
|
|
423
|
+
data = texture->tryAlloc(*this, pimpl->absoluteTransforms, pimpl->queues, texture, trimmedSrc, 0);
|
|
426
424
|
}
|
|
427
425
|
|
|
428
426
|
if (!data.get())
|
|
@@ -454,7 +452,7 @@ std::auto_ptr<Gosu::ImageData> Gosu::Graphics::createImage(
|
|
|
454
452
|
boost::shared_ptr<Texture> texture(*i);
|
|
455
453
|
|
|
456
454
|
std::auto_ptr<ImageData> data;
|
|
457
|
-
data = texture->tryAlloc(*this, pimpl->absoluteTransforms, pimpl->queues, texture, bmp,
|
|
455
|
+
data = texture->tryAlloc(*this, pimpl->absoluteTransforms, pimpl->queues, texture, bmp, 1);
|
|
458
456
|
if (data.get())
|
|
459
457
|
return data;
|
|
460
458
|
}
|
|
@@ -466,7 +464,7 @@ std::auto_ptr<Gosu::ImageData> Gosu::Graphics::createImage(
|
|
|
466
464
|
pimpl->textures.push_back(texture);
|
|
467
465
|
|
|
468
466
|
std::auto_ptr<ImageData> data;
|
|
469
|
-
data = texture->tryAlloc(*this, pimpl->absoluteTransforms, pimpl->queues, texture, bmp,
|
|
467
|
+
data = texture->tryAlloc(*this, pimpl->absoluteTransforms, pimpl->queues, texture, bmp, 1);
|
|
470
468
|
if (!data.get())
|
|
471
469
|
throw std::logic_error("Internal texture block allocation error");
|
|
472
470
|
|
data/GosuImpl/Graphics/Image.cpp
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
Gosu::Image::Image(Graphics& graphics, const std::wstring& filename, bool tileable)
|
|
9
9
|
{
|
|
10
10
|
// Forward.
|
|
11
|
-
Image(graphics,
|
|
11
|
+
Image(graphics, loadImageFile(filename), tileable).data.swap(data);
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
Gosu::Image::Image(Graphics& graphics, const std::wstring& filename,
|
|
@@ -16,7 +16,7 @@ Gosu::Image::Image(Graphics& graphics, const std::wstring& filename,
|
|
|
16
16
|
bool tileable)
|
|
17
17
|
{
|
|
18
18
|
// Forward.
|
|
19
|
-
Image(graphics,
|
|
19
|
+
Image(graphics, loadImageFile(filename), srcX, srcY, srcWidth, srcHeight, tileable).data.swap(data);
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
Gosu::Image::Image(Graphics& graphics, const Bitmap& source, bool tileable)
|
|
@@ -26,15 +26,15 @@ Gosu::Image::Image(Graphics& graphics, const Bitmap& source, bool tileable)
|
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
Gosu::Image::Image(Graphics& graphics, const Bitmap& source,
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
:
|
|
29
|
+
unsigned srcX, unsigned srcY, unsigned srcWidth, unsigned srcHeight,
|
|
30
|
+
bool tileable)
|
|
31
|
+
: data(graphics.createImage(source, srcX, srcY, srcWidth, srcHeight,
|
|
32
32
|
tileable ? Gosu::bfTileable : Gosu::bfSmooth))
|
|
33
33
|
{
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
Gosu::Image::Image(std::auto_ptr<ImageData> data)
|
|
37
|
-
:
|
|
37
|
+
: data(data.release())
|
|
38
38
|
{
|
|
39
39
|
}
|
|
40
40
|
|
|
@@ -103,7 +103,7 @@ void Gosu::Image::drawRot(double x, double y, ZPos z,
|
|
|
103
103
|
c, z, mode);
|
|
104
104
|
}
|
|
105
105
|
|
|
106
|
-
|
|
106
|
+
Gosu::ImageData& Gosu::Image::getData() const
|
|
107
107
|
{
|
|
108
108
|
return *data;
|
|
109
109
|
}
|
|
@@ -126,3 +126,10 @@ Gosu::Bitmap Gosu::LargeImageData::toBitmap() const
|
|
|
126
126
|
bitmap.insert(parts[y * partsX + x]->toBitmap(), x * partWidth, y * partHeight);
|
|
127
127
|
return bitmap;
|
|
128
128
|
}
|
|
129
|
+
|
|
130
|
+
void Gosu::LargeImageData::insert(const Bitmap& bitmap, int atX, int atY)
|
|
131
|
+
{
|
|
132
|
+
for (int x = 0; x < partsX; ++x)
|
|
133
|
+
for (int y = 0; y < partsY; ++y)
|
|
134
|
+
parts[y * partsX + x]->insert(bitmap, atX - x * partWidth, atY - y * partHeight);
|
|
135
|
+
}
|
data/GosuImpl/Graphics/Macro.hpp
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
#include <Gosu/ImageData.hpp>
|
|
6
6
|
#include <GosuImpl/Graphics/Common.hpp>
|
|
7
7
|
#include <GosuImpl/Graphics/DrawOpQueue.hpp>
|
|
8
|
+
#include <boost/bind.hpp>
|
|
8
9
|
#include <boost/foreach.hpp>
|
|
9
10
|
#include <boost/scoped_ptr.hpp>
|
|
10
11
|
#include <cmath>
|
|
@@ -15,12 +16,14 @@ class Gosu::Macro : public Gosu::ImageData
|
|
|
15
16
|
VertexArray vertexArray;
|
|
16
17
|
unsigned w, h;
|
|
17
18
|
|
|
19
|
+
Graphics& graphics;
|
|
18
20
|
public:
|
|
19
|
-
Macro(DrawOpQueue& queue)
|
|
21
|
+
Macro(Graphics& graphics, DrawOpQueue& queue)
|
|
22
|
+
: graphics(graphics)
|
|
20
23
|
{
|
|
21
24
|
queue.compileTo(vertexArray);
|
|
22
25
|
double left = 0, right = 0, top = 0, bottom = 0;
|
|
23
|
-
BOOST_FOREACH(const ArrayVertex& av, vertexArray)
|
|
26
|
+
BOOST_FOREACH (const ArrayVertex& av, vertexArray)
|
|
24
27
|
{
|
|
25
28
|
left = std::min<double>(left, av.vertices[0]);
|
|
26
29
|
right = std::max<double>(right, av.vertices[0]);
|
|
@@ -47,27 +50,37 @@ public:
|
|
|
47
50
|
double x4, double y4, Color c4,
|
|
48
51
|
ZPos z, AlphaMode mode) const
|
|
49
52
|
{
|
|
50
|
-
|
|
51
|
-
|
|
53
|
+
boost::function<void()> f = boost::bind(&Macro::realDraw, this, x1, y1, x2, y2, x3, y3);
|
|
54
|
+
graphics.scheduleGL(f, z);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
void realDraw(double x1, double y1,
|
|
58
|
+
double x2, double y2,
|
|
59
|
+
double x3, double y3) const
|
|
60
|
+
{
|
|
61
|
+
// TODO: Commented out for now on the iPhone.
|
|
52
62
|
// To work, it would need to reset the VertexPointer etc. after doing its work.
|
|
63
|
+
#ifndef GOSU_IS_IPHONE
|
|
64
|
+
glEnable(GL_BLEND);
|
|
65
|
+
RenderState rs;
|
|
66
|
+
rs.setTexName(1);
|
|
67
|
+
rs.setAlphaMode(amDefault);
|
|
68
|
+
|
|
69
|
+
// TODO: We should apply current transformations either here or in draw(), or both.
|
|
70
|
+
// TODO: Also, calculate the transform as a matrix and use RenderState::setTransform.
|
|
53
71
|
|
|
54
72
|
glMatrixMode(GL_MODELVIEW);
|
|
55
|
-
glPushMatrix();
|
|
73
|
+
//glPushMatrix();
|
|
56
74
|
glTranslated(x1, y1, 0);
|
|
57
75
|
glScaled((x2 - x1) / width(), (y3 - y1) / height(), 1);
|
|
58
76
|
|
|
59
|
-
glEnable(GL_TEXTURE_2D);
|
|
60
|
-
glBindTexture(GL_TEXTURE_2D, 1);
|
|
61
|
-
|
|
62
77
|
glInterleavedArrays(GL_T2F_C4UB_V3F, 0, &vertexArray[0]);
|
|
63
78
|
|
|
64
79
|
glDrawArrays(GL_QUADS, 0, vertexArray.size());
|
|
65
80
|
glFlush();
|
|
66
81
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
glPopMatrix();
|
|
70
|
-
#endif
|
|
82
|
+
//glPopMatrix();
|
|
83
|
+
#endif
|
|
71
84
|
}
|
|
72
85
|
|
|
73
86
|
boost::optional<Gosu::GLTexInfo> glTexInfo() const
|
|
@@ -77,7 +90,12 @@ public:
|
|
|
77
90
|
|
|
78
91
|
Gosu::Bitmap toBitmap() const
|
|
79
92
|
{
|
|
80
|
-
throw std::logic_error("Gosu::Macro cannot be rendered
|
|
93
|
+
throw std::logic_error("Gosu::Macro cannot be rendered as Gosu::Bitmap");
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
void insert(const Bitmap& bitmap, int x, int y)
|
|
97
|
+
{
|
|
98
|
+
throw std::logic_error("Gosu::Macro cannot be updated with a Gosu::Bitmap");
|
|
81
99
|
}
|
|
82
100
|
};
|
|
83
101
|
|
|
@@ -57,3 +57,34 @@ Gosu::Bitmap Gosu::TexChunk::toBitmap() const
|
|
|
57
57
|
{
|
|
58
58
|
return texture->toBitmap(x, y, w, h);
|
|
59
59
|
}
|
|
60
|
+
|
|
61
|
+
void Gosu::TexChunk::insert(const Bitmap& original, int x, int y)
|
|
62
|
+
{
|
|
63
|
+
// TODO: Should respect borderFlags.
|
|
64
|
+
|
|
65
|
+
Bitmap alternate;
|
|
66
|
+
const Bitmap* bitmap = &original;
|
|
67
|
+
if (x < 0 || y < 0 || x + original.width() > w || y + original.height() > h)
|
|
68
|
+
{
|
|
69
|
+
int offsetX = 0, offsetY = 0, trimmedWidth = original.width(), trimmedHeight = original.height();
|
|
70
|
+
if (x < 0)
|
|
71
|
+
offsetX = x, trimmedWidth += x, x = 0;
|
|
72
|
+
if (y < 0)
|
|
73
|
+
offsetY = y, trimmedHeight += y, y = 0;
|
|
74
|
+
if (x + trimmedWidth > w)
|
|
75
|
+
trimmedWidth -= (w - x - trimmedWidth);
|
|
76
|
+
if (y + trimmedHeight > h)
|
|
77
|
+
trimmedHeight -= (h - y - trimmedHeight);
|
|
78
|
+
|
|
79
|
+
if (trimmedWidth <= 0 || trimmedHeight <= 0)
|
|
80
|
+
return;
|
|
81
|
+
|
|
82
|
+
alternate.resize(trimmedWidth, trimmedHeight);
|
|
83
|
+
alternate.insert(original, offsetX, offsetY);
|
|
84
|
+
bitmap = &alternate;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
glBindTexture(GL_TEXTURE_2D, texture->texName());
|
|
88
|
+
glTexSubImage2D(GL_TEXTURE_2D, 0, this->x + x, this->y + y, bitmap->width(), bitmap->height(),
|
|
89
|
+
Color::GL_FORMAT, GL_UNSIGNED_BYTE, bitmap->data());
|
|
90
|
+
}
|
|
@@ -62,14 +62,11 @@ GLuint Gosu::Texture::texName() const
|
|
|
62
62
|
|
|
63
63
|
std::auto_ptr<Gosu::TexChunk>
|
|
64
64
|
Gosu::Texture::tryAlloc(Graphics& graphics, Transforms& transforms,
|
|
65
|
-
DrawOpQueueStack& queues, boost::shared_ptr<Texture> ptr,
|
|
66
|
-
const Bitmap& bmp, unsigned srcX,
|
|
67
|
-
unsigned srcY, unsigned srcWidth,
|
|
68
|
-
unsigned srcHeight, unsigned padding)
|
|
65
|
+
DrawOpQueueStack& queues, boost::shared_ptr<Texture> ptr, const Bitmap& bmp, unsigned padding)
|
|
69
66
|
{
|
|
70
67
|
std::auto_ptr<Gosu::TexChunk> result;
|
|
71
68
|
|
|
72
|
-
boost::optional<BlockAllocator::Block> block = allocator.alloc(
|
|
69
|
+
boost::optional<BlockAllocator::Block> block = allocator.alloc(bmp.width(), bmp.height());
|
|
73
70
|
if (!block)
|
|
74
71
|
return result;
|
|
75
72
|
|
|
@@ -25,8 +25,7 @@ namespace Gosu
|
|
|
25
25
|
GLuint texName() const;
|
|
26
26
|
std::auto_ptr<TexChunk>
|
|
27
27
|
tryAlloc(Graphics& graphics, Transforms& transforms, DrawOpQueueStack& queues, boost::shared_ptr<Texture> ptr,
|
|
28
|
-
const Bitmap& bmp, unsigned
|
|
29
|
-
unsigned padding);
|
|
28
|
+
const Bitmap& bmp, unsigned padding);
|
|
30
29
|
void free(unsigned x, unsigned y);
|
|
31
30
|
Gosu::Bitmap toBitmap(unsigned x, unsigned y, unsigned width, unsigned height) const;
|
|
32
31
|
};
|
data/GosuImpl/MacUtility.hpp
CHANGED
data/GosuImpl/RubyGosu.swg
CHANGED
|
@@ -127,6 +127,18 @@
|
|
|
127
127
|
$1 = *reinterpret_cast<Gosu::Color*>(ptr);
|
|
128
128
|
}
|
|
129
129
|
|
|
130
|
+
// Allow integral constants to be passed in place of Color values.
|
|
131
|
+
%typemap(in) boost::optional<Gosu::Color> {
|
|
132
|
+
if (TYPE($input) == T_FIXNUM || TYPE($input) == T_BIGNUM)
|
|
133
|
+
$1 = Gosu::Color(NUM2UINT($input));
|
|
134
|
+
else {
|
|
135
|
+
void* ptr;
|
|
136
|
+
int res = SWIG_ConvertPtr($input, &ptr, SWIGTYPE_p_Gosu__Color, 0);
|
|
137
|
+
if (SWIG_IsOK(res) && ptr)
|
|
138
|
+
$1 = *reinterpret_cast<Gosu::Color*>(ptr);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
130
142
|
// Header inclusion (order irrelevant)
|
|
131
143
|
%module(directors="1") gosu
|
|
132
144
|
%{
|
|
@@ -220,7 +232,7 @@ namespace Gosu
|
|
|
220
232
|
{
|
|
221
233
|
VALUE to_str = rb_funcall(val, rb_intern("to_str"), 0);
|
|
222
234
|
const char* filename = StringValuePtr(to_str);
|
|
223
|
-
return
|
|
235
|
+
return loadImageFile(Gosu::utf8ToWstring(filename));
|
|
224
236
|
}
|
|
225
237
|
|
|
226
238
|
// Otherwise, try to call .to_blob on it.
|
|
@@ -368,8 +380,8 @@ namespace Gosu {
|
|
|
368
380
|
return stream.str();
|
|
369
381
|
}
|
|
370
382
|
|
|
371
|
-
bool operator==(Gosu::Color other) {
|
|
372
|
-
return *$self == other;
|
|
383
|
+
bool operator==(boost::optional<Gosu::Color> other) {
|
|
384
|
+
return other && *$self == *other;
|
|
373
385
|
}
|
|
374
386
|
}
|
|
375
387
|
|
|
@@ -425,8 +437,7 @@ namespace Gosu {
|
|
|
425
437
|
%include "../Gosu/Image.hpp"
|
|
426
438
|
%extend Gosu::Image {
|
|
427
439
|
Image(Gosu::Window& window, VALUE source, bool tileable = false) {
|
|
428
|
-
return new Gosu::Image(window.graphics(),
|
|
429
|
-
Gosu::loadBitmap(source), tileable);
|
|
440
|
+
return new Gosu::Image(window.graphics(), Gosu::loadBitmap(source), tileable);
|
|
430
441
|
}
|
|
431
442
|
Image(Gosu::Window& window, VALUE source, bool tileable,
|
|
432
443
|
unsigned srcX, unsigned srcY, unsigned srcWidth, unsigned srcHeight) {
|
|
@@ -456,23 +467,26 @@ namespace Gosu {
|
|
|
456
467
|
}
|
|
457
468
|
%newobject fromText4;
|
|
458
469
|
static Gosu::Image* fromText4(Gosu::Window& window, const std::wstring& text,
|
|
459
|
-
const std::wstring& fontName, unsigned fontHeight)
|
|
470
|
+
const std::wstring& fontName, unsigned fontHeight)
|
|
471
|
+
{
|
|
460
472
|
Gosu::Bitmap bmp = Gosu::createText(text, fontName, fontHeight);
|
|
461
473
|
return new Gosu::Image(window.graphics(), bmp);
|
|
462
474
|
}
|
|
463
475
|
%newobject fromText7;
|
|
464
476
|
static Gosu::Image* fromText7(Gosu::Window& window, const std::wstring& text,
|
|
465
|
-
|
|
466
|
-
|
|
477
|
+
const std::wstring& fontName, unsigned fontHeight,
|
|
478
|
+
int lineSpacing, unsigned maxWidth, TextAlign align)
|
|
479
|
+
{
|
|
467
480
|
Gosu::Bitmap bmp = Gosu::createText(text, fontName, fontHeight, lineSpacing, maxWidth, align);
|
|
468
481
|
return new Gosu::Image(window.graphics(), bmp);
|
|
469
482
|
}
|
|
470
|
-
static std::vector<Gosu::Image*> loadTiles(Gosu::Window& window,
|
|
471
|
-
|
|
483
|
+
static std::vector<Gosu::Image*> loadTiles(Gosu::Window& window,
|
|
484
|
+
VALUE source, int tileWidth, int tileHeight, bool tileable)
|
|
485
|
+
{
|
|
472
486
|
std::vector<Gosu::Image*> vec;
|
|
473
487
|
// TODO: const correctness (<- did I mean exception safety?)
|
|
474
488
|
Gosu::imagesFromTiledBitmap(window.graphics(), Gosu::loadBitmap(source),
|
|
475
|
-
|
|
489
|
+
tileWidth, tileHeight, tileable, vec);
|
|
476
490
|
return vec;
|
|
477
491
|
}
|
|
478
492
|
std::string toBlob() const
|
|
@@ -500,6 +514,10 @@ namespace Gosu {
|
|
|
500
514
|
Gosu::saveToPNG(bmp, buf.backWriter());
|
|
501
515
|
Gosu::saveFile(buf, filename);
|
|
502
516
|
}
|
|
517
|
+
void insert(VALUE source, int x, int y)
|
|
518
|
+
{
|
|
519
|
+
$self->getData().insert(Gosu::loadBitmap(source), x, y);
|
|
520
|
+
}
|
|
503
521
|
}
|
|
504
522
|
|
|
505
523
|
// Inspection:
|
data/GosuImpl/RubyGosu_wrap.cxx
CHANGED
|
@@ -2172,11 +2172,12 @@ namespace Swig {
|
|
|
2172
2172
|
#define SWIGTYPE_p_Gosu__TextInput swig_types[10]
|
|
2173
2173
|
#define SWIGTYPE_p_Gosu__Window swig_types[11]
|
|
2174
2174
|
#define SWIGTYPE_p_boost__arrayT_double_16_t swig_types[12]
|
|
2175
|
-
#define
|
|
2176
|
-
#define
|
|
2177
|
-
#define
|
|
2178
|
-
|
|
2179
|
-
static
|
|
2175
|
+
#define SWIGTYPE_p_boost__optionalT_Gosu__Color_t swig_types[13]
|
|
2176
|
+
#define SWIGTYPE_p_char swig_types[14]
|
|
2177
|
+
#define SWIGTYPE_p_double swig_types[15]
|
|
2178
|
+
#define SWIGTYPE_p_std__wstring swig_types[16]
|
|
2179
|
+
static swig_type_info *swig_types[18];
|
|
2180
|
+
static swig_module_info swig_module = {swig_types, 17, 0, 0, 0, 0};
|
|
2180
2181
|
#define SWIG_TypeQuery(name) SWIG_TypeQueryModule(&swig_module, &swig_module, name)
|
|
2181
2182
|
#define SWIG_MangledTypeQuery(name) SWIG_MangledTypeQueryModule(&swig_module, &swig_module, name)
|
|
2182
2183
|
|
|
@@ -2292,7 +2293,7 @@ namespace Gosu
|
|
|
2292
2293
|
{
|
|
2293
2294
|
VALUE to_str = rb_funcall(val, rb_intern("to_str"), 0);
|
|
2294
2295
|
const char* filename = StringValuePtr(to_str);
|
|
2295
|
-
return
|
|
2296
|
+
return loadImageFile(Gosu::utf8ToWstring(filename));
|
|
2296
2297
|
}
|
|
2297
2298
|
|
|
2298
2299
|
// Otherwise, try to call .to_blob on it.
|
|
@@ -2516,8 +2517,8 @@ SWIG_From_std_string (const std::string& s)
|
|
|
2516
2517
|
}
|
|
2517
2518
|
}
|
|
2518
2519
|
|
|
2519
|
-
SWIGINTERN bool Gosu_Color_operator_Se__Se_(Gosu::Color *self,Gosu::Color other){
|
|
2520
|
-
return *self == other;
|
|
2520
|
+
SWIGINTERN bool Gosu_Color_operator_Se__Se_(Gosu::Color *self,boost::optional< Gosu::Color > other){
|
|
2521
|
+
return other && *self == *other;
|
|
2521
2522
|
}
|
|
2522
2523
|
|
|
2523
2524
|
SWIGINTERNINLINE VALUE
|
|
@@ -2637,8 +2638,7 @@ SWIG_AsVal_bool (VALUE obj, bool *val)
|
|
|
2637
2638
|
}
|
|
2638
2639
|
|
|
2639
2640
|
SWIGINTERN Gosu::Image *new_Gosu_Image__SWIG_0(Gosu::Window &window,VALUE source,bool tileable=false){
|
|
2640
|
-
return new Gosu::Image(window.graphics(),
|
|
2641
|
-
Gosu::loadBitmap(source), tileable);
|
|
2641
|
+
return new Gosu::Image(window.graphics(), Gosu::loadBitmap(source), tileable);
|
|
2642
2642
|
}
|
|
2643
2643
|
SWIGINTERN Gosu::Image *new_Gosu_Image__SWIG_1(Gosu::Window &window,VALUE source,bool tileable,unsigned int srcX,unsigned int srcY,unsigned int srcWidth,unsigned int srcHeight){
|
|
2644
2644
|
return new Gosu::Image(window.graphics(), Gosu::loadBitmap(source),
|
|
@@ -2666,7 +2666,7 @@ SWIGINTERN std::vector< Gosu::Image * > Gosu_Image_loadTiles(Gosu::Window &windo
|
|
|
2666
2666
|
std::vector<Gosu::Image*> vec;
|
|
2667
2667
|
// TODO: const correctness (<- did I mean exception safety?)
|
|
2668
2668
|
Gosu::imagesFromTiledBitmap(window.graphics(), Gosu::loadBitmap(source),
|
|
2669
|
-
|
|
2669
|
+
tileWidth, tileHeight, tileable, vec);
|
|
2670
2670
|
return vec;
|
|
2671
2671
|
}
|
|
2672
2672
|
SWIGINTERN std::string Gosu_Image_toBlob(Gosu::Image const *self){
|
|
@@ -2690,6 +2690,9 @@ SWIGINTERN void Gosu_Image_save(Gosu::Image const *self,std::wstring const &file
|
|
|
2690
2690
|
Gosu::saveToPNG(bmp, buf.backWriter());
|
|
2691
2691
|
Gosu::saveFile(buf, filename);
|
|
2692
2692
|
}
|
|
2693
|
+
SWIGINTERN void Gosu_Image_insert(Gosu::Image *self,VALUE source,int x,int y){
|
|
2694
|
+
self->getData().insert(Gosu::loadBitmap(source), x, y);
|
|
2695
|
+
}
|
|
2693
2696
|
SWIGINTERN unsigned int Gosu_TextInput_caret_pos(Gosu::TextInput const *self){
|
|
2694
2697
|
return RUBY_18_19(Gosu::wstringToUTF8(self->text().substr(0, self->caretPos())).size(),
|
|
2695
2698
|
self->caretPos());
|
|
@@ -5023,7 +5026,7 @@ Equality comparison operator.
|
|
|
5023
5026
|
SWIGINTERN VALUE
|
|
5024
5027
|
_wrap_Color___eq__(int argc, VALUE *argv, VALUE self) {
|
|
5025
5028
|
Gosu::Color *arg1 = (Gosu::Color *) 0 ;
|
|
5026
|
-
Gosu::Color arg2 ;
|
|
5029
|
+
boost::optional< Gosu::Color > arg2 ;
|
|
5027
5030
|
void *argp1 = 0 ;
|
|
5028
5031
|
int res1 = 0 ;
|
|
5029
5032
|
bool result;
|
|
@@ -5038,15 +5041,14 @@ _wrap_Color___eq__(int argc, VALUE *argv, VALUE self) {
|
|
|
5038
5041
|
}
|
|
5039
5042
|
arg1 = reinterpret_cast< Gosu::Color * >(argp1);
|
|
5040
5043
|
{
|
|
5041
|
-
|
|
5042
|
-
int res = SWIG_ConvertPtr(argv[0], &ptr, SWIGTYPE_p_Gosu__Color, 0);
|
|
5043
|
-
if (!SWIG_IsOK(res))
|
|
5044
|
-
// TODO: error checking
|
|
5044
|
+
if (TYPE(argv[0]) == T_FIXNUM || TYPE(argv[0]) == T_BIGNUM)
|
|
5045
5045
|
arg2 = Gosu::Color(NUM2UINT(argv[0]));
|
|
5046
|
-
else
|
|
5047
|
-
|
|
5048
|
-
|
|
5049
|
-
|
|
5046
|
+
else {
|
|
5047
|
+
void* ptr;
|
|
5048
|
+
int res = SWIG_ConvertPtr(argv[0], &ptr, SWIGTYPE_p_Gosu__Color, 0);
|
|
5049
|
+
if (SWIG_IsOK(res) && ptr)
|
|
5050
|
+
arg2 = *reinterpret_cast<Gosu::Color*>(ptr);
|
|
5051
|
+
}
|
|
5050
5052
|
}
|
|
5051
5053
|
{
|
|
5052
5054
|
try {
|
|
@@ -7327,6 +7329,60 @@ fail:
|
|
|
7327
7329
|
}
|
|
7328
7330
|
|
|
7329
7331
|
|
|
7332
|
+
|
|
7333
|
+
/*
|
|
7334
|
+
Document-method: Gosu::Image.insert
|
|
7335
|
+
|
|
7336
|
+
call-seq:
|
|
7337
|
+
insert(source, x, y)
|
|
7338
|
+
|
|
7339
|
+
Insert one or more new elements in the Image.
|
|
7340
|
+
*/
|
|
7341
|
+
SWIGINTERN VALUE
|
|
7342
|
+
_wrap_Image_insert(int argc, VALUE *argv, VALUE self) {
|
|
7343
|
+
Gosu::Image *arg1 = (Gosu::Image *) 0 ;
|
|
7344
|
+
VALUE arg2 = (VALUE) 0 ;
|
|
7345
|
+
int arg3 ;
|
|
7346
|
+
int arg4 ;
|
|
7347
|
+
void *argp1 = 0 ;
|
|
7348
|
+
int res1 = 0 ;
|
|
7349
|
+
int val3 ;
|
|
7350
|
+
int ecode3 = 0 ;
|
|
7351
|
+
int val4 ;
|
|
7352
|
+
int ecode4 = 0 ;
|
|
7353
|
+
|
|
7354
|
+
if ((argc < 3) || (argc > 3)) {
|
|
7355
|
+
rb_raise(rb_eArgError, "wrong # of arguments(%d for 3)",argc); SWIG_fail;
|
|
7356
|
+
}
|
|
7357
|
+
res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_Gosu__Image, 0 | 0 );
|
|
7358
|
+
if (!SWIG_IsOK(res1)) {
|
|
7359
|
+
SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "Gosu::Image *","insert", 1, self ));
|
|
7360
|
+
}
|
|
7361
|
+
arg1 = reinterpret_cast< Gosu::Image * >(argp1);
|
|
7362
|
+
arg2 = argv[0];
|
|
7363
|
+
ecode3 = SWIG_AsVal_int(argv[1], &val3);
|
|
7364
|
+
if (!SWIG_IsOK(ecode3)) {
|
|
7365
|
+
SWIG_exception_fail(SWIG_ArgError(ecode3), Ruby_Format_TypeError( "", "int","insert", 3, argv[1] ));
|
|
7366
|
+
}
|
|
7367
|
+
arg3 = static_cast< int >(val3);
|
|
7368
|
+
ecode4 = SWIG_AsVal_int(argv[2], &val4);
|
|
7369
|
+
if (!SWIG_IsOK(ecode4)) {
|
|
7370
|
+
SWIG_exception_fail(SWIG_ArgError(ecode4), Ruby_Format_TypeError( "", "int","insert", 4, argv[2] ));
|
|
7371
|
+
}
|
|
7372
|
+
arg4 = static_cast< int >(val4);
|
|
7373
|
+
{
|
|
7374
|
+
try {
|
|
7375
|
+
Gosu_Image_insert(arg1,arg2,arg3,arg4);
|
|
7376
|
+
} catch(const std::runtime_error& e) {
|
|
7377
|
+
SWIG_exception(SWIG_RuntimeError, e.what());
|
|
7378
|
+
}
|
|
7379
|
+
}
|
|
7380
|
+
return Qnil;
|
|
7381
|
+
fail:
|
|
7382
|
+
return Qnil;
|
|
7383
|
+
}
|
|
7384
|
+
|
|
7385
|
+
|
|
7330
7386
|
SWIGINTERN void
|
|
7331
7387
|
free_Gosu_Image(Gosu::Image *arg1) {
|
|
7332
7388
|
SWIG_RubyRemoveTracking(arg1);
|
|
@@ -10662,6 +10718,7 @@ static swig_type_info _swigt__p_Gosu__Song = {"_p_Gosu__Song", "Gosu::Song *", 0
|
|
|
10662
10718
|
static swig_type_info _swigt__p_Gosu__TextInput = {"_p_Gosu__TextInput", "Gosu::TextInput *", 0, 0, (void*)0, 0};
|
|
10663
10719
|
static swig_type_info _swigt__p_Gosu__Window = {"_p_Gosu__Window", "Gosu::Window *", 0, 0, (void*)0, 0};
|
|
10664
10720
|
static swig_type_info _swigt__p_boost__arrayT_double_16_t = {"_p_boost__arrayT_double_16_t", "boost::array< double,16 > *|Gosu::Transform *", 0, 0, (void*)0, 0};
|
|
10721
|
+
static swig_type_info _swigt__p_boost__optionalT_Gosu__Color_t = {"_p_boost__optionalT_Gosu__Color_t", "boost::optional< Gosu::Color > *", 0, 0, (void*)0, 0};
|
|
10665
10722
|
static swig_type_info _swigt__p_char = {"_p_char", "char *", 0, 0, (void*)0, 0};
|
|
10666
10723
|
static swig_type_info _swigt__p_double = {"_p_double", "Gosu::ZPos *|double *", 0, 0, (void*)0, 0};
|
|
10667
10724
|
static swig_type_info _swigt__p_std__wstring = {"_p_std__wstring", "std::wstring *", 0, 0, (void*)0, 0};
|
|
@@ -10680,6 +10737,7 @@ static swig_type_info *swig_type_initial[] = {
|
|
|
10680
10737
|
&_swigt__p_Gosu__TextInput,
|
|
10681
10738
|
&_swigt__p_Gosu__Window,
|
|
10682
10739
|
&_swigt__p_boost__arrayT_double_16_t,
|
|
10740
|
+
&_swigt__p_boost__optionalT_Gosu__Color_t,
|
|
10683
10741
|
&_swigt__p_char,
|
|
10684
10742
|
&_swigt__p_double,
|
|
10685
10743
|
&_swigt__p_std__wstring,
|
|
@@ -10698,6 +10756,7 @@ static swig_cast_info _swigc__p_Gosu__Song[] = { {&_swigt__p_Gosu__Song, 0, 0,
|
|
|
10698
10756
|
static swig_cast_info _swigc__p_Gosu__TextInput[] = { {&_swigt__p_Gosu__TextInput, 0, 0, 0},{0, 0, 0, 0}};
|
|
10699
10757
|
static swig_cast_info _swigc__p_Gosu__Window[] = { {&_swigt__p_Gosu__Window, 0, 0, 0},{0, 0, 0, 0}};
|
|
10700
10758
|
static swig_cast_info _swigc__p_boost__arrayT_double_16_t[] = { {&_swigt__p_boost__arrayT_double_16_t, 0, 0, 0},{0, 0, 0, 0}};
|
|
10759
|
+
static swig_cast_info _swigc__p_boost__optionalT_Gosu__Color_t[] = { {&_swigt__p_boost__optionalT_Gosu__Color_t, 0, 0, 0},{0, 0, 0, 0}};
|
|
10701
10760
|
static swig_cast_info _swigc__p_char[] = { {&_swigt__p_char, 0, 0, 0},{0, 0, 0, 0}};
|
|
10702
10761
|
static swig_cast_info _swigc__p_double[] = { {&_swigt__p_double, 0, 0, 0},{0, 0, 0, 0}};
|
|
10703
10762
|
static swig_cast_info _swigc__p_std__wstring[] = { {&_swigt__p_std__wstring, 0, 0, 0},{0, 0, 0, 0}};
|
|
@@ -10716,6 +10775,7 @@ static swig_cast_info *swig_cast_initial[] = {
|
|
|
10716
10775
|
_swigc__p_Gosu__TextInput,
|
|
10717
10776
|
_swigc__p_Gosu__Window,
|
|
10718
10777
|
_swigc__p_boost__arrayT_double_16_t,
|
|
10778
|
+
_swigc__p_boost__optionalT_Gosu__Color_t,
|
|
10719
10779
|
_swigc__p_char,
|
|
10720
10780
|
_swigc__p_double,
|
|
10721
10781
|
_swigc__p_std__wstring,
|
|
@@ -10981,8 +11041,8 @@ SWIGEXPORT void Init_gosu(void) {
|
|
|
10981
11041
|
SWIG_RubyInitializeTrackings();
|
|
10982
11042
|
rb_define_const(mGosu, "MAJOR_VERSION", SWIG_From_int(static_cast< int >(0)));
|
|
10983
11043
|
rb_define_const(mGosu, "MINOR_VERSION", SWIG_From_int(static_cast< int >(7)));
|
|
10984
|
-
rb_define_const(mGosu, "POINT_VERSION", SWIG_From_int(static_cast< int >(
|
|
10985
|
-
rb_define_const(mGosu, "VERSION", SWIG_FromCharPtr("0.7.
|
|
11044
|
+
rb_define_const(mGosu, "POINT_VERSION", SWIG_From_int(static_cast< int >(28)));
|
|
11045
|
+
rb_define_const(mGosu, "VERSION", SWIG_FromCharPtr("0.7.28"));
|
|
10986
11046
|
rb_define_module_function(mGosu, "milliseconds", VALUEFUNC(_wrap_milliseconds), -1);
|
|
10987
11047
|
rb_define_module_function(mGosu, "random", VALUEFUNC(_wrap_random), -1);
|
|
10988
11048
|
rb_define_module_function(mGosu, "degrees_to_radians", VALUEFUNC(_wrap_degrees_to_radians), -1);
|
|
@@ -11102,6 +11162,7 @@ SWIGEXPORT void Init_gosu(void) {
|
|
|
11102
11162
|
rb_define_method(SwigClassImage.klass, "columns", VALUEFUNC(_wrap_Image_columns), -1);
|
|
11103
11163
|
rb_define_method(SwigClassImage.klass, "rows", VALUEFUNC(_wrap_Image_rows), -1);
|
|
11104
11164
|
rb_define_method(SwigClassImage.klass, "save", VALUEFUNC(_wrap_Image_save), -1);
|
|
11165
|
+
rb_define_method(SwigClassImage.klass, "insert", VALUEFUNC(_wrap_Image_insert), -1);
|
|
11105
11166
|
SwigClassImage.mark = 0;
|
|
11106
11167
|
SwigClassImage.destroy = (void (*)(void *)) free_Gosu_Image;
|
|
11107
11168
|
SwigClassImage.trackObjects = 1;
|
data/GosuImpl/Utility.cpp
CHANGED
|
File without changes
|
data/README.txt
CHANGED
|
@@ -1,17 +1,26 @@
|
|
|
1
|
-
Moin
|
|
1
|
+
Moin and welcome to Gosu!
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Gosu's main website is http://www.libgosu.org/ which always has the latest
|
|
4
|
+
links to all relevant information.
|
|
4
5
|
|
|
5
|
-
|
|
6
|
+
The actual source code, wiki, issue tracker etc. are currently moving away
|
|
7
|
+
from Gosu's old Google Code project to GitHub:
|
|
6
8
|
|
|
7
|
-
http://code.google.com/p/gosu/
|
|
9
|
+
http://code.google.com/p/gosu/ -> http://github.com/jlnr/gosu/
|
|
10
|
+
|
|
11
|
+
The best entry point into Gosu's documentation is still this wiki page:
|
|
8
12
|
|
|
9
|
-
|
|
10
|
-
at one of the games in the Gosu Users board.
|
|
13
|
+
http://code.google.com/p/gosu/wiki/DocsOverview
|
|
11
14
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
- try your luck in irc://irc.freenode.org/gosu,
|
|
15
|
-
- or mail me at julian@raschke.de!
|
|
15
|
+
Try doing the tutorial there if you don't know how to start out. Or look at
|
|
16
|
+
one of the games in the Gosu Users board.
|
|
16
17
|
|
|
17
|
-
|
|
18
|
+
Remember that Gosu is licensed under the MIT license and feel invited to fork,
|
|
19
|
+
port and transmogrify all parts of it. The only license that may affect you by
|
|
20
|
+
indirection is libogg's (BSD-style). If you release a Gosu game in any common
|
|
21
|
+
binary form, you will need to mention use of libogg and libvorbis somewhere.
|
|
22
|
+
|
|
23
|
+
Complaints, questions, feedback?
|
|
24
|
+
* Visit the boards, http://www.libgosu.org/
|
|
25
|
+
* try your luck in the chat, irc://irc.freenode.org/gosu
|
|
26
|
+
* or e-mail me. Have fun, write games! julian@raschke.de
|
metadata
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: gosu
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
hash:
|
|
4
|
+
hash: 59
|
|
5
5
|
prerelease:
|
|
6
6
|
segments:
|
|
7
7
|
- 0
|
|
8
8
|
- 7
|
|
9
|
-
-
|
|
10
|
-
|
|
11
|
-
version: 0.7.27.1
|
|
9
|
+
- 28
|
|
10
|
+
version: 0.7.28
|
|
12
11
|
platform: ruby
|
|
13
12
|
authors:
|
|
14
13
|
- Julian Raschke
|
|
@@ -17,7 +16,7 @@ autorequire:
|
|
|
17
16
|
bindir: bin
|
|
18
17
|
cert_chain: []
|
|
19
18
|
|
|
20
|
-
date: 2011-
|
|
19
|
+
date: 2011-03-24 00:00:00 +08:00
|
|
21
20
|
default_executable:
|
|
22
21
|
dependencies: []
|
|
23
22
|
|
|
@@ -30,7 +29,7 @@ extensions:
|
|
|
30
29
|
extra_rdoc_files: []
|
|
31
30
|
|
|
32
31
|
files:
|
|
33
|
-
- COPYING
|
|
32
|
+
- COPYING
|
|
34
33
|
- README.txt
|
|
35
34
|
- Gosu/Async.hpp
|
|
36
35
|
- Gosu/Audio.hpp
|
|
@@ -101,10 +100,10 @@ files:
|
|
|
101
100
|
- GosuImpl/FileUnix.cpp
|
|
102
101
|
- GosuImpl/FileWin.cpp
|
|
103
102
|
- GosuImpl/Graphics/Bitmap.cpp
|
|
103
|
+
- GosuImpl/Graphics/BitmapApple.mm
|
|
104
104
|
- GosuImpl/Graphics/BitmapBMP.cpp
|
|
105
105
|
- GosuImpl/Graphics/BitmapColorKey.cpp
|
|
106
106
|
- GosuImpl/Graphics/BitmapPNG.cpp
|
|
107
|
-
- GosuImpl/Graphics/BitmapTouch.mm
|
|
108
107
|
- GosuImpl/Graphics/BitmapUtils.cpp
|
|
109
108
|
- GosuImpl/Graphics/BlockAllocator.cpp
|
|
110
109
|
- GosuImpl/Graphics/BlockAllocator.hpp
|
|
@@ -205,7 +204,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
205
204
|
requirements:
|
|
206
205
|
- See http://code.google.com/p/gosu/wiki/GettingStartedOnLinux
|
|
207
206
|
rubyforge_project:
|
|
208
|
-
rubygems_version: 1.
|
|
207
|
+
rubygems_version: 1.6.0
|
|
209
208
|
signing_key:
|
|
210
209
|
specification_version: 3
|
|
211
210
|
summary: 2D game development library.
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
#include <Gosu/Graphics.hpp>
|
|
2
|
-
#include <Gosu/Bitmap.hpp>
|
|
3
|
-
#include <Gosu/IO.hpp>
|
|
4
|
-
#include <Gosu/Utility.hpp>
|
|
5
|
-
#include <GosuImpl/MacUtility.hpp>
|
|
6
|
-
#include <boost/algorithm/string.hpp>
|
|
7
|
-
#include <boost/lexical_cast.hpp>
|
|
8
|
-
#include <stdexcept>
|
|
9
|
-
#import <UIKit/UIKit.h>
|
|
10
|
-
|
|
11
|
-
Gosu::Reader Gosu::loadFromBMP(Bitmap& bmp, Reader reader)
|
|
12
|
-
{
|
|
13
|
-
ObjRef<NSAutoreleasePool> pool([NSAutoreleasePool new]);
|
|
14
|
-
|
|
15
|
-
std::size_t length = reader.resource().size() - reader.position();
|
|
16
|
-
ObjRef<NSMutableData> buffer([[NSMutableData alloc] initWithLength: length]);
|
|
17
|
-
reader.read([buffer.get() mutableBytes], length);
|
|
18
|
-
|
|
19
|
-
ObjRef<UIImage> image([[UIImage alloc] initWithData: buffer.get()]);
|
|
20
|
-
if (!image.get())
|
|
21
|
-
throw std::runtime_error("Could not load image from resource of length " +
|
|
22
|
-
boost::lexical_cast<std::string>(length));
|
|
23
|
-
|
|
24
|
-
CGImageRef imageRef = [image.obj() CGImage];
|
|
25
|
-
|
|
26
|
-
bmp.resize(CGImageGetWidth(imageRef), CGImageGetHeight(imageRef));
|
|
27
|
-
|
|
28
|
-
// Use a temporary context to draw the CGImage to the buffer.
|
|
29
|
-
CGContextRef context =
|
|
30
|
-
CGBitmapContextCreate(bmp.data(),
|
|
31
|
-
bmp.width(), bmp.height(), 8, bmp.width() * 4,
|
|
32
|
-
CGImageGetColorSpace(imageRef),
|
|
33
|
-
kCGImageAlphaPremultipliedLast);
|
|
34
|
-
CGContextDrawImage(context, CGRectMake(0.0, 0.0, bmp.width(), bmp.height()), imageRef);
|
|
35
|
-
CGContextRelease(context);
|
|
36
|
-
|
|
37
|
-
return reader;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
Gosu::Reader Gosu::loadFromPNG(Bitmap& bmp, Reader reader)
|
|
41
|
-
{
|
|
42
|
-
return loadFromBMP(bmp, reader);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
Gosu::Writer Gosu::saveToPNG(const Bitmap& bmp, Writer writer)
|
|
46
|
-
{
|
|
47
|
-
ObjRef<NSAutoreleasePool> pool([NSAutoreleasePool new]);
|
|
48
|
-
|
|
49
|
-
CGDataProviderRef dataProvider =
|
|
50
|
-
CGDataProviderCreateWithData(0, bmp.data(), bmp.width() * bmp.height() * 4, 0);
|
|
51
|
-
|
|
52
|
-
static CGColorSpaceRef colorspace = CGColorSpaceCreateDeviceRGB();
|
|
53
|
-
|
|
54
|
-
CGImageRef imageRef =
|
|
55
|
-
CGImageCreate(bmp.width(), bmp.height(), 8, 32, bmp.width() * 4, colorspace,
|
|
56
|
-
kCGImageAlphaLast, dataProvider, 0, false, kCGRenderingIntentDefault);
|
|
57
|
-
|
|
58
|
-
ObjRef<UIImage> image([[UIImage alloc] initWithCGImage: imageRef]);
|
|
59
|
-
|
|
60
|
-
NSData* pngRef = UIImagePNGRepresentation(image.get());
|
|
61
|
-
writer.write([pngRef bytes], [pngRef length]);
|
|
62
|
-
image.reset();
|
|
63
|
-
|
|
64
|
-
CGImageRelease(imageRef);
|
|
65
|
-
|
|
66
|
-
CGDataProviderRelease(dataProvider);
|
|
67
|
-
|
|
68
|
-
return writer;
|
|
69
|
-
}
|