OGRE  2.0
Object-Oriented Graphics Rendering Engine
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
OgreOSXWindow.h
Go to the documentation of this file.
1 /*
2 -----------------------------------------------------------------------------
3 This source file is part of OGRE
4 (Object-oriented Graphics Rendering Engine)
5 For the latest info, see http://www.ogre3d.org
6 
7 Copyright (c) 2000-2014 Torus Knot Software Ltd
8 
9 Permission is hereby granted, free of charge, to any person obtaining a copy
10 of this software and associated documentation files (the "Software"), to deal
11 in the Software without restriction, including without limitation the rights
12 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 copies of the Software, and to permit persons to whom the Software is
14 furnished to do so, subject to the following conditions:
15 
16 The above copyright notice and this permission notice shall be included in
17 all copies or substantial portions of the Software.
18 
19 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 THE SOFTWARE.
26 -----------------------------------------------------------------------------
27 */
28 
29 #ifndef __OSXWindow_H__
30 #define __OSXWindow_H__
31 
32 #include <Carbon/Carbon.h>
33 #include "OgreRenderWindow.h"
34 #include "OgreOSXContext.h"
35 #include <OpenGL/OpenGL.h>
36 #include <OpenGL/CGLTypes.h>
37 
38 namespace Ogre
39 {
40  class OSXWindow : public RenderWindow
41  {
42  public:
43  OSXWindow();
44  virtual ~OSXWindow();
45 
47  void create( const String& name, unsigned int width, unsigned int height,
48  bool fullScreen, const NameValuePairList *miscParams ) = 0;
50  virtual void destroy( void ) = 0;
52  virtual bool isActive( void ) const = 0;
54  virtual bool isClosed( void ) const = 0;
55  virtual bool isHidden() const = 0;
56  virtual void setHidden(bool hidden) = 0;
58  virtual void reposition( int left, int top ) = 0;
60  virtual void resize( unsigned int width, unsigned int height ) = 0;
62  virtual void swapBuffers( ) = 0;
64  virtual void copyContentsToMemory(const PixelBox &dst, FrameBuffer buffer);
66  virtual void windowMovedOrResized() {};
67 
68  protected:
70  CGLContextObj mCGLContextObj;
71 #if defined(MAC_OS_X_VERSION_10_6) && MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_6
72  CGDisplayModeRef mOriginalDisplayMode;
73 #else
74  CFDictionaryRef mOriginalDisplayMode;
75 #endif
76 
78  void createCGLFullscreen(unsigned int width, unsigned int height, unsigned int depth, unsigned int fsaa, CGLContextObj sharedContext);
80  void destroyCGLFullscreen(void);
82  void swapCGLBuffers(void);
83 #if defined(MAC_OS_X_VERSION_10_6) && MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_6
84  uint32 bitDepthFromDisplayMode(CGDisplayModeRef mode);
85 #endif
86  };
87 
88  #define ENABLE_CG_CHECK 0
89  #if ENABLE_CG_CHECK
90  #define CG_CHECK_ERROR(e) \
91  { \
92  if((CGError)e != kCGErrorSuccess) \
93  { \
94  CGReleaseAllDisplays(); \
95  OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, String("CG Error: " + StringConverter::toString(e) + + \
96  " Line # " + StringConverter::toString(__LINE__)), __PRETTY_FUNCTION__); \
97  } \
98  }
99  #else
100  #define CG_CHECK_ERROR(e) {}
101  #endif
102 
103  #if ENABLE_CG_CHECK
104  #define CGL_CHECK_ERROR(e) \
105  { \
106  if((CGLError)e != kCGLNoError) \
107  { \
108  CGReleaseAllDisplays(); \
109  OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, String("CGL Error: " + String(CGLErrorString(e)) + \
110  " Line # " + StringConverter::toString(__LINE__)), __PRETTY_FUNCTION__); \
111  } \
112  }
113  #else
114  #define CGL_CHECK_ERROR(e) {}
115  #endif
116 }
117 
118 #endif
Manages the target rendering window.
unsigned int uint32
Definition: OgrePlatform.h:420
void createCGLFullscreen(unsigned int width, unsigned int height, unsigned int depth, unsigned int fsaa, CGLContextObj sharedContext)
Switch to full screen mode using CGL.
virtual void resize(unsigned int width, unsigned int height)=0
Overridden - see RenderWindow.
map< String, String >::type NameValuePairList
Name / value parameter pair (first = name, second = value)
Definition: OgreCommon.h:580
virtual ~OSXWindow()
Class that encapsulates an GL context.
virtual void copyContentsToMemory(const PixelBox &dst, FrameBuffer buffer)
Overridden - see RenderTarget.
virtual bool isActive(void) const =0
Overridden - see RenderWindow.
virtual void windowMovedOrResized()
Overridden - see RenderTarget.
Definition: OgreOSXWindow.h:66
CGLContextObj mCGLContextObj
Definition: OgreOSXWindow.h:70
virtual void reposition(int left, int top)=0
Overridden - see RenderWindow.
void swapCGLBuffers(void)
Update the full screen context.
CFDictionaryRef mOriginalDisplayMode
Definition: OgreOSXWindow.h:74
virtual bool isHidden() const =0
Indicates whether the window was set to hidden (not displayed)
OSXContext * mContext
Definition: OgreOSXWindow.h:66
void destroyCGLFullscreen(void)
Kill full screen mode, and return to default windowed mode.
virtual void destroy(void)=0
Overridden - see RenderWindow.
virtual void setHidden(bool hidden)=0
Hide (or show) the window.
_StringBase String
Definition: OgreCommon.h:53
virtual void swapBuffers()=0
Overridden - see RenderWindow.
virtual bool isClosed(void) const =0
Overridden - see RenderWindow.
void create(const String &name, unsigned int width, unsigned int height, bool fullScreen, const NameValuePairList *miscParams)=0
Overridden - see RenderWindow.