diff --git a/Program.cs b/Program.cs index ce0f27c..3ef9be1 100644 --- a/Program.cs +++ b/Program.cs @@ -565,7 +565,7 @@ public class Game : GameWindow { int VertexArrayObject; List allPhotos = new(); List photos = new(); - HashSet loadedImages = new(); + HashSet loadedImages = new(); int photoIndex = 0; int ribbonIndex = 0; Shader shader = new(); @@ -710,6 +710,8 @@ public class Game : GameWindow { void FilterByRating(int rating) { Console.WriteLine("filter to " + rating); + photos = allPhotos.Where(p => p.Rating >= rating).ToList(); + photoIndex = 0; } protected override void OnLoad() { @@ -750,11 +752,11 @@ public class Game : GameWindow { // Load photos from a directory. // string[] files = Directory.GetFiles(@"c:\users\colin\desktop\photos-test\"); - // string[] files = Directory.GetFiles(@"c:\users\colin\pictures\photos\2023\07\14\"); + string[] files = Directory.GetFiles(@"c:\users\colin\pictures\photos\2023\07\14\"); // string[] files = Directory.GetFiles(@"G:\DCIM\100EOSR6\"); // string[] files = Directory.GetFiles(@"C:\Users\colin\Pictures\photos\2018\06\23"); // string[] files = Directory.GetFiles(@"C:\Users\colin\Desktop\Germany all\104D7000"); - string[] files = Directory.GetFiles(@"C:\Users\colin\Desktop\many-birds\"); + // string[] files = Directory.GetFiles(@"C:\Users\colin\Desktop\many-birds\"); for (int i = 0; i < files.Count(); i++) { string file = files[i]; @@ -789,8 +791,9 @@ public class Game : GameWindow { int maxLoadedImage = Math.Min(photoIndex + 20, photos.Count - 1); // First, unload images that are far outside our window. // FIXME: also cancel any in-progress loading tasks that have moved outside our window. - // FIXME: maybe use an LRU cache for evicting images? // FIXME: keep around thumbnail-sized textures? + // FIXME: turn unloading back on, using an LRU cache for evicting images. + /* foreach (int i in loadedImages) { if (i < minUnloadedImage || i > maxUnloadedImage) { // Console.WriteLine("unloading " + i); @@ -798,12 +801,12 @@ public class Game : GameWindow { photos[i].UnloadAsync(); } } - + */ // Then, start loading any images that aren't in our window. for (int i = minLoadedImage; i <= maxLoadedImage; i++) { - if (!loadedImages.Contains(i)) { + if (!loadedImages.Contains(photos[i].Filename)) { // Console.WriteLine("loading " + i); - loadedImages.Add(i); + loadedImages.Add(photos[i].Filename); await Task.Run( () => { photos[i].LoadAsync(); }); } } @@ -816,7 +819,7 @@ public class Game : GameWindow { LoadAndUnloadImagesAsync(); GL.Clear(ClearBufferMask.ColorBufferBit); - GL.BindBuffer(BufferTarget.ArrayBuffer, VertexBufferObject); HashSet loadedImages = new(); + GL.BindBuffer(BufferTarget.ArrayBuffer, VertexBufferObject); GL.ActiveTexture(TextureUnit.Texture0); Photo activePhoto = photos[photoIndex];