Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Discussion / memblock or arrays?

Author
Message
Caleb1994
16
Years of Service
User Offline
Joined: 10th Oct 2008
Location: The Internet you idiot!
Posted: 2nd Mar 2009 01:22
ok so i'm making a set of window functions and some things that i'm doing in arrays can be done with a memblock but i'm not sure which is better and the "advantages"

what do you think?
Latch
18
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 2nd Mar 2009 01:57
Arrays have the advantage of being being easy to manage, save, and load.

Memblocks have the advantage of customization and pointers that can be exchanged with DLLs. A pointer is an identifyer to a place in memory where the memblock information is stored. Anything you can do with an array, you can do with a memblock - but a memblock has more options - but they are a little trickier to use.

Memblocks can be setup to use less memory than arrays. Memblocks can copy chunks of information at a time without having to loop through items like in arrays.

You could design a memblock to act as a stucture or a type . For example, you could reserve a certain number of bytes in the memblock as a header, the next chunk could store an image, after that you could store a mesh, and then after that you could store a series of strings - all in one memblock. The list goes on and on.

It all comes down to what you need. The most flexibility and the most options go with using memblocks. Arrays are just much easier.

Enjoy your day.
Caleb1994
16
Years of Service
User Offline
Joined: 10th Oct 2008
Location: The Internet you idiot!
Posted: 2nd Mar 2009 03:44
ok so its the same as asking the question functions or subroutines hahaha thanks.


one question though. i was going to use make memblock from image to store the images that way i wouldn't need the have then loaded until i used them but when i do and i try to use make image from memblock it says "Memblock does not exist"or something to that extent(can't remember the exact error)

i have went over and over the help files and i cant understand why it's doing this :/ gr
Quirkyjim
16
Years of Service
User Offline
Joined: 18th Oct 2008
Location: At my computer
Posted: 2nd Mar 2009 22:36
Hehehe, I get to use it again!



~QJ
Latch
18
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 3rd Mar 2009 19:23
Quote: " i was going to use make memblock from image to store the images that way i wouldn't need the have then loaded until i used them but when i do and i try to use make image from memblock it says "Memblock does not exist"or something "


After calling make memblock from image, call SYNC or WAIT

make memblock from image 1,1
sync

make memblock from image 1,1
wait 0

Enjoy your day.
Caleb1994
16
Years of Service
User Offline
Joined: 10th Oct 2008
Location: The Internet you idiot!
Posted: 6th Mar 2009 07:01
oh ok sweet i will try this in the morning just wondering though what does that do to make it work?


quarkyjim:

ya lol whoops geuss i should follow my own advice hahaha
Latch
18
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 6th Mar 2009 09:21
Quote: "just wondering though what does that do to make it work?"


I'm not sure about the inner workings of DBC but there are many ways to transfer data from one memory location to another, and with graphics data, there can be more than 1 step. In this case, it's transfering pixel data to a memblock. If you are managing the timing updates yourself (SYNC ON) with SYNC, then I'm guessing that the initial call to make memblock from image set's up the memblock (allocates the appropriately sized memory chunk) to hold the pixel data based on the resolution and depth + a 12 byte header, and the SYNC does a blit (BLT - Block transfer) of the pixel data to the memblock. I think the same thing might happen with Get Image because I noticed if there isn't a SYNC after it, it doesn't always grab the image correctly.

Quote: "one question though. i was going to use make memblock from image to store the images that way i wouldn't need the have then loaded until i used them "

If you are storing the image in a memblock, then they are loaded into memory - the memory of the memblock. So unless you're manipulating the image somehow in the memblock or compressing it, or doing something out of the norm that requires the storage, you may as well just have the image loaded as an image and not placed in the memblock.

Enjoy your day.
Caleb1994
16
Years of Service
User Offline
Joined: 10th Oct 2008
Location: The Internet you idiot!
Posted: 6th Mar 2009 16:31
aaaaahhhh i just went into darkbasic and was going to try the original way i did just for testing purposes and it worked ugh thats very annoying. heres the code i put it





any ideas? i mean that would be great if i didn't have to do it but thiis is odd.
Latch
18
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 6th Mar 2009 16:51
Quote: "If you are managing the timing updates yourself (SYNC ON) with SYNC, then I'm guessing that the initial call to make memblock from image set's up the memblock (allocates the appropriately sized memory chunk) to hold the pixel data based on the resolution and depth + a 12 byte header, and the SYNC does a blit "

If you aren't using SYNC ON then you don't need the SYNC because DBC is managing the timing and BLTing itself.

Your snippet doesn't include a SYNC ON. Try:



Enjoy your day.
Caleb1994
16
Years of Service
User Offline
Joined: 10th Oct 2008
Location: The Internet you idiot!
Posted: 6th Mar 2009 17:22
ohhhh sorry geuss i didn't read closenough lol thanks.



oh and i see what you mean about not using them to store images.

i was thinking about that at like 1 am and i was thinking then it would take less images but i just realized it doesn't lol thanks

Login to post a reply

Server time is: 2025-05-17 13:30:32
Your offset time is: 2025-05-17 13:30:32