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
00072 inline bool Window::hasCommonExtension(UInt32 id)
00073 {
00074 bool has = _commonExtensions[id];
00075 return has;
00076 }
00077
00083 inline void* Window::getFunction(UInt32 id)
00084 {
00085 if(id >= _extFunctions.size())
00086 {
00087 FINFO(("Window::getFunction: illegal id %d!\n", id));
00088 return NULL;
00089 }
00090 if(_extFunctions[id] == NULL)
00091 {
00092 FINFO(("Window::getFunction: function \"%s\" is NULL!\n",
00093 _registeredFunctions[id].c_str()));
00094 return NULL;
00095 }
00096 return _extFunctions[id];
00097 }
00098
00103 inline void* Window::getFunctionNoCheck(UInt32 id)
00104 {
00105 return _extFunctions[ id ];
00106 }
00107
00111 inline Real32 Window::getConstantValue(GLenum id)
00112 {
00113 return getConstantValuev(id)[0];
00114 }
00115
00120 inline void Window::setGLLibraryName(const Char8 *s)
00121 {
00122 _glLibraryName = s;
00123 }
00124
00128 inline Int32 Window::getExtensionId(const Char8 *s)
00129 {
00130 std::vector<std::string>::iterator it;
00131
00132 it = std::find(_registeredExtensions.begin(),
00133 _registeredExtensions.end(),
00134 s);
00135
00136 if(it == _registeredExtensions.end())
00137 return -1;
00138
00139 return Int32(it -_registeredExtensions.begin());
00140 }
00141
00144 inline const std::vector<std::string> &Window::getExtensions(void)
00145 {
00146 return _extensions;
00147 }
00148
00151 inline const std::vector<std::string> &Window::getRegisteredExtensions(void)
00152 {
00153 return _registeredExtensions;
00154 }
00155
00158 inline const std::vector<std::string> &Window::getRegisteredFunctions(void)
00159 {
00160 return _registeredFunctions;
00161 }
00162
00165 inline const std::vector<std::string> &Window::getIgnoredExtensions(void)
00166 {
00167 return _ignoredExtensions;
00168 }
00169
00170 inline void Window::setGLObjectId(UInt32 id, UInt32 id2)
00171 {
00172 if(id < _ids.size())
00173 {
00174 _ids[id] = id2;
00175 }
00176 else
00177 {
00178 _ids.resize(_glObjects.size());
00179 if(id < _ids.size())
00180 _ids[id] = id2;
00181 else
00182 SWARNING << "Window::setGLObjectId: id (" << id << ") is not valid!" << std::endl;
00183 }
00184 }
00185
00186 inline UInt32 Window::getGLObjectId(UInt32 id)
00187 {
00188 if(id < _ids.size())
00189 return _ids[id];
00190
00191
00192 return 0;
00193 }
00194
00205 inline UInt32 Window::packIdStatus(UInt32 id, GLObjectStatusE status)
00206 {
00207 return (id << statusShift) | status;
00208 }
00209
00212 inline void Window::unpackIdStatus(UInt32 idstatus, UInt32 &id,
00213 GLObjectStatusE &status)
00214 {
00215 id = idstatus >> statusShift;
00216 status = static_cast<GLObjectStatusE>(idstatus & statusMask);
00217 }
00218
00219
00220
00221
00222 inline Window::GLObject::GLObject( GLObjectFunctor funct ) :
00223 _functor(funct),
00224 _refCounter(0),
00225 _lastValidate(0)
00226 {
00227 }
00228
00229 inline Window::GLObjectFunctor& Window::GLObject::getFunctor(void)
00230 {
00231 return _functor;
00232 };
00233
00234 inline void Window::GLObject::setFunctor(GLObjectFunctor funct)
00235 {
00236 _functor = funct;
00237 };
00238
00239 inline UInt32 Window::GLObject::getLastValidate(void)
00240 {
00241 return _lastValidate;
00242 }
00243
00244 inline void Window::GLObject::setLastValidate(UInt32 val)
00245 {
00246 _lastValidate = val;
00247 }
00248
00249 inline UInt32 Window::GLObject::getRefCounter(void)
00250 {
00251 return _refCounter;
00252 }
00253
00254 inline UInt32 Window::GLObject::incRefCounter(void)
00255 {
00256 UInt32 val;
00257
00258 if ( ! _GLObjectLock )
00259 {
00260 _GLObjectLock = ThreadManager::the()->getLock(NULL);
00261 }
00262
00263 _GLObjectLock->aquire();
00264 val = _refCounter = _refCounter + 1;
00265 _GLObjectLock->release();
00266
00267 return val;
00268 }
00269
00270 inline UInt32 Window::GLObject::decRefCounter(void)
00271 {
00272 UInt32 val;
00273
00274 if(! _GLObjectLock)
00275 {
00276 _GLObjectLock = ThreadManager::the()->getLock(NULL);
00277 }
00278
00279 _GLObjectLock->aquire();
00280 if(_refCounter)
00281 val = _refCounter = _refCounter - 1;
00282 else
00283 val = 0;
00284 _GLObjectLock->release();
00285
00286 return val;
00287 }
00288
00289 OSG_END_NAMESPACE
00290
00291
00292 #define OSGWINDOW_INLINE_CVSID "@(#)$Id:$"