-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprint.html
More file actions
359 lines (329 loc) · 20.5 KB
/
print.html
File metadata and controls
359 lines (329 loc) · 20.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
<!DOCTYPE HTML>
<html lang="en" class="sidebar-visible no-js light">
<head>
<!-- Book generated using mdBook -->
<meta charset="UTF-8">
<title>Geometria Documentation</title>
<meta name="robots" content="noindex" />
<!-- Custom HTML head -->
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="theme-color" content="#ffffff" />
<link rel="icon" href="favicon.svg">
<link rel="shortcut icon" href="favicon.png">
<link rel="stylesheet" href="css/variables.css">
<link rel="stylesheet" href="css/general.css">
<link rel="stylesheet" href="css/chrome.css">
<link rel="stylesheet" href="css/print.css" media="print">
<!-- Fonts -->
<link rel="stylesheet" href="FontAwesome/css/font-awesome.css">
<link rel="stylesheet" href="fonts/fonts.css">
<!-- Highlight.js Stylesheets -->
<link rel="stylesheet" href="highlight.css">
<link rel="stylesheet" href="tomorrow-night.css">
<link rel="stylesheet" href="ayu-highlight.css">
<!-- Custom theme stylesheets -->
</head>
<body>
<!-- Provide site root to javascript -->
<script type="text/javascript">
var path_to_root = "";
var default_theme = window.matchMedia("(prefers-color-scheme: dark)").matches ? "navy" : "light";
</script>
<!-- Work around some values being stored in localStorage wrapped in quotes -->
<script type="text/javascript">
try {
var theme = localStorage.getItem('mdbook-theme');
var sidebar = localStorage.getItem('mdbook-sidebar');
if (theme.startsWith('"') && theme.endsWith('"')) {
localStorage.setItem('mdbook-theme', theme.slice(1, theme.length - 1));
}
if (sidebar.startsWith('"') && sidebar.endsWith('"')) {
localStorage.setItem('mdbook-sidebar', sidebar.slice(1, sidebar.length - 1));
}
} catch (e) { }
</script>
<!-- Set the theme before any content is loaded, prevents flash -->
<script type="text/javascript">
var theme;
try { theme = localStorage.getItem('mdbook-theme'); } catch(e) { }
if (theme === null || theme === undefined) { theme = default_theme; }
var html = document.querySelector('html');
html.classList.remove('no-js')
html.classList.remove('light')
html.classList.add(theme);
html.classList.add('js');
</script>
<!-- Hide / unhide sidebar before it is displayed -->
<script type="text/javascript">
var html = document.querySelector('html');
var sidebar = 'hidden';
if (document.body.clientWidth >= 1080) {
try { sidebar = localStorage.getItem('mdbook-sidebar'); } catch(e) { }
sidebar = sidebar || 'visible';
}
html.classList.remove('sidebar-visible');
html.classList.add("sidebar-" + sidebar);
</script>
<nav id="sidebar" class="sidebar" aria-label="Table of contents">
<div class="sidebar-scrollbox">
<ol class="chapter"><li class="chapter-item expanded "><a href="introduction.html"><strong aria-hidden="true">1.</strong> Introduction</a></li><li class="chapter-item expanded "><a href="get-started/get-started.html"><strong aria-hidden="true">2.</strong> Get Started</a></li><li><ol class="section"><li class="chapter-item expanded "><a href="get-started/hello-world.html"><strong aria-hidden="true">2.1.</strong> Your First Hello World!</a></li><li class="chapter-item expanded "><a href="get-started/square.html"><strong aria-hidden="true">2.2.</strong> Your First Square!</a></li></ol></li></ol>
</div>
<div id="sidebar-resize-handle" class="sidebar-resize-handle"></div>
</nav>
<div id="page-wrapper" class="page-wrapper">
<div class="page">
<div id="menu-bar-hover-placeholder"></div>
<div id="menu-bar" class="menu-bar sticky bordered">
<div class="left-buttons">
<button id="sidebar-toggle" class="icon-button" type="button" title="Toggle Table of Contents" aria-label="Toggle Table of Contents" aria-controls="sidebar">
<i class="fa fa-bars"></i>
</button>
<button id="theme-toggle" class="icon-button" type="button" title="Change theme" aria-label="Change theme" aria-haspopup="true" aria-expanded="false" aria-controls="theme-list">
<i class="fa fa-paint-brush"></i>
</button>
<ul id="theme-list" class="theme-popup" aria-label="Themes" role="menu">
<li role="none"><button role="menuitem" class="theme" id="light">Light (default)</button></li>
<li role="none"><button role="menuitem" class="theme" id="rust">Rust</button></li>
<li role="none"><button role="menuitem" class="theme" id="coal">Coal</button></li>
<li role="none"><button role="menuitem" class="theme" id="navy">Navy</button></li>
<li role="none"><button role="menuitem" class="theme" id="ayu">Ayu</button></li>
</ul>
<button id="search-toggle" class="icon-button" type="button" title="Search. (Shortkey: s)" aria-label="Toggle Searchbar" aria-expanded="false" aria-keyshortcuts="S" aria-controls="searchbar">
<i class="fa fa-search"></i>
</button>
</div>
<h1 class="menu-title">Geometria Documentation</h1>
<div class="right-buttons">
<a href="print.html" title="Print this book" aria-label="Print this book">
<i id="print-button" class="fa fa-print"></i>
</a>
</div>
</div>
<div id="search-wrapper" class="hidden">
<form id="searchbar-outer" class="searchbar-outer">
<input type="search" id="searchbar" name="searchbar" placeholder="Search this book ..." aria-controls="searchresults-outer" aria-describedby="searchresults-header">
</form>
<div id="searchresults-outer" class="searchresults-outer hidden">
<div id="searchresults-header" class="searchresults-header"></div>
<ul id="searchresults">
</ul>
</div>
</div>
<!-- Apply ARIA attributes after the sidebar and the sidebar toggle button are added to the DOM -->
<script type="text/javascript">
document.getElementById('sidebar-toggle').setAttribute('aria-expanded', sidebar === 'visible');
document.getElementById('sidebar').setAttribute('aria-hidden', sidebar !== 'visible');
Array.from(document.querySelectorAll('#sidebar a')).forEach(function(link) {
link.setAttribute('tabIndex', sidebar === 'visible' ? 0 : -1);
});
</script>
<div id="content" class="content">
<main>
<h1 id="geometria-engine"><a class="header" href="#geometria-engine">Geometria Engine</a></h1>
<h2 id="what-is-the-geometria-engine"><a class="header" href="#what-is-the-geometria-engine">What is the Geometria Engine?</a></h2>
<p>Geometria is a multipurpose engine (mostly used for games, but can be used for making all kinds of programs/applications)
that it focuses on:</p>
<ul>
<li>Bringing high fidelity graphics on low-end devices (and expand the capabilities on high-end devices).</li>
<li>Allowing the developer/programmer/user as much control as it can from the engine.</li>
</ul>
<h2 id="about-geometria"><a class="header" href="#about-geometria">About Geometria</a></h2>
<h3 id="graphics"><a class="header" href="#graphics">Graphics</a></h3>
<p>This engine comes with a rendering system that instead of deleting data and generating new one each frame,
it recycles data from the last frame and modifies the data that changed. With this you can save a lot of
CPU power and being able to build from small, to big and complex scenes without sacrificing detail and
performance.</p>
<h3 id="control"><a class="header" href="#control">Control</a></h3>
<p>In most game engines, by default they do most of the tasks for you. But sometimes those tasks don't work in
specific cases or make things worse, and those systems aren't flexible enough overall, and in the worst case
scenario, you can't go inside the code and edit, modify or create according what you need, forcing developers to start "micro-optimizing" or making systems that workaround that system in order to keep the project they've been
working for so long alive.</p>
<p>So instead, Geometria takes a different approach and instead of acting as an engine that controls everything,
it acts like a toolkit with automated systems as an option, that can either control everything,
being completely disabled, work partially, or if nothing of this suits your needs, you can go ahead and modify
them internally without any consequences whatsoever.</p>
<p><strong>YOU</strong> are the one in control of the engine.</p>
<h3 id="beginner-friendly"><a class="header" href="#beginner-friendly">Beginner-friendly</a></h3>
<p>Most tools you encounter start with being complex out of the box most of the time, some of them being so hard
that following a simple tutorial just to print "Hello World!" is incredibly daunting.
In here, setting up a scene and start building it is quick with just a few lines of code!</p>
<div style="break-before: page; page-break-before: always;"></div><h1 id="get-started"><a class="header" href="#get-started">Get Started</a></h1>
<div style="break-before: page; page-break-before: always;"></div><h1 id="your-first-hello-world"><a class="header" href="#your-first-hello-world">Your First Hello World!</a></h1>
<h2 id="know-your-environment"><a class="header" href="#know-your-environment">Know your environment</a></h2>
<p>When you go to the source code of your project, you might end up seeing a lot of folders. It might be overwhelming but don't worry,
all of the folders you see there are basically the entire engine, everything from rendering, to input management, to cores, everything is here!</p>
<p>But we're not here to see all of them, you don't need to, because there's one folder that is not part of the engine but rather, its part of
your game or application, which is called the "Game" folder.</p>
<h2 id="game-folder"><a class="header" href="#game-folder">"Game" Folder</a></h2>
<p>This folder is the heart of your application, in this folder not only there's gonna be your scripts, but also your images, sounds, all of your app's content!. And you're gonna see that the only thing that is inside there is only a file called "GameMain.h".</p>
<h2 id="gamemainh"><a class="header" href="#gamemainh">GameMain.h</a></h2>
<p>This file is the entry of your application, where everything begins, and if you desire, where it ends. If you open it you're gonna see
this chunk of code:</p>
<pre><code class="language-c++">#pragma once
#include "geometria.h"
struct GameMain
{
static void Init()
{
}
};
</code></pre>
<p>You have 2 things here, the <strong>GameMain</strong> struct, and the <strong>Init()</strong> void. GameMain obviously is the initialization of your game or app as
the form of an entity. And Init() is the stuff that'll be executed once the game starts.</p>
<p>See? This is easy so far! Let's print something to the game console, shall we?</p>
<p>Let's add the classic "std::cout" message...</p>
<pre><code class="language-c++">static void Init()
{
std::cout << "Hello World!" << std::endl;
}
</code></pre>
<p>...and as a result, the whole script should look like this:</p>
<pre><code class="language-c++">#pragma once
#include "geometria.h"
struct GameMain
{
static void Init()
{
std::cout << "Hello World!" << std::endl;
}
};
</code></pre>
<p>Once you've done this, compile the project and voalá!
There's your first hello world!</p>
<p><img src="get-started/../images/hello-world-1.png" alt="There it is!" /></p>
<p>Congratulations! Now you know where your app is going to begin!
But this is just only the beginning! Because next up is...</p>
<p><a href="get-started/./square.html">Your First Square!</a></p>
<div style="break-before: page; page-break-before: always;"></div><h1 id="your-first-square"><a class="header" href="#your-first-square">Your First Square!</a></h1>
<p>If you already made your first hello world, you can see that in the game, there's nothing but a dark cyan background:</p>
<p><img src="get-started/../images/square-1.png" alt="Dark Cyan BG" /></p>
<p>What if we add something? Let's add a simple square!</p>
<p>But first, you need to know about what "Draw Calls" are!</p>
<h2 id="what-is-a-draw-call"><a class="header" href="#what-is-a-draw-call">What is a Draw Call?</a></h2>
<p>A <strong>Draw Call</strong> is the instruction from the CPU to draw to the GPU. You basically get the data that you need first,
and then you make a draw call to push it to the GPU so it can render it and put it on the screen.
Draw Calls are used in everything that has graphics nowdays, even your favorite games, engines and even some apps
use them for drawing with the GPU!</p>
<h2 id="why-should-i-know-about-draw-calls"><a class="header" href="#why-should-i-know-about-draw-calls">Why should i know about Draw Calls?</a></h2>
<p>You should know because, instead of having an entire system to handle the draw calls for you, you are the one
in charge of instantiating them!</p>
<p>You may think this is too much, but don't worry, its simple as it sounds and it comes with stuff that
is going to be explained later.</p>
<p>Let's go back to the <strong>Init()</strong> void where you did the first Hello World. And replace the print code, with this</p>
<pre><code class="language-c++">static void Init()
{
DrawCall* myDrawCall = SceneManager::MainScene().CreateDrawCall();
}
</code></pre>
<p>Let's see what are we doing here, in here we're asking to the "Main Scene" (the one we're using by default) to
create a Draw Call. So far so good, but if we compile, we're not gonna see anything yet.</p>
<p>Remember what we talked earlier? Before rendering something, we need to add stuff into the Draw Call. That's
where the "Models" come into place!</p>
<h2 id="the-model"><a class="header" href="#the-model">The "Model"</a></h2>
<p>A Model is basically the data we're sending to the Draw Call in form of an object (or a pointer, to be exact).
This object could've be anything, from a square, to a big metropolis, to anything that contains vertices
and indices!</p>
<p>Let's add a Model! After the Draw Call creation, add this!</p>
<pre><code class="language-c++">
Model* model = new Model(Model::Primitives::SQUARE, Vector3(0, 0, 0), Vector3(0, 0, 0), Vector3(1, 1, 1));
</code></pre>
<p>Whoa whoa wait! What is all of this information?! What are these variables that we're passing inside the parenthesis!</p>
<ul>
<li>
<p>Well, first, there's the vertex information! In there you send the data of the model in form of a list with Vector3s.
This could've be tedious if you do it by hand sometimes, so the engine comes with presets already made, under the name
of <strong>Primitives</strong>! One of them being the Square! (<code>Model::Primitives::SQUARE</code>).</p>
</li>
<li>
<p>The second variable you send is the position, this one is in the form of a Vector3, inside you add the X, Y and Z
position of where the object is gonna be in the scene: <code>Vector3(x, y, z)</code>.</p>
</li>
<li>
<p>The third variable is the rotation, just like position, its in form of a Vector3 and inside you add the X, Y and Z
rotation.</p>
</li>
<li>
<p>And the last variable is the scale, same as rotation and position, in form of a Vector3, and you set how big it is.
Something you should know about scaling is that the default size for each axis is "1". If you add 0 it'll be so small
it'll become invisible!</p>
</li>
</ul>
<p>Now that you know what each variable you're adding to the model is. You can see that we're trying to create is: <strong>a Square in the
center of the scene (0, 0, 0), without any rotation and with its normal scale.</strong></p>
<p>Now we have the draw call, we have the model, let's add it, and you do this with this line!</p>
<pre><code class="language-c++">
RendererCore::AddModel(*model, myDrawCall->Target());
</code></pre>
<p>In the <code>RendererCore::AddModel(...)</code> function you pass the model you want to push to the Draw Call, and the Draw Call
that you want the model to be used.</p>
<p>The <code>Target()</code> function that the draw call is using is just a "safe way" to use it when adding models.<br />
<em>(You can use <code>RendererCore::AddModel(*model, *myDrawCall);</code>, but it tends to have "undefined behaviour" on very complex scenarios)</em></p>
<p>So the final result of the code looks like this:</p>
<pre><code class="language-c++">#pragma once
#include "geometria.h"
struct GameMain
{
static void Init()
{
DrawCall* myDrawCall = SceneManager::MainScene().CreateDrawCall();
Model* model = new Model(Model::Primitives::SQUARE, Vector3(0, 0, 0), Vector3(0, 0, 0), Vector3(1, 1, 1));
RendererCore::AddModel(*model, myDrawCall->Target());
}
};
</code></pre>
<p>And if you compile the project, you can see that you have a Square in the Scene!</p>
<p><img src="get-started/../images/square-2.png" alt="There it is!" /></p>
<h2 id="want-something-more-simpler"><a class="header" href="#want-something-more-simpler">Want something more simpler?</a></h2>
<p>When the game begins, by default it instantiates what is called, the "Main Draw Call", this Draw Call is just like a normal one, but its always
active and can't be deleted or removed.</p>
<p>If you want, you can add the Square to the Main Draw Call instead of creating a new one,<br />
(<em>If you don't add any draw call to the <code>RendererCore::AddModel()</code> function, it'll default to the Main Draw Call</em>)<br />
and the code looks like this, and you're still going to have the same result:</p>
<pre><code class="language-c++">static void Init()
{
Model* model = new Model(Model::Primitives::SQUARE, Vector3(0, 0, 0), Vector3(0, 0, 0), Vector3(1, 1, 1));
RendererCore::AddModel(*model);
}
</code></pre>
</main>
<nav class="nav-wrapper" aria-label="Page navigation">
<!-- Mobile navigation buttons -->
<div style="clear: both"></div>
</nav>
</div>
</div>
<nav class="nav-wide-wrapper" aria-label="Page navigation">
</nav>
</div>
<!-- Livereload script (if served using the cli tool) -->
<script type="text/javascript">
var socket = new WebSocket("ws://localhost:3000/__livereload");
socket.onmessage = function (event) {
if (event.data === "reload") {
socket.close();
location.reload();
}
};
window.onbeforeunload = function() {
socket.close();
}
</script>
<script type="text/javascript">
window.playground_copyable = true;
</script>
<script src="elasticlunr.min.js" type="text/javascript" charset="utf-8"></script>
<script src="mark.min.js" type="text/javascript" charset="utf-8"></script>
<script src="searcher.js" type="text/javascript" charset="utf-8"></script>
<script src="clipboard.min.js" type="text/javascript" charset="utf-8"></script>
<script src="highlight.js" type="text/javascript" charset="utf-8"></script>
<script src="book.js" type="text/javascript" charset="utf-8"></script>
<!-- Custom JS scripts -->
<script type="text/javascript">
window.addEventListener('load', function() {
window.setTimeout(window.print, 100);
});
</script>
</body>
</html>