reference

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

ofAppGLFWWindow.h
Go to the documentation of this file.
1#pragma once
2
3#include "ofAppBaseWindow.h"
4#include "ofRectangle.h"
5#include "ofConstants.h"
6
7#if defined(TARGET_LINUX) && !defined(TARGET_RASPBERRY_PI_LEGACY)
8typedef struct _XIM * XIM;
9typedef struct _XIC * XIC;
10#endif
11
12class ofBaseApp;
13struct GLFWwindow;
14class ofCoreEvents;
15template<typename T>
16class ofPixels_;
18
19#ifdef TARGET_OPENGLES
21#else
23#endif
24public:
26
27#ifdef TARGET_OPENGLES
29 :ofGLESWindowSettings(settings){}
30#else
33#endif
34
35#ifdef TARGET_RASPBERRY_PI
36 int numSamples = 0;
37#else
38 int numSamples = 4;
39#endif
40
41 bool doubleBuffering = true;
42 int redBits = 8;
43 int greenBits = 8;
44 int blueBits = 8;
45 int alphaBits = 8;
46 int depthBits = 24;
47 int stencilBits = 0;
48 bool stereo = false;
49 bool visible = true;
50 bool iconified = false;
51 bool decorated = true;
52 bool resizable = true;
53 bool transparent = false;
54 int monitor = 0;
56 std::shared_ptr<ofAppBaseWindow> shareContextWith;
57};
58
59#ifdef TARGET_OPENGLES
61#else
63#endif
64
65public:
66
69
70 // Can't be copied, use shared_ptr
73
74 static void loop(){};
75 static bool doesLoop(){ return false; }
76 static bool allowsMultiWindow(){ return true; }
77 static bool needsPolling(){ return true; }
78 static void pollEvents();
79
80
81 // this functions are only meant to be called from inside OF don't call them from your code
83#ifdef TARGET_OPENGLES
84 void setup(const ofGLESWindowSettings & settings);
85#else
86 void setup(const ofGLWindowSettings & settings);
87#endif
88 void setup(const ofGLFWWindowSettings & settings);
89 void update();
90 void draw();
91 bool getWindowShouldClose();
92 void setWindowShouldClose();
93
94 void hideCursor();
95 void showCursor();
96
97 int getHeight();
98 int getWidth();
99
100 ofCoreEvents & events();
101 std::shared_ptr<ofBaseRenderer> & renderer();
102
103 GLFWwindow* getGLFWWindow();
104 void * getWindowContext(){return getGLFWWindow();}
105 ofGLFWWindowSettings getSettings(){ return settings; }
106
107 glm::vec2 getWindowSize();
108 glm::vec2 getScreenSize();
109 glm::vec2 getWindowPosition();
110
111 void setWindowTitle(std::string title);
112 void setWindowPosition(int x, int y);
113 void setWindowShape(int w, int h);
114
115 void setOrientation(ofOrientation orientation);
116 ofOrientation getOrientation();
117
118 ofWindowMode getWindowMode();
119
120 void setFullscreen(bool fullscreen);
121 void toggleFullscreen();
122
123 void enableSetupScreen();
124 void disableSetupScreen();
125
126 void setVerticalSync(bool bSync);
127
128 void setClipboardString(const std::string& text);
129 std::string getClipboardString();
130
131 int getPixelScreenCoordScale();
132
133 void makeCurrent();
134 void swapBuffers();
135 void startRender();
136 void finishRender();
137
138 static void listVideoModes();
139 static void listMonitors();
140 bool isWindowIconified();
141 bool isWindowActive();
142 bool isWindowResizeable();
143 void iconify(bool bIconify);
144
145 // window settings, this functions can only be called from main before calling ofSetupOpenGL
146 // TODO: remove specialized version of ofSetupOpenGL when these go away
147 OF_DEPRECATED_MSG("use ofGLFWWindowSettings to create the window instead", void setNumSamples(int samples));
148 OF_DEPRECATED_MSG("use ofGLFWWindowSettings to create the window instead", void setDoubleBuffering(bool doubleBuff));
149 OF_DEPRECATED_MSG("use ofGLFWWindowSettings to create the window instead", void setColorBits(int r, int g, int b));
150 OF_DEPRECATED_MSG("use ofGLFWWindowSettings to create the window instead", void setAlphaBits(int a));
151 OF_DEPRECATED_MSG("use ofGLFWWindowSettings to create the window instead", void setDepthBits(int depth));
152 OF_DEPRECATED_MSG("use ofGLFWWindowSettings to create the window instead", void setStencilBits(int stencil));
153 OF_DEPRECATED_MSG("use ofGLFWWindowSettings to create the window instead", void setMultiDisplayFullscreen(bool bMultiFullscreen)); //note this just enables the mode, you have to toggle fullscreen to activate it.
154
155#if defined(TARGET_LINUX) && !defined(TARGET_RASPBERRY_PI_LEGACY)
156 Display* getX11Display();
157 Window getX11Window();
158 XIC getX11XIC();
159
160 void setWindowIcon(const std::string & path);
161 void setWindowIcon(const ofPixels & iconPixels);
162#endif
163
164#if defined(TARGET_LINUX) && !defined(TARGET_OPENGLES)
165 GLXContext getGLXContext();
166#endif
167
168#if defined(TARGET_LINUX) && defined(TARGET_OPENGLES)
169 EGLDisplay getEGLDisplay();
170 EGLContext getEGLContext();
171 EGLSurface getEGLSurface();
172#endif
173
174#if defined(TARGET_OSX)
175 void * getNSGLContext();
176 void * getCocoaWindow();
177#endif
178
179#if defined(TARGET_WIN32)
180 HGLRC getWGLContext();
181 HWND getWin32Window();
182#endif
183
184private:
185 static ofAppGLFWWindow * setCurrent(GLFWwindow* windowP);
186 static void mouse_cb(GLFWwindow* windowP_, int button, int state, int mods);
187 static void motion_cb(GLFWwindow* windowP_, double x, double y);
188 static void entry_cb(GLFWwindow* windowP_, int entered);
189 static void keyboard_cb(GLFWwindow* windowP_, int key, int scancode, int action, int mods);
190 static void char_cb(GLFWwindow* windowP_, uint32_t key);
191 static void resize_cb(GLFWwindow* windowP_, int w, int h);
192 static void framebuffer_size_cb(GLFWwindow* windowP_, int w, int h);
193 static void exit_cb(GLFWwindow* windowP_);
194 static void scroll_cb(GLFWwindow* windowP_, double x, double y);
195 static void drop_cb(GLFWwindow* windowP_, int numFiles, const char** dropString);
196 static void error_cb(int errorCode, const char* errorDescription);
197
198 void close();
199
200 #if defined(TARGET_LINUX) && !defined(TARGET_RASPBERRY_PI_LEGACY)
201 XIM xim;
202 XIC xic;
203 #endif
204
205 std::unique_ptr<ofCoreEvents> coreEvents;
206 std::shared_ptr<ofBaseRenderer> currentRenderer;
207 ofGLFWWindowSettings settings;
208
209 ofWindowMode targetWindowMode;
210
211 bool bEnableSetupScreen;
212 int windowW, windowH;
213 int currentW, currentH;
214 float pixelScreenCoordScale;
215
216 ofRectangle windowRect;
217
218 int buttonInUse;
219 bool buttonPressed;
220
221 int nFramesSinceWindowResized;
222 bool bWindowNeedsShowing;
223
224 #ifdef TARGET_RASPBERRY_PI
225 bool needsResizeCheck = false;
226 #endif
227
228 GLFWwindow* windowP;
229
230 int getCurrentMonitor();
231
232 ofBaseApp * ofAppPtr;
233
234
235 ofOrientation orientation;
236
237 bool iconSet;
238
239 #ifdef TARGET_WIN32
240 LONG lExStyle, lStyle;
241 #endif // TARGET_WIN32
242};
243
244
245//#endif
Definition ofAppBaseWindow.h:117
Definition ofAppBaseWindow.h:103
virtual void setup(const ofWindowSettings &settings)=0
Definition ofAppGLFWWindow.h:62
static bool allowsMultiWindow()
Definition ofAppGLFWWindow.h:76
OF_DEPRECATED_MSG("use ofGLFWWindowSettings to create the window instead", void setNumSamples(int samples))
void * getWindowContext()
Definition ofAppGLFWWindow.h:104
OF_DEPRECATED_MSG("use ofGLFWWindowSettings to create the window instead", void setAlphaBits(int a))
ofGLFWWindowSettings getSettings()
Definition ofAppGLFWWindow.h:105
static void loop()
Definition ofAppGLFWWindow.h:74
ofAppGLFWWindow & operator=(ofAppGLFWWindow &w)=delete
OF_DEPRECATED_MSG("use ofGLFWWindowSettings to create the window instead", void setDepthBits(int depth))
OF_DEPRECATED_MSG("use ofGLFWWindowSettings to create the window instead", void setMultiDisplayFullscreen(bool bMultiFullscreen))
OF_DEPRECATED_MSG("use ofGLFWWindowSettings to create the window instead", void setStencilBits(int stencil))
static bool doesLoop()
Definition ofAppGLFWWindow.h:75
static bool needsPolling()
Definition ofAppGLFWWindow.h:77
OF_DEPRECATED_MSG("use ofGLFWWindowSettings to create the window instead", void setDoubleBuffering(bool doubleBuff))
OF_DEPRECATED_MSG("use ofGLFWWindowSettings to create the window instead", void setColorBits(int r, int g, int b))
ofAppGLFWWindow(ofAppGLFWWindow &w)=delete
Definition ofBaseApp.h:14
Definition ofEvents.h:326
Definition ofWindowSettings.h:120
Definition ofAppGLFWWindow.h:22
int monitor
Definition ofAppGLFWWindow.h:54
bool stereo
Definition ofAppGLFWWindow.h:48
int depthBits
Definition ofAppGLFWWindow.h:46
int redBits
Definition ofAppGLFWWindow.h:42
bool doubleBuffering
Definition ofAppGLFWWindow.h:41
int stencilBits
Definition ofAppGLFWWindow.h:47
int greenBits
Definition ofAppGLFWWindow.h:43
bool iconified
Definition ofAppGLFWWindow.h:50
ofGLFWWindowSettings()
Definition ofAppGLFWWindow.h:25
bool multiMonitorFullScreen
Definition ofAppGLFWWindow.h:55
ofGLFWWindowSettings(const ofGLWindowSettings &settings)
Definition ofAppGLFWWindow.h:31
bool decorated
Definition ofAppGLFWWindow.h:51
bool resizable
Definition ofAppGLFWWindow.h:52
bool visible
Definition ofAppGLFWWindow.h:49
int blueBits
Definition ofAppGLFWWindow.h:44
bool transparent
Definition ofAppGLFWWindow.h:53
int numSamples
Definition ofAppGLFWWindow.h:38
int alphaBits
Definition ofAppGLFWWindow.h:45
std::shared_ptr< ofAppBaseWindow > shareContextWith
Definition ofAppGLFWWindow.h:56
Definition ofWindowSettings.h:92
A class representing a collection of pixels.
Definition ofPixels.h:170
A class representing a 2D rectangle.
Definition ofRectangle.h:87
void * EGLSurface
Definition ofAppEGLWindow.h:29
struct _XIM * XIM
Definition ofAppEGLWindow.h:19
void * EGLContext
Definition ofAppEGLWindow.h:30
unsigned long Window
Definition ofAppEGLWindow.h:21
void * EGLDisplay
Definition ofAppEGLWindow.h:27
struct _XDisplay Display
Definition ofAppEGLWindow.h:23
struct _XIC * XIC
Definition ofAppEGLWindow.h:20
ofPixels_< unsigned char > ofPixels
Definition ofAppGLFWWindow.h:17
#define a
#define b
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