GRASS RENDERING in OpenGL // Code Review

  Рет қаралды 112,834

The Cherno

The Cherno

Күн бұрын

Visit brilliant.org/TheCherno to get started learning STEM for free! The first 200 people will get 20% off their annual premium subscription.
Patreon ► / thecherno
Instagram ► / thecherno
Twitter ► / thecherno
Discord ► / discord
Code ► github.com/SomePineaple/GLGrass
Send an email to chernoreview@gmail.com with your source code, a brief explanation, and what you need help with/want me to review and you could be in the next episode of my Code Review series! Also let me know if you would like to remain anonymous.
CHAPTERS
0:00 - Rendering lots of grass in OpenGL
2:55 - Diving into the code
10:12 - Instantiating objects in C++ vs C#/Java
11:35 - Shader class
12:12 - Variable naming conventions
13:25 - Initializing variables
15:03 - Some notes on strings
15:30 - Pass larger types by const reference
16:45 - Using correct types
17:48 - Strings in C++ and std::string_view
20:48 - .obj format
22:38 - Grass mesh
23:44 - Rendering meshes
24:24 - General notes and C++ code style
25:35 - Grass rendering and shaders
26:32 - Handling a time variable for shaders
27:14 - Storage buffers in OpenGL
28:25 - Reduce complexity in hot code paths
29:00 - How grass is actually rendered
29:50 - Grass vertex shader
32:11 - Use mat3 instead of mat4
33:13 - Reduce vertex shader complexity
34:22 - Don't reallocate GPU buffers
35:28 - Inspecting rendering using Nvidia Nsight
37:13 - Set buffer data instead of reallocating
39:36 - Grass fragment shader + improvements
41:46 - Adding variance to grass blade color
This video is sponsored by Brilliant.
#CodeReview

