gosu 0.7.10.1
Sign up to get free protection for your applications and to get access to all the features.
- data/COPYING.txt +29 -0
- data/Gosu/Async.hpp +48 -0
- data/Gosu/Audio.hpp +145 -0
- data/Gosu/AutoLink.hpp +16 -0
- data/Gosu/Bitmap.hpp +85 -0
- data/Gosu/ButtonsMac.hpp +114 -0
- data/Gosu/ButtonsWin.hpp +111 -0
- data/Gosu/ButtonsX.hpp +115 -0
- data/Gosu/Color.hpp +172 -0
- data/Gosu/Directories.hpp +36 -0
- data/Gosu/Font.hpp +59 -0
- data/Gosu/Fwd.hpp +31 -0
- data/Gosu/Gosu.hpp +26 -0
- data/Gosu/Graphics.hpp +86 -0
- data/Gosu/GraphicsBase.hpp +45 -0
- data/Gosu/IO.hpp +255 -0
- data/Gosu/Image.hpp +148 -0
- data/Gosu/ImageData.hpp +45 -0
- data/Gosu/Input.hpp +116 -0
- data/Gosu/Math.hpp +95 -0
- data/Gosu/Platform.hpp +61 -0
- data/Gosu/RotFlip.hpp +116 -0
- data/Gosu/Sockets.hpp +129 -0
- data/Gosu/Text.hpp +47 -0
- data/Gosu/TextInput.hpp +57 -0
- data/Gosu/Timing.hpp +16 -0
- data/Gosu/Utility.hpp +24 -0
- data/Gosu/WinUtility.hpp +76 -0
- data/Gosu/Window.hpp +84 -0
- data/GosuImpl/Async.cpp +37 -0
- data/GosuImpl/AudioFmod.cpp +417 -0
- data/GosuImpl/AudioSDL.cpp +255 -0
- data/GosuImpl/DirectoriesMac.mm +38 -0
- data/GosuImpl/DirectoriesUnix.cpp +48 -0
- data/GosuImpl/DirectoriesWin.cpp +42 -0
- data/GosuImpl/FileUnix.cpp +100 -0
- data/GosuImpl/FileWin.cpp +83 -0
- data/GosuImpl/Graphics/Bitmap.cpp +116 -0
- data/GosuImpl/Graphics/BitmapBMP.cpp +232 -0
- data/GosuImpl/Graphics/BitmapColorKey.cpp +39 -0
- data/GosuImpl/Graphics/BitmapPNG.cpp +276 -0
- data/GosuImpl/Graphics/BitmapUtils.cpp +67 -0
- data/GosuImpl/Graphics/BlockAllocator.cpp +127 -0
- data/GosuImpl/Graphics/BlockAllocator.hpp +34 -0
- data/GosuImpl/Graphics/Color.cpp +126 -0
- data/GosuImpl/Graphics/Common.hpp +21 -0
- data/GosuImpl/Graphics/DrawOp.hpp +154 -0
- data/GosuImpl/Graphics/Font.cpp +110 -0
- data/GosuImpl/Graphics/Graphics.cpp +295 -0
- data/GosuImpl/Graphics/Image.cpp +159 -0
- data/GosuImpl/Graphics/LargeImageData.cpp +115 -0
- data/GosuImpl/Graphics/LargeImageData.hpp +37 -0
- data/GosuImpl/Graphics/RotFlip.cpp +184 -0
- data/GosuImpl/Graphics/TexChunk.cpp +77 -0
- data/GosuImpl/Graphics/TexChunk.hpp +40 -0
- data/GosuImpl/Graphics/Text.cpp +223 -0
- data/GosuImpl/Graphics/TextMac.cpp +242 -0
- data/GosuImpl/Graphics/TextPangoFT.cpp +186 -0
- data/GosuImpl/Graphics/TextWin.cpp +172 -0
- data/GosuImpl/Graphics/Texture.cpp +104 -0
- data/GosuImpl/Graphics/Texture.hpp +34 -0
- data/GosuImpl/IO.cpp +48 -0
- data/GosuImpl/InputMac.mm +677 -0
- data/GosuImpl/InputWin.cpp +444 -0
- data/GosuImpl/InputX.cpp +158 -0
- data/GosuImpl/MacUtility.hpp +48 -0
- data/GosuImpl/Math.cpp +49 -0
- data/GosuImpl/RubyGosu.swg +474 -0
- data/GosuImpl/RubyGosuStub.mm +17 -0
- data/GosuImpl/RubyGosu_DllMain.cxx +30 -0
- data/GosuImpl/RubyGosu_wrap.cxx +8521 -0
- data/GosuImpl/RubyGosu_wrap.h +31 -0
- data/GosuImpl/Sockets/CommSocket.cpp +304 -0
- data/GosuImpl/Sockets/ListenerSocket.cpp +60 -0
- data/GosuImpl/Sockets/MessageSocket.cpp +136 -0
- data/GosuImpl/Sockets/Socket.cpp +145 -0
- data/GosuImpl/Sockets/Sockets.hpp +66 -0
- data/GosuImpl/TextInputMac.mm +207 -0
- data/GosuImpl/TextInputWin.cpp +197 -0
- data/GosuImpl/TextInputX.cpp +201 -0
- data/GosuImpl/TextTTFWin.cpp +247 -0
- data/GosuImpl/TimingUnix.cpp +17 -0
- data/GosuImpl/TimingWin.cpp +28 -0
- data/GosuImpl/Utility.cpp +140 -0
- data/GosuImpl/WinMain.cpp +69 -0
- data/GosuImpl/WinUtility.cpp +137 -0
- data/GosuImpl/WindowMac.mm +466 -0
- data/GosuImpl/WindowWin.cpp +447 -0
- data/GosuImpl/WindowX.cpp +392 -0
- data/GosuImpl/X11vroot.h +118 -0
- data/README.txt +13 -0
- data/Rakefile +178 -0
- data/examples/ChipmunkIntegration.rb +275 -0
- data/examples/CptnRuby.rb +231 -0
- data/examples/MoreChipmunkAndRMagick.rb +155 -0
- data/examples/OpenGLIntegration.rb +232 -0
- data/examples/RMagickIntegration.rb +449 -0
- data/examples/TextInput.cpp +170 -0
- data/examples/TextInput.rb +139 -0
- data/examples/Tutorial.cpp +215 -0
- data/examples/Tutorial.rb +137 -0
- data/examples/media/Beep.wav +0 -0
- data/examples/media/CptnRuby Gem.png +0 -0
- data/examples/media/CptnRuby Map.txt +25 -0
- data/examples/media/CptnRuby Tileset.png +0 -0
- data/examples/media/CptnRuby.png +0 -0
- data/examples/media/Cursor.png +0 -0
- data/examples/media/Earth.png +0 -0
- data/examples/media/Explosion.wav +0 -0
- data/examples/media/LargeStar.png +0 -0
- data/examples/media/Sky.jpg +0 -0
- data/examples/media/Smoke.png +0 -0
- data/examples/media/Soldier.png +0 -0
- data/examples/media/Space.png +0 -0
- data/examples/media/Star.png +0 -0
- data/examples/media/Starfighter.bmp +0 -0
- data/linux/Makefile.in +98 -0
- data/linux/configure +5658 -0
- data/linux/configure.ac +126 -0
- data/linux/extconf.rb +11 -0
- data/mac/English.lproj/InfoPlist.strings +0 -0
- data/mac/Gosu-Info.plist +26 -0
- data/mac/Gosu.xcodeproj/project.pbxproj +1194 -0
- data/mac/RubyGosu Template-Info.plist +26 -0
- data/mac/libboost_thread_1_34_1_universal.a +0 -0
- data/mac/libboost_thread_d_1_34_1_universal.a +0 -0
- data/mac/libfmod_universal.a +0 -0
- data/mac/libpng_universal.a +0 -0
- data/mac/libz_universal.a +0 -0
- data/reference/Async_8hpp-source.html +70 -0
- data/reference/Audio_8hpp-source.html +114 -0
- data/reference/Audio_8hpp.html +50 -0
- data/reference/AutoLink_8hpp-source.html +38 -0
- data/reference/AutoLink_8hpp.html +34 -0
- data/reference/Bitmap_8hpp-source.html +85 -0
- data/reference/Bitmap_8hpp.html +58 -0
- data/reference/ButtonsMac_8hpp-source.html +133 -0
- data/reference/ButtonsWin_8hpp-source.html +133 -0
- data/reference/ButtonsX_8hpp-source.html +134 -0
- data/reference/Color_8hpp-source.html +169 -0
- data/reference/Color_8hpp.html +85 -0
- data/reference/Directories_8hpp-source.html +42 -0
- data/reference/Directories_8hpp.html +46 -0
- data/reference/Font_8hpp-source.html +65 -0
- data/reference/Font_8hpp.html +41 -0
- data/reference/Fwd_8hpp-source.html +52 -0
- data/reference/Fwd_8hpp.html +37 -0
- data/reference/Gosu_8hpp-source.html +48 -0
- data/reference/Gosu_8hpp.html +34 -0
- data/reference/GraphicsBase_8hpp-source.html +57 -0
- data/reference/GraphicsBase_8hpp.html +56 -0
- data/reference/Graphics_8hpp-source.html +96 -0
- data/reference/Graphics_8hpp.html +53 -0
- data/reference/IO_8hpp-source.html +255 -0
- data/reference/IO_8hpp.html +74 -0
- data/reference/ImageData_8hpp-source.html +62 -0
- data/reference/ImageData_8hpp.html +43 -0
- data/reference/Image_8hpp-source.html +126 -0
- data/reference/Image_8hpp.html +48 -0
- data/reference/Input_8hpp-source.html +118 -0
- data/reference/Input_8hpp.html +50 -0
- data/reference/Math_8hpp-source.html +92 -0
- data/reference/Math_8hpp.html +74 -0
- data/reference/Platform_8hpp-source.html +83 -0
- data/reference/Platform_8hpp.html +73 -0
- data/reference/RotFlip_8hpp-source.html +138 -0
- data/reference/RotFlip_8hpp.html +77 -0
- data/reference/Sockets_8hpp-source.html +130 -0
- data/reference/Sockets_8hpp.html +66 -0
- data/reference/TextInput_8hpp-source.html +64 -0
- data/reference/TextInput_8hpp.html +41 -0
- data/reference/Text_8hpp-source.html +51 -0
- data/reference/Text_8hpp.html +46 -0
- data/reference/Timing_8hpp-source.html +36 -0
- data/reference/Timing_8hpp.html +42 -0
- data/reference/Utility_8hpp-source.html +44 -0
- data/reference/Utility_8hpp.html +48 -0
- data/reference/WinUtility_8hpp-source.html +79 -0
- data/reference/WinUtility_8hpp.html +64 -0
- data/reference/Window_8hpp-source.html +91 -0
- data/reference/Window_8hpp.html +41 -0
- data/reference/annotated.html +51 -0
- data/reference/classGosu_1_1Audio-members.html +34 -0
- data/reference/classGosu_1_1Audio.html +46 -0
- data/reference/classGosu_1_1Bitmap-members.html +44 -0
- data/reference/classGosu_1_1Bitmap.html +263 -0
- data/reference/classGosu_1_1Buffer-members.html +44 -0
- data/reference/classGosu_1_1Buffer.html +78 -0
- data/reference/classGosu_1_1Buffer.png +0 -0
- data/reference/classGosu_1_1Button-members.html +36 -0
- data/reference/classGosu_1_1Button.html +143 -0
- data/reference/classGosu_1_1Color-members.html +56 -0
- data/reference/classGosu_1_1Color.html +387 -0
- data/reference/classGosu_1_1File-members.html +41 -0
- data/reference/classGosu_1_1File.html +69 -0
- data/reference/classGosu_1_1File.png +0 -0
- data/reference/classGosu_1_1Font-members.html +39 -0
- data/reference/classGosu_1_1Font.html +309 -0
- data/reference/classGosu_1_1Graphics-members.html +50 -0
- data/reference/classGosu_1_1Graphics.html +234 -0
- data/reference/classGosu_1_1Image-members.html +45 -0
- data/reference/classGosu_1_1Image.html +518 -0
- data/reference/classGosu_1_1ImageData-members.html +37 -0
- data/reference/classGosu_1_1ImageData.html +60 -0
- data/reference/classGosu_1_1Input-members.html +44 -0
- data/reference/classGosu_1_1Input.html +223 -0
- data/reference/classGosu_1_1MessageSocket-members.html +40 -0
- data/reference/classGosu_1_1MessageSocket.html +233 -0
- data/reference/classGosu_1_1Resource-members.html +39 -0
- data/reference/classGosu_1_1Resource.html +116 -0
- data/reference/classGosu_1_1Resource.png +0 -0
- data/reference/classGosu_1_1Sample-members.html +37 -0
- data/reference/classGosu_1_1Sample.html +200 -0
- data/reference/classGosu_1_1SampleInstance-members.html +38 -0
- data/reference/classGosu_1_1SampleInstance.html +169 -0
- data/reference/classGosu_1_1Song-members.html +43 -0
- data/reference/classGosu_1_1Song.html +260 -0
- data/reference/classGosu_1_1TextInput-members.html +38 -0
- data/reference/classGosu_1_1TextInput.html +121 -0
- data/reference/classGosu_1_1Window-members.html +50 -0
- data/reference/classGosu_1_1Window.html +271 -0
- data/reference/doxyfile +233 -0
- data/reference/doxygen.css +433 -0
- data/reference/doxygen.png +0 -0
- data/reference/files.html +54 -0
- data/reference/functions.html +236 -0
- data/reference/functions_enum.html +45 -0
- data/reference/functions_func.html +227 -0
- data/reference/functions_vars.html +47 -0
- data/reference/hierarchy.html +53 -0
- data/reference/index.html +26 -0
- data/reference/namespaceGosu.html +2890 -0
- data/reference/namespaceGosu_1_1Colors.html +70 -0
- data/reference/namespaceGosu_1_1Win.html +275 -0
- data/reference/namespacemembers.html +216 -0
- data/reference/namespacemembers_enum.html +52 -0
- data/reference/namespacemembers_eval.html +54 -0
- data/reference/namespacemembers_func.html +185 -0
- data/reference/namespacemembers_type.html +46 -0
- data/reference/namespacemembers_vars.html +46 -0
- data/reference/namespaces.html +35 -0
- data/reference/tab_b.gif +0 -0
- data/reference/tab_l.gif +0 -0
- data/reference/tab_r.gif +0 -0
- data/reference/tabs.css +102 -0
- data/windows/Gosu.sln +29 -0
- data/windows/Gosu.vcproj +553 -0
- data/windows/RubyGosu.vcproj +138 -0
- metadata +305 -0
@@ -0,0 +1,115 @@
|
|
1
|
+
#include <GosuImpl/Graphics/LargeImageData.hpp>
|
2
|
+
#include <Gosu/Bitmap.hpp>
|
3
|
+
#include <Gosu/Graphics.hpp>
|
4
|
+
#include <Gosu/Math.hpp>
|
5
|
+
#include <cmath>
|
6
|
+
using namespace std;
|
7
|
+
|
8
|
+
Gosu::LargeImageData::LargeImageData(Graphics& graphics,
|
9
|
+
const Bitmap& source, unsigned partWidth, unsigned partHeight,
|
10
|
+
unsigned borderFlags)
|
11
|
+
{
|
12
|
+
fullWidth = source.width();
|
13
|
+
fullHeight = source.height();
|
14
|
+
partsX = trunc(ceil(1.0 * source.width() / partWidth));
|
15
|
+
partsY = trunc(ceil(1.0 * source.height() / partHeight));
|
16
|
+
this->partWidth = partWidth;
|
17
|
+
this->partHeight = partHeight;
|
18
|
+
|
19
|
+
parts.resize(partsX * partsY);
|
20
|
+
|
21
|
+
for (unsigned y = 0; y < partsY; ++y)
|
22
|
+
for (unsigned x = 0; x < partsX; ++x)
|
23
|
+
{
|
24
|
+
// The right-most parts don't necessarily have the full width.
|
25
|
+
unsigned srcWidth = partWidth;
|
26
|
+
if (x == partsX - 1 && source.width() % partWidth != 0)
|
27
|
+
srcWidth = source.width() % partWidth;
|
28
|
+
|
29
|
+
// Same for the parts on the bottom.
|
30
|
+
unsigned srcHeight = partHeight;
|
31
|
+
if (y == partsY - 1 && source.height() % partHeight != 0)
|
32
|
+
srcHeight = source.height() % partHeight;
|
33
|
+
|
34
|
+
unsigned localBorderFlags = bfHard;
|
35
|
+
if (x == 0)
|
36
|
+
localBorderFlags &= ~(borderFlags & bfHardLeft);
|
37
|
+
else if (x == partsX - 1)
|
38
|
+
localBorderFlags &= ~(borderFlags & bfHardRight);
|
39
|
+
if (y == 0)
|
40
|
+
localBorderFlags &= ~(borderFlags & bfHardTop);
|
41
|
+
else if (y == partsY - 1)
|
42
|
+
localBorderFlags &= ~(borderFlags & bfHardBottom);
|
43
|
+
|
44
|
+
parts[y * partsX + x].reset(graphics.createImage(source,
|
45
|
+
x * partWidth, y * partHeight, srcWidth, srcHeight,
|
46
|
+
localBorderFlags).release());
|
47
|
+
}
|
48
|
+
}
|
49
|
+
|
50
|
+
unsigned Gosu::LargeImageData::width() const
|
51
|
+
{
|
52
|
+
return fullWidth;
|
53
|
+
}
|
54
|
+
|
55
|
+
unsigned Gosu::LargeImageData::height() const
|
56
|
+
{
|
57
|
+
return fullHeight;
|
58
|
+
}
|
59
|
+
|
60
|
+
namespace
|
61
|
+
{
|
62
|
+
// Local interpolation helper functions.
|
63
|
+
|
64
|
+
double ipl(double a, double b, double ratio)
|
65
|
+
{
|
66
|
+
return a + (b - a) * ratio;
|
67
|
+
}
|
68
|
+
|
69
|
+
Gosu::Color ipl(Gosu::Color a, Gosu::Color b, double ratio)
|
70
|
+
{
|
71
|
+
Gosu::Color result;
|
72
|
+
result.setAlpha(Gosu::round(ipl(a.alpha(), b.alpha(), ratio)));
|
73
|
+
result.setRed (Gosu::round(ipl(a.red(), b.red(), ratio)));
|
74
|
+
result.setGreen(Gosu::round(ipl(a.green(), b.green(), ratio)));
|
75
|
+
result.setBlue (Gosu::round(ipl(a.blue(), b.blue(), ratio)));
|
76
|
+
return result;
|
77
|
+
}
|
78
|
+
}
|
79
|
+
|
80
|
+
void Gosu::LargeImageData::draw(double x1, double y1, Color c1,
|
81
|
+
double x2, double y2, Color c2, double x3, double y3, Color c3,
|
82
|
+
double x4, double y4, Color c4, ZPos z, AlphaMode mode) const
|
83
|
+
{
|
84
|
+
if (parts.empty())
|
85
|
+
return;
|
86
|
+
|
87
|
+
for (unsigned py = 0; py < partsY; ++py)
|
88
|
+
for (unsigned px = 0; px < partsX; ++px)
|
89
|
+
{
|
90
|
+
const ImageData& part = *parts[py * partsX + px];
|
91
|
+
|
92
|
+
double relXL = static_cast<double>(px * partWidth) / width();
|
93
|
+
double relXR = static_cast<double>(px * partWidth + part.width()) / width();
|
94
|
+
double relYT = static_cast<double>(py * partHeight) / height();
|
95
|
+
double relYB = static_cast<double>(py * partHeight + part.height()) / height();
|
96
|
+
|
97
|
+
double absXTL = ipl(ipl(x1, x3, relYT), ipl(x2, x4, relYT), relXL);
|
98
|
+
double absXTR = ipl(ipl(x1, x3, relYT), ipl(x2, x4, relYT), relXR);
|
99
|
+
double absXBL = ipl(ipl(x1, x3, relYB), ipl(x2, x4, relYB), relXL);
|
100
|
+
double absXBR = ipl(ipl(x1, x3, relYB), ipl(x2, x4, relYB), relXR);
|
101
|
+
|
102
|
+
double absYTL = ipl(ipl(y1, y3, relYT), ipl(y2, y4, relYT), relXL);
|
103
|
+
double absYTR = ipl(ipl(y1, y3, relYT), ipl(y2, y4, relYT), relXR);
|
104
|
+
double absYBL = ipl(ipl(y1, y3, relYB), ipl(y2, y4, relYB), relXL);
|
105
|
+
double absYBR = ipl(ipl(y1, y3, relYB), ipl(y2, y4, relYB), relXR);
|
106
|
+
|
107
|
+
Color absCTL = ipl(ipl(c1, c3, relYT), ipl(c2, c4, relYT), relXL);
|
108
|
+
Color absCTR = ipl(ipl(c1, c3, relYT), ipl(c2, c4, relYT), relXR);
|
109
|
+
Color absCBL = ipl(ipl(c1, c3, relYB), ipl(c2, c4, relYB), relXL);
|
110
|
+
Color absCBR = ipl(ipl(c1, c3, relYB), ipl(c2, c4, relYB), relXR);
|
111
|
+
|
112
|
+
part.draw(absXTL, absYTL, absCTL, absXTR, absYTR, absCTR,
|
113
|
+
absXBL, absYBL, absCBL, absXBR, absYBR, absCBR, z, mode);
|
114
|
+
}
|
115
|
+
}
|
@@ -0,0 +1,37 @@
|
|
1
|
+
#ifndef GOSUIMPL_LARGEIMAGEDATA_HPP
|
2
|
+
#define GOSUIMPL_LARGEIMAGEDATA_HPP
|
3
|
+
|
4
|
+
#include <Gosu/Fwd.hpp>
|
5
|
+
#include <Gosu/ImageData.hpp>
|
6
|
+
#include <boost/none.hpp>
|
7
|
+
#include <boost/shared_ptr.hpp>
|
8
|
+
#include <vector>
|
9
|
+
|
10
|
+
namespace Gosu
|
11
|
+
{
|
12
|
+
class LargeImageData : public ImageData
|
13
|
+
{
|
14
|
+
unsigned fullWidth, fullHeight, partsX, partsY, partWidth, partHeight;
|
15
|
+
std::vector<boost::shared_ptr<ImageData> > parts;
|
16
|
+
|
17
|
+
public:
|
18
|
+
LargeImageData(Graphics& graphics, const Bitmap& source,
|
19
|
+
unsigned partWidth, unsigned partHeight, unsigned borderFlags);
|
20
|
+
|
21
|
+
unsigned width() const;
|
22
|
+
unsigned height() const;
|
23
|
+
|
24
|
+
void draw(double x1, double y1, Color c1,
|
25
|
+
double x2, double y2, Color c2,
|
26
|
+
double x3, double y3, Color c3,
|
27
|
+
double x4, double y4, Color c4,
|
28
|
+
ZPos z, AlphaMode mode) const;
|
29
|
+
|
30
|
+
boost::optional<GLTexInfo> glTexInfo() const
|
31
|
+
{
|
32
|
+
return boost::none;
|
33
|
+
}
|
34
|
+
};
|
35
|
+
}
|
36
|
+
|
37
|
+
#endif
|
@@ -0,0 +1,184 @@
|
|
1
|
+
#include <Gosu/RotFlip.hpp>
|
2
|
+
#include <algorithm>
|
3
|
+
|
4
|
+
const Gosu::RotFlip::TransTable Gosu::RotFlip::flipXTable =
|
5
|
+
{
|
6
|
+
// rfDefault ->
|
7
|
+
rfFlipX,
|
8
|
+
// rfRotate90 ->
|
9
|
+
rfRotate90FlipX,
|
10
|
+
// rfRotate180 ->
|
11
|
+
rfRotate180FlipX,
|
12
|
+
// rfRotate270 ->
|
13
|
+
rfRotate270FlipX,
|
14
|
+
// rfFlipX ->
|
15
|
+
rfDefault,
|
16
|
+
// rfRotate90FlipX ->
|
17
|
+
rfRotate90,
|
18
|
+
// rfRotate180FlipX ->
|
19
|
+
rfRotate180,
|
20
|
+
// rfRotate270FlipX ->
|
21
|
+
rfRotate270
|
22
|
+
};
|
23
|
+
|
24
|
+
const Gosu::RotFlip::TransTable Gosu::RotFlip::flipYTable =
|
25
|
+
{
|
26
|
+
// rfDefault ->
|
27
|
+
rfFlipY,
|
28
|
+
// rfRotate90 ->
|
29
|
+
rfRotate90FlipY,
|
30
|
+
// rfRotate180 ->
|
31
|
+
rfRotate180FlipY,
|
32
|
+
// rfRotate270 ->
|
33
|
+
rfRotate270FlipY,
|
34
|
+
// rfFlipX ->
|
35
|
+
rfRotate180,
|
36
|
+
// rfRotate90FlipX ->
|
37
|
+
rfRotate270,
|
38
|
+
// rfRotate180FlipX ->
|
39
|
+
rfDefault,
|
40
|
+
// rfRotate270FlipX ->
|
41
|
+
rfRotate90
|
42
|
+
};
|
43
|
+
|
44
|
+
const Gosu::RotFlip::TransTable Gosu::RotFlip::rotate90Table =
|
45
|
+
{
|
46
|
+
// rfDefault ->
|
47
|
+
rfRotate90,
|
48
|
+
// rfRotate90 ->
|
49
|
+
rfRotate180,
|
50
|
+
// rfRotate180 ->
|
51
|
+
rfRotate270,
|
52
|
+
// rfRotate270 ->
|
53
|
+
rfDefault,
|
54
|
+
// rfFlipX ->
|
55
|
+
rfFlipXRotate90,
|
56
|
+
// rfRotate90FlipX ->
|
57
|
+
rfFlipX,
|
58
|
+
// rfRotate180FlipX ->
|
59
|
+
rfFlipYRotate90,
|
60
|
+
// rfRotate270FlipX ->
|
61
|
+
rfFlipY
|
62
|
+
};
|
63
|
+
|
64
|
+
const Gosu::RotFlip::TransTable Gosu::RotFlip::rotate180Table =
|
65
|
+
{
|
66
|
+
// rfDefault ->
|
67
|
+
rotate90Table[rotate90Table[rfDefault]],
|
68
|
+
// rfRotate90 ->
|
69
|
+
rotate90Table[rotate90Table[rfRotate90]],
|
70
|
+
// rfRotate180 ->
|
71
|
+
rotate90Table[rotate90Table[rfRotate180]],
|
72
|
+
// rfRotate270 ->
|
73
|
+
rotate90Table[rotate90Table[rfRotate270]],
|
74
|
+
// rfFlipX ->
|
75
|
+
rotate90Table[rotate90Table[rfFlipX]],
|
76
|
+
// rfRotate90FlipX ->
|
77
|
+
rotate90Table[rotate90Table[rfRotate90FlipX]],
|
78
|
+
// rfRotate180FlipX ->
|
79
|
+
rotate90Table[rotate90Table[rfRotate180FlipX]],
|
80
|
+
// rfRotate270FlipX ->
|
81
|
+
rotate90Table[rotate90Table[rfRotate270FlipX]],
|
82
|
+
};
|
83
|
+
|
84
|
+
const Gosu::RotFlip::TransTable Gosu::RotFlip::rotate270Table =
|
85
|
+
{
|
86
|
+
// rfDefault ->
|
87
|
+
rotate90Table[rotate180Table[rfDefault]],
|
88
|
+
// rfRotate90 ->
|
89
|
+
rotate90Table[rotate180Table[rfRotate90]],
|
90
|
+
// rfRotate180 ->
|
91
|
+
rotate90Table[rotate180Table[rfRotate180]],
|
92
|
+
// rfRotate270 ->
|
93
|
+
rotate90Table[rotate180Table[rfRotate270]],
|
94
|
+
// rfFlipX ->
|
95
|
+
rotate90Table[rotate180Table[rfFlipX]],
|
96
|
+
// rfRotate90FlipX ->
|
97
|
+
rotate90Table[rotate180Table[rfRotate90FlipX]],
|
98
|
+
// rfRotate180FlipX ->
|
99
|
+
rotate90Table[rotate180Table[rfRotate180FlipX]],
|
100
|
+
// rfRotate270FlipX ->
|
101
|
+
rotate90Table[rotate180Table[rfRotate270FlipX]],
|
102
|
+
};
|
103
|
+
|
104
|
+
const Gosu::RotFlip::CornerTable Gosu::RotFlip::mapCornerTable =
|
105
|
+
{
|
106
|
+
// rfDefault ->
|
107
|
+
{ 0, 1, 2, 3 },
|
108
|
+
// rfRotate90 ->
|
109
|
+
{ 1, 3, 0, 2 },
|
110
|
+
// rfRotate180 ->
|
111
|
+
{ 3, 2, 1, 0 },
|
112
|
+
// rfRotate270 ->
|
113
|
+
{ 2, 0, 3, 1 },
|
114
|
+
// rfFlipX ->
|
115
|
+
{ 1, 0, 3, 2 },
|
116
|
+
// rfRotate90FlipX ->
|
117
|
+
{ 0, 2, 1, 3 },
|
118
|
+
// rfRotate180FlipX ->
|
119
|
+
{ 2, 3, 0, 1 },
|
120
|
+
// rfRotate270FlipX ->
|
121
|
+
{ 3, 1, 2, 0 }
|
122
|
+
};
|
123
|
+
|
124
|
+
const Gosu::RotFlip::CornerTable Gosu::RotFlip::realCornerTable =
|
125
|
+
{
|
126
|
+
// rfDefault ->
|
127
|
+
{ 0, 1, 2, 3 },
|
128
|
+
// rfRotate90 ->
|
129
|
+
{ 1, 3, 0, 2 },
|
130
|
+
// rfRotate180 ->
|
131
|
+
{ 3, 2, 1, 0 },
|
132
|
+
// rfRotate270 ->
|
133
|
+
{ 1, 3, 0, 2 },
|
134
|
+
// rfFlipX ->
|
135
|
+
{ 1, 0, 3, 2 },
|
136
|
+
// rfRotate90FlipX ->
|
137
|
+
{ 3, 1, 2, 0 },
|
138
|
+
// rfRotate180FlipX ->
|
139
|
+
{ 2, 3, 0, 1 },
|
140
|
+
// rfRotate270FlipX ->
|
141
|
+
{ 0, 2, 1, 3 }
|
142
|
+
};
|
143
|
+
|
144
|
+
void Gosu::applyToPoint(Gosu::RotFlip rotFlip, int& x, int& y, int max)
|
145
|
+
{
|
146
|
+
switch (rotFlip.name())
|
147
|
+
{
|
148
|
+
case rfDefault:
|
149
|
+
return;
|
150
|
+
|
151
|
+
case rfRotate90:
|
152
|
+
std::swap(x, y);
|
153
|
+
y = max - y;
|
154
|
+
return;
|
155
|
+
|
156
|
+
case rfRotate180:
|
157
|
+
x = max - x;
|
158
|
+
y = max - y;
|
159
|
+
return;
|
160
|
+
|
161
|
+
case rfRotate270:
|
162
|
+
std::swap(x, y);
|
163
|
+
x = max - x;
|
164
|
+
return;
|
165
|
+
|
166
|
+
case rfFlipX:
|
167
|
+
x = max - x;
|
168
|
+
return;
|
169
|
+
|
170
|
+
case rfRotate90FlipX:
|
171
|
+
std::swap(x, y);
|
172
|
+
return;
|
173
|
+
|
174
|
+
case rfRotate180FlipX: // == rfFlipY
|
175
|
+
y = max - y;
|
176
|
+
return;
|
177
|
+
|
178
|
+
case rfRotate270FlipX:
|
179
|
+
int temp = x;
|
180
|
+
x = max - y;
|
181
|
+
y = max - temp;
|
182
|
+
return;
|
183
|
+
}
|
184
|
+
}
|
@@ -0,0 +1,77 @@
|
|
1
|
+
#include <GosuImpl/Graphics/TexChunk.hpp>
|
2
|
+
#include <GosuImpl/Graphics/Texture.hpp>
|
3
|
+
#include <GosuImpl/Graphics/DrawOp.hpp>
|
4
|
+
#include <Gosu/Bitmap.hpp>
|
5
|
+
#include <Gosu/Graphics.hpp>
|
6
|
+
|
7
|
+
Gosu::TexChunk::TexChunk(Graphics& graphics, DrawOpQueue& queue,
|
8
|
+
boost::shared_ptr<Texture> texture,
|
9
|
+
int x, int y, int w, int h, int padding)
|
10
|
+
: graphics(&graphics), queue(&queue), texture(texture), x(x), y(y), w(w), h(h), padding(padding)
|
11
|
+
{
|
12
|
+
}
|
13
|
+
|
14
|
+
Gosu::TexChunk::~TexChunk()
|
15
|
+
{
|
16
|
+
texture->free(x - padding, y - padding);
|
17
|
+
}
|
18
|
+
|
19
|
+
unsigned int Gosu::TexChunk::width() const
|
20
|
+
{
|
21
|
+
return w;
|
22
|
+
}
|
23
|
+
|
24
|
+
unsigned int Gosu::TexChunk::height() const
|
25
|
+
{
|
26
|
+
return h;
|
27
|
+
}
|
28
|
+
|
29
|
+
GLuint Gosu::TexChunk::texName() const
|
30
|
+
{
|
31
|
+
return texture->texName();
|
32
|
+
}
|
33
|
+
|
34
|
+
void Gosu::TexChunk::getCoords(double& left, double& top, double& right, double& bottom) const
|
35
|
+
{
|
36
|
+
left = double(x) / texture->size();
|
37
|
+
top = double(y) / texture->size();
|
38
|
+
right = double(x + w) / texture->size();
|
39
|
+
bottom = double(y + h) / texture->size();
|
40
|
+
}
|
41
|
+
|
42
|
+
void Gosu::TexChunk::draw(double x1, double y1, Color c1,
|
43
|
+
double x2, double y2, Color c2,
|
44
|
+
double x3, double y3, Color c3,
|
45
|
+
double x4, double y4, Color c4,
|
46
|
+
ZPos z, AlphaMode mode) const
|
47
|
+
{
|
48
|
+
DrawOp newDrawOp;
|
49
|
+
|
50
|
+
x1 *= graphics->factorX();
|
51
|
+
y1 *= graphics->factorY();
|
52
|
+
x2 *= graphics->factorX();
|
53
|
+
y2 *= graphics->factorY();
|
54
|
+
x3 *= graphics->factorX();
|
55
|
+
y3 *= graphics->factorY();
|
56
|
+
x4 *= graphics->factorX();
|
57
|
+
y4 *= graphics->factorY();
|
58
|
+
|
59
|
+
newDrawOp.usedVertices = 4;
|
60
|
+
newDrawOp.vertices[0] = DrawOp::Vertex(x1, y1, c1);
|
61
|
+
newDrawOp.vertices[1] = DrawOp::Vertex(x2, y2, c2);
|
62
|
+
newDrawOp.vertices[3] = DrawOp::Vertex(x3, y3, c3);
|
63
|
+
newDrawOp.vertices[2] = DrawOp::Vertex(x4, y4, c4);
|
64
|
+
newDrawOp.chunk = this;
|
65
|
+
newDrawOp.mode = mode;
|
66
|
+
|
67
|
+
queue->addDrawOp(newDrawOp, z);
|
68
|
+
}
|
69
|
+
|
70
|
+
|
71
|
+
boost::optional<Gosu::GLTexInfo> Gosu::TexChunk::glTexInfo() const
|
72
|
+
{
|
73
|
+
Gosu::GLTexInfo info;
|
74
|
+
info.texName = texName();
|
75
|
+
getCoords(info.left, info.top, info.right, info.bottom);
|
76
|
+
return info;
|
77
|
+
}
|
@@ -0,0 +1,40 @@
|
|
1
|
+
#ifndef GOSUIMPL_GRAPHICS_TEXCHUNK_HPP
|
2
|
+
#define GOSUIMPL_GRAPHICS_TEXCHUNK_HPP
|
3
|
+
|
4
|
+
#include <Gosu/Fwd.hpp>
|
5
|
+
#include <Gosu/ImageData.hpp>
|
6
|
+
#include <GosuImpl/Graphics/Common.hpp>
|
7
|
+
#include <memory>
|
8
|
+
#include <vector>
|
9
|
+
#include <stdexcept>
|
10
|
+
#include <boost/shared_ptr.hpp>
|
11
|
+
|
12
|
+
class Gosu::TexChunk : public Gosu::ImageData
|
13
|
+
{
|
14
|
+
Graphics* graphics;
|
15
|
+
DrawOpQueue* queue;
|
16
|
+
boost::shared_ptr<Texture> texture;
|
17
|
+
int x, y, w, h, padding;
|
18
|
+
|
19
|
+
public:
|
20
|
+
TexChunk(Graphics& graphics, DrawOpQueue& queue, boost::shared_ptr<Texture> texture,
|
21
|
+
int x, int y, int w, int h, int padding);
|
22
|
+
~TexChunk();
|
23
|
+
|
24
|
+
unsigned int width() const;
|
25
|
+
unsigned int height() const;
|
26
|
+
|
27
|
+
GLuint texName() const;
|
28
|
+
void getCoords(double& left, double& top, double& right, double& bottom) const;
|
29
|
+
|
30
|
+
void draw(double x1, double y1, Color c1,
|
31
|
+
double x2, double y2, Color c2,
|
32
|
+
double x3, double y3, Color c3,
|
33
|
+
double x4, double y4, Color c4,
|
34
|
+
ZPos z, AlphaMode mode) const;
|
35
|
+
|
36
|
+
boost::optional<GLTexInfo> glTexInfo() const;
|
37
|
+
};
|
38
|
+
|
39
|
+
#endif
|
40
|
+
|