# Visualization Library

A lightweight C++ OpenGL middleware for 2D/3D graphics

[Home] [Tutorials] [All Classes] [Grouped Classes]

Public Types | Public Member Functions | Static Public Member Functions | Protected Attributes

# vl::Buffer Class Reference

Implements a buffer whose storage is in local memory. More...

`#include <Buffer.hpp>`

Inheritance diagram for vl::Buffer:

List of all members.

## Public Types

enum | EAllocationMode { UserAllocatedBuffer, AutoAllocatedBuffer }

## Public Member Functions

| Buffer ()
| Buffer (const Buffer &other)
Buffer & | operator= (const Buffer &other)
void | swap (Buffer &other)
| ~Buffer ()
void | clear ()
void | resize (size_t byte_count, size_t alignment=0)
void | setUserAllocatedBuffer (void *ptr, size_t bytes)
| Uses a user-allocated buffer as storage.
void | setAllocationMode (EAllocationMode mode)
EAllocationMode | allocationMode () const
size_t | bytesUsed () const
bool | empty () const
unsigned char * | ptr ()
const unsigned char * | ptr () const
size_t | alignment () const

## Static Public Member Functions

static void * | alignedMalloc (size_t bytes, size_t alignment)
static void | alignedFree (void *ptr)

## Protected Attributes

unsigned char * | mPtr
size_t | mByteCount
size_t | mAlignment
EAllocationMode | mAllocationMode

## Detailed Description

Implements a buffer whose storage is in local memory.

Definition at line 46 of file Buffer.hpp.

## Member Enumeration Documentation

enum vl::Buffer::EAllocationMode

Enumerator:

  UserAllocatedBuffer |
  AutoAllocatedBuffer |

Definition at line 51 of file Buffer.hpp.

## Constructor & Destructor Documentation

vl::Buffer::Buffer | ( | ) | `[inline]`

Definition at line 58 of file Buffer.hpp.

References AutoAllocatedBuffer, mAlignment, mAllocationMode, mByteCount, mPtr, NULL, VL_DEBUG_SET_OBJECT_NAME, and VL_DEFAULT_BUFFER_BYTE_ALIGNMENT.

vl::Buffer::Buffer | ( | const Buffer & | other ) | `[inline]`

Definition at line 66 of file Buffer.hpp.

References AutoAllocatedBuffer, mAlignment, mAllocationMode, mByteCount, mPtr, NULL, VL_DEBUG_SET_OBJECT_NAME, and VL_DEFAULT_BUFFER_BYTE_ALIGNMENT.

vl::Buffer::~Buffer | ( | ) | `[inline]`

Definition at line 114 of file Buffer.hpp.

References clear().

## Member Function Documentation

Buffer& vl::Buffer::operator= | ( | const Buffer & | other ) | `[inline]`

Definition at line 76 of file Buffer.hpp.

References AutoAllocatedBuffer, bytesUsed(), mAlignment, mAllocationMode, mByteCount, mPtr, ptr(), resize(), and VL_CHECK.

void vl::Buffer::swap | ( | Buffer & | other ) | `[inline]`

Definition at line 98 of file Buffer.hpp.

References mAlignment, mByteCount, and mPtr.

void vl::Buffer::clear | ( | ) | `[inline]`

Definition at line 119 of file Buffer.hpp.

References alignedFree(), AutoAllocatedBuffer, mAllocationMode, mByteCount, mPtr, and NULL.

Referenced by vl::ArrayAbstract::clear(), resize(), setAllocationMode(), vl::BufferObject::setBufferData(), vl::BufferObject::setBufferSubData(), setUserAllocatedBuffer(), and ~Buffer().

void vl::Buffer::resize | ( | size_t | byte_count,
|  | size_t | alignment = `0`
| ) |  | `[inline]`

Definition at line 128 of file Buffer.hpp.

References alignedFree(), alignedMalloc(), alignment(), AutoAllocatedBuffer, clear(), mAlignment, mAllocationMode, mByteCount, vl::min(), mPtr, NULL, ptr(), and VL_CHECK.

