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
00064 inline bool Window::hasExtension(UInt32 id)
00065 {
00066 return _availExtensions[id];
00067 }
00068
00071 inline bool Window::hasCommonExtension(UInt32 id)
00072 {
00073 if(id >= _commonExtensions.size())
00074 return false;
00075
00076 return _commonExtensions[id];
00077 }
00078
00084 inline void* Window::getFunction(UInt32 id)
00085 {
00086 if(id >= _extFunctions.size())
00087 {
00088 FINFO(("Window::getFunction: illegal id %d!\n", id));
00089 return NULL;
00090 }
00091 if(_extFunctions[id] == NULL)
00092 {
00093 FINFO(("Window::getFunction: function \"%s\" is NULL!\n",
00094 _registeredFunctions[id].c_str()));
00095 return NULL;
00096 }
00097 return _extFunctions[id];
00098 }
00099
00104 inline void* Window::getFunctionNoCheck(UInt32 id)
00105 {
00106 return _extFunctions[ id ];
00107 }
00108
00112 inline Real32 Window::getConstantValue(GLenum id)
00113 {
00114 return getConstantValuev(id)[0];
00115 }
00116
00121 inline void Window::setGLLibraryName(const Char8 *s)
00122 {
00123 _glLibraryName = s;
00124 }
00125
00129 inline UInt32 Window::getGLVersion(void)
00130 {
00131 return _glVersion;
00132 }
00133
00137 inline Int32 Window::getExtensionId(const Char8 *s)
00138 {
00139 std::vector<std::string>::iterator it;
00140
00141 it = std::find(_registeredExtensions.begin(),
00142 _registeredExtensions.end(),
00143 s);
00144
00145 if(it == _registeredExtensions.end())
00146 return -1;
00147
00148 return Int32(it -_registeredExtensions.begin());
00149 }
00150
00153 inline const std::vector<std::string> &Window::getExtensions(void)
00154 {
00155 return _extensions;
00156 }
00157
00160 inline const std::vector<std::string> &Window::getRegisteredExtensions(void)
00161 {
00162 return _registeredExtensions;
00163 }
00164
00167 inline const std::vector<std::string> &Window::getRegisteredFunctions(void)
00168 {
00169 return _registeredFunctions;
00170 }
00171
00174 inline const std::vector<std::string> &Window::getIgnoredExtensions(void)
00175 {
00176 return _ignoredExtensions;
00177 }
00178
00179 inline void Window::setGLObjectId(UInt32 osgId, UInt32 id2)
00180 {
00181 if(osgId < _ids.size())
00182 {
00183 _ids[osgId] = id2;
00184 }
00185 else
00186 {
00187 _ids.resize(_glObjects.size());
00188 if(osgId < _ids.size())
00189 _ids[osgId] = id2;
00190 else
00191 SWARNING << "Window::setGLObjectId: id (" << osgId << ") is not valid!" << std::endl;
00192 }
00193 }
00194
00195 inline UInt32 Window::getGLObjectId(UInt32 osgId)
00196 {
00197 if(osgId < _ids.size())
00198 return _ids[osgId];
00199
00200
00201 return 0;
00202 }
00203
00204 inline UInt32 Window::getGLObjectsSize(void)
00205 {
00206 return _glObjects.size();
00207 }
00208
00219 inline UInt32 Window::packIdStatus(UInt32 osgId, GLObjectStatusE status)
00220 {
00221 return (osgId << statusShift) | status;
00222 }
00223
00226 inline void Window::unpackIdStatus(UInt32 idstatus, UInt32 &osgId,
00227 GLObjectStatusE &status)
00228 {
00229 osgId = idstatus >> statusShift;
00230 status = static_cast<GLObjectStatusE>(idstatus & statusMask);
00231 }
00232
00233
00234
00235
00236 inline Window::GLObject::GLObject( GLObjectFunctor funct ) :
00237 _functor(funct),
00238 _refCounter(0),
00239 _lastValidate(0)
00240 {
00241 }
00242
00243 inline Window::GLObjectFunctor& Window::GLObject::getFunctor(void)
00244 {
00245 return _functor;
00246 };
00247
00248 inline void Window::GLObject::setFunctor(GLObjectFunctor funct)
00249 {
00250 _functor = funct;
00251 };
00252
00253 inline UInt32 Window::GLObject::getLastValidate(void)
00254 {
00255 return _lastValidate;
00256 }
00257
00258 inline void Window::GLObject::setLastValidate(UInt32 val)
00259 {
00260 _lastValidate = val;
00261 }
00262
00263 inline UInt32 Window::GLObject::getRefCounter(void)
00264 {
00265 return _refCounter;
00266 }
00267
00268 inline UInt32 Window::GLObject::incRefCounter(void)
00269 {
00270 UInt32 val;
00271
00272 if ( ! _GLObjectLock )
00273 {
00274 _GLObjectLock = ThreadManager::the()->getLock(NULL);
00275 }
00276
00277 _GLObjectLock->aquire();
00278 val = _refCounter = _refCounter + 1;
00279 _GLObjectLock->release();
00280
00281 return val;
00282 }
00283
00284 inline UInt32 Window::GLObject::decRefCounter(void)
00285 {
00286 UInt32 val;
00287
00288 if(! _GLObjectLock)
00289 {
00290 _GLObjectLock = ThreadManager::the()->getLock(NULL);
00291 }
00292
00293 _GLObjectLock->aquire();
00294 if(_refCounter)
00295 val = _refCounter = _refCounter - 1;
00296 else
00297 val = 0;
00298 _GLObjectLock->release();
00299
00300 return val;
00301 }
00302
00303 OSG_END_NAMESPACE
00304
00305
00306 #define OSGWINDOW_INLINE_CVSID "@(#)$Id:$"