H3D API  2.4.1
GLUTWindow.h
Go to the documentation of this file.
1 // Copyright 2004-2019, SenseGraphics AB
3 //
4 // This file is part of H3D API.
5 //
6 // H3D API is free software; you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published by
8 // the Free Software Foundation; either version 2 of the License, or
9 // (at your option) any later version.
10 //
11 // H3D API is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
15 //
16 // You should have received a copy of the GNU General Public License
17 // along with H3D API; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 //
20 // A commercial license is also available. Please contact us at
21 // www.sensegraphics.com for more information.
22 //
23 //
27 //
29 #ifndef __GLUTWINDOW_H__
30 #define __GLUTWINDOW_H__
31 
32 #include <H3D/H3DWindowNode.h>
33 #include <H3D/Scene.h>
34 #ifdef HAVE_GLUT
35 
36 namespace H3D {
37 
51  class H3DAPI_API GLUTWindow : public H3DWindowNode {
52  public:
53 
55  GLUTWindow( Inst< SFInt32 > _width = 0,
56  Inst< SFInt32 > _height = 0,
57  Inst< SFBool > _fullscreen = 0,
58  Inst< SFBool > _mirrored = 0,
59  Inst< RenderMode > _renderMode = 0,
60  Inst< SFViewpoint > _viewpoint = 0,
61  Inst< SFInt32 > _posX = 0,
62  Inst< SFInt32 > _posY = 0,
63  Inst< SFBool > _manualCursorControl = 0,
64  Inst< SFString > _cursorType = 0,
65  Inst< SFString > _gameMode = 0 );
66 
68  ~GLUTWindow();
69 
71  virtual void swapBuffers();
72 
74  virtual void initWindow();
75 
77  virtual void deinitWindow();
78 
80  virtual void initWindowHandler() { initGLUT(); }
81 
83  virtual void setFullscreen( bool _fullscreen );
84 
86  virtual void makeWindowActive();
87 
90  static GLUTWindow * getGLUTWindow( int glut_id );
91 
94  return window_id;
95  }
96 
98  static void glutKeyboardDownCallback( unsigned char key,
99  int x, int y );
100 
102  static void glutSpecialDownCallback( int key,
103  int x, int y );
104 
106  static void glutKeyboardUpCallback( unsigned char key,
107  int x, int y );
108 
110  static void glutSpecialUpCallback( int key,
111  int x, int y );
112 
115  static void glutMouseCallback( int button, int state,
116  int x, int y );
117 
119  static void glutMotionCallback( int x, int y );
120 
124  static void glutMouseWheelCallback( int wheel,
125  int direction, int x, int y );
126 
127 
129  static void glutWMCloseCallback();
130 
132  static void initGLUT();
133 
140  H3DUniquePtr< SFString > gameMode;
141 
144 
145  protected:
147  virtual int setCursorType( const std::string & cursor_type );
148 
158  virtual string getCursorForMode( const string &mode );
159 
160  static bool GLUT_init;
161  int window_id;
162 
163  // Define these even though they are not used for when we use FREEGLUT.
164  bool last_fullscreen;
165  int last_x_pos, last_y_pos, last_width, last_height;
166  };
167 }
168 #endif // HAVE_GLUT
169 #endif
Header file for H3DWindowNode.
Header file for Scene.
H3DWindowNode implementet using GLUT.
Definition: GLUTWindow.h:51
virtual void initWindowHandler()
Initializes GLUT.
Definition: GLUTWindow.h:80
static H3DNodeDatabase database
The H3DNodeDatabase for this node.
Definition: GLUTWindow.h:143
int getGLUTWindowId()
Returns the GLUT window id for this window.
Definition: GLUTWindow.h:93
H3DUniquePtr< SFString > gameMode
Support for GLUT GameMode which is basically a string used to optimize the glut window for gaming.
Definition: GLUTWindow.h:140
The base class for all window nodes.
Definition: H3DWindowNode.h:57
H3DDouble x
H3D API namespace.
Definition: Anchor.h:38
The H3DNodeDatabase contains a mapping between a name of a Node and the constructor for the Node with...
Definition: H3DNodeDatabase.h:194