Advanced C++/Graphics Tutorial 43: Multiple Renderers, Lazy Init

preview_player
Показать описание
Today we pimp out our ball game with cool rendering effects! Also, we learn what lazy initialization is! Please make your own renderers and put the code in the comments below. I will feature the coolest ones in a video, and I'll put them in the description as well :D

Рекомендации по теме
Комментарии
Автор

Note for Code::Blocks users, just right click and select "Swap header/source" to switch between the header and source file. If one of the two is not open yet, it will open it and take you to it automatically.

You can also highlight what you want to copy in Code::Blocks, then click your middle mouse button (wheel) to copy it, then left click so nothing is highlighted and the next time you middle mouse click, it will paste it. Note, if you have anything highlighted, middle clicking will always copy, not paste. Also, it doesn't paste where your cursor is sitting, it pastes where your mouse is pointing, this can be a fast way to past something in many locations really quickly if you're careful. Ben has taught me just how great copy/pasting is! LOL (hey, lead by example! ;) )

NeilRoy
Автор

You are great! Thanks a lot! Wish you enough energy to follow this path to the win! :)
Keep it up!

romanch
Автор

hey budy i hope you have read my comment. I love your video, this video is the only that i have watched yet. I have estasy about your knowledge i found the man YOU who make really good videos about cpp in this range so that i thank you so much your videos have a nice day:)

vencelkocsis
Автор

Great tutorials. Really love the in depth knowledge you're sharing!
I noticed that the dropbox link is not working anymore... Anybody knows where I can download the code examples?

noxusss
Автор

A bug with selecting the balls with the mouse is the further down the screen I click, the further below a ball I have to click to select it. So a ball at the top of the screen I can click dead on it. One near the middle, I click just below it. One near the bottom I need to click farther below it. This is only off in the Y axis. The further down the ball is, the further below it you have to click. My screen is exactly 1920x1080.

NeilRoy
Автор

Whenever is set the gravity to left or right, my fps drops to below 5... That must be something in the ballcontroller or the grid right?

justsomeguywithamovi
Автор

If I say uniform_int_distribution<int> randomStuff(0, 1);, will it generate values 1 and 0 or just 0? (randomStuff(0, 1) = randomStuff(a, b) = a is min, b = max - 1 or b = max?)

DJoppiesaus
Автор

What IDE you use for c++ graphics program in Windows environment

avijitsamanta
Автор

When is your next video going to be? I want more pls! I love your videos.

kiwixfps
Автор

First, I just wanted to say thank you so much Ben. I haven't made it this far in these tutorials yet, but I've been learning so much. I do have a question/problem not code related though. I'm going to be without internet for about a month or so and I was wondering if there is a way to download videos or playlist on youtube so I can watch them with VLC. I found a program that I can install to do it, but I really don't like installing random software on my pc. Any help would be greatly appreciated.

veridiux
Автор

Any chance you could make a tutorial on implementing Lua in to Bengine?

Dick.C.Normous
Автор

This has nothing to do with the lesson, but on the right side of the editor you have a code "overview" thing that shows where you are in the code. How do you get that? Thanks!

nickhoff
Автор

Hi Ben, following ur tutorials, they are amazing.

Just wanted to say something interesting, maybe you know it but, I was testing some stuff related to rendering performance. With your batching and rendering optimization, I was able to render 100 000 brick blocks on screen. Have 35fps when all of them are on screen visible.

Then I went into Unity3D, put another for loop to put other 100 000 brick blocks onto screen, then I built it (Since Editor Play reduces framerate by 10x), opened up .exe with 100 000 block and whoala, 6fps :D

This means, your rendering optimization was really amazing, and it`s even better than Unity`s ones. (No collision on both builds)

Amazing work!

wrymen
Автор

Hi Ben,
 I am grateful for your work and so far I haven't found anything like this (of this high quality tutorials) anywhere on the web except here.
 Can I suggest for a code refactoring before going any further to more advanced tutorials? I would like to see how the objects that are currently constructed in the MainGame.cpp should be organized. Plus, some of the resource loaders are scattered while IOManager.cpp only loads png file. Should the level loader (and other file readers) be included in the IOManager as well?  Perhaps a tutorial on the engine structure followed by the refactoring? That would enable us to see the big picture followed by immediate practice on the implementation of a solid 2d game engine. Then perhaps after that IOManager can be expanded to handle tmx files and animated sprites as well?

yadashare
Автор

I'm getting the following error when running with the momentumRenderer for the first time :( BallGame(8529, 0x7fff7d0e4300) malloc: *** error for object pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug

jaap
Автор

We cannot access to the source code, in your dropbox URL says "404 Not Found". Could you fix it?

legendguard
Автор

I replace the annoying unique pointers with the following code...

if(m_program != nullptr) delete m_program;

...to the destructor and I will be using new to create m_program.
I dread seeing those unique pointers used, and honestly, I don 't see the advantage when I can just add a delete to the destructor (plus they look ugly). C++ seems to be getting uglier each year. :/

NeilRoy
Автор

Hi Ben! Huge problem here!

The partitioning works fine, 60 fps smooth, but if i play around with it for a while, suddenly the fps drop down to the floor.
So i wrote a counter to count the number of calls to the check_collision function, since the profiler clearly told me that the problem was there.
The result is that the problem is the update_function called within the cell,

if i only check collisions with neighbour cells, i get a function count like:
42359
42569
41993
43010
42040

but if i enable the collision within the cell, and play around a bit with the particles, i get something like
42593
43590
47003
52343
58293
and so on...

i'm out of ideas, because the ball list inside each cell seems to work fine, and my code seems identical to yours...any suggestion?
And if you have time, try to "stress" out your own game, because it's a problem that could not arise if you play with the game a little and have a powerful pc, so maybe you have this as well :) (though probably not, i surely screwd up somewhere :) )

DarkDrakman
Автор

Its perfectly fine to use vector<unique_ptr<T>> even if T is a polymorphic object... But I think you need to add a virtual destructor on the base class for this to work.. correct me if im wrong

PaulMetalhero
Автор

I accidentally swapped the random ball size with r2 instead of r1.. oh lord.

MrDritten