JeVois  1.21
JeVois Smart Embedded Machine Vision Toolkit
Share this page:
Loading...
Searching...
No Matches
ImGuiBackendMALI.H
Go to the documentation of this file.
1// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2//
3// JeVois Smart Embedded Machine Vision Toolkit - Copyright (C) 2020 by Laurent Itti, the University of Southern
4// California (USC), and iLab at USC. See http://iLab.usc.edu and http://jevois.org for information about this project.
5//
6// This file is part of the JeVois Smart Embedded Machine Vision Toolkit. This program is free software; you can
7// redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software
8// Foundation, version 2. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
9// without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
10// License for more details. You should have received a copy of the GNU General Public License along with this program;
11// if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
12//
13// Contact information: Laurent Itti - 3641 Watt Way, HNB-07A - Los Angeles, CA 90089-2520 - USA.
14// Tel: +1 213 740 3527 - itti@pollux.usc.edu - http://iLab.usc.edu - http://jevois.org
15// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
16/*! \file */
17
18#pragma once
19
20#ifdef JEVOIS_PLATFORM_PRO
21
23#include <chrono>
24#include <string>
25#include <array>
26
27#include <wchar.h>
28#include <wctype.h>
29
30//using namespace std::literals;
31using namespace std::string_literals;
32//using namespace std::literals::string_literals;
33
34// Helper struct to key track of key states
36{
37 int altgr:1;
38 int alt:1;
39 int shift:1;
40 int ctrl:1;
41 int meta:1;
42};
43
44namespace jevois
45{
46 //! BackendMALI for ImGui on JeVois-Pro
47 /*! This abstract base class provides an interface used by VideoDisplayGUI. Derived implementations are available for
48 SDL2 and Mali framebuffer + evdev.
49
50 JeVois Pro hardware reports the following:
51
52 EGL v1.4
53 EGL API is EGL_OPENGL_ES_API
54 OpenGL ES 3.2 git.c8adbf9.122c9daed32dbba4b3056f41a2f23c58 ARM (Mali-G52) GL_VER=3.2
55
56 OpenGL extensions: GL_ARM_rgba8 GL_ARM_mali_shader_binary GL_OES_depth24 GL_OES_depth_texture
57 GL_OES_depth_texture_cube_map GL_OES_packed_depth_stencil GL_OES_rgb8_rgba8 GL_EXT_read_format_bgra
58 GL_OES_compressed_paletted_texture GL_OES_compressed_ETC1_RGB8_texture GL_OES_standard_derivatives
59 GL_OES_EGL_image GL_OES_EGL_image_external GL_OES_EGL_image_external_essl3 GL_OES_EGL_sync GL_OES_texture_npot
60 GL_OES_vertex_half_float GL_OES_required_internalformat GL_OES_vertex_array_object GL_OES_mapbuffer
61 GL_EXT_texture_format_BGRA8888 GL_EXT_texture_rg GL_EXT_texture_type_2_10_10_10_REV GL_OES_fbo_render_mipmap
62 GL_OES_element_index_uint GL_EXT_shadow_samplers GL_OES_texture_compression_astc
63 GL_KHR_texture_compression_astc_ldr GL_KHR_texture_compression_astc_hdr GL_KHR_texture_compression_astc_sliced_3d
64 GL_EXT_texture_compression_astc_decode_mode GL_EXT_texture_compression_astc_decode_mode_rgb9e5 GL_KHR_debug
65 GL_EXT_occlusion_query_boolean GL_EXT_disjoint_timer_query GL_EXT_blend_minmax GL_EXT_discard_framebuffer
66 GL_OES_get_program_binary GL_OES_texture_3D GL_EXT_texture_storage GL_EXT_multisampled_render_to_texture
67 GL_OES_surfaceless_context GL_OES_texture_stencil8 GL_EXT_shader_pixel_local_storage
68 GL_ARM_shader_framebuffer_fetch GL_ARM_shader_framebuffer_fetch_depth_stencil GL_ARM_mali_program_binary
69 GL_EXT_sRGB GL_EXT_sRGB_write_control GL_EXT_texture_sRGB_decode GL_EXT_texture_sRGB_R8 GL_EXT_texture_sRGB_RG8
70 GL_KHR_blend_equation_advanced GL_KHR_blend_equation_advanced_coherent GL_OES_texture_storage_multisample_2d_array
71 GL_OES_shader_image_atomic GL_EXT_robustness GL_EXT_draw_buffers_indexed GL_OES_draw_buffers_indexed
72 GL_EXT_texture_border_clamp GL_OES_texture_border_clamp GL_EXT_texture_cube_map_array
73 GL_OES_texture_cube_map_array GL_OES_sample_variables GL_OES_sample_shading
74 GL_OES_shader_multisample_interpolation GL_EXT_shader_io_blocks GL_OES_shader_io_blocks GL_EXT_tessellation_shader
75 GL_OES_tessellation_shader GL_EXT_primitive_bounding_box GL_OES_primitive_bounding_box GL_EXT_geometry_shader
76 GL_OES_geometry_shader GL_ANDROID_extension_pack_es31a GL_EXT_gpu_shader5 GL_OES_gpu_shader5 GL_EXT_texture_buffer
77 GL_OES_texture_buffer GL_EXT_copy_image GL_OES_copy_image GL_EXT_shader_non_constant_global_initializers
78 GL_EXT_color_buffer_half_float GL_EXT_color_buffer_float GL_EXT_YUV_target GL_OVR_multiview GL_OVR_multiview2
79 GL_OVR_multiview_multisampled_render_to_texture GL_KHR_robustness GL_KHR_robust_buffer_access_behavior
80 GL_EXT_draw_elements_base_vertex GL_OES_draw_elements_base_vertex GL_EXT_buffer_storage
81 GL_EXT_texture_filter_anisotropic
82
83 To get correct UTF-8 keyboard translation, you need env var LC_CTYPE to be set, e.g., en_US.UTF-8
84
85 \ingroup core */
87 {
88 public:
89 //! Constructor
91
92 //! Virtual destructor for safe inheritance, free resources
93 virtual ~ImGuiBackendMALI();
94
95 //! Avoid masking virtual overloads
97
98 //! Initialize the underlying engine that will process events, create windows, etc
99 /*! The init starts with the given initial window/framebuffer size. If conslock is true, we lock the console and
100 the framebuffer; set to false when running in gdb for debugging, using gdb --args jevoispro-daemon
101 --conslock=false */
102 virtual void init(unsigned short w, unsigned short h, bool fullscreen = false, float scale = 1.0f,
103 bool conslock = true);
104
105 //! Poll events such as mouse movements, buttons, keyboard, joystick, and pass to ImGui
106 /*! Returns true if some events were received, which can be used to turn on mouse pointer and GUI. */
107 virtual bool pollEvents(bool & shouldclose) override;
108
109 //! Start a new frame and clear the window/framebuffer
110 virtual void newFrame() override;
111
112 //! Render the ImGui graphics
113 virtual void render() override;
114
115 protected:
116 std::chrono::time_point<std::chrono::steady_clock> itsLastNewFrameTime;
117 int itsFd[32];
118 void scanDevices();
119 void addDevice(size_t num, int fd);
120 void removeDevice(size_t num);
126 int itsWidth = 0, itsHeight = 0;
127
128 std::array<wchar_t, 49> itsCharKeys { L"1234567890-=qwertyuiop[]asdfghjkl;'`\\zxcvbnm,./<" };
129 std::array<wchar_t, 49> itsShiftKeys { L"!@#$%^&*()_+QWERTYUIOP{}ASDFGHJKL:\"~|ZXCVBNM<>?>" };
130 std::array<wchar_t, 49> itsAltgrKeys = { 0 };
131 static constexpr wchar_t itsFuncKeys[58][8] =
132 {
133 L"<Esc>", L"<BckSp>", L"<Tab>", L"<Enter>", L"<LCtrl>", L"<LShft>",
134 L"<RShft>", L"<KP*>", L"<LAlt>", L" ", L"<CpsLk>", L"<F1>", L"<F2>",
135 L"<F3>", L"<F4>", L"<F5>", L"<F6>", L"<F7>", L"<F8>", L"<F9>", L"<F10>",
136 L"<NumLk>", L"<ScrLk>", L"<KP7>", L"<KP8>", L"<KP9>", L"<KP->", L"<KP4>",
137 L"<KP5>", L"<KP6>", L"<KP+>", L"<KP1>", L"<KP2>", L"<KP3>", L"<KP0>",
138 L"<KP.>", /*"<",*/ L"<F11>", L"<F12>", L"<KPEnt>", L"<RCtrl>", L"<KP/>",
139 L"<PrtSc>", L"<AltGr>", L"<Break>" /*linefeed?*/, L"<Home>", L"<Up>",
140 L"<PgUp>", L"<Left>", L"<Right>", L"<End>", L"<Down>", L"<PgDn>",
141 L"<Ins>", L"<Del>", L"<Pause>", L"<LMeta>", L"<RMeta>", L"<Menu>"
142 };
143
145 char itsInputBuffer[256] = { 0 };
146 bool itsInitialized = false;
147 };
148
149} // namespace jevois
150
151#endif // JEVOIS_PLATFORM_PRO
int h
Definition GUIhelper.C:2491
#define L(i, x, y, z)
Definition GUIhelper.C:2492
BackendMALI for ImGui on JeVois-Pro.
std::array< wchar_t, 49 > itsShiftKeys
void addDevice(size_t num, int fd)
void removeDevice(size_t num)
std::array< wchar_t, 49 > itsCharKeys
static constexpr wchar_t itsFuncKeys[58][8]
virtual bool pollEvents(bool &shouldclose) override
Poll events such as mouse movements, buttons, keyboard, joystick, and pass to ImGui.
virtual ~ImGuiBackendMALI()
Virtual destructor for safe inheritance, free resources.
virtual void init(unsigned short w, unsigned short h, bool fullscreen=false, float scale=1.0f, bool conslock=true)
Initialize the underlying engine that will process events, create windows, etc.
std::chrono::time_point< std::chrono::steady_clock > itsLastNewFrameTime
virtual void render() override
Render the ImGui graphics.
virtual void newFrame() override
Start a new frame and clear the window/framebuffer.
input_event_state itsInputState
std::array< wchar_t, 49 > itsAltgrKeys
Backend for VideoDisplay on JeVois-Pro host using MALI.
virtual void init(unsigned short w, unsigned short h, bool fullscreen=false) override
Initialize the underlying engine that will process events, create windows, etc.
Main namespace for all JeVois classes and functions.
Definition Concepts.dox:2