Skip to content

Commit

Permalink
oops make it use the gpu bitmap lol
Browse files Browse the repository at this point in the history
  • Loading branch information
Vortex2Oblivion committed Sep 18, 2024
1 parent 0c896bb commit a87ea2c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
18 changes: 10 additions & 8 deletions source/Paths.hx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import openfl.display3D.textures.RectangleTexture;
class Paths {
public static var currentLevel:String = "preload";

public static var bitmaps:Map<String, BitmapData> = new Map<String, BitmapData>();
public static var bitmaps:Map<String, FlxGraphic> = new Map<String, FlxGraphic>();

public static function getPath(file:String, type:AssetType, library:Null<String>):String {
if (library != null)
Expand Down Expand Up @@ -107,10 +107,8 @@ class Paths {
return file;
}
@:privateAccess {
if (bitmaps.exists(file)) {
bitmap = bitmaps.get(file);
} else {
//trace('loading $file to the gpu', DEBUG);
if(!bitmaps.exists(file)){
trace('loading $file to the gpu', DEBUG);
bitmap.lock();
if (bitmap.__texture == null) {
bitmap.image.premultiplied = true;
Expand All @@ -121,12 +119,16 @@ class Paths {
bitmap.image.data = null;
bitmap.image = null;
bitmap.readable = true; // hashlink fix
bitmaps.set(file, bitmap);
}
}
else{
bitmap = null;
return bitmaps.get(file);
}
}
var graphic:FlxGraphic = FlxGraphic.fromBitmapData(bitmap, false, file, false);
graphic.persist = true;
return file;
bitmaps.set(file, graphic);
return graphic;
}

inline static public function font(key:String):String
Expand Down
2 changes: 1 addition & 1 deletion source/ui/Alphabet.hx
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ class AlphaCharacter extends FlxSprite {
super(x, y);
this.scaleMult = scaleMult;

frames = Paths.getSparrowAtlas('alphabet');
frames = Paths.getSparrowAtlas('alphabet', "preload", true);

antialiasing = Options.getData("antialiasing");

Expand Down

0 comments on commit a87ea2c

Please sign in to comment.