Loading results...

Search Results for "Term"

Buffers

These functions can be used to read and write
directly to the device buffer memory.

A binary buffer is a region of physical memory used to
temporarily hold data while it is being moved from one place to
another or manipulated in some way, for example you can use a
buffer to hold packet data awaiting transmission over a network or
for storing a packet that has been received over a network.
GameMaker: Studio has a number of specific functions related
to creating, modifying and loading/saving buffers, but before using
them please note the following points:

When a buffer is created, it is automatically cleared and
filled to 0.

The "size" argument of the buffer functions always refers to
the size in bytes of the buffer.

The "Alignment" argument refers to how data is stored within a
buffer. If your alignment is set to say, 4, and you write a single
piece of data which is 1 byte in size then do a
buffer_tell, you'll get an offset of 1. However, if you
write another piece of data, also 1 byte in size, then do a
buffer_tell, you'll get an offset of 5 as the alignment
has "padded" the data to that size. Alignment only affects
where things are written to, so if you do a
buffer_tell after you write something, it'll return the
current write position which immediately follows the data you've
written. Note, however, that if you then write another piece of
data, internally the buffer will move the write position along to
the next multiple of the alignment size before actually writing the
piece of data.

When dealing with "offset", this is the value in bytes
to offset the data by within the given buffer. So if your buffer is
2 byte aligned and you want to skip the first 4 aligned places, you
would have an offset of 2 * 4 bytes.

Some of the buffer functions also create a new buffer (like
buffer_load for example). Remember that these buffers will
also need to be removed from memory when not in use using the
buffer_delete function.

The memory used for creating buffers is system memory so
even when the game doesn't have focus, any data stored in a buffer
should be safe, however if the app is closed or re-started then it
will be lost.

The following pages explain how buffers work within the context
of GameMaker: Studio and contain a couple of code examples
for those users that are unsure of how to use them: