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-2013 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
OgreOSXContext.h
Ogre::OSXWindow
Definition: OgreOSXWindow.h:40
Ogre::OSXWindow::createCGLFullscreen
void createCGLFullscreen(unsigned int width, unsigned int height, unsigned int depth, unsigned int fsaa, CGLContextObj sharedContext)
Switch to full screen mode using CGL.
Ogre
Definition: OgreAndroidLogListener.h:34
Ogre::OSXWindow::mOriginalDisplayMode
CFDictionaryRef mOriginalDisplayMode
Definition: OgreOSXWindow.h:74
Ogre::OSXWindow::windowMovedOrResized
virtual void windowMovedOrResized()
Overridden - see RenderTarget.
Definition: OgreOSXWindow.h:66
Ogre::OSXWindow::swapCGLBuffers
void swapCGLBuffers(void)
Update the full screen context.
Ogre::OSXWindow::copyContentsToMemory
virtual void copyContentsToMemory(const PixelBox &dst, FrameBuffer buffer)
Overridden - see RenderTarget.
Ogre::RenderWindow
Manages the target rendering window.
Definition: OgreRenderWindow.h:62
Ogre::OSXContext
Class that encapsulates an GL context.
Definition: OgreOSXContext.h:41
Ogre::OSXWindow::resize
virtual void resize(unsigned int width, unsigned int height)=0
Overridden - see RenderWindow.
Ogre::uint32
unsigned int uint32
Definition: OgrePlatform.h:359
Ogre::OSXWindow::isHidden
virtual bool isHidden() const =0
Indicates whether the window was set to hidden (not displayed)
Ogre::OSXWindow::destroy
virtual void destroy(void)=0
Overridden - see RenderWindow.
Ogre::String
_StringBase String
Definition: OgrePrerequisites.h:439
Ogre::OSXWindow::mCGLContextObj
CGLContextObj mCGLContextObj
Definition: OgreOSXWindow.h:70
Ogre::OSXWindow::isActive
virtual bool isActive(void) const =0
Overridden - see RenderWindow.
Ogre::OSXWindow::reposition
virtual void reposition(int left, int top)=0
Overridden - see RenderWindow.
Ogre::NameValuePairList
map< String, String >::type NameValuePairList
Name / value parameter pair (first = name, second = value)
Definition: OgreCommon.h:550
Ogre::OSXWindow::destroyCGLFullscreen
void destroyCGLFullscreen(void)
Kill full screen mode, and return to default windowed mode.
Ogre::RenderTarget::FrameBuffer
FrameBuffer
Definition: OgreRenderTarget.h:91
Ogre::OSXWindow::create
void create(const String &name, unsigned int width, unsigned int height, bool fullScreen, const NameValuePairList *miscParams)=0
Overridden - see RenderWindow.
OgreRenderWindow.h
Ogre::OSXWindow::mContext
OSXContext * mContext
Definition: OgreOSXWindow.h:66
Ogre::OSXWindow::swapBuffers
virtual void swapBuffers()=0
Overridden - see RenderWindow.
Ogre::PixelBox
A primitive describing a volume (3D), image (2D) or line (1D) of pixels in memory.
Definition: OgrePixelFormat.h:304
Ogre::OSXWindow::setHidden
virtual void setHidden(bool hidden)=0
Hide (or show) the window.
Ogre::OSXWindow::OSXWindow
OSXWindow()
Ogre::OSXWindow::isClosed
virtual bool isClosed(void) const =0
Overridden - see RenderWindow.
Ogre::OSXWindow::~OSXWindow
virtual ~OSXWindow()

Copyright © 2012 Torus Knot Software Ltd
Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
Last modified Tue Apr 13 2021 08:53:15