11package engine .resources ;
22
3+ import java .awt .Image ;
34import java .util .HashMap ;
45import java .util .Map ;
56
67public class TextureManager {
78
89 private static TextureManager instance ;
910
10- private TextureLoader imageLoader ;
11+ private TextureLoader textureLoader ;
1112
1213 private final Map <String , Texture > resourceCache = new HashMap <>();
1314
@@ -21,19 +22,19 @@ public static TextureManager getInstance() {
2122 }
2223
2324 public void setTextureLoader (TextureLoader loader ) {
24- this .imageLoader = loader ;
25+ this .textureLoader = loader ;
2526 }
2627
2728 public Texture loadTexture (String path ) {
2829 if (resourceCache .containsKey (path )) {
2930 return resourceCache .get (path ); // Return cached resource
3031 }
3132
32- if (imageLoader == null ) {
33- throw new IllegalStateException ("ImageLoader is not set! " );
33+ if (textureLoader == null ) {
34+ throw new IllegalStateException ("TextureLoader is not set. " );
3435 }
3536
36- Texture texture = imageLoader .loadTexture (path );
37+ Texture texture = textureLoader .loadTexture (path );
3738 resourceCache .put (path , texture );
3839
3940 return texture ;
@@ -42,4 +43,12 @@ public Texture loadTexture(String path) {
4243 public void unloadImage (String path ) {
4344 resourceCache .remove (path ); // Optionally handle cleanup for backend-specific resources
4445 }
46+
47+ public Texture createTexture (Image image ) {
48+ return textureLoader .createTexture (image );
49+ }
50+
51+ public Texture createTexture (int width , int height ) {
52+ return textureLoader .createTexture (width , height );
53+ }
4554}
0 commit comments