Logo
  • Main Page
  • Related Pages
  • Modules
  • Classes
  • Files

mmsfbbuffer.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2005-2007 Stefan Schwarzer, Jens Schneider,             *
00003  *                           Matthias Hardt, Guido Madaus                  *
00004  *                                                                         *
00005  *   Copyright (C) 2007-2008 BerLinux Solutions GbR                        *
00006  *                           Stefan Schwarzer & Guido Madaus               *
00007  *                                                                         *
00008  *   Copyright (C) 2009-2011 BerLinux Solutions GmbH                       *
00009  *                                                                         *
00010  *   Authors:                                                              *
00011  *      Stefan Schwarzer   <stefan.schwarzer@diskohq.org>,                 *
00012  *      Matthias Hardt     <matthias.hardt@diskohq.org>,                   *
00013  *      Jens Schneider     <jens.schneider@diskohq.org>,                   *
00014  *      Guido Madaus       <guido.madaus@diskohq.org>,                     *
00015  *      Patrick Helterhoff <patrick.helterhoff@diskohq.org>,               *
00016  *      René Bählkow       <rene.baehlkow@diskohq.org>                     *
00017  *                                                                         *
00018  *   This library is free software; you can redistribute it and/or         *
00019  *   modify it under the terms of the GNU Lesser General Public            *
00020  *   License version 2.1 as published by the Free Software Foundation.     *
00021  *                                                                         *
00022  *   This library is distributed in the hope that it will be useful,       *
00023  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00024  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU     *
00025  *   Lesser General Public License for more details.                       *
00026  *                                                                         *
00027  *   You should have received a copy of the GNU Lesser General Public      *
00028  *   License along with this library; if not, write to the                 *
00029  *   Free Software Foundation, Inc.,                                       *
00030  *   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA            *
00031  **************************************************************************/
00032 
00033 #ifndef MMSFBBUFFER_H_
00034 #define MMSFBBUFFER_H_
00035 
00036 #include "mmstools/base.h"
00037 #include "mmstools/mmstypes.h"
00038 #include "mmsgui/fb/mmsfbgl.h"
00039 #include <stdlib.h>
00040 
00041 class MMSFBBuffer {
00042     public:
00043         //! list of index arrays
00044         typedef struct {
00045             //! index data
00046             MMS_INDEX_ARRAY *arrays;
00047             //! maximum number of arrays
00048             unsigned short int  max_arrays;
00049             //! arrays which are initialized
00050             unsigned short int  num_arrays;
00051         } INDEX_BUFFER;
00052 
00053         //! list of vertex arrays
00054         typedef struct {
00055             //! vertex data
00056             MMS_VERTEX_ARRAY    *arrays;
00057             //! maximum number of arrays
00058             unsigned short int  max_arrays;
00059             //! arrays which are initialized
00060             unsigned short int  num_arrays;
00061         } VERTEX_BUFFER;
00062 
00063         //! buffer types
00064         typedef enum {
00065             //! buffer not initialized
00066             BUFFER_TYPE_NOTSET = 0,
00067             //! index and vertex buffer
00068             BUFFER_TYPE_INDEX_VERTEX
00069         } BUFFER_TYPE;
00070 
00071         //! contains a OpenGL index buffer object with additional description
00072         typedef struct {
00073             //! OpenGL's buffer object
00074             unsigned int        bo;
00075             //! index data description
00076             MMS_INDEX_BUFFER    *buffers;
00077             //! number of buffers
00078             unsigned short int  num_buffers;
00079         } INDEX_BUFFER_OBJECT;
00080 
00081         //! contains a OpenGL vertex buffer object with additional description
00082         typedef struct {
00083             //! OpenGL's buffer object
00084             unsigned int        bo;
00085             //! vertex data description
00086             MMS_VERTEX_BUFFER   *buffers;
00087             //! number of buffers
00088             unsigned short int  num_buffers;
00089         } VERTEX_BUFFER_OBJECT;
00090 
00091         //! extkey description
00092         class EXTKEY {
00093             public:
00094                 //! is extkey initialized?
00095                 bool initialized;
00096 
00097                 //! use count
00098                 unsigned int    use_count;
00099 
00100                 //! own key
00101                 unsigned int    key;
00102 
00103 #ifdef __HAVE_OPENGL__
00104                 //! OpenGL's buffer object which contains indices
00105                 unsigned int    ibo;
00106                 unsigned int    ibo_size;
00107                 unsigned int    ibo_used;
00108 
00109                 //! OpenGL's buffer object which contains vertices
00110                 unsigned int    vbo;
00111                 unsigned int    vbo_size;
00112                 unsigned int    vbo_used;
00113 #endif
00114 
00115                 EXTKEY(unsigned int key);
00116                 ~EXTKEY();
00117                 bool allocVertexArray(unsigned int size);
00118                 bool reserveIndexArray(unsigned int requested_size, unsigned int *offset);
00119                 bool reserveVertexArray(unsigned int requested_size, unsigned int *offset);
00120         };
00121 
00122         //! buffer description
00123         class BUFFER {
00124             public:
00125                 //! is buffer initialized?
00126                 bool initialized;
00127 
00128                 //! use count
00129                 unsigned int    use_count;
00130 
00131                 //! type of buffer
00132                 BUFFER_TYPE     type;
00133 
00134                 //! index data
00135                 INDEX_BUFFER    index_buffer;
00136 
00137                 //! vertex data
00138                 VERTEX_BUFFER   vertex_buffer;
00139 
00140 #ifdef __HAVE_OPENGL__
00141                 //! OpenGL's buffer object which contains indices
00142                 INDEX_BUFFER_OBJECT     index_bo;
00143 
00144                 //! OpenGL's buffer object which contains vertices
00145                 VERTEX_BUFFER_OBJECT    vertex_bo;
00146 #endif
00147 
00148                 BUFFER();
00149                 ~BUFFER();
00150                 void initIndexBuffer(EXTKEY *extkey, INDEX_BUFFER index_buffer);
00151                 void initVertexBuffer(EXTKEY *extkey, VERTEX_BUFFER vertex_buffer);
00152                 bool getBuffers(MMSFBBuffer::INDEX_BUFFER **index_buffer, MMSFBBuffer::VERTEX_BUFFER **vertex_buffer);
00153 #ifdef __HAVE_OPENGL__
00154                 bool getBufferObjects(MMSFBBuffer::INDEX_BUFFER_OBJECT **index_bo, MMSFBBuffer::VERTEX_BUFFER_OBJECT **vertex_bo);
00155 #endif
00156         };
00157 
00158     private:
00159 
00160         //! external ID of buffer (64bit, extkey + subkey)
00161         unsigned long long ext_id;
00162 
00163         //! defines mapping between extkey of buffer and content
00164         typedef std::map<unsigned int, MMSFBBuffer::EXTKEY*> EXTKEY_INDEX;
00165 
00166         //! static key index
00167         static EXTKEY_INDEX extkey_index;
00168 
00169         //! pointer to extkey content
00170         EXTKEY *extkey;
00171 
00172         //! defines mapping between external ID of buffer and content
00173         typedef std::map<unsigned long long, MMSFBBuffer::BUFFER*> BUFFER_INDEX;
00174 
00175         //! static buffer index
00176         static BUFFER_INDEX buffer_index;
00177 
00178         //! pointer to buffer content
00179         BUFFER *buffer;
00180 
00181     public:
00182         MMSFBBuffer(unsigned int extkey, unsigned int subkey);
00183         ~MMSFBBuffer();
00184         bool isInitialized();
00185         bool getExtKey(MMSFBBuffer::EXTKEY **extkey);
00186         bool initBuffer(INDEX_BUFFER index_buffer, VERTEX_BUFFER vertex_buffer);
00187         bool getBuffer(MMSFBBuffer::BUFFER **buffer);
00188 };
00189 
00190 #endif /* MMSFBBUFFER_H_ */
00191 
00192 
00193 

Generated by doxygen