OGRE  1.7
Object-Oriented Graphics Rendering Engine
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator 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-2011 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;
56  virtual void reposition( int left, int top ) = 0;
58  virtual void resize( unsigned int width, unsigned int height ) = 0;
60  virtual void swapBuffers( bool waitForVSync ) = 0;
62  virtual void copyContentsToMemory(const PixelBox &dst, FrameBuffer buffer);
64  virtual void windowMovedOrResized() {};
65 
66  protected:
68  CGLContextObj mCGLContextObj;
69 #if defined(MAC_OS_X_VERSION_10_6) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6
70  CGDisplayModeRef mOriginalDisplayMode;
71 #else
72  CFDictionaryRef mOriginalDisplayMode;
73 #endif
74 
76  void createCGLFullscreen(unsigned int width, unsigned int height, unsigned int depth, unsigned int fsaa, CGLContextObj sharedContext);
78  void destroyCGLFullscreen(void);
80  void swapCGLBuffers(void);
81 #if defined(MAC_OS_X_VERSION_10_6) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6
82  uint32 bitDepthFromDisplayMode(CGDisplayModeRef mode);
83 #endif
84  };
85 
86  #define ENABLE_CG_CHECK 0
87  #if ENABLE_CG_CHECK
88  #define CG_CHECK_ERROR(e) \
89  { \
90  if((CGError)e != kCGErrorSuccess) \
91  { \
92  CGReleaseAllDisplays(); \
93  OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, String("CG Error: " + StringConverter::toString(e) + + \
94  " Line # " + StringConverter::toString(__LINE__)), __PRETTY_FUNCTION__); \
95  } \
96  }
97  #else
98  #define CG_CHECK_ERROR(e) {}
99  #endif
100 
101  #if ENABLE_CG_CHECK
102  #define CGL_CHECK_ERROR(e) \
103  { \
104  if((CGLError)e != kCGLNoError) \
105  { \
106  CGReleaseAllDisplays(); \
107  OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, String("CGL Error: " + String(CGLErrorString(e)) + \
108  " Line # " + StringConverter::toString(__LINE__)), __PRETTY_FUNCTION__); \
109  } \
110  }
111  #else
112  #define CGL_CHECK_ERROR(e) {}
113  #endif
114 }
115 
116 #endif
Manages the target rendering window.
unsigned int uint32
Definition: OgrePlatform.h:246
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:524
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:64
CGLContextObj mCGLContextObj
Definition: OgreOSXWindow.h:68
virtual void reposition(int left, int top)=0
Overridden - see RenderWindow.
void swapCGLBuffers(void)
Update the full screen context.
CFDictionaryRef mOriginalDisplayMode
Definition: OgreOSXWindow.h:72
virtual void swapBuffers(bool waitForVSync)=0
Overridden - see RenderWindow.
OSXContext * mContext
Definition: OgreOSXWindow.h:64
void destroyCGLFullscreen(void)
Kill full screen mode, and return to default windowed mode.
virtual void destroy(void)=0
Overridden - see RenderWindow.
_StringBase String
A primitive describing a volume (3D), image (2D) or line (1D) of pixels in memory.
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.