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 
00021 #include <X11/Xutil.h>
00022 
00023 ////////////////////////////////////////////////////////////////////
00024 //       Class : eglGraphicsStateGuardian
00025 // Description : A tiny specialization on GLESGraphicsStateGuardian
00026 //               to add some egl-specific information.
00027 ////////////////////////////////////////////////////////////////////
00028 #ifdef OPENGLES_2
00029 class eglGraphicsStateGuardian : public GLES2GraphicsStateGuardian {
00030 #else
00031 class eglGraphicsStateGuardian : public GLESGraphicsStateGuardian {
00032 #endif
00033 public:
00034   INLINE const FrameBufferProperties &get_fb_properties() const;
00035   void get_properties(FrameBufferProperties &properties,
00036              bool &pbuffer_supported, bool &pixmap_supported,
00037                                bool &slow, EGLConfig config);
00038   void choose_pixel_format(const FrameBufferProperties &properties,
00039          Display *_display,
00040          int _screen,
00041          bool need_pbuffer, bool need_pixmap);
00042 
00043   eglGraphicsStateGuardian(GraphicsEngine *engine, GraphicsPipe *pipe,
00044          eglGraphicsStateGuardian *share_with);
00045 
00046   virtual ~eglGraphicsStateGuardian();
00047 
00048   virtual void reset();
00049 
00050   bool egl_is_at_least_version(int major_version, int minor_version) const;
00051 
00052   EGLContext _share_context;
00053   EGLContext _context;
00054   EGLDisplay _egl_display;
00055   Display *_display;
00056   int _screen;
00057   XVisualInfo *_visual;
00058   XVisualInfo *_visuals;
00059   EGLConfig _fbconfig;
00060   FrameBufferProperties _fbprops;
00061 
00062 protected:
00063   virtual void gl_flush() const;
00064   virtual GLenum gl_get_error() const;
00065 
00066   virtual void query_gl_version();
00067   virtual void get_extra_extensions();
00068   virtual void *do_get_extension_func(const char *prefix, const char *name);
00069 
00070 private:
00071   int _egl_version_major, _egl_version_minor;
00072 
00073 public:
00074   static TypeHandle get_class_type() {
00075     return _type_handle;
00076   }
00077   static void init_type() {
00078 #ifdef OPENGLES_2
00079     GLES2GraphicsStateGuardian::init_type();
00080     register_type(_type_handle, "eglGraphicsStateGuardian",
00081                   GLES2GraphicsStateGuardian::get_class_type());
00082 #else
00083     GLESGraphicsStateGuardian::init_type();
00084     register_type(_type_handle, "eglGraphicsStateGuardian",
00085                   GLESGraphicsStateGuardian::get_class_type());
00086 #endif
00087   }
00088   virtual TypeHandle get_type() const {
00089     return get_class_type();
00090   }
00091   virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
00092 
00093 private:
00094   static TypeHandle _type_handle;
00095 };
00096 
00097 #include "eglGraphicsStateGuardian.I"
00098 
00099 #endif
 All Classes Functions Variables Enumerations