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]
Win32Context.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 Win32Context_INCLUDE_ONCE
33 #define Win32Context_INCLUDE_ONCE
34 
35 #include <vlWin32/link_config.hpp>
37 
38 namespace vlWin32
39 {
40 //-----------------------------------------------------------------------------
41  VLWIN32_EXPORT int choosePixelFormat(const vl::OpenGLContextFormat& fmt, bool verbose = true);
42 //-----------------------------------------------------------------------------
47  {
48  public:
49  Win32Context(): mHDC(NULL), mHGLRC(NULL) {}
50 
51  Win32Context(int w, int h): OpenGLContext(w,h), mHDC(NULL), mHGLRC(NULL) {}
52 
53  ~Win32Context();
54 
55  virtual HWND hwnd() const = 0;
56 
57  HDC hdc() const { return mHDC; }
58 
59  HGLRC hglrc() const { return mHGLRC; }
60 
66  void shareOpenGLResources(HGLRC hGLRC);
67 
68  void makeCurrent();
69 
70  void update();
71 
72  void swapBuffers();
73 
74  void setWindowTitle(const vl::String& title);
75 
76  void show();
77 
78  void hide();
79 
80  void getFocus();
81 
82  void setMouseVisible(bool visible);
83 
84  void setMousePosition(int x, int y);
85 
86  void setPosition(int x, int y);
87 
88  vl::ivec2 position() const;
89 
92  void setSize(int w, int h);
93 
95  vl::ivec2 size() const;
96 
98  void setWindowSize(int w, int h);
99 
102  vl::ivec2 windowSize() const;
103 
104  bool setFullscreen(bool fullscreen_on);
105 
107  void quitApplication();
108 
111  const std::vector<int>& contextAttribs() const { return mContextAttribs; }
112 
115  std::vector<int>& contextAttribs() { return mContextAttribs; }
116 
119  void setContextAttribs(const int* attribs, int size);
120 
121  protected:
122  bool initWin32GLContext(HGLRC share_context, const vl::String& title, const vl::OpenGLContextFormat& fmt, int x, int y, int width, int height);
123 
124  protected:
125  std::vector<int> mContextAttribs;
126 
127  HDC mHDC;
128  HGLRC mHGLRC;
129 
132  unsigned int mNormFlags;
133  };
134 }
135 //-----------------------------------------------------------------------------
136 
137 #endif
The String class implements an advanced UTF16 (Unicode BMP) string manipulation engine.
Definition: String.hpp:62
Represents an OpenGL context, possibly a widget or a pbuffer, which can also respond to keyboard...
std::vector< int > mContextAttribs
The OpenGLContextFormat class encapsulates the settings of an OpenGL rendering context.
VLWIN32_EXPORT int choosePixelFormat(const vl::OpenGLContextFormat &fmt, bool verbose=true)
The Win32Context class implements an OpenGLContext using the Win32 API.
#define NULL
Definition: OpenGLDefs.hpp:81
const std::vector< int > & contextAttribs() const
Context attributes used when creating an OpenGL 3.x / 4.x context.
Win32Context(int w, int h)
std::vector< int > & contextAttribs()
Context attributes used when creating an OpenGL 3.x / 4.x context.
The Win32 bindings namespace.