14#ifndef OSG_GRAPHICSCONTEXT
15#define OSG_GRAPHICSCONTEXT 1
59 if (displayNum<0) displayNum = 0;
60 if (screenNum<0) screenNum = 0;
163 ScreenSettings(
int in_width,
int in_height,
double in_refreshRate=0,
unsigned int in_colorDepth=0) :
166 refreshRate(in_refreshRate),
167 colorDepth(in_colorDepth)
181 void setName(
const std::string& name) { _name = name; }
182 const std::string&
getName()
const {
return _name; }
203 getScreenSettings(screenIdentifier, settings);
204 width = settings.
width;
212 return setScreenSettings(screenIdentifier,
ScreenSettings(width, height));
219 getScreenSettings(screenIdentifier, settings);
221 return setScreenSettings(screenIdentifier, settings);
235 typedef std::vector< osg::ref_ptr<GraphicsContext::WindowingSystemInterface> >
Interfaces;
369 void close(
bool callCloseImplementation=
true);
375 inline bool isRealized()
const {
return isRealizedImplementation(); }
462 if (_state.valid()) _state->frameCompleted();
464 if (_swapCallback.valid()) _swapCallback->swapBuffersImplementation(
this);
465 else swapBuffersImplementation();
476 void resized(
int x,
int y,
int width,
int height)
478 if (_resizedCallback.valid()) _resizedCallback->resizedImplementation(
this, x, y, width, height);
479 else resizedImplementation(x, y, width, height);
518 virtual const char*
className()
const {
return "GraphicsContext"; }
600#define REGISTER_WINDOWINGSYSTEMINTERFACE(ext, classname) \
601 extern "C" void graphicswindow_##ext(void) {} \
602 static osg::WindowingSystemInterfaceProxy<classname> s_proxy_##classname(#ext);
Simple container for specifying which CPU a thread should have affinity with. An empty Affinity....
Definition Affinity:34
This class provides an object-oriented thread mutex interface.
Definition Mutex:31
static size_t CurrentThreadId()
Definition DisplaySettings:34
SwapMethod
Definition DisplaySettings:257
Definition GraphicsContext:231
WindowingSystemInterface * getWindowingSystemInterface(const std::string &name="")
WindowingSystemInterfaces()
Interfaces & getInterfaces()
Definition GraphicsContext:237
std::vector< osg::ref_ptr< GraphicsContext::WindowingSystemInterface > > Interfaces
Definition GraphicsContext:235
void removeWindowingSystemInterface(WindowingSystemInterface *wsInterface)
void addWindowingSystemInterface(WindowingSystemInterface *wsInterface)
Definition GraphicsContext:30
void removeAllOperations()
virtual bool isSameKindAs(const Object *object) const
Definition GraphicsContext:516
bool isRealized() const
Definition GraphicsContext:375
double getTimeSinceLastClear() const
Definition GraphicsContext:358
const State * getState() const
Definition GraphicsContext:337
Vec4 _clearColor
Definition GraphicsContext:547
bool isCurrent() const
Definition GraphicsContext:393
void resized(int x, int y, int width, int height)
Definition GraphicsContext:476
ref_ptr< State > _state
Definition GraphicsContext:545
void setSwapCallback(SwapCallback *rc)
Definition GraphicsContext:449
void setDefaultFboId(GLuint i)
Definition GraphicsContext:510
static void decrementContextIDUsageCount(unsigned int contextID)
osg::ref_ptr< osg::RefBlock > _operationsBlock
Definition GraphicsContext:553
Timer_t _lastClearTick
Definition GraphicsContext:562
GLuint _defaultFboId
Definition GraphicsContext:564
virtual void bindPBufferToTextureImplementation(GLenum buffer)=0
static GraphicsContexts getRegisteredGraphicsContexts(unsigned int contextID)
std::list< ref_ptr< Operation > > GraphicsOperationQueue
Definition GraphicsContext:306
virtual bool makeCurrentImplementation()=0
osg::ref_ptr< Operation > _currentOperation
Definition GraphicsContext:555
std::list< osg::Camera * > Cameras
Definition GraphicsContext:501
static void registerGraphicsContext(GraphicsContext *gc)
std::vector< GraphicsContext * > GraphicsContexts
Definition GraphicsContext:272
SwapCallback * getSwapCallback()
Definition GraphicsContext:452
ref_ptr< Traits > _traits
Definition GraphicsContext:544
static unsigned int createNewContextID()
void remove(const std::string &name)
Cameras & getCameras()
Definition GraphicsContext:504
static void setCompileContext(unsigned int contextID, GraphicsContext *gc)
virtual ~GraphicsContext()
GLuint getDefaultFboId() const
Definition GraphicsContext:512
void add(Operation *operation)
std::vector< ScreenSettings > ScreenSettingsList
Definition GraphicsContext:176
ref_ptr< ResizedCallback > _resizedCallback
Definition GraphicsContext:559
virtual void closeImplementation()=0
size_t _threadOfLastMakeCurrent
Definition GraphicsContext:550
GraphicsOperationQueue & getOperationsQueue()
Definition GraphicsContext:309
GraphicsThread * getGraphicsThread()
Definition GraphicsContext:407
void bindPBufferToTexture(GLenum buffer)
Definition GraphicsContext:396
osg::RefBlock * getOperationsBlock()
Definition GraphicsContext:315
const GraphicsThread * getGraphicsThread() const
Definition GraphicsContext:410
virtual bool makeContextCurrentImplementation(GraphicsContext *readContext)=0
virtual bool isRealizedImplementation() const =0
GLbitfield getClearMask() const
Definition GraphicsContext:352
virtual void runOperations()
Cameras _cameras
Definition GraphicsContext:540
virtual const char * libraryName() const
Definition GraphicsContext:517
static unsigned int getMaxContextID()
void setClearMask(GLbitfield mask)
Definition GraphicsContext:349
static void incrementContextIDUsageCount(unsigned int contextID)
virtual bool valid() const =0
virtual bool realizeImplementation()=0
void setGraphicsThread(GraphicsThread *gt)
ResizedCallback * getResizedCallback()
Definition GraphicsContext:492
const Cameras & getCameras() const
Definition GraphicsContext:507
void setClearColor(const Vec4 &color)
Definition GraphicsContext:341
OpenThreads::Mutex _operationsMutex
Definition GraphicsContext:552
static WindowingSystemInterface * getWindowingSystemInterface(const std::string &name="")
ref_ptr< SwapCallback > _swapCallback
Definition GraphicsContext:560
void swapBuffersCallbackOrImplementation()
Definition GraphicsContext:460
virtual bool releaseContextImplementation()=0
GraphicsOperationQueue _operations
Definition GraphicsContext:554
void remove(Operation *operation)
void createGraphicsThread()
const Traits * getTraits() const
Definition GraphicsContext:324
const ResizedCallback * getResizedCallback() const
Definition GraphicsContext:495
static void unregisterGraphicsContext(GraphicsContext *gc)
void setState(State *state)
Definition GraphicsContext:331
Operation * getCurrentOperation()
Definition GraphicsContext:318
const SwapCallback * getSwapCallback() const
Definition GraphicsContext:455
State * getState()
Definition GraphicsContext:334
void removeCamera(osg::Camera *camera)
virtual void resizedImplementation(int x, int y, int width, int height)
virtual const char * className() const
Definition GraphicsContext:518
GraphicsContext(const GraphicsContext &, const osg::CopyOp &)
static GraphicsContext * createGraphicsContext(Traits *traits)
bool makeContextCurrent(GraphicsContext *readContext)
ref_ptr< GraphicsThread > _graphicsThread
Definition GraphicsContext:557
const Vec4 & getClearColor() const
Definition GraphicsContext:344
OpenThreads::Mutex * getOperationsMutex()
Definition GraphicsContext:312
static GraphicsContext * getOrCreateCompileContext(unsigned int contextID)
virtual Object * cloneType() const
Definition GraphicsContext:527
GLbitfield _clearMask
Definition GraphicsContext:548
void close(bool callCloseImplementation=true)
static GraphicsContext * getCompileContext(unsigned int contextID)
static osg::ref_ptr< WindowingSystemInterfaces > & getWindowingSystemInterfaces()
virtual Object * clone(const CopyOp &) const
Definition GraphicsContext:528
virtual void swapBuffersImplementation()=0
void setResizedCallback(ResizedCallback *rc)
Definition GraphicsContext:489
static GraphicsContexts getAllRegisteredGraphicsContexts()
void addCamera(osg::Camera *camera)
Definition GraphicsThread:26
Definition OperationThread:51
Definition OperationThread:31
T * get()
Definition State:124
Definition GraphicsContext:571
virtual void swapBuffersImplementation(GraphicsContext *gc)
GLsync _previousSync
Definition GraphicsContext:577
SyncSwapBuffersCallback()
static Timer * instance()
double delta_s(Timer_t t1, Timer_t t2) const
Definition Timer:59
Definition observer_ptr:39
author: Julien Valentin 2017 (mp3butcher@hotmail.com)
Definition AlphaFunc:19
struct __GLsync * GLsync
Definition GLDefines:680
unsigned long long Timer_t
Definition Timer:24
#define OSG_EXPORT
Definition osg/Export:39
Definition GraphicsContext:483
virtual void resizedImplementation(GraphicsContext *gc, int x, int y, int width, int height)=0
Definition GraphicsContext:34
ScreenIdentifier(const std::string &in_hostName, int in_displayNum, int in_screenNum)
void setUndefinedScreenDetailsToDefaultScreen()
Definition GraphicsContext:57
ScreenIdentifier(int in_screenNum)
std::string hostName
Definition GraphicsContext:63
std::string displayName() const
int screenNum
Definition GraphicsContext:65
void setScreenIdentifier(const std::string &displayName)
int displayNum
Definition GraphicsContext:64
Definition GraphicsContext:155
unsigned int colorDepth
RGB(A) color buffer depth.
Definition GraphicsContext:173
int height
Definition GraphicsContext:171
double refreshRate
Screen refresh rate, in Hz.
Definition GraphicsContext:172
ScreenSettings()
Definition GraphicsContext:156
int width
Definition GraphicsContext:170
ScreenSettings(int in_width, int in_height, double in_refreshRate=0, unsigned int in_colorDepth=0)
Definition GraphicsContext:163
Definition GraphicsContext:441
virtual void swapBuffersImplementation(GraphicsContext *gc)=0
Definition GraphicsContext:70
int width
Definition GraphicsContext:76
GLenum target
Definition GraphicsContext:108
unsigned int face
Definition GraphicsContext:111
bool vsync
Definition GraphicsContext:115
int y
Definition GraphicsContext:75
unsigned int glContextProfileMask
Definition GraphicsContext:131
bool doubleBuffer
Definition GraphicsContext:105
unsigned int level
Definition GraphicsContext:110
bool getContextVersion(unsigned int &major, unsigned int &minor) const
unsigned int red
Definition GraphicsContext:91
bool pbuffer
Definition GraphicsContext:103
osg::ref_ptr< osg::Referenced > inheritedWindowData
Definition GraphicsContext:139
unsigned int samples
Definition GraphicsContext:100
bool useCursor
Definition GraphicsContext:126
std::string windowingSystemPreference
Definition GraphicsContext:83
GLuint swapBarrier
Definition GraphicsContext:120
bool setInheritedWindowPixelFormat
Definition GraphicsContext:142
unsigned int sampleBuffers
Definition GraphicsContext:99
bool swapGroupEnabled
Definition GraphicsContext:118
unsigned int green
Definition GraphicsContext:93
bool useMultiThreadedOpenGLEngine
Definition GraphicsContext:123
bool windowDecoration
Definition GraphicsContext:87
bool overrideRedirect
Definition GraphicsContext:145
bool supportsResize
Definition GraphicsContext:88
osg::observer_ptr< GraphicsContext > sharedContext
Definition GraphicsContext:137
unsigned int glContextFlags
Definition GraphicsContext:130
int height
Definition GraphicsContext:77
DisplaySettings::SwapMethod swapMethod
Definition GraphicsContext:147
OpenThreads::Affinity affinity
Definition GraphicsContext:150
GLuint swapGroup
Definition GraphicsContext:119
unsigned int depth
Definition GraphicsContext:95
bool quadBufferStereo
Definition GraphicsContext:104
int x
Definition GraphicsContext:74
unsigned int stencil
Definition GraphicsContext:96
GLenum format
Definition GraphicsContext:109
std::string windowName
Definition GraphicsContext:86
unsigned int mipMapGeneration
Definition GraphicsContext:112
unsigned int alpha
Definition GraphicsContext:94
std::string glContextVersion
Definition GraphicsContext:129
Traits(DisplaySettings *ds=0)
unsigned int blue
Definition GraphicsContext:92
Definition GraphicsContext:180
bool setScreenResolution(const ScreenIdentifier &screenIdentifier, unsigned int width, unsigned int height)
Definition GraphicsContext:210
WindowingSystemInterface()
Definition GraphicsContext:224
void setName(const std::string &name)
Definition GraphicsContext:181
std::string _name
Definition GraphicsContext:227
bool setScreenRefreshRate(const ScreenIdentifier &screenIdentifier, double refreshRate)
Definition GraphicsContext:216
virtual unsigned int getNumScreens(const ScreenIdentifier &screenIdentifier=ScreenIdentifier())=0
virtual osg::DisplaySettings * getDisplaySettings() const
Definition GraphicsContext:194
void getScreenResolution(const ScreenIdentifier &screenIdentifier, unsigned int &width, unsigned int &height)
Definition GraphicsContext:200
virtual void setDisplaySettings(DisplaySettings *)
Definition GraphicsContext:192
const std::string & getName() const
Definition GraphicsContext:182
virtual GraphicsContext * createGraphicsContext(Traits *traits)=0
virtual void getScreenSettings(const ScreenIdentifier &screenIdentifier, ScreenSettings &resolution)=0
virtual void enumerateScreenSettings(const ScreenIdentifier &screenIdentifier, ScreenSettingsList &resolutionList)=0
virtual bool setScreenSettings(const ScreenIdentifier &, const ScreenSettings &)
Definition GraphicsContext:188
virtual ~WindowingSystemInterface()
Definition GraphicsContext:225
Definition GraphicsContext:583
osg::ref_ptr< T > _wsi
Definition GraphicsContext:597
WindowingSystemInterfaceProxy(const std::string &name)
Definition GraphicsContext:584
~WindowingSystemInterfaceProxy()
Definition GraphicsContext:592