GLC_lib  2.5.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
glc_state.cpp
Go to the documentation of this file.
1 /****************************************************************************
2 
3  This file is part of the GLC-lib library.
4  Copyright (C) 2005-2008 Laurent Ribon (laumaya@users.sourceforge.net)
5  http://glc-lib.sourceforge.net
6 
7  GLC-lib is free software; you can redistribute it and/or modify
8  it under the terms of the GNU Lesser General Public License as published by
9  the Free Software Foundation; either version 3 of the License, or
10  (at your option) any later version.
11 
12  GLC-lib is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU Lesser General Public License for more details.
16 
17  You should have received a copy of the GNU Lesser General Public License
18  along with GLC-lib; if not, write to the Free Software
19  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 
21 *****************************************************************************/
22 
24 
25 #include "glc_state.h"
26 #include "glc_ext.h"
27 #include "sceneGraph/glc_octree.h"
28 
29 #include <QGLFramebufferObject>
30 
31 bool GLC_State::m_VboSupported= false;
32 bool GLC_State::m_UseVbo= true;
33 bool GLC_State::m_GlslSupported= false;
35 bool GLC_State::m_UseShader= true;
41 
42 QString GLC_State::m_Version;
43 QString GLC_State::m_Vendor;
44 QString GLC_State::m_Renderer;
45 
46 bool GLC_State::m_UseCache= false;
47 
49 
52 bool GLC_State::m_IsValid= false;
53 
55 {
56 }
57 
59 {
60  return m_VboSupported;
61 }
62 
64 {
65  return m_UseVbo;
66 }
67 
69 {
70  return m_GlslSupported;
71 }
72 
74 {
76 }
77 
79 {
81 }
82 
84 {
85  return m_UseShader && m_GlslSupported;
86 }
87 
89 {
91 }
92 
94 {
95  return m_UseSelectionShader;
96 }
97 
99 {
100  return m_IsInSelectionMode;
101 }
102 
104 {
105  return m_Version;
106 }
107 
109 {
110  return m_Vendor;
111 }
112 
114 {
115  return m_Renderer;
116 }
117 
119 {
120  return m_Vendor.contains("NVIDIA");
121 }
122 
124 {
126 }
127 
129 {
130  return m_UseCache;
131 }
132 
134 {
135  return m_CacheManager;
136 }
137 
139 {
141 }
142 
144 {
145  return GLC_Octree::defaultDepth();
146 }
147 
149 {
151 }
152 
154 {
155  if (!m_IsValid)
156  {
157  Q_ASSERT((NULL != QGLContext::currentContext()) && QGLContext::currentContext()->isValid());
158  setVboSupport();
159  setGlslSupport();
162  m_Version= (char *) glGetString(GL_VERSION);
163  m_Vendor= (char *) glGetString(GL_VENDOR);
164  m_Renderer= (char *) glGetString(GL_RENDERER);
165 
166  m_IsValid= true;
167  }
168 }
169 
171 {
172  return m_IsValid;
173 }
174 
176 {
177  m_VboSupported= glc::extensionIsSupported("ARB_vertex_buffer_object") && glc::loadVboExtension();
179 }
180 
181 void GLC_State::setVboUsage(const bool vboUsed)
182 {
184 }
185 
187 {
188  m_GlslSupported= glc::extensionIsSupported("GL_ARB_shading_language_100") && glc::loadGlSlExtension();
190 }
191 
193 {
195 }
196 
198 {
199  m_IsFrameBufferSupported= QGLFramebufferObject::hasOpenGLFramebufferObjects();
200 }
201 
203 {
204  m_IsFrameBufferBlitSupported= QGLFramebufferObject::hasOpenGLFramebufferBlit();
205 }
206 
207 void GLC_State::setGlslUsage(const bool glslUsage)
208 {
209  m_UseShader= m_GlslSupported && glslUsage;
210 }
211 
212 void GLC_State::setSelectionShaderUsage(const bool shaderUsed)
213 {
214  m_UseSelectionShader= shaderUsed && m_GlslSupported;
215 }
216 
217 void GLC_State::setSelectionMode(const bool mode)
218 {
219  m_IsInSelectionMode= mode;
220 }
221 
222 void GLC_State::setPixelCullingUsage(const bool activation)
223 {
224  m_IsPixelCullingActivated= activation;
225 }
226 
227 void GLC_State::setCacheUsage(const bool cacheUsage)
228 {
229  m_UseCache= cacheUsage;
230 }
231 
233 {
234  m_CacheManager= cacheManager;
235 }
236 
238 {
240 }
241 
243 {
245 }
246 
248 {
250 }

©2005-2013 Laurent Ribon