loadTexture method
Implementation
Pointer<SdlTexture> loadTexture(
String text, {
String? fontFile,
int? fontSize,
int? textColor,
int? backgroundColor,
int? style,
int? outline,
}) {
fontFile ??= _defaultFontFile;
fontSize ??= _defaultFontSize;
textColor ??= _defaultTextColor;
backgroundColor ??= _defaultBackgroundColor;
style ??= _defaultStyle;
outline ??= _defaultOutline;
Pointer<SdlTexture> result = nullptr;
var key = _createKey(
fontFile, fontSize, textColor, backgroundColor, style, outline, text);
if (list[key] != null) {
result = list[key]!;
} else {
var font = _open(fontFile, fontSize);
if (font != nullptr) {
font.setStyle(style);
font.setOutline(outline);
Pointer<SdlSurface> surface = nullptr;
if (backgroundColor != null) {
surface = font.renderUtf8Shaded(text, textColor, backgroundColor);
} else {
surface = font.renderUtf8Blended(text, textColor);
}
if (surface != nullptr) {
var texture = renderer.createTextureFromSurface(surface);
if (texture != nullptr) {
result = texture;
list[key] = texture;
}
}
font.close();
}
}
return result;
}