Panda3D
Loading...
Searching...
No Matches
androidGraphicsWindow.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 androidGraphicsWindow.h
10 * @author rdb
11 * @date 2013-01-11
12 */
13
14#ifndef ANDROIDGRAPHICSWINDOW_H
15#define ANDROIDGRAPHICSWINDOW_H
16
17#include "pandabase.h"
18
19#include "androidGraphicsPipe.h"
20#include "graphicsWindow.h"
21#include "buttonHandle.h"
22
23#include <android/native_window.h>
24#include <android/input.h>
25#include <android/native_activity.h>
26#include <android/rect.h>
27
28struct android_app;
29
30/**
31 * An interface to manage Android windows and their appropriate EGL surfaces.
32 */
33class AndroidGraphicsWindow : public GraphicsWindow {
34public:
35 AndroidGraphicsWindow(GraphicsEngine *engine, GraphicsPipe *pipe,
36 const std::string &name,
37 const FrameBufferProperties &fb_prop,
38 const WindowProperties &win_prop,
39 int flags,
41 GraphicsOutput *host);
42 virtual ~AndroidGraphicsWindow();
43
44 virtual bool begin_frame(FrameMode mode, Thread *current_thread);
45 virtual void end_frame(FrameMode mode, Thread *current_thread);
46 virtual void end_flip();
47
48 virtual void process_events();
49 virtual void set_properties_now(WindowProperties &properties);
50
51protected:
52 virtual void close_window();
53 virtual bool open_window();
54
55 virtual void destroy_surface();
56 virtual bool create_surface();
57
58private:
59 static void handle_command(struct android_app *app, int32_t command);
60 static int32_t handle_input_event(struct android_app *app, AInputEvent *event);
61
62 void ns_handle_command(int32_t command);
63 int32_t handle_key_event(const AInputEvent *event);
64 int32_t handle_motion_event(const AInputEvent *event);
65
66 ButtonHandle map_button(int32_t keycode);
67
68private:
69 struct android_app* _app;
70
71 EGLDisplay _egl_display;
72 EGLSurface _egl_surface;
73
74 int32_t _mouse_button_state;
75
77
78public:
79 static TypeHandle get_class_type() {
80 return _type_handle;
81 }
82 static void init_type() {
83 GraphicsWindow::init_type();
84 register_type(_type_handle, "AndroidGraphicsWindow",
85 GraphicsWindow::get_class_type());
86 }
87 virtual TypeHandle get_type() const {
88 return get_class_type();
89 }
90 virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
91
92private:
93 static TypeHandle _type_handle;
94};
95
97
98#endif
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
virtual void end_flip()
This function will be called within the draw thread after begin_flip() has been called on all windows...
virtual bool begin_frame(FrameMode mode, Thread *current_thread)
This function will be called within the draw thread before beginning rendering for a given frame.
virtual void process_events()
Do whatever processing is necessary to ensure that the window responds to user events.
virtual void set_properties_now(WindowProperties &properties)
Applies the requested set of properties to the window, if possible, for instance to request a change ...
virtual void end_frame(FrameMode mode, Thread *current_thread)
This function will be called within the draw thread after rendering is completed for a given frame.
A ButtonHandle represents a single button from any device, including keyboard buttons and mouse butto...
A container for the various kinds of properties we might ask to have on a graphics frameBuffer before...
Encapsulates all the communication with a particular instance of a given rendering backend.
This is a virtual input device that represents the keyboard and mouse pair that is associated with a ...
A thread; that is, a lightweight process.
Definition thread.h:46
TypeHandle is the identifier used to differentiate C++ class types.
Definition typeHandle.h:81
A container for the various kinds of properties we might ask to have on a graphics window before we o...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void register_type(TypeHandle &type_handle, const std::string &name)
This inline function is just a convenient way to call TypeRegistry::register_type(),...