Skip to content

Commit a39aa83

Browse files
committed
Finished lines chapter (9)
1 parent 12405ec commit a39aa83

28 files changed

+2189
-391
lines changed

01-preface.rst

+9-9
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,11 @@ Preface
99

1010
This book is open-access (i.e. it's free to read at `this address
1111
<http://www.labri.fr/perso/nrougier/python+opengl>`_) because I believe
12-
knowledge should be free. However, *if you think the book is worth a few
13-
dollars* (`5€ <https://www.paypal.me/NicolasPRougier/5>`_ or `10€
14-
<https://www.paypal.me/NicolasPRougier/10>`_), you can use `Paypal
15-
<https://www.paypal.me/NicolasPRougier/>`_ to make payment. This money will
16-
help me to travel to Python conferences and to write other books as well. If
17-
you don't have money, it's fine. Just enjoy the book and spread the
18-
word about it. The teaser image above comes from the `artwork section
12+
knowledge should be free. However, if you think the book is worth a few
13+
dollars, you can `Buy the book`_. This money will help me to travel to Python
14+
conferences and to write other books as well. If you don't have money, it's
15+
fine. Just enjoy the book and spread the word about it. The teaser image above
16+
comes from the `artwork section
1917
<http://www.labri.fr/perso/nrougier/artwork/index.html>`_ of my website. It has
2018
been made some years ago using the `Povray <http://www.povray.org>`_
2119
(Persistence of Vision) raytracer. I like it very much because it is a kind of
@@ -184,8 +182,10 @@ As you may have realized by now, the book is free for you to read
184182
online. However, some people prefer to have a PDF version or even a dead-tree
185183
version. For this to happen, I need to design a latex template for producing a
186184
nice PDF. That's a lot of work and I don't really have time since I'm also (and
187-
mainly) a researcher with several students to supervise, researches to do,
188-
grants to write, talks to prepare, etc.
185+
mainly) a `researcher
186+
<http://www.labri.fr/perso/nrougier/research/index.html>`_ with several
187+
students to supervise, researches to do, articles and grants to write, talks to
188+
prepare, etc.
189189

190190
Consequently, if you really want to have a PDF version, you'll have to
191191
explicitly express your interest by contributing a small amount of

03-quickstart.rst

+37-34
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Quickstart
1+
Quickstart
22
===============================================================================
33

44
.. contents:: .
@@ -12,9 +12,9 @@ For the **really** impatient, you can try to run the code in the `teaser image
1212
open on your desktop with a red color in the background. If you now want to
1313
understand how this works, you'll have to read the text below.
1414

15-
16-
Preliminaries
17-
-------------
15+
16+
Preliminaries
17+
-------------------------------------------------------------------------------
1818

1919
The main difficulty for newcomers in programming modern OpenGL is that it
2020
requires to underdtand a lot of different concepts at once and then, to perform
@@ -25,8 +25,8 @@ first OpenGL program using the raw interface and our goal is to display a
2525
simple colored quad (i.e. a red square).
2626

2727

28-
Normalize Device Coordinates
29-
++++++++++++++++++++++++++++
28+
Normalize Device Coordinates
29+
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
3030

3131
.. figure:: images/chapter-03/NDC.png
3232
:figwidth: 40%
@@ -53,8 +53,8 @@ some problems, especially when you're dealing with the mouse pointer whose
5353
**y** coordinate goes this other way around.
5454

5555

56-
Triangulation
57-
+++++++++++++
56+
Triangulation
57+
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
5858

5959
.. figure:: images/chapter-03/triangulation.png
6060
:figwidth: 35%
@@ -98,8 +98,8 @@ Our quad can now be using triangle `(V₀,V₁,V₂)` and triangle `(V₁,V₂,V
9898
is exactly what we need to tell OpenGL.
9999

100100

101-
GL Primitives
102-
+++++++++++++
101+
GL Primitives
102+
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
103103

104104
.. figure:: images/chapter-03/gl-primitives.png
105105
:figwidth: 40%
@@ -136,8 +136,8 @@ because we took care of describing the two triangles following this implicit
136136
structure.
137137

138138

139-
Interpolation
140-
+++++++++++++
139+
Interpolation
140+
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
141141

142142
.. figure:: images/chapter-03/interpolation.png
143143
:figwidth: 40%
@@ -186,8 +186,8 @@ shader. And this property will be used and abused in this book.
186186

187187

188188

189-
The hard way
190-
------------
189+
The hard way
190+
-------------------------------------------------------------------------------
191191

192192
Having reviewed some important OpenGL concepts, it's time to code our quad
193193
example. But, before even using OpenGL, we need to open a window with a valid GL
@@ -240,8 +240,8 @@ simple case, we just ask OpenGL to swap buffers (this avoids flickering).
240240
Finally, the keyboard callback allows us to exit by pressing the `Escape` key.
241241

242242

243-
Writing shaders
244-
+++++++++++++++
243+
Writing shaders
244+
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
245245

246246
Now that your window has been created, we can start writing our program, that
247247
is, we need to write a vertex and a fragment shader. For the vertex shader, the
@@ -289,8 +289,8 @@ notation. `1.0` for alpha channel means fully opaque.
289289
}
290290
291291
292-
Compiling the program
293-
+++++++++++++++++++++
292+
Compiling the program
293+
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
294294

