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]
WXGLCanvas.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 vlWXGLCanvas_INCLUDE_ONCE
33 #define vlWXGLCanvas_INCLUDE_ONCE
34 
35 #include <vlWX/link_config.hpp>
37 #include <vlCore/Time.hpp>
38 #include <wx/frame.h>
39 #include <wx/glcanvas.h>
40 #include <wx/timer.h>
41 #include <wx/dcclient.h>
42 #include <wx/image.h>
43 #include <wx/app.h>
44 
45 #if !wxUSE_GLCANVAS
46  #error "OpenGL required: set wxUSE_GLCANVAS to 1 and rebuild the library"
47 #endif
48 
49 namespace vlWX
50 {
52  class VLWX_EXPORT WXGLCanvas: public wxGLCanvas, public vl::OpenGLContext
53  {
54  public:
55  WXGLCanvas( wxWindow *parent,
56  const wxGLContext *shared,
57  wxWindowID id = wxID_ANY,
58  const wxPoint& pos = wxDefaultPosition,
59  const wxSize& size = wxDefaultSize,
60  long style = 0,
61  int *attribList = 0,
62  const wxString& name = wxT("WXGLCanvas"),
63  const wxPalette& palette = wxNullPalette );
64 
65  ~WXGLCanvas();
66 
67  void OnPaint(wxPaintEvent& ev);
68  void OnSize(wxSizeEvent& ev);
69  void OnEraseBackground(wxEraseEvent& ev);
70  void OnKeyDown(wxKeyEvent& ev);
71  void OnKeyUp(wxKeyEvent& ev);
72  /*void OnChar(wxKeyEvent& ev);*/
73  void OnMouseMotion(wxMouseEvent &ev);
74  void OnMouseDown(wxMouseEvent &ev);
75  void OnMouseUp(wxMouseEvent &ev);
76  void OnMouseWheel( wxMouseEvent& ev );
77  void OnMouseEnter(wxMouseEvent& ev);
78  void OnIdle(wxIdleEvent& ev);
79  void OnDropFiles(wxDropFilesEvent& ev);
80 
81  bool setFullscreen(bool fullscreen);
82  void quitApplication();
83  void makeCurrent();
84  void swapBuffers();
85  void getFocus();
86  void setMousePosition(int x, int y);
87  void update();
88  void setWindowTitle(const vl::String& text);
89  void show();
90  void hide();
91  void setPosition(int x, int y);
92  void setSize(int w, int h);
93  vl::ivec2 position() const;
94  void setMouseVisible(bool visible);
95 
96  private:
97  wxCursor mCursor;
98  int mMouseCount;
99  DECLARE_EVENT_TABLE()
100  };
101 }
102 
103 #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...
The wxWidgets bindings namespace.
The WXGLCanvas class implements a vl::OpenGLContext using the wxWidgets library.
Definition: WXGLCanvas.hpp:52