zMol
A viewer for molecular data using OpenGL and ambient occlusion
Public Member Functions
zmol::buffer_object_mapping Class Reference

#include <buffer_object.hpp>

Inherits zmol::noncopyable_::noncopyable.

List of all members.

Public Member Functions

 buffer_object_mapping (buffer_object &p_bufobj, GLenum const p_access)
 buffer_object_mapping (buffer_object &p_bufobj, GLenum const p_access, GLintptr const p_offset, GLsizeiptr p_length)
 ~buffer_object_mapping ()
void * get_mapped_pointer ()
void const * get_mapped_pointer () const
void flush_subrange (GLintptr const p_offset, GLsizeiptr p_length)
void flush_entire_range ()

Detailed Description

RAII-style class for mapping the buffer object contents to the local address space. Example usage:

buffer_object buf(GL_ARRAY_BUFFER, GL_STATIC_DRAW);
buf.resize(4096);
{
buffer_object_mapping map(buf, GL_MAP_WRITE_BIT);
void *ptr = map.get_mapped_pointer();
// .... do something with the data pointed at by ptr ....
// buffer_object_mapping destructor automatically unmaps the pointer
}

Constructor & Destructor Documentation

zmol::buffer_object_mapping::buffer_object_mapping ( buffer_object p_bufobj,
GLenum const  p_access 
)
explicit

Constructor. Maps the entire buffer object data to the local address space using glMapBufferRange().

Parameters:
p_bufobjBuffer object whose data shall be mapped
p_accessSee the OpenGL glMapBufferRange() documentation for an explanation of this value
zmol::buffer_object_mapping::buffer_object_mapping ( buffer_object p_bufobj,
GLenum const  p_access,
GLintptr const  p_offset,
GLsizeiptr  p_length 
)
explicit

Constructor. Maps a subset of the buffer object data to the local address space using glMapBufferRange().

Parameters:
p_bufobjBuffer object whose data shall be mapped
p_accessSee the OpenGL glMapBufferRange() documentation for an explanation of this value
p_offsetOffset within the buffer object data, in bytes; the mapping will start at this offset
p_lengthLength of the buffer object data to map, in bytes; the mapping will be valid for this amount of bytes
zmol::buffer_object_mapping::~buffer_object_mapping ( )

Destructor. Unmaps the buffer object data by using glUnmapBuffer().


Member Function Documentation

void zmol::buffer_object_mapping::flush_entire_range ( )

Explicitely flush the entire mapped range. See the OpenGL glMapBufferRange() documentation for details about explicit flushing. This call is necessary only if explicit flushing was enabled in the constructor's access argument.

void zmol::buffer_object_mapping::flush_subrange ( GLintptr const  p_offset,
GLsizeiptr  p_length 
)

Explicitely flush a subrange. See the OpenGL glMapBufferRange() documentation for details about explicit flushing. This call is necessary only if explicit flushing was enabled in the constructor's access argument.

Parameters:
p_offsetOffset, in bytes, of the region to flush
p_lengthLength, in bytes, of the region to flush
void * zmol::buffer_object_mapping::get_mapped_pointer ( )

Returns the pointer to the mapped data.

void const * zmol::buffer_object_mapping::get_mapped_pointer ( ) const

Returns the pointer to the mapped data.