Refs, Scopes and Smart Pointers | Game Engine series

  Рет қаралды 36,865

The Cherno

The Cherno

Күн бұрын

Пікірлер: 82
@sebastiannocke3725
@sebastiannocke3725 5 жыл бұрын
Cooking with Cherno, I need it please
@jamesmnguyen
@jamesmnguyen 5 жыл бұрын
We need some Turkey too!
@austindrane3162
@austindrane3162 5 жыл бұрын
That would be the best series on KZbin
@bandolero818
@bandolero818 2 жыл бұрын
Cooking while doing analogies with programming and c++, would love that content !
@cyqry
@cyqry 2 жыл бұрын
@@bandolero818 "Now we're going to dice this here and its kind of like making a shared pointer"
@mrhidetf2
@mrhidetf2 5 жыл бұрын
cherno really stepping up his metahphor game in this series. Honestly tho i think you are getting better and better at communicating
@Daniel-zr4pk
@Daniel-zr4pk Ай бұрын
7:10 Counter-Strike 1.6 is single threaded and works amazingly well. it's a masterpiece - long time ago i had made a Mod called Alien Invasion where it spawns aliens from the sky and they had a Think() function to make them seek you around the map and hit you when they are close to you. It had the capability to spawn more than 100 aliens that were thinking every milisecond. it was starting to lag at around 200 aliens. huge lag at 300. but i think it's increadible performance for single threaded engine and server.
@mario7501
@mario7501 4 жыл бұрын
Just made a patreon account to support your channel! This is by a mile the best C++ and game dev content on KZbin!
@jdev6402
@jdev6402 5 жыл бұрын
Now i'm curious how that asset manager will look. Thank you for your dedication to this series, it's really motivating and informational.
@felipecarlin8540
@felipecarlin8540 4 жыл бұрын
9:29 I was not prepared for that, now I'm concerned about memory ownership and management. Thanks Cherno!
@carlosgarciavigoa7937
@carlosgarciavigoa7937 5 жыл бұрын
Guys & Girls, this is a simple tip. If anyone here goes to the beginning of the series and watch the first episode again, it will increase watching time, popularity, ranking and many other things that will help the Series. Of course, it will help Cherno too. More view more ranking and at the same time more subscriber than eventually will become Patrons. Remember now is a FULL-TIME JOB. We need to keep that. TY in advantages.
@colorcookie6088
@colorcookie6088 5 жыл бұрын
Love you Cherno!!! Your C++ series has helped me a lot. Thankk you
@robertocabiddu6008
@robertocabiddu6008 4 жыл бұрын
0:10 nah m8 EVERY SINGLE episode is EXCITING
@__jan
@__jan 5 жыл бұрын
he's getting funnier every episode
@SandFoxling
@SandFoxling 3 жыл бұрын
2021 and still no "Cooking with Cherno". In the mean time, patreons should get access to a shared pointer to his kitchen
@davencharity
@davencharity 5 жыл бұрын
Cooking with Cherno? It's been over four years since Sparky, and I don't think you've ever remembered to take the turkey out of the oven! ;)
@thecookiegeneration
@thecookiegeneration 5 жыл бұрын
You can check if the sharedptr is lock free, most atomic increment and decrement operations can be done threadsafe without a lock (single cpu instruction for read increment write)
@misterbenjamin7845
@misterbenjamin7845 2 жыл бұрын
Cooking With Cherno - Episode 1: The Perfect Cup of Coffee
@simonbaxter8001
@simonbaxter8001 5 жыл бұрын
I'm still waiting for the 'Cooking with Cherno' series ! ;)
@ZyklonV
@ZyklonV 5 жыл бұрын
Man, last time I heard the word "ownership" so many times was during a talk presenting the Rust programming language. Love C/C++, love Rust more
@stanleythehandsome5402
@stanleythehandsome5402 5 жыл бұрын
Boy I Love this guy
@TriNity-GER
@TriNity-GER 5 жыл бұрын
Whenever I need a pointer, I always ask myself: who is the owner? Are there multiple owners? Using this though massively helped me to choose between unique_ptr and shared_ptr. Also my favorite replacement for raw pointer is object_ptr :D
@MirralisDias
@MirralisDias 3 ай бұрын
In the current code base (Hazel2D), what is the point of using std::shared_ptr, if you're passing it as a const reference basically everywhere, therefore not incrementing the counter, and not avoiding the same things you are concerned about. I wonder if this is the same for the dev branch.
@colorcookie6088
@colorcookie6088 5 жыл бұрын
Cooking with chernoooooooo!!!!!! Let's go babyyyy!!!!
@jamesdadabo
@jamesdadabo 4 жыл бұрын
"all cool and hip and trendy"
@FurtoMega
@FurtoMega 2 жыл бұрын
I was having a big problem with a dangling pointer in my code. Weak pointer saved my life. Every since then I use shared pointers only..
@quanghong3922
@quanghong3922 5 жыл бұрын
Great job
@alopmemes1964
@alopmemes1964 2 жыл бұрын
nice new haircut :D
@sam_is_people1170
@sam_is_people1170 3 жыл бұрын
thanks!!!
@MieysoFelix
@MieysoFelix 2 жыл бұрын
I live in sad 2022 😔. Can i get a reference to *"Cooking with Cherno"* ? Or at least a pointer address?
@Thiago1337
@Thiago1337 5 жыл бұрын
Great tutorials.
@engsayed2007
@engsayed2007 5 жыл бұрын
I Am developing a program which I draw objects using the mouse I draw a point _ line and polygon with any number of sides I save each created object (line or point or polygon) as a mesh having its own vba_vbo_ibo Till now I can select each object and individually without any problems My problem is I want to create large number of objects say 2 millions When I create more objects the program becomes too slow in rendering I tried to make all vertices coordinates in one buffer and all created objects share this buffer according to its indices How can I handle such a huge number of objects ?????? Thanx in advance
@gracicot42
@gracicot42 5 жыл бұрын
What I do usually is to decouple the refcount to the asset. I have the asset object that contains only the minimum necessary to use it, and a refcount. For example, the asset object for a shader program would contain the id and the refcount. But having a refcount of some sort, whether it's with a shared pointer or something like I do is absolutely necessary. Keeping resources around from scene to scene makes the engine not loading things over and over. We don't know when we will destroy the texture or when it won't be needed anymore. So shared ownership is ideal.
@GalaxySoftwareStudio
@GalaxySoftwareStudio 5 жыл бұрын
What do you using about using glad2 instead in the future ? As it supports Vulkan too, multiple GL contexts, internal loader and you can even generate a header only version ! ^^
@jakobfriedl3098
@jakobfriedl3098 4 жыл бұрын
all of us crying xD
@popplestones886
@popplestones886 2 жыл бұрын
Still waiting for cooking with cherno, 3 years later :-(
@theo-dr2dz
@theo-dr2dz Жыл бұрын
What he says at minute 3 is not correct. std::unique_ptr can't be copied (if it could, it would not be unique anymore), but it can be moved. Moving a std::unique_ptr transfers the ownership. But of course, if you need shared ownership, use a shared_ptr
@fryderykst
@fryderykst 5 жыл бұрын
Great video as always, thanks! :) Could you (or someone else) explain the difference between atomic count and regular one? How it works? Thanks.
@mytech6779
@mytech6779 5 жыл бұрын
I was trying to slog through a bunch of the CPPcon videos, mind blown. Getting down to manipulating L2 and L3 to achieve better atomic multi-threading; actually considering the physical time to transmit an electric pulse between cores and predictive fetching from memory. And they always say "use vectors", I'm not sure if this is an old running joke or actual advice for better general performance.
@reductor_
@reductor_ 5 жыл бұрын
'better general performance' : no, get a few more ns with micro optimizations : yes essentially don't prematurely optimize
@daleowens7695
@daleowens7695 2 жыл бұрын
As you are aware, it's a consequence of cache. "Everything" is probably a vector, and now with cache, this is doubly so. @ReDucT0r; 'better general performance' : yes. I sugges you research cpu cache. vectors are beating out linked lists, even for tasks classically thought of as optimized for linked lists, like midpoint insertions and deletions because cpu cache is orders of magnitude faster than going to RAM.
@mytech6779
@mytech6779 2 жыл бұрын
@@daleowens7695 2 years on and I know a good deal more about c++. The vector referenced was the std library dynamic array, not the SIMD hardware or math concepts. And yes they were mostly comparing it to [linked] list performance, but it was also about moving away from old style C and improving code quality both in reading the logic and in avoiding memory leaks associated with deleting manually allocated dynamic memory for classic arrays. (Though if done just right a classic array can be a hair more optimized if needed for some very critical corner case, but in most cases the payoff isn't worth the effort and would need a lot of profiling and testing to proove. In many cases careful use of vec1.reserve(n) will close most of that gap without the hassle. )
@_Omni
@_Omni 5 жыл бұрын
24:26 you didn't say what you will do in the next episode 🤷‍♂️
@raffallo
@raffallo 3 жыл бұрын
textures :)
@clodgozon3968
@clodgozon3968 5 жыл бұрын
I love dealing with refs and pointers. Not an irony.
@cubefish2320
@cubefish2320 5 жыл бұрын
Give me lapsis episode 9 i'm still waiting after all these years I've become nothing, dedicating every second of my waking time to trying to solve what episode 9 would be. I lost my job, my wife, my family outed me, and I lost all my friends. I live on the streets, wandering with my phone, theorizing about how the Minecraft Machinima 'Lapsis' episode 9 would have ended. I need this. please.
@bies_moron4404
@bies_moron4404 5 жыл бұрын
401 patrons !!
@aarondraws7699
@aarondraws7699 3 жыл бұрын
i destroyed my entire code base with the replace all function I basically have to start over
@mjthebest7294
@mjthebest7294 2 жыл бұрын
This is why you want to use git and commit often. :)
@jdev6402
@jdev6402 5 жыл бұрын
9:35 lmao
@graph2001
@graph2001 Жыл бұрын
ChatGPT3.5 Generated: - The transcript is from a video in a game engine series. - The video discusses references and smart pointers for the engine's core system. - Shared pointers are being used to encapsulate objects on the heap to control their lifetime. - The issue of ownership is important for smart pointers as they automate the deletion of objects. - The renderer of the engine needs to hold references to assets such as shaders and vertex arrays for deferred rendering.
@billclinton4913
@billclinton4913 5 жыл бұрын
"We have a very exciting epesode" says without anny emotion.
@nextlifeonearth
@nextlifeonearth 5 жыл бұрын
Somehow in the poll people imply 2D would be a stepping stone to 3D.. If you look at any given 2D or 3D engine editor you see they're almost nothing alike. "use the feedback from 2D for 3D" That's not how it works. Outside of some scripting, the UI feedback will be of no benefit in the 3D editor. There are fewer materials in 2D, so no material editor except for its texture and maybe some filters, that's out. The world editor, is vastly different in 3D again, that's out. Will it be faster? Yes, you can look at 100+ tutorials to make 2D engines online today and see for yourself it can be pretty easy. If you'd like to compare it a a PBR capable 3D engine tutorial, good luck, there's about 5 of which most are behind a paywall and/or abstracted from the code. Then what it the purpose of this engine? Making it modern. Is 2D modern? Pretty much every modern effect only applies to 3D.
@Sevo779Gaming
@Sevo779Gaming 5 жыл бұрын
2D and 3D both have modern developments, new rendering technics are always being developed, now that is not to say that 3D is not more complex, or different but you seem to be heavily biased because it is obvious that building a simpler engine is a stepping stone to a more complex and demanding one. Also, I have made a UI that works in both 2D and 3D so I am not sure what you mean there.
@nextlifeonearth
@nextlifeonearth 5 жыл бұрын
​@@Sevo779Gaming Works doesn't mean work well. An optimal workflow in either are little alike. I don't doubt you can make it more complex, but we don't want complexity, we want sophistication without it being complex. That's mainly it, you COULD make an editor for 2D and modify it for 3D later, but it would not work as well as if you were designing it for 3D from the beginning. It's a compromise and "compromises are the enemy of success", to quote someone.
@DovydasV2
@DovydasV2 5 жыл бұрын
He's not going to make a full on 2D editor at first, nor a 3d editor. I hope you do understand that. (By the way, you can totally use a 3d editor for 2d games, that's what unity does, they only make the camera orthographic) He is going to create a 2D Renderer at first which will do sprite batching and stuff like that, and then after that he will continue on to 3d PBR renderer which will take a lot of episodes and time to make. There is no debate, what kind of engine it is going to be. As he said, he will do both, but he's asking which one should come first. Also, I think that world editor is not coming anytime soon, since what is the reason to make an editor right now? I will repeat myself again, but he's not going to build a 3d renderer on top of a 2d renderer. They are going to both eventually come and the poll is a debate whether 3D rendering or 2D rendering should come first.
@nextlifeonearth
@nextlifeonearth 5 жыл бұрын
@@DovydasV2 "you can totally use a 3d editor for 2d games, that's what unity does" And it's terrible. I have used it and I'd rather use Gamemaker than that for 2D games, because unlike Unity, Gamemaker was actually designed for 2D. I have too much of a bad experience with people saying "X will come later even though it's the primary purpose of the software, we'll do Y first" and then it vastly compromises what can be done with X. That's why I have a big aversion of what's essentially a sidetrack that has little to do with 3D and could actually get in the way of the final product and at the very least delay it simply to sate some people who weren't into this series for its purpose in the first place.
@jarekmyszko3332
@jarekmyszko3332 2 жыл бұрын
Thread pool system is better than dividing engine into specialized threads. 1) Easy to add to existing engine structure. 2) Easy to synchronize(you don't need to use double buffering) 3) Memory efficient(look above) 4) Scales better for computers with more than 4 cores. 5) Great for ECS pattern.
@Rekongstor
@Rekongstor 5 жыл бұрын
I love smart pointers and especially shared ones, the main idea of this video is good. But what's the point of renaming std::shared_ptr into Hazel::Ref or std::unique_ptr into Hazel::Scope? You still have to type a bunch of letters but new Hazel users will not intuitively understand what Hazel::Ref stands for without peeking on the code or reading the documentation. Like maybe it would be better to remain std library without Hazel aliases because there're more people familiar with std naming, not Hazel's.
@madeso
@madeso 4 жыл бұрын
Premature refactoring. At 14:03 he says it's because he might want to implement a shared_ptr for "assets" with the same exact api as std::shared_ptr and changing it then would be too hard.
@jamesmnguyen
@jamesmnguyen 5 жыл бұрын
Would delaying the rendering cause noticeable input lag for the user?
@nielsvs2203
@nielsvs2203 5 жыл бұрын
Generally not
@denisbalcom1429
@denisbalcom1429 5 жыл бұрын
loving the metaphors and cooking with cherno statement lol. ~^_^~.
@bensettiabderrahmane1801
@bensettiabderrahmane1801 5 жыл бұрын
Hello, World!!!
@bensettiabderrahmane1801
@bensettiabderrahmane1801 5 жыл бұрын
First Vue!!!!
@vitaliiseptember266
@vitaliiseptember266 5 жыл бұрын
Hey, Yan - its a russian name, and Chernikov - its like russian surname, isnt it?
@jamespong6588
@jamespong6588 5 жыл бұрын
So it's either ugly code or cryptic code Plus you still have to manage when things get deleted but in an abstract way instead of shouting to the world HERE IN THIS VERY MOMENT I AM RELEASED FROM MEMORY New and delete is fine.
@ricardopieper11
@ricardopieper11 5 жыл бұрын
It's fine, but we forget to do it all the time. No matter how genius of a C++ programmer you are, you are bound to forget it at some point. Or you'll double-free, or dereference a dangling pointer, or return a pointer to a stack value... so much can go wrong. It's no surprise they created Rust because of this very problem.
@jamespong6588
@jamespong6588 5 жыл бұрын
Ricardo Pieper yeah people forget to call delete, but you can follow the code and figure out if you forgot it, also we have powerful tools to trace memory leaks, it's orders of magnitude harder to figure out when something is released by code structure, than Ctrl+F and find "delete xyz"
@huyvole9724
@huyvole9724 5 жыл бұрын
New pc
@optimusfjstudio3345
@optimusfjstudio3345 5 жыл бұрын
when you make your own engine can use blender
@TheKbdering
@TheKbdering 5 жыл бұрын
It's pronounced decrement, not decrement
Weak Pointers in C++ (std::weak_ptr)
17:25
The Cherno
Рет қаралды 61 М.
I made it FASTER // Code Review
38:46
The Cherno
Рет қаралды 553 М.
Andro, ELMAN, TONI, MONA - Зари (Official Music Video)
2:50
RAAVA MUSIC
Рет қаралды 2 МЛН
$1 vs $500,000 Plane Ticket!
12:20
MrBeast
Рет қаралды 122 МЛН
요즘유행 찍는법
0:34
오마이비키 OMV
Рет қаралды 12 МЛН
УЛИЧНЫЕ МУЗЫКАНТЫ В СОЧИ 🤘🏻
0:33
РОК ЗАВОД
Рет қаралды 7 МЛН
Window Abstraction and GLFW | Game Engine series
29:20
The Cherno
Рет қаралды 135 М.
C++ Smart Pointers - Do I really need them? When?
28:41
CppMonk
Рет қаралды 9 М.
unique_ptr: C++'s simplest smart pointer
11:54
mCoding
Рет қаралды 47 М.
Hazel - My Game Engine // Code Review
40:59
The Cherno
Рет қаралды 119 М.
Go Pointers: When & How To Use Them Efficiently
14:09
Anthony GG
Рет қаралды 90 М.
SMART POINTERS in C++ (for beginners in 20 minutes)
24:32
CodeBeauty
Рет қаралды 107 М.
Entity Component System | Game Engine series
43:05
The Cherno
Рет қаралды 131 М.
Andrew Kelley   Practical Data Oriented Design (DoD)
46:40
ChimiChanga
Рет қаралды 153 М.
Smart Pointers in C++ (Stop Using new?)
17:18
Caleb Curry
Рет қаралды 14 М.
are "smart pointers" actually smart?
9:44
Low Level
Рет қаралды 81 М.
Andro, ELMAN, TONI, MONA - Зари (Official Music Video)
2:50
RAAVA MUSIC
Рет қаралды 2 МЛН