H3D API  2.4.1
Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | Protected Member Functions | List of all members
H3D::GLUTWindow Class Reference

H3DWindowNode implementet using GLUT. More...

#include <H3D/GLUTWindow.h>

Inheritance diagram for H3D::GLUTWindow:
Inheritance graph

Public Member Functions

 GLUTWindow (Inst< SFInt32 > _width=0, Inst< SFInt32 > _height=0, Inst< SFBool > _fullscreen=0, Inst< SFBool > _mirrored=0, Inst< RenderMode > _renderMode=0, Inst< SFViewpoint > _viewpoint=0, Inst< SFInt32 > _posX=0, Inst< SFInt32 > _posY=0, Inst< SFBool > _manualCursorControl=0, Inst< SFString > _cursorType=0, Inst< SFString > _gameMode=0)
 Constructor.
 
 ~GLUTWindow ()
 Destructor.
 
virtual void swapBuffers ()
 Calls glutSwapBuffers.
 
virtual void initWindow ()
 Creates and initializes a GLUT window/.
 
virtual void deinitWindow ()
 Virtual function to clean up all that was created in initWindow.
 
virtual void initWindowHandler ()
 Initializes GLUT.
 
virtual void setFullscreen (bool _fullscreen)
 Sets fullscreen mode.
 
virtual void makeWindowActive ()
 Make this the current window.
 
int getGLUTWindowId ()
 Returns the GLUT window id for this window.
 
- Public Member Functions inherited from H3D::H3DWindowNode
 H3DWindowNode (Inst< SFInt32 > _width=0, Inst< SFInt32 > _height=0, Inst< SFBool > _fullscreen=0, Inst< SFBool > _mirrored=0, Inst< RenderMode > _renderMode=0, Inst< SFViewpoint > _viewpoint=0, Inst< SFInt32 > _posX=0, Inst< SFInt32 > _posY=0, Inst< SFBool > _manualCursorControl=0, Inst< SFString > _cursorType=0, Inst< SFNavigationInfo > _navigationInfo=0, Inst< SFBool > _useFullscreenAntiAliasing=0, Inst< SFVec2f > _clipDistances=0, Inst< SFBool > _singlePassStereo=0, Inst< SFString > _pointingDeviceRefreshMode=0, Inst< SFBool > _resetViewPoint=0, Inst< SFInt32 > _numSamples=0)
 Constructor.
 
 ~H3DWindowNode ()
 Destructor.
 
virtual void initialize ()
 Initialize the window node.
 
virtual void render (X3DChildNode *child_to_render)
 This function renders the X3DChildNode given into the window of the H3DWindowNode.
 
virtual void reshape (int w, int h)
 This function will be called when the window size has changed.
 
virtual void display ()
 This function is called when the window has to redraw itself.
 
virtual void onKeyDown (int key, bool special)
 This function should be called by a window when a key is pressed. More...
 
virtual void onKeyUp (int key, bool special)
 This function should be called by a window when a key is released. More...
 
virtual void onMouseButtonAction (int button, int state)
 This function should be called by a window when a mouse button is pressed or released. More...
 
virtual void onMouseMotionAction (int x, int y)
 This function should be called by a window when a mouse sends a motion event. More...
 
virtual void onMouseWheelAction (int direction)
 This function should be called by a window when a mouse wheel is scrolled either from or towards the user For values of direction see MouseSensor.h.
 
virtual void shareRenderingContext (H3DWindowNode *w)
 This function shares the rendering context between this H3DWindowNode and the one given as an argument. More...
 
 operator HWND ()
 Class Conversion Operator For Window Handle (H3DWindowNode Can Be Used As A Window Handle)
 
- Public Member Functions inherited from H3D::Node
 Node ()
 Constructor.
 
virtual Nodeclone (bool deepCopy=true, DeepCopyMap *deepCopyMap=NULL)
 Returns a new instance of this node type with the same state as this one. More...
 
virtual ~Node ()
 Destructor.
 
X3DPrototypeInstancegetProtoInstanceParent ()
 If this node is the root node in the proto body of a X3DPrototypeInstance then this will return that node. More...
 
void setProtoInstanceParent (X3DPrototypeInstance *p)
 Set the X3DPrototypeInstance this node is the the root node if applicaple.
 
virtual void render ()
 the render() function is used for the depth-first rendering traversal of the scene-graph. More...
 
virtual void traverseSG (TraverseInfo &ti)
 traverseSG is called once per scenegraph loop on the scene in order to traverse the scenegraph. More...
 
virtual bool lineIntersect (const Vec3f &from, const Vec3f &to, LineIntersectResult &result)
 Detect intersection between a line segment and the Node. More...
 
virtual void closestPoint (const Vec3f &p, NodeIntersectResult &result)
 Find closest point on Node to p. More...
 
virtual bool movingSphereIntersect (H3DFloat radius, const Vec3f &from, const Vec3f &to, NodeIntersectResult &result)
 Detect collision between a moving sphere and the Node. More...
 
