59 initGLFWWindow(title, info, width, height);
70 GLFWmonitor* monitor = glfwGetPrimaryMonitor();
71 const GLFWvidmode* mode = glfwGetVideoMode( monitor );
73 glfwWindowHint( GLFW_RED_BITS, info.
rgbaBits().
r() ? info.
rgbaBits().
r() : mode->redBits );
74 glfwWindowHint( GLFW_GREEN_BITS, info.
rgbaBits().
g() ? info.
rgbaBits().
g() : mode->greenBits );
75 glfwWindowHint( GLFW_BLUE_BITS, info.
rgbaBits().
b() ? info.
rgbaBits().
b() : mode->blueBits );
76 glfwWindowHint( GLFW_ALPHA_BITS, info.
rgbaBits().
a() ? info.
rgbaBits().
a() : GLFW_DONT_CARE );
85 glfwWindowHint( GLFW_AUX_BUFFERS, GLFW_DONT_CARE );
87 glfwWindowHint( GLFW_STEREO, info.
stereo() );
91 glfwWindowHint( GLFW_SRGB_CAPABLE, GLFW_DONT_CARE );
93 glfwWindowHint( GLFW_DOUBLEBUFFER, info.
doubleBuffer() );
95 glfwWindowHint( GLFW_REFRESH_RATE, mode->refreshRate );
97 glfwWindowHint( GLFW_CLIENT_API, GLFW_OPENGL_API );
109 glfwWindowHint( GLFW_OPENGL_PROFILE, GLFW_OPENGL_COMPAT_PROFILE );
112 glfwWindowHint( GLFW_CONTEXT_VERSION_MAJOR, info.
majVersion() );
113 glfwWindowHint( GLFW_CONTEXT_VERSION_MINOR, info.
minVersion() );
118 glfwWindowHint( GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE );
121 glfwWindowHint( GLFW_CONTEXT_VERSION_MAJOR, info.
majVersion() );
122 glfwWindowHint( GLFW_CONTEXT_VERSION_MINOR, info.
minVersion() );
126 glfwWindowHint( GLFW_OPENGL_PROFILE, GLFW_OPENGL_ANY_PROFILE );
133 height = mode->height;
138 mHandle = glfwCreateWindow(width, height, title.
toStdString().c_str(), monitor, share);
146 mWinMap[ mHandle ] =
this;
149 glfwMakeContextCurrent( mHandle );
157 dispatchResizeEvent( width, height );
159 glfwSetWindowSizeCallback( mHandle, glfw_size_callback );
160 glfwSetWindowPosCallback( mHandle, glfw_pos_callback );
161 glfwSetWindowRefreshCallback( mHandle, glfw_refresh_callback );
162 glfwSetWindowCloseCallback( mHandle, glfw_close_callback );
163 glfwSetWindowFocusCallback( mHandle, glfw_focus_callback );
164 glfwSetWindowIconifyCallback( mHandle, glfw_iconify_callback );
166 glfwSetKeyCallback( mHandle, glfw_key_callback );
167 glfwSetCharCallback( mHandle, glfw_unicode_callback );
168 glfwSetCursorEnterCallback( mHandle, glfw_cursor_enter_callback );
169 glfwSetCursorPosCallback( mHandle, glfw_cursor_pos_callback );
170 glfwSetMouseButtonCallback( mHandle, glfw_mouse_button_callback );
171 glfwSetScrollCallback( mHandle, glfw_scroll_callback );
172 glfwSetDropCallback( mHandle, glfw_drop_callback );
181 dispatchDestroyEvent();
182 glfwDestroyWindow( mHandle );
183 mWinMap.erase( mHandle );
192 glfwMakeContextCurrent( mHandle );
197 dispatchUpdateEvent();
203 glfwSwapBuffers( mHandle );
209 WinMapType::iterator it = mWinMap.find( window );
218 WinMapType::iterator it = mWinMap.find( window );
228 WinMapType::iterator it = mWinMap.find( window );
237 if ( glfwWindowShouldClose( window ) ) {
238 WinMapType::iterator it = mWinMap.find( window );
248 WinMapType::iterator it = mWinMap.find( window );
258 WinMapType::iterator it = mWinMap.find( window );
267 WinMapType::iterator it = mWinMap.find( window );
288 WinMapType::iterator it = mWinMap.find( window );
301 WinMapType::iterator it = mWinMap.find( window );
310 WinMapType::iterator it = mWinMap.find( window );
321 WinMapType::iterator it = mWinMap.find( window );
327 case GLFW_MOUSE_BUTTON_LEFT:
330 case GLFW_MOUSE_BUTTON_MIDDLE:
333 case GLFW_MOUSE_BUTTON_RIGHT:
338 double dx = 0, dy = 0;
339 glfwGetCursorPos( window, &dx, &dy );
343 if (action == GLFW_PRESS)
346 if (action == GLFW_RELEASE)
353 WinMapType::iterator it = mWinMap.find( window );
364 WinMapType::iterator it = mWinMap.find( window );
367 std::vector<String> files;
368 for(
int i=0; i<count; ++i) {
369 files.push_back( df[ i ] );
380 GLFWmonitor* monitor = glfwGetPrimaryMonitor();
381 const GLFWvidmode* mode = glfwGetVideoMode( monitor );
386 int r = GLFW_DONT_CARE;
392 r = mode->refreshRate;
396 glfwSetWindowMonitor( mHandle, monitor, x, y, w, h, r );
410 glfwSetWindowTitle( mHandle, title.
toStdString().c_str() );
418 glfwSetWindowPos( mHandle, x, y );
426 glfwSetWindowSize( mHandle, w, h );
435 glfwGetWindowPos( mHandle, &x, &y );
445 glfwGetWindowSize( mHandle, &w, &h );
454 glfwShowWindow( mHandle );
462 glfwHideWindow( mHandle );
470 glfwFocusWindow( mHandle );
478 glfwSetInputMode( mHandle, GLFW_CURSOR, visible ? GLFW_CURSOR_NORMAL : GLFW_CURSOR_DISABLED );
486 glfwSetCursorPos( mHandle, x, y );
void dispatchKeyReleaseEvent(unsigned short unicode_ch, EKey key)
Dispatches the UIEventListener::keyReleaseEvent() notification to the subscribed UIEventListener obje...
Vector2< int > ivec2
A 2 components vector with int precision.
void show()
If the OpenGL context is a widget this function makes it visible to the user.
int stencilBufferBits() const
void setMouseVisible(bool visible)
If the OpenGL context is a widget this function sets whether the mouse is visible over it or not...
void hide()
If the OpenGL context is a widget this function makes it invisible to the user.
void dispatchMouseDownEvent(EMouseButton button, int x, int y)
Dispatches the UIEventListener::mouseDownEvent() notification to the subscribed UIEventListener objec...
static void glfw_mouse_button_callback(GLFWwindow *, int, int, int)
static void glfw_focus_callback(GLFWwindow *window, int)
The String class implements an advanced UTF16 (Unicode BMP) string manipulation engine.
int multisampleSamples() const
const T_Scalar & r() const
static void glfw_unicode_callback(GLFWwindow *, unsigned int)
unsigned short mUnicodeChar
The GLFW bindings namespace.
The GLFWWindow class implements an OpenGLContext using the GLFW API.
void dispatchVisibilityEvent(bool visible)
Dispatches the UIEventListener::visibilityEvent() notification to the subscribed UIEventListener obje...
static void glfw_key_callback(GLFWwindow *window, int key, int scancode, int action, int mods)
static void glfw_size_callback(GLFWwindow *window, int w, int h)
void dispatchKeyPressEvent(unsigned short unicode_ch, EKey key)
Dispatches the UIEventListener::keyPressEvent() notification to the subscribed UIEventListener object...
void dispatchResizeEvent(int w, int h)
Dispatches the UIEventListener::resizeEvent() notification to the subscribed UIEventListener objects...
bool setFullscreen(bool fs)
If the OpenGL context is a widget this function requests a maximization to fullscreen.
static void glfw_pos_callback(GLFWwindow *window, int x, int y)
void swapBuffers()
Swaps the back and front buffers to present the last rendering.
Visualization Library main namespace.
void setWindowTitle(const vl::String &title)
If the OpenGL context is a top window this function sets its title.
void translateKey(int &unicode, EKey &key, const wxKeyEvent &ev)
std::map< ::GLFWwindow *, vlGLFW::GLFWWindow *> WinMapType
static void glfw_iconify_callback(GLFWwindow *window, int)
const T_Scalar & g() const
void dispatchUpdateEvent()
Dispatches the UIEventListener::updateEvent() notification to the subscribed UIEventListener objects...
The OpenGLContextFormat class encapsulates the settings of an OpenGL rendering context.
static WinMapType mWinMap
const ivec4 & rgbaBits() const
void getFocus()
If the OpenGL context is a widget this function requests the mouse focus on it.
const ivec4 & accumRGBABits() const
static void glfw_refresh_callback(GLFWwindow *window)
static void glfw_close_callback(GLFWwindow *window)
static vl::EKey translateKey(int key, int scancode, int mods)
void setPosition(int x, int y)
If the OpenGL context is a widget this function sets its position.
bool initGLFWWindow(const vl::String &title, const vl::OpenGLContextFormat &info, int width, int height, GLFWwindow *share=NULL)
Initializes and shows a GLFW window.
const T_Scalar & b() const
void dispatchMouseWheelEvent(int n)
Dispatches the UIEventListener::mouseWheelEvent() notification to the subscribed UIEventListener obje...
static void glfw_cursor_pos_callback(GLFWwindow *, double, double)
void setSize(int w, int h)
If the OpenGL context is a widget this function sets its size.
EOpenGLProfile openGLProfile() const
static void glfw_scroll_callback(GLFWwindow *, double, double)
void dispatchFileDroppedEvent(const std::vector< String > &files)
Dispatches the UIEventListener::fileDroppedEvent() notification to the subscribed UIEventListener obj...
static void glfw_drop_callback(GLFWwindow *, int, const char **)
int depthBufferBits() const
void dispatchMouseMoveEvent(int x, int y)
Dispatches the UIEventListener::mouseMoveEvent() notification to the subscribed UIEventListener objec...
std::string toStdString() const
Returns a UTF8 encoded std::string.
vl::ivec2 position() const
If the OpenGL context is a widget this function returns its position.
void makeCurrent()
Sets the OpenGL context as current for the calling thread.
static void glfw_cursor_enter_callback(GLFWwindow *, int)
void setMousePosition(int x, int y)
If the OpenGL context is a widget this function sets the mouse position.
bool doubleBuffer() const
void update()
If the OpenGLContext is a widget this function requests a redraw and generates an updateEvent()...
const T_Scalar & a() const
void dispatchMouseUpEvent(EMouseButton button, int x, int y)
Dispatches the UIEventListener::mouseUpEvent() notification to the subscribed UIEventListener objects...