Panda3D
androidGraphicsStateGuardian.h
1 // Filename: androidGraphicsStateGuardian.h
2 // Created by: pro-rsoft (21May09)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #ifndef ANDROIDGRAPHICSSTATEGUARDIAN_H
16 #define ANDROIDGRAPHICSSTATEGUARDIAN_H
17 
18 #include "pandabase.h"
19 #include "androidGraphicsPipe.h"
20 
21 ////////////////////////////////////////////////////////////////////
22 // Class : AndroidGraphicsStateGuardian
23 // Description : A tiny specialization on GLESGraphicsStateGuardian
24 // to add some egl-specific information.
25 ////////////////////////////////////////////////////////////////////
26 #ifdef OPENGLES_2
27 class AndroidGraphicsStateGuardian : public GLES2GraphicsStateGuardian {
28 #else
29 class AndroidGraphicsStateGuardian : public GLESGraphicsStateGuardian {
30 #endif
31 public:
32  INLINE const FrameBufferProperties &get_fb_properties() const;
33  void get_properties(FrameBufferProperties &properties,
34  bool &pbuffer_supported, bool &pixmap_supported,
35  bool &slow, EGLConfig config);
36  void choose_pixel_format(const FrameBufferProperties &properties,
37  bool need_pbuffer, bool need_pixmap);
38  bool create_context();
39  void destroy_context();
40 
42  AndroidGraphicsStateGuardian *share_with);
43 
45 
46  virtual void reset();
47 
48  bool egl_is_at_least_version(int major_version, int minor_version) const;
49 
50 protected:
51  EGLContext _share_context;
52  EGLContext _context;
53  EGLDisplay _egl_display;
54  EGLConfig _fbconfig;
55  EGLint _format;
56  FrameBufferProperties _fbprops;
57 
58 protected:
59  virtual void gl_flush() const;
60  virtual GLenum gl_get_error() const;
61 
62  virtual void query_gl_version();
63  virtual void get_extra_extensions();
64  virtual void *do_get_extension_func(const char *name);
65 
66 private:
67  int _egl_version_major, _egl_version_minor;
68 
69  friend class AndroidGraphicsWindow;
70 
71 public:
72  static TypeHandle get_class_type() {
73  return _type_handle;
74  }
75  static void init_type() {
76 #ifdef OPENGLES_2
77  GLES2GraphicsStateGuardian::init_type();
78  register_type(_type_handle, "AndroidGraphicsStateGuardian",
79  GLES2GraphicsStateGuardian::get_class_type());
80 #else
81  GLESGraphicsStateGuardian::init_type();
82  register_type(_type_handle, "AndroidGraphicsStateGuardian",
83  GLESGraphicsStateGuardian::get_class_type());
84 #endif
85  }
86  virtual TypeHandle get_type() const {
87  return get_class_type();
88  }
89  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
90 
91 private:
92  static TypeHandle _type_handle;
93 };
94 
95 #include "androidGraphicsStateGuardian.I"
96 
97 #endif
const FrameBufferProperties & get_fb_properties() const
Gets the FrameBufferProperties for all windows and buffers that use this GSG.
bool create_context()
Creates the context based on the config previously obtained in choose_pixel_format.
void choose_pixel_format(const FrameBufferProperties &properties, bool need_pbuffer, bool need_pixmap)
Selects a visual or fbconfig for all the windows and buffers that use this gsg.
An interface to manage Android windows and their appropriate EGL surfaces.
virtual void reset()
Resets all internal state as if the gsg were newly created.
bool egl_is_at_least_version(int major_version, int minor_version) const
Returns true if the runtime GLX version number is at least the indicated value, false otherwise...
An object to create GraphicsOutputs that share a particular 3-D API.
Definition: graphicsPipe.h:58
void get_properties(FrameBufferProperties &properties, bool &pbuffer_supported, bool &pixmap_supported, bool &slow, EGLConfig config)
Gets the FrameBufferProperties to match the indicated config.
A tiny specialization on GLESGraphicsStateGuardian to add some egl-specific information.
void destroy_context()
Destroys the context previously created by create_context.
This class is the main interface to controlling the render process.
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:85
A container for the various kinds of properties we might ask to have on a graphics frameBuffer before...