00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #ifndef OSXGRAPHICSSTATEGUARDIAN_H
00013 #define OSXGRAPHICSSTATEGUARDIAN_H
00014 #include <Carbon/Carbon.h>
00015 #include <ApplicationServices/ApplicationServices.h>
00016
00017 #define __glext_h_
00018 #include <OpenGL/gl.h>
00019 #include <AGL/agl.h>
00020
00021 #include "pandabase.h"
00022 #include "glgsg.h"
00023
00024 #include "osxGraphicsWindow.h"
00025
00026 class osxGraphicsWindow;
00027
00028
00029
00030
00031
00032
00033 class osxGraphicsStateGuardian : public GLGraphicsStateGuardian {
00034 public:
00035 osxGraphicsStateGuardian(GraphicsEngine *engine, GraphicsPipe *pipe,
00036 osxGraphicsStateGuardian *share_with);
00037 virtual ~osxGraphicsStateGuardian();
00038 virtual void reset();
00039
00040 void draw_resize_box();
00041
00042 bool get_gamma_table();
00043 bool static_set_gamma(bool restore, PN_stdfloat gamma);
00044 bool set_gamma(PN_stdfloat gamma);
00045 void atexit_function();
00046 void restore_gamma();
00047
00048 protected:
00049 virtual void *do_get_extension_func(const char *prefix, const char *name);
00050
00051 public:
00052 OSStatus build_gl(bool full_screen, bool pbuffer, FrameBufferProperties &fb_props);
00053 AGLContext get_context() { return _aglcontext; };
00054
00055 const AGLPixelFormat get_agl_pixel_format() const { return _aglPixFmt; };
00056
00057 private:
00058 void describe_pixel_format(FrameBufferProperties &fb_props);
00059
00060
00061
00062
00063 PT(osxGraphicsStateGuardian) _share_with;
00064 AGLPixelFormat _aglPixFmt;
00065 AGLContext _aglcontext;
00066 CGGammaValue _gOriginalRedTable[ 256 ];
00067 CGGammaValue _gOriginalGreenTable[ 256 ];
00068 CGGammaValue _gOriginalBlueTable[ 256 ];
00069 CGTableCount _sampleCount;
00070 CGDisplayErr _cgErr;
00071
00072 public:
00073 GLint _shared_buffer;
00074
00075 public:
00076 static TypeHandle get_class_type() {
00077 return _type_handle;
00078 }
00079 static void init_type() {
00080 GLGraphicsStateGuardian::init_type();
00081 register_type(_type_handle, "osxGraphicsStateGuardian",
00082 GLGraphicsStateGuardian::get_class_type());
00083 }
00084 virtual TypeHandle get_type() const {
00085 return get_class_type();
00086 }
00087 virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
00088
00089 private:
00090 static TypeHandle _type_handle;
00091
00092 friend class osxGraphicsBuffer;
00093 };
00094
00095
00096 #endif