glc_state.cpp

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 #include "glc_state.h"
00026 #include "glc_ext.h"
00027 #include "sceneGraph/glc_octree.h"
00028 
00029 #include <QGLFramebufferObject>
00030 
00031 bool GLC_State::m_VboSupported= false;
00032 bool GLC_State::m_UseVbo= true;
00033 bool GLC_State::m_GlslSupported= false;
00034 bool GLC_State::m_PointSpriteSupported= false;
00035 bool GLC_State::m_UseShader= true;
00036 bool GLC_State::m_UseSelectionShader= false;
00037 bool GLC_State::m_IsInSelectionMode= false;
00038 bool GLC_State::m_IsPixelCullingActivated= true;
00039 bool GLC_State::m_IsFrameBufferSupported= false;
00040 
00041 QString GLC_State::m_Version;
00042 QString GLC_State::m_Vendor;
00043 QString GLC_State::m_Renderer;
00044 
00045 bool GLC_State::m_UseCache= false;
00046 
00047 GLC_CacheManager GLC_State::m_CacheManager;
00048 
00049 bool GLC_State::m_IsSpacePartitionningActivated= false;
00050 bool GLC_State::m_IsFrustumCullingActivated= false;
00051 
00052 GLC_State::~GLC_State()
00053 {
00054 }
00055 
00056 bool GLC_State::vboSupported()
00057 {
00058         return m_VboSupported;
00059 }
00060 
00061 bool GLC_State::vboUsed()
00062 {
00063         return m_UseVbo;
00064 }
00065 
00066 bool GLC_State::glslSupported()
00067 {
00068         return m_GlslSupported;
00069 }
00070 
00071 bool GLC_State::frameBufferSupported()
00072 {
00073         return m_IsFrameBufferSupported;
00074 }
00075 
00076 bool GLC_State::glslUsed()
00077 {
00078         return m_UseShader && m_GlslSupported;
00079 }
00080 
00081 bool GLC_State::pointSpriteSupported()
00082 {
00083         return m_PointSpriteSupported;
00084 }
00085 
00086 bool GLC_State::selectionShaderUsed()
00087 {
00088         return m_UseSelectionShader;
00089 }
00090 
00091 bool GLC_State::isInSelectionMode()
00092 {
00093         return m_IsInSelectionMode;
00094 }
00095 
00096 QString GLC_State::version()
00097 {
00098         return m_Version;
00099 }
00100 
00101 QString GLC_State::vendor()
00102 {
00103         return m_Vendor;
00104 }
00105 
00106 QString GLC_State::renderer()
00107 {
00108         return m_Renderer;
00109 }
00110 
00111 bool GLC_State::vendorIsNvidia()
00112 {
00113         return m_Vendor.contains("NVIDIA");
00114 }
00115 
00116 bool GLC_State::isPixelCullingActivated()
00117 {
00118         return m_IsPixelCullingActivated;
00119 }
00120 
00121 bool GLC_State::cacheIsUsed()
00122 {
00123         return m_UseCache;
00124 }
00125 
00126 GLC_CacheManager& GLC_State::currentCacheManager()
00127 {
00128         return m_CacheManager;
00129 }
00130 
00131 bool GLC_State::isSpacePartitionningActivated()
00132 {
00133         return m_IsSpacePartitionningActivated;
00134 }
00135 
00136 int GLC_State::defaultOctreeDepth()
00137 {
00138         return GLC_Octree::defaultDepth();
00139 }
00140 
00141 bool GLC_State::isFrustumCullingActivated()
00142 {
00143         return m_IsFrustumCullingActivated;
00144 }
00145 
00146 void GLC_State::init()
00147 {
00148         setVboSupport();
00149         setGlslSupport();
00150         setPointSpriteSupport();
00151         setFrameBufferSupport();
00152         m_Version= (char *) glGetString(GL_VERSION);
00153         m_Vendor= (char *) glGetString(GL_VENDOR);
00154         m_Renderer= (char *) glGetString(GL_RENDERER);
00155 }
00156 
00157 void GLC_State::setVboSupport()
00158 {
00159         m_VboSupported= glc::extensionIsSupported("ARB_vertex_buffer_object") && glc::loadVboExtension();
00160         setVboUsage(m_UseVbo);
00161 }
00162 
00163 void GLC_State::setVboUsage(const bool vboUsed)
00164 {
00165         m_UseVbo= m_VboSupported && vboUsed;
00166 }
00167 
00168 void GLC_State::setGlslSupport()
00169 {
00170         m_GlslSupported= glc::extensionIsSupported("GL_ARB_shading_language_100") && glc::loadGlSlExtension();
00171         setGlslUsage(m_UseShader);
00172 }
00173 
00174 void GLC_State::setPointSpriteSupport()
00175 {
00176         m_PointSpriteSupported= glc::extensionIsSupported("GL_ARB_point_parameters") && glc::loadPointSpriteExtension();
00177 }
00178 
00179 void GLC_State::setFrameBufferSupport()
00180 {
00181         m_IsFrameBufferSupported= QGLFramebufferObject::hasOpenGLFramebufferObjects();
00182 }
00183 
00184 void GLC_State::setGlslUsage(const bool glslUsage)
00185 {
00186         m_UseShader= m_GlslSupported && glslUsage;
00187 }
00188 
00189 void GLC_State::setSelectionShaderUsage(const bool shaderUsed)
00190 {
00191         m_UseSelectionShader= shaderUsed && m_GlslSupported;
00192 }
00193 
00194 void GLC_State::setSelectionMode(const bool mode)
00195 {
00196         m_IsInSelectionMode= mode;
00197 }
00198 
00199 void GLC_State::setPixelCullingUsage(const bool activation)
00200 {
00201         m_IsPixelCullingActivated= activation;
00202 }
00203 
00204 void GLC_State::setCacheUsage(const bool cacheUsage)
00205 {
00206         m_UseCache= cacheUsage;
00207 }
00208 
00209 void GLC_State::setCurrentCacheManager(const GLC_CacheManager& cacheManager)
00210 {
00211         m_CacheManager= cacheManager;
00212 }
00213 
00214 void GLC_State::setSpacePartionningUsage(const bool usage)
00215 {
00216         m_IsSpacePartitionningActivated= usage;
00217 }
00218 
00219 void GLC_State::setDefaultOctreeDepth(int depth)
00220 {
00221         GLC_Octree::setDefaultDepth(depth);
00222 }
00223 
00224 void GLC_State::setFrustumCullingUsage(bool usage)
00225 {
00226         m_IsFrustumCullingActivated= usage;
00227 }

SourceForge.net Logo

©2005-2011 Laurent Ribon