Panda3D

Loading...
Searching...
No Matches
osxGraphicsStateGuardian.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 osxGraphicsStateGuardian.h
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 * A tiny specialization on GLGraphicsStateGuardian to add some wgl-specific
30 * information.
31 */
32 class osxGraphicsStateGuardian : public GLGraphicsStateGuardian {
33 public:
34 osxGraphicsStateGuardian(GraphicsEngine *engine, GraphicsPipe *pipe,
35 osxGraphicsStateGuardian *share_with);
36 virtual ~osxGraphicsStateGuardian();
37 virtual void reset();
38
39 void draw_resize_box();
40
41 bool get_gamma_table();
42 bool static_set_gamma(bool restore, PN_stdfloat gamma);
43 bool set_gamma(PN_stdfloat gamma);
44 void atexit_function();
45 void restore_gamma();
46
47 protected:
48 virtual void *do_get_extension_func(const char *name);
49
50 public:
51 OSStatus build_gl(bool full_screen, bool pbuffer, FrameBufferProperties &fb_props);
52 AGLContext get_context() { return _aglcontext; };
53
54 const AGLPixelFormat get_agl_pixel_format() const { return _aglPixFmt; };
55
56 private:
57 void describe_pixel_format(FrameBufferProperties &fb_props);
58
59 // We have to save a pointer to the GSG we intend to share texture context
60 // with, since we don't create our own context in the constructor.
61 PT(osxGraphicsStateGuardian) _share_with;
62 AGLPixelFormat _aglPixFmt;
63 AGLContext _aglcontext;
64 CGGammaValue _gOriginalRedTable[ 256 ];
65 CGGammaValue _gOriginalGreenTable[ 256 ];
66 CGGammaValue _gOriginalBlueTable[ 256 ];
67 uint32_t _sampleCount;
68 CGDisplayErr _cgErr;
69
70 public:
71 GLint _shared_buffer;
72
73 public:
74 static TypeHandle get_class_type() {
75 return _type_handle;
76 }
77 static void init_type() {
78 GLGraphicsStateGuardian::init_type();
79 register_type(_type_handle, "osxGraphicsStateGuardian",
80 GLGraphicsStateGuardian::get_class_type());
81 }
82 virtual TypeHandle get_type() const {
83 return get_class_type();
84 }
85 virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
86
87 private:
88 static TypeHandle _type_handle;
89
90 friend class osxGraphicsBuffer;
91};
92
93
94#endif
FrameBufferProperties
A container for the various kinds of properties we might ask to have on a graphics frameBuffer before...
Definition frameBufferProperties.h:26
GraphicsEngine
This class is the main interface to controlling the render process.
Definition graphicsEngine.h:53
GraphicsPipe
An object to create GraphicsOutputs that share a particular 3-D API.
Definition graphicsPipe.h:52
TypeHandle
TypeHandle is the identifier used to differentiate C++ class types.
Definition typeHandle.h:81
osxGraphicsStateGuardian::restore_gamma
void restore_gamma()
Restore original gamma.
Definition osxGraphicsStateGuardian.cxx:449
osxGraphicsStateGuardian::atexit_function
void atexit_function()
This function is passed to the atexit function.
Definition osxGraphicsStateGuardian.cxx:457
osxGraphicsStateGuardian::reset
virtual void reset()
Resets all internal state as if the gsg were newly created.
Definition osxGraphicsStateGuardian.cxx:79
osxGraphicsStateGuardian::draw_resize_box
void draw_resize_box()
Draws an OSX-style resize icon in the bottom right corner of the current display region.
Definition osxGraphicsStateGuardian.cxx:106
osxGraphicsStateGuardian::set_gamma
bool set_gamma(PN_stdfloat gamma)
Non static version of setting gamma.
Definition osxGraphicsStateGuardian.cxx:437
osxGraphicsStateGuardian::get_gamma_table
bool get_gamma_table()
Static function for getting the orig gamma tables.
Definition osxGraphicsStateGuardian.cxx:375
osxGraphicsStateGuardian::build_gl
OSStatus build_gl(bool full_screen, bool pbuffer, FrameBufferProperties &fb_props)
This function will build up a context for a gsg.
Definition osxGraphicsStateGuardian.cxx:165
osxGraphicsStateGuardian::static_set_gamma
bool static_set_gamma(bool restore, PN_stdfloat gamma)
Static function for setting gamma which is needed for atexit.
Definition osxGraphicsStateGuardian.cxx:384
osxGraphicsWindow
An interface to the osx/ system for managing GL windows under X.
Definition osxGraphicsWindow.h:31
glgsg.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
osxGraphicsWindow.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