DART  6.10.1
Window.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2011-2021, The DART development contributors
3  * All rights reserved.
4  *
5  * The list of contributors can be found at:
6  * https://github.com/dartsim/dart/blob/master/LICENSE
7  *
8  * This file is provided under the following "BSD-style" License:
9  * Redistribution and use in source and binary forms, with or
10  * without modification, are permitted provided that the following
11  * conditions are met:
12  * * Redistributions of source code must retain the above copyright
13  * notice, this list of conditions and the following disclaimer.
14  * * Redistributions in binary form must reproduce the above
15  * copyright notice, this list of conditions and the following
16  * disclaimer in the documentation and/or other materials provided
17  * with the distribution.
18  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
19  * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
20  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
21  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
23  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
26  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
27  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
29  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30  * POSSIBILITY OF SUCH DAMAGE.
31  */
32 
33 #ifndef DART_GUI_GLUT_WINDOW_HPP_
34 #define DART_GUI_GLUT_WINDOW_HPP_
35 
36 #include <vector>
37 
38 #include "dart/gui/LoadOpengl.hpp"
40 
41 namespace dart {
42 namespace gui {
43 namespace glut {
44 
46 class Window
47 {
48 public:
49  Window();
50  virtual ~Window();
51 
53  virtual void initWindow(int _w, int _h, const char* _name);
54 
55  // callback functions
56  static void reshape(int _w, int _h);
57  static void keyEvent(unsigned char _key, int _x, int _y);
58  static void specKeyEvent(int _key, int _x, int _y);
59  static void mouseClick(int _button, int _state, int _x, int _y);
60  static void mouseDrag(int _x, int _y);
61  static void mouseMove(int _x, int _y);
62  static void refresh();
63  static void refreshTimer(int _val);
64  static void runTimer(int _val);
65 
66  static Window* current();
67  static std::vector<Window*> mWindows;
68  static std::vector<int> mWinIDs;
69 
70 protected:
71  // callback implementation
72  virtual void resize(int _w, int _h) = 0;
73  virtual void render() = 0;
74  virtual void keyboard(unsigned char _key, int _x, int _y);
75  virtual void specKey(int _key, int _x, int _y);
76  virtual void click(int _button, int _state, int _x, int _y);
77  virtual void drag(int _x, int _y);
78  virtual void move(int _x, int _y);
79  virtual void displayTimer(int _val);
80  virtual void simTimer(int _val);
81 
82  virtual bool screenshot();
83 
84  int mWinWidth;
86  int mMouseX;
87  int mMouseY;
89  bool mMouseDown;
90  bool mMouseDrag;
91  bool mCapture;
92  double mBackground[4];
94  std::vector<unsigned char> mScreenshotTemp;
95  std::vector<unsigned char> mScreenshotTemp2;
96 };
97 
98 } // namespace glut
99 } // namespace gui
100 } // namespace dart
101 
102 #endif // DART_GUI_GLUT_WINDOW_HPP_
Definition: RenderInterface.hpp:71
Definition: Window.hpp:47
virtual void move(int _x, int _y)
Definition: GlutWindow.cpp:287
static void refresh()
Definition: GlutWindow.cpp:153
std::vector< unsigned char > mScreenshotTemp2
Definition: Window.hpp:95
static void mouseClick(int _button, int _state, int _x, int _y)
Definition: GlutWindow.cpp:138
std::vector< unsigned char > mScreenshotTemp
Definition: Window.hpp:94
gui::RenderInterface * mRI
Definition: Window.hpp:93
virtual ~Window()
Definition: GlutWindow.cpp:79
virtual void resize(int _w, int _h)=0
static void specKeyEvent(int _key, int _x, int _y)
Definition: GlutWindow.cpp:133
static void keyEvent(unsigned char _key, int _x, int _y)
Definition: GlutWindow.cpp:128
virtual void specKey(int _key, int _x, int _y)
Definition: GlutWindow.cpp:275
virtual bool screenshot()
Definition: GlutWindow.cpp:178
static std::vector< Window * > mWindows
Definition: Window.hpp:67
static Window * current()
Definition: GlutWindow.cpp:256
int mMouseY
Definition: Window.hpp:87
static void runTimer(int _val)
Definition: GlutWindow.cpp:173
int mMouseX
Definition: Window.hpp:86
static void mouseDrag(int _x, int _y)
Definition: GlutWindow.cpp:143
virtual void render()=0
virtual void drag(int _x, int _y)
Definition: GlutWindow.cpp:283
static void refreshTimer(int _val)
Definition: GlutWindow.cpp:158
int mWinWidth
Definition: Window.hpp:84
static void reshape(int _w, int _h)
Definition: GlutWindow.cpp:121
virtual void displayTimer(int _val)
Definition: GlutWindow.cpp:163
virtual void click(int _button, int _state, int _x, int _y)
Definition: GlutWindow.cpp:279
int mWinHeight
Definition: Window.hpp:85
virtual void initWindow(int _w, int _h, const char *_name)
Definition: GlutWindow.cpp:84
Window()
Definition: GlutWindow.cpp:62
double mBackground[4]
Definition: Window.hpp:92
static std::vector< int > mWinIDs
Definition: Window.hpp:68
virtual void keyboard(unsigned char _key, int _x, int _y)
Definition: GlutWindow.cpp:270
double mDisplayTimeout
Definition: Window.hpp:88
bool mMouseDrag
Definition: Window.hpp:90
virtual void simTimer(int _val)
Definition: GlutWindow.cpp:169
bool mCapture
Definition: Window.hpp:91
bool mMouseDown
Definition: Window.hpp:89
static void mouseMove(int _x, int _y)
Definition: GlutWindow.cpp:148
Definition: BulletCollisionDetector.cpp:65