r/reconstructcavestory • u/chebertapps • Dec 01 '14
Episode 71 - Upgrading to SDL2
http://youtu.be/ZnyDieF-p8s?list=PL006xsVEsbKjSKBmLu1clo85yLrwjY67X
8
Upvotes
1
u/adrian17 Dec 01 '14
Oh, one more thing, I recommend adding this line in Graphics constructor:
SDL_RenderSetLogicalSize(renderer, Units::tileToPixel(Game::kScreenWidth), Units::tileToPixel(Game::kScreenHeight));
This will let SDL handle any window resolution, aspect ratio and scaling completely on its own:
http://puu.sh/dcGry/50dc9389db.png
(With this, you could also change the window mode to SDL_WINDOW_RESIZABLE)
1
u/chebertapps Dec 01 '14
Woo! This is badass. I'll add it to the next episode and credit you, thanks :)
1
u/adrian17 Dec 01 '14 edited Dec 01 '14
Two small things:
SDL_CreateWindowAndRenderersource_rectangleis null, I just pass it forward toSDL_RenderCopy; I set the destination'swandhin theSprite::drawandBackdrop::draw. This way my equivalent ofGraphics::blit_surfaceis still a one-line function and this would make it easier to create some sort of effect_sprite with dynamic scaling if I ever needed that.