Panda3D

eglGraphicsStateGuardian.h

00001 // Filename: eglGraphicsStateGuardian.h
00002 // Created by:  pro-rsoft (21May09)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) Carnegie Mellon University.  All rights reserved.
00008 //
00009 // All use of this software is subject to the terms of the revised BSD
00010 // license.  You should have received a copy of this license along
00011 // with this source code in a file named "LICENSE."
00012 //
00013 ////////////////////////////////////////////////////////////////////
00014 
00015 #ifndef EGLGRAPHICSSTATEGUARDIAN_H
00016 #define EGLGRAPHICSSTATEGUARDIAN_H
00017 
00018 #include "pandabase.h"
00019 #include "eglGraphicsPipe.h"
00020 #include "get_x11.h"
00021 
00022 ////////////////////////////////////////////////////////////////////
00023 //       Class : eglGraphicsStateGuardian
00024 // Description : A tiny specialization on GLESGraphicsStateGuardian
00025 //               to add some egl-specific information.
00026 ////////////////////////////////////////////////////////////////////
00027 #ifdef OPENGLES_2
00028 class eglGraphicsStateGuardian : public GLES2GraphicsStateGuardian {
00029 #else
00030 class eglGraphicsStateGuardian : public GLESGraphicsStateGuardian {
00031 #endif
00032 public:
00033   INLINE const FrameBufferProperties &get_fb_properties() const;
00034   void get_properties(FrameBufferProperties &properties,
00035              bool &pbuffer_supported, bool &pixmap_supported,
00036                                bool &slow, EGLConfig config);
00037   void choose_pixel_format(const FrameBufferProperties &properties,
00038          X11_Display *_display,
00039          int _screen,
00040          bool need_pbuffer, bool need_pixmap);
00041 
00042   eglGraphicsStateGuardian(GraphicsEngine *engine, GraphicsPipe *pipe,
00043          eglGraphicsStateGuardian *share_with);
00044 
00045   virtual ~eglGraphicsStateGuardian();
00046 
00047   virtual void reset();
00048 
00049   bool egl_is_at_least_version(int major_version, int minor_version) const;
00050 
00051   EGLContext _share_context;
00052   EGLContext _context;
00053   EGLDisplay _egl_display;
00054   X11_Display *_display;
00055   int _screen;
00056   XVisualInfo *_visual;
00057   XVisualInfo *_visuals;
00058   EGLConfig _fbconfig;
00059   FrameBufferProperties _fbprops;
00060 
00061 protected:
00062   virtual void gl_flush() const;
00063   virtual GLenum gl_get_error() const;
00064 
00065   virtual void query_gl_version();
00066   virtual void get_extra_extensions();
00067   virtual void *do_get_extension_func(const char *prefix, const char *name);
00068 
00069 private:
00070   int _egl_version_major, _egl_version_minor;
00071 
00072 public:
00073   static TypeHandle get_class_type() {
00074     return _type_handle;
00075   }
00076   static void init_type() {
00077 #ifdef OPENGLES_2
00078     GLES2GraphicsStateGuardian::init_type();
00079     register_type(_type_handle, "eglGraphicsStateGuardian",
00080                   GLES2GraphicsStateGuardian::get_class_type());
00081 #else
00082     GLESGraphicsStateGuardian::init_type();
00083     register_type(_type_handle, "eglGraphicsStateGuardian",
00084                   GLESGraphicsStateGuardian::get_class_type());
00085 #endif
00086   }
00087   virtual TypeHandle get_type() const {
00088     return get_class_type();
00089   }
00090   virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
00091 
00092 private:
00093   static TypeHandle _type_handle;
00094 };
00095 
00096 #include "eglGraphicsStateGuardian.I"
00097 
00098 #endif
 All Classes Functions Variables Enumerations