flat assembler
Message board for the users of flat assembler.

Index > High Level Languages > image viewer on direct3d9(wip)

Author
Thread Post new topic Reply to topic
vivik



Joined: 29 Oct 2016
Posts: 671
vivik 21 Mar 2018, 20:57
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:
pointer_to_the_first_"big"
length
is_reverse

thumb_range will look like:
pointer_to_"thumb"_texture
starts_at
length
is_reverse
Post 21 Mar 2018, 20:57
View user's profile Send private message Reply with quote
vivik



Joined: 29 Oct 2016
Posts: 671
vivik 21 Mar 2018, 21:00
Here is the code for it. It's super raw and super buggy. Say if you have anything to comment about it.

EDIT:
By the way, it gives me "out of memory" only after 50-100 opened images. Too complicated for me to debug right now.

Also, thumbnails don't get displayed properly, their right border goes 1-2 pixels otherboard. Very noticeable if you'll set background to some color.

I want to rewrite it in directdraw now, need to see if it's fast enough. If it's not, then I'll continue with direct3d.


Description:
Download
Filename: tut2_Vertices.cpp.txt
Filesize: 80.16 KB
Downloaded: 941 Time(s)

Post 21 Mar 2018, 21:00
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
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


Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.