struct Gloop::Buffer::BindTarget

Overview

Reference to a target that a buffer can be bound to. Provides operations for working with buffers bound to the target.

Included Modules

Defined in:

gloop/buffer/bind_target.cr

Class Method Summary

Instance Method Summary

Class Method Detail

def self.copy(from read_target : Target | self, to write_target : Target | self, read_offset : Size, write_offset : Size, size : Size) : Nil #

Copies a subset of data from a buffer bound to one target into one bound by another target.

The read_offset indicates the byte offset to start copying from read_target. The write_offset indicates the byte offset to start copying into write_target. The size is the number of bytes to copy.

See: Buffer.copy

  • OpenGL function: glCopyBufferSubData
  • OpenGL version: 3.1

[View source]

Instance Method Detail

def [](start : Size, count : Size) : Bytes #

Retrieves a subset of data from the buffer currently bound to this target.

NOTE Modifying the data returned by this method will not update the contents of the buffer.

See: Buffer#[]

  • OpenGL function: glGetBufferSubData
  • OpenGL version: 2.0

[View source]
def [](range : Range) : Bytes #

Retrieves a range of data from the buffer currently bound to this target.

NOTE Modifying the data returned by this method will not update the contents of the buffer.

See: Buffer#[]

  • OpenGL function: glGetBufferSubData
  • OpenGL version: 2.0

[View source]
def []=(start : Size, count : Size, data) #

Updates a subset of the currently bound buffer's data store.

The data must have a #to_unsafe method or be a Pointer. Bytes, Slice, and StaticArray types are ideal for this.

NOTE Any length data might have is ignored. Be sure that count is less than or equal to the byte size of data.

See: Buffer#[]=

  • OpenGL function: glBufferSubData
  • OpenGL version: 2.0

[View source]
def []=(range : Range, data) #

Updates a subset of the currently bound buffer's data store.

The data must have a #to_unsafe method or be a Pointer. Bytes, Slice, and StaticArray types are ideal for this.

NOTE Any length data might have is ignored. Be sure that the size of range is less than or equal to the byte size of data.

See: Buffer#[]=

  • OpenGL function: glBufferSubData
  • OpenGL version: 2.0

[View source]
def allocate_data(size : Size, usage : Usage = :static_draw) : Nil #

Initializes the currently bound buffer to a given size with undefined contents.

See: Buffer#allocate_data

  • OpenGL function: glBufferData
  • OpenGL version: 2.0

[View source]
def allocate_storage(size : Size, flags : Storage) : Nil #

Initializes the currently bound buffer to a given size with undefined contents. This makes the buffer have a fixed size (immutable).

See: Buffer#allocate_storage

  • OpenGL function: glBufferStorage
  • OpenGL version: 4.4

[View source]
def bind(buffer : Buffer) : Nil #

Binds a buffer to this target.

See: Buffer#bind

  • OpenGL function: glBindBuffer
  • OpenGL version: 2.0

[View source]
def bind(buffer : Buffer, &) #

Binds a buffer to this target.

The previously bound buffer (if any) is restored after the block completes.

See: Buffer#bind

  • OpenGL function: glBindBuffer
  • OpenGL version: 2.0

[View source]
def buffer : Buffer #

Retrieves the buffer currently bound to this target.

Returns .none if no buffer is bound.

  • OpenGL function: glGetIntegerv
  • OpenGL version: 2.0

[View source]
def buffer? : Buffer | Nil #

Retrieves the buffer currently bound to this target.

Returns nil if no buffer is bound.

  • OpenGL function: glGetIntegerv
  • OpenGL version: 2.0

[View source]
def clear : Nil #

Sets the contents of the buffer to zero.

  • OpenGL function: glClearBufferData
  • OpenGL version: 4.3

[View source]
def context : Context #

Context for this target.


[View source]
def copy_from(target : Target | self, read_offset : Size, write_offset : Size, size : Size) : Nil #

Copies a subset of another buffer into the buffer bound to this target.

The read_offset indicates the byte offset to start copying from target. The write_offset indicates the byte offset to start copying into the buffer bound to this target.. The size is the number of bytes to copy.

