14 #ifndef OSG_GRAPHICSCONTEXT
15 #define OSG_GRAPHICSCONTEXT 1
18 #include <osg/GraphicsThread>
37 ScreenIdentifier(
int in_screenNum);
39 ScreenIdentifier(
const std::string& in_hostName,
int in_displayNum,
int in_screenNum);
42 std::string displayName()
const;
54 void setScreenIdentifier(
const std::string& displayName);
59 if (displayNum<0) displayNum = 0;
60 if (screenNum<0) screenNum = 0;
128 bool getContextVersion(
unsigned int& major,
unsigned int& minor)
const;
156 refreshRate(refreshRate),
157 colorDepth(colorDepth)
177 virtual void enumerateScreenSettings(
const ScreenIdentifier& screenIdentifier, ScreenSettingsList & resolutionList) = 0;
193 getScreenSettings(screenIdentifier, settings);
194 width = settings.
width;
202 return setScreenSettings(screenIdentifier,
ScreenSettings(width, height));
209 getScreenSettings(screenIdentifier, settings);
211 return setScreenSettings(screenIdentifier, settings);
218 static void setWindowingSystemInterface(WindowingSystemInterface* wsInterface);
221 static WindowingSystemInterface* getWindowingSystemInterface();
228 static unsigned int createNewContextID();
231 static unsigned int getMaxContextID();
234 static void incrementContextIDUsageCount(
unsigned int contextID);
237 static void decrementContextIDUsageCount(
unsigned int contextID);
242 static GraphicsContexts getAllRegisteredGraphicsContexts();
245 static GraphicsContexts getRegisteredGraphicsContexts(
unsigned int contextID);
248 static void setCompileContext(
unsigned int contextID,
GraphicsContext* gc);
251 static GraphicsContext* getOrCreateCompileContext(
unsigned int contextID);
265 void remove(
const std::string& name);
268 void removeAllOperations();
271 virtual void runOperations();
294 virtual bool valid()
const = 0;
323 virtual void clear();
336 void close(
bool callCloseImplementation=
true);
342 inline bool isRealized()
const {
return isRealizedImplementation(); }
357 bool releaseContext();
368 void createGraphicsThread();
382 virtual bool realizeImplementation() = 0;
386 virtual bool isRealizedImplementation()
const = 0;
390 virtual void closeImplementation() = 0;
394 virtual bool makeCurrentImplementation() = 0;
398 virtual bool makeContextCurrentImplementation(
GraphicsContext* readContext) = 0;
401 virtual bool releaseContextImplementation() = 0;
405 virtual void bindPBufferToTextureImplementation(GLenum buffer) = 0;
429 if (_state.valid()) _state->frameCompleted();
431 if (_swapCallback.valid()) _swapCallback->swapBuffersImplementation(
this);
432 else swapBuffersImplementation();
437 virtual void swapBuffersImplementation() = 0;
445 if (_resizedCallback.valid()) _resizedCallback->resizedImplementation(
this, x, y, width, height);
446 else resizedImplementation(x, y, width, height);
465 virtual void resizedImplementation(
int x,
int y,
int width,
int height);
485 virtual const char*
className()
const {
return "GraphicsContext"; }
unsigned int glContextProfileMask
const SwapCallback * getSwapCallback() const
bool setScreenResolution(const ScreenIdentifier &screenIdentifier, unsigned int width, unsigned int height)
osg::RefBlock * getOperationsBlock()
GraphicsOperationQueue & getOperationsQueue()
virtual const char * libraryName() const
void setState(State *state)
GraphicsThread * getGraphicsThread()
virtual ~WindowingSystemInterface()
const State * getState() const
const Traits * getTraits() const
DisplaySettings::SwapMethod swapMethod
void setResizedCallback(ResizedCallback *rc)
This class provides an object-oriented thread mutex interface.
const Vec4 & getClearColor() const
GLbitfield getClearMask() const
OpenThreads::Thread * _threadOfLastMakeCurrent
std::vector< GraphicsContext * > GraphicsContexts
ref_ptr< SwapCallback > _swapCallback
osg::ref_ptr< osg::Referenced > inheritedWindowData
void setClearMask(GLbitfield mask)
static Thread * CurrentThread()
double delta_s(Timer_t t1, Timer_t t2) const
osg::ref_ptr< Operation > _currentOperation
ref_ptr< Traits > _traits
std::list< ref_ptr< Operation > > GraphicsOperationQueue
osg::observer_ptr< GraphicsContext > sharedContext
std::string glContextVersion
GraphicsOperationQueue _operations
const ResizedCallback * getResizedCallback() const
void swapBuffersCallbackOrImplemenation()
unsigned long long Timer_t
virtual bool isSameKindAs(const Object *object) const
static Timer * instance()
virtual const char * className() const
ref_ptr< ResizedCallback > _resizedCallback
ref_ptr< GraphicsThread > _graphicsThread
GLint GLenum GLsizei width
This class provides an object-oriented thread interface.
void setDefaultFboId(GLuint i)
Operation * getCurrentOperation()
virtual Object * clone(const CopyOp &) const
void resized(int x, int y, int width, int height)
void setUndefinedScreenDetailsToDefaultScreen()
bool useMultiThreadedOpenGLEngine
GLuint getDefaultFboId() const
unsigned int glContextFlags
ScreenSettings(int width, int height, double refreshRate=0, unsigned int colorDepth=0)
void getScreenResolution(const ScreenIdentifier &screenIdentifier, unsigned int &width, unsigned int &height)
GLint GLenum GLsizei GLsizei height
osg::ref_ptr< osg::RefBlock > _operationsBlock
bool setScreenRefreshRate(const ScreenIdentifier &screenIdentifier, double refreshRate)
double getTimeSinceLastClear() const
unsigned int sampleBuffers
virtual osg::DisplaySettings * getDisplaySettings() const
bool setInheritedWindowPixelFormat
const GraphicsThread * getGraphicsThread() const
ResizedCallback * getResizedCallback()
std::vector< ScreenSettings > ScreenSettingsList
const Cameras & getCameras() const
void setClearColor(const Vec4 &color)
SwapCallback * getSwapCallback()
unsigned int colorDepth
RGB(A) color buffer depth.
void bindPBufferToTexture(GLenum buffer)
OpenThreads::Mutex _operationsMutex
std::list< osg::Camera * > Cameras
void setSwapCallback(SwapCallback *rc)
unsigned int mipMapGeneration
virtual Object * cloneType() const
virtual void setDisplaySettings(DisplaySettings *)
double refreshRate
Screen refresh rate, in Hz.
OpenThreads::Mutex * getOperationsMutex()
virtual bool setScreenSettings(const ScreenIdentifier &, const ScreenSettings &)