Sorry, for the long delay. I’ve been busy with other things.
So When I init SDL I call the following code.
Code:
if (SDL_Init(SDL_INIT_TIMER|SDL_INIT_VIDEO|SDL_INIT_JOYSTICK) < 0)
{
return false;
}
unsigned int flags = SDL_WINDOW_SHOWN | SDL_WINDOW_OPENGL;
if (aWindowed)
{
flags |= SDL_WINDOW_RESIZABLE;
}
SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8);
SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8);
SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8);
SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24);
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1);
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, 2);
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
mWindow = SDL_CreateWindow("Help Me", 0, 0, aXRes, aYRes, flags | SDL_WINDOW_BORDERLESS);
SDL_SetWindowFullscreen(mWindow, !aWindowed ? SDL_TRUE : SDL_FALSE);
mRenderer = SDL_CreateRenderer(mWindow, -1, SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC);
TTF_Init();
SDL_EventState(SDL_TEXTINPUT, SDL_ENABLE);
SDL_EventState(SDL_TEXTEDITING, SDL_ENABLE);
Then when I want to create so text I call the following code.
Code:
SDL_Color black = { 0x00, 0x00, 0x00, 255 };
SDL_Surface *fg_surface = TTF_RenderText_Blended(font, aText.c_str(), aColour);
SDL_Surface *bg_surface = NULL;
if (fg_surface)
{
bg_surface = TTF_RenderText_Blended(font, aText.c_str(), black);
fg_surface = GuiManager::GetInstance()->CreateShadow(fg_surface, bg_surface, offset);
}
mTexture = SDL_CreateTextureFromSurface(aRenderer, fg_surface);
SDL_FreeSurface(fg_surface);
I am guessing when the application is swapped out and then back the aRenderer variable is no longer valid. (aRenderer is passed in the the text create code from the first code).
I have tested the code and the problem isn’t the CreateShadow code.
Does this help any?
Cheers
Brad