Download full Computer Graphics Programming in OpenGL with Java Gordon ebook all chapters
Download full Computer Graphics Programming in OpenGL with Java Gordon ebook all chapters
com
https://textbookfull.com/product/computer-graphics-
programming-in-opengl-with-java-gordon/
OR CLICK BUTTON
DOWNLOAD NOW
https://textbookfull.com/product/computer-graphics-programming-in-
opengl-with-java-2nd-edition-v-scott-gordon/
textboxfull.com
https://textbookfull.com/product/computer-graphics-programming-in-
opengl-using-c-third-edition-gordon-phd/
textboxfull.com
https://textbookfull.com/product/introduction-to-computer-graphics-
with-opengl-es-first-edition-junghyun-han/
textboxfull.com
https://textbookfull.com/product/computer-graphics-through-opengl-
third-edition-guha/
textboxfull.com
Computer Graphics Through OpenGL: From Theory to
Experiments Sumanta Guha
https://textbookfull.com/product/computer-graphics-through-opengl-
from-theory-to-experiments-sumanta-guha/
textboxfull.com
https://textbookfull.com/product/learn-opengl-learn-modern-opengl-
graphics-programming-in-a-step-by-step-fashion-1st-edition-joey-de-
vries/
textboxfull.com
https://textbookfull.com/product/computer-graphics-for-java-
programmers-3rd-edition-leen-ammeraal/
textboxfull.com
https://textbookfull.com/product/opengl-programming-guide-the-
official-guide-to-learning-opengl-version-4-5-with-spir-v-9th-edition-
kessenich/
textboxfull.com
https://textbookfull.com/product/learning-java-an-introduction-to-
real-world-programming-with-java-marc-loy/
textboxfull.com
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
info@merclearning.com.
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 info@merclearning.com.
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
About the Authors
Dr. V. Scott Gordon has been a professor in the California State University system for
over twenty years, and currently teaches advanced graphics and game engineering courses
at CSU Sacramento. He has authored or coauthored over thirty publications in a variety
of areas including video and strategy game programming, artificial intelligence, neural net-
works, software engineering, and computer science education. Dr. Gordon obtained his PhD
at Colorado State University. He is also a jazz drummer and a competitive table tennis player.
Dr. John Clevenger has over forty years of experience teaching a wide variety of courses
including advanced graphics, game architecture, operating systems, VLSI chip design,
system simulation, and other topics. He is the developer of several software frameworks
and tools for teaching graphics and game architecture, including the graphicslib3D library
used in this textbook. He is the technical director of the ACM International Collegiate
Programming Contest, and oversees the ongoing development of PC^2, the most widely
used programming contest support system in the world. Dr. Clevenger obtained his PhD
at the University of California, Davis. He is also a performing jazz musician, and spends
summer vacations in his mountain cabin.
References
[AS14] E. Angel, and D. Shreiner, Interactive Computer Graphics: A Top-Down
Approach with WebGL, 7th ed. (Pearson, 2014).
[LW16] Lightweight Java Game Library (LWJGL), accessed July 2016, https://www.
lwjgl.org/.
[LU16] F. Luna, Introduction to 3D Game Programming with DirectX 12, 2nd ed.
(Mercury Learning, 2016).
[WO13] D. Wolff, OpenGL Shading Language Cookbook, 2nd ed. (Packt Publishing, 2013).
xvi ■ Pr e f a c e
C hapter 1
GettinG started
1.1 Languages and Libraries. . . . . . . . . . . . . . . . . . . . . . . . . . .1
1.2 Installation and Configuration . . . . . . . . . . . . . . . . . . . . . .3
■ ■ ■■■
Graphics programming has a reputation of being among the most challeng-
ing computer science topics to learn. These days, graphics programming is shader
based—that is, some of the program is written in a standard language such as Java
or C++ for running on the CPU, and some is written in a special-purpose shader
language for running directly on the graphics card (GPU). Shader programming has
a steep learning curve, so that even drawing something simple requires a convoluted
set of steps to pass graphics data down a “pipeline.” Modern graphics cards are able
to process this data in parallel, and so the graphics programmer must understand the
parallel architecture of the GPU, even when drawing simple shapes.
The payoff, however, is extraordinary power. The blossoming of stunning virtual
reality in videogames and increasingly realistic effects in Hollywood movies can be
greatly attributed to advances in shader programming. If reading this book is your
entrée into 3D graphics, you are taking on a personal challenge that will reward you
not only with pretty pictures, but with a level of control over your machine that you
never imagined was possible. Welcome to the exciting world of computer graphics!
• Java
• OpenGL / GLSL
• JOGL
• graphicslib3D
2 ■ C o m p uter G rap h ics P ro g ram min g in O pe nG L w ith J a va
It is likely that the reader will need to do a few preparatory steps to ensure that
each of these are installed and properly accessible on his/her system. In this sec-
tion we briefly describe each of them. Then in the following section we show how
to install and/or configure them for use.
1.1.1 Java
Java was developed at Sun Microsystems in the early 1990s, and the first
stable release of a development kit (JDK) was in 1995. In 2010, Oracle Corp. ac-
quired Sun, and has maintained Java since that time [OR16]. This book assumes
Java version 8, which was released in 2014.
1
Despite this, many graphics card manufacturers (notably NVIDIA) continue to support
deprecated functionality.
C ha pte r 1 · G e tting Sta rte d ■ 3
1.1.3 JOGL
JOGL first appeared in 2003, published on the website Java.net. Since 2010
it has been an independent open source project, and part of a suite of Java bind-
ings maintained by JogAmp [JO15], an online community of developers. JogAmp
also maintains JOAL and JOCL, bindings for OpenAL and OpenCL, respectively.
As new versions of OpenGL and/or Java are released, new versions of JOGL are
developed to support continued compatibility. JogAmp also maintains a short
online user’s guide that includes valuable guidelines for installing and using JOGL
efficiently and effectively [JU16]. This book assumes at least version 2.3 of JOGL.
1.1.4 graphicslib3D
3D graphics programming makes heavy use of vector and matrix algebra.
For this reason, use of OpenGL is greatly facilitated by accompanying it with
a function library or class package to support common mathematical functions.
For example, the popular OpenGL Superbible [SW15] utilizes a C library called
“vecmath”. In this book, we use a Java library called graphicslib3D.
graphicslib3D provides classes for basic math functions related to graphics con-
cepts, such as vector, matrix, point, vertex, and quaternion. It also contains a few
utility classes for storing frequently used 3D graphics structures, such as a stack
for building hierarchical structures, lighting and material information, and a few
basic shapes such as a sphere and a torus.
graphicslib3D was first developed in 2005 by John Clevenger at California State
University Sacramento, and is maintained by the authors.
jogamp-all-platforms.7z
jogl-javadoc.7z
Unzip these files into the folder on your machine where you would like to
store the JOGL system. A typical location in Windows could be, for example, in a
folder at the root of the C: drive.
The unzipped “jogamp-all-platforms” file contains a folder named “jar”, which
contains two important files that will be used by your applications:
jogl-all.jar
gluegen-rt.jar
Add the full path name of each of these two files to your CLASSPATH environ-
ment variable.
In the jogl-javadoc folder, double-click the file named index.html. This opens the
JOGL javadocs in a browser, which you should then bookmark.
References
[GV16] GLView, realtech-vr, accessed July 2016, http://www.realtech-vr.com/
glview/.
[JO16] Jogamp, accessed July 2016, http://jogamp.org/.
[JU16] JOGL Users Guide, accessed July 2016, https://jogamp.org/jogl/doc/
userguide/.
[OR16] Java Software, Oracle Corp., accessed July 2016, https://www.oracle.com/
java/index.html.
[SW15] G. Sellers, R. Wright Jr., and N. Haemel, OpenGL SuperBible:
Comprehensive Tutorial and Reference, 7th ed. (Addison-Wesley, 2015).
C hapter 2
JoGL and the openGL
GraphiCs pipeLine
■ ■ ■■■
OpenGL (Open Graphics Library) is a multi-platform 2D and 3D graphics API
that incorporates both hardware and software. Using OpenGL requires a graphics
card (GPU) that supports a sufficiently up-to-date version of OpenGL (as described
in Chapter 1).
On the hardware side, OpenGL provides a multi-stage graphics pipeline that is
partially programmable using a language called GLSL (OpenGL Shading Language).
On the software side, OpenGL’s API is written in C, and thus the calls are directly
compatible with C and C++. However, stable language bindings (or “wrappers”) are
available for more than a dozen other popular languages (Java, Perl, Python, Visual
Basic, Delphi, Haskell, Lisp, Ruby, etc.) with virtually equivalent performance. This
textbook uses the popular Java wrapper JOGL (Java OpenGL). When using JOGL,
the programmer writes a Java program that runs on the CPU (more specifically, on
the Java Virtual Machine, or JVM) and includes JOGL (and thus, OpenGL) calls. We
will refer to a Java program that contains JOGL calls as a Java/JOGL application.
One important task of a Java/JOGL application is to install the programmer’s GLSL
code onto the GPU.
8 ■ C o m p uter G rap h ics P ro g ram min g in O pe nG L w ith J a va
An overview of a JOGL-based
graphics application is shown in Fig-
ure 2.1, with the software components
highlighted in red:
Some of the code we will write
will be in Java, with JOGL calls, and
some will be written in GLSL. Our
Java/JOGL application will work to-
gether with our GLSL modules, and
the hardware, to create our 3D graph-
ics output. Once our application is
Figure 2.1 complete, the end user will interact
Overview of a JOGL-based graphics application. with the Java application.
GLSL is an example of a shader language. Shader languages are intended
to run on a GPU, in the context of a graphics pipeline. There are other shader
languages, such as HLSL, which works with Microsoft’s 3D framework DirectX.
GLSL is the specific shader language that is compatible with OpenGL, and thus
we will write shader code in GLSL, in addition to our Java/JOGL application code.
For the rest of this chapter, we will take a brief “tour” of the OpenGL pipeline.
The reader is not expected to understand every detail thoroughly, but just to get a
feel for how the stages work together.
1. It uses Java to obtain the GLSL code, either from text files or hardcoded
as strings.
Ch ap ter 2 · J O G L and the O pe nG L G ra phic s Pipe line ■ 9
Figure 2.3
The mechanism by which these functions
Output of Program 2-1. are deployed is as follows: When a GLCanvas
Ch ap ter 2 · J O G L and the O pe nG L G ra phic s Pipe line ■ 11
is made “visible” (by our calling “setVisible(true)” on the JFrame that contains it), it
initializes OpenGL, which in turn creates a “GL4” object that our application can use
for making OpenGL function calls. OpenGL then does a “callback,” calling init(),
and passes it a “drawable” object (in this case the drawable object is the GLCanvas,
although that isn’t obvious from the code). In this particular example, init() doesn’t
do anything—in most applications it is where we would read in GLSL code, load 3D
models, and so on. OpenGL next calls display(), also sending it the drawable object.
It is typical to immediately obtain the GL4 object and put it in a variable called “gl”.
(Actually, GL4 is an interface—in practice we don’t need to know the actual GL ob-
ject class).
Later we will see that if we want our scene to be animated, our Java/JOGL ap-
plication will need to tell OpenGL to make additional calls to display().
Now is an appropriate time to take a closer look at JOGL calls in Program 2.1.
Consider this one:
gl.glClearBufferfv(GL_COLOR, 0, bkgBuffer);
Since JOGL is a Java binding for OpenGL, that means that calls to JOGL in
turn generate calls to OpenGL’s library of C functions. In this case, the C function
being called, as described in the OpenGL reference documentation (available on
the web at https://www.opengl.org/sdk/docs) is:
The first thing to notice is that the name of the JOGL function is the same as
that of the original OpenGL C function, except it is preceded by “gl.”, which is the
name of the GL4 object. The period “.” after the “gl” is significant because “gl” is
the object on which we are invoking the OpenGL function.
To reiterate, GL4 is a Java interface to the OpenGL functions. We can obtain
it in one of two ways: (a) by calling drawable.getGL(), utilizing the “GLAutoDraw-
able” object provided automatically when the various GLEventListener functions
are invoked (called back) by OpenGL, or (b) by calling GLContext.getCurrentGL()
as done in Program 2.1. Obtaining the current GL4 object is important because,
in general, any OpenGL function described in the OpenGL documentation can
be called from JOGL by preceding it with the name of the appropriate GL4 object
(such as “gl.”, here).
The next detail to notice is that the first parameter makes reference to a “GLenum”.
OpenGL has many predefined constants (enums); this one references the color buffer
GL_COLOR that contains the pixels as they are rendered. In actuality, there is more
12 ■ C o m p uter G rap h ics P ro g ram min g i n O pe nG L w ith J a va
than one color buffer, and the second parameter is used to specify which one we are
using (in this case, the 0th or first one).
Next, notice that the third parameter is defined in OpenGL as a C pointer.
While JOGL makes every effort to match the original OpenGL C calls, Java does
not have pointers. Any parameter in OpenGL that is a pointer is changed in JOGL.
In this case, the JOGL version utilizes a FloatBuffer instead. Whenever there is a
discrepancy between a JOGL call and the original C call, consult the JOGL Java-
doc for details on the revised parameter(s).1
Immediately before the call to glClearBufferfv() is a call to newDirectFloatBuffer().
We will learn about this function later in Chapter 4 when we discuss buffers and
the JOGL buffer tools.
Finally, besides display() and init(), we also must implement reshape() and
dispose(). The reshape() function is called when a GLCanvas is resized, and dispose()
is called when the application exits. In Program 2.1 we left them both empty.
1
In this example, we have described each parameter in the call. However, as the book proceeds,
we will sometimes not bother describing a parameter when we believe that doing so would
complicate matters unnecessarily. The reader should get used to using the JOGL/OpenGL
documentation to fill in such details as necessary.
Other documents randomly have
different content
miekkailua kuin sinä päivänä näin linnan pihalla.»
Mutta vasta nyt, kun hän tunsi saaneensa selville syyn, minkä
tähden hän aina ratsasti kypärinsilmikko suljettuna, halusi hän itse
kiihkeästi piilottaa kasvonsa muiden ihmisten näkyvistä — ei pelosta,
sillä pelkoa hän ei tuntenut, vaan jonkin sisäisen mielijohteen
pakotuksesta, jota hän ei koettanutkaan käsittää.
KAHDEKSAS LUKU
»Niinpä kyllä», virkkoi pappi, »näin hänet sinä päivänä. Hänellä oli
seikkailu useiden Peter of Colfaxin linnan ritarien kanssa, ja hän
pelasti heidän käsistään erään neidon, jonka ratsun koristeiden
nojalla epäilin kuuluvan Montfortin sukuun. Yhdessä he lähtivät
ratsastamaan pohjoista kohti, mutta poikani ei maininnut, mihin hän
aikoi ja missä tarkoituksessa. Hänen ainoa huomautuksensa, kun
hän puki ylleen sota-asunsa, oli se, että nyt saisin nähdä haukan
hoivaamassa kyyhkystä. Eikö hän ole palannut?»
»Ja siellä hän kenties olisi paremmin kotonaan kuin täällä», virkkoi
pappi tyynesti.
Kohta sen jälkeen, kun hän oli saapunut asunnolleen, kajahti kova
koputus oveen, joka heti aukaistiin odottamatta muodollista lupaa.
Isä Claude katsahti sinnepäin, näki Norman of Tornin kookkaan
hahmon, ja hänen kasvoilleen levisi iloisen tyytyväinen
tervehdyshymy.
»No, no, isä», torjui henkipatto. »Mitä olen tehnyt sellaista, mihin
ylimykset, kuningas ja pyhä kirkko eivät ole näyttäneet minulle
hyvää esimerkkiä. Murhia, varkauksia, ryöstöjä! Kuluuko Englannissa
ainoatakaan päivää, jona ei tehtäisi näistä jotakuta tai kaikkia
joidenkuiden näiden nimessä?
»Jos tämä hurja vintiö osuisi tielleni, olisi parempi, että uhrattaisiin
viisi kuin viisikymmentä miestä, sillä kumpikin lukumäärä olisi ihan
mitätön tuota hirttämättömien murhamiesten kammottavaa laumaa
vastaan. Niin, Mary; minä lähden huomenna, ja teidän kelpo
soturinne palaavat seuraavana päivänä, tuoden minulta mitä parhaat
terveiset.»
»Jos sinä tahdot, niin tahdot», kivahti Mary nenäkkäästi. »Ihan
kouraan jo tuntuu, että olet de Montfort-sukua, jonka peritty
urhoollisuus jää jälkeen ainoastaan sen peritystä itsepäisyydestä.»
*****
»Eikö riitä se, että tarjoudun auttamaan teitä, sir Peter», kysyi
hän, »koska teidän täytyy saada tietää, minkä tähden sen teen?
Uskokaa, että vihani Leicesteriä kohtaan on minua kannustava
intohimo. Yrityksesi ryöstää tyttö meni myttyyn; jos annat mukaani
kymmenen sotilasta, tuon hänet sinulle.»
»Kyllä, mylord.»
»Kyllä, mylord.»
*****
»Nyt jo olen ollut kolme päivää yli ajastani, enkä edes minä, tytär,
saa noin vain olla tottelematta Simon de Montfortia. Näinkin on
minulla kylliksi vastattavaa. Älä vaadi minua enää lisäämään
päivääkään anteeksi pyydettäväkseni! Ja sitäpaitsi saattavat äitini ja
isäni olla hyvin levottomia jatkuvan poissaoloni tähden. Ei, Mary;
minun täytyy lähteä tänään.» Ja sen hän teki saattajinaan viisi
miestä, jotka linnan puolustusväestä voitiin luovuttaa.
Noin kolmen kilometrin päässä siitä paikasta, jossa valkea ratsu oli
kohdattu, he näkivät niiden viiden palvelijan ruumiit, jotka olivat
olleet saattamassa Bertradea Stutevillista.
Hänen vilkas katseensa oli osoittanut hänelle, että huone oli ihan
tyhjä ja että sen alapäässä olevan pääoven lisäksi, josta hän oli
tullut, sieltä vei ainoastaan yksi toinen ovi. Se oli sivuseinällä, ja kun
se oli raollaan, näki hän sen vievän pieneen huoneeseen, nähtävästi
makuukammioon.
Hänen seisoessaan kasvot pääoveen päin avautui seinälaudoitus
meluttomasti hänen takanaan, aivan sen paikan kohdalla, jossa
valtaistuimet olivat olleet menneinä aikoina. Aukon tummasta suusta
astui esiin Peter of Colfax. Hän sulki laudoituksen hiljaa jälkeensä ja
eteni tyttöä kohti äänettömin askelin. Korokkeen reunalle
saavuttuaan hän seisahtui, kalisuttaen miekkaansa herättääkseen
Bertraden huomiota.
Jos hän vain saisi vanhan naisen pois huoneesta, aprikoi Bertrade,
voisi hän huonekaluilla teljetä oven sisältäpäin ja siten ainakin
viivyttää uhkaavaa kohtaloaan siinä toivossa, että apua joltakin
taholta tulisi. Mutta hänen ovelimmatkin juonensa osoittautuivat
tehottomiksi pystymättä edes hetkeksikään vapauttamaan häntä
harpyijamaisesta vanginvartijastaan; ja kun lopullinen kutsu oli tullut,
oli hän suunniltaan, koska hänellä ei ollut mitään keinoa tehdäkseen
tyhjiksi ryöstäjänsä aikeet.
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