-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathREADME.txt
More file actions
61 lines (47 loc) · 2.3 KB
/
README.txt
File metadata and controls
61 lines (47 loc) · 2.3 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
Documentation Author: Niko Procopi 2020
This tutorial was designed for Visual Studio 2019
If the solution does not compile, retarget the solution
to a different version of the Windows SDK. If you do not
have any version of the Windows SDK, it can be installed
from the Visual Studio Installer Tool
AtlasEngine - Threading
Prerequisites
Intro C tutorials, Basic OpenGL tutorials, and
physics tutorials are required before starting
the engine series
With threading, we can attach code to the objects we build.
Right now, out of all the members in struct Thread, only
siblingThread and funcOnTick are used, just to start off simple.
Threading is not the same as multithreading. Multithreading is
where code runs on separate CPU processors in parallel, but
"Threading" itself is where code is divided, but then runs
sequentially (one by one).
When each thread is built, it must be added to what Naughty Dog
calls a "Thread Bucket" which is basically a linked list, so that
similar threads are grouped together (players with players, AIs
with AIs, etc).
Also, globals.h was renamed to pch.h, it is now a precompiled header,
which makes compiling the game twice as fast as before. To learn more,
skip to 12:30 of this video, it explains everything about PCH
https://www.youtube.com/watch?v=eSI4wctZUto
With this system the following has been accomplished:
- Threads and Instances can be attached to each other,
meaning code can be indirectly "attached" to an instance,
just like what we do with player.
- By grouping similar threads together, like coin, we can
count how many coins there are in the world by looping
through the list in player.cpp (press 'C' to count coins).
This also allows us to access all threads without needing
to save all pointers to all threads in a big array or vector
- We can build a large number of Instances, and a large
number of Threads, then have our engine automatically
draw all Instances, and execute all Threads, with a loop,
without us needing to access pointers to the data.
Coming next:
- Building "pool" systems, as Naughty Dog calls them,
so that we can allocate and deallocate our Threads and Instances,
without needing to undo allocations in the Stack Allocator.
(next tutorial)
- Coins will take advantage of threads,
by using threads for collisions
(tutorial after next)