DART  6.7.3
Window.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2011-2019, 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 public:
48  Window();
49  virtual ~Window();
50 
52  virtual void initWindow(int _w, int _h, const char* _name);
53 
54  // callback functions
55  static void reshape(int _w, int _h);
56  static void keyEvent(unsigned char _key, int _x, int _y);
57  static void specKeyEvent(int _key, int _x, int _y);
58  static void mouseClick(int _button, int _state, int _x, int _y);
59  static void mouseDrag(int _x, int _y);
60  static void mouseMove(int _x, int _y);
61  static void refresh();
62  static void refreshTimer(int _val);
63  static void runTimer(int _val);
64 
65  static Window* current();
66  static std::vector<Window*> mWindows;
67  static std::vector<int> mWinIDs;
68 
69 protected:
70  // callback implementation
71  virtual void resize(int _w, int _h) = 0;
72  virtual void render() = 0;
73  virtual void keyboard(unsigned char _key, int _x, int _y);
74  virtual void specKey(int _key, int _x, int _y);
75  virtual void click(int _button, int _state, int _x, int _y);
76  virtual void drag(int _x, int _y);
77  virtual void move(int _x, int _y);
78  virtual void displayTimer(int _val);
79  virtual void simTimer(int _val);
80 
81  virtual bool screenshot();
82 
83  int mWinWidth;
85  int mMouseX;
86  int mMouseY;
88  bool mMouseDown;
89  bool mMouseDrag;
90  bool mCapture;
91  double mBackground[4];
93  std::vector<unsigned char> mScreenshotTemp;
94  std::vector<unsigned char> mScreenshotTemp2;
95 };
96 
97 } // namespace glut
98 } // namespace gui
99 } // namespace dart
100 
101 #endif // DART_GUI_GLUT_WINDOW_HPP_
Definition: RenderInterface.hpp:67
Definition: Window.hpp:46
virtual void move(int _x, int _y)
Definition: GlutWindow.cpp:246
static void refresh()
Definition: GlutWindow.cpp:143
std::vector< unsigned char > mScreenshotTemp2
Definition: Window.hpp:94
static void mouseClick(int _button, int _state, int _x, int _y)
Definition: GlutWindow.cpp:131
std::vector< unsigned char > mScreenshotTemp
Definition: Window.hpp:93
gui::RenderInterface * mRI
Definition: Window.hpp:92
virtual ~Window()
Definition: GlutWindow.cpp:78
virtual void resize(int _w, int _h)=0
static void specKeyEvent(int _key, int _x, int _y)
Definition: GlutWindow.cpp:127
static void keyEvent(unsigned char _key, int _x, int _y)
Definition: GlutWindow.cpp:123
virtual void specKey(int _key, int _x, int _y)
Definition: GlutWindow.cpp:237
virtual bool screenshot()
Definition: GlutWindow.cpp:163
static std::vector< Window * > mWindows
Definition: Window.hpp:66
static Window * current()
Definition: GlutWindow.cpp:222
int mMouseY
Definition: Window.hpp:86
static void runTimer(int _val)
Definition: GlutWindow.cpp:159
int mMouseX
Definition: Window.hpp:85
static void mouseDrag(int _x, int _y)
Definition: GlutWindow.cpp:135
virtual void render()=0
virtual void drag(int _x, int _y)
Definition: GlutWindow.cpp:243
static void refreshTimer(int _val)
Definition: GlutWindow.cpp:147
int mWinWidth
Definition: Window.hpp:83
static void reshape(int _w, int _h)
Definition: GlutWindow.cpp:117
virtual void displayTimer(int _val)
Definition: GlutWindow.cpp:151
virtual void click(int _button, int _state, int _x, int _y)
Definition: GlutWindow.cpp:240
int mWinHeight
Definition: Window.hpp:84
virtual void initWindow(int _w, int _h, const char *_name)
Definition: GlutWindow.cpp:82
Window()
Definition: GlutWindow.cpp:62
double mBackground[4]
Definition: Window.hpp:91
static std::vector< int > mWinIDs
Definition: Window.hpp:67
virtual void keyboard(unsigned char _key, int _x, int _y)
Definition: GlutWindow.cpp:233
double mDisplayTimeout
Definition: Window.hpp:87
bool mMouseDrag
Definition: Window.hpp:89
virtual void simTimer(int _val)
Definition: GlutWindow.cpp:156
bool mCapture
Definition: Window.hpp:90
bool mMouseDown
Definition: Window.hpp:88
static void mouseMove(int _x, int _y)
Definition: GlutWindow.cpp:139
Definition: BulletCollisionDetector.cpp:63