glc_global.h

Go to the documentation of this file.
00001 /****************************************************************************
00002 
00003  This file is part of the GLC-lib library.
00004  Copyright (C) 2005-2008 Laurent Ribon (laumaya@users.sourceforge.net)
00005  http://glc-lib.sourceforge.net
00006 
00007  GLC-lib is free software; you can redistribute it and/or modify
00008  it under the terms of the GNU Lesser General Public License as published by
00009  the Free Software Foundation; either version 3 of the License, or
00010  (at your option) any later version.
00011 
00012  GLC-lib is distributed in the hope that it will be useful,
00013  but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  GNU Lesser General Public License for more details.
00016 
00017  You should have received a copy of the GNU Lesser General Public License
00018  along with GLC-lib; if not, write to the Free Software
00019  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
00020 
00021 *****************************************************************************/
00022 
00024 
00025 #ifndef GLC_GLOBAL_H_
00026 #define GLC_GLOBAL_H_
00027 
00028 #include <QMutex>
00029 #include <QtOpenGL>
00030 #include <QList>
00031 #include <QVector>
00032 #include <QHash>
00033 
00034 #include "glc_config.h"
00035 
00036 // GLC_lib typedef
00038 typedef unsigned int GLC_uint;
00039 
00041 typedef QVector<GLfloat> GLfloatVector;
00042 
00044 typedef QVector<GLuint> GLuintVector;
00045 
00046 typedef QList<GLuint> IndexList;
00047 typedef QVector<GLsizei> IndexSizes;
00048 typedef QVector<GLvoid*> OffsetVector;
00049 typedef QVector<GLuint> OffsetVectori;
00050 
00051 
00052 namespace glc
00053 {
00055         GLC_LIB_EXPORT GLC_uint GLC_GenID();
00056 
00058         GLC_LIB_EXPORT GLC_uint GLC_GenGeomID();
00059 
00061         GLC_LIB_EXPORT GLC_uint GLC_GenUserID();
00062 
00064         GLC_LIB_EXPORT GLC_uint GLC_Gen3DWidgetID();
00065 
00067         GLC_LIB_EXPORT GLC_uint GLC_GenShaderGroupID();
00068 
00070         inline GLC_uint decodeRgbId(const GLubyte*);
00071 
00073         inline void encodeRgbId(GLC_uint, GLubyte*);
00074 
00075         const int GLC_DISCRET= 70;
00076         const int GLC_POLYDISCRET= 60;
00077 
00078         extern QMutex iDMutex;
00079         extern QMutex geomIdMutex;
00080         extern QMutex userIdMutex;
00081         extern QMutex widget3dIdMutex;
00082         extern QMutex shadingGroupIdMutex;
00083 
00085         enum WidgetEventFlag
00086         {
00087                 AcceptEvent,
00088                 IgnoreEvent,
00089                 BlockedEvent
00090         };
00091 
00093         GLC_LIB_EXPORT const QString archivePrefix();
00094 
00096         GLC_LIB_EXPORT const QString archiveInfix();
00097 
00099         GLC_LIB_EXPORT const QString filePrefix();
00100 
00102         GLC_LIB_EXPORT const QString fileInfix();
00103 
00105         GLC_LIB_EXPORT bool isArchiveString(const QString& fileName);
00106 
00108         GLC_LIB_EXPORT bool isFileString(const QString& fileName);
00109 
00111         GLC_LIB_EXPORT QString builtArchiveString(const QString& Archive, const QString& entry);
00112 
00114         GLC_LIB_EXPORT QString builtFileString(const QString& File, const QString& entry);
00115 
00117         GLC_LIB_EXPORT QString archiveFileName(const QString& archiveString);
00118 
00120         GLC_LIB_EXPORT QString archiveEntryFileName(const QString& archiveString);
00121 
00122         // GLC_Lib version
00123         const QString version("2.2.0");
00124         const QString description("GLC_lib is a Open Source C++ class library that enables the quick creation of an OpenGL application based on QT4.");
00125 
00126 };
00127 
00128 // Return the GLC_uint decoded ID from RGBA encoded ID
00129 GLC_uint glc::decodeRgbId(const GLubyte* pcolorId)
00130 {
00131         GLC_uint returnId= 0;
00132         returnId|= (GLC_uint)pcolorId[0] << (0 * 8);
00133         returnId|= (GLC_uint)pcolorId[1] << (1 * 8);
00134         returnId|= (GLC_uint)pcolorId[2] << (2 * 8);
00135         // Only get first 24 bits
00136         //returnId|= (GLC_uint)pcolorId[3] << (3 * 8);
00137 
00138         return returnId;
00139 }
00140 
00141 // Encode Id to RGBA color
00142 void glc::encodeRgbId(GLC_uint id, GLubyte* colorId)
00143 {
00144         colorId[0]= static_cast<GLubyte>((id >> (0 * 8)) & 0xFF);
00145         colorId[1]= static_cast<GLubyte>((id >> (1 * 8)) & 0xFF);
00146         colorId[2]= static_cast<GLubyte>((id >> (2 * 8)) & 0xFF);
00147         colorId[3]= static_cast<GLubyte>((id >> (3 * 8)) & 0xFF);
00148 }
00149 
00150 
00151 #endif //GLC_GLOBAL_H_
00152 
00153 

SourceForge.net Logo

©2005-2011 Laurent Ribon