GetBufferPointer

Top  Previous  Next

Syntax

POINTER = GetBufferPointer(opt buffer as POINTER)

Description

Returns the beginning memory address of a screen buffer.

Parameters

buffer - Optional. Can be either BACKBUFFER (default) or FRONTBUFFER

Return value

The address of the first pixel in a screen buffer

Remarks

Used for direct memory access of a screen buffer. The buffer must be locked first with the LockBuffer command and unlocked with the UnlockBuffer command after access is completed. You must be sure never to write outside the confines of the buffer.

The return value is actually a UINT. To use with a POINTER a variable must be defined first.

See Also: LockBuffer, UnlockBuffer, GetBufferPitch

Example usage

DEF buffer as POINTER
IF(CREATESCREEN(800,600,32) < 0)
    MESSAGEBOX 0,"Error creating screen","Error"
ENDIF
 
DO
    FillScreen 0
    ' turn the pixel at 100,200 blue
    LockBuffer
    buffer = GetBufferPointer
    pitch = GetBufferPitch
    buffer += (200 * pitch) + (100 * 4)
    #<UINT>buffer = RGBToScreen(RGB(0,0,255))
    Unlockbuffer
    WriteText 0,0,"Press Left MouseButton to Close"
    FLIP
UNTIL GetKeyState(0x01)
CLOSESCREEN
END