Skip to content

Commit 7520d24

Browse files
committed
DrawingLotsOf3dText: Text in place
1 parent 41a55b3 commit 7520d24

File tree

8 files changed

+265
-10
lines changed

8 files changed

+265
-10
lines changed
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
Take me out tonight
2+
Where there's music and there's people
3+
And they're young and alive
4+
Driving in your car
5+
I never, never want to go home
6+
Because I haven't got one
7+
Anymore
8+
Take me out tonight
9+
Because I want to see people
10+
And I want to see life
11+
Driving in your car
12+
Oh, please don't drop me home
13+
Because it's not my home, it's their home
14+
And I'm welcome no more
15+
And if a double-decker bus
16+
Crashes into us
17+
To die by your side
18+
Is such a heavenly way to die
19+
And if a ten ton truck
20+
Kills the both of us
21+
To die by your side
22+
Well, the pleasure, the privilege is mine
23+
Take me out tonight
24+
Take me anywhere, I don't care
25+
I don't care, I don't care
26+
And in the darkened underpass
27+
I thought, "Oh God, my chance has come at last"
28+
But then a strange fear gripped me
29+
And I just couldn't ask
30+
Take me out tonight
31+
Oh, take me anywhere, I don't care
32+
I don't care, I don't care
33+
Driving in your car
34+
I never, never want to go home
35+
Because I haven't got one, la-di-dum
36+
Oh, I haven't got one
37+
Oh, oh
38+
And if a double-decker bus
39+
Crashes into us
40+
To die by your side
41+
Is such a heavenly way to die
42+
And if a ten ton truck
43+
Kills the both of us
44+
To die by your side
45+
Well, the pleasure, the privilege is mine
46+
Oh, there is a light and it never goes out
47+
There is a light and it never goes out
48+
There is a light and it never goes out
49+
There is a light and it never goes out
50+
There is a light and it never goes out
51+
There is a light and it never goes out
52+
There is a light and it never goes out
53+
There is a light and it never goes out
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
When you walk without ease
2+
On these streets where you were raised
3+
I had a really bad dream
4+
It lasted 20 years, 7 months and 27 days
5+
And I know alone that I never, ever oh
6+
Had no one ever
7+
Now I'm outside your house
8+
I'm alone
9+
And I'm outside your house
10+
I hate to intrude
11+
Oh, I'm alone, I'm alone
12+
I'm alone, I'm alone, I'm alone, I'm alone
13+
And I never, never oh
14+
Had no one ever
15+
I never had no one ever
16+
I never had no, no one ever
17+
Had no one never
18+
Never, no, oh
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
The death of a disco dancer
2+
Well, it happens a lot 'round here
3+
And if you think Peace
4+
Is a common goal
5+
That goes to show
6+
How little you know
7+
The death of a disco dancer
8+
Well, I'd rather not get involved
9+
I never talk to my neighbour
10+
I'd rather not get involved
11+
Oh
12+
Love, peace and harmony?
13+
Love, peace and harmony?
14+
Oh, very nice
15+
Very nice
16+
Very nice
17+
Very nice
18+
But maybe in the next world
19+
Love, peace and harmony?
20+
Love, peace and harmony?
21+
Oh, very nice
22+
Very nice
23+
Very nice
24+
Very nice
25+
Very nice
26+
But maybe in the next world
27+
Maybe in the next world
28+
Maybe in the next world
29+
Oh, love, peace and harmony?
30+
Love, peace and harmony?
31+
Oh, very nice
32+
Very nice
33+
Very nice
34+
Oh, but maybe in the next world
35+
Maybe in the next world
36+
(In the next world, in the next world, in the next world)
37+
(In the next world, in the next world, in the next world)
38+
The next world, the next world
39+
Oh
40+
The death of a disco dancer
41+
The death of a disco dancer
42+
The death of a disco dancer
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
Farewell to this land's cheerless marshes
2+
Hemmed in like a boar between archers
3+
Her very Lowness with her head in a sling
4+
I'm truly sorry, but it sounds like a wonderful thing
5+
"I say, Charles, don't you ever crave
6+
To appear on the front of the Daily Mail
7+
Dressed in your Mother's bridal veil?" Ooh, ooh, ooh
8+
And so I checked all the registered historical facts
9+
And I was shocked into shame to discover
10+
How I'm the 18th pale descendant of some old queen or other
11+
Oh, has the world changed, or have I changed?
12+
Oh, has the world changed, or have I changed?
13+
As some 9-year-old tough, who peddles drugs
14+
I swear to God, I swear, I never even knew what drugs were
15+
Ooh, oh-oh, ooh
16+
So I broke into the Palace with a sponge and a rusty spanner
17+
She said, "Eh, I know, and you cannot sing"
18+
I said, "That's nothing, you should hear me play the piano"
19+
We can go for a walk where it's quiet and dry
20+
And talk about precious things
21+
But when you're tied to your Mother's apron
22+
No one talks about castration, ooh, oh-oh, ooh
23+
We can go for a walk where it's quiet and dry
24+
And talk about precious things
25+
Like love and law and poverty, ooh-ooh
26+
(These are the things that kill me)
27+
We can go for a walk where it's quiet and dry
28+
And talk about precious things
29+
But the rain that flattens my hair, ooh
30+
(These are the things that kill me)
31+
All their life, they make love and then pierce through me
32+
Pass the Pub that saps your body
33+
And the church who'll snatch your money
34+
The Queen is dead, boys
35+
And it's so lonely on a limb
36+
Pass the Pub that wrecks your body
37+
And the church all they want is your money
38+
The Queen is dead, boys
39+
And it's so lonely on a limb
40+
Life is very long when you're lonely
41+
Life is very long when you're lonely
42+
Life is very long when you're lonely
43+
Life is very long when you're lonely
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
Frankly, Mr. Shankly, this position I've held
2+
It pays my way, and it corrodes my soul
3+
I want to leave, you will not miss me
4+
I want to go down in musical history
5+
Frankly, Mr. Shankly, I'm a sickening wreck
6+
I've got the 21st century breathing down my neck
7+
I must move fast, you understand me
8+
I want to go down in celluloid history, Mr. Shankly
9+
Fame, fame, fatal fame
10+
It can play hideous tricks on the brain
11+
But still, I'd rather be famous
12+
Then righteous or holy, any day, any day, any day
13+
But sometimes I'd feel more fulfilled
14+
Making Christmas cards with the mentally ill
15+
I want to live and I want to love
16+
I want to catch something that I might be ashamed of
17+
Frankly, Mr. Shankly, this position I've held
18+
It pays my way, and it corrodes my soul
19+
Oh, I didn't realize that you wrote poetry
20+
I didn't realize you wrote such bloody awful poetry, Mr. Shankly
21+
Frankly, Mr. Shankly, since you ask
22+
You are a flatulent pain in the arse
23+
I do not mean to be so rude
24+
Still, I must speak frankly, Mr. Shankly
25+
Oh, give us your money
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
... Oh Mother, I can feel the soil falling over my head
2+
And as I climb into an empty bed
3+
Oh well. Enough said.
4+
I know it's over - still I cling
5+
I don't know where else I can go
6+
Oh...
7+
... Oh Mother, I can feel the soil falling over my head
8+
See, the sea wants to take me
9+
The knife wants to slit me
10+
Do you think you can help me?
11+
... Sad veiled bride, please be happy
12+
Handsome groom, give her room
13+
Loud, loutish lover, treat her kindly
14+
(Though she needs you
15+
More than she loves you)
16+
And I know it's over - still I cling
17+
I don't know where else I can go
18+
Over and over and over and over
19+
Over and over, la...
20+
... I know it's over
21+
And it never really began
22+
But in my heart it was so real
23+
And you even spoke to me, and said :
24+
"If you're so funny
25+
Then why are you on your own tonight ?
26+
And if you're so clever
27+
Then why are you on your own tonight ?
28+
If you're so very entertaining
29+
Then why are you on your own tonight ?
30+
If you're so very good-looking
31+
Why do you sleep alone tonight ?
32+
I know...
33+
... 'Cause tonight is just like any other night
34+
That's why you're on your own tonight
35+
With your triumphs and your charms
36+
While they're in each other's arms..."
37+
It's so easy to laugh
38+
It's so easy to hate
39+
It takes strength to be gentle and kind
40+
Over, over, over, over
41+
... It's so easy to laugh
42+
It's so easy to hate
43+
It takes guts to be gentle and kind
44+
Over, over
45+
Love is natural and real
46+
But not for you, my love
47+
Not tonight, my love
48+
Love is natural and real
49+
But not for such as you and I, my love
50+
... Oh Mother, I can feel the soil falling over my head
51+
Oh Mother, I can feel the soil falling over my head
52+
Oh Mother, I can feel the soil falling over my head
53+
Oh Mother, I can feel the soil falling over my ...
54+
Oh Mother, I can feel the soil falling over my head
55+
Oh Mother, I can even feel the soil falling over my head
56+
Oh Mother, I can feel the soil falling over my head
57+
Oh Mother, I can feel the soil falling over my...

