Panda3D
osxGraphicsStateGuardian.h
1 ////////////////////////////////////////////////////////////////////
2 //
3 // PANDA 3D SOFTWARE
4 // Copyright (c) Carnegie Mellon University. All rights reserved.
5 //
6 // All use of this software is subject to the terms of the revised BSD
7 // license. You should have received a copy of this license along
8 // with this source code in a file named "LICENSE."
9 //
10 ////////////////////////////////////////////////////////////////////
11 
12 #ifndef OSXGRAPHICSSTATEGUARDIAN_H
13 #define OSXGRAPHICSSTATEGUARDIAN_H
14 #include <Carbon/Carbon.h>
15 #include <ApplicationServices/ApplicationServices.h>
16 
17 #define __glext_h_
18 #include <OpenGL/gl.h>
19 #include <AGL/agl.h>
20 
21 #include "pandabase.h"
22 #include "glgsg.h"
23 
24 #include "osxGraphicsWindow.h"
25 
26 class osxGraphicsWindow;
27 
28 ////////////////////////////////////////////////////////////////////
29 // Class : wglGraphicsStateGuardian
30 // Description : A tiny specialization on GLGraphicsStateGuardian to
31 // add some wgl-specific information.
32 ////////////////////////////////////////////////////////////////////
33 class osxGraphicsStateGuardian : public GLGraphicsStateGuardian {
34 public:
36  osxGraphicsStateGuardian *share_with);
37  virtual ~osxGraphicsStateGuardian();
38  virtual void reset();
39 
40  void draw_resize_box();
41 
42  bool get_gamma_table();
43  bool static_set_gamma(bool restore, PN_stdfloat gamma);
44  bool set_gamma(PN_stdfloat gamma);
45  void atexit_function();
46  void restore_gamma();
47 
48 protected:
49  virtual void *do_get_extension_func(const char *name);
50 
51 public:
52  OSStatus build_gl(bool full_screen, bool pbuffer, FrameBufferProperties &fb_props);
53  AGLContext get_context() { return _aglcontext; };
54 
55  const AGLPixelFormat get_agl_pixel_format() const { return _aglPixFmt; };
56 
57 private:
58  void describe_pixel_format(FrameBufferProperties &fb_props);
59 
60  // We have to save a pointer to the GSG we intend to share texture
61  // context with, since we don't create our own context in the
62  // constructor.
63  PT(osxGraphicsStateGuardian) _share_with;
64  AGLPixelFormat _aglPixFmt;
65  AGLContext _aglcontext;
66  CGGammaValue _gOriginalRedTable[ 256 ];
67  CGGammaValue _gOriginalGreenTable[ 256 ];
68  CGGammaValue _gOriginalBlueTable[ 256 ];
69  CGTableCount _sampleCount;
70  CGDisplayErr _cgErr;
71 
72 public:
73  GLint _shared_buffer;
74 
75 public:
76  static TypeHandle get_class_type() {
77  return _type_handle;
78  }
79  static void init_type() {
80  GLGraphicsStateGuardian::init_type();
81  register_type(_type_handle, "osxGraphicsStateGuardian",
82  GLGraphicsStateGuardian::get_class_type());
83  }
84  virtual TypeHandle get_type() const {
85  return get_class_type();
86  }
87  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
88 
89 private:
90  static TypeHandle _type_handle;
91 
92  friend class osxGraphicsBuffer;
93 };
94 
95 
96 #endif
bool set_gamma(PN_stdfloat gamma)
Non static version of setting gamma.
An offscreen buffer in the OSX environment.
void draw_resize_box()
Draws an OSX-style resize icon in the bottom right corner of the current display region.
A tiny specialization on GLGraphicsStateGuardian to add some wgl-specific information.
void atexit_function()
This function is passed to the atexit function.
bool static_set_gamma(bool restore, PN_stdfloat gamma)
Static function for setting gamma which is needed for atexit.
An interface to the osx/ system for managing GL windows under X.
An object to create GraphicsOutputs that share a particular 3-D API.
Definition: graphicsPipe.h:58
void restore_gamma()
Restore original gamma.
OSStatus build_gl(bool full_screen, bool pbuffer, FrameBufferProperties &fb_props)
This function will build up a context for a gsg.
This class is the main interface to controlling the render process.
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:85
A container for the various kinds of properties we might ask to have on a graphics frameBuffer before...
virtual void reset()
Resets all internal state as if the gsg were newly created.
bool get_gamma_table()
Static function for getting the orig gamma tables.