Designing Our Pixel Renderer // Remaking My First Game in C++

Поделиться
HTML-код
  • Опубликовано: 23 янв 2025
  • Support ► / thecherno
    Follow ► / thecherno
    Twitter ► / thecherno
    Discord ► / discord
    #Genesis

Комментарии • 59

  • @verminology9999
    @verminology9999 Год назад +7

    Love these videos. I enjoy seeing your thought process and how everything is being done on the fly. Very educational!
    I would love to see your key presses on screen. You work so efficiently, and it would be beyond helpful to learn what shortcuts you're using to speed up your workflow.

  • @zhulikkulik
    @zhulikkulik Год назад +2

    Something's with audio, i think it started near the end, or at least I didn't notice it until the last third of the video.
    Sounds as if mic recording is layered on top of webcam audio recording or there's some band-pass echo effect.

  • @Balouxe
    @Balouxe Год назад +3

    Great video! The mic sounds great, however around 23:00 your voice seems kinda doubled, as if you were using both your microphone and the camera microphone at once.

  • @maxi-g
    @maxi-g Год назад +2

    the audio sounds like there are two vocal tracks on top of each other with a little delay

  • @nextlifeonearth
    @nextlifeonearth Год назад +7

    You can just put the m_imageData in a unique_ptr too. Saves you the hassle with delete and the destructor.
    std::unique_ptr bla = new uint32_t[200]; works just fine.

    • @paulredmond6467
      @paulredmond6467 Год назад +3

      Or just use std::vector..

    • @justonefra
      @justonefra Год назад +1

      @@paulredmond6467 That is unnecessary as the size is constant between frames (except for when resizing) and wouldn't help much

    • @erikabutler6893
      @erikabutler6893 Год назад +1

      @@justonefra It would be helpful, because the vector can manage resizes for you. The thing about vector is that it often keeps more memory than it needs, so Cherno could avoid most of the reallocations from the resizing and vector never shrinks when you remove items. Whenever he goes onto a new size, he can just call clear() on the vector and then insert the number of items needed.
      He can then pass the vector's internal array to the Image object via the vector's data() function.

  • @serhiih.4724
    @serhiih.4724 Год назад +4

    I don’t know if my message will reach your eyes , but thank you very much for content and c++ lessons ! When I started with C++ many years ago I was struggling so much with be able learn only from books …

  • @KyleKatarn145
    @KyleKatarn145 Год назад +4

    I think you writing your code how you would now would be much more interesting and useful than an almost straight copy+paste, half of what interested me about this series is hearing you take a "what would I do now?" approach

  • @karatsu44
    @karatsu44 Год назад +9

    Audio plosives and S are a bit hard maybe consider a pop filter - and boost a bit the sound. Quality is good as your content in general

  • @mobslicer1529
    @mobslicer1529 Год назад +1

    i do my includes in the opposite order and change it until it compiles if necessary

  • @malckhazarsteamcat9817
    @malckhazarsteamcat9817 Год назад +2

    1. Why didn't you kept the sprites in a map with the enum as key? I guess it would look not so terrible.
    2. Loop with setting value to ImageBuffer in Renderer::Clear function:
    for (uint32_t i = 0; i < m_Width * m_Height; i++)
    m_ImageBuffer[i] = clearColor;
    can be changed to single call from standard library:
    memset(m_ImageBuffer, clearColor, m_Width * m_Height * sizeof(uint32_t));
    which is faster since it uses SSE/AVX optimizations (you'll need only to align the buffer on recreation).

    • @TheCherno
      @TheCherno  Год назад +6

      1. We're just getting started with the sprites API and won't keep it like this
      2. Can't use memset here because we're trying to set uint32_t's and not bytes - for eg. Clear(0xffff00ff) won't work with a memset (not to mention the for loop is more than fast enough and will also be optimized)

    • @ABaumstumpf
      @ABaumstumpf Год назад

      As the variable clearColor is just a normal parameter the compiler likely is smart enough to convert it to movdqu or other larger instructions. Just for readability though i would suggest using std::fill - tells you that the memory is filled with that value. (well, a C++-version of memset would be nice - one that can be used with other things then char* ).

  • @anjaysahaniara
    @anjaysahaniara Год назад

    So much for being there

  • @paradox8425
    @paradox8425 Год назад

    I think you should make spritesheet ignored color as alpha 0 from pink as a little challange (not as a some part of project, just as a temp code for this task)
    It could be very good for learning more stuff

  • @CreativeOven
    @CreativeOven Год назад

    Great series! : D

  • @KernelNinja_
    @KernelNinja_ Год назад +5

    Why not to use std::vector for imageBuffer or unique_ptr ?

  • @anuhasjayawardana9905
    @anuhasjayawardana9905 Год назад +18

    god, I wish cherno used something like SDL or SFML for this one. It'd have been a thousand times much more interesting. Looking at him code in an API that I have absolutely no experience with just doesn't hit the same :(

    • @zhulikkulik
      @zhulikkulik Год назад +3

      I wish SDL had a consistent wiki that is at least half as detailed as Unity's wiki :(
      It's really a mess and some things don't even have a wiki page.

  • @OscarCS
    @OscarCS Год назад +1

    Any tips for learning cpp coming from a Java background

    • @popcultureprogrammer2171
      @popcultureprogrammer2171 Год назад

      learn you should probably go back to Java if you want to maintain sanity, or learn you should have never learned java if you want something that runs fast

    • @gaafts
      @gaafts Год назад +1

      Cpp and java are fairly similar. I believe Java was inspired by C++; the folks at Oracle wanted a more controlled and simplistic language so that “Everyone could code.”
      The main difference between C++ and Java is that in C++ you manage your own memory. All objects in Java are passed by reference, and the task of freeing memory is managed by the garbage collector (which is pretty well optimized these days in Java - and is probably not your performance bottleneck). In C++, you can choose to pass by value or by reference, and can even choose whether to free your own memory or have it be garbage collected. The goal of C++ is choice.
      The transition isn’t hard if you know Java already, but beware of using C++ specific features like smart pointers or operator overloading at the start. You can get sucked down a rabbit hole with feature creep. Like I said, C++ is about choice and freedom, but you can only really appreciate those tools after you understand the essence of the language. Otherwise it’s super easy to dig yourself in a really deep hole.

    • @erikabutler6893
      @erikabutler6893 Год назад

      I would start by saying that there's more to the difference between the two than just that you "manage your own memory" with C++. And I'd say in modern C++, memory management is less important than in determining ownership of pointers. That is, determining who is responsible for cleaning up the mess afterward. That's the point of unique_ptr and shared_ptr. (And you can still pass the pointer to functions if you use unique_ptr by calling its get() function; you do this when you don't intend to pass ownership to the function, when it just needs to access it.)
      Other considerations would be don't declare stuff as pointers or references if you don't have to. In C++, objects (and this concept has a very broad definition in C++) are by default value types, and you should take advantage of that.
      In addition, you should make heavy use of the standard library, which is designed to be efficient. Cherno above should have put the data in a vector, for example. There are various highly useful algorithms you can use to simplify the layout of your code.
      More tips can be found in the ISO C++ FAQ and the C++ Core Guidelines.

  • @vavanbonus
    @vavanbonus Год назад

    @TheCherno. Hey Yan! Nice videos! Sound is very deep now, I like it. by the way, what keyboard do you use?

  • @nathans_codes
    @nathans_codes Год назад +1

    C++ is not complicated, it's just confusing

  • @almighty1984
    @almighty1984 Год назад +1

    Why not using modules?

    • @theEndermanMGS
      @theEndermanMGS Год назад +2

      Module support is very, very spotty right now. Visual C++ is the only compiler with module support that you could reasonably call production ready, and I think even that is a stretch, not to mention that build tool support is almost nonexistent. Maybe using modules will be worth it in a year or two when things have become more stable, but not yet.

    • @ChrisCarlos64
      @ChrisCarlos64 Год назад +1

      As someone using modules in some small projects (in scope to his engine stuff) while great, they have a big drawback in tooling support. Visual Studio has the best support, but it's still really spotty. I personally have encountered broken intellisense (though it has gotten better over time), and syntax highlighting is also busted because of it from time to time. The parser just gets confused with the "import" statements or something.

    • @almighty1984
      @almighty1984 Год назад

      @@ChrisCarlos64 Yeah it's definitely buggy, IntelliSense doesn't work for me either and have had to include std headers in the global module. Still for me I think it's worth it.

  • @andreyprotsenko9855
    @andreyprotsenko9855 Год назад

    Hey, Cherno! Awesome video and series!
    How did you set those not equal symbols in VS?

  • @SSouper
    @SSouper Год назад +29

    What's your opinion on Rust? A video comparing C++ to Rust would be cool.

  • @Wild.WolfGames
    @Wild.WolfGames Год назад +3

    Hi, Cherno. Do you recommend any book or other resource for a beginner in c++ for windows (with GUI)?

    • @RyNiuu
      @RyNiuu Год назад +2

      There's a beautiful Harvard CS50 lecture on yt. 25h total and much of it in C++. Why book?

    • @FirstLast-bo7ef
      @FirstLast-bo7ef Год назад +2

      ​@RyNiuu some people learn better from reading than videos, each people are different

    • @AliceErishech
      @AliceErishech Год назад +2

      @@FirstLast-bo7ef Also helps when people actually know where to find such a lecture. Just mentioning it but not bothering to provide a link doesn't really help.

    • @user-sl6gn1ss8p
      @user-sl6gn1ss8p Год назад +1

      @@AliceErishech I guess he means this /watch?v=IDDmrzzB14M&list=PLhQjrBD2T380F_inVRXMIHCqLaNUd7bN4
      no idea how much does this go into GUI tho

  • @jesseemmoth5482
    @jesseemmoth5482 Год назад

    I think you should go with the sm7b! If output is the issue just get a fethead with it. Great content otherwise

    • @Bassalicious
      @Bassalicious Год назад

      Fits his voice and the youtube-vibe more than the tlm102, I agree.

  • @didodido883
    @didodido883 Год назад +1

    microphone was good enough.

  • @prabhatgaurav5740
    @prabhatgaurav5740 Год назад

    Hi cherno, Can we connect once.
    I wanna get some valuable knowledge from you.

  • @Jorgen12
    @Jorgen12 Год назад

    Please make a DirectX video!

  • @Jkauppa
    @Jkauppa Год назад

    maybe a puff filter

    • @Jkauppa
      @Jkauppa Год назад

      languages: k.i.s.s.

  • @HonsHon
    @HonsHon Год назад +1

    Okay, genuine question: Why do you always look depressed in your thumbnails?
    Not trying to sound rude, but I do want to remind you that you have a great engine, a following, and a really great amount of skills that give you a bunch of avenues in life. Love your channel and hope that you are doing alright in your life!

  • @GamingStudiosX
    @GamingStudiosX Год назад

    hi (ayo im fourth comment)

  • @Alperic27
    @Alperic27 Год назад

    bad idea: make a ‘renderer’ responsible for resizing… … 🤦‍♂️🤦‍♂️🤦‍♂️ .. seriously?!

  • @joysaha3927
    @joysaha3927 Год назад

    First

  • @lanchanoinguyen2914
    @lanchanoinguyen2914 Год назад

    Making your first game? Lol we are not kids

  • @appsenence9244
    @appsenence9244 Год назад +1

    Do you ever consider making mathematics videos? Mathematics that would be used in rendering? Ray tracing and so on?

    • @mjthebest7294
      @mjthebest7294 Год назад +1

      He did some in the Raytracing series