virtual string defaultXMLContainerField ()
 Returns the default xml containerField attribute value. More...
 
virtual FieldgetField (const string &_name) const
 return a pointer to the field specified by name within this instance
 
int addDestructCallback (void(*func)(Node *, void *), void *args)
 Add a callback function to be run on destruction of node. More...
 
int removeDestructCallback (void(*func)(Node *, void *), void *args)
 Add a callback function to be run on destruction of node. More...
 

Static Public Member Functions

static GLUTWindowgetGLUTWindow (int glut_id)
 Given the identifier of a GLUT window the GLWindow instance that created that window is returned.
 
static void glutKeyboardDownCallback (unsigned char key, int x, int y)
 GLUT callback function for glutKeyboardFunc.
 
static void glutSpecialDownCallback (int key, int x, int y)
 GLUT callback function for glutSpecialFunc.
 
static void glutKeyboardUpCallback (unsigned char key, int x, int y)
 GLUT callback function for glutKeyboardUpFunc.
 
static void glutSpecialUpCallback (int key, int x, int y)
 GLUT callback function for glutSpecialUpFunc.
 
static void glutMouseCallback (int button, int state, int x, int y)
 glut callback function. More...
 
static void glutMotionCallback (int x, int y)
 glut callback function. Calls onMouseMotionAction
 
static void glutMouseWheelCallback (int wheel, int direction, int x, int y)
 glut callback function for mouse scroll wheel. More...
 
static void glutWMCloseCallback ()
 GLUT callback function for when window is closed.
 
static void initGLUT ()
 Initialize GLUT.
 
- Static Public Member Functions inherited from H3D::H3DWindowNode
static bool calculateFarAndNearPlane (H3DFloat &far, H3DFloat &near, X3DChildNode *child, X3DViewpointNode *vp, bool include_stylus)
 Calculate the far and near clipping planes from the bounding box of a X3DChildNode. More...
 
static string takeScreenShot (const string &url)
 
static string takeScreenshot (const string &url)
 Saves the currently rendered buffer to file. More...
 
- Static Public Member Functions inherited from H3D::Node
static unsigned int nrNodesAlive ()
 Returns the nr of nodes currently alive, i.e. nodes created but not destructed.
 
static int nrNodesCreated ()
 Returns the number of nodes created in total since the start of the program.
 

Public Attributes

H3DUniquePtr< SFStringgameMode
 Support for GLUT GameMode which is basically a string used to optimize the glut window for gaming. More...
 
- Public Attributes inherited from H3D::H3DWindowNode
H3DUniquePtr< SFInt32posX
 The x coordinate in pixels of the window in screen coordinates. More...
 
H3DUniquePtr< SFInt32posY
 The y coordinate in pixels of the window in screen coordinates. More...
 
H3DUniquePtr< SFInt32width
 The width in pixels of the window. More...
 
H3DUniquePtr< SFInt32height
 The height in pixels of the window. More...
 
H3DUniquePtr< SFBoolfullscreen
 Determines if the window should be in fullscreen or not. More...
 
H3DUniquePtr< SFBoolmirrored
 Determines if the scene rendered should be mirrored or not. More...
 
H3DUniquePtr< RenderModerenderMode
 The mode to render the scene in the window in. More...
 
H3DUniquePtr< SFViewpointviewpoint
 If the viewpoint field is specified, that viewpoint is used by the rendering in H3DWindowNode instead of the stack top of the Viewpoint bindable stack. More...
 
H3DUniquePtr< SFBoolmanualCursorControl
 If set to true changes of cursor is totally up to the user of the window by changing the cursorType. More...
 
H3DUniquePtr< SFStringcursorType
 The cursorType field specifies the look of the mouse pointer. More...
 
H3DUniquePtr< SFNavigationInfonavigationInfo
 If the navigationInfo field is specified, that NavigationInfo is used for rendering in H3DWindowNode instead of the stack top of the NavigationInfo bindable stack. More...
 
H3DUniquePtr< SFVec2fclipDistances
 The distance (in meters) used for the far and near clip plane. More...
 
H3DUniquePtr< SFBooluseFullscreenAntiAliasing
 If set to true fullscreen anti-aliasing is used for this window. More...
 
H3DUniquePtr< SFInt32viewportWidth
 The width of the viewport being used for this window Access type: outputOnly
.
 
H3DUniquePtr< SFInt32projectionWidth
 The width of the projection width, mostly of the time it is the same as the viewport width. More...
 
H3DUniquePtr< SFInt32viewportHeight
 The height of the viewport being used for this window Access type: outputOnly
.
 
H3DUniquePtr< SFInt32projectionHeight
 The height of the projection height, mostly of the time it is the same as the viewport height. More...
 
H3DUniquePtr< SFBoolsinglePassStereo
 Flag for whether singlePassStereo is enabled or not. More...
 
H3DUniquePtr< SFStringpointingDeviceRefreshMode
 Determines how often the X3DPointingDeviceSensorNode's in the scene will be checked for intersection. More...
 
