19 #ifndef OSGVIEWER_GRAPHICSWINDOWCOCOA
20 #define OSGVIEWER_GRAPHICSWINDOWCOCOA 1
25 @class GraphicsWindowIOSWindow;
26 @class GraphicsWindowIOSGLView;
27 @class GraphicsWindowIOSGLViewController;
32 class GraphicsWindowIOSGLView;
33 class GraphicsWindowIOSWindow;
34 class GraphicsWindowIOSGLViewController;
40 #include <osgViewer/GraphicsWindow>
60 _viewController(
NULL),
63 _deviceOrientationFlags(WindowData::ALL_ORIENTATIONS),
64 _viewContentScaleFactor(-1.0f)
73 getState()->setGraphicsContext(
this);
75 if (_traits.valid() && _traits->sharedContext.valid())
77 getState()->setContextID( _traits->sharedContext->getState()->getContextID() );
78 incrementContextIDUsageCount( getState()->getContextID() );
87 virtual bool isSameKindAs(
const Object*
object)
const {
return dynamic_cast<const GraphicsWindowIOS*
>(object)!=0; }
88 virtual const char* libraryName()
const {
return "osgViewer"; }
89 virtual const char* className()
const {
return "GraphicsWindowIOS"; }
91 virtual bool valid()
const {
return _valid; }
94 virtual bool realizeImplementation();
97 virtual bool isRealizedImplementation()
const {
return _realized; }
100 virtual void closeImplementation();
103 virtual bool makeCurrentImplementation();
106 virtual bool releaseContextImplementation();
109 virtual void swapBuffersImplementation();
112 virtual bool checkEvents();
115 virtual bool setWindowDecorationImplementation(
bool flag);
118 virtual void grabFocus();
121 virtual void grabFocusIfPointerInWindow();
124 virtual void raiseWindow();
126 virtual void resizedImplementation(
int x,
int y,
int width,
int height);
128 virtual bool setWindowRectangleImplementation(
int x,
int y,
int width,
int height);
130 virtual void setWindowName (
const std::string & name);
131 virtual void useCursor(
bool cursorOn);
132 virtual void setCursor(MouseCursor mouseCursor);
138 enum DeviceOrientation{
139 IGNORE_ORIENTATION = 0,
140 PORTRAIT_ORIENTATION = 1<<0,
141 PORTRAIT_UPSIDEDOWN_ORIENTATION = 1<<1,
142 LANDSCAPE_LEFT_ORIENTATION = 1<<2,
143 LANDSCAPE_RIGHT_ORIENTATION = 1<<3,
144 ALL_ORIENTATIONS = PORTRAIT_ORIENTATION | PORTRAIT_UPSIDEDOWN_ORIENTATION | LANDSCAPE_LEFT_ORIENTATION | LANDSCAPE_RIGHT_ORIENTATION
146 typedef unsigned int DeviceOrientationFlags;
148 WindowData(UIView* window_or_view =
NULL, DeviceOrientationFlags orientationFlags = ALL_ORIENTATIONS,
float scaleFactor = -1.0f)
149 : _windowOrView(window_or_view),
150 _deviceOrientationFlags(orientationFlags),
151 _viewContentScaleFactor(scaleFactor),
152 _createTransparentView(false),
153 _useRetainedBacking(false)
157 void setAdaptToDeviceOrientation(DeviceOrientationFlags flags) { _deviceOrientationFlags = flags; }
159 void setViewContentScaleFactor(
float scaleFactor) { _viewContentScaleFactor = scaleFactor; }
161 UIView* getWindowOrParentView()
const {
return _windowOrView; }
163 bool getCreateTransparentView() {
return _createTransparentView; }
164 void setCreateTransparentView(
bool b) { _createTransparentView = b; }
166 bool getUseRetainedBacking() {
return _useRetainedBacking; }
167 void setUseRetainedBacking(
bool b) { _useRetainedBacking = b; }
171 UIView* _windowOrView;
172 DeviceOrientationFlags _deviceOrientationFlags;
173 float _viewContentScaleFactor;
174 bool _createTransparentView;
175 bool _useRetainedBacking;
177 friend class GraphicsWindowIOS;
181 EAGLContext* getContext() {
return _context; }
182 GraphicsWindowIOSWindow* getWindow() {
return _window; }
183 GraphicsWindowIOSGLView* getView() {
return _view; }
184 void setVSync(
bool f);
187 void adaptResize(
int x,
int y,
int w,
int h);
190 WindowData::DeviceOrientationFlags getDeviceOrientationFlags()
const {
return _deviceOrientationFlags; }
192 void setDeviceOrientationFlags(WindowData::DeviceOrientationFlags flags) { _deviceOrientationFlags = flags; }
204 void transformMouseXY(
float& x,
float& y);
206 virtual ~GraphicsWindowIOS();
212 bool _useWindowDecoration;
217 GraphicsWindowIOSWindow* _window;
218 GraphicsWindowIOSGLView* _view;
219 GraphicsWindowIOSGLViewController* _viewController;
220 EAGLContext* _context;
225 WindowData::DeviceOrientationFlags _deviceOrientationFlags;
227 float _viewContentScaleFactor;
GLint GLenum GLsizei width
static unsigned int createNewContextID()
GLint GLenum GLsizei GLsizei height