sketches/DrawingLotsOf3dText/src/Sketch.cpp

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,31 @@ using namespace std;
44
using namespace chr;
55
using namespace gl;
66

7-
static constexpr float FOVY = 45;
8-
static constexpr float CAMERA_DISTANCE = 400;
9-
static constexpr float CAMERA_ELEVATION = 60;
7+
static constexpr float GUTTER = 20;
108

119
void Sketch::setup()
1210
{
13-
auto lines = utils::readLines<u16string>(InputSource::resource("song1.txt"));
11+
vector<vector<u16string>> songs;
12+
for (auto &name : {"song1.txt", "song2.txt", "song3.txt", "song4.txt", "song5.txt", "song6.txt", "song7.txt"})
13+
{
14+
songs.push_back(utils::readLines<u16string>(InputSource::resource(name)));
15+
}
1416

1517
font = fontManager.getFont(InputSource::resource("Georgia_Regular_64.fnt"), XFont::Properties3d());
1618
font->setShader(textureAlphaShader);
1719
font->setSize(12);
1820
font->setColor(0, 0, 0, 1);
1921

2022
font->beginSequence(sequence);
21-
drawLines(*font, lines, 0, 0);
23+
24+
float x = -150;
25+
float y= -70;
26+
for (const auto &song : songs)
27+
{
28+
auto result = drawLines(*font, song, x, y);
29+
x += GUTTER + result.x;
30+
}
31+
2232
font->endSequence();
2333

2434
// ---
@@ -33,7 +43,7 @@ void Sketch::setup()
3343
void Sketch::resize()
3444
{
3545
camera
36-
.setFov(FOVY)
46+
.setFov(45)
3747
.setClip(1, 10000)
3848
.setWindowSize(windowInfo.size);
3949
}
@@ -48,8 +58,9 @@ void Sketch::draw()
4858
camera.getViewMatrix()
4959
.setIdentity()
5060
.scale(1, -1, 1)
51-
.translate(0, 0, -CAMERA_DISTANCE)
52-
.rotateX(CAMERA_ELEVATION * D2R);
61+
.translate(0, 0, -400)
62+
.rotateX(45 * D2R)
63+
.rotateZ(-15 * D2R);
5364

5465
Matrix panMatrix;
5566
panMatrix.translate(pan);
@@ -73,15 +84,21 @@ void Sketch::updateTouch(int index, float x, float y)
7384
pan = convert(glm::vec2(x, y)) - dragOrigin;
7485
}
7586

