All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Pages
Luminous::Buffer Class Reference

This class represents a general unformatted linear memory stored on the graphics card. More...

#include <Luminous/Buffer.hpp>

Inheritance diagram for Luminous::Buffer:
Luminous::RenderResource

Public Types

enum  MapAccess {
  MAP_READ = GL_MAP_READ_BIT, MAP_WRITE = GL_MAP_WRITE_BIT, MAP_READ_WRITE = MAP_READ | MAP_WRITE, MAP_INVALIDATE_RANGE = GL_MAP_INVALIDATE_RANGE_BIT,
  MAP_INVALIDATE_BUFFER = GL_MAP_INVALIDATE_BUFFER_BIT, MAP_FLUSH_EXPLICIT = GL_MAP_FLUSH_EXPLICIT_BIT, MAP_UNSYNCHRONIZED = GL_MAP_UNSYNCHRONIZED_BIT
}
 Map access modifiers.
 
enum  Type { UNKNOWN = 0, VERTEX = GL_ARRAY_BUFFER, INDEX = GL_ELEMENT_ARRAY_BUFFER, UNIFORM = GL_UNIFORM_BUFFER }
 Buffer object type.
 
enum  Usage {
  STATIC_DRAW = GL_STATIC_DRAW, STATIC_READ = GL_STATIC_READ, STATIC_COPY = GL_STATIC_COPY, STREAM_DRAW = GL_STREAM_DRAW,
  STREAM_READ = GL_STREAM_READ, STREAM_COPY = GL_STREAM_COPY, DYNAMIC_DRAW = GL_DYNAMIC_DRAW, DYNAMIC_READ = GL_DYNAMIC_READ,
  DYNAMIC_COPY = GL_DYNAMIC_COPY
}
 Hint indicating the expected application usage pattern of the buffer. More...
 
- Public Types inherited from Luminous::RenderResource
typedef uint64_t Id
 Id of a resource.
 
enum  Type {
  VertexArray, Buffer, Program, Texture,
  RenderBuffer, FrameBuffer
}
 Different types of render resources. More...
 

Public Member Functions

LUMINOUS_API Buffer ()
 Constructor.
 
LUMINOUS_API Buffer (const Buffer &b)
 Copy constructor. More...
 
LUMINOUS_API Buffer (Buffer &&b)
 Move constructor. More...
 
LUMINOUS_API const void * data () const
 Get a pointer to the buffer data. More...
 
LUMINOUS_API Bufferoperator= (const Buffer &b)
 Assignment operator. More...
 
LUMINOUS_API Bufferoperator= (Buffer &&b)
 Move assignment operator. More...
 
LUMINOUS_API void setData (const void *data, size_t size, Usage usage)
 Set the buffer contents. More...
 
LUMINOUS_API size_t size () const
 Get the size of the buffer. More...
 
LUMINOUS_API Usage usage () const
 Get the usage hints for the buffer. More...
 
LUMINOUS_API ~Buffer ()
 Destructor.
 
- Public Member Functions inherited from Luminous::RenderResource
unsigned int expiration () const
 Returns resource expiration time. More...
 
int generation () const
 Returns generation of this resource. More...
 
void invalidate ()
 Invalidates correspondent GPU objects and forces uploading of data to GPU.
 
RenderResourceoperator= (RenderResource &&rr)
 Move assignment operator. More...
 
 RenderResource (Type type)
 Constructor of RenderResource. More...
 
 RenderResource (RenderResource &&rr)
 Move constructor. More...
 
Id resourceId () const
 Returns identifier of resource. More...
 
Type resourceType () const
 Returns type of the resource. More...
 
void setExpiration (unsigned int seconds)
 Set resource expiration time. More...
 
void setGeneration (int generation)
 Sets generation for this resource. More...
 
virtual ~RenderResource ()
 Destructor of RenderResource.
 

Friends

class VertexArray
 

Additional Inherited Members

- Protected Member Functions inherited from Luminous::RenderResource
RenderResourceoperator= (const RenderResource &rr)
 Assignment operator. More...
 
 RenderResource (const RenderResource &rr)
 Copy constructor. More...
 

Detailed Description

This class represents a general unformatted linear memory stored on the graphics card.

It can be used to store vertex data, pixel data retrieved from images or the framebuffer, etc. GPU correspondent of this class is BufferGL.

Examples:
Widget3DExample.cpp.

Member Enumeration Documentation

Hint indicating the expected application usage pattern of the buffer.

A buffers data store is sourced when it is read from as a result of OpenGL commands which specify images, or invoke shaders accessing buffer data as a result of drawing commands or compute shader dispatch.

Enumerator
STATIC_DRAW 

The data store contents will be specied once by the application, and sourced many times.

STATIC_READ 

The data store contents will be specied once by reading data from the GL, and queried many times by the application.

STATIC_COPY 

The data store contents will be specied once by reading data from the GL, and sourced many times.

STREAM_DRAW 

The data store contents will be specied once by the application, and sourced at most a few times.

STREAM_READ 

The data store contents will be specied once by reading data from the GL, and queried at most a few times by the application.

STREAM_COPY 

The data store contents will be specied once by reading data from the GL, and sourced at most a few times.

DYNAMIC_DRAW 

The data store contents will be respecied repeatedly by the application, and sourced many times.

DYNAMIC_READ 

The data store contents will be respecied repeatedly by reading data from the GL, and queried many times by the application.

DYNAMIC_COPY 

The data store contents will be respecied repeatedly by reading data from the GL, and sourced many times.

Constructor & Destructor Documentation

LUMINOUS_API Luminous::Buffer::Buffer ( const Buffer b)

Copy constructor.

Parameters
bbuffer to copy
LUMINOUS_API Luminous::Buffer::Buffer ( Buffer &&  b)

Move constructor.

Parameters
bbuffer to move

Member Function Documentation

LUMINOUS_API const void* Luminous::Buffer::data ( ) const

Get a pointer to the buffer data.

Returns
data pointer
LUMINOUS_API Buffer& Luminous::Buffer::operator= ( const Buffer b)

Assignment operator.

Parameters
bbuffer to copy
LUMINOUS_API Buffer& Luminous::Buffer::operator= ( Buffer &&  b)

Move assignment operator.

Parameters
bbuffer to move
LUMINOUS_API void Luminous::Buffer::setData ( const void *  data,
size_t  size,
Usage  usage 
)

Set the buffer contents.

Does not copy the data. The pointer must remain valid as long as the buffer is in use.

Parameters
datapointer to data
sizesize of the data in bytes
usageusage hint
LUMINOUS_API size_t Luminous::Buffer::size ( ) const

Get the size of the buffer.

Returns
size of the buffer in bytes
LUMINOUS_API Usage Luminous::Buffer::usage ( ) const

Get the usage hints for the buffer.

Returns
usage hints