H3DUniquePtr< SFBoolresetViewPoint
 Reset viewpoint Access type: inputOutput
Default value: false
.
 
H3DUniquePtr< SFInt32numSamples
 Number of samples used by this window. More...
 

Static Public Attributes

static H3DNodeDatabase database
 The H3DNodeDatabase for this node.
 
- Static Public Attributes inherited from H3D::H3DWindowNode
static H3DNodeDatabase database
 The H3DNodeDatabase for this node.
 

Protected Member Functions

virtual int setCursorType (const std::string &cursor_type)
 Set cursor shape according to given cursor mode.
 
virtual string getCursorForMode (const string &mode)
 Return the cursor type to use for given mode. More...
 
- Protected Member Functions inherited from H3D::H3DWindowNode
void initWindowWithContext ()
 internal help function to initialize the window and check if success. More...
 
LRESULT Message (HWND _hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
 Handles messages. Called by WindowProc.
 
void renderChild (X3DChildNode *child_to_render, bool render_fbo_only)
 Help function for renderChild.
 
- Protected Member Functions inherited from H3D::Node
void cloneFieldValue (Field &_from, Field &_to, bool deepCopy, DeepCopyMap &deepCopyMap)
 A helper function for the clone() method. More...
 

Additional Inherited Members

- Public Types inherited from H3D::Node
typedef std::map< Node *, Node * > DeepCopyMap
 A map type used during a deep copy clone() to map from original nodes to cloned nodes.
 
- Static Protected Member Functions inherited from H3D::H3DWindowNode
static LRESULT CALLBACK WindowProc (HWND _hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
 Whenever a subclass to H3DWindowNode is created this callback is a subclass callback. More...
 
static void setMultiPassTransparency (bool b)
 If multi pass transparency is set to true the scene will be rendered three times graphically, once for all solid objects, once for the back side of transparent objects and once for the front face of transparent objects. More...
 
- Static Protected Member Functions inherited from H3D::Node
static NodegetClonedInstance (Node *original, bool deepCopy, DeepCopyMap &deepCopyMap)
 A helper function for nodes that implement clone() More...
 
- Protected Attributes inherited from H3D::H3DWindowNode
RenderMode::Mode last_render_mode
 The render mode used in the last render loop.
 
X3DViewpointNode::EyeMode eye_mode
 Current eye mode.
 
string current_cursor
 The cursor currently in use.
 
H3DUniquePtr< WindowSizeChangedwindowSizeChanged
 Field handles necessary operations needed when window size actually changes.
 

Detailed Description

H3DWindowNode implementet using GLUT.

Valid values for the cursorType field are: "RIGHT_ARROW", "LEFT_ARROW", "INFO", "DESTROY", "HELP", "CYCLE", "SPRAYCAN", "WAIT", "TEXT", "CROSSHAIR", "UP_DOWN", "LEFT_RIGHT", "TOP_SIDE", "BOTTOM_SIDE", "LEFT_SIDE", "RIGHT_SIDE", "TOP_LEFT_CORNER", "TOP_RIGHT_CORNER", "BOTTOM_RIGHT_CORNER", "BOTTOM_LEFT_CORNER", "FULL_CROSSHAIR", "NONE", "DEFAULT"

For example usage of this class see the H3DLoad application.

Member Function Documentation

◆ getCursorForMode()

string GLUTWindow::getCursorForMode ( const string &  mode)
protectedvirtual

Return the cursor type to use for given mode.

This should be implemented for each subclass to choose appropriate cursors.

The standard events are: "DEFAULT" - normal mode ("DEFAULT") "ON_SENSOR_OVER" - when mouse pointer is over a pointing device sensor ("CROSS") "ON_SENSOR_ACTIVE" - when a sensor node is active ("NAVIGATE" ) "ON_NAV_LOOKAT" - when lookat mode is chosen

Reimplemented from H3D::H3DWindowNode.

◆ glutMouseCallback()

void GLUTWindow::glutMouseCallback ( int  button,
int  state,
int  x,
int  y 
)
static

glut callback function.

Calls onMouseButtonAction with the button and state translated to the enumerated values in KeySensor.h

References getGLUTWindow(), and H3D::H3DWindowNode::onMouseButtonAction().

◆ glutMouseWheelCallback()

void GLUTWindow::glutMouseWheelCallback ( int  wheel,
int  direction,
int  x,
int  y 
)
static

glut callback function for mouse scroll wheel.

Calls onMouseWheelAction with direction translated to the values in KeySensor.h

References getGLUTWindow(), and H3D::H3DWindowNode::onMouseWheelAction().

Member Data Documentation

◆ gameMode

H3DUniquePtr< SFString > H3D::GLUTWindow::gameMode

Support for GLUT GameMode which is basically a string used to optimize the glut window for gaming.

Some features are disabled for such things. For more information about GLUT GameMode see for example http://freeglut.sourceforge.net/docs/api.php#GameMode

Access type: initializeOnly

Referenced by initWindow(), and setFullscreen().


The documentation for this class was generated from the following files: