loadTexture static method

Future<GTexture> loadTexture(
  1. String path, [
  2. double resolution = 1.0,
  3. String? cacheId
])

Loads a texture from the given path with optional resolution and cacheId. If the texture is already in the cache, it is returned directly. Otherwise, the image at the given path is loaded and converted into a GTexture instance.

Implementation

static Future<GTexture> loadTexture(
  String path, [
  double resolution = 1.0,
  String? cacheId,
]) async {
  if (cacheId != null && textureCache.containsKey(cacheId)) {
    return textureCache[cacheId]!;
  }
  var texture = GTexture.fromImage(await loadImage(path), resolution);
  if (cacheId != null) {
    textureCache[cacheId] = texture;
  }
  return texture;
}