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  Version 2.0.0 Beta 1, packaged on April 2010.
00006 
00007  http://glc-lib.sourceforge.net
00008 
00009  GLC-lib is free software; you can redistribute it and/or modify
00010  it under the terms of the GNU General Public License as published by
00011  the Free Software Foundation; either version 2 of the License, or
00012  (at your option) any later version.
00013 
00014  GLC-lib is distributed in the hope that it will be useful,
00015  but WITHOUT ANY WARRANTY; without even the implied warranty of
00016  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017  GNU General Public License for more details.
00018 
00019  You should have received a copy of the GNU General Public License
00020  along with GLC-lib; if not, write to the Free Software
00021  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
00022 
00023 *****************************************************************************/
00024 
00026 
00027 #include "glc_state.h"
00028 #include "glc_ext.h"
00029 #include "../sceneGraph/glc_octree.h"
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 
00040 QString GLC_State::m_Version;
00041 QString GLC_State::m_Vendor;
00042 QString GLC_State::m_Renderer;
00043 
00044 bool GLC_State::m_UseCache= false;
00045 
00046 GLC_CacheManager GLC_State::m_CacheManager;
00047 
00048 bool GLC_State::m_IsSpacePartitionningActivated= false;
00049 bool GLC_State::m_IsFrustumCullingActivated= false;
00050 
00051 GLC_State::~GLC_State()
00052 {
00053 }
00054 
00055 bool GLC_State::vboSupported()
00056 {
00057         return m_VboSupported;
00058 }
00059 
00060 bool GLC_State::vboUsed()
00061 {
00062         return m_UseVbo;
00063 }
00064 
00065 bool GLC_State::glslSupported()
00066 {
00067         return m_GlslSupported;
00068 }
00069 
00070 bool GLC_State::glslUsed()
00071 {
00072         return m_UseShader;
00073 }
00074 
00075 bool GLC_State::pointSpriteSupported()
00076 {
00077         return m_PointSpriteSupported;
00078 }
00079 
00080 bool GLC_State::selectionShaderUsed()
00081 {
00082         return m_UseSelectionShader;
00083 }
00084 
00085 bool GLC_State::isInSelectionMode()
00086 {
00087         return m_IsInSelectionMode;
00088 }
00089 
00090 QString GLC_State::version()
00091 {
00092         return m_Version;
00093 }
00094 
00095 QString GLC_State::vendor()
00096 {
00097         return m_Vendor;
00098 }
00099 
00100 QString GLC_State::renderer()
00101 {
00102         return m_Renderer;
00103 }
00104 
00105 bool GLC_State::vendorIsNvidia()
00106 {
00107         return m_Vendor.contains("NVIDIA");
00108 }
00109 
00110 bool GLC_State::isPixelCullingActivated()
00111 {
00112         return m_IsPixelCullingActivated;
00113 }
00114 
00115 bool GLC_State::cacheIsUsed()
00116 {
00117         return m_UseCache;
00118 }
00119 
00120 GLC_CacheManager& GLC_State::currentCacheManager()
00121 {
00122         return m_CacheManager;
00123 }
00124 
00125 bool GLC_State::isSpacePartitionningActivated()
00126 {
00127         return m_IsSpacePartitionningActivated;
00128 }
00129 
00130 int GLC_State::defaultOctreeDepth()
00131 {
00132         return GLC_Octree::defaultDepth();
00133 }
00134 
00135 bool GLC_State::isFrustumCullingActivated()
00136 {
00137         return m_IsFrustumCullingActivated;
00138 }
00139 
00140 void GLC_State::init()
00141 {
00142         setVboSupport();
00143         setGlslSupport();
00144         setPointSpriteSupport();
00145         m_Version= (char *) glGetString(GL_VERSION);
00146         m_Vendor= (char *) glGetString(GL_VENDOR);
00147         m_Renderer= (char *) glGetString(GL_RENDERER);
00148 }
00149 
00150 void GLC_State::setVboSupport()
00151 {
00152         m_VboSupported= glc::extensionIsSupported("ARB_vertex_buffer_object") && glc::loadVboExtension();
00153 }
00154 
00155 void GLC_State::setVboUsage(const bool vboUsed)
00156 {
00157         m_UseVbo= m_VboSupported && vboUsed;
00158 }
00159 
00160 void GLC_State::setGlslSupport()
00161 {
00162         m_GlslSupported= glc::extensionIsSupported("GL_ARB_shading_language_100") && glc::loadGlSlExtension();
00163 }
00164 
00165 void GLC_State::setPointSpriteSupport()
00166 {
00167         m_PointSpriteSupported= glc::extensionIsSupported("GL_ARB_point_parameters") && glc::loadPointSpriteExtension();
00168 }
00169 
00170 void GLC_State::setGlslUsage(const bool glslUsage)
00171 {
00172         m_UseShader= m_GlslSupported && glslUsage;
00173 }
00174 
00175 void GLC_State::setSelectionShaderUsage(const bool shaderUsed)
00176 {
00177         m_UseSelectionShader= shaderUsed && m_GlslSupported;
00178 }
00179 
00180 void GLC_State::setSelectionMode(const bool mode)
00181 {
00182         m_IsInSelectionMode= mode;
00183 }
00184 
00185 void GLC_State::setPixelCullingUsage(const bool activation)
00186 {
00187         m_IsPixelCullingActivated= activation;
00188 }
00189 
00190 void GLC_State::setCacheUsage(const bool cacheUsage)
00191 {
00192         m_UseCache= cacheUsage;
00193 }
00194 
00195 void GLC_State::setCurrentCacheManager(const GLC_CacheManager& cacheManager)
00196 {
00197         m_CacheManager= cacheManager;
00198 }
00199 
00200 void GLC_State::setSpacePartionningUsage(const bool usage)
00201 {
00202         m_IsSpacePartitionningActivated= usage;
00203 }
00204 
00205 void GLC_State::setDefaultOctreeDepth(int depth)
00206 {
00207         GLC_Octree::setDefaultDepth(depth);
00208 }
00209 
00210 void GLC_State::setFrustumCullingUsage(bool usage)
00211 {
00212         m_IsFrustumCullingActivated= usage;
00213 }

SourceForge.net Logo

©2005 Laurent Ribon