How do use SDL2_ttf is as follows:
- Method A
surface = TTF_RenderUTF8_Blended(font, “Text”, colour);
texture = SDL_CreateTextureFromSurface(renderer, surface);
SDL_RenderCopy(…texture…);
No issue.
- Method B
surfaceOrig = TTF_RenderUTF8_Blended(fontTitle, “Text”, colour);
textureOrig = SDL_CreateTextureFromSurface(renderer, surfaceOrig);
textureScaled = SDL_CreateTexture(renderer, pixFormatOrig, SDL_TEXTUREACCESS_TARGET, w, h);
SDL_SetRenderTarget(renderer, textureScaled);
SDL_RenderCopy(renderer, textureOrig, NULL, NULL)
SDL_SetRenderTarget(renderer, NULL);
SDL_RenderCopy(…textureScaled…);
Only in this path I have issues.
Note 1, test program for Method B does not show any issue.
Note 2, texture returned from SDL_CreateTexture() is not validated in any way other than for a valid pointer. If necessary to validate, what should I do?
Thanks.
Sagara
how do you render your ttf ?
usually SDL_tt will generate a surface, and then you either render
the surface onscreen, or to a target texture which is then
rendered onscreen.
In the latter case, did you check that your target texture was
initialized (filled) with zeros ?
- Method A
surface = TTF_RenderUTF8_Blended(font, “Text”, colour);
texture = SDL_CreateTextureFromSurface(renderer, surface);
SDL_RenderCopy(…texture…);
No issue.
- Method B
surfaceOrig = TTF_RenderUTF8_Blended(fontTitle, “Text”, colour);
textureOrig = SDL_CreateTextureFromSurface(renderer, surfaceOrig);
textureScaled = SDL_CreateTexture(renderer, pixFormatOrig, SDL_TEXTUREACCESS_TARGET, w, h);
SDL_SetRenderTarget(renderer, textureScaled);
SDL_RenderCopy(renderer, textureOrig, NULL, NULL)
SDL_SetRenderTarget(renderer, NULL);
SDL_RenderCopy(…textureScaled…);
Only in this path I have issues.
SDL mailing list SDL at lists.libsdl.org http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.orgOn Saturday, September 6, 2014 11:57 AM, Sanette wrote: