Brenta Engine 1.1
Loading...
Searching...
No Matches
brenta::types::buffer Class Reference

Buffer wrapper around OpenGL buffer objects. More...

#include <buffer.hpp>

Inheritance diagram for brenta::types::buffer:
brenta::types::framebuffer

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 destroy ()
 Delete the buffer object.
 
int get_id ()
 Get the buffer object id.
 
GLenum get_target ()
 Get the buffer object target.
 
void set_id (unsigned int id)
 Set the buffer object id.
 
void set_target (GLenum target)
 Set the buffer object target.
 
void copy_data (GLsizeiptr size, const void *data, GLenum usage)
 Copy data to the buffer object.
 
void copy_vertices (GLsizeiptr size, const void *data, GLenum usage)
 Copy data to the buffer object.
 
void copy_indices (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.

◆ copy_data()

void buffer::copy_data ( 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.

◆ copy_indices()

void buffer::copy_indices ( 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.

◆ copy_vertices()

void buffer::copy_vertices ( 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.

◆ destroy()

void buffer::destroy ( )

Delete the buffer object.

Definition at line 77 of file buffer.cpp.

◆ get_id()

int buffer::get_id ( )

Get the buffer object id.

Returns
Buffer object id

Definition at line 87 of file buffer.cpp.

◆ get_target()

GLenum buffer::get_target ( )

Get the buffer object target.

Returns
Buffer object target

Definition at line 92 of file buffer.cpp.

◆ set_id()

void buffer::set_id ( unsigned int id)

Set the buffer object id.

Parameters
idBuffer object id

Definition at line 97 of file buffer.cpp.

◆ set_target()

void buffer::set_target ( 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: