00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038 #include <stdlib.h>
00039 #include <stdio.h>
00040
00041 #include "OSGConfig.h"
00042
00043 OSG_BEGIN_NAMESPACE
00044
00045
00046
00050 inline void Window::setSize(UInt16 width, UInt16 height)
00051 {
00052 setHeight(height);
00053 setWidth(width);
00054 }
00055
00056 inline bool Window::isResizePending(void)
00057 {
00058 return _sfResizePending.getValue();
00059 }
00060
00063 inline bool Window::hasExtension(UInt32 id)
00064 {
00065 if(id >= _availExtensions.size())
00066 {
00067 FWARNING(("Extension id [%u] out-of-range!\n", id));
00068
00069 return false;
00070 }
00071
00072 return _availExtensions[id];
00073 }
00074
00077 inline bool Window::hasCommonExtension(UInt32 id)
00078 {
00079 if(id >= _commonExtensions.size())
00080 return false;
00081
00082 return _commonExtensions[id];
00083 }
00084
00090 inline Window::GLExtensionFunction Window::getFunction(UInt32 id)
00091 {
00092 if(id >= _extFunctions.size())
00093 {
00094 FINFO(("Window::getFunction: illegal id %d!\n", id));
00095 return NULL;
00096 }
00097 if(_extFunctions[id] == NULL)
00098 {
00099 FINFO(("Window::getFunction: function \"%s\" is NULL!\n",
00100 _registeredFunctions[id].c_str()));
00101 return NULL;
00102 }
00103 return _extFunctions[id];
00104 }
00105
00110 inline Window::GLExtensionFunction Window::getFunctionNoCheck(UInt32 id)
00111 {
00112 return _extFunctions[ id ];
00113 }
00114
00118 inline Real32 Window::getConstantValue(GLenum id)
00119 {
00120 return getConstantValuev(id)[0];
00121 }
00122
00127 inline void Window::setGLLibraryName(const Char8 *s)
00128 {
00129 _glLibraryName = s;
00130 }
00131
00135 inline UInt32 Window::getGLVersion(void)
00136 {
00137 return _glVersion;
00138 }
00139
00143 inline Int32 Window::getExtensionId(const Char8 *s)
00144 {
00145 std::vector<std::string>::iterator it;
00146
00147 it = std::find(_registeredExtensions.begin(),
00148 _registeredExtensions.end(),
00149 s);
00150
00151 if(it == _registeredExtensions.end())
00152 return -1;
00153
00154 return Int32(it -_registeredExtensions.begin());
00155 }
00156
00159 inline const std::vector<std::string> &Window::getExtensions(void)
00160 {
00161 return _extensions;
00162 }
00163
00166 inline const std::vector<std::string> &Window::getRegisteredExtensions(void)
00167 {
00168 return _registeredExtensions;
00169 }
00170
00173 inline const std::vector<std::string> &Window::getRegisteredFunctions(void)
00174 {
00175 return _registeredFunctions;
00176 }
00177
00180 inline const std::vector<std::string> &Window::getIgnoredExtensions(void)
00181 {
00182 return _ignoredExtensions;
00183 }
00184
00185 inline void Window::setGLObjectId(UInt32 osgId, UInt32 id2)
00186 {
00187 if(osgId < _ids.size())
00188 {
00189 _ids[osgId] = id2;
00190 }
00191 else
00192 {
00193 _ids.resize(_glObjects.size());
00194 if(osgId < _ids.size())
00195 _ids[osgId] = id2;
00196 else
00197 SWARNING << "Window::setGLObjectId: id (" << osgId << ") is not valid!" << std::endl;
00198 }
00199 }
00200
00201 inline UInt32 Window::getGLObjectId(UInt32 osgId)
00202 {
00203 if(osgId < _ids.size())
00204 return _ids[osgId];
00205
00206
00207 return 0;
00208 }
00209
00210 inline UInt32 Window::getGLObjectsSize(void)
00211 {
00212 return _glObjects.size();
00213 }
00214
00225 inline UInt32 Window::packIdStatus(UInt32 osgId, GLObjectStatusE status)
00226 {
00227 return (osgId << statusShift) | status;
00228 }
00229
00232 inline void Window::unpackIdStatus(UInt32 idstatus, UInt32 &osgId,
00233 GLObjectStatusE &status)
00234 {
00235 osgId = idstatus >> statusShift;
00236 status = static_cast<GLObjectStatusE>(idstatus & statusMask);
00237 }
00238
00239
00240
00241
00242 inline Window::GLObject::GLObject( GLObjectFunctor funct ) :
00243 _functor(funct),
00244 _refCounter(0),
00245 _lastValidate(0)
00246 {
00247 }
00248
00249 inline Window::GLObjectFunctor& Window::GLObject::getFunctor(void)
00250 {
00251 return _functor;
00252 };
00253
00254 inline void Window::GLObject::setFunctor(GLObjectFunctor funct)
00255 {
00256 _functor = funct;
00257 };
00258
00259 inline UInt32 Window::GLObject::getLastValidate(void)
00260 {
00261 return _lastValidate;
00262 }
00263
00264 inline void Window::GLObject::setLastValidate(UInt32 val)
00265 {
00266 _lastValidate = val;
00267 }
00268
00269 inline UInt32 Window::GLObject::getRefCounter(void)
00270 {
00271 return _refCounter;
00272 }
00273
00274 inline UInt32 Window::GLObject::incRefCounter(void)
00275 {
00276 UInt32 val;
00277
00278 if ( ! _GLObjectLock )
00279 {
00280 _GLObjectLock = ThreadManager::the()->getLock(NULL);
00281 }
00282
00283 _GLObjectLock->aquire();
00284 val = _refCounter = _refCounter + 1;
00285 _GLObjectLock->release();
00286
00287 return val;
00288 }
00289
00290 inline UInt32 Window::GLObject::decRefCounter(void)
00291 {
00292 UInt32 val;
00293
00294 if(! _GLObjectLock)
00295 {
00296 _GLObjectLock = ThreadManager::the()->getLock(NULL);
00297 }
00298
00299 _GLObjectLock->aquire();
00300 if(_refCounter)
00301 val = _refCounter = _refCounter - 1;
00302 else
00303 val = 0;
00304 _GLObjectLock->release();
00305
00306 return val;
00307 }
00308
00309 OSG_END_NAMESPACE
00310
00311
00312 #define OSGWINDOW_INLINE_CVSID "@(#)$Id:$"