Referenced by vl::BufferObject::downloadBufferObject(), vl::ArrayAbstract::operator=(), operator=(), and vl::Array< bvec2, GLbyte, 2, GL_BYTE >::resize().

void vl::Buffer::setUserAllocatedBuffer | ( | void * | ptr,
|  | size_t | bytes
| ) |  | `[inline]`

Uses a user-allocated buffer as storage.

After calling this function any call to resize() is illegal. Calling this function enables the UserAllocatedBuffer mode. Call setAllocationMode( AutoAllocatedBuffer ) to revert to the default behaviour.

Definition at line 171 of file Buffer.hpp.

References clear(), mAlignment, mAllocationMode, mByteCount, mPtr, and UserAllocatedBuffer.

void vl::Buffer::setAllocationMode | ( | EAllocationMode | mode ) | `[inline]`

Definition at line 180 of file Buffer.hpp.

References clear(), mAlignment, mAllocationMode, mByteCount, and mPtr.

EAllocationMode vl::Buffer::allocationMode | ( | ) | const`[inline]`

Definition at line 193 of file Buffer.hpp.

References mAllocationMode.

size_t vl::Buffer::bytesUsed | ( | ) | const`[inline]`

Definition at line 195 of file Buffer.hpp.

References mByteCount.

Referenced by vl::ArrayAbstract::bytesUsed(), vl::ArrayAbstract::operator=(), operator=(), and vl::BufferObject::setBufferData().

bool vl::Buffer::empty | ( | ) | const`[inline]`

Definition at line 197 of file Buffer.hpp.

References mByteCount.

unsigned char* vl::Buffer::ptr | ( | ) | `[inline]`

Definition at line 199 of file Buffer.hpp.

References mPtr.

Referenced by vl::OpenGLContext::bindVAS(), vl::BufferObject::downloadBufferObject(), vl::BufferObject::mapBufferObject(), operator=(), vl::ArrayAbstract::ptr(), resize(), vl::BufferObject::setBufferData(), and vl::BufferObject::setBufferSubData().

const unsigned char* vl::Buffer::ptr | ( | ) | const`[inline]`

Definition at line 201 of file Buffer.hpp.

References mPtr.

size_t vl::Buffer::alignment | ( | ) | const`[inline]`

Definition at line 203 of file Buffer.hpp.

References mAlignment.

Referenced by resize().

static void* vl::Buffer::alignedMalloc | ( | size_t | bytes,
|  | size_t | alignment
| ) |  | `[inline, static]`

Definition at line 207 of file Buffer.hpp.

References NULL.

Referenced by resize().

static void vl::Buffer::alignedFree | ( | void * | ptr ) | `[inline, static]`

Definition at line 247 of file Buffer.hpp.

References NULL.

Referenced by clear(), and resize().

## Member Data Documentation

unsigned char* vl::Buffer::mPtr`[protected]`

Definition at line 263 of file Buffer.hpp.

Referenced by Buffer(), clear(), operator=(), ptr(), resize(), setAllocationMode(), setUserAllocatedBuffer(), and swap().

size_t vl::Buffer::mByteCount`[protected]`

Definition at line 264 of file Buffer.hpp.

Referenced by Buffer(), bytesUsed(), clear(), empty(), operator=(), resize(), setAllocationMode(), setUserAllocatedBuffer(), and swap().

size_t vl::Buffer::mAlignment`[protected]`

Definition at line 265 of file Buffer.hpp.

Referenced by alignment(), Buffer(), operator=(), resize(), setAllocationMode(), setUserAllocatedBuffer(), and swap().

EAllocationMode vl::Buffer::mAllocationMode`[protected]`

Definition at line 266 of file Buffer.hpp.

Referenced by allocationMode(), Buffer(), clear(), operator=(), resize(), setAllocationMode(), and setUserAllocatedBuffer().

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

- D:/VL/BuildSystem/VL_DISTRO/Visualization_Library_SDK/src/vlCore/Buffer.hpp

Visualization Library v2011.09.1162 Reference Documentation
Copyright 2005-2011 Michele Bosi. All rights reserved.
Updated on Thu Jan 26 2012 00:44:03.
Permission is granted to use this page to write and publish articles regarding Visualization Library.