Visualization Library 2.1.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(
56  wxWindow* parent,
57  wxWindowID id = wxID_ANY,
58  const int *attribList = NULL,
59  const wxPoint& pos = wxDefaultPosition,
60  const wxSize& size = wxDefaultSize,
61  long style = 0,
62  const wxString& name = wxT("WXGLCanvas"),
63  const wxPalette& palette = wxNullPalette
64  );
65 
66  ~WXGLCanvas();
67 
68  void OnPaint(wxPaintEvent& ev);
69  void OnSize(wxSizeEvent& ev);
70  void OnEraseBackground(wxEraseEvent& ev);
71  void OnKeyDown(wxKeyEvent& ev);
72  void OnKeyUp(wxKeyEvent& ev);
73  /*void OnChar(wxKeyEvent& ev);*/
74  void OnMouseMotion(wxMouseEvent &ev);
75  void OnMouseDown(wxMouseEvent &ev);
76  void OnMouseUp(wxMouseEvent &ev);
77  void OnMouseWheel( wxMouseEvent& ev );
78  void OnMouseEnter(wxMouseEvent& ev);
79  void OnIdle(wxIdleEvent& ev);
80  void OnDropFiles(wxDropFilesEvent& ev);
81 
82  bool setFullscreen(bool fullscreen);
83  void quitApplication();
84  void makeCurrent();
85  void swapBuffers();
86  void getFocus();
87  void setMousePosition(int x, int y);
88  void update();
89  void setWindowTitle(const vl::String& text);
90  void show();
91  void hide();
92  void setPosition(int x, int y);
93  void setSize(int w, int h);
94  vl::ivec2 position() const;
95  vl::ivec2 size() const;
96  void setMouseVisible(bool visible);
97 
98  const wxGLContext* getWXGLContext() const { return mWXGLContext; }
99  wxGLContext* getWXGLContext() { return mWXGLContext; }
100  void setWXGLContext( wxGLContext* c ) { mWXGLContext = c; }
101 
102  private:
103  wxCursor mCursor;
104  int mMouseCount;
105  wxGLContext* mWXGLContext;
106  DECLARE_EVENT_TABLE()
107  };
108 }
109 
110 #endif
wxGLContext * getWXGLContext()
Definition: WXGLCanvas.hpp:99
The String class implements an advanced UTF16 (Unicode BMP) string manipulation engine.
Definition: String.hpp:62
void setWXGLContext(wxGLContext *c)
Definition: WXGLCanvas.hpp:100
Represents an OpenGL context, possibly a widget or a pbuffer, which can also respond to keyboard...
#define NULL
Definition: OpenGLDefs.hpp:81
The wxWidgets bindings namespace.
The WXGLCanvas class implements a vl::OpenGLContext using the wxWidgets library.
Definition: WXGLCanvas.hpp:52
const wxGLContext * getWXGLContext() const
Definition: WXGLCanvas.hpp:98