VR-Forces 4.0.4 Class Documentation
include/vrvGraphics/DtBufferObject.h
Go to the documentation of this file.
00001 /******************************************************************************
00002 ** Copyright (c) 2009 MAK Technologies, Inc.
00003 ** All rights reserved.
00004 ******************************************************************************/
00005 
00007 
00008 #pragma once
00009 
00010 #include <vrvGraphics/vrvGraphics.h>
00011 
00012 namespace makVrv
00013 {
00014 
00017    class DT_DLL_VRVGRAPHICS DtBufferObject
00018    {
00019    public:
00020 
00021       enum ArrayType
00022       {
00023          Vertex3,
00024          Vertex4,
00025          Color3,
00026          Color4,
00027          Normal,
00028          TextureCoordinate
00029       };
00030 
00031       enum Usage
00032       {
00033          Static,  //Data hardly changes
00034          Dynamic, //Data frequently changes
00035          Stream  //Data usually changes
00036       };
00037 
00039       DtBufferObject(Usage usage );
00040 
00042       ~DtBufferObject();
00043 
00044       //Change the size of the buffer.
00045       void resize(unsigned int sizeBytes);
00046 
00047       //Get the buffer's size
00048       unsigned int size() const;
00049 
00051       inline unsigned int objectId() const { return myVertexBufferObjectId; }
00052 
00053       //Set the size and initialize the buffer with data.
00054       void setData(const float* data, unsigned int sizeBytes);
00055 
00056       //Upload a subsection of data starting at the offset for count floats,
00057       //Either resize or setData must be called before uploading data.
00058       void uploadData(unsigned int offsetBytes, unsigned int sizeBytes,const float* data);
00059 
00060       //Bind the buffer for use.
00061       void bind(ArrayType type, unsigned int stride = 0, unsigned int offset = 0, 
00062          unsigned int textureUnit = 0);
00063 
00064       //Unbind the buffer for use.
00065       void unbind(ArrayType type,unsigned int textureUnit = 0);
00066 
00067    protected:
00068       unsigned int myVertexBufferObjectId;
00069       unsigned int myUsage;
00070       unsigned int mySize;
00071 
00072    };
00073 
00074 }

Document ID: Generated on Fri Jun 29 16:33:32 EDT 2012 from SVN revision 116588
Copyright © 2005-2012 VT MÄK Inc. All Rights Reserved (www.mak.com)