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