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.

Newcomers DBPro Corner / Testing full capability of arrays/memblocks

Author
Message
BearCDPOLD
20
Years of Service
User Offline
Joined: 16th Oct 2003
Location: AZ,USA
Posted: 15th Jan 2004 00:58
Hey guys,
I've been reading through a bunch of posts and looking at some docs for some dlls, and I've noticed that people use arrays and memblocks in various ways. I've seen code that puts media into an array, and the same thing with a memblock. But, I guess my first question would be: What is a memblock? Is the idea behind it similar to an array?
And can you load files (media or otherwise) into arrays and memblocks?

thanks,
crazy donuts

Juvenile Industries
Current Project: KillZone(FPS)
Soon to come:An rts, and a snowball fight game
the_winch
21
Years of Service
User Offline
Joined: 1st Feb 2003
Location: Oxford, UK
Posted: 15th Jan 2004 01:45 Edited at: 15th Jan 2004 01:50
A memblock is just a block of memory, because of this they have quite a lot of uses.

Have a look at the memblock commands in the dbpro help.
You can make meblocks using
MAKE MEMBLOCK FROM BITMAP
MAKE MEMBLOCK FROM IMAGE
MAKE MEMBLOCK FROM SOUND
MAKE MEMBLOCK FROM MESH
and you can turn memblocks back into the object or you can use MAKE MEMBLOCK to make a blank memblock and build the obejct up yourself
Unfortuntly the dbpro help doesn't tell you a lot about how the different objects data is stored in the memblock.

You can also read/write byte/word/dword/float values and save a memblock to a file and load a file into a memblock.

They are also pretty usefull for sending data in network games.

You can also get the memblock pointer with GET MEMBLOCK PTR() which can be used for a number of things incuding api calls. Like this code that gets the desktop size


BearCDPOLD
20
Years of Service
User Offline
Joined: 16th Oct 2003
Location: AZ,USA
Posted: 19th Jan 2004 05:48
I think I get where you're coming from. Are memblocks limited to just numbers? I askt shi because I've heard people prefer storing vertex points in memblocks instead of using DB's matrices. Could you provide me with a generic example of what it could be used for in a game so I could grasp why it was included in the app?

thanks,
Crazy Donuts

Juvenile Industries
Current Project: KillZone(FPS)
Soon to come:An rts, and a snowball fight game
Zeal
21
Years of Service
User Offline
Joined: 10th Oct 2002
Location: Colorado Springs, CO
Posted: 23rd Jan 2004 02:51
Its kinda advanced but you should take a look at kevils memblock matrix tutorial...

http://darkbasicpro.thegamecreators.com/?m=codebase_view&i=ff622260deaf05fa7890237516f9147f

In general, think of a memblock as a string of numbers. If you wanted to turn a memblock into a image, youd have to follow a strict data structure (you can see how all the data structures are setup in the dbp help files).

The data structure for a image is as follows. the first dword in your memblock (at position 0) represents the width in pexels of the image, the second dword (at position 4) represents the length in pixels of the image, the third dword (position 8) represents the color depth of the image (16bit or 32bit), from there on out each dword represents a pixel color of the image, so at position 12 youd wirte the color of the pixel at position 0,0. Once all pixel colors are recorded, youre done. Then just use the make image from memblock command to make your image from the memblock.

Use the same logic to make a mesh/object. Youd just use a different data structure.

All you need is zeal
BearCDPOLD
20
Years of Service
User Offline
Joined: 16th Oct 2003
Location: AZ,USA
Posted: 25th Jan 2004 03:32
I see now. I'll be sure to read up on that tutorial, and maybe see about implementing it into something cool.

Thanks guys! DB has the best forum.

Juvenile Industries
Current Project: KillZone(FPS)
Soon to come:An rts, and a snowball fight game

Login to post a reply

Server time is: 2024-09-21 18:44:11
Your offset time is: 2024-09-21 18:44:11