class VBO

Vertex Buffer Object

[source]

methods

VBO.Delete

function VBO.Delete() ->  nil

[source]

VBO.Define

function VBO.Define(
  size: number,
  attribs: (number|VBOAttributeDef[])
) ->  nil

@param size - The maximum number of elements this VBO can have.

@param attribs - When number, the maximum number of elements this VBO can have.

Otherwise, an array of arrays specifying the layout.

Specify the kind of VBO you will be using.


[<a href="https://github.com/beyond-all-reason/spring/blob/9a9aa1ba68226e0024f3359ae75bff4a5c1a7a8d/rts/Lua/LuaVBOImpl.cpp#L500-L538" target="_blank">source</a>]


### VBO.GetBufferSize

```lua
function VBO.GetBufferSize()
 -> elementsCount number
 -> bufferSizeInBytes number
 -> size number

[source]

VBO.Upload

function VBO.Upload(
  vboData: number[],
  attributeIndex: integer?,
  elemOffset: integer?,
  luaStartIndex: integer?,
  luaFinishIndex: integer?
)
 -> indexData number[]
 -> elemOffset integer
 -> attrID (integer|(integer,integer,integer,integer))

@param vboData - a lua array of values to upload into the VBO

@param attributeIndex - (Default: -1)

If supplied with non-default value then the data from vboData will only be used to upload the data to this particular attribute.

The whole vboData is expected to contain only attributeIndex data.

Otherwise all attributes get updated sequentially across attributes and elements.

@param elemOffset - (Default: 0) Which VBO element to start uploading data from Lua array into.

@param luaStartIndex - (Default: 1) Start uploading from that element in supplied Lua array.

@param luaFinishIndex - Consider this element the last element in Lua array.

Uploads the data (array of floats) into the VBO

vbo:Upload(posArray, 0, 1)


### VBO.Download

```lua
function VBO.Download(
  attributeIndex: integer?,
  elementOffset: integer?,
  elementCount: number?,
  forceGPURead: boolean?
) ->  unknown

@param attributeIndex - (Default: -1) when supplied with non-default value: only data from specified attribute will be downloaded - otherwise all attributes are downloaded

@param elementOffset - (Default: 0) download data starting from this element

@param elementCount - number of elements to download

@param forceGPURead - (Default: false) force downloading the data from GPU buffer as opposed to using shadow RAM buffer

[source]

VBO.ModelsVBO

function VBO.ModelsVBO() -> buffer (nil|number)

@return buffer - size in bytes

Binds engine side vertex or index VBO containing models (units, features) data.

[source]

Also fills in VBO definition data as they’re set for engine models (no need to do VBO:Define()).

VBO.InstanceDataFromUnitDefIDs

function VBO.InstanceDataFromUnitDefIDs(
  unitDefIDs: (number|number[]),
  attrID: integer,
  teamIdOpt: integer?,
  elementOffset: integer?
)
 -> instanceData (number,number,number,number)
 -> elementOffset integer
 -> attrID integer

Fills in attribute data for each specified unitDefID

[source]

The instance data in that attribute will contain the offset to bind position matrix in global matrices SSBO and offset to uniform buffer structure in global per unit/feature uniform SSBO (unused for Unit/FeatureDefs), as well as some auxiliary data ushc as draw flags and team index.

Data Layout:

SInstanceData:
   , matOffset{ matOffset_ }            // updated during the following draw frames
   , uniOffset{ uniOffset_ }            // updated during the following draw frames
   , info{ teamIndex, drawFlags, 0, 0 } // not updated during the following draw frames
   , aux1 { 0u }

VBO.InstanceDataFromFeatureDefIDs

function VBO.InstanceDataFromFeatureDefIDs(
  featureDefIDs: (number|number[]),
  attrID: integer,
  teamIdOpt: integer?,
  elementOffset: integer?
)
 -> instanceData (number,number,number,number)
 -> elementOffset integer
 -> attrID integer

Fills in attribute data for each specified featureDefID

[source]

The instance data in that attribute will contain the offset to bind position matrix in global matrices SSBO and offset to uniform buffer structure in global per unit/feature uniform SSBO (unused for Unit/FeatureDefs), as well as some auxiliary data ushc as draw flags and team index.

Data Layout

SInstanceData:
   , matOffset{ matOffset_ }            // updated during the following draw frames
   , uniOffset{ uniOffset_ }            // updated during the following draw frames
   , info{ teamIndex, drawFlags, 0, 0 } // not updated during the following draw frames
   , aux1 { 0u }

VBO.InstanceDataFromUnitIDs

function VBO.InstanceDataFromUnitIDs(
  unitIDs: (number|number[]),
  attrID: integer,
  teamIdOpt: integer?,
  elementOffset: integer?
)
 -> instanceData (number,number,number,number)
 -> elementOffset integer
 -> attrID integer

Fills in attribute data for each specified unitID

[source]

The instance data in that attribute will contain the offset to bind position matrix in global matrices SSBO and offset to uniform buffer structure in global per unit/feature uniform SSBO (unused for Unit/FeatureDefs), as well as some auxiliary data ushc as draw flags and team index.

Data Layout

SInstanceData:
   , matOffset{ matOffset_ }            // updated during the following draw frames
   , uniOffset{ uniOffset_ }            // updated during the following draw frames
   , info{ teamIndex, drawFlags, 0, 0 } // not updated during the following draw frames
   , aux1 { 0u }

VBO.InstanceDataFromFeatureIDs

function VBO.InstanceDataFromFeatureIDs(
  featureIDs: (number|number[]),
  attrID: integer,
  teamIdOpt: integer?,
  elementOffset: integer?
)
 -> instanceData (number,number,number,number)
 -> elementOffset integer
 -> attrID integer

Fills in attribute data for each specified featureID

[source]

The instance data in that attribute will contain the offset to bind position matrix in global matrices SSBO and offset to uniform buffer structure in global per unit/feature uniform SSBO (unused for Unit/FeatureDefs), as well as some auxiliary data ushc as draw flags and team index.

VBO.MatrixDataFromProjectileIDs

function VBO.MatrixDataFromProjectileIDs(
  projectileIDs: (integer|integer[]),
  attrID: integer,
  teamIdOpt: integer?,
  elementOffset: integer?
)
 -> matDataVec number[]
 -> elemOffset integer
 -> attrID (integer|(integer,integer,integer,integer))

@return matDataVec - 4x4 matrix

[source]

VBO.BindBufferRange

function VBO.BindBufferRange(
  index: integer,
  elementOffset: integer?,
  elementCount: number?,
  target: number?
) -> bindingIndex integer

@param index - should be in the range between 5 < index < GL_MAX_UNIFORM_BUFFER_BINDINGS value (usually 31)

@param target - glEnum

@return bindingIndex - when successful, -1 otherwise

Bind a range within a buffer object to an indexed buffer target

[source]

Generally mimics https://registry.khronos.org/OpenGL-Refpages/gl4/html/glBindBufferRange.xhtml except offset and size are specified in number of elements / element indices.

VBO.UnbindBufferRange

function VBO.UnbindBufferRange(
  index: integer,
  elementOffset: integer?,
  elementCount: number?,
  target: number?
) -> bindingIndex number

@param target - glEnum

@return bindingIndex - when successful, -1 otherwise

[source]

VBO.DumpDefinition

function VBO.DumpDefinition() ->  nil

Logs the definition of the VBO to the console

[source]

VBO.GetID

function VBO.GetID() -> bufferID number

Gets the OpenGL Buffer ID

[source]