00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00027
00029 #ifndef __H3DWINDOWNODE_H__
00030 #define __H3DWINDOWNODE_H__
00031
00032 #include "Viewpoint.h"
00033 #include "MFNode.h"
00034 #include "SFInt32.h"
00035 #include "DefaultAppearance.h"
00036
00037 namespace H3D {
00038
00049 class H3DAPI_API H3DWindowNode : public Node {
00050 public:
00051
00052 typedef TypedSFNode< Viewpoint > SFViewpoint;
00053
00055 class RenderMode: public SFString {
00056 public:
00058 H3D_VALUE_EXCEPTION( string, InvalidRenderMode );
00060 typedef enum {
00062 MONO,
00065 QUAD_BUFFERED_STEREO,
00068 HORIZONTAL_SPLIT,
00071 VERTICAL_SPLIT,
00074 HORIZONTAL_INTERLACED,
00077 VERTICAL_INTERLACED,
00082 VERTICAL_INTERLACED_GREEN_SHIFT,
00085 RED_BLUE_STEREO,
00088 RED_CYAN_STEREO
00089 } Mode;
00090
00092 inline bool isStereoMode() {
00093 upToDate();
00094 return value != "MONO";
00095 }
00096
00099 RenderMode::Mode getRenderMode();
00100 };
00101
00103 H3DWindowNode( Inst< SFInt32 > _width = 0,
00104 Inst< SFInt32 > _height = 0,
00105 Inst< SFBool > _fullscreen = 0,
00106 Inst< SFBool > _mirrored = 0,
00107 Inst< RenderMode > _renderMode = 0,
00108 Inst< SFViewpoint > _viewpoint = 0,
00109 Inst< SFTime > _time = 0 );
00110
00112 ~H3DWindowNode();
00113
00115 virtual void swapBuffers() = 0;
00116
00119 virtual void initWindow() = 0;
00120
00122 virtual void initWindowHandler() = 0;
00123
00125 virtual void setFullscreen( bool fullscreen ) = 0;
00126
00129 virtual void makeWindowActive() = 0;
00130
00132 virtual void initialize();
00133
00136 virtual void render( X3DChildNode *child_to_render );
00137
00139 virtual void reshape( int w, int h );
00140
00142 virtual void display();
00143
00158 bool calculateFarAndNearPlane( H3DFloat &far,
00159 H3DFloat &near,
00160 X3DChildNode *child,
00161 Viewpoint *vp,
00162 bool include_stylus );
00163
00168 auto_ptr< SFInt32 > width;
00169
00174 auto_ptr< SFInt32 > height;
00175
00180 auto_ptr< SFBool > fullscreen;
00181
00186 auto_ptr< SFBool > mirrored;
00187
00195 auto_ptr< RenderMode > renderMode;
00196
00204 auto_ptr< SFViewpoint > viewpoint;
00205
00206 auto_ptr< SFTime > time;
00207 static set< H3DWindowNode* > windows;
00208
00215 void shareRenderingContext( H3DWindowNode *w );
00216
00217 #if WIN32
00218 HGLRC getRenderingContext() {
00219 return rendering_context;
00220 }
00221 #endif
00222
00223 static H3DNodeDatabase database;
00224
00225 protected:
00226 #if WIN32
00227 HGLRC rendering_context;
00228 #endif
00229 X3DChildNode *last_render_child;
00230 static bool GLEW_init;
00231 int window_id;
00232 bool rebuild_stencil_mask;
00233 unsigned char *stencil_mask;
00234 unsigned int stencil_mask_height;
00235 unsigned int stencil_mask_width;
00236 };
00237 }
00238
00239 #endif