buffer_peek

Read data from a buffer at the given position.

Syntax:

GML Code Example

buffer_peek(buffer, offset, type);


Argument Description
buffer The index of the buffer to use.
offset The offset position (in bytes) within the buffer to read the given data from.
type The type of data that is to be read from the buffer (see the list of constants here).


Returns: Real/String


Description

With the buffer_read function, you can read data from the given buffer at the current "seek" position, with each piece of data being read advancing this position by the bytes being read or written. However, it may be necessary for you to read a given piece of data without wanting to change the current seek position, and that's when you would use this function. You simply supply the function with a buffer id, and then an offset position (from the buffer start) within that buffer to read from, as well as the data type that you are wanting to read.

NOTE: Using the incorrect data type for the data being read will result in erroneous values!


Example:

GML Code Example

var red = buffer_peek(buff, 1, buffer_u8);
 var green = buffer_peek(buff, 2, buffer_u8);
 var blue = buffer_peek(buff, 3, buffer_u8);
 image_blend = make_colour_rgb(red, green, blue);
 

The above code will get three values from three different positions within the buffer indexed in the variable "buff" and then use those values to set the image blend of the instance.


Back: Buffers



No Examples Submitted

Does this page need better examples? Be the first to Submit

No Edits Suggested

Is this page unclear or not descriptive enough? Suggest an edit to the page and with enough upvotes your changes will be made.

No Questions Have Been Ask

Do you have a question about this page? Ask it Here