Panda3D
|
00001 //////////////////////////////////////////////////////////////////// 00002 // 00003 // PANDA 3D SOFTWARE 00004 // Copyright (c) Carnegie Mellon University. All rights reserved. 00005 // 00006 // All use of this software is subject to the terms of the revised BSD 00007 // license. You should have received a copy of this license along 00008 // with this source code in a file named "LICENSE." 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 // Class : wglGraphicsStateGuardian 00030 // Description : A tiny specialization on GLGraphicsStateGuardian to 00031 // add some wgl-specific information. 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 // We have to save a pointer to the GSG we intend to share texture 00061 // context with, since we don't create our own context in the 00062 // constructor. 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