reference

This documentation is automatically generated from the openFrameworks source code using doxygen and refers to the most recent release, version 0.12.0.

ofAppEGLWindow.h
Go to the documentation of this file.
1#pragma once
2
3#include "ofAppBaseWindow.h"
4#include "ofThread.h"
5#include "ofImage.h"
6#include "ofEvents.h"
7#include "ofRectangle.h"
8#include "ofConstants.h"
9#include <queue>
10#include <map>
11#include <X11/Xlib.h>
12
18
19typedef struct _XIM * XIM;
20typedef struct _XIC * XIC;
21typedef unsigned long Window;
22struct _XDisplay;
23typedef struct _XDisplay Display;
24
25typedef unsigned int EGLBoolean;
26typedef int32_t EGLint;
27typedef void *EGLDisplay;
28typedef void *EGLConfig;
29typedef void *EGLSurface;
30typedef void *EGLContext;
31
32typedef std::map<EGLint,EGLint> ofEGLAttributeList;
33typedef std::map<EGLint,EGLint>::iterator ofEGLAttributeListIterator;
34
52
54public:
55
59
61 virtual ~ofAppEGLWindow();
62
63 static void loop(){};
64 static bool doesLoop(){ return false; }
65 static bool allowsMultiWindow(){ return false; }
66 static bool needsPolling(){ return true; }
67 static void pollEvents();
68
70 void setup(const ofAppEGLWindowSettings & settings);
71 void setup(const ofGLESWindowSettings & settings);
72
73 void update();
74 void draw();
75 void close();
76 void makeCurrent();
77 void swapBuffers();
78 void startRender();
79 void finishRender();
80
82 std::shared_ptr<ofBaseRenderer> & renderer();
83
84 void setThreadTimeout(long timeOut){ threadTimeout = timeOut; }
85
86 virtual void hideCursor();
87 virtual void showCursor();
88
89 virtual void setWindowPosition(int x, int y);
90 virtual void setWindowShape(int w, int h);
91
92 virtual glm::vec2 getWindowPosition();
93 virtual glm::vec2 getWindowSize();
94 virtual glm::vec2 getScreenSize();
95
98 virtual bool doesHWOrientation();
99
100 //this is used by ofGetWidth and now determines the window width based on orientation
101 virtual int getWidth();
102 virtual int getHeight();
103
104 virtual void setWindowTitle(std::string title); // TODO const correct
105
106 virtual ofWindowMode getWindowMode();
107
108 virtual void setFullscreen(bool fullscreen);
109 virtual void toggleFullscreen();
110
111 virtual void enableSetupScreen();
112 virtual void disableSetupScreen();
113
114 virtual void setVerticalSync(bool enabled);
115
119
120#ifndef TARGET_RASPBERRY_PI_LEGACY
123#endif
124
125 EGLConfig getEglConfig() const;
126
127 EGLint getEglVersionMajor () const;
129
130
131protected:
132 void setWindowRect(const ofRectangle& requestedWindowRect);
133
134
135// bool create
136
137 virtual void setupPeripherals();
138
139 virtual ofRectangle getScreenRect();
140
141 int getWindowWidth();
142 int getWindowHeight();
143
149
150 std::string eglDisplayString;
153
154
155 void threadedFunction();
156 std::queue<ofMouseEventArgs> mouseEvents;
157 std::queue<ofKeyEventArgs> keyEvents;
158 std::queue<ofTouchEventArgs> touchEvents;
161
162 // TODO: getters and setters? OR automatically set based on
163 // OS or screen size? Should be changed when screen is resized?
166
167
168 // float getMouseScaleX() const;
169 // void setMouseScaleX(float x);
170 // float getMouseScaleY() const;
171 // void setMouseScaleY(float y);
172
173 // For absolute input devices that send ABS_X and ABS_Y events, we want to store
174 // information about the min and max axis values.
179
180 bool hasMouse() { return mouseDetected; }
181 bool hasKeyboard() { return keyboardDetected; }
182
183
184//------------------------------------------------------------
185// EGL
186//------------------------------------------------------------
187
188 bool createSurface();
189 bool destroySurface();
190
191 // bool resizeSurface();
192
193 EGLDisplay eglDisplay; // EGL display connection
196
198
201
202//------------------------------------------------------------
203// PLATFORM SPECIFIC WINDOWING
204//------------------------------------------------------------
205
206//------------------------------------------------------------
207// WINDOWING
208//------------------------------------------------------------
209 // EGL window
210 ofRectangle nonFullscreenWindowRect; // the rectangle describing the non-fullscreen window
211 ofRectangle currentWindowRect; // the rectangle describing the current device
212
213 bool createWindow(const ofRectangle& requestedWindowRect);
214 bool destroyWindow();
215
217
220
221 void initNative();
222 void exitNative();
223
224 EGLNativeWindowType getNativeWindow();
225 EGLNativeDisplayType getNativeDisplay();
226
227#ifdef TARGET_RASPBERRY_PI_LEGACY
228 void initRPiNative();
229 void exitRPiNative();
230
231 EGL_DISPMANX_WINDOW_T dispman_native_window; // rpi
232
233 DISPMANX_UPDATE_HANDLE_T dispman_update;
234 DISPMANX_ELEMENT_HANDLE_T dispman_element;
235 DISPMANX_DISPLAY_HANDLE_T dispman_display;
236
237 DISPMANX_CLAMP_T dispman_clamp;
238 DISPMANX_TRANSFORM_T dispman_transform;
239 VC_DISPMANX_ALPHA_T dispman_alpha;
240
241 bool createRPiNativeWindow(const ofRectangle& requestedWindowRect);
242
243#else
244 // if you are not raspberry pi, you will not be able to
245 // create a window without using x11.
246#endif
247
249 Screen* x11Screen;
252 bool createX11NativeWindow(const ofRectangle& requestedWindowRect);
253
254//------------------------------------------------------------
255// EVENTS
256//------------------------------------------------------------
257 void setupNativeEvents();
258 void destroyNativeEvents();
259
260 void setupNativeUDev();
261 void destroyNativeUDev();
262
263 void setupNativeInput();
264 void destroyNativeInput();
265
268
269 void processInput(int fd, const char * node);
270 void addInput(const char * node, bool isMouse);
271 void removeInput(const char * node);
272 void printInput();
273
274 static void handleX11Event(const XEvent& event);
275
276private:
277 ofAppEGLWindowSettings settings;
278 int glesVersion;
279 bool keyboardDetected;
280 bool mouseDetected;
281 long threadTimeout;
282 ofCoreEvents coreEvents;
283 std::shared_ptr<ofBaseRenderer> currentRenderer;
284 static ofAppEGLWindow * instance;
285};
Definition ofAppBaseWindow.h:117
virtual void setup(const ofGLESWindowSettings &settings)=0
Definition ofAppEGLWindow.h:53
ofAppEGLWindow()
Definition ofAppEGLWindow.cpp:248
std::shared_ptr< ofBaseRenderer > & renderer()
Definition ofAppEGLWindow.cpp:902
void setupNativeUDev()
Definition ofAppEGLWindow.cpp:1323
void destroyNativeUDev()
Definition ofAppEGLWindow.cpp:1346
ofRectangle nonFullscreenWindowRect
Definition ofAppEGLWindow.h:210
virtual int getHeight()
Definition ofAppEGLWindow.cpp:1139
bool isSurfaceInited
Indicate that the surface is (properly) initialized.
Definition ofAppEGLWindow.h:219
bool destroyWindow()
Definition ofAppEGLWindow.cpp:757
int mouseAbsXMax
Definition ofAppEGLWindow.h:176
EGLint eglVersionMajor
Definition ofAppEGLWindow.h:199
long x11ScreenNum
The number of the X11 screen is in use (currently).
Definition ofAppEGLWindow.h:251
float mouseScaleX
Amount by which to mouse movements along the X axis.
Definition ofAppEGLWindow.h:164
void printInput()
Definition ofAppEGLWindow.cpp:1488
virtual void disableSetupScreen()
Definition ofAppEGLWindow.cpp:1289
EGLContext getEglContext() const
Definition ofAppEGLWindow.cpp:289
void makeCurrent()
Definition ofAppEGLWindow.cpp:805
void setWindowRect(const ofRectangle &requestedWindowRect)
Definition ofAppEGLWindow.cpp:921
EGLSurface eglSurface
Definition ofAppEGLWindow.h:194
EGLConfig getEglConfig() const
Definition ofAppEGLWindow.cpp:305
void exitNative()
Definition ofAppEGLWindow.cpp:327
int mouseAbsYMax
Definition ofAppEGLWindow.h:178
void threadedFunction()
The thread's run function.
Definition ofAppEGLWindow.cpp:1305
void destroyNativeInput()
Definition ofAppEGLWindow.cpp:1496
virtual int getWidth()
Definition ofAppEGLWindow.cpp:1131
bool bEnableSetupScreen
This indicates the need/intent to draw a setup screen.
Definition ofAppEGLWindow.h:147
ofCoreEvents & events()
Definition ofAppEGLWindow.cpp:897
virtual glm::vec2 getWindowSize()
Definition ofAppEGLWindow.cpp:1091
void removeInput(const char *node)
Definition ofAppEGLWindow.cpp:1477
bool createX11NativeWindow(const ofRectangle &requestedWindowRect)
Definition ofAppEGLWindow.cpp:2046
EGLConfig eglConfig
Definition ofAppEGLWindow.h:197
void destroyNativeEvents()
Definition ofAppEGLWindow.cpp:914
Window getX11Window()
Definition ofAppEGLWindow.cpp:300
void update()
Definition ofAppEGLWindow.cpp:832
bool createSurface()
Definition ofAppEGLWindow.cpp:506
EGLDisplay getEglDisplay() const
Definition ofAppEGLWindow.cpp:279
virtual void setupPeripherals()
Definition ofAppEGLWindow.cpp:490
ofWindowMode windowMode
Definition ofAppEGLWindow.h:144
bool isWindowInited
Indicate that the window is (properly) initialized.
Definition ofAppEGLWindow.h:218
virtual void setOrientation(ofOrientation orientation)
Definition ofAppEGLWindow.cpp:1147
void setThreadTimeout(long timeOut)
Definition ofAppEGLWindow.h:84
static bool doesLoop()
Definition ofAppEGLWindow.h:64
bool bShowCursor
Indicate the visibility of the (mouse) cursor.
Definition ofAppEGLWindow.h:148
virtual void setWindowPosition(int x, int y)
Definition ofAppEGLWindow.cpp:1162
void addInput(const char *node, bool isMouse)
Definition ofAppEGLWindow.cpp:1439
virtual void hideCursor()
Definition ofAppEGLWindow.cpp:1076
int mouseAbsYMin
Definition ofAppEGLWindow.h:177
ofAppEGLWindowSettings Settings
Definition ofAppEGLWindow.h:58
int nFramesSinceWindowResized
The number of frames passed/shown since the window got resized.
Definition ofAppEGLWindow.h:151
void finishRender()
Definition ofAppEGLWindow.cpp:827
bool hasMouse()
Definition ofAppEGLWindow.h:180
virtual void toggleFullscreen()
Definition ofAppEGLWindow.cpp:1259
std::string eglDisplayString
Definition ofAppEGLWindow.h:150
void setupNativeEvents()
Definition ofAppEGLWindow.cpp:907
virtual void setWindowShape(int w, int h)
Definition ofAppEGLWindow.cpp:1223
static bool allowsMultiWindow()
Definition ofAppEGLWindow.h:65
Window x11Window
Definition ofAppEGLWindow.h:250
EGLint eglVersionMinor
Definition ofAppEGLWindow.h:200
static void loop()
Definition ofAppEGLWindow.h:63
EGLint getEglVersionMinor() const
Definition ofAppEGLWindow.cpp:315
virtual void showCursor()
Definition ofAppEGLWindow.cpp:1081
ofOrientation orientation
Definition ofAppEGLWindow.h:152
void setup(const ofAppEGLWindowSettings &settings)
Definition ofAppEGLWindow.cpp:382
static bool needsPolling()
Definition ofAppEGLWindow.h:66
virtual void setFullscreen(bool fullscreen)
Definition ofAppEGLWindow.cpp:1271
EGLContext eglContext
Definition ofAppEGLWindow.h:195
void close()
Definition ofAppEGLWindow.cpp:790
float mouseScaleY
Amount by which to mouse movements along the Y axis.
Definition ofAppEGLWindow.h:165
bool destroySurface()
Definition ofAppEGLWindow.cpp:732
EGLNativeDisplayType getNativeDisplay()
Definition ofAppEGLWindow.cpp:353
bool isUsingX11
Indicate the use of the X Window System.
Definition ofAppEGLWindow.h:216
void initNative()
Definition ofAppEGLWindow.cpp:320
Display * getX11Display()
Definition ofAppEGLWindow.cpp:295
virtual glm::vec2 getWindowPosition()
Definition ofAppEGLWindow.cpp:1096
int getWindowWidth()
Definition ofAppEGLWindow.cpp:1012
virtual ofOrientation getOrientation()
Definition ofAppEGLWindow.cpp:1152
Display * x11Display
Indicate which X11 display is in use (currently).
Definition ofAppEGLWindow.h:248
virtual void setWindowTitle(std::string title)
Definition ofAppEGLWindow.cpp:1086
virtual void setVerticalSync(bool enabled)
Definition ofAppEGLWindow.cpp:1300
bool hasKeyboard()
Definition ofAppEGLWindow.h:181
virtual ofWindowMode getWindowMode()
Definition ofAppEGLWindow.cpp:1254
virtual void enableSetupScreen()
Definition ofAppEGLWindow.cpp:1284
static void handleX11Event(const XEvent &event)
Definition ofAppEGLWindow.cpp:2228
EGLint getEglVersionMajor() const
Definition ofAppEGLWindow.cpp:310
int getWindowHeight()
Definition ofAppEGLWindow.cpp:1017
virtual ~ofAppEGLWindow()
Definition ofAppEGLWindow.cpp:274
EGLNativeWindowType getNativeWindow()
Definition ofAppEGLWindow.cpp:334
void swapBuffers()
Definition ofAppEGLWindow.cpp:813
virtual glm::vec2 getScreenSize()
Definition ofAppEGLWindow.cpp:1101
void readNativeUDevEvents()
Definition ofAppEGLWindow.cpp:1870
void startRender()
Definition ofAppEGLWindow.cpp:822
void readNativeInputEvents()
Definition ofAppEGLWindow.cpp:1932
EGLDisplay eglDisplay
Definition ofAppEGLWindow.h:193
bool createWindow(const ofRectangle &requestedWindowRect)
Definition ofAppEGLWindow.cpp:998
std::queue< ofKeyEventArgs > keyEvents
Definition ofAppEGLWindow.h:157
std::queue< ofTouchEventArgs > touchEvents
Definition ofAppEGLWindow.h:158
int mouseAbsXMin
Definition ofAppEGLWindow.h:175
static void pollEvents()
Definition ofAppEGLWindow.cpp:1022
void setupNativeInput()
Definition ofAppEGLWindow.cpp:1350
int buttonInUse
Mouse button currently in use.
Definition ofAppEGLWindow.h:146
void processInput(int fd, const char *node)
Definition ofAppEGLWindow.cpp:1511
ofRectangle currentWindowRect
Definition ofAppEGLWindow.h:211
void checkEvents()
std::queue< ofMouseEventArgs > mouseEvents
Definition ofAppEGLWindow.h:156
virtual ofRectangle getScreenRect()
Definition ofAppEGLWindow.cpp:1294
void draw()
Definition ofAppEGLWindow.cpp:838
bool bNewScreenMode
This indicates if a (new) window rectangle has to be adjusted.
Definition ofAppEGLWindow.h:145
virtual bool doesHWOrientation()
Definition ofAppEGLWindow.cpp:1157
Screen * x11Screen
Indicate which X11 screen is in use (currently).
Definition ofAppEGLWindow.h:249
ofImage mouseCursor
Definition ofAppEGLWindow.h:160
EGLSurface getEglSurface() const
Definition ofAppEGLWindow.cpp:284
Definition ofEvents.h:326
Definition ofWindowSettings.h:120
A class representing a 2D rectangle.
Definition ofRectangle.h:87
A threaded base class with a built in mutex for convenience.
Definition ofThread.h:70
std::map< EGLint, EGLint > ofEGLAttributeList
Definition ofAppEGLWindow.h:32
void * EGLSurface
Definition ofAppEGLWindow.h:29
struct _XIM * XIM
Definition ofAppEGLWindow.h:19
int32_t EGLint
Definition ofAppEGLWindow.h:26
void * EGLContext
Definition ofAppEGLWindow.h:30
unsigned long Window
Definition ofAppEGLWindow.h:21
std::map< EGLint, EGLint >::iterator ofEGLAttributeListIterator
Definition ofAppEGLWindow.h:33
void * EGLConfig
Definition ofAppEGLWindow.h:28
void * EGLDisplay
Definition ofAppEGLWindow.h:27
struct _XDisplay Display
Definition ofAppEGLWindow.h:23
unsigned int EGLBoolean
Definition ofAppEGLWindow.h:25
ofAppEGLWindowType
Definition ofAppEGLWindow.h:13
@ OF_APP_WINDOW_X11
Definition ofAppEGLWindow.h:16
@ OF_APP_WINDOW_AUTO
Definition ofAppEGLWindow.h:14
@ OF_APP_WINDOW_NATIVE
Definition ofAppEGLWindow.h:15
struct _XIC * XIC
Definition ofAppEGLWindow.h:20
ofOrientation
Used to represent the available screen orientations.
Definition ofWindowSettings.h:25
ofWindowMode
Used to represent the available windowing modes for the application.
Definition ofWindowSettings.h:8
Definition ofAppEGLWindow.h:35
int layer
Definition ofAppEGLWindow.h:47
ofColor initialClearColor
Definition ofAppEGLWindow.h:44
ofEGLAttributeList frameBufferAttributes
Definition ofAppEGLWindow.h:40
ofAppEGLWindowType eglWindowPreference
what window type is preferred?
Definition ofAppEGLWindow.h:37
ofAppEGLWindowSettings()
Definition ofAppEGLWindow.cpp:205
ofEGLAttributeList windowSurfaceAttributes
Definition ofAppEGLWindow.h:42
int screenNum
Definition ofAppEGLWindow.h:46
EGLint eglWindowOpacity
0-255 window alpha value
Definition ofAppEGLWindow.h:38