Computer Graphics Programming in OpenGL with Java Gordon instant download
Computer Graphics Programming in OpenGL with Java Gordon instant download
https://textbookfull.com/product/computer-graphics-programming-
in-opengl-with-java-gordon/
https://textbookfull.com/product/computer-graphics-programming-
in-opengl-with-java-2nd-edition-v-scott-gordon/
https://textbookfull.com/product/computer-graphics-programming-
in-opengl-using-c-third-edition-gordon-phd/
https://textbookfull.com/product/introduction-to-computer-
graphics-with-opengl-es-first-edition-junghyun-han/
https://textbookfull.com/product/computer-graphics-through-
opengl-third-edition-guha/
Computer Graphics Through OpenGL: From Theory to
Experiments Sumanta Guha
https://textbookfull.com/product/computer-graphics-through-
opengl-from-theory-to-experiments-sumanta-guha/
https://textbookfull.com/product/learn-opengl-learn-modern-
opengl-graphics-programming-in-a-step-by-step-fashion-1st-
edition-joey-de-vries/
https://textbookfull.com/product/computer-graphics-for-java-
programmers-3rd-edition-leen-ammeraal/
https://textbookfull.com/product/opengl-programming-guide-the-
official-guide-to-learning-opengl-version-4-5-with-spir-v-9th-
edition-kessenich/
https://textbookfull.com/product/learning-java-an-introduction-
to-real-world-programming-with-java-marc-loy/
Computer GraphiCs
proGramminG in openGL
with Java
LICENSE, DISCLAIMER OF LIABILITY, AND LIMITED WARRANTY
By purchasing or using this book (the “Work”), you agree that this license grants
permission to use the contents contained herein, but does not give you the right
of ownership to any of the textual content in the book or ownership to any of the
information or products contained in it. This license does not permit uploading of the
Work onto the Internet or on a network (of any kind) without the written consent of
the Publisher. Duplication or dissemination of any text, code, simulations, images,
etc. contained herein is limited to and subject to licensing terms for the respective
products, and permission must be obtained from the Publisher or the owner of the
content, etc., in order to reproduce or network any portion of the textual material
(in any media) that is contained in the Work.
The authors, developers, and the publisher of any accompanying content, and
anyone involved in the composition, production, and manufacturing of this work
will not be liable for damages of any kind arising out of the use of (or the inability to
use) the algorithms, source code, computer programs, or textual material contained
in this publication. This includes, but is not limited to, loss of revenue or profit, or
other incidental, physical, or consequential damages arising out of the use of this
Work.
The sole remedy in the event of a claim of any kind is expressly limited to
replacement of the book, and only at the discretion of the Publisher. The use of
“implied warranty” and certain “exclusions” vary from state to state, and might not
apply to the purchaser of this product.
Companion disc files are available for download from the publisher by writing to
[email protected].
Computer GraphiCs
proGramminG in openGL
with Java
This publication, portions of it, or any accompanying software may not be reproduced in any way,
stored in a retrieval system of any type, or transmitted by any means, media, electronic display or
mechanical display, including, but not limited to, photocopy, recording, Internet postings, or scan-
ning, without prior permission in writing from the publisher.
The publisher recognizes and respects all marks used by companies, manufacturers, and
developers as a means to distinguish their products. All brand names and product names mentioned
in this book are trademarks or service marks of their respective companies. Any omission or misuse
(of any kind) of service marks or trademarks, etc. is not an attempt to infringe on the property
of others.
Our titles are available for adoption, license, or bulk purchase by institutions, corporations, etc.
For additional information, please contact the Customer Service Dept. at 800-232-0223 (toll free).
Digital versions of our titles are available at: www.authorcloudware.com and other e-vendors. All
companion files are available by writing to the publisher at [email protected].
The sole obligation of Mercury Learning and InforMation to the purchaser is to replace the book
and/or disc, based on defective materials or faulty workmanship, but not based on the operation or
functionality of the product.
Contents
Preface xi
Intended Audience xiii
How to Use This Book xiii
Acknowledgments xv
About the Authors xv
vi ■ C o n t e n ts
4.9 Combating “Z-Fighting” Artifacts 94
4.10 Other Options for Primitives 95
4.11 Back-Face Culling 97
viii ■ C o n t e n ts
Chapter 13 Geometry Shaders 287
13.1 Per-Primitive Processing in OpenGL 287
13.2 Altering Primitives 288
13.3 Deleting Primitives 293
13.4 Adding Primitives 294
Index 337
C onte nts ■ ix
Preface
This book is designed primarily as a textbook for a typical computer science undergradu-
ate course in OpenGL 3D graphics programming. However, we have also wanted to create
a text that could be used to teach oneself, without an accompanying course. With both of
those aims in mind, we have tried to explain things as clearly and simply as we can. Every
programming example is stripped-down and simplified as much as possible, but still com-
plete so that the reader may run them all as presented.
One of the things that we hope is unique about this book is that we have strived to make
it accessible to a beginner—that is, someone new to 3D graphics programming. While
there is by no means a lack of information available on the topic—quite the contrary—
many students are initially overwhelmed. This text is our attempt to write the book we
wish we had had when we were starting out, with step-by-step explanations of the basics,
progressing in an organized manner up through advanced topics. We considered titling the
book “shader programming made easy”; however, we don’t think that there really is any
way of making shader programming “easy.” We hope that we have come close.
Another thing that makes this book unique is that it teaches OpenGL programming
in Java, using JOGL—a Java “wrapper” for OpenGL’s native C calls [JO16]. There are
several advantages to learning graphics programming in Java rather than in C:
• It is more convenient for students at schools that conduct most of their curriculum
in Java.
• Java’s I/O, window, and event handling are arguably cleaner than in C.
• Java’s excellent support for object-oriented design patterns can foster good design.
It is worth mentioning that there do exist other Java bindings for OpenGL. One that
is becoming increasingly popular is Lightweight Java Game Library, or LWJGL [LW16].
Like JOGL, LWJGL also offers bindings for OpenAL and OpenCL. This textbook focuses
only on JOGL.
Another point of clarification is that there exist both different versions of OpenGL
(briefly discussed later) and different variants of OpenGL. For example, in addition to
“standard OpenGL” (sometimes called “desktop OpenGL”), there exists a variant called
“OpenGL ES” which is tailored for development of embedded systems (hence the “ES”).
“Embedded systems” include devices such as mobile phones, game consoles, automobiles,
and industrial control systems. OpenGL ES is mostly a subset of standard OpenGL, elimi-
nating a large number of operations that are typically not needed for embedded systems.
OpenGL ES also adds some additional functionality, typically application-specific opera-
tions for particular target environments. The JOGL suite of Java bindings includes inter-
faces for different versions of OpenGL ES, although we do not use them in this book.
Yet another variant of OpenGL is called “WebGL.” Based on OpenGL ES, WebGL is
designed to support the use of OpenGL in web browsers. WebGL allows an application to
use JavaScript1 to invoke OpenGL ES operations, which makes it easy to embed OpenGL
graphics into standard HTML (web) documents. Most modern web browsers support
WebGL, including Apple Safari, Google Chrome, Microsoft Internet Explorer, Mozilla
Firefox, and Opera. Since web programming is outside the scope of this book, we will not
cover any WebGL specifics. Note however that because WebGL is based on OpenGL ES,
which in turn is based on standard OpenGL, much of what is covered in this book can be
transferred directly to learning about these OpenGL variants.
The very topic of 3D graphics lends itself to impressive, even beautiful images.
Indeed, many popular textbooks on the topic are filled with breathtaking scenes, and it
is enticing to leaf through their galleries. While we acknowledge the motivational utility
of such examples, our aim is to teach, not to impress. The images in this book are simply
the outputs of the example programs, and since this is an introductory text, the resulting
scenes are unlikely to impress an expert. However, the techniques presented do constitute
the foundational elements for producing today’s stunning 3D effects.
1
JavaScript is a scripting language that can be used to embed code in webpages. It has strong
similarities to Java, but also many important differences.
xii ■ Pr e f a c e
use OpenGL and JOGL as vehicles for teaching the fundamentals of modern shader-based
3D graphics programming, and provide the reader with a sufficiently deep understanding
for further study. If along the way this text helps to expand awareness of JOGL and other
JogAmp technologies, that would be nice too.
Intended Audience
This book is targeted at students of computer science. This could mean undergraduates pur-
suing a BS degree, but it could also mean anyone who studies computer science. As such, we
are assuming that the reader has at least a solid background in object-oriented programming,
at the level of someone who is, say, a computer science major at the junior or senior level.
There are also some specific things that we use in this book, but that we don’t cover
because we assume the reader already has sufficient background. In particular:
• Java and its Abstract Window Toolkit (AWT) or Swing library, especially for
GUI-building
• Java configuration details, such as manipulating the CLASSPATH
• event-driven programming
• basic matrix algebra and trigonometry
• awareness of color models, such as RGB, RGBA, etc.
This is also intended mostly as a practical, hands-on guide. While there is plenty of
theoretical material included, the reader should treat this text as a sort of “workbook,” in
which you learn basic concepts by actually programming them yourself. We have provided
code for all of the examples, but to really learn the concepts you will want to play with
those examples—extend them to build your own 3D scenes.
At the end of each chapter are a few problems to solve. Some are very simple, involv-
ing merely making simple modifications to the provided code. The problems that are
marked “(PROJECT),” however, are expected to take some time to solve, and require writ-
ing a significant amount of code, or combining techniques from various examples. There
are also a few marked “(RESEARCH)”—those are problems that encourage independent
study because this textbook doesn’t provide sufficient detail to solve them.
Pre fa c e ■ xiii
OpenGL calls, whether made in C or in Java through JOGL, often involve long lists of
parameters. While writing this book, the authors debated whether or not to, in each case,
describe all of the parameters. We decided that at the very beginning, we would describe
every detail. But as the topics progress, we decided to avoid getting bogged down in every
piece of minutiae in the OpenGL calls (and there are many), for fear of the reader losing
sight of the big picture. For this reason, it is essential when working through the examples
to have ready access to reference material for Java, OpenGL, and JOGL.
For this, there are a number of excellent reference sources that we recommend using
in conjunction with this book. The javadocs for Java and JOGL are absolutely essential,
and can be accessed online or downloaded (we explain in Chapter 1 how to download the
JOGL javadoc). The reader should bookmark them for easy access in a browser, and expect
to access them continuously for looking up items such as parameter and constructor details.
The URLs for the Java and JOGL javadocs are:
https://docs.oracle.com/javase/8/docs/api/
https://jogamp.org/deployment/webstart/javadoc/jogl/javadoc
Many of the entries in the JOGL javadoc are simply pointers to the corresponding
entry in the OpenGL documentation, available here:
https://www.opengl.org/sdk/docs/man/
Our examples utilize a mathematics library called graphicslib3D. This is a Java library
that also has its own set of javadocs included. After installing graphicslib3D (described in
Chapter 1), the reader should locate the accompanying javadoc folder and bookmark its
root file (index.html).
Finally, there are many other books on 3D graphics programming that we recommend
reading in parallel with this book (such as for solving the “research” problems). Here are
five that we often refer to:
• (Sellers et al.) OpenGL SuperBible [SW15]
• (Kessenich et al.) OpenGL Programming Guide [KS16] (the “red book”)
• (Wolff) OpenGL 4 Shading Language Cookbook [WO13]
• (Angel and Shreiner) Interactive Computer Graphics [AS14]
• (Luna) Introduction to 3D Game Programming with DirectX 12 [LU16]
xiv ■ Pr e f a c e
Acknowledgments
Early drafts of this book were used in the CSc-155 (Advanced Computer Graphics
Programming) course at CSU Sacramento, and benefited from many student corrections
and comments (and in some cases, code). The authors would particularly like to thank
Mitchell Brannan, Tiffany Chiapuzio-Wong, Samson Chua, Anthony Doan, Kian Faroughi,
Cody Jackson, John Johnston, Zeeshan Khaliq, Raymond Rivera, Oscar Solorzano, Darren
Takemoto, Jon Tinney, James Womack, and Victor Zepeda for their suggestions. We
apologize if we have missed anyone.
We are extremely grateful for the invaluable advice provided to us by Julien Gouesse,
engine support maintainer at Jogamp. Mr. Gouesse provided technical information on
JOGL textures, cube maps, buffer handling, and proper loading of shader source files that
led to improvements in our text.
Jay Turberville of Studio 522 Productions in Scottsdale (Arizona) built the dolphin
model shown on the cover and used throughout this book. Studio 522 Productions does
incredibly high-quality 3D animation and video production, as well as custom 3D mod-
eling. We were thrilled that Mr. Turberville kindly offered to build such a wonderful new
model just for this book project.
We wish to thank a few other artists and researchers who were gracious enough
to allow us to utilize their models and textures. James Hastings-Trew of Planet Pixel
Emporium provided many of the planetary surface textures. Paul Bourke allowed us to use
his wonderful star field. Dr. Marc Levoy of Stanford University granted us permission to
use the famous “Stanford Dragon” model. Paul Baker’s bump-mapping tutorial formed the
basis of the “torus” model we used in many examples. We also thank Mercury Learning
for allowing us to use some of the textures from [LU16].
Dr. Danny Kopec connected us with Mercury Learning and introduced us to its pub-
lisher, David Pallai. Dr. Kopec’s Artificial Intelligence textbook inspired us to consider
Mercury, and our telephone conversations with him were extremely informative. We were
deeply saddened to hear of Dr. Kopec’s untimely passing, and regret that he didn’t have the
chance to see our book come to fruition.
Finally, we wish to thank David Pallai and Jennifer Blaney of Mercury Learning for
believing in this project and guiding us through the textbook publishing process.
Pre fa c e ■ xv
Another Random Scribd Document
with Unrelated Content
fifteen feet of ladder and stepped across the intervening space
between the water and the motor-boat's quarter.
"I'm going to turn in on the floor for the next few nights," replied
Waynsford. "I'm used to it. You see, we've another boat for actual
duty purposes in fine weather. She's smaller and handier. We use
'Lonette' mostly as a kind of parent ship. Now, I'll get the boy to
bring the grub in. Fire away and let's have all the news."
During the rest of the day while daylight lasted Waynsford piloted
his chum round the Queen of Watering Places, taking him up to the
ruined castle and introducing him to some officers of Kitchener's
Army whose acquaintance he had recently made.
It was quite late in the night before the officers of the "Lonette"
turned in. The crew detailed for the duty boat had departed, their
"trick" commencing at midnight. Quietude settled upon the almost
lifeless harbour. Most of the fishing fleet that still remained at its
usual work were out. Five or six of the boats, locked up for the
night, were moored in the inner harbour. Three more, preparing to
leave at high water, were tied up to buoys at the entrance to the
outer basin, their crews working silently as if infected by the solitude
that overspread the once busy port.
Striking a match Waynsford lit the cabin lamp and glanced at the
bulkhead clock.
Sub-Lieutenant Nalder, who being in the port cot had been wedged
between the bunk cushions and those on the side, was sleeping
unconcernedly throughout the racket, as if such happenings were
quite in the usual order of things. Aroused by Waynsford's voice and
a hearty slap on the back, he sat up.
"Sorry, sir," he reported, "but the blessed condensed milk has gone
and upset itself all over the pack."
Gradually the gaunt outlines of the ruined castle that towered high
above the harbour began to grow distinct against the grey sky. The
fog began to disperse, although the cliffs to the southern end of the
town were still invisible.
Acting upon this proposal the two ascended the stony path. As they
approached the coastguard station they noticed that the signalman
was peering seawards through a telescope. The man was so intent
upon some objects out to sea that he paid no attention to the new-
comers.
The three subs. gazed seawards. Just visible through the haze
were four cruisers, moving sufficiently fast through the leaden-
coloured water to cause the foam to froth at their bows. Even as
they looked the young officers were mildly surprised to see a spurt
of dull red flame burst from the for'ard turret of the leading vessel.
Before the noise of the falling brickwork and masonry had subsided
the devoted coastguardsman could be heard shouting on the
telephone:—
The man had done his duty. He could do no more good remaining
where he was. At a quick double he tore for safety, shouting to the
young officers to get under cover.
The three subs. were now under the lee of the frowning rock. Here
they were comparatively safe, except from stray fragments of
splintered shell and flying masonry. The coastguardsman had gone
in a different direction.
The attacking craft had now passed in front of the Castle Hill and
were clearly visible from the harbour, as they slowly steamed within
a quarter of a mile of the shore, vomiting death and destruction
upon the hapless town.
For once, however, these two ships were having things all their
own way. With the exception of the fiasco at Yarmouth, over a
hundred years had elapsed since the thunder of an enemy's guns
had been heard by the dwellers of our sea-girt island. British pride in
the impregnable position of our insular kingdom had received a
nasty shock, for without let or hindrance German guns were
pounding her shores in broad daylight.
Half a mile or so behind the battle cruisers were two light cruisers,
which apparently took little part in the one-sided engagement. They
were engaged in the pleasant occupation of mine-laying, in the hope
that one of the British squadrons, summoned by wireless, would
flounder blindly into the dangerous zone.
"Oh, for a couple of our submarines!" groaned Terence, as the
hostile craft moved slowly along the bay. "They'd bag the whole
crowd of them."
Twenty paces from the spot where the subs. stood was an old
bronzed and bearded fisherman—a typical Yorkshire salt. Heedless of
the risk he ran, he leapt upon the stone parapet, and shaking his fist
at the German ships rated them in the choicest language of the
Shire of Broad Acres. Nor would he descend when Aubyn pointed
out the risk he ran, and it was only when a shell tore a huge hole in
the side of the lighthouse that the old fellow would deign to move.
"Let's gie into town an see t' damage," suggested the old
fisherman, who, like the rest of the hardy East Coast men, had little
respect for rank and persons. "Sith'a, lads, there'll be work for us
over yonder," and he pointed to the maze of houses, many of which
showed signs of the effect of the high-explosive shells.
The cries for aid, uttered in a childish voice, came from the upper
storey. Here a part of the bedroom floor had collapsed, exposing to
view a wooden bedstead, so insecurely perched that it threatened at
every moment to topple over into the chaotic mass thirty feet below.
The stairs had vanished, only the iron handrail and a few of its
supports remaining.
"It may be too late then," replied Terence; then turning to the old
fisherman he bade him bring a coil of rope.
The next instant the sub. was well on his hazardous climb.
Grasping the handrail and making fairly certain that it would bear his
weight, Terence hauled himself up, using the holes in the stonework,
left by the dislodged stairs, as footholds. As sure-footed as a cat, as
active as a panther, he swung himself up, hardly pausing till he
gained the uppermost landing, where a few square inches of
floorboards remained. Between that and the bedstead was a gap
nearly ten feet in width. A professional long-jumper might have
essayed the task with success, but in his case Terence realized that a
leap would be out of the question.
Rapidly the sub. reviewed the situation. From where he stood he
could see the children distinctly. One was a girl of about nine years
of age, fair-haired and pale-faced. It was she who was screaming,
more with fright than pain, although there was a dark moist patch
upon her hair. Her companion was a child of about three, lying with
his head over the side of the bed to all appearances either dead or
else unconscious.
Already the joist nearest the gap in the shattered floor was bending
ominously. Terence felt certain that even if he could get across the
intervening space his weight would precipitate the bed and its
occupants on to the mound of rubble and broken woodwork below.
He looked above him. The laths and plaster of the ceiling had
vanished, the tiles had been blown into the street, leaving the gaunt
rafters practically intact. Raising his hand he found that he could just
grasp the sloping timber.
"If it carries away, I'm done," he thought. "But it's no use hanging
on here, so here goes."
With a resolute leap the sub. seized the two adjoining rafters. The
rough woodwork lacerated his hands, but he heeded it not. By sheer
muscular effort he raised himself sufficiently to pass his arms over
the timber, whence it was a comparatively simple matter to clamber
on top of the outside wall.
Well it was that Aubyn had a good head for heights. Looking down
from that precarious perch would make most landsmen giddy, but as
coolly as if he were walking along a street, the sub. made his way
round to the opposite side of the shattered house immediately over
the still holding floor of the bedroom.
The elder child, on seeing Terence approach, had ceased her cries
and was watching him with wide-open eyes. Then she raised herself,
as if to make a spring into his arms.
"Don't move just yet," exclaimed the sub. as calmly as he could.
"I'll help you both very soon."
He was desperately anxious lest the girl, by her action, would bring
about the calamity he was trying to prevent. At the same time he
was racking his brains to find out how he could get hold of the rope
when the fisherman returned with it.
"Eh, little lass," he exclaimed, imitating to the best of his ability the
East Riding dialect, "just you hand me up one of those sheets. Don't
hurry."
"Eh, lad, a've got 'en," he announced. "An' a block as well. Th'
knows it might come in handy.
Steadily the sub. began to haul in his flimsy line, while the
fisherman dexterously paid out the coil of rope, the end of which he
had made to Aubyn's means of communication. Then, as soon as he
saw that Terence had secured one end of the rope, the old man
hitched on the large pulley and continued to pay out more cordage
until the block was within the sub.'s grasp.
Whipping out his knife Terence cut off about six or seven feet of
rope, using the severed portion as a strop to make fast the block to
a pair of rafters. Then passing the rest of the rope through the
sheave his means of effecting the rescue of the children were ready
for service.
"Ay, ay," replied the old salt, at the same time signing to Waynsford
and Nalder to bear a hand.
Giving a final tug at the strop to make sure as far as possible that
the rafter would hold, Terence slid into the loop and swung himself
clear of the wall.
The next moment the injured girl was safe in his arms. Although
the bed shook as the rescued child moved, it still withstood the
tendency to slip into the abyss. Twenty seconds later Terence
handed his charge over to a doctor who formed one of the rapidly-
gathering crowd in the street.
Spinning round and round like a joint on a meat-jack the sub. again
ascended, till the smaller child's body was within reach of his arms.
As he whipped off the covering he gave an ill-suppressed
exclamation of horror. The left foot of the little victim had been torn
away at the ankle.
"You may have the chance yet," replied Waynsford. He had been
thinking deeply for the last few moments. "I'm afraid I'm on the
wrong lay. Here I am, wearing His Majesty's uniform, fooling about
in a rotten little motor-boat, when I ought to be taking a man's part
out there," and he pointed towards the North Sea."
"You haven't done badly, when you come to think of it," remarked
Terence. "At Yarmouth, for instance."
"A beastly fluke. You, my dear fellow, had most of the game then."
"Buck up!" exclaimed Aubyn cheerily. "You may have a good sniff-in
yet. If you don't, remember there's some verse about people serving
who only sit and wait. I'm not fond of poetry myself, but perhaps
you may know the line I refer to. Let's make a move. There may be
more work for us amongst the ruins."
"May I coom along wi' tha', maaster?" asked the fisherman, who
was coiling away the rope that had been so instrumental. "Eh, lad,
thou'rt real champion."
"By all means," replied the sub. heartily. In spite of his years the
old fellow had his wits about him. If there should be any work of a
similar nature his assistance would be most valuable.
Before they had gone fifty yards the attention of Aubyn and his
party was attracted by the sudden appearance of an elderly
corpulent man whose garments consisted of a pyjama suit, over
which he wore a woman's jacket with the sleeves tied round his
throat, an old pair of carpet slippers and a felt hat. He had just
emerged from a cellar, into which he had bolted during the earlier
stages of the bombardment. Blinking like an owl he asked plaintively
if the danger was at an end.
"Ay," replied the old salt, with a grim twinkle in his eye. "Ay, that a'
did. Th' knows the Huns gave us a look up at a time when most
folks ought to be up an' about. Naw, get you gone, friend Thomas;
thou'rt not fit to be seen in a respectable town like Scarbro'."
Terence looked inquiringly at his humble friend, as the pyjama-clad
man waddled away.
"I knows him well. Always was trying to make us believe that those
Huns were our best friends, and that there weren't no use for a
British Navy. Th' knows t' sort. For one reason, sith'a, I'm not sorry
that those Germans came to Scarbro'."
CHAPTER XIV.
THE END OF THE "TERRIER"
It was blowing fairly fresh. Outside the bar the sea was foam-
flecked. Rollers came tumbling in, breaking heavily on shore or else
expending themselves harmlessly in the creek. At her anchorage the
torpedo-gunboat was pitching slightly to the heave of the open sea.
"Do you see any sign of the boat, Mr. Aubyn?" asked Captain
Holloway. "Those fellows ought to be on their way back by this
time."
Terence, who was officer of the watch, brought his glass to bear
upon the shore, where a cluster of red-tiled roofs, dominated by the
grey tower of a church, marked the position of the village—a
distance of about a mile and a half from where the "Terrier" lay.
Once more the sub. brought his telescope to bear upon the shore.
There were signs of activity on the part of the boat-keeper, so
Terence came to the conclusion that the hospital party were on their
way back.
A bugle blared. Ere the short notes of alarm had died away Captain
Holloway was beside his subordinate on the bridge. The guns' crews
of the two 4.7's sprang to their weapons. Clang went the breach-
blocks.
But a deadlier weapon was already on its way towards the doomed
ship. A torpedo, set at its minimum depth in order to make sure that
it would not pass under the keel of its intended prey, was tearing
towards the "Terrier" with the speed of an express train.
From his position on the bridge Terence watched its rapid progress.
He could do nothing beyond what he had already done. It was
evident that before the ship could swing on her cable, under the
adverse action of her twin propellers, until she was bows on to the
deadly missile, the torpedo would hit her.
The two 4.7's clashed almost simultaneously. The shell from her
bow gun, aimed at the now disappearing periscope of the hostile
submarine, missed it by a bare yard, and ricochetting, threw up five
distinct columns of spray ere it sunk for good and all.
"Stand clear there!" shouted the captain, seeing even in that tense
interval that several of the men were standing by the stanchions.
There was a general rush to the starboard side to avoid the direct
effect of the explosion of the "tin-fish," then a strange silence fell
upon the ship's company.
"Crash!"
The captain was capless. There was blood upon his forehead. A
splinter had grazed his head, making a clean superficial wound. The
two men exchanged reassuring glances, then in clear, steady tones
Captain Holloway issued an order for all hands to fall in on the
quarter-deck.
The men made their way aft at the double. There was no undue
scrambling or frantic haste, although the "Terrier's" raised fo'c'sle
was now almost flush with the water, and her after part, where the
freeboard was nominally only five feet, was thrice that height in the
air.
"Pass all injured men over the side," ordered Captain Holloway.
"The rest of you can make the best of your way ashore—and good
luck to you."
The crew gave three rousing cheers and prepared for the coming
ordeal, for although the distance to the shore was an easy swim the
bitter coldness of the water had to be taken into consideration.
One by one the wounded were passed into the boat; after them as
many men as she could safely hold. The boat was ordered to lie off
and render assistance to any swimmers in difficulties.
"With your permission, sir," said Aubyn, "I'll have a look down on
the mess-deck. There may be some of the hands left below."
"Do so, by all means, Mr. Aubyn," replied his superior. "The old
boat shows no great hurry."
"I fancy she's aground for'ard, sir," said the sub. "I'll be as sharp as
I can."
It was some time before the sub. grew accustomed to the semi-
gloom. His senses were still affected by the concussion; he could see
the water pouring in, but the noise it made was barely audible. The
situation reminded him of a cinematograph show unaccompanied by
a band.
"All clear as far as I can see," he thought. "It's about time I looked
after number one. Heavens! What is that?"
Just then Captain Holloway, having seen that the last of the
swimmers had reached the mud-fringed shore, remembered that the
sub. had gone below, and finding that he had not returned, hurried
to the companion.
"Found him below, sir," explained the sub. "Double fracture of the
leg and a nasty gash on his head."
"We'll soon have him out of it," remarked Captain Holloway. "The
gig's returning, and I see the whaler is coming up as hard as she
can."
He pointed to the boat which had taken the invalid to the sick-
quarters. Alarmed by the explosion and concluding that something
had befallen the ship, the ship's crew had bent to their oars with a
will, to find on drawing clear of the hard that the "Terrier" was on
the point of sinking.
The sub. felt himself shivering. The keen wind blowing against his
saturated nether garments reminded him that it was mid-winter. As
he stooped to wring the water out of the bottoms of his trousers he
realized that the unconscious stoker, who a few moments before had
been toiling in the hot stokehold, was now lying stripped to the
waist.
Removing his great-coat and muffler Terence slipped the garments
over the unfortunate man, just as the gig and the whaler came
alongside.
This time there were plenty of helpers. Carefully the stoker was
lowered into the whaler and placed in the stern-sheets.
"The old ship seems to be hanging on. We may as well have a look
below and see if there's anything of value in our cabins."
Bidding the gig lie off at a boat's length from the ship, which was
now tilted at such an angle that her propellers were clear of the
water, Captain Holloway, followed by Terence, disappeared down the
little companion just abaft the after 4.7-in. gun.
Being well aft Aubyn's cabin had escaped much of the force of the
explosion, but most of the loose gear had been displaced and lodged
in the angle formed by the sloping floor and bulkhead. Two
photographs in silver frames, their glasses smashed to atoms, lay on
the carpet in company with the sub.'s silver cigarette-case, his watch
and chain and a toilet-case—the latter a present from his
headmaster upon leaving school. That little heap represented
practically the whole of his worldly belongings in the way of luxuries:
he could have stowed the lot inside his sweater.
Up the companion raced the two officers. The ship was trembling
violently. Air bubbles, escaping through the submerged scuttles,
agitated the water alongside. The whole of the fore-part of the
"Terrier," as far as the base of the after funnel, was under the
waves. It was even a difficult matter to cross the deck from the
companion to the side.
The gig backed. Captain Holloway signed to the sub. to leap; then
giving a last look round he followed Aubyn into the boat.
"Lay on your oars, man," he ordered, after the gig had gone a
hundred yards from the sinking ship.
Raising his hand to the peak of his cap the captain gave his former
command a last salute, then resuming his seat, bade the men "give
way."
All the inhabitants of the village were on the shore ready to offer
hospitality to the crew, many of whom had discarded most of their
clothing before jumping from the ship. One petty officer, three able
seamen, and a stoker were missing—doubtless killed outright by the
explosion. Four men were seriously injured, while a score more were
suffering from wounds and shock.
CHAPTER XV.
VICE VERSÂ.
But she was disappointed. Deftly Mrs. Aubyn tore the envelope and
scanned the contents.
Not until the maid had closed the door did the old lady betray the
anguish that the telegram had caused.
The telegram was dispatched from Shotley Naval Hospital and bore
the signature of one of the medical officers.
She had read all the important news in the morning paper. There
had been no mention of a naval engagement, so there could be no
other explanation of how Terence received his injuries. She was
thankful indeed that she had not gone to Portsmouth for the day
with her sister. Thankful, also, that the said relative was not in the
house, for in contrast to the presence of mind displayed by Mrs.
Aubyn, Miss Wilson possessed a highly-strung temperament that
frequently expressed itself in hysterical outbursts.
Mrs. Aubyn consulted a time-table and then rang the bell.
"Jane," said the old lady in even tones, "I want you to run across
to Smith's and order a taxi to take me to the station at once, to
catch the 9.15 train."
It was close on four in the afternoon when the train steamed into
Harwich station. Making her way through crowds of bluejackets who
formed the bulk of the passengers, Mrs. Aubyn called a cab and
bade the man drive her to Shotley as quickly as possible.
"Shotley?" he repeated. "'Tis a long way. It'll cost you a quid, mum
—a sovereign. Couldn't do it for less."
"Not a penny less, mum," declared the man, stolidly. The old lady's
hand tightened on her purse. Her means were strictly limited. A
sovereign was to her a large sum. Yet, for her boy's sake——
She spoke bravely, laying emphasis upon her boy's rank. She felt
certain she could enlist the entire sympathy and aid of a brother-
officer, notwithstanding he was a post-captain.
"If you will allow me I will give you a passage in my gig," said the
naval officer. "It is only a short distance by water, but quite twenty
miles from here by land. I fancy that cabby knew you were a
stranger here. My name is O'Rourke—Captain O'Rourke."
Outside the station boys were selling the early evening papers.
Catching sight of the naval officer three or four of them made a rush
towards him.
Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.
textbookfull.com