00001 //////////////////////////////////////////////////////////////////////////////// 00002 // Scorched3D (c) 2000-2009 00003 // 00004 // This file is part of Scorched3D. 00005 // 00006 // Scorched3D is free software; you can redistribute it and/or modify 00007 // it under the terms of the GNU General Public License as published by 00008 // the Free Software Foundation; either version 2 of the License, or 00009 // (at your option) any later version. 00010 // 00011 // Scorched3D is distributed in the hope that it will be useful, 00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 // GNU General Public License for more details. 00015 // 00016 // You should have received a copy of the GNU General Public License 00017 // along with Scorched3D; if not, write to the Free Software 00018 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00019 //////////////////////////////////////////////////////////////////////////////// 00020 00021 #if !defined(__INCLUDE_GLVertexBufferObjecth_INCLUDE__) 00022 #define __INCLUDE_GLVertexBufferObjecth_INCLUDE__ 00023 00024 #include <GLEXT/GLState.h> 00025 00026 class GLVertexBufferObject 00027 { 00028 public: 00029 ///> create buffer. Tell the handler if you wish to store indices or other data. 00030 GLVertexBufferObject(bool indexbuffer = false); 00031 ~GLVertexBufferObject(); 00032 00033 ///> call ONCE after creation, to set data size and optionally data. 00034 ///> pointer to data can be NULL to just (re)size the buffer. 00035 ///> usage can be one of GL_STREAM_DRAW_ARB, GL_STREAM_READ_ARB, 00036 ///> GL_STREAM_COPY_ARB, GL_STATIC_DRAW_ARB, GL_STATIC_READ_ARB, 00037 ///> GL_STATIC_COPY_ARB, GL_DYNAMIC_DRAW_ARB, GL_DYNAMIC_READ_ARB, 00038 ///> GL_DYNAMIC_COPY_ARB 00039 void init_data(unsigned size, const void* data, int usage); 00040 ///> init/set sub data 00041 void init_sub_data(unsigned offset, unsigned subsize, const void* data); 00042 ///> bind buffer 00043 void bind() const; 00044 ///> unbind buffer 00045 void unbind() const; 00046 ///> map buffer to address, access is one of GL_READ_ONLY_ARB, GL_WRITE_ONLY_ARB, 00047 ///> GL_ERAD_WRITE_ARB. 00048 void* map(int access); 00049 ///> get size of mapped space 00050 unsigned int get_map_size() const { return size_; } 00051 ///> unmap buffer 00052 void unmap(); 00053 00054 protected: 00055 GLuint id_; 00056 unsigned int size_; 00057 bool mapped_; 00058 int target_; 00059 }; 00060 00061 #endif // __INCLUDE_GLVertexBufferObjecth_INCLUDE__
1.5.3