Computer Graphics Programming in OpenGL With Java 3rd Edition V. Scott Gordon Download
Computer Graphics Programming in OpenGL With Java 3rd Edition V. Scott Gordon Download
https://ebookmeta.com/product/computer-graphics-programming-in-
opengl-with-java-3rd-edition-v-scott-gordon/
https://ebookmeta.com/product/computer-graphics-programming-in-
opengl-with-c-2nd-edition-v-scott-gordon/
https://ebookmeta.com/product/introduction-to-computer-graphics-
using-opengl-and-java-3rd-edition-karsten-lehn/
https://ebookmeta.com/product/developing-graphics-frameworks-
with-java-and-opengl-1st-edition-lee-stemkoski/
https://ebookmeta.com/product/engaged-learners-and-digital-
citizens-critical-outcomes-for-teaching-and-learning-1st-edition-
brad-garner/
The Spy Whisperer 1st Edition Matthew Dunn
https://ebookmeta.com/product/the-spy-whisperer-1st-edition-
matthew-dunn/
https://ebookmeta.com/product/case-files-family-medicine-4e-4th-
edition-donald-briscoe/
https://ebookmeta.com/product/advanced-therapeutics-in-pain-
medicine-first-edition-sahar-swidan/
https://ebookmeta.com/product/gingerbear-christmas-howls-romance-
howliday-special-1st-edition-reina-torres-torres-reina/
https://ebookmeta.com/product/resonating-system-what-to-perceive-
so-you-can-receive-resonation-realm-book-1-2nd-edition-rinzen-
joye/
Beaded By Midnight A curvy girl and brother s best
friend romance 1st Edition Eve London
https://ebookmeta.com/product/beaded-by-midnight-a-curvy-girl-
and-brother-s-best-friend-romance-1st-edition-eve-london/
Computer Graphics
Programming in OpenGL
with Java
Third Edition
By purchasing or using this book and its companion files (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 author, 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 disc 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 files are available for download from the publisher by writing to
[email protected].
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
scanning, 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.academiccourseware.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.
Index 505
One of the things 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, progress-
ing 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.
This book teaches OpenGL programming in Java, using JOGL—a Java “wrapper”
for OpenGL’s native C calls [JO21]. 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
• Installation and setup is easier in Java than for C or C++
• 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
• JOGL includes some very nice tools, such as for loading textures, animation
loops, etc.
It is worth mentioning that there do exist other Java bindings for OpenGL. One that
has become very popular is Lightweight Java Game Library, or LWJGL [LW21]. Like
JOGL, LWJGL also offers bindings for OpenAL and OpenCL. This textbook focuses
only on JOGL.
Another thing that makes this book unique is that it has a “sister” textbook: Computer
Graphics Programming in OpenGL with C++, Second Edition. The two books are orga-
nized in lockstep, with the same chapter and section numbers and topics, figures, exer-
cises, and theoretical descriptions. Wherever possible, the code is organized similarly.
Of course, the use of Java versus C++ leads to considerable programming differences
(although all of the shader code is identical). Still, we believe that we have provided vir-
tually identical learning paths, even allowing a student to choose either option within a
single classroom.
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 Edge, 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
1 JavaScript is a scripting language that can be used to embed code in web pages. It has strong
similarities to Java, but also many important differences.
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 because 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.
For years our own students have repeatedly expressed an interest in simulating water.
However, water takes so many forms that writing an introductory section on the topic is
challenging. Ultimately, we decided to present water in a way that would complement
related topics in the book such as terrain, sky, etc., and so in Chapter 15 we focus on utiliz-
ing our noise maps from Chapter 14 to generate water surfaces such as are seen in lakes
and oceans.
As a result of these additions, this 3rd edition is larger than the previous edition.
Besides the new material, there are important revisions throughout the book. For
example, we fixed bugs in our Torus class in Chapter 6, and made significant improve-
ments to our noise map functions in Chapter 14. Another small, but important, modifica-
tion was to change all of our lighting computations so that they are done in world space
rather than in camera space – this makes it easier to develop applications that require
being able to move the camera around. We also expanded our Utils.java utility class to
handle the loading of compute shaders.
There are dozens of small changes in every chapter that the reader might not even
notice: fixing typos, cleaning up code inconsistencies, updating the installation instruc-
tions, making slight wording changes, sprucing up figures, updating references, etc.
Completely eliminating typos is virtually impossible in a book that covers an ever-chang-
ing technology-rich topic, but we have attempted it.
Intended Audience
This book is targeted at students of computer science. This could mean undergraduates
pursuing 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
• basic data structures and algorithms, such as linked lists, stacks and queues, etc.
• recursion
• event-driven programming concepts
• basic matrix algebra and trigonometry
• basic analytic geometry, such as for defining points, lines, vectors, planes, and circles
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 pro-
vided 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 exercises 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.
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 in the early chapters 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. The reader should bookmark them for easy
After the death of the elder Audubon, his sons, under the
leadership of Bachman, continued the work on the Quadrupeds until
the third and last volume of the letterpress was completed in 1852.
On March 13 of that year Bachman wrote to Edward Harris:[229]
When this larger venture failed, one of the publishers, who was
not satisfied with the surplusage of books and plates left on his
hands, is said to have placed encumbrances upon the Audubon
estate. At about this time John W. Audubon's health broke down;
"Worn out," as his daughter has said,[237] "in body and spirit,
overburdened with anxieties, saddened by the condition of his
country, it is no matter of surprise that my father could not throw off
a heavy cold which attacked him early in 1862." He died at the age
of forty-nine, on the 18th of February of that year.
Mrs. John James Audubon was very active in body and mind for
a long period after her husband's death, and in 1857, when in her
seventieth year, she returned in a degree to her old vocation of
school teaching, which had been so successfully followed in Ohio
and Louisiana when her husband was on the threshold of his
extraordinary career. Her pupils now consisted of some of her
numerous grandchildren and a few others drawn from the
neighborhood; among the latter was the well known writer and
father of the original Audubon Society, George Bird Grinnell, who
pointed out to me the room in Victor Audubon's old house where his
revered and venerable teacher had gathered her little flock. "She
loved to read, to study, and to teach," said one who had known her,
and "she knew how to gain the attention of the young, and to fix
knowledge in their minds. 'If I can hold the mind of a child to a
subject for five minutes, he will never forget what I teach him,' she
once remarked; and, acting upon this principle, she was as
successful, at three score and ten years, in imparting knowledge, as
she had been in early life when she taught in Louisiana."
After Mrs. Audubon had passed her eightieth year she left New
York and again made her home in the West. In 1874, when with a
granddaughter at Louisville, she dictated and signed the following
letter to a gentleman who had asked for an autograph of her
husband:
Mrs. Audubon to William R. Dorlan
Dear Sir
The enclosed, the best I have to send you is one from which
the autograph and a portion of the letter were cut off many
years ago.
I am dear Sir
Yours respectfully,
Lucy Audubon
It was thought possible that some of these plates had been sold
in New York City before the bulk of them were condemned as junk
and sent to Connecticut, but in 1898 Mr. Deane was able to give the
designation and resting place of only thirty-seven;[248] among these,
however, were the Wild Turkeys, Canada Goose, Great Northern
Diver, Raven, American Robin, and Ruby-throated Hummingbird, all
among the finest of the original 435.
The three houses which were built and occupied by the great
nature lover and his two sons, though in dire neglect, are not
beyond repair; if such a project were practicable, they should be
converted into a museum, and their walls once more ornamented
with those beautiful pictures of birds and beasts which father and
sons united to create. The triangle of ground between Riverside
Drive and the Hudson River should be spared by the proud city that
for years was the home of America's pioneer naturalist and animal
painter, as well as the scene of his youthful experiments in trade,
and converted into a true "Audubon Park." Such a memorial would
contribute to the instruction and pleasure of all the people, for every
generation of Americans that is to come.
APPENDICES
APPENDIX I
Original Documents
. Copy of the original bill rendered by Doctor Sanson, physician at Les
Cayes, Santo Domingo, to Jean Audubon, containing the only record
known to exist of the birth of his son, Jean Jacques Fougère Audubon
(see entry for April 26, 1785). Les Cayes, December 29, 1783-October
19, 1785; paid, June 7, 1787.
SAVOIR
|
L
1783 Xbre " 29 ipecacuanha pour un
" nègre Bossal " 6""
" 31 ipecacuanha pour un
" nègre Bossal " 6""
1784 janvier " 3 une medecine pour
" un nègre Bossal " 6""
" 5 une medecine pour
" un nègre Bossal " 6""
" 7 une medecine pour
" un nègre Bossal " 6""
" 9 une medecine pour
" un Bossal " 6""
" 10 une medecine pour
" un Bossal " 6""
" 14 une medecine pour le
" mulâtre joue " 6""
" 26 une medecine pour 10 "
" Mr Audubon " "
mars " 27 inoculé cezard 30 "
" inoculé jupiter 30 90 "
inoculé Rose 30 " " "
avril " 1 apozême purgatif
" pour joue mulâtre " 6""
" 3 une medecine pour le
" mulâtre joue " 6""
" 8 apozême purgatif
" pour le nègre
Dominique " 6""
" 10 une medecine pour
" Dominique " 6""
" 15 une medecine pour
" Zemire " 6""
" 20 une medecine pour
" Rose " 6""
" apozême purgatif
pour jupiter " 6""
" 21 une medecine pour
" Dominique " 6""
may " 2 une medecine pour la
" negresse therese " 6""
" 11 pour soins, visites et
" remedes pendant
la petite verole du 66 "
mulâtre joue " "
" 21 Liqueur minerale
" d'hoffman pour
mlle. Rabin " 6""
juin " 20 inoculé un petit nègre 30 "
" Bossal nommé joue " "
juillet " 20 Remis a mr audubon
" le compte du
traitement de la
galle de marianne
et de sa fille, tout 36 "
acquité " "
7bre " 14 apozême purgatif
" pour le nègre jean
maçon " 6""
" 16 une medecine pour
" jean maçon " 6""
" 21 saigné au bras mr
" audubon " 3""
" 23 eau de tamarinds
" compee. pour mr 10 "
Audubon " "
" 24 une medecine en
" deux Dozes pour 10 "
mr audubon " "
8bre. " 22 une medecine pour le
" negrillon joue " 6""
" 23 traité soigné et fourni
" le medicament a
joue attaqué de 132 "
piano " "
513 "
L "
[Page 2]