blip  0.1
RenderingContext.hpp
Go to the documentation of this file.
1 #ifndef __blip_RenderingContext_hpp
2 #define __blip_RenderingContext_hpp
3 
4 #include <EGL/egl.h>
5 
6 #include <blip/Blip.hpp>
7 #include <blip/Size.hpp>
8 
9 struct ANativeWindow;
10 
11 namespace blip {
12 
13 class NativeActivity;
14 class Pixmap;
15 
25 {
26  friend class NativeActivity;
27 
28  public:
29 
32 
36  void makeCurrent();
37 
41  void swapBuffers();
42 
46  bool copyBuffer(Pixmap* pixmap);
47 
49  inline int getScreenWidth() const
50  { return(_screenSize.getWidth()); }
51 
53  inline int getScreenHeight() const
54  { return(_screenSize.getHeight()); }
55 
57  inline const Size& getScreenSize() const
58  { return(_screenSize); }
59 
61  inline int getGLVersionMajor() const
62  { return(_versionMajor); }
63 
65  inline int getGLVersionMinor() const
66  { return(_versionMinor); }
67 
69  inline bool isValid() const
70  { return(_eglContext != EGL_NO_CONTEXT); }
71 
72  private:
73 
75 
76  bool init(ANativeWindow* window);
77  void shutdown();
78 
79  EGLContext _eglContext;
80  EGLDisplay _eglDisplay;
81  EGLSurface _eglSurface;
82  Size _screenSize;
83  int _versionMajor;
84  int _versionMinor;
85 
86  CCXX_COPY_DECLS(RenderingContext);
87 };
88 
89 } // namespace blip
90 
91 #endif // __blip_RenderingContext_hpp
uint_t getHeight() const
Get the height.
Definition: Size.hpp:35
int getScreenHeight() const
Get the height of the screen, in pixels.
Definition: RenderingContext.hpp:53
A rectangular size that has a width and a height.
Definition: Size.hpp:13
void makeCurrent()
Bind this rendering context to the native window.
Definition: RenderingContext.cpp:127
int getScreenWidth() const
Get the width of the screen, in pixels.
Definition: RenderingContext.hpp:49
const Size & getScreenSize() const
Get the size of the screen, in pixels.
Definition: RenderingContext.hpp:57
uint_t getWidth() const
Get the width.
Definition: Size.hpp:27
bool isValid() const
Test if this rendering context is valid.
Definition: RenderingContext.hpp:69
The native rendering context.
Definition: RenderingContext.hpp:24
WAV file format details at: https://ccrma.stanford.edu/courses/422/projects/WaveFormat/.
Definition: AccelerometerSensorEvent.cpp:3
An abstract base class for all "native" (C++) Android activities.
Definition: NativeActivity.hpp:71
bool copyBuffer(Pixmap *pixmap)
Copy the EGL surface color buffer to a Pixmap.
Definition: RenderingContext.cpp:143
~RenderingContext()
Destructor.
Definition: RenderingContext.cpp:49
int getGLVersionMajor() const
Get the OpenGL ES major version number.
Definition: RenderingContext.hpp:61
A buffer for two-dimensional pixel data, stored in inverted row order (bottom row first...
Definition: Pixmap.hpp:58
int getGLVersionMinor() const
Get the OpenGL ES minor version number.
Definition: RenderingContext.hpp:65
void swapBuffers()
Post the EGL surface to the native window.
Definition: RenderingContext.cpp:135