Пікірлер: 191
@TheCherno
@TheCherno Жыл бұрын
Hope you all enjoyed this one! If you have anything to add drop a comment below 👇 Also hurry and visit brilliant.org/TheCherno to get started learning STEM for free! The first 200 people will get 20% off their annual premium subscription.
@oamioxmocliox8082
@oamioxmocliox8082 Жыл бұрын
;)
@CodeParticles
@CodeParticles Жыл бұрын
@The Cherno, spot on code review. I always learn a tidbit or two from these and they all add up over time, thx! 👍👍👍
@gwch3481
@gwch3481 Жыл бұрын
graphics programmers don't touch grass, they would rather generate and render virtual grass and touch the screen.
@nielsbishere
@nielsbishere Жыл бұрын
Can confirm. Sauce: am
@axelanderson2030
@axelanderson2030 Жыл бұрын
Yep
@WireWhiz
@WireWhiz Жыл бұрын
If you're a VR dev you can even "touch it"
@stuntfax9004
@stuntfax9004 Жыл бұрын
UNDERRATED COMMENT 😂
@lolcat69
@lolcat69 Жыл бұрын
i can confirm wath you say, cuz as a game dev i will make an entire game just to make a virtual hand touch virtual grass...
@Acerola_t
@Acerola_t Жыл бұрын
0:30 oh hey I know that guy
@FullGardenStudent
@FullGardenStudent Жыл бұрын
Me too!
@RetroMMO
@RetroMMO Жыл бұрын
have my babies
@Acerola_t
@Acerola_t Жыл бұрын
@@RetroMMO okay
@kalechips22
@kalechips22 16 күн бұрын
Uhmmmmmmmm
@squelchedotter
@squelchedotter Жыл бұрын
I really don't like middle star because it makes a lot of type definitions look a lot like multiplications
@amadeusk525
@amadeusk525 Жыл бұрын
Yeah, I don't like the trailing star either. The only way to go is leading star. Leading star gang
@theRPGmaster
@theRPGmaster Жыл бұрын
I think since since "pointer to x" is ultimately the type, the target type and pointer-star should be grouped together, just like Cherno did in the video.
@squelchedotter
@squelchedotter Жыл бұрын
@@theRPGmaster It should be like that, but it's not. If you write `int* a, b`, a will be a pointer but b will not. As far as the parser is concerned, the pointer is part of the variable name, not the type.
@gareth4168
@gareth4168 Жыл бұрын
@@squelchedotter I 100% agree. The * makes more sense to me associated with the type but, alas, the language does not work that way and int *foo is correct. K&R, the Linux Kernel etc and other big projects all do it that way.
@Goodwarrior12345
@Goodwarrior12345 Жыл бұрын
I actually type all my pointer (and reference) declarations like that. To me it just makes the most sense, that way it's really obvious if something is a pointer or a normal value, instead of being grouped together and your eyes potentially glossing over the thing. There's also semantic separation in it for me - an int is very different from an int pointer, and spacing the * out makes that fact more obvious. But if I'm working with them I always write it as &ref or *ptr, I'm not crazy enough for that. Probably part of why I picked up the habit was that our C/C++ teacher would insert spaces literally everywhere. I don't know if it's his personal style, or people used to just do it like that back in the day, but where you'd write "this->function(value1, value2)" he'd do something like "this -> function ( value1, value2 )". Never really got used to it and eventually I naturally got into a code style that's basically the common Java style, but the pointer star in the middle just kinda stuck I guess.
@Baffi1096
@Baffi1096 Жыл бұрын
16:20 There is a saying in our company, if you want speed, pass by value. Most of the time the compiler (especially with O2) will decide what is fastest and either pass by reference or by move semantics.
@mbg47971
@mbg47971 Жыл бұрын
i really wish you implemented all your suggested changes so that we could see the difference it makes
@yanisbdf
@yanisbdf Жыл бұрын
I was really frustrated...
@mehdouchbhk6445
@mehdouchbhk6445 Жыл бұрын
Really impressive how such young people are good at programming nowadays , i wrote my first line of code when i was 18 and only now in my early 20s that i started to really taking it seriously on learning programming and computer graphics. Real Props for that dude!
@maybutworse4409
@maybutworse4409 Жыл бұрын
A lot of young people have resources and networks to learn that weren't around even 2-3 years ago. Everybody knows somebody who codes now, and with more people picking it up, it's the new thing for nerdy kids to get into.
@To-mos
@To-mos Жыл бұрын
Having to code in the 90's was painful, it involved setting up EPROM erasers with UV lamps and old serial line PIC programmers that got compiled through windows 98. A custom C language called PIC C existed to allow using the chips. You basically had to design your own micro-controller from scratch and budget project kits like arduino, raspberry pi's(Technically SoC), esp32's didn't exist.
@treyquattro
@treyquattro Жыл бұрын
it is but I find not many understand the underlying architecture or code that gets produced. It's different for C++ programmers, or should be, since C++ is more tightly coupled with hardware, but people who only know Java or Python e.g., while they maybe hot at algorithms and data structures, would have a hard time debugging at assembler level. Similarly people have difficulty with pointers for the same reason - they're hardware-oriented. That said, there's less and less need to do hardware-level debugging outside of kernel, driver and embedded development.
@infinitesimotel
@infinitesimotel Жыл бұрын
@@To-mos Really? I don;t remember it being that problematic. We had desktops from Computer Shopper and Borland at least had turbo C and Pascal. We even played DooM on the college network LoL.
@infinitesimotel
@infinitesimotel Жыл бұрын
@@rnayabed Ah, OK.
@user-dh8oi2mk4f
@user-dh8oi2mk4f Жыл бұрын
32:20 AFAIK, for the GPU, a mat3 is just a mat4 with padded zeroes. GPUs don't have specialized mat3 registers, so a mat3 is just a mat4 which is treated like a mat3 in code.
@weirddan455
@weirddan455 Жыл бұрын
15:30 It's interesting whether pass by value or reference/pointer is better. Obviously it can differ case by case but I saw a video of Chandler Carruth at cppcon (Google employee, works on Clang and does a lot of talks about optimization). He said pass by value is often better even for semi-large structs. The reason is that compilers don't do optimization as well when they have to deal with memory. If you pass by value, the compiler knows the function has a unique copy of the data and can better optimize. That may be the reason why you said that code at EA performed better when you did so.
@Galakyllz
@Galakyllz Жыл бұрын
I really enjoyed this code review. The level of detail was great; I appreciate all of the small points you made, even if you think that you "took too long on those earlier parts", I'm learning something. Please, more of this.
@axelanderson2030
@axelanderson2030 Жыл бұрын
As an aspiring c++ developer (used python for 6ish years), I have trouble understanding code structure. I know it's subjective, but deciding where to put what and what should handle what is the biggest roadblock for me. It'd be helpful (for me at least) going over some structure and design. Syntax and implementation are no problem, however it always ends up being needlessly complex and I usually rewrite everything once or twice till I'm happy with it. Regardless, thanks for the video cherno, really appreciate your work. Keep it up!
@theRPGmaster
@theRPGmaster Жыл бұрын
Same. I've spent a riddiculous amount of time pondering where my public members should be declared, for example. Put them last in the class? Put them first and use an extra access specifier? Maybe struct instead of class? What about member functions? Indecisiveness kills productivity.
@JanVerny
@JanVerny Жыл бұрын
Proper code structure and correct use of design patterns etc. are just something that you figure out eventually with experience. Programming isn't like working in a manufacturing line, it's an art, and just like there is no best color for every painting, there is no best solution for all situations. And I wouldn't worry about rewriting and restructuring the code. Maybe one in a million novelists can write a book without ever going back to change something, but it shouldn't be anyone's goal to replicate that.
@axelanderson2030
@axelanderson2030 Жыл бұрын
@@theRPGmaster I feel you dude, hopefully with more practice this will get easier!
@Baffi1096
@Baffi1096 Жыл бұрын
There are the SOLID principles, which are nice to follow imho. But they can confuse new programmers. Structuring your code in a way, that you only interact with blocks of code through an interface is a very powerful idea. If you introduce some unit testing, in my experience the code structure follows from testing, since you need to find a good way to have small enough code, so that it can be tested separately
@theRPGmaster
@theRPGmaster Жыл бұрын
@@axelanderson2030 Det är nog bara mild OCD, like another guy above said: it might be subjective, so we should decide on our own best practices / style rules.
@cton3d
@cton3d Жыл бұрын
Please do the video on grass rendering, especially talking about LOD! Would love to see that :) Great video!
@evan_game_dev
@evan_game_dev Жыл бұрын
I'm with right gang. Asterisk goes with the variable. Another thing, I completely agree that fragmented memory is slow (not really much to agree on, that's just a fact) but to counteract that, I like to allocate a couple gibibytes of memory at the beginning and put all my non stack memory on there
@JamesTamesGames
@JamesTamesGames Жыл бұрын
heck yeah more Acerola recognition. Grass enthusiasts should definitely check out his channel.
@StevenMartinGuitar
@StevenMartinGuitar Жыл бұрын
Would love to see you make all your changes and upgrade the quality to make the absolute best grass rendering example!
@furball_vixie
@furball_vixie Жыл бұрын
I'm sure I'm not the only one who would love to listen to you talking about rendering grass, without you restraining yourself
@Zer0Flash
@Zer0Flash Жыл бұрын
the grass looked amazing damn, man has made grass in opengl and c++ when i still take 5 days of errors doing it in unreal engine while following tutorials
@theRPGmaster
@theRPGmaster Жыл бұрын
That's what made me start doing graphics programming from scratch, I used UE for a long time, but really it's too much of a spaghetti engine, the only people able to fix those bugs properly are those who made it. The codebase isn't written to be easily extensible/patchable by independent devs.
@peezieforestem5078
@peezieforestem5078 Жыл бұрын
You imply that it's more difficult to do in OpenGL and C++, but I'd argue that it is easier than in a high-profile game engine like Unreal. It's similar to what Cherno says in the beginning, that overabstraction is not needed on simple projects, and that actually simplifies the task. Same with OpenGL and C++, simple projects are actually easier without Engines, I'd argue.
@zvxcvxcz
@zvxcvxcz Жыл бұрын
@@peezieforestem5078 Yup, I can never seem to figure out these stupid engines. Always seems like there's a million arbitrary cryptic steps to the incantation and you invariably forget one.. and no amount of logic or thinking will let you fix that, just need to hunt up and down the UI and search for a tutorial or something like that... OpenGL, yes, it's a lot of additional code to write, but at least it's code and you wrote it so you know where the hell to find it and fixing it works by the rules of the logic and the programming language, no voodoo required.
@vasaaviarion
@vasaaviarion Жыл бұрын
Sometimed I forget how late I started programming. Im 23 and wrote my first line of code a couple months ago. Its still quite cryptic to me, but I hope to one day make and release my own video game
@bluehornet6752
@bluehornet6752 Жыл бұрын
I absolutely *LOVE* this type of content, Yan! As someone with a few college degrees including a doctorate, I've basically devoted my life to life-long learning. I've been following you for years now on KZbin and really must compliment you, as you've developed into an excellent educator. You've always been an excellent C++ developer, and inspire me (read "kick my ass") to push myself to become a better C++ developer with each and every one of your videos I watch. Thank you for making this type of content. I'm incredibly impressed with the amount of effort that this young man has devoted to this project. It's awesome that you took the time to not only do a code review of his code, but also to demonstrate techniques to make it better. I'm not even an OpenGL developer, and I learned a bunch from watching this video. Perhaps the biggest compliment I can give you is to tell you that of all the videos out there these days with what I call "in-content advertising" (ie; the content creator does the commercial live during the video), the commercial you did for Brilliant.org is the only one I've actually watched for months and months now. Usually I just scroll through them, but I watched yours--and even went there and signed up using your 20% discount. So thanks for that as well... I have to say I had my doubts as to the path your channel would take when you left EA and charted this new course, but I'm very happy to see where you're taking it--it's really working very well, and you've really grown into the role. You are *easily* one of the most educational development channels I've ever seen on KZbin. And finally to Nathan: GREAT JOB on this code! Yan gave you some incredible tips, and I'm sure you will grow as a developer if you understand and implement them. I wish I would have been half the developer you already are, when I was 15.
@stburton00
@stburton00 Жыл бұрын
For the SSBO update you may see some speedup if you orphan the data (see: OpenGL buffer orphaning) before the grass positions upload, instead of using glBufferSubData. As written, with glBufferSubData (or glBufferData without orphaning) it could force a sync between the CPU and GPU as the pending GPU draw commands that read from the buffer must complete before the new buffer upload to ensure that the memory is not stepped on while it's in flight, since all draw commands are sourcing from the same buffer (if I understood the code correctly).
@rbaleksandar
@rbaleksandar 11 ай бұрын
Great video. And through it I discovered the existence of RenderDoc. Thanks a bunch! :D
@Dagrond
@Dagrond Жыл бұрын
Love these reviews, learn so much.
@zami001001
@zami001001 Жыл бұрын
its worth noting that trig functions on GPU specifically, at least for sin, cos and tan, are done on the hardware layer directly and end up being only slightly more expensive than something like multiplication. This is of course vastly different that what would occur if you ran the same calculation on CPU which does not have a dedicated hardware instruction for those.
@chromosundrift
@chromosundrift 11 ай бұрын
Great way you handled the idea of program structure for such a small program. As code grows, the benefits of structure grows. I think if you make this point clearly, viewers can see how excess abstraction is problematic and yet tackle the perhaps intended question of how to restructure as the code base grows.
@Tegeran66
@Tegeran66 Жыл бұрын
Thank you very much for this review. Could you please tell me that did you press at 36:34 Nsight for correction memory structure? Thanks in advance.
@thehambone1454
@thehambone1454 Жыл бұрын
I learned a lot from this! I might submit something at some point!
@VictorMistral
@VictorMistral Жыл бұрын
For the mat4 that can be faster in not const& in some cases, well that's a register. 64byte, is only a few registers, so it can be passed by register, and that is faster then a memory access that the ref needs, even if the referred memory is in the stack and in cache... But there is a limited amount of register, pass a certain point, it will move the params to the stack instead of register, and that can slower then the ref due to stack move + copy then memory access...
@loli42
@loli42 Жыл бұрын
I LOVE CHERNO CODE REVIEWS!!!
@HazStepFTW
@HazStepFTW Жыл бұрын
Possibly the greatest Cherno thumbnail to date 🤣
@ultimatesoup
@ultimatesoup 8 ай бұрын
I took a look at hazel. It's pretty neat but has a long ways to go. I would suggest having an components class with all static elements though as opposed to singletons because that way you can control their initialization and destruction
@rmt3589
@rmt3589 4 ай бұрын
Isn't that more OOP than ECS? I prefer OOP, but I don't think Cherno does.
@chill_edits1924
@chill_edits1924 Жыл бұрын
TNice tutorials just made it so clear to thank you so much
@zxuiji
@zxuiji Жыл бұрын
39:15 I think a better way to speed it up would be maybe have a single 2048x2048 buffer (perhaps smaller or bigger, not giving heavy thought to this for now) to generate then use for every tile, no re-generating positions of grass blades, just make it dense enough that it difficult to notice it's being reused, as for when the grass should be sparse, still use the same buffer but just min/max blade opacity based on the meshes seed value for rand_r(), if it doesn't have one make it.
@elderdragon7856
@elderdragon7856 Жыл бұрын
The thumbnail so funny 🤣
@gwch3481
@gwch3481 Жыл бұрын
Welcome to _grass_
@william383
@william383 Жыл бұрын
A video on grass rendering in hazel would be really cool
@johanrojassoderman5590
@johanrojassoderman5590 Жыл бұрын
I generally like having the asterisk next to the type, which is nice when you want to define functions without naming the parameters: void operation(type*, type*) It's not as nice when trying to declare multiple pointers at once though. int* a, * b, * c In the last case I tend to just write the pointer next to the name.
@BaJoBr
@BaJoBr Жыл бұрын
15:16 std::string_view is not guaranteed to be null terminated which is what opengl expects, std::string is though, something to keep in mind. Taking an std::string_view would require extra validation and possibly copy to add null.
@BrandNewByxor
@BrandNewByxor Жыл бұрын
25:03 it's interesting that you mention dropping the `{` onto a new line for function definitions. I've been in the "put it on the same line" gang for years now, but I sometimes find myself adding an empty line at the top of the function body anyway as a way to fight back against the density. I never thought about it though or how the ` {` would fix it
@rmt3589
@rmt3589 4 ай бұрын
I'd rather have a blank line than drop it. It's what I've always did in CSS, and is standard with how I write. Even if I wanted to drop it. If I genuinely tried, it'd become inconsistent. As I'd have to edit it every time.
@StarCourtesan
@StarCourtesan Жыл бұрын
I like this form of content
@tfbhalaleo2546
@tfbhalaleo2546 Жыл бұрын
I have a question: if header files can't compile and make an obj file, how can we run a project, it has only a header file (main function definition in this file)?
@samvodopianov9399
@samvodopianov9399 Жыл бұрын
When the world needed him most, he came back.
@Photon852
@Photon852 Жыл бұрын
is there a way to make a vulkan/opengl application outside the windows/default main window?
@oystercatcher943
@oystercatcher943 Жыл бұрын
Just seen first few mins. This is super impressive for a 15 year old. Especially in C++ and after a years(!) of Java
@__hannibaal__
@__hannibaal__ Жыл бұрын
This code and view i had seen 20 years ago; when i start with OpenGL and my theses on Topology of Fractal geometry.
@m.hosseinmahmoodi
@m.hosseinmahmoodi Жыл бұрын
Am I the only one who didn't know Visual Studio had a 3d model viewer?
@thehambone1454
@thehambone1454 Жыл бұрын
Do you in general try to avoid heap allocation?
@sureshrawal7913
@sureshrawal7913 Жыл бұрын
I have a question how I can start with opengl c++ like you is there any video how to set up openGL and c++ in pc
@Goodwarrior12345
@Goodwarrior12345 Жыл бұрын
hey I'm middle gang! Seemed like the most intuitive way to type in pointers to me when I was learning about them so I stuck with it.
@sashareinhard6645
@sashareinhard6645 24 күн бұрын
me too, except i do it to be different
@suzanne4300
@suzanne4300 Жыл бұрын
I really like the Ray Tracing series. when will the next video come?
@perkele1989
@perkele1989 Жыл бұрын
I was “middle gang” for a while, though to clarify it wasn’t really in the middle. It was aligned to the variable name, but with a space between. Just happened to fall into the middle when it wasn’t aligned to other similar locs, if that makes sense.
@paccc
@paccc Жыл бұрын
You mentioned UBOs, could you maybe do a video on Uniform Buffer Objects for the OpenGL series.
@TristanWalter
@TristanWalter 7 ай бұрын
i think the pointer star belongs next to *window like this, since if you have multiple pointers you‘d have to repeat the * too
@zxuiji
@zxuiji Жыл бұрын
30:52, simple solution, keep the flat plane, rename the y axis to z axis, decide grass xz as usual but before generating any further detail just see if there's a top view triangle of the mesh that encompasses the blade position, if yes then decide the blade's y position based on the triangle's vertices, if no then the blade is never finished or rendered
@flowmanSF
@flowmanSF Жыл бұрын
What color scheme are you using?
@tilaktankasali8756
@tilaktankasali8756 Жыл бұрын
Hi, i want the c++ software to my computer please help me to find it, can you give the link to download the software
@jeevan1874
@jeevan1874 Жыл бұрын
Where to learn these advanced topics?
@command1989
@command1989 4 ай бұрын
15:15 std::string_view should not be used to pass strings to C-like APIs like OpenGL, which take strings as const char*, because they typically expect null-terminated strings. string_view does not necessarily point to a null-terminated string, which can make for some painful debugging.
@masheroz
@masheroz Жыл бұрын
Re abstracting: I want to know that sort of thing. I am writing a gui program using walnut, and the abstractions in there were all new to me.
@Mozartenhimer
@Mozartenhimer Жыл бұрын
I became middle star when I was learning C++. It just made more sense to me that this a" character pointer" which in C++ land is char *. I might go to lhs gang though.
@kirillarionov123456
@kirillarionov123456 Жыл бұрын
Please credit the Acerola! He did actually make a video about grass rendering. And from what we can see apart from the implementation the ideas are the same!
@firdodev9416
@firdodev9416 Жыл бұрын
Yoo cooolll
@shanewalsch
@shanewalsch Жыл бұрын
What font is that?
@sflashy6850
@sflashy6850 Жыл бұрын
wish you review projects that has written in c#
@orangasli2943
@orangasli2943 Жыл бұрын
@15:54 Luckily you show it there that pass by reference is valid for immutable object like std::string by passing it's constant object reference..maybe I should watch your video again
@johnpomaro1731
@johnpomaro1731 Жыл бұрын
LOL!... Great thumbnail!!
@DavidGispert
@DavidGispert Жыл бұрын
color theme?
@nieznanyprzesladowca120
@nieznanyprzesladowca120 Жыл бұрын
Regarding code formatting, why don't we just let formatting and naming convention left to the static analyser tools?
@thedebapriyakar
@thedebapriyakar Жыл бұрын
grass reminds me of the good old days
@fraelitecagnin7628
@fraelitecagnin7628 Жыл бұрын
It would be cool to see some Rust videos! Have you already tried it?
@prafulkhanduri542
@prafulkhanduri542 Жыл бұрын
@ The Cherno I llearned c++ but I won't get how can I start the advance c++ and what are the topics in it can you tell it please .and more then stuck on problem solving with c++ I want to work with in applications using c++.
@faik...
@faik... Жыл бұрын
can you please talk more about the grass
@erne75
@erne75 Күн бұрын
Small observation. Inside his classes interfacing with OpenGL he should be speaking OpenGL "language". Meaning he should be using/casting to OpenGL types.
@on-hv9co
@on-hv9co Жыл бұрын
Alright, I'm settled. Converting to middle gang
@ermilburn02
@ermilburn02 Жыл бұрын
Since when did Visual Studio have a model viewer?
@theEndermanMGS
@theEndermanMGS Жыл бұрын
I believe it was added in VS 2017. I vaguely remember hearing about it around that time, and that's the first version that has a mention of a 3D model editor in the docs.
@Coughyyee
@Coughyyee Жыл бұрын
Theme?
@ultimatesoup
@ultimatesoup 8 ай бұрын
You have a pretty decent knowledge of graphics. Check out the book real time rendering to get even better as well. I like it cause there is literally no code...it just describes the methods used. You're getting pretty good though. I'll send you my engine one of these days...it's over 100k lines though cause I've been working on it for years
@thev01d12
@thev01d12 Жыл бұрын
Still waiting for your vs color scheme
@awmachanel2816
@awmachanel2816 Жыл бұрын
Thank you tNice tutorials really helped!!!!!!!!!!!!
@user-sl6gn1ss8p
@user-sl6gn1ss8p Жыл бұрын
remarkably little roasting on this one
@MK-bx8xv
@MK-bx8xv Жыл бұрын
I always ditch hungarian notation, even for members. I just append a '_' at the end of the member (e.g. u32 fragement_shader_id_).
@laenprogrammation
@laenprogrammation Жыл бұрын
i'm not quite sure passing 64 bits of data by reference create increased performance at all. I mean it will likely be evaluated using a pointer (except if your function gets inlined), so you are still passing a 64 bit value anyway
@wintermute1814
@wintermute1814 Жыл бұрын
It’s 64 bytes. But yeah this could get inlined in which case passing by value would be faster
@crusaderanimation6967
@crusaderanimation6967 Жыл бұрын
2:40 Dear Lord, DId you touched it ? DID YOU TOUCHED IT ?
@xravedogx
@xravedogx Жыл бұрын
Imo the * should be next to the type, since it's part of the type. Never understood why some prefer it next to the name.
@not_ever
@not_ever Жыл бұрын
I do not agree, for the same reason this won't compile. int* a, b = nullptr; or that this does compile but doesn't do what a lot of people might assume that it does: int* a, b; However since it is possible to write the second example, keeping the * by the varible name is perfectly understandable. To be clear no one should be writing code like the above, and, int *a, *b = nullptr; is a recipe for disaster that isn't doing what a lot of people probably expect either.
@jeffg4686
@jeffg4686 Жыл бұрын
You gotta move to Bevy. Bevy is where it's at.
@RAMANKUMARGCEBIT
@RAMANKUMARGCEBIT Жыл бұрын
wow
@emmetray9703
@emmetray9703 Жыл бұрын
please review this : int x = 9;
@alexmercerind
@alexmercerind Жыл бұрын
Approved. You'll live. - Putin
@OfficialGamingNetwork
@OfficialGamingNetwork Жыл бұрын
Very unoptimised and clunky. Disappointed.
@on-hv9co
@on-hv9co Жыл бұрын
auto x{9}; please
@emmetray9703
@emmetray9703 Жыл бұрын
@@OfficialGamingNetwork you broke my heart
@emmetray9703
@emmetray9703 Жыл бұрын
@@on-hv9co you are not a C programmer .
@peronohaynada
@peronohaynada Жыл бұрын
looks like some "mistakes" may be cause the developer is used to java that primitive types are initialized when instantiating a class. I'm a java dev too so I don't see anything wrong in their code lol
@treyquattro
@treyquattro Жыл бұрын
structs aren't heap allocated in C++? News to me! You can allocate anything from the heap. A struct is semantically identical to a class other than the default access control (everything is public by default in a struct, private in a class). Similarly you can allocate classes on the heap, the stack or static memory in C++. I know you know this, I just found the statement misleading, probably because you were trying to identify differences with default Java (or C#) behavior?
@TheCherno
@TheCherno Жыл бұрын
I said they're stack allocated in C#, not C++. Structs in C# are value types, classes are reference types.
@glorioussir9673
@glorioussir9673 Жыл бұрын
Middle gang!
@mudlee1058
@mudlee1058 Жыл бұрын
15 years old, my gosh. I dont even remember what kind of toy I was playing with at that age...
@AlDumbrava
@AlDumbrava Жыл бұрын
Middle gang!!!!! :D
@onogrirwin
@onogrirwin Жыл бұрын
cute hair bro
@aarorissanen930
@aarorissanen930 Жыл бұрын
Cherno touched grass?!?
@1008OH
@1008OH Жыл бұрын
Middle pointer gang
@sashareinhard6645
@sashareinhard6645 24 күн бұрын
MIDDLE GANG!!!
@m4rt_
@m4rt_ Жыл бұрын
Card review? 0:00
@zhabiboss
@zhabiboss Жыл бұрын
The thumbnail 💀
@nicom9853
@nicom9853 Жыл бұрын
All my homies hate middle pointer gang....
@vijendranayak3457
@vijendranayak3457 Жыл бұрын
sa here
@anon_y_mousse
@anon_y_mousse Жыл бұрын
When someone tells you to touch grass, you really take it seriously.
@vegetableball
@vegetableball Жыл бұрын
When I was 15, the best thing I know was calculus.
All about MEMORY // Code Review
33:42
The Cherno
Рет қаралды 154 М.
I made it FASTER // Code Review
38:46
The Cherno
Рет қаралды 515 М.
Did you find it?! 🤔✨✍️ #funnyart
00:11
Artistomg
Рет қаралды 125 МЛН
Eccentric clown jack #short #angel #clown
00:33
Super Beauty team
Рет қаралды 27 МЛН
КАРМАНЧИК 2 СЕЗОН 5 СЕРИЯ
27:21
Inter Production
Рет қаралды 596 М.
WHY did this C++ code FAIL?
38:10
The Cherno
Рет қаралды 104 М.
Adding This One Thing Made my Game Look 327% Better
6:11
OverPhil Dev
Рет қаралды 82 М.
PATH TRACER made by 15-YEAR-OLD in C++ OpenGL! // Code Review
36:56
How Are Games Rendering Fur?
28:51
Acerola
Рет қаралды 413 М.
Understanding Code You Didn't Write // Code Review
27:15
The Cherno
Рет қаралды 65 М.
How Ray Tracing (Modern CGI) Works And How To Do It 600x Faster
32:06
Josh's Channel
Рет қаралды 556 М.
What I Did To Optimize My Game's Grass
8:13
Acerola
Рет қаралды 121 М.
Giving Personality to Procedural Animations using Math
15:30
t3ssel8r
Рет қаралды 2,4 МЛН
how this game renders millions of blades of grass
5:03
Stylized Station
Рет қаралды 368 М.
Did you find it?! 🤔✨✍️ #funnyart
00:11
Artistomg
Рет қаралды 125 МЛН