00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #ifndef _SO_WIN_GL_WIDGET_H_
00027 #define _SO_WIN_GL_WIDGET_H_
00028
00029
00030 #include <Inventor/Win/SoWinBeginStrict.h>
00031
00032 #include <Inventor/Win/SoWinComponent.h>
00033 #include <Inventor/components/SoGLGraphicConfigTemplate.h>
00034 #include <Inventor/components/SoGLGraphicDevice.h>
00035 #include <Inventor/components/SoGLGraphicConfig.h>
00036
00037 #include <Inventor/devices/SoGLContext.h>
00038
00039 #include <Inventor/nodes/SoFullSceneAntialiasing.h>
00040
00041 #include <Inventor/Gui/SoGuiGLWidget.h>
00042
00043 #ifdef _WIN32
00044 #pragma warning(push)
00045 #pragma warning(disable:4251)
00046 #endif
00047
00048 class SoAntialiasingParameters;
00049
00051
00052
00053
00054
00056
00079 class SoWinGLWidget : public SoWinComponent
00080 {
00081 public:
00082
00084 enum FloatColorBufferSize
00085 {
00089 FLOAT_16_COLOR_BUFFER = SoGuiGLWidget::FLOAT_16_COLOR_BUFFER,
00093 FLOAT_32_COLOR_BUFFER = SoGuiGLWidget::FLOAT_32_COLOR_BUFFER
00094 };
00095
00104 virtual Window getNormalWindow();
00105
00114 GLXContext getNormalContext() { return m_contextNormal->getGLContext(); }
00115
00116 virtual SoGLContext* getNormalSoContext() { return m_contextNormal.ptr(); }
00117
00121 Hdc getNormalDC() const;
00122
00123 #ifndef HIDDEN_FROM_DOC
00124
00125 Hdc copyWindowBits() ;
00126 #endif // HIDDEN_FROM_DOC
00127
00135 void setStealFocus( SbBool onOrOff ) { stealFocus = onOrOff; };
00136
00145 SoWidget getNormalWidget() const;
00146
00155 virtual void setNormalVisual( XVisualInfo* vis );
00156
00160 XVisualInfo* getNormalVisual();
00161
00174 virtual void setPixelFormat( int format );
00175
00181 int getPixelFormat();
00182
00186 void setAntialiasing(const float quality, const SoSceneManager::AntialiasingMode mode = SoSceneManager::AUTO);
00187
00191 void setAntialiasing(SoAntialiasingParameters* advancedParameters);
00192
00196 float getAntialiasingQuality() const;
00197
00201 SoSceneManager::AntialiasingMode getAntialiasingMode() const;
00202
00206 SoAntialiasingParameters* getAntialiasingParameters() const;
00207
00213 void setDoubleBuffer( SbBool onOrOff );
00214
00218 SbBool isDoubleBuffer() { return m_guiGLWidget->isDoubleBuffer(); }
00219
00223 void setBorder( SbBool onOrOff );
00224
00228 int getBorderSize() { return m_guiGLWidget->getBorderSize(); }
00229
00233 SbBool isBorder() const { return m_guiGLWidget->isBorder(); }
00234
00239 void setDrawToFrontBufferEnable( SbBool enableFlag );
00240
00244 SbBool isDrawToFrontBufferEnable() const { return m_guiGLWidget->isDrawToFrontBufferEnable(); }
00245
00254 void setCursor( Cursor newCursor );
00255
00260 Cursor getCursor();
00261
00266 virtual SbBool bindNormalContext();
00267
00271 virtual SbBool unbindNormalContext();
00272
00273
00277 virtual SbBool swapNormalBuffers();
00278
00282 SoGLGraphicConfigTemplate* getGraphicConfigTemplate();
00283
00287 void setGraphicConfigTemplate( SoGLGraphicConfigTemplate* gTemplate );
00288
00302 virtual void setFloatingColorBuffer( SbBool enable,
00303 FloatColorBufferSize size = FLOAT_16_COLOR_BUFFER );
00304
00308 virtual void getFloatingColorBuffer( SbBool& enable, FloatColorBufferSize& size );
00309
00335 bool saveSnapshot( const SbString& filename, bool overwrite = true );
00336
00337 #if 1 SoDEPRECATED
00340 SbBool isFsaaSupported();
00341 SoDEPRECATED
00346 virtual SbBool makeNormalCurrent();
00347
00348 #endif
00350 #if 1 SoDEPRECATED
00373 SbBool setFullSceneAntialiasing( SbBool enable,
00374 float quality = -1.0,
00375 int filterMask = SoFullSceneAntialiasing::ALL );
00376 SoDEPRECATED
00381 SbBool isFullSceneAntialiasingEnabled() const;
00382 SoDEPRECATED
00387 SbBool getFullSceneAntialiasing( float& quality );
00388 SoDEPRECATED
00393 SbBool isFullSceneAntialiasingAvailable() const;
00394 SoDEPRECATED
00399 SbBool isFullSceneAntialiasingHQAvailable() const;
00400 SoDEPRECATED
00405 SbBool setFullSceneAntialiasingHQ( SbBool enable );
00406 SoDEPRECATED
00411 SbBool isFullSceneAntialiasingHQEnabled() const;
00412
00413 #endif
00415 private:
00416
00417
00418
00419
00420
00421
00422
00423 void flush();
00424
00425 private:
00426
00427 SoGuiGLWidget* getGuiGLWidget() const;
00428
00429
00430 void syncFromCurrentConfig();
00431
00432 void syncToCurrentConfigTemplate( PIXELFORMATDESCRIPTOR* newPFD );
00433
00434 SbBool currentGraphicConfigTemplateIsUsed;
00435 SoGLGraphicConfigTemplate currentGraphicConfigTemplate;
00436
00437
00438 SoGLGraphicDevice* getGraphicDevice();
00439
00440
00441 SoGLGraphicConfig* getGraphicConfig();
00442
00443 virtual void posChanged( const SbVec2i32&, const SbVec2i32& );
00444
00445
00446
00447 SbBool drawToFrontBuffer;
00448 SbBool m_isFloatingPointRendering;
00449 FloatColorBufferSize m_floatingPointRenderingPrecision;
00450
00451
00452
00453 static SbBool swapNormalBuffersCB(void *data);
00454 static SbBool bindNormalCurrentCB(void *data);
00455 static SbBool unbindNormalCurrentCB(void *data);
00456 static void* getNormalWindowCB(void *data);
00457
00458 private:
00459
00460
00461
00462
00463
00464
00465
00466 void updateCurrentDeviceAndConfig( HDC hdc );
00467
00468 SbBool currentGraphicConfigIsUsed;
00469 SoGLGraphicConfig* currentGraphicConfig;
00470 SbBool currentGraphicDeviceIsUsed;
00471 SoGLGraphicDevice* currentGraphicDevice;
00472
00473
00474
00475
00476
00477 SoWinGLWidget( SoWidget parent = NULL,
00478 const char* name = NULL,
00479 SbBool buildInsideParent = TRUE,
00480 int glModes = SO_GLX_RGB,
00481 SbBool buildNow = TRUE,
00482 SbBool sync = TRUE );
00483
00484 SoWinGLWidget( SoWidget parent,
00485 const char* name,
00486 SbBool buildInsideParent,
00487 int glModes,
00488 SbBool buildNow,
00489 SbBool sync,
00490 SoGuiGLWidget* guiGLWidget );
00491
00492 virtual ~SoWinGLWidget();
00493
00494
00495 virtual void redraw() = 0;
00496 virtual void processEvent( XAnyEvent* anyevent );
00497
00498
00499
00500
00501
00502
00503 virtual void initGraphic();
00504 virtual void sizeChanged( const SbVec2s& newSize );
00505 virtual void widgetChanged( SoWidget newWidget );
00506
00507
00508
00509
00510
00511 void setGlxSize( SbVec2s newSize );
00512 const SbVec2s& getGlxSize() const { return m_guiGLWidget->getGlxSize(); }
00513
00514
00515
00516 static void eventHandler( SoWidget w, SoWinGLWidget* p, XAnyEvent* e, Boolean* b );
00517
00518
00519
00520
00521 void setStereoBuffer( SbBool flag );
00522 SbBool isStereoBuffer() const;
00523
00524
00525 SbBool isRGBMode() const;
00526
00527
00528 int getDisplayListShareGroup( SoGLContext* ctx );
00529
00530
00531 Colormap getColorMap() const
00532 { return m_guiGLWidget->getColorMap(); }
00533
00534
00535 SbBool waitForExpose;
00536
00537
00538
00539 SoWidget buildWidget( SoWidget parent );
00540 SoWidget getGlxMgrWidget() { return mgrWidget; }
00541
00542
00543
00544
00545
00546 void changeCursor( Cursor newCursor );
00547
00548
00549 DWORD getThreadId() { return dwThreadId; };
00550 void setThreadId( DWORD id ) { dwThreadId=id; };
00551
00553
00554 virtual void onExpose();
00555
00556 void destroyNormalWindows(SbBool normalCall=TRUE);
00557
00558 private:
00559
00560 void constructorCommon( int glModes, SbBool buildNow, SoWidget parent );
00561
00562 static SbBool onGLFormatChangeCallback( SoGLFormat& format, void* userData );
00563
00564 HWND createWindow( SoGLFormat* format );
00565
00566 void destroyWindow( HWND handle );
00567
00568 void initGLXWidget( SoWidget glx, SoGLFormat* format );
00569
00570
00571 SoWidget mgrWidget;
00572 SoWidget m_widgetNormal;
00573
00574 SoRef<SoGLContext> m_contextNormal;
00575
00576 SoGuiGLWidget* m_guiGLWidget;
00577
00578
00579
00580
00581
00582
00583
00584
00585
00586 Hdc m_hdcNormal;
00587
00588
00589
00590 HPALETTE palNormal;
00591
00592
00593
00594 SoWidget parent;
00595 SoWidget ancestor;
00596
00597
00598
00599
00600
00601
00602
00603
00604 int haveFocus;
00605
00606
00607 int stealFocus;
00608
00609
00610
00611
00612
00613 UINT mouseCaptured;
00614
00615
00616
00617
00618
00619
00620
00621
00622 HCURSOR currentCursor;
00623
00624
00625 static HCURSOR defaultCursor;
00626
00627 DWORD dwThreadId;
00628
00629 int* attribList;
00630
00631
00632
00633
00634
00635 SbBool windowResized;
00636
00637 bool m_isMouseTracking;
00638
00639
00640
00641 void buildNormalGLXWidget( SoGLFormat* format = NULL );
00642 void destroyGLXWidget( SoWidget& w, SoRef<SoGLContext>& ctx, SbBool normalWindow );
00643
00644
00645 static void ginitCB( SoWidget w, SoWinGLWidget* p, XtPointer );
00646 static void exposeCB( SoWidget w, SoWinGLWidget* p, XtPointer ptr );
00647 static void resizeCB( SoWidget w, SoWinGLWidget* p, XtPointer ptr );
00648 static void mgrStructureNotifyCB( SoWidget w, SoWinGLWidget* p, XAnyEvent* e, Boolean* b );
00649
00650
00651 static LRESULT CALLBACK mgrWindowProc( Hwnd hwnd, UINT message,
00652 WPARAM wParam, LPARAM lParam );
00653
00654
00655 static LRESULT CALLBACK glxWindowProc( Hwnd hwnd, UINT message,
00656 WPARAM wParam, LPARAM lParam );
00657 };
00658
00659 inline void
00660 SoWinGLWidget::posChanged( const SbVec2i32&, const SbVec2i32& )
00661 {};
00662
00663
00664 #include <Inventor/Win/SoWinEndStrict.h>
00665
00666 #ifdef _WIN32
00667 #pragma warning(pop)
00668 #endif
00669
00670 #endif // _SO_WIN_GL_WIDGET_H_
00671
00672
00673