295295
We wrote our shader and we need now to build a program that will link the
296296
vertex and the fragment shader together. Building such program is relatively
@@ -364,8 +364,8 @@ because we'll use a single program in this example:
364364
gl.glUseProgram(program)
365365
366366
367-
Uploading data to the GPU
368-
+++++++++++++++++++++++++
367+
Uploading data to the GPU
368+
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
369369

370370
Next, we need to build CPU data and the corresponding GPU buffer that will hold
371371
a copy of the CPU data (GPU cannot access CPU memory). In Python, things are
@@ -440,8 +440,9 @@ Let's now fill our CPU data and upload it to the newly created GPU buffer:
440440
gl.glBufferData(gl.GL_ARRAY_BUFFER, data.nbytes, data, gl.GL_DYNAMIC_DRAW)
441441
442442
443-
Rendering
444-
+++++++++
443+
444+
Rendering
445+
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
445446

446447
We're done, we can now rewrite the display function:
447448

@@ -474,8 +475,9 @@ numpy. Of course, you can design your own library to ease the writing of GL
474475
Python applications.
475476

476477

477-
Uniform color
478-
+++++++++++++
478+
479+
Uniform color
480+
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
479481

480482
.. figure:: images/chapter-03/glumpy-quad-uniform-color.png
481483
:figwidth: 30%
@@ -516,8 +518,9 @@ If you run the new `<code/glut-quad-uniform-color.py>`_ example, you should
516518
obtain the blue quad as shown on the right.
517519

518520

519-
Varying color
520-
+++++++++++++
521+
522+
Varying color
523+
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
521524

522525

523526
.. figure:: images/chapter-03/glumpy-quad-varying-color.png
@@ -612,8 +615,8 @@ thanks to NumPy:
612615
613616
614617
615-
The easy way
616-
------------
618+
The easy way
619+
-------------------------------------------------------------------------------
617620

618621
As we've seen in the previous section, displaying a simple quad using modern GL
619622
is quite tedious and requires a fair number of operations and this why from now
@@ -716,8 +719,8 @@ program.
716719
`<code/chapter-03/quad-glumpy.py>`_
717720
718721

719-
Uniform color
720-
+++++++++++++
722+
Uniform color
723+
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
721724

722725
Adding a `uniform` specified color like is only a matter of modifying the
723726
fragment shader as in the previous section an directly assigning the color to
@@ -729,8 +732,8 @@ the quad program (see `<code/chapter-03/glumpy-quad-uniform-color.py>`_):
729732
730733
731734
732-
Varying color
733-
+++++++++++++
735+
Varying color
736+
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
734737

735738
Adding a per-vertex color like is also and only a matter of modifying the
736739
fragment shader as in the previous section an directly assigning the color to
@@ -794,8 +797,8 @@ the quad program (see `<code/chapter-03/glumpy-quad-varying-color.py>`_):
794797
795798
796799
797-
Exercises
798-
---------
800+
Exercises
801+
-------------------------------------------------------------------------------
799802

800803
Now we can play a bit with the shader and hopefully you'll understand why
801804
learning to program the dynamic graphic pipeline is worth the effort. Modifying

08-markers.rst

+10
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,16 @@ Rendering markers
77
:class: toc chapter-08
88

99

10+
Markers and arrows are important components in scientific visualisation.
11+
Markers help to visualize individual points and aggregated data while arrows
12+
can be used to visualize a stream flow. Markers and arrows can be actually
13+
rendered very fast by taking advantage of the shader. In fact, they can be
14+
drawn entirely inside the shader provided we know the size, the type and the
15+
orientation. The teaser figure comes from an `article
16+
<http://jcgt.org/published/0003/04/01/>`_ I wrote and published in the journal
17+
of Computer Graphics and Techniques. The content of this chapter is largely
18+
inspired by this article.
19+
1020

1121
Constructive Solid Geometry
1222
-------------------------------------------------------------------------------

0 commit comments

Comments
 (0)