/* -*-c++-*- Producer - Copyright (C) 2001-2004 Don Burns * * This library is open source and may be redistributed and/or modified under * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or * (at your option) any later version. The full license is in LICENSE file * included with this distribution, and on the openscenegraph.org website. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * OpenSceneGraph Public License for more details. */ #include using namespace std; using namespace Producer; const std::string RenderSurface::defaultWindowName = std::string(" *** Producer::RenderSurface *** "); const unsigned int RenderSurface::UnknownDimension = 0xFFFFFFFF; const unsigned int RenderSurface::UnknownAmount = 0xFFFFFFFF; unsigned int RenderSurface::_numScreens = RenderSurface::UnknownAmount; bool RenderSurface::_shareAllGLContexts = false; GLContext RenderSurface::_globallySharedGLContext = 0L; void RenderSurface::shareAllGLContexts(bool flag) { _shareAllGLContexts = flag; } bool RenderSurface::allGLContextsAreShared() { return _shareAllGLContexts; } const std::string &RenderSurface::getDefaultWindowName() { return defaultWindowName; } RenderSurface::RenderSurface( void ) { _drawableType = DrawableType_Window; _hostname = ""; _displayNum = 0; _screen = 0; _mayFullScreen = true; _isFullScreen = true; // This used to be #ifdefed for the X11 implementation // but the code is pure C++ and should compile anywhere // The _dislayNum variable is used by CGL as well. char *envptr = getenv( "DISPLAY" ); if( envptr != NULL && *envptr != 0 ) { size_t p0 = 0; size_t p1 = string(envptr).find(":", p0); _hostname = string(envptr).substr(p0,p1); p0 = p1+1; p1 = string(envptr).find(".", p0); if( p1 > 0 ) { _displayNum = atoi((string(envptr).substr(p0,p1)).c_str()); p0 = p1+1; p1 = string(envptr).length() - p0; if( p1 > 0 ) _screen = atoi((string(envptr).substr(p0,p1)).c_str()); } else if( p1 < string(envptr).length() ) { p1 = string(envptr).length(); _displayNum = atoi((string(envptr).substr(p0,p1)).c_str()); _screen = 0; } } _windowLeft = 0; _windowRight = 1; _windowBottom = 0; _windowTop = 1; _windowX = 0; _windowY = 0; _windowWidth = UnknownDimension; _windowHeight = UnknownDimension; _screenWidth = UnknownDimension; _screenHeight = UnknownDimension; _customFullScreenOriginX = 0; _customFullScreenOriginY = 0; _customFullScreenWidth = UnknownDimension; _customFullScreenHeight = UnknownDimension; _useCustomFullScreen = false; _dpy = NULL; _win = 0; _parent = 0; _readDrawableRenderSurface = 0L; _visualInfo = NULL; _visualID = 0; _decorations = true; _useCursorFlag = true; _currentCursor = 0; _nullCursor = 0; _defaultCursor = 0; _windowName = defaultWindowName; _realized = false; _useConfigEventThread = true; _threadReady = new OpenThreads::Barrier(2); _overrideRedirectFlag = false; char *override_envptr = getenv( "PRODUCER_OVERRIDE_REDIRECT" ); if( override_envptr != NULL && *override_envptr != 0 ) { if (strcmp(override_envptr,"true")==0 || strcmp(override_envptr,"True")==0 || strcmp(override_envptr,"TRUE")==0) { _overrideRedirectFlag = true; } else { _overrideRedirectFlag = false; } } _useDefaultEsc = true; _checkOwnEvents = true; _inputRectangle.set( -1.0, 1.0, -1.0, 1.0 ); _bindInputRectangleToWindowSize = false; _realizeBlock = new Producer::Block; _rtt_mode = RenderToTextureMode_None; //_rtt_mode = RenderToRGBTexture; _rtt_target = Texture2D; _rtt_options = RenderToTextureOptions_Default; _rtt_mipmap = 0; _rtt_face = PositiveX; _rtt_dirty_mipmap = true; _rtt_dirty_face = true; _glcontext = NULL; _sharedGLContext = NULL; #ifdef _WIN32_IMPLEMENTATION _ownWindow = true; _ownVisualChooser = true; _ownVisualInfo = true; _hinstance = NULL; _glcontext = NULL; _mx = 0; _my = 0; _mbutton = 0; #endif } RenderSurface::~RenderSurface( void ) { cancel(); _fini(); while (isRunning()) { //std::cout << "waiting for RenderSurface to cancel"<block(); return true; } void RenderSurface::positionPointer( int x, int y ) { _positionPointer(x,y); } void RenderSurface::initThreads() { _initThreads(); } RenderSurface::RenderToTextureMode RenderSurface::getRenderToTextureMode() const { return _rtt_mode; } void RenderSurface::setRenderToTextureMode(RenderToTextureMode mode) { _rtt_mode = mode; } RenderSurface::RenderToTextureTarget RenderSurface::getRenderToTextureTarget() const { return _rtt_target; } void RenderSurface::setRenderToTextureTarget(RenderToTextureTarget target) { _rtt_target = target; } RenderSurface::RenderToTextureOptions RenderSurface::getRenderToTextureOptions() const { return _rtt_options; } void RenderSurface::setRenderToTextureOptions(RenderToTextureOptions options) { _rtt_options = options; } int RenderSurface::getRenderToTextureMipMapLevel() const { return _rtt_mipmap; } void RenderSurface::setRenderToTextureMipMapLevel(int level) { _rtt_mipmap = level; _rtt_dirty_mipmap = true; } RenderSurface::CubeMapFace RenderSurface::getRenderToTextureFace() const { return _rtt_face; } void RenderSurface::setRenderToTextureFace(CubeMapFace face) { _rtt_face = face; _rtt_dirty_face = true; } const std::vector &RenderSurface::getPBufferUserAttributes() const { return _user_pbattr; } std::vector &RenderSurface::getPBufferUserAttributes() { return _user_pbattr; } void RenderSurface::useOverrideRedirect(bool flag) { _useOverrideRedirect(flag); } bool RenderSurface::usesOverrideRedirect() { return _overrideRedirectFlag; }