OpenSceneGraph 3.6.5
GraphicsWindowX11
Go to the documentation of this file.
1/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
2 *
3 * This library is open source and may be redistributed and/or modified under
4 * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
5 * (at your option) any later version. The full license is in LICENSE file
6 * included with this distribution, and on the openscenegraph.org website.
7 *
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * OpenSceneGraph Public License for more details.
12*/
13
14/* Note, elements of GraphicsWindowX11 have used Prodcer/RenderSurface_X11.cpp as both
15 * a guide to use of X11/GLX and copiying directly in the case of setBorder().
16 * These elements are license under OSGPL as above, with Copyright (C) 2001-2004 Don Burns.
17 */
18
19#ifndef OSGVIEWER_GRAPHICSWINDOWX11
20#define OSGVIEWER_GRAPHICSWINDOWX11 1
21
24
25#include <string.h>
26
27namespace osgViewer
28{
29
31{
32 public:
33
35 _valid(false),
37 _parent(0),
38 _window(0),
39 _visualInfo(0),
40 #ifdef OSG_USE_EGL
41 _eglDisplay(0),
42 _eglSurface(0),
43 #else
44 _fbConfig(0),
45 #endif
47 _initialized(false),
48 _realized(false),
53 {
54 _traits = traits;
55 memset(_keyMap, 0, 32);
56
57 init();
58
59 if (valid())
60 {
61 setState( new osg::State );
62 getState()->setGraphicsContext(this);
63
64 if (_traits.valid() && _traits->sharedContext.valid())
65 {
66 getState()->setContextID( _traits->sharedContext->getState()->getContextID() );
67 incrementContextIDUsageCount( getState()->getContextID() );
68 }
69 else
70 {
72 }
73
74 }
75 }
76
77 virtual bool isSameKindAs(const Object* object) const { return dynamic_cast<const GraphicsWindowX11*>(object)!=0; }
78 virtual const char* libraryName() const { return "osgViewer"; }
79 virtual const char* className() const { return "GraphicsWindowX11"; }
80
81 virtual bool valid() const { return _valid; }
82
84 virtual bool realizeImplementation();
85
87 virtual bool isRealizedImplementation() const { return _realized; }
88
90 virtual void closeImplementation();
91
94
97
100
102 virtual bool checkEvents();
103
105 virtual bool setWindowDecorationImplementation(bool flag);
106
108 virtual void grabFocus();
109
112
114 virtual void raiseWindow();
115
116 // Override from GUIActionAdapter
117 virtual void requestWarpPointer(float x,float y);
118
120 virtual bool setWindowRectangleImplementation(int x, int y, int width, int height);
121
123 virtual void setWindowName(const std::string& name);
124
126 virtual void setCursor(MouseCursor cursor);
127
130 {
131 WindowData(Window window):
132 _window(window) {}
133
134 Window _window;
135 };
136
137 public:
138
139 // X11 specific access functions
140
141 Display* getEventDisplay() const { return _eventDisplay; }
142 Display* getDisplayToUse() const ;
143
144
145 Window& getParent() { return _parent; }
146 Window& getWindow() { return _window; }
147
148 Cursor getCurrentCursor() { return _currentCursor; }
149
150 protected:
151
153
154 Cursor getOrCreateCursor(MouseCursor mouseShape);
155
157
159
160 bool setWindow(Window window);
161
162 void init();
163
164 bool checkAndSendEventFullScreenIfNeeded(Display* display, int x, int y, int width, int height, bool windowDecoration);
165
166
167 void transformMouseXY(float& x, float& y);
168 void adaptKey(XKeyEvent& keyevent, int& keySymbol, int& unmodifiedKeySymbol);
169 void forceKey(int key, double time, bool state);
171 void getModifierMap(char* keymap) const;
172 int getModifierMask() const;
173 void syncLocks();
175
176 bool _valid;
178 Window _parent;
179 Window _window;
180 XVisualInfo* _visualInfo;
181
182 #ifdef OSG_USE_EGL
183 EGLDisplay _eglDisplay;
184 EGLSurface _eglSurface;
185 #else
186 GLXFBConfig _fbConfig;
187 #endif
188
190
192
196
201
202 char _keyMap[32];
203 std::map<MouseCursor,Cursor> _mouseCursorMap;
204};
205
206}
207
208#endif
The osgViewer library provides high level viewer functionality designed to make it easier to write a ...
ref_ptr< Traits > _traits
Definition GraphicsContext:544
static unsigned int createNewContextID()
Create a contextID for a new graphics context, this contextID is used to set up the osg::State associ...
static void incrementContextIDUsageCount(unsigned int contextID)
Increment the usage count associate with a contextID.
void setState(State *state)
Set the State object which tracks the current OpenGL state for this graphics context.
Definition GraphicsContext:331
State * getState()
Get the State object which tracks the current OpenGL state for this graphics context.
Definition GraphicsContext:334
GraphicsContext Traits object provides the specification of what type of graphics context is required...
Definition GraphicsContext:70
Object()
Construct an object.
Definition Object:69
Base class for providing reference counted objects.
Definition Referenced:44
Encapsulates the current applied OpenGL modes, attributes and vertex arrays settings,...
Definition State:80
Class to encapsulate platform-specific OpenGL context handle variables.
Definition GraphicsHandleX11:45
int _numLockMask
Definition GraphicsWindowX11:200
bool _valid
Definition GraphicsWindowX11:176
virtual bool isRealizedImplementation() const
Return true if the graphics context has been realised and is ready to use.
Definition GraphicsWindowX11:87
void adaptKey(XKeyEvent &keyevent, int &keySymbol, int &unmodifiedKeySymbol)
virtual bool checkEvents()
Check to see if any events have been generated.
virtual bool setWindowRectangleImplementation(int x, int y, int width, int height)
Set the window's position and size.
double _timeOfLastCheckEvents
Definition GraphicsWindowX11:197
bool _ownsWindow
Definition GraphicsWindowX11:195
virtual void requestWarpPointer(float x, float y)
requestWarpPointer(int,int) is requesting a repositioning of the mouse pointer to a specified x,...
Display * getDisplayToUse() const
bool _initialized
Definition GraphicsWindowX11:193
Display * getEventDisplay() const
Definition GraphicsWindowX11:141
int _lastEventType
Definition GraphicsWindowX11:198
GLXFBConfig _fbConfig
Definition GraphicsWindowX11:186
bool checkAndSendEventFullScreenIfNeeded(Display *display, int x, int y, int width, int height, bool windowDecoration)
char _keyMap[32]
Definition GraphicsWindowX11:202
int _modifierState
Definition GraphicsWindowX11:199
virtual bool releaseContextImplementation()
Release the graphics context.
Window _parent
Definition GraphicsWindowX11:178
virtual void grabFocusIfPointerInWindow()
Get focus on if the pointer is in this window.
Window _window
Definition GraphicsWindowX11:179
GraphicsWindowX11(osg::GraphicsContext::Traits *traits)
Definition GraphicsWindowX11:34
virtual bool realizeImplementation()
Realise the GraphicsContext.
virtual void swapBuffersImplementation()
Swap the front and back buffers.
virtual const char * libraryName() const
return the name of the object's library.
Definition GraphicsWindowX11:78
std::map< MouseCursor, Cursor > _mouseCursorMap
Definition GraphicsWindowX11:203
virtual bool makeCurrentImplementation()
Make this graphics context current.
void forceKey(int key, double time, bool state)
Cursor getOrCreateCursor(MouseCursor mouseShape)
bool _realized
Definition GraphicsWindowX11:194
Cursor _currentCursor
Definition GraphicsWindowX11:189
virtual bool valid() const
Return whether a valid and usable GraphicsContext has been created.
Definition GraphicsWindowX11:81
virtual bool setWindowDecorationImplementation(bool flag)
Set Window decoration.
Atom _deleteWindow
Definition GraphicsWindowX11:191
Window & getWindow()
Definition GraphicsWindowX11:146
Window & getParent()
Definition GraphicsWindowX11:145
Cursor getCurrentCursor()
Definition GraphicsWindowX11:148
void transformMouseXY(float &x, float &y)
void getModifierMap(char *keymap) const
virtual bool isSameKindAs(const Object *object) const
Definition GraphicsWindowX11:77
XVisualInfo * _visualInfo
Definition GraphicsWindowX11:180
virtual void setWindowName(const std::string &name)
Set the name of the window.
bool setWindow(Window window)
virtual void setCursor(MouseCursor cursor)
Set mouse cursor to a specific shape.
virtual void grabFocus()
Get focus.
virtual void closeImplementation()
Close the graphics context.
virtual void raiseWindow()
Raise specified window.
Display * _eventDisplay
Definition GraphicsWindowX11:177
virtual const char * className() const
return the name of the object's class type.
Definition GraphicsWindowX11:79
Window _window
Definition GraphicsWindowX11:134
WindowData(Window window)
Definition GraphicsWindowX11:131
Base class for providing Windowing API agnostic access to creating and managing graphics window and e...
Definition GraphicsWindow:43
MouseCursor
Mouse cursor types, the same ones already present with ancient glut ...
Definition GraphicsWindow:100
#define OSGVIEWER_EXPORT
Definition Export:40

osg logo
Generated at Sun Jul 20 2025 00:00:00 for the OpenSceneGraph by doxygen 1.14.0.