See: Buffer#copy_from

  • OpenGL function: glCopyBufferSubData
  • OpenGL version: 3.1

[View source]
def copy_to(target : Target | self, read_offset : Size, write_offset : Size, size : Size) : Nil #

Copies a subset of the buffer bound to this target into another.

The read_offset indicates the byte offset to start copying from the buffer bound to this target. The write_offset indicates the byte offset to start copying into target. The size is the number of bytes to copy.

See: Buffer#copy_to

  • OpenGL function: glCopyBufferSubData
  • OpenGL version: 3.1

[View source]
def data : Bytes #

Retrieves all data in the buffer currently bound to this target.

NOTE Modifying the data returned by this method will not update the contents of the buffer.

See: Buffer#data

  • OpenGL function: glGetBufferSubData
  • OpenGL version: 2.0

[View source]
def data=(data) #

Stores data in the buffer currently bound to this target.

The data must have a #to_slice method. Bytes, Slice, and StaticArray types are ideal for this. Previously set #usage hint is reapplied for this data.

See: Buffer#data=

  • OpenGL function: glBufferData
  • OpenGL version: 2.0

[View source]
def fill(value : Int8) : Nil #

Fills the contents of the buffer to a single value.

The value is repeated throughout the buffer. Ensure the correct numerical type is used.

  • OpenGL function: glClearNamedBufferData
  • OpenGL version: 4.5

[View source]
def fill(value : UInt8) : Nil #

Fills the contents of the buffer to a single value.

The value is repeated throughout the buffer. Ensure the correct numerical type is used.

  • OpenGL function: glClearNamedBufferData
  • OpenGL version: 4.5

[View source]
def fill(value : Int16) : Nil #

Fills the contents of the buffer to a single value.

The value is repeated throughout the buffer. Ensure the correct numerical type is used.

  • OpenGL function: glClearNamedBufferData
  • OpenGL version: 4.5

[View source]
def fill(value : UInt16) : Nil #

Fills the contents of the buffer to a single value.

The value is repeated throughout the buffer. Ensure the correct numerical type is used.

  • OpenGL function: glClearNamedBufferData
  • OpenGL version: 4.5

[View source]
def fill(value : Int32) : Nil #

Fills the contents of the buffer to a single value.

The value is repeated throughout the buffer. Ensure the correct numerical type is used.

  • OpenGL function: glClearNamedBufferData
  • OpenGL version: 4.5

[View source]
def fill(value : UInt32) : Nil #

Fills the contents of the buffer to a single value.

The value is repeated throughout the buffer. Ensure the correct numerical type is used.

  • OpenGL function: glClearNamedBufferData
  • OpenGL version: 4.5

[View source]
def fill(value : Float32) : Nil #

Fills the contents of the buffer to a single value.

The value is repeated throughout the buffer. Ensure the correct numerical type is used.

  • OpenGL function: glClearNamedBufferData
  • OpenGL version: 4.5

[View source]
def flush(start : Size, count : Size) : Nil #

Flushes a subset of the mapped buffer to indicate changes have been made.

See: Buffer#flush

  • OpenGL function: glFlushMappedBufferRange
  • OpenGL version: 3.0

[View source]
def flush(range : Range) : Nil #

Flushes a subset of the mapped buffer to indicate changes have been made.

See: Buffer#flush

  • OpenGL function: glFlushMappedBufferRange
  • OpenGL version: 3.0

[View source]
def flush : Nil #

Flushes the entire mapped buffer range to indicate changes have been made.

See: Buffer#flush

  • OpenGL function: glFlushMappedBufferRange
  • OpenGL version: 3.0

[View source]
def immutable? : Bool #

Indicates whether the buffer is immutable.

See: Buffer#immutable?

  • OpenGL function: glGetBufferParameteriv
  • OpenGL enum: GL_BUFFER_IMMUTABLE_STORAGE
  • OpenGL version: 4.4

[View source]
def initialize_data(data, usage : Usage = :static_draw) : Nil #

Stores data in the buffer currently bound to this target.

The data must have a #to_slice method. Bytes, Slice, and StaticArray types are ideal for this.

See: Buffer#initialize_data

  • OpenGL function: glBufferData
  • OpenGL version: 2.0

