You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<p>Getting started with C++ is hard. Before you can draw anything on screen you need to set up a build system, open a window, initialize OpenGL, and write a lot of setup code. Most people give up before they see anything.</p>
51
67
52
-
<p>Processing solved this problem for Java. C++ Mode does the same thing for C++. You type <code>ellipse(300, 300, 50, 50)</code>, hit Run, and something appears on screen. The window, the event loop, the OpenGL context, all of it is taken care of.</p>
68
+
<p>Processing solved this problem for Java. C++ Mode does the same thing for C++. You type <codestyle="font-family:monospace;background:#f4f4f4;padding:2px 6px;border-radius:4px;">ellipse(300, 300, 50, 50)</code>, hit Run, and something appears on screen. The window, the event loop, the OpenGL context, all of it is taken care of.</p>
53
69
54
70
<h2>A friendlier path into C++</h2>
55
71
56
-
<p>If you already know Processing, you already know most of the API. <code>setup()</code>, <code>draw()</code>, <code>background()</code>, <code>mouseX</code>, <code>fill()</code> all work the same way. The only difference is that you are now writing C++.</p>
72
+
<p>If you already know Processing, you already know most of the API. setup(), draw(), background(), mouseX, fill() all work the same way. The only difference is that you are now writing C++.</p>
57
73
58
74
<p>You can take it step by step. Start with sketches that look almost identical to what you would write in Java. Then start introducing C++ concepts at your own pace: structs, vectors, pointers, templates. The visual feedback makes it easier to understand what your code is actually doing.</p>
59
75
60
76
<h2>Who is it for</h2>
61
77
62
78
<p>C++ Mode is for Processing users who are curious about C++ and want a familiar starting point. It is for students taking a C++ course who want to make something visual while they learn. It is for developers who already know C++ and want a fast creative coding environment. And it is for artists who want their sketches to run as fast as possible without giving up the simplicity of the Processing API.</p>
63
79
64
-
<p>Made by <ahref="https://github.com/pepc84" style="border-bottom:1px solid #ddd;">Jose Gonzalez Llamas</a>. Contributions welcome on <ahref="https://github.com/processing-cpp/processing.cpp" style="border-bottom:1px solid #ddd;">GitHub</a>.</p>
80
+
<p>Made by <ahref="https://github.com/pepc84" style="border-bottom:1px solid #ddd;">Jose Gonzalez Llamas</a>. Contributions welcome on <ahref="https://github.com/processing-cpp/processing.cpp" style="border-bottom:1px solid #ddd;">GitHub</a>.</p>
<pclass="subtitle">Everything available in C++ Mode out of the box.</p>
83
62
84
63
<divclass="tip">
85
64
None of these require an <code>#include</code>. They are all automatically available in every sketch through <code>Processing.h</code>.
86
65
</div>
87
66
88
-
<h2id="included">What is included</h2>
89
-
<p>C++ Mode includes the full C++ Standard Library automatically. You can use any of the following without writing a single <code>#include</code> at the top of your sketch.</p>
90
-
<p>If you want to use a third-party library, you can still add <code>#include</code> statements as normal.</p>
91
-
92
-
<h2id="containers">Containers</h2>
67
+
<h2>Containers</h2>
93
68
<divclass="lib-grid">
94
69
<divclass="lib-card"><code>std::vector</code><p>Dynamic array. The most common container. Use instead of Java's ArrayList.</p></div>
95
70
<divclass="lib-card"><code>std::map</code><p>Key-value pairs sorted by key. Use instead of Java's HashMap.</p></div>
<divclass="lib-card"><code>std::sort</code><p>Sort any container. Works with lambdas for custom comparison.</p></div>
106
81
<divclass="lib-card"><code>std::find</code><p>Find an element in a range.</p></div>
107
82
<divclass="lib-card"><code>std::remove_if</code><p>Remove elements matching a condition. Commonly used with vectors.</p></div>
108
-
<divclass="lib-card"><code>std::min / std::max</code><p>Min and max of two values. Also available as the Processing functions min() and max().</p></div>
83
+
<divclass="lib-card"><code>std::min / std::max</code><p>Min and max of two values.</p></div>
109
84
<divclass="lib-card"><code>std::accumulate</code><p>Sum or fold a range of values.</p></div>
110
85
<divclass="lib-card"><code>std::transform</code><p>Apply a function to every element in a range.</p></div>
111
86
</div>
112
87
113
-
<h2id="strings">Strings and IO</h2>
88
+
<h2>Strings and IO</h2>
114
89
<divclass="lib-grid">
115
-
<divclass="lib-card"><code>std::string</code><p>Text string. Use instead of Java's String. Supports +, ==, .size(), .substr() and more.</p></div>
116
-
<divclass="lib-card"><code>std::stringstream</code><p>Build strings from mixed types. Useful for formatting numbers into text.</p></div>
90
+
<divclass="lib-card"><code>std::string</code><p>Text string. Use instead of Java's String.</p></div>
91
+
<divclass="lib-card"><code>std::stringstream</code><p>Build strings from mixed types.</p></div>
117
92
<divclass="lib-card"><code>std::ifstream</code><p>Read from files.</p></div>
118
93
<divclass="lib-card"><code>std::ofstream</code><p>Write to files.</p></div>
119
-
<divclass="lib-card"><code>std::regex</code><p>Regular expressions for pattern matching in strings.</p></div>
120
-
<divclass="lib-card"><code>std::cout / std::cerr</code><p>Print to the console. Also available as println() in Processing style.</p></div>
94
+
<divclass="lib-card"><code>std::regex</code><p>Regular expressions for pattern matching.</p></div>
95
+
<divclass="lib-card"><code>std::cout / std::cerr</code><p>Print to the console. Also available as println().</p></div>
121
96
</div>
122
97
123
-
<h2id="concurrency">Concurrency</h2>
98
+
<h2>Concurrency</h2>
124
99
<divclass="lib-grid">
125
-
<divclass="lib-card"><code>std::thread</code><p>Run code on a separate thread. Useful for background loading or computation.</p></div>
100
+
<divclass="lib-card"><code>std::thread</code><p>Run code on a separate thread.</p></div>
126
101
<divclass="lib-card"><code>std::mutex</code><p>Protect shared data between threads.</p></div>
127
102
<divclass="lib-card"><code>std::atomic</code><p>Thread-safe operations on single values.</p></div>
128
103
</div>
129
104
130
-
<h2id="utilities">Utilities</h2>
105
+
<h2>Utilities</h2>
131
106
<divclass="lib-grid">
132
-
<divclass="lib-card"><code>std::optional</code><p>A value that may or may not be present. Avoids null pointers.</p></div>
107
+
<divclass="lib-card"><code>std::optional</code><p>A value that may or may not be present.</p></div>
133
108
<divclass="lib-card"><code>std::variant</code><p>A value that can be one of several types.</p></div>
134
109
<divclass="lib-card"><code>std::tuple</code><p>A fixed-size collection of values of different types.</p></div>
<divclass="lib-card"><code>std::memory (unique_ptr, shared_ptr)</code><p>Smart pointers for automatic memory management.</p></div>
111
+
<divclass="lib-card"><code>std::unique_ptr / std::shared_ptr</code><p>Smart pointers for automatic memory management.</p></div>
137
112
<divclass="lib-card"><code>std::chrono</code><p>Time utilities. Measure durations and get the current time.</p></div>
138
113
</div>
139
114
140
-
<h2id="math">Math</h2>
115
+
<h2>Math</h2>
141
116
<divclass="lib-grid">
142
-
<divclass="lib-card"><code>std::cmath</code><p>sin, cos, tan, sqrt, pow, abs, floor, ceil and more. Also available as Processing-style functions.</p></div>
143
-
<divclass="lib-card"><code>std::random</code><p>Random number generation. Also available as random() in Processing style.</p></div>
144
-
<divclass="lib-card"><code>std::numeric</code><p>Numeric utilities like iota, accumulate, inner_product.</p></div>
117
+
<divclass="lib-card"><code>std::cmath</code><p>sin, cos, tan, sqrt, pow, abs, floor, ceil and more.</p></div>
118
+
<divclass="lib-card"><code>std::random</code><p>Random number generation. Also available as random().</p></div>
119
+
<divclass="lib-card"><code>std::numeric</code><p>iota, accumulate, inner_product and more.</p></div>
0 commit comments