19#ifndef OSGVIEWER_GRAPHICSWINDOWCOCOA
20#define OSGVIEWER_GRAPHICSWINDOWCOCOA 1
25@class GraphicsWindowIOSWindow;
26@class GraphicsWindowIOSGLView;
27@class GraphicsWindowIOSGLViewController;
31@class UIViewController;
33class GraphicsWindowIOSGLView;
34class GraphicsWindowIOSWindow;
35class GraphicsWindowIOSGLViewController;
39class UIViewController;
62 _viewController(
NULL),
65 _deviceOrientationFlags(WindowData::ALL_ORIENTATIONS),
66 _viewContentScaleFactor(-1.0f)
75 getState()->setGraphicsContext(
this);
77 if (_traits.valid() && _traits->sharedContext.valid())
79 getState()->setContextID( _traits->sharedContext->getState()->getContextID() );
80 incrementContextIDUsageCount( getState()->getContextID() );
89 virtual bool isSameKindAs(
const Object*
object)
const {
return dynamic_cast<const GraphicsWindowIOS*
>(object)!=0; }
90 virtual const char* libraryName()
const {
return "osgViewer"; }
91 virtual const char* className()
const {
return "GraphicsWindowIOS"; }
93 virtual void runOperations();
95 virtual bool valid()
const {
return _valid; }
98 virtual bool realizeImplementation();
101 virtual bool isRealizedImplementation()
const {
return _realized; }
104 virtual void closeImplementation();
107 virtual bool makeCurrentImplementation();
110 virtual bool releaseContextImplementation();
113 virtual void swapBuffersImplementation();
116 virtual bool checkEvents();
119 virtual bool setWindowDecorationImplementation(
bool flag);
122 virtual void grabFocus();
125 virtual void grabFocusIfPointerInWindow();
128 virtual void raiseWindow();
130 virtual void resizedImplementation(
int x,
int y,
int width,
int height);
132 virtual bool setWindowRectangleImplementation(
int x,
int y,
int width,
int height);
134 virtual void setWindowName (
const std::string & name);
135 virtual void useCursor(
bool cursorOn);
136 virtual void setCursor(MouseCursor mouseCursor);
142 enum DeviceOrientation{
143 IGNORE_ORIENTATION = 0,
144 PORTRAIT_ORIENTATION = 1<<0,
145 PORTRAIT_UPSIDEDOWN_ORIENTATION = 1<<1,
146 LANDSCAPE_LEFT_ORIENTATION = 1<<2,
147 LANDSCAPE_RIGHT_ORIENTATION = 1<<3,
148 ALL_ORIENTATIONS = PORTRAIT_ORIENTATION | PORTRAIT_UPSIDEDOWN_ORIENTATION | LANDSCAPE_LEFT_ORIENTATION | LANDSCAPE_RIGHT_ORIENTATION
150 typedef unsigned int DeviceOrientationFlags;
152 WindowData(UIView* window_or_view =
NULL, UIViewController* parentController =
NULL, DeviceOrientationFlags orientationFlags = ALL_ORIENTATIONS,
float scaleFactor = -1.0f)
153 : _windowOrView(window_or_view),
154 _parentController(parentController),
155 _deviceOrientationFlags(orientationFlags),
156 _viewContentScaleFactor(scaleFactor),
157 _createTransparentView(false),
158 _useRetainedBacking(false)
162 void setAdaptToDeviceOrientation(DeviceOrientationFlags flags) { _deviceOrientationFlags = flags; }
164 void setViewContentScaleFactor(
float scaleFactor) { _viewContentScaleFactor = scaleFactor; }
166 UIView* getWindowOrParentView()
const {
return _windowOrView; }
167 UIViewController* getController()
const;
169 bool getCreateTransparentView() {
return _createTransparentView; }
170 void setCreateTransparentView(
bool b) { _createTransparentView = b; }
172 bool getUseRetainedBacking() {
return _useRetainedBacking; }
173 void setUseRetainedBacking(
bool b) { _useRetainedBacking = b; }
177 UIView* _windowOrView;
178 UIViewController* _parentController;
179 DeviceOrientationFlags _deviceOrientationFlags;
180 float _viewContentScaleFactor;
181 bool _createTransparentView;
182 bool _useRetainedBacking;
184 friend class GraphicsWindowIOS;
188 EAGLContext* getContext() {
return _context; }
189 GraphicsWindowIOSWindow* getWindow() {
return _window; }
190 GraphicsWindowIOSGLView* getView() {
return _view; }
191 void setVSync(
bool f);
194 void adaptResize(
int x,
int y,
int w,
int h);
197 WindowData::DeviceOrientationFlags getDeviceOrientationFlags()
const {
return _deviceOrientationFlags; }
199 void setDeviceOrientationFlags(WindowData::DeviceOrientationFlags flags) { _deviceOrientationFlags = flags; }
211 void transformMouseXY(
float& x,
float& y);
213 virtual ~GraphicsWindowIOS();
219 bool _useWindowDecoration;
224 GraphicsWindowIOSWindow* _window;
225 GraphicsWindowIOSGLView* _view;
226 GraphicsWindowIOSGLViewController* _viewController;
227 EAGLContext* _context;
232 WindowData::DeviceOrientationFlags _deviceOrientationFlags;
234 float _viewContentScaleFactor;
Definition GraphicsWindow:43
static unsigned int createNewContextID()
#define NULL
Definition osg/Export:55
Definition GraphicsContext:70