Brenta Engine 1.0
Loading...
Searching...
No Matches
Brenta::Types::Buffer Class Reference

Buffer wrapper around OpenGL buffer objects. More...

#include <buffer.hpp>

Public Member Functions

 Buffer ()
 Default constructor, does nothing.
 
 Buffer (GLenum input_target)
 Constructor that creates a buffer object.
 
void Bind ()
 Bind the buffer object.
 
void Unbind ()
 Unbind the buffer object.
 
void Delete ()
 Delete the buffer object.
 
int GetId ()
 Get the buffer object id.
 
GLenum GetTarget ()
 Get the buffer object target.
 
void SetId (unsigned int id)
 Set the buffer object id.
 
void SetTarget (GLenum target)
 Set the buffer object target.
 
void CopyData (GLsizeiptr size, const void *data, GLenum usage)
 Copy data to the buffer object.
 
void CopyVertices (GLsizeiptr size, const void *data, GLenum usage)
 Copy data to the buffer object.
 
void CopyIndices (GLsizeiptr size, const void *data, GLenum usage)
 Copy data to the buffer object.
 

Data Fields

unsigned int id
 Buffer object id, generated by OpenGL.
 
GLenum target
 Buffer object target (like GL_ARRAY_BUFFER, GL_ELEMENT_ARRAY_BUFFER...)
 

Detailed Description

Buffer wrapper around OpenGL buffer objects.

This class is a wrapper around OpenGL buffer objects. It provides a simple interface to create, bind, unbind and delete buffer objects. It also provides methods to copy data to the buffer objects.

This class offers methods to:

  • create and delete buffer object
  • bind and unbind buffer object
  • copy data to the buffer object

Definition at line 49 of file buffer.hpp.

Constructor & Destructor Documentation

◆ Buffer() [1/2]

Brenta::Types::Buffer::Buffer ( )
inline

Default constructor, does nothing.

Definition at line 65 of file buffer.hpp.

◆ Buffer() [2/2]

Buffer::Buffer ( GLenum input_target)

Constructor that creates a buffer object.

Parameters
targetBuffer object target

This constructor creates a buffer object with the specified target. It calls the OpenGL function glGenBuffers to generate a buffer object id and glBindBuffer to bind the buffer object. The buffer has a default destructor that deletes the buffer object when it goes out of scope.

Definition at line 34 of file buffer.cpp.

Member Function Documentation

◆ Bind()

void Buffer::Bind ( )

Bind the buffer object.

Buffers must be bound before they can be used!

Definition at line 62 of file buffer.cpp.

◆ CopyData()

void Buffer::CopyData ( GLsizeiptr size,
const void * data,
GLenum usage )

Copy data to the buffer object.

Parameters
sizeSize of the data in bytes
dataPointer to the data
usageOpenGL usage hint (like GL_STATIC_DRAW)

This method copies data to the buffer object. The size of the data is specified in bytes, the data is a pointer to the data and the usage is an OpenGL usage hint.

Definition at line 41 of file buffer.cpp.

◆ CopyIndices()

void Buffer::CopyIndices ( GLsizeiptr size,
const void * data,
GLenum usage )

Copy data to the buffer object.

Parameters
sizeSize of the data in bytes
dataPointer to the data
usageOpenGL usage hint (like GL_STATIC_DRAW)

Same as CopyVertices but for target GL_ELEMENT_ARRAY_BUFFER.

Definition at line 46 of file buffer.cpp.

◆ CopyVertices()

void Buffer::CopyVertices ( GLsizeiptr size,
const void * data,
GLenum usage )

Copy data to the buffer object.

Parameters
sizeSize of the data in bytes
dataPointer to the data
usageOpenGL usage hint (like GL_STATIC_DRAW)

Same as Copydata but for target GL_ARRAY_BUFFER. The naming is more specific to the use case.

Definition at line 54 of file buffer.cpp.

◆ Delete()

void Buffer::Delete ( )

Delete the buffer object.

Definition at line 77 of file buffer.cpp.

◆ GetId()

int Buffer::GetId ( )

Get the buffer object id.

Returns
Buffer object id

Definition at line 87 of file buffer.cpp.

◆ GetTarget()

GLenum Buffer::GetTarget ( )

Get the buffer object target.

Returns
Buffer object target

Definition at line 92 of file buffer.cpp.

◆ SetId()

void Buffer::SetId ( unsigned int id)

Set the buffer object id.

Parameters
idBuffer object id

Definition at line 97 of file buffer.cpp.

◆ SetTarget()

void Buffer::SetTarget ( GLenum target)

Set the buffer object target.

Parameters
targetBuffer object target

Definition at line 102 of file buffer.cpp.

◆ Unbind()

void Buffer::Unbind ( )

Unbind the buffer object.

Definition at line 72 of file buffer.cpp.

Field Documentation

◆ id

unsigned int Brenta::Types::Buffer::id

Buffer object id, generated by OpenGL.

Definition at line 55 of file buffer.hpp.

◆ target

GLenum Brenta::Types::Buffer::target

Buffer object target (like GL_ARRAY_BUFFER, GL_ELEMENT_ARRAY_BUFFER...)

Definition at line 60 of file buffer.hpp.


The documentation for this class was generated from the following files: