The SDL forums have moved to discourse.libsdl.org.
This is just a read-only archive of the previous forums, to keep old links working.


SDL Forum Index
SDL
Simple Directmedia Layer Forums
Question regarding good practices / habits
GunnDawg


Joined: 25 Jan 2016
Posts: 6
I'm new to SDL and game development in general (not so much C and C++ programming though) and am curious on a few things that may or may not be considered bad practice. I'm going to be creating a simple game at first that has a sky and some ground textures (sprites). The sky will be using a static blue color and was wondering if the way I am currently handling that is considered wrong or a bad habit.

Code:

SDL_SetRenderDrawColor(_renderer, 135, 206, 235, 255);
SDL_RenderClear(_renderer);
SDL_RenderPresent(_renderer);


So as you can see I'm just using SDL_SetRenderDrawColor to draw the entire screen the sky blue color rather than creating a texture out of a surface (SDL_CreateTextureFromSurface) and then drawing that texture to the screen. This way I can just draw the sprites where I need them leaving any remaining space to appear as the sky, which as far as I'm concerned would look the same as drawing a blue colored texture behind it all.

So maybe it's just a matter of opinion when both methods produce the same results, but I'd still like to get an opinion before adopting bad practices and habits.

Thank you folks.[/code]