Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(250)

Side by Side Diff: native_client_sdk/src/doc/cds2014/cpp.rst

Issue 731323003: Revising cds2014 samples based on first round of feedback. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add html Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 .. _cds2014_cpp: 1 .. _cds2014_cpp:
2 2
3 ################################## 3 ##################################
4 A Saga of Fire and Water - Codelab 4 A Saga of Fire and Water - Codelab
5 ################################## 5 ##################################
6 6
7 Introduction 7 Introduction
8 ------------ 8 ------------
9 9
10 .. include:: cpp_summary.inc 10 .. include:: cpp_summary.inc
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 Remarkably, not everyone enjoys the primal illusion of fire. 66 Remarkably, not everyone enjoys the primal illusion of fire.
67 67
68 Your task in this codelab is to transform the rising fire 68 Your task in this codelab is to transform the rising fire
69 effect you see before you, into a beautiful, tranquil waterfall. 69 effect you see before you, into a beautiful, tranquil waterfall.
70 This will require digging into some C++ code. 70 This will require digging into some C++ code.
71 71
72 Before you begin, you'll want to copy our fire program to a new name, 72 Before you begin, you'll want to copy our fire program to a new name,
73 since you might decide later that you like fire better, I know I do:: 73 since you might decide later that you like fire better, I know I do::
74 74
75 cp fire.cc water.cc 75 cp fire.cc water.cc
76 git add water.cc
77 git commit -am "adding water"
76 78
77 For this codelab, you'll only need to change `water.cc`. 79 For this codelab, you'll only need to change `water.cc`.
78 80
79 The task of turning fire into water involves two key challenges: 81 The task of turning fire into water involves two key challenges:
80 82
81 * Alter the red-yellow palette of fire into a blue-green one. 83 * Alter the red-yellow palette of fire into a blue-green one.
82 * Reverse upward rising flame into downward falling water. 84 * Reverse upward rising flame into downward falling water.
83 * Seed the waterfall from the top instead of the bottom. 85 * Seed the waterfall from the top instead of the bottom.
84 86
85 At this point you'll want to open up `water.cc` in the editor you 87 At this point you'll want to open up `water.cc` in the editor you
86 picked earlier. 88 picked earlier.
87 89
88 I see a red door and I want it painted... blue 90 I see a red door and I want it painted... blue
89 ============================================== 91 ==============================================
90 92
91 While PPAPI's 2D graphics API uses multi-component RGB pixels, 93 While PPAPI's 2D graphics API uses multi-component RGB pixels,
92 our flame effect is actually monochrome. A single intensity 94 our flame effect is actually monochrome. A single intensity
93 value is used in the flame simulation. This is then converted 95 value is used in the flame simulation. This is then converted
94 to color based on a multi-color gradient. 96 to color based on a multi-color gradient.
95 To alter the color-scheme, locate this palette, and exchange 97 To alter the color-scheme, locate this palette, and exchange
96 the red component for blue. 98 the red component (first) with blue (third).
97 99
98 Hint: Focus your energies on the CreatePalette function. 100 Hint: Focus your energies on the CreatePalette function.
99 101
100 You can test you changes at any time with:: 102 You can test you changes at any time with::
101 103
102 make water 104 make water
103 105
104 What goes up... 106 What goes up...
105 =============== 107 ===============
106 108
107 Now there's the small matter of gravity. 109 Now there's the small matter of gravity.
108 While smoke, and well flame, rises, we want our water to go down. 110 While smoke, and well flame, rises, we want our water to go down.
109 111
110 The simulation of fire loops over each pixel, 112 The simulation of fire loops over each pixel,
111 bottom row to top row, 113 bottom row to top row,
112 diffusing "fire stuff" behind the sweep. 114 diffusing "fire stuff" behind the sweep.
113 You'll want to reverse this. 115 You'll want to reverse this.
114 Note the simulation buffer is stored in |row_major| from bottom to top.
115 Accesses of + width and - width are used to reach rows above and below
116 the current line.
117
118 .. |row_major| raw:: html
119
120 <a href="http://en.wikipedia.org/wiki/Row-major_order"
121 target="_blank">Row-major order</a>
122 116
123 Hint: You'll need to change the y loop direction in the UpdateFlames function. 117 Hint: You'll need to change the y loop direction in the UpdateFlames function.
124 118
125 Up high, down low 119 Up high, down low
126 ================= 120 =================
127 121
128 While you can now use the mouse to inject a trickle of water. 122 While you can now use the mouse to inject a trickle of water.
129 The small line of blue at the bottom isn't much of a waterfall. 123 The small line of blue at the bottom isn't much of a waterfall.
130 Move it to the top to complete the effect. 124 Move it to the top to complete the effect.
131 125
(...skipping 21 matching lines...) Expand all
153 147
154 For questions, concerns, and help contact us at 148 For questions, concerns, and help contact us at
155 `native-client-discuss@googlegroups.com 149 `native-client-discuss@googlegroups.com
156 <https://groups.google.com/forum/#!forum/native-client-discuss>`_. 150 <https://groups.google.com/forum/#!forum/native-client-discuss>`_.
157 151
158 I hope this codelab has lit a fire in you to go out there, 152 I hope this codelab has lit a fire in you to go out there,
159 and bring an awesome C/C++ application to NaCl or PNaCl today! 153 and bring an awesome C/C++ application to NaCl or PNaCl today!
160 154
161 155
162 .. include:: ../nacldev/cleanup_app.inc 156 .. include:: ../nacldev/cleanup_app.inc
OLDNEW
« no previous file with comments | « native_client_sdk/doc_generated/sdk/download.html ('k') | native_client_sdk/src/doc/cds2014/python.rst » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698