I want to create a thread about it, to sort of document it as I go, and to log my progress.
This is the image viewer I'm making. Goals: to work super fast, to have controls tuned for me, and to report anything suspicious in the images (comments, extra space, everything). This is also hilariously complicated.
Idea 1: For all data, for which I don't know the size ahead of time, I use linked lists. And I'm also using fixed size memory allocation, with VirtualAlloc. Each memory chunk is 0x1000 bytes in size. I reserve the last dword of this chunk for an address to the next chunk, so that it sort of autoexpands (or I use first dword for the "prev" pointer, quite good for stacks). Pros: don't have to realloc anything ever, don't have to move data around unnecessarily, memory fragmentation isn't an issue, allocator is super simple. Cons: I have to check for overflows very often (more code), slightly more memory wasted, and I'm not sure if this is actually better than a usual malloc.
Idea 2: every image I load, is either "big" or "thumb". "Big" are the actual images, "thumb" are thumbnails for them. "Big" images get spitted into a bunch of 512x512 textures, and a bunch of "thumb" are stored on a one or more 1024x1024 texture. All to waste less memory.
Idea 3: I'm storing info for those "big" and "thumb" in an interesting manner. All using those fixed size chunks from Idea 1. For "big", I'm storing the image width, image height, and a bunch of direct3d textures for them. For "thumb", I'm storing a direct3d texture, a "length" of currently placed thumbs on them, and a bunch of "x y width height" coordinates for each. Pros: it's more compact, and somewhat simple. Cons: you can only traverse it in one direction, too many overflow checks. I can make it better by pointing to the proper position in it, and by using "ranges" where possible. Also, I want to add the ability to load images in the reverse order (so that I can open a folder in the middle, and this program will preload images upwards too), and that will require ranges in reverse order and rendering in reverse order.
big_range will look like:
thumb_range will look like:
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum