Class: vidbuffer

Allows allocation of memory mostly resident on graphics card, or managed by driver for fast data exchange. Several vidbuffertypes exist, OpenGL allows changing use of same buffer during a lifetime.

Hierarchy

o-+ renderinterface
  o-+ vidbuffer

Methods:

Method overview:


new (vidtype,vidhint,int sizebytes,[pointer])
returns: (vidbuffer)
creates a new buffer with the given size. Optionally copies content from given pointer.
glid (vidbuffer,[vidtype/other])
returns: (pointer)
returns the native graphics buffer identifier stored in a pointer. Cast the (void*) to (GLuint). If you pass a vidtype, the buffer is also bound, if you pass any none vidtype, the buffer is unbound from all possible types. As OpenGL uses reference counting itself, the buffer is kept alive, even if luxinia flags it for deletion. Useful for interoperability with CUDA/OpenCL.
keeponloss (vidbuffer,[bool])
returns: ([bool])
whether to keep a temporary local copy of the data in case of context loss, such as fullscreen toggle. Default is false.
localalloc (vidbuffer, int sizebytes, [int alignpad=4])
returns: (int offset)
advances the internal allocation state. To aid storing multiple content in same buffer (speed benefit) as well as mapping safety, the returned offset can be used to identify the region of current allocation. The allocation can be aligned to a given size. For example storing multiple vertextypes in same buffer, works if they all allocation starts are aligned to the gratest vertexsize.
map (vidbuffer, vidmapping)
returns: (pointer start,end)
maps the full buffer into application memory. While mapped other content operations (retreve or submit) are not allowed.
mapped (vidbuffer)
returns: ([pointer start,end])
is the buffer mapped, if yes returns pointers
maprange (vidbuffer, vidmapping, int from, sizebytes, [bool manualflush], [bool unsync])
returns: (pointer start,end)
maps the buffer into application memory. Only the specified range is mapped if maprange capability exists, otherwise full is mapped and pointers offset to match range. The last arguments are only valid for maprange capability.Manual flush means that the data is not marked 'valid' after unmap, but requires calls to flush.Unsynchronized access means data can be accessed even if still modified by graphics.While mapped other content operations (retreve or submit) are not allowed.
release (vidbuffer)
returns: (int bytes)
deletes the buffer (driver might delay resource release, if still in use).
retrieve (vidbuffer,int frombyte, sizebytes, pointer output)
returns: ()
stores the data into the given pointer.
submit (vidbuffer,int frombyte, sizebytes, pointer output)
returns: (int bytes)
submits data from the given pointer.
unmap (vidbuffer)
returns: ()
unmaps the buffer

Inherited Methods: