00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef SO_GUI_GL_WIDGET_H
00025 #define SO_GUI_GL_WIDGET_H
00026
00028
00029
00030
00031
00032
00033
00035
00036 #include <Inventor/antialiasing/SiAntialiasingEventListener.h>
00037 #include <Inventor/Gui/SoGuiComponent.h>
00038 #include <Inventor/fields/SoSFInt32.h>
00039 #include <Inventor/fields/SoSFFloat.h>
00040 #include <Inventor/devices/SoGLFormat.h>
00041 #include <Inventor/nodes/SoFullSceneAntialiasing.h>
00042 #include <Inventor/image/SbRasterImage.h>
00043
00044 class SoGLGraphicConfigTemplate;
00045
00046 #ifndef HIDDEN_FROM_DOC
00047 typedef SbBool (*soGUIDependentCB)(void* data);
00048 typedef void* (*soGUIWindowDependentCB)(void* data);
00049 #endif
00050
00051
00052 class SoGuiGLWidget : public SoGuiComponent
00053 {
00054 #ifndef HIDDEN_FROM_DOC
00055 SO_FIELDCONTAINER_HEADER( SoGuiGLWidget );
00056 #endif
00057
00058 private:
00059
00060 SoSFFieldContainer gcTemplate;
00061 SoSFBool focus;
00062
00063 enum FloatColorBufferSize
00064 {
00068 FLOAT_16_COLOR_BUFFER = 0,
00072 FLOAT_32_COLOR_BUFFER = 1
00073 };
00074
00078 SoGuiGLWidget();
00079
00083 void setAntialiasing(const float quality, const SoSceneManager::AntialiasingMode mode = SoSceneManager::AUTO);
00084
00088 void setAntialiasing(SoAntialiasingParameters* advancedParameters);
00089
00093 float getAntialiasingQuality() const;
00094
00098 SoSceneManager::AntialiasingMode getAntialiasingMode() const;
00099
00103 SoAntialiasingParameters* getAntialiasingParameters() const;
00104
00108 void setColorMapSize( int size );
00109
00113 int getColorMapSize();
00114
00118 SbBool isDoubleBuffer();
00119
00124 void setBorder( int newValue );
00125
00129 int getBorderSize();
00130
00134 SbBool isBorder() const;
00135
00140 void setDrawToFrontBufferEnable( SbBool enableFlag );
00141
00145 SbBool isDrawToFrontBufferEnable() const;
00146
00160 void setFloatingColorBuffer( SbBool enable, FloatColorBufferSize size = FLOAT_16_COLOR_BUFFER );
00161
00166 void getFloatingColorBuffer( SbBool& enable, FloatColorBufferSize& size );
00167
00171 static SbBool isFloatingColorBufferSupported();
00172
00178 void setGLModes( int mode );
00179
00183 int getGLModes() const;
00184
00192 SbBool setGLFormat( const SoGLFormat& format );
00193
00197 const SoGLFormat& getGLFormat() const;
00198
00204 typedef SbBool (*FormatChangeCallback)( SoGLFormat&, void* userData );
00205
00210 void setOnFormatChangeCalback( FormatChangeCallback callback, void* userData = NULL );
00211
00219 virtual SbBool setDoubleBuffer( SbBool enable );
00220
00224 void setRemoteRendering( bool enable );
00225
00229 bool isRemoteRendering() const;
00230
00235 SbBool setStereoEnabled( SbBool enable );
00236
00240 SbBool isStereoEnabled() const;
00241
00244
00245
00246 bool saveSnapshot( const SbString& filename, bool override = true );
00247
00248
00249 void setDrawToFrontBuffer( SbBool enable );
00250 SbBool getDrawToFrontBuffer() const;
00251
00252
00253 void setColorMap( unsigned long colorMap );
00254 unsigned long getColorMap() const;
00255
00256
00257
00258
00259
00260
00261
00262 void setGlxSize( SbVec2s newSize );
00263 const SbVec2s& getGlxSize() const;
00264
00265 SbBool isStereoBuffer();
00266
00267
00268 SbBool isRGBMode();
00269
00270
00271 void setGraphicConfigTemplate( SoGLGraphicConfigTemplate* gc );
00272 SoGLGraphicConfigTemplate* getGraphicConfigTemplate();
00273
00274
00275 void setGLWidgetHandle( const void* glWidgetHandle,
00276 soGUIDependentCB swapBufferCB,
00277 soGUIDependentCB bindCurrentCB,
00278 soGUIDependentCB unbindCurrentCB,
00279 soGUIWindowDependentCB getNormalCB,
00280 soGUIWindowDependentCB getDisplayCB = NULL);
00281
00282
00283
00284
00285 static soGUIDependentCB swapNormalBuffersCB;
00286 static soGUIDependentCB bindNormalCurrentCB;
00287 static soGUIDependentCB unbindNormalCurrentCB;
00288 static soGUIWindowDependentCB getNormalWindowCB;
00289 static soGUIWindowDependentCB getCurrentDisplayCB;
00290 void * m_glWidgetHandle;
00291
00292 virtual void* getNormalWindow() { return getNormalWindowCB(m_glWidgetHandle); }
00293 virtual void* getDisplay() { return getCurrentDisplayCB(m_glWidgetHandle); }
00294
00295 virtual SbBool bindNormalContext();
00296 virtual SbBool unbindNormalContext();
00297
00298 bool onAntialiasingSwitch(const SoSceneManager::AntialiasingMode& mode, const float& quality, const SoAntialiasingParameters* parameters);
00299
00300
00301
00302 private:
00303
00307 virtual ~SoGuiGLWidget();
00308
00309 static SbBool m_hasFloatBuffer;
00310
00311 SiAntialiasingEventListener* getAntialiasingListener() const;
00312
00313
00314
00315 private:
00316
00317
00318 SoAntialiasingParameters* m_fsaaParameters;
00319
00320
00321 SbVec2s m_glxSize;
00322 int m_glModes;
00323 int m_borderSize;
00324
00325 SoGLFormat m_format;
00326 FormatChangeCallback m_formatChangeCallback;
00327 void* m_formatChangeCallbackUserData;
00328
00329 unsigned long m_colorMap;
00330 int m_colorMapSize;
00331
00332 SbBool m_drawToFrontBuffer;
00333 SbBool m_enableDrawToFrontBuffer;
00334
00335 unsigned long m_transparentPixel;
00336
00337 bool m_isRemoteRendering;
00338
00339 int m_snapshotFBOId;
00340
00341 SbBool m_isFloatingPointRendering;
00342 FloatColorBufferSize m_floatingPointRenderingPrecision;
00343
00344 SoGLGraphicConfigTemplate* m_gcTemplate;
00345
00346 SiAntialiasingEventListener* m_antialiasingListener;
00347 };
00348
00349
00350 #endif // SO_GUI_GL_WIDGET_H
00351
00352
00353