I'm using a class called UICanvas, this class has a texture that is used by child-objects to render to.
I use SDL_SetRenderTarget to achieve this, and it works quite well, but when i toggle to fullscreen, the whole screen uses the canvas-texture as a screen texture for some reason. Is this a bug, or have i done something wrong?
This is the draw-function for the canvas class, the m_canvas is a texture used for the childobjects to draw to.
void UICanvas::draw( SDL_Renderer* onWhat, Uint32 deltaTime )
{
/* Change rendering target to the canvas. */
SDL_SetRenderTarget( onWhat, m_canvas );
/* Fill with background color */
Color old;
SDL_GetRenderDrawColor( onWhat, &old.r, &old.g, &old.b, &old.a );
SDL_SetRenderDrawColor( onWhat, m_color.r, m_color.g, m_color.b, m_color.a );
SDL_RenderFillRect( onWhat, NULL );
SDL_SetRenderDrawColor( onWhat, old.r, old.g, old.b, old.a );
/* Draw child textures on the canvas. */
drawChildren( onWhat, deltaTime );
/* Reset to default rendering target */
SDL_SetRenderTarget( onWhat, NULL );
/* Position and render canvas */
Point2Df abs( getAbsolutePosition() );
Rectangle dest( static_cast<Sint32>( abs.x ), static_cast<Sint32>( abs.y ), m_width, m_height );
SDL_RenderCopy( onWhat, m_canvas, NULL, &dest );
}
Whenever I toggle fullscreen the whole screen goes white. This is the function I use to toggle fullscreen:
void Application::toggleFullscreen()
{
Uint32 flags( SDL_GetWindowFlags( GE_SYS.window ) );
flags ^= SDL_WINDOW_FULLSCREEN_DESKTOP;
SDL_SetWindowFullscreen( GE_SYS.window, flags );
SDL_DestroyRenderer( GE_SYS.renderer );
GE_SYS.renderer = SDL_CreateRenderer( GE_SYS.window, -1, SDL_RENDERER_ACCELERATED | SDL_RENDERER_TARGETTEXTURE );
//SDL_SetRenderTarget( GE_SYS.renderer, NULL );
}