[View source]
def initialize_storage(data, flags : Storage) : Nil #

Stores data in the buffer currently bound to this target. This makes the buffer have a fixed size (immutable).

The data must have a #to_slice method. Bytes, Slice, and StaticArray types are ideal for this.

See: Buffer#initialize_storage

  • OpenGL function: glBufferStorage
  • OpenGL version: 4.4

[View source]
def map(access : AccessMask, start : Size, count : Size) : Bytes #

Maps a subset of the buffer's memory into client space.

See: Buffer#map

  • OpenGL function: glMapBufferRange
  • OpenGL version: 3.0

[View source]
def map(access : AccessMask, range : Range) : Bytes #

Maps a subset of the buffer's memory into client space.

See: Buffer#map

  • OpenGL function: glMapBufferRange
  • OpenGL version: 3.0

[View source]
def map(access : Access) : Bytes #

Maps the buffer's memory into client space.

See: Buffer#map

  • OpenGL function: glMapBuffer
  • OpenGL version: 2.0

[View source]
def map(access : AccessMask, start : Size, count : Size, & : Bytes -> _) : Bool #

Maps a subset of the buffer's memory into client space.

The buffer is automatically unmapped when the block completes. Returns false if the buffer memory was corrupted while it was mapped.

See: Buffer#map


[View source]
def map(access : AccessMask, range : Range, & : Bytes -> _) : Bool #

Maps a subset of the buffer's memory into client space.

The buffer is automatically unmapped when the block completes. Returns false if the buffer memory was corrupted while it was mapped.

See: Buffer#map


[View source]
def map(access : Access, & : Bytes -> _) : Bool #

Maps the buffer's memory into the client space.

The buffer is automatically unmapped when the block completes. Returns false if the buffer memory was corrupted while it was mapped.

See: Buffer#map


[View source]
def mapped? : Bool #

Indicates whether the buffer is currently mapped.

See: Buffer#mapped?

  • OpenGL function: glGetBufferParameteriv
  • OpenGL enum: GL_BUFFER_MAPPED
  • OpenGL version: 2.0

[View source]
def mapping : TargetMap #

Retrieves information about the bound buffer's current map.

Raises if the buffer isn't mapped.

See: Buffer#mapping


[View source]
def mapping? : TargetMap | Nil #

Retrieves information about the bound buffer's current map.

Returns nil if the buffer isn't mapped.

See: Buffer#mapping?


[View source]
def size #

Size of the buffer's contents in bytes.

See: Buffer#size

  • OpenGL function: glGetBufferParameteri64v
  • OpenGL enum: GL_BUFFER_SIZE
  • OpenGL version: 3.2

def storage_flags : Gloop::Buffer::Storage #

Retrieves the flags previously set for the buffer's immutable storage.

See: #storage

See: Buffer#storage_flags

  • OpenGL function: glGetBufferParameteriv
  • OpenGL enum: GL_BUFFER_STORAGE_FLAGS
  • OpenGL version: 4.4

[View source]
def target : Target #

Target this binding refers to.


[View source]
def to_unsafe #

Returns an OpenGL enum representing this buffer binding target.


[View source]
def unbind : Nil #

Unbinds any previously bound buffer from this target.

  • OpenGL function: glBindBuffer
  • OpenGL version: 2.0

[View source]
def unmap : Bool #

Unmaps the buffer's memory from client space.

Returns false if the buffer memory was corrupted while it was mapped.

See: Buffer#unmap

  • OpenGL function: glUnmapBuffer
  • OpenGL version: 2.0

[View source]
def update(offset : Size, data) : self #

Updates a subset of the currently bound buffer's data store.

The number of bytes updated in the buffer is equal to the byte size of data. The data must have a #to_slice. Bytes, Slice, and StaticArray types are ideal for this.

See: Buffer#update

  • OpenGL function: glBufferSubData
  • OpenGL version: 2.0

[View source]
def usage : Gloop::Buffer::Usage #

Retrieves the usage hints previously provided for the buffer's data.

See: #data

See: Buffer#usage

  • OpenGL function: glGetBufferParameteriv
  • OpenGL enum: GL_BUFFER_USAGE
  • OpenGL version: 2.0

[View source]