Panda3D
cocoaGraphicsStateGuardian.h
Go to the documentation of this file.
1 /**
2  * PANDA 3D SOFTWARE
3  * Copyright (c) Carnegie Mellon University. All rights reserved.
4  *
5  * All use of this software is subject to the terms of the revised BSD
6  * license. You should have received a copy of this license along
7  * with this source code in a file named "LICENSE."
8  *
9  * @file cocoaGraphicsStateGuardian.h
10  * @author rdb
11  * @date 2012-05-14
12  */
13 
14 #ifndef COCOAGRAPHICSSTATEGUARDIAN_H
15 #define COCOAGRAPHICSSTATEGUARDIAN_H
16 
17 #include "pandabase.h"
18 #include "cocoaGraphicsPipe.h"
19 #include "glgsg.h"
20 
21 #import <AppKit/NSOpenGL.h>
22 #import <OpenGL/OpenGL.h>
23 #import <CoreVideo/CoreVideo.h>
24 
25 /**
26  * A tiny specialization on GLGraphicsStateGuardian to add some Cocoa-specific
27  * 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  bool setup_vsync();
43 
44  INLINE void lock_context();
45  INLINE void unlock_context();
46 
47  NSOpenGLContext *_share_context;
48  NSOpenGLContext *_context;
49  NSOpenGLPixelFormat *_format = nullptr;
50  FrameBufferProperties _fbprops;
51 
52  CVDisplayLinkRef _display_link = nullptr;
53  TrueMutexImpl _swap_lock;
54  TrueConditionVarImpl _swap_condition;
55  AtomicAdjust::Integer _last_wait_frame = 0;
56 
57 protected:
58  virtual void query_gl_version();
59  virtual void *do_get_extension_func(const char *name);
60 
61 public:
62  static TypeHandle get_class_type() {
63  return _type_handle;
64  }
65  static void init_type() {
66  GLGraphicsStateGuardian::init_type();
67  register_type(_type_handle, "CocoaGraphicsStateGuardian",
68  GLGraphicsStateGuardian::get_class_type());
69  }
70  virtual TypeHandle get_type() const {
71  return get_class_type();
72  }
73  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
74 
75 private:
76  static TypeHandle _type_handle;
77 };
78 
80 
81 #endif
FrameBufferProperties
A container for the various kinds of properties we might ask to have on a graphics frameBuffer before...
Definition: frameBufferProperties.h:26
glgsg.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
pandabase.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
register_type
void register_type(TypeHandle &type_handle, const std::string &name)
This inline function is just a convenient way to call TypeRegistry::register_type(),...
Definition: register_type.I:22
CocoaGraphicsStateGuardian::get_fb_properties
const FrameBufferProperties & get_fb_properties() const
Gets the FrameBufferProperties for all windows and buffers that use this GSG.
Definition: cocoaGraphicsStateGuardian.I:19
GraphicsEngine
This class is the main interface to controlling the render process.
Definition: graphicsEngine.h:53
TypeHandle
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:81
GraphicsPipe
An object to create GraphicsOutputs that share a particular 3-D API.
Definition: graphicsPipe.h:52
cocoaGraphicsStateGuardian.I
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
CocoaGraphicsStateGuardian
A tiny specialization on GLGraphicsStateGuardian to add some Cocoa-specific information.
Definition: cocoaGraphicsStateGuardian.h:29
CocoaGraphicsStateGuardian::lock_context
void lock_context()
Locks the context.
Definition: cocoaGraphicsStateGuardian.I:27
cocoaGraphicsPipe.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
CocoaGraphicsStateGuardian::unlock_context
void unlock_context()
Unlocks the context.
Definition: cocoaGraphicsStateGuardian.I:36