What is the best way to set background screen color


#1

What is the easiest way to set background screen. Right now, I’m using the following:

m_buffer = new Uint32[SCREEN_WIDTH * SCREEN_HEIGHT];

memset(m_buffer, 0, SCREEN_WIDTH * SCREEN_HEIGHT * sizeof(Uint32));
SDL_UpdateTexture(m_texture, NULL, m_buffer, SCREEN_WIDTH * sizeof(Uint32));

I know this is wrong, but I couldn’t find any other way.


#2

The best, and easiest, way of clearing the window to a specific color is by setting the clear color at the start of the program, by calling SDL_SetRenderDrawColor(). Then, in the main loop’s render function, clear the window with SDL_RenderClear() and the window will then be cleared with the color chosen as the clear color.


#3

Thank you, Naith

That was so much easier.