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 unsigned long getOverlayTransparentPixel();
00109
00113 void setOverlayTransparentPixel( unsigned long pixel );
00114
00118 void setOverlayColorMapSize( int size );
00119
00123 int getOverlayColorMapSize();
00124
00128 void setColorMapSize( int size );
00129
00133 int getColorMapSize();
00134
00138 SbBool isDoubleBuffer();
00139
00144 void setBorder( int newValue );
00145
00149 int getBorderSize();
00150
00154 SbBool isBorder() const;
00155
00160 void setDrawToFrontBufferEnable( SbBool enableFlag );
00161
00165 SbBool isDrawToFrontBufferEnable() const;
00166
00180 void setFloatingColorBuffer( SbBool enable, FloatColorBufferSize size = FLOAT_16_COLOR_BUFFER );
00181
00186 void getFloatingColorBuffer( SbBool& enable, FloatColorBufferSize& size );
00187
00191 static SbBool isFloatingColorBufferSupported();
00192
00198 void setGLModes( int mode );
00199
00203 int getGLModes() const;
00204
00212 SbBool setGLFormat( const SoGLFormat& format );
00213
00217 const SoGLFormat& getGLFormat() const;
00218
00224 typedef SbBool (*FormatChangeCallback)( SoGLFormat&, void* userData );
00225
00230 void setOnFormatChangeCalback( FormatChangeCallback callback, void* userData = NULL );
00231
00239 SbBool setDoubleBuffer( SbBool enable );
00240
00244 void setRemoteRendering( bool enable );
00245
00249 bool isRemoteRendering() const;
00250
00255 SbBool setStereoEnabled( SbBool enable );
00256
00260 SbBool isStereoEnabled() const;
00261
00264
00265
00266 bool saveSnapshot( const SbString& filename, bool override = true );
00267
00268
00269 void setDrawToFrontBuffer( SbBool enable );
00270 SbBool getDrawToFrontBuffer() const;
00271
00272
00273 void setOverlayColorMap( unsigned long overlayColorMap );
00274 unsigned long getOverlayColorMap() const;
00275
00276
00277 void setColorMap( unsigned long colorMap );
00278 unsigned long getColorMap() const;
00279
00280
00281
00282
00283
00284
00285
00286 void setGlxSize( SbVec2s newSize );
00287 const SbVec2s& getGlxSize() const;
00288
00289 SbBool isStereoBuffer();
00290
00291
00292 SbBool isRGBMode();
00293
00294
00295 void setGraphicConfigTemplate( SoGLGraphicConfigTemplate* gc );
00296 SoGLGraphicConfigTemplate* getGraphicConfigTemplate();
00297
00298
00299 void setGLWidgetHandle( const void* glWidgetHandle,
00300 soGUIDependentCB swapBufferCB,
00301 soGUIDependentCB bindCurrentCB,
00302 soGUIDependentCB unbindCurrentCB,
00303 soGUIWindowDependentCB getNormalCB,
00304 soGUIWindowDependentCB getDisplayCB = NULL);
00305
00306
00307
00308
00309 static soGUIDependentCB swapNormalBuffersCB;
00310 static soGUIDependentCB bindNormalCurrentCB;
00311 static soGUIDependentCB unbindNormalCurrentCB;
00312 static soGUIWindowDependentCB getNormalWindowCB;
00313 static soGUIWindowDependentCB getCurrentDisplayCB;
00314 void * m_glWidgetHandle;
00315
00316 virtual void* getNormalWindow() { return getNormalWindowCB(m_glWidgetHandle); }
00317 virtual void* getDisplay() { return getCurrentDisplayCB(m_glWidgetHandle); }
00318
00319 virtual SbBool bindNormalContext();
00320 virtual SbBool unbindNormalContext();
00321
00322 bool onAntialiasingSwitch(const SoSceneManager::AntialiasingMode& mode, const float& quality, const SoAntialiasingParameters* parameters);
00323
00324 #if 1 SoDEPRECATED
00327 SbBool isFsaaEnabled() const;
00328 SoDEPRECATED
00333 SbBool isFsaaSupported();
00334 SoDEPRECATED
00339 SbBool isFsaaSupportHighQuality();
00340 SoDEPRECATED
00342 SbBool setFsaaHighQuality( SbBool enable );
00343 SoDEPRECATED
00345 SbBool isFsaaHighQuality();
00346 SoDEPRECATED
00348 int getFsaaMaxSamplesCount() const;
00349
00350 #endif
00352 #if 1 SoDEPRECATED
00373 SbBool setFullSceneAntialiasing( SbBool enable,
00374 float quality = -1.f,
00375 int filterMask = SoFullSceneAntialiasing::ALL );
00376 SoDEPRECATED
00381 SbBool isFullSceneAntialiasingEnabled() const;
00382 SoDEPRECATED
00388 SbBool getFullSceneAntialiasing( float& quality, int& filterMask ) const;
00389 SoDEPRECATED
00394 SbBool isFullSceneAntialiasingAvailable();
00395 SoDEPRECATED
00402 SbBool isFullSceneAntialiasingHQAvailable();
00403 SoDEPRECATED
00410 SbBool setFullSceneAntialiasingHQ( SbBool enable );
00411 SoDEPRECATED
00416 SbBool isFullSceneAntialiasingHQEnabled() const;
00417 SoDEPRECATED
00422 int getFullSceneAntialiasingMaxSamples() const;
00423
00424 #endif
00426 private:
00427
00431 virtual ~SoGuiGLWidget();
00432
00433 static SbBool m_hasFloatBuffer;
00434
00435 SiAntialiasingEventListener* getAntialiasingListener() const;
00436
00437
00438
00439
00440 private:
00441
00442
00443 SoAntialiasingParameters* m_fsaaParameters;
00444
00445
00446 SbVec2s m_glxSize;
00447 int m_glModes;
00448 int m_borderSize;
00449
00450 SoGLFormat m_format;
00451 FormatChangeCallback m_formatChangeCallback;
00452 void* m_formatChangeCallbackUserData;
00453
00454 unsigned long m_colorMap;
00455 unsigned long m_overlayColorMap;
00456 int m_colorMapSize;
00457 int m_overlayColorMapSize;
00458
00459 SbBool m_drawToFrontBuffer;
00460 SbBool m_enableDrawToFrontBuffer;
00461
00462 unsigned long m_transparentPixel;
00463
00464 bool m_isRemoteRendering;
00465
00466 int m_snapshotFBOId;
00467
00468 SbBool m_isFloatingPointRendering;
00469 FloatColorBufferSize m_floatingPointRenderingPrecision;
00470
00471 SoGLGraphicConfigTemplate* m_gcTemplate;
00472
00473 SiAntialiasingEventListener* m_antialiasingListener;
00474 };
00475
00476
00477 #endif // SO_GUI_GL_WIDGET_H
00478
00479
00480