Panda3D
cocoaGraphicsStateGuardian.h
1 // Filename: cocoaGraphicsStateGuardian.h
2 // Created by: rdb (14May12)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #ifndef COCOAGRAPHICSSTATEGUARDIAN_H
16 #define COCOAGRAPHICSSTATEGUARDIAN_H
17 
18 #include "pandabase.h"
19 #include "cocoaGraphicsPipe.h"
20 #include "glgsg.h"
21 
22 #import <AppKit/NSOpenGL.h>
23 
24 ////////////////////////////////////////////////////////////////////
25 // Class : CocoaGraphicsStateGuardian
26 // Description : A tiny specialization on GLGraphicsStateGuardian
27 // to add some Cocoa-specific information.
28 ////////////////////////////////////////////////////////////////////
29 class CocoaGraphicsStateGuardian : public GLGraphicsStateGuardian {
30 public:
31  INLINE const FrameBufferProperties &get_fb_properties() const;
32  void get_properties(FrameBufferProperties &properties,
33  NSOpenGLPixelFormat *pixel_format, int virtual_screen);
34  void choose_pixel_format(const FrameBufferProperties &properties,
35  CGDirectDisplayID display,
36  bool need_pbuffer);
37 
39  CocoaGraphicsStateGuardian *share_with);
40 
41  virtual ~CocoaGraphicsStateGuardian();
42 
43  NSOpenGLContext *_share_context;
44  NSOpenGLContext *_context;
45  FrameBufferProperties _fbprops;
46 
47 protected:
48  virtual void query_gl_version();
49  virtual void *do_get_extension_func(const char *name);
50 
51 public:
52  static TypeHandle get_class_type() {
53  return _type_handle;
54  }
55  static void init_type() {
56  GLGraphicsStateGuardian::init_type();
57  register_type(_type_handle, "CocoaGraphicsStateGuardian",
58  GLGraphicsStateGuardian::get_class_type());
59  }
60  virtual TypeHandle get_type() const {
61  return get_class_type();
62  }
63  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
64 
65 private:
66  static TypeHandle _type_handle;
67 };
68 
69 #include "cocoaGraphicsStateGuardian.I"
70 
71 #endif
const FrameBufferProperties & get_fb_properties() const
Gets the FrameBufferProperties for all windows and buffers that use this GSG.
A tiny specialization on GLGraphicsStateGuardian to add some Cocoa-specific information.
An object to create GraphicsOutputs that share a particular 3-D API.
Definition: graphicsPipe.h:58
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...