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.

Dark GDK / how do i use memblocks?

Author
Message
sadyk
15
Years of Service
User Offline
Joined: 6th Sep 2009
Location: Spain-Madrid
Posted: 3rd Dec 2009 20:04
well, in de tutorials there isn´t any advice to use this, and y don´t know how do it works. i have tried a program that make a memblock, save a 1 byte value in it after after y break the LoopGDK, an then, when there is a value of 1 in the memblock i close the program. something like this:

what am i doing wrong? there´s not problem whith the compiler, but it don´t goes.

sorry my english
sadyk
15
Years of Service
User Offline
Joined: 6th Sep 2009
Location: Spain-Madrid
Posted: 3rd Dec 2009 20:11
i thint that the memblocks are used to save values on the computer to use it later, am i wrong?

sorry my english
Rudolpho
18
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 3rd Dec 2009 22:16 Edited at: 3rd Dec 2009 22:16
Umm.... you aren't setting the memblock value until after finishing the while loop, which is only finished when the GDK loop condition is false. Therefore, the system will likely not even register the dbWriteMemblockByte function call, and even if it did, the program will just terminate directly afterwards, not telling you whether the function succeeded or not.

This should probably work:


luke810
18
Years of Service
User Offline
Joined: 4th Sep 2006
Location: United States
Posted: 3rd Dec 2009 23:02
Umm, No. I believe memblock are blocks of memory in ram that you can use for various purposes, such as editing data for media files. Using them for storage after a program closed would not be possible, and if it was it would be a very big no no. You can only use memblocks within your program, and the memory is indexed as in an array so byte one is at index 0.

Rudolpho
18
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 3rd Dec 2009 23:09
Oh, sorry, didn't read your post properly it seems.
Luke is right.
If you want to save to disc (static memory), you can use dbOpenFile() etc., or just filestream. To store something to the RAM that isn't deleted when the application is closed can be done with the malloc() function, I believe. You better find a way of telling some other program where this memory exist though, or it will be locked up until you restart your computer.

Also, in DGDK, you should really only use memblocks when you need to edit some sort of DBP media (images, meshes, sounds). For general memory storage you would be better off creating a container class or, depending on what kind of data you need to store, an array.

sadyk
15
Years of Service
User Offline
Joined: 6th Sep 2009
Location: Spain-Madrid
Posted: 4th Dec 2009 21:11
thanks for your help!
well, I wanted to use memblocks for save the game, but i will trie a veter idea: (i don´t know how to say this in inglish, so i pur it in spanish) ficheros.
it`s easy to work whith it and i like that i can read the fichero in thed notpad

sorry my english

Login to post a reply

Server time is: 2024-11-20 09:29:28
Your offset time is: 2024-11-20 09:29:28