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
00242 void useSpecificFBOForSnapshot( int FBOId );
00243
00246
00247
00248 bool saveSnapshot( const SbString& filename, bool override = true );
00249
00250
00251 void setDrawToFrontBuffer( SbBool enable );
00252 SbBool getDrawToFrontBuffer() const;
00253
00254
00255 void setColorMap( unsigned long colorMap );
00256 unsigned long getColorMap() const;
00257
00258
00259
00260
00261
00262
00263
00264 void setGlxSize( SbVec2s newSize );
00265 const SbVec2s& getGlxSize() const;
00266
00267 SbBool isStereoBuffer();
00268
00269
00270 SbBool isRGBMode();
00271
00272
00273 void setGraphicConfigTemplate( SoGLGraphicConfigTemplate* gc );
00274 SoGLGraphicConfigTemplate* getGraphicConfigTemplate();
00275
00276
00277 void setGLWidgetHandle( const void* glWidgetHandle,
00278 soGUIDependentCB swapBufferCB,
00279 soGUIDependentCB bindCurrentCB,
00280 soGUIDependentCB unbindCurrentCB,
00281 soGUIWindowDependentCB getNormalCB,
00282 soGUIWindowDependentCB getDisplayCB = NULL);
00283
00284
00285
00286
00287 static soGUIDependentCB swapNormalBuffersCB;
00288 static soGUIDependentCB bindNormalCurrentCB;
00289 static soGUIDependentCB unbindNormalCurrentCB;
00290 static soGUIWindowDependentCB getNormalWindowCB;
00291 static soGUIWindowDependentCB getCurrentDisplayCB;
00292 void * m_glWidgetHandle;
00293
00294 virtual void* getNormalWindow() { return getNormalWindowCB(m_glWidgetHandle); }
00295 virtual void* getDisplay() { return getCurrentDisplayCB(m_glWidgetHandle); }
00296
00297 virtual SbBool bindNormalContext();
00298 virtual SbBool unbindNormalContext();
00299
00300 bool onAntialiasingSwitch(const SoSceneManager::AntialiasingMode& mode, const float& quality, const SoAntialiasingParameters* parameters);
00301
00302 #if 1 SoDEPRECATED
00305 SbBool isFsaaEnabled() const;
00306 SoDEPRECATED
00311 SbBool isFsaaSupported();
00312 SoDEPRECATED
00314 SbBool isFsaaSupportHighQuality();
00315 SoDEPRECATED
00317 SbBool setFsaaHighQuality( SbBool enable );
00318 SoDEPRECATED
00320 SbBool isFsaaHighQuality();
00321 SoDEPRECATED
00323 int getFsaaMaxSamplesCount() const;
00324
00325 #endif
00327 #if 1 SoDEPRECATED
00348 SbBool setFullSceneAntialiasing( SbBool enable,
00349 float quality = -1.f,
00350 int filterMask = SoFullSceneAntialiasing::ALL );
00351 SoDEPRECATED
00356 SbBool isFullSceneAntialiasingEnabled() const;
00357 SoDEPRECATED
00363 SbBool getFullSceneAntialiasing( float& quality, int& filterMask ) const;
00364 SoDEPRECATED
00369 SbBool isFullSceneAntialiasingAvailable();
00370 SoDEPRECATED
00376 SbBool isFullSceneAntialiasingHQAvailable();
00377 SoDEPRECATED
00383 SbBool setFullSceneAntialiasingHQ( SbBool enable );
00384 SoDEPRECATED
00389 SbBool isFullSceneAntialiasingHQEnabled() const;
00390 SoDEPRECATED
00395 int getFullSceneAntialiasingMaxSamples() const;
00396
00397 #endif
00399 private:
00400
00404 virtual ~SoGuiGLWidget();
00405
00406 static SbBool m_hasFloatBuffer;
00407
00408 SiAntialiasingEventListener* getAntialiasingListener() const;
00409
00410
00411
00412
00413 private:
00414
00415
00416 SoAntialiasingParameters* m_fsaaParameters;
00417
00418
00419 SbVec2s m_glxSize;
00420 int m_glModes;
00421 int m_borderSize;
00422
00423 SoGLFormat m_format;
00424 FormatChangeCallback m_formatChangeCallback;
00425 void* m_formatChangeCallbackUserData;
00426
00427 unsigned long m_colorMap;
00428 int m_colorMapSize;
00429
00430 SbBool m_drawToFrontBuffer;
00431 SbBool m_enableDrawToFrontBuffer;
00432
00433 unsigned long m_transparentPixel;
00434
00435 bool m_isRemoteRendering;
00436
00437 int m_snapshotFBOId;
00438
00439 SbBool m_isFloatingPointRendering;
00440 FloatColorBufferSize m_floatingPointRenderingPrecision;
00441
00442 SoGLGraphicConfigTemplate* m_gcTemplate;
00443
00444 SiAntialiasingEventListener* m_antialiasingListener;
00445 };
00446
00447
00448 #endif // SO_GUI_GL_WIDGET_H
00449
00450
00451