76-
void Sketch::drawLines(XFont &font, const vector<u16string> &lines, float x, float y)
87+
glm::vec2 Sketch::drawLines(XFont &font, const vector<u16string> &lines, float x, float y)
7788
{
7889
float lineHeight = font.getHeight() * 1.2f;
90+
float maxWidth = 0;
7991

8092
for (const auto &line : lines)
8193
{
94+
float width = font.getStringAdvance(line);
95+
if (width > maxWidth) maxWidth = width;
96+
8297
drawText(font, line, x, y);
8398
y += lineHeight;
8499
}
100+
101+
return glm::vec2(maxWidth, lineHeight * lines.size());
85102
}
86103

87104
void Sketch::drawText(XFont &font, const u16string &text, float x, float y)

sketches/DrawingLotsOf3dText/src/Sketch.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class Sketch : public chr::CrossSketch
2828
chr::xf::FontSequence sequence;
2929
chr::gl::shaders::TextureAlphaShader textureAlphaShader;
3030

31-
static void drawLines(chr::XFont &font, const std::vector<std::u16string> &lines, float x, float y);
31+
static glm::vec2 drawLines(chr::XFont &font, const std::vector<std::u16string> &lines, float x, float y);
3232
static void drawText(chr::XFont &font, const std::u16string &text, float x, float y);
3333

3434
glm::vec2 convert(const glm::vec2 &position);

0 commit comments

Comments
 (0)