Visualization Library 2.0.0

A lightweight C++ OpenGL middleware for 2D/3D graphics

VL     Star     Watch     Fork     Issue

[Download] [Tutorials] [All Classes] [Grouped Classes]
EGLWindow.hpp
Go to the documentation of this file.
1 /**************************************************************************************/
2 /* */
3 /* Visualization Library */
4 /* http://visualizationlibrary.org */
5 /* */
6 /* Copyright (c) 2005-2020, Michele Bosi */
7 /* All rights reserved. */
8 /* */
9 /* Redistribution and use in source and binary forms, with or without modification, */
10 /* are permitted provided that the following conditions are met: */
11 /* */
12 /* - Redistributions of source code must retain the above copyright notice, this */
13 /* list of conditions and the following disclaimer. */
14 /* */
15 /* - Redistributions in binary form must reproduce the above copyright notice, this */
16 /* list of conditions and the following disclaimer in the documentation and/or */
17 /* other materials provided with the distribution. */
18 /* */
19 /* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND */
20 /* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED */
21 /* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE */
22 /* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR */
23 /* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES */
24 /* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; */
25 /* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON */
26 /* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT */
27 /* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS */
28 /* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
29 /* */
30 /**************************************************************************************/
31 
32 #ifndef EGL_Window_INCLUDE_ONCE
33 #define EGL_Window_INCLUDE_ONCE
34 
35 #include <vlEGL/link_config.hpp>
37 #include <EGL/egl.h>
38 #include <map>
39 
40 namespace vlEGL
41 {
42 //-----------------------------------------------------------------------------
44  VLEGL_EXPORT void peekMessage(MSG& msg);
46 //-----------------------------------------------------------------------------
47 // EGLWindow
48 //-----------------------------------------------------------------------------
53  {
54  public:
55  static const wchar_t* EGLWindowClassName;
56  static LONG WINAPI WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
57 
58  public:
59  EGLWindow();
60  ~EGLWindow();
61 
62  // *** OpenGLContext implementation ***
63 
64  void swapBuffers();
65  void makeCurrent();
66  void update();
67  void quitApplication();
68  void setMouseVisible(bool visible);
69  void setPosition(int x, int y);
70  void setSize(int w, int h);
71  void setWindowSize(int w, int h);
72  vl::ivec2 position() const;
73  vl::ivec2 windowSize() const;
74  vl::ivec2 size() const;
75  void setWindowTitle(const vl::String& title);
76  void show();
77  void hide();
78  void getFocus();
79  void setMousePosition(int x, int y);
80 
83  bool initEGLWindow(HWND parent, const vl::String& title, const vl::OpenGLContextFormat& fmt, int x=0, int y=0, int width=640, int height=480);
84 
86  void destroyEGLGLWindow();
87 
88  HWND hwnd() const { return mHWND; }
89 
91  DWORD style() const { return mStyle; }
92 
94  void setStyle(DWORD style) { mStyle = style; }
95 
97  DWORD exStyle() const { return mStyle; }
98 
100  void setExStyle(DWORD ex_style) { mStyle = ex_style; }
101 
103  const wchar_t* windowClassName() const { return mWindowClassName; }
104 
106  void setWindowClassName(const wchar_t* name) { mWindowClassName = name; }
107 
108  const EGLDisplay& eglDisplay() const { return mEGL_Display; }
109  const EGLContext& eglContext() const { return mEGL_Context; }
110  const EGLSurface& eglSurface() const { return mEGL_Surface; }
111 
112  protected:
114  HWND mHWND;
115  DWORD mStyle;
116  DWORD mExStyle;
117  const wchar_t* mWindowClassName;
118 
119  EGLDisplay mEGL_Display;
120  EGLContext mEGL_Context;
121  EGLSurface mEGL_Surface;
122 
123  // *** static members start here ***
124 
125  public:
127  static EGLWindow* getWindow(HWND hWnd);
128  static const std::map< HWND, EGLWindow* >& winMap() { return mWinMap; }
129 
130  protected:
131  static std::map< HWND, EGLWindow* > mWinMap;
132  };
133 //-----------------------------------------------------------------------------
134  VLEGL_EXPORT void translateKeyEvent(WPARAM wParam, LPARAM lParam, unsigned short& unicode_out, vl::EKey& key_out);
135 //-----------------------------------------------------------------------------
136 }
137 
138 #endif
const EGLDisplay & eglDisplay() const
Definition: EGLWindow.hpp:108
void setStyle(DWORD style)
The dwExStyle parameter passed to the EGL function CreateWindowEx.
Definition: EGLWindow.hpp:94
VLEGL_EXPORT int messageLoop()
Definition: EGLWindow.cpp:572
EGLDisplay mEGL_Display
Definition: EGLWindow.hpp:119
The String class implements an advanced UTF16 (Unicode BMP) string manipulation engine.
Definition: String.hpp:62
void setWindowClassName(const wchar_t *name)
Specifies the value given to the lpClassName parameter passed to CreateWindowEx.
Definition: EGLWindow.hpp:106
Represents an OpenGL context, possibly a widget or a pbuffer, which can also respond to keyboard...
static const std::map< HWND, EGLWindow *> & winMap()
Definition: EGLWindow.hpp:128
static std::map< HWND, EGLWindow *> mWinMap
Definition: EGLWindow.hpp:131
const wchar_t * windowClassName() const
Specifies the value given to the lpClassName parameter passed to CreateWindowEx.
Definition: EGLWindow.hpp:103
const EGLSurface & eglSurface() const
Definition: EGLWindow.hpp:110
EGLContext mEGL_Context
Definition: EGLWindow.hpp:120
DWORD style() const
The dwExStyle parameter passed to the EGL function CreateWindowEx.
Definition: EGLWindow.hpp:91
VLEGL_EXPORT void peekMessage(MSG &msg)
Definition: EGLWindow.cpp:558
const EGLContext & eglContext() const
Definition: EGLWindow.hpp:109
The OpenGLContextFormat class encapsulates the settings of an OpenGL rendering context.
EGLSurface mEGL_Surface
Definition: EGLWindow.hpp:121
VLEGL_EXPORT void translateKeyEvent(WPARAM wParam, LPARAM lParam, unsigned short &unicode_out, vl::EKey &key_out)
Definition: EGLWindow.cpp:584
The experimental EGL bindings namespace.
void setExStyle(DWORD ex_style)
The dwStyle parameter passed to the EGL function CreateWindowEx.
Definition: EGLWindow.hpp:100
The EGLWindow class is a EGLContext that can be used as a top or child window.
Definition: EGLWindow.hpp:52
const wchar_t * mWindowClassName
Definition: EGLWindow.hpp:117
static const wchar_t * EGLWindowClassName
Definition: EGLWindow.hpp:55
DWORD exStyle() const
The dwStyle parameter passed to the EGL function CreateWindowEx.
Definition: EGLWindow.hpp:97
HWND hwnd() const
Definition: EGLWindow.hpp:88
VLEGL_EXPORT void dispatchUpdate()
Definition: EGLWindow.cpp:542