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
00262 void useSpecificFBOForSnapshot( int FBOId );
00263
00266
00267
00268 bool saveSnapshot( const SbString& filename, bool override = true );
00269
00270
00271 void setDrawToFrontBuffer( SbBool enable );
00272 SbBool getDrawToFrontBuffer() const;
00273
00274
00275 void setOverlayColorMap( unsigned long overlayColorMap );
00276 unsigned long getOverlayColorMap() const;
00277
00278
00279 void setColorMap( unsigned long colorMap );
00280 unsigned long getColorMap() const;
00281
00282
00283
00284
00285
00286
00287
00288 void setGlxSize( SbVec2s newSize );
00289 const SbVec2s& getGlxSize() const;
00290
00291 SbBool isStereoBuffer();
00292
00293
00294 SbBool isRGBMode();
00295
00296
00297 void setGraphicConfigTemplate( SoGLGraphicConfigTemplate* gc );
00298 SoGLGraphicConfigTemplate* getGraphicConfigTemplate();
00299
00300
00301 void setGLWidgetHandle( const void* glWidgetHandle,
00302 soGUIDependentCB swapBufferCB,
00303 soGUIDependentCB bindCurrentCB,
00304 soGUIDependentCB unbindCurrentCB,
00305 soGUIWindowDependentCB getNormalCB,
00306 soGUIWindowDependentCB getDisplayCB = NULL);
00307
00308
00309
00310
00311 static soGUIDependentCB swapNormalBuffersCB;
00312 static soGUIDependentCB bindNormalCurrentCB;
00313 static soGUIDependentCB unbindNormalCurrentCB;
00314 static soGUIWindowDependentCB getNormalWindowCB;
00315 static soGUIWindowDependentCB getCurrentDisplayCB;
00316 void * m_glWidgetHandle;
00317
00318 virtual void* getNormalWindow() { return getNormalWindowCB(m_glWidgetHandle); }
00319 virtual void* getDisplay() { return getCurrentDisplayCB(m_glWidgetHandle); }
00320
00321 virtual SbBool bindNormalContext();
00322 virtual SbBool unbindNormalContext();
00323
00324 bool onAntialiasingSwitch(const SoSceneManager::AntialiasingMode& mode, const float& quality, const SoAntialiasingParameters* parameters);
00325
00326 #if 1 SoDEPRECATED
00329 SbBool isFsaaEnabled() const;
00330 SoDEPRECATED
00335 SbBool isFsaaSupported();
00336 SoDEPRECATED
00341 SbBool isFsaaSupportHighQuality();
00342 SoDEPRECATED
00344 SbBool setFsaaHighQuality( SbBool enable );
00345 SoDEPRECATED
00347 SbBool isFsaaHighQuality();
00348 SoDEPRECATED
00350 int getFsaaMaxSamplesCount() const;
00351
00352 #endif
00354 #if 1 SoDEPRECATED
00375 SbBool setFullSceneAntialiasing( SbBool enable,
00376 float quality = -1.f,
00377 int filterMask = SoFullSceneAntialiasing::ALL );
00378 SoDEPRECATED
00383 SbBool isFullSceneAntialiasingEnabled() const;
00384 SoDEPRECATED
00390 SbBool getFullSceneAntialiasing( float& quality, int& filterMask ) const;
00391 SoDEPRECATED
00396 SbBool isFullSceneAntialiasingAvailable();
00397 SoDEPRECATED
00404 SbBool isFullSceneAntialiasingHQAvailable();
00405 SoDEPRECATED
00412 SbBool setFullSceneAntialiasingHQ( SbBool enable );
00413 SoDEPRECATED
00418 SbBool isFullSceneAntialiasingHQEnabled() const;
00419 SoDEPRECATED
00424 int getFullSceneAntialiasingMaxSamples() const;
00425
00426 #endif
00428 private:
00429
00433 virtual ~SoGuiGLWidget();
00434
00435 static SbBool m_hasFloatBuffer;
00436
00437 SiAntialiasingEventListener* getAntialiasingListener() const;
00438
00439
00440
00441
00442 private:
00443
00444
00445 SoAntialiasingParameters* m_fsaaParameters;
00446
00447
00448 SbVec2s m_glxSize;
00449 int m_glModes;
00450 int m_borderSize;
00451
00452 SoGLFormat m_format;
00453 FormatChangeCallback m_formatChangeCallback;
00454 void* m_formatChangeCallbackUserData;
00455
00456 unsigned long m_colorMap;
00457 unsigned long m_overlayColorMap;
00458 int m_colorMapSize;
00459 int m_overlayColorMapSize;
00460
00461 SbBool m_drawToFrontBuffer;
00462 SbBool m_enableDrawToFrontBuffer;
00463
00464 unsigned long m_transparentPixel;
00465
00466 bool m_isRemoteRendering;
00467
00468 int m_snapshotFBOId;
00469
00470 SbBool m_isFloatingPointRendering;
00471 FloatColorBufferSize m_floatingPointRenderingPrecision;
00472
00473 SoGLGraphicConfigTemplate* m_gcTemplate;
00474
00475 SiAntialiasingEventListener* m_antialiasingListener;
00476 };
00477
00478
00479 #endif // SO_GUI_GL_WIDGET_H
00480
00481
00482