| 1 | /* |
| 2 | * |
| 3 | * Copyright (C) 2000 Silicon Graphics, Inc. All Rights Reserved. |
| 4 | * |
| 5 | * This library is free software; you can redistribute it and/or |
| 6 | * modify it under the terms of the GNU Lesser General Public |
| 7 | * License as published by the Free Software Foundation; either |
| 8 | * version 2.1 of the License, or (at your option) any later version. |
| 9 | * |
| 10 | * This library is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 13 | * Lesser General Public License for more details. |
| 14 | * |
| 15 | * Further, this software is distributed without any warranty that it is |
| 16 | * free of the rightful claim of any third person regarding infringement |
| 17 | * or the like. Any license provided herein, whether implied or |
| 18 | * otherwise, applies only to this software file. Patent licenses, if |
| 19 | * any, provided herein do not apply to combinations of this program with |
| 20 | * other software, or any other product whatsoever. |
| 21 | * |
| 22 | * You should have received a copy of the GNU Lesser General Public |
| 23 | * License along with this library; if not, write to the Free Software |
| 24 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 25 | * |
| 26 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, |
| 27 | * Mountain View, CA 94043, or: |
| 28 | * |
| 29 | * http://www.sgi.com |
| 30 | * |
| 31 | * For further information regarding this notice, see: |
| 32 | * |
| 33 | * http://oss.sgi.com/projects/GenInfo/NoticeExplan/ |
| 34 | * |
| 35 | */ |
| 36 | |
| 37 | // -*- C++ -*- |
| 38 | |
| 39 | /* |
| 40 | * Copyright (C) 1990-93 Silicon Graphics, Inc. |
| 41 | * |
| 42 | _______________________________________________________________________ |
| 43 | ______________ S I L I C O N G R A P H I C S I N C . ____________ |
| 44 | | |
| 45 | | $Revision: 1.1.1.1 $ |
| 46 | | |
| 47 | | Description: |
| 48 | | This is a c++ wrapper for the Glx mixed mode widget. |
| 49 | | |
| 50 | | Author(s): Alain Dumesny, David Mott |
| 51 | | |
| 52 | ______________ S I L I C O N G R A P H I C S I N C . ____________ |
| 53 | _______________________________________________________________________ |
| 54 | */ |
| 55 | |
| 56 | #ifndef _SO_XT_GL_WIDGET_H_ |
| 57 | #define _SO_XT_GL_WIDGET_H_cxx . . $ `libSoXt/include/Inventor/Xt/SoXtGLWidget.h:57:9`! |
| 58 | |
| 59 | #include <X11/Intrinsic.h> |
| 60 | #include <GL/glx.h> |
| 61 | #include <Inventor/Xt/SoXtComponent.h>cxx . . $ `<file>/libSoXt/include/Inventor/Xt/SoXtComponent.h`/ |
| 62 | |
| 63 | // C-api: end |
| 64 | /* |
| 65 | * Defines used when specifying the glModes flag to the constructor. |
| 66 | * (used instead of the glx.h defines which do overlap) |
| 67 | */ |
| 68 | #define SO_GLX_RGBcxx . . $ `libSoXt/include/Inventor/Xt/SoXtGLWidget.h:68:9`! (1<<0) |
| 69 | #define SO_GLX_DOUBLEcxx . . $ `libSoXt/include/Inventor/Xt/SoXtGLWidget.h:69:9`! (1<<1) |
| 70 | #define SO_GLX_ZBUFFERcxx . . $ `libSoXt/include/Inventor/Xt/SoXtGLWidget.h:70:9`! (1<<2) |
| 71 | #define SO_GLX_OVERLAYcxx . . $ `libSoXt/include/Inventor/Xt/SoXtGLWidget.h:71:9`! (1<<3) |
| 72 | #define SO_GLX_STEREOcxx . . $ `libSoXt/include/Inventor/Xt/SoXtGLWidget.h:72:9`! (1<<4) |
| 73 | // C-api: begin |
| 74 | |
| 75 | |
| 76 | ////////////////////////////////////////////////////////////////////////////// |
| 77 | // |
| 78 | // Class: SoXtGLWidget |
| 79 | // |
| 80 | // |
| 81 | ////////////////////////////////////////////////////////////////////////////// |
| 82 | |
| 83 | // C-api: abstract |
| 84 | class SoXtGLWidgetcxx . . $ SoXtGLWidget# : public SoXtComponentcxx . . $ SoXtComponent# { |
| 85 | public: |
| 86 | |
| 87 | // |
| 88 | // Get the current normal and overlay GLX windows, which are needed |
| 89 | // as arguments to glXMakeCurrent() when doing drawing in the normal |
| 90 | // or overlay planes. |
| 91 | // |
| 92 | // NOTE: These should NOT be cached by users because these will |
| 93 | // change dynamically when the visual is changed (like when |
| 94 | // setDoubleBuffer() is called). |
| 95 | // |
| 96 | // C-api: name=getNormWin |
| 97 | Windowcxx . . $ Window# getNormalWindowcxx . . $ SoXtGLWidget#getNormalWindow(f708dce9a8856c70).(); |
| 98 | // C-api: name=getOverWin |
| 99 | Windowcxx . . $ Window# getOverlayWindowcxx . . $ SoXtGLWidget#getOverlayWindow(f708dce9a8856c70).(); |
| 100 | |
| 101 | // C-api: name=getNormCtx |
| 102 | GLXContext getNormalContextcxx . . $ SoXtGLWidget#getNormalContext(de005d43f0a9bab4).() { return ctxNormalcxx . . $ SoXtGLWidget#ctxNormal.; } |
| 103 | // C-api: name=getOverCtx |
| 104 | GLXContext getOverlayContextcxx . . $ SoXtGLWidget#getOverlayContext(de005d43f0a9bab4).() { return ctxOverlaycxx . . $ SoXtGLWidget#ctxOverlay.; } |
| 105 | |
| 106 | // C-api: name=getNormWidget |
| 107 | Widgetcxx . . $ Widget# getNormalWidgetcxx . . $ SoXtGLWidget#getNormalWidget(5908e39d78662822).() { return (glModescxx . . $ SoXtGLWidget#glModes. & SO_GLX_DOUBLEcxx . . $ `libSoXt/include/Inventor/Xt/SoXtGLWidget.h:69:9`!) ? doubleBufferWidgetcxx . . $ SoXtGLWidget#doubleBufferWidget. : singleBufferWidgetcxx . . $ SoXtGLWidget#singleBufferWidget.; } |
| 108 | // C-api: name=getOverWidget |
| 109 | Widgetcxx . . $ Widget# getOverlayWidgetcxx . . $ SoXtGLWidget#getOverlayWidget(5908e39d78662822).() { return overlayWidgetcxx . . $ SoXtGLWidget#overlayWidget.; } |
| 110 | |
| 111 | // |
| 112 | // Specify exactly what the visual should be for the normal and overlay |
| 113 | // window. This allows the user to create all possible visuals supported |
| 114 | // by OpenGL. The XVisualInfo structure should be a valid OpenGL visual |
| 115 | // returned by glXChooseVisual(). |
| 116 | // |
| 117 | // C-api: expose |
| 118 | // C-api: name=setNormVis |
| 119 | virtual void setNormalVisualcxx . . $ SoXtGLWidget#setNormalVisual(ebbc07a6722bc54b).(XVisualInfocxx . . $ XVisualInfo# *vis); |
| 120 | // C-api: name=getNormVis |
| 121 | XVisualInfocxx . . $ XVisualInfo# * getNormalVisualcxx . . $ SoXtGLWidget#getNormalVisual(4470823b6d66a64).(); |
| 122 | // C-api: expose |
| 123 | // C-api: name=setOverVis |
| 124 | virtual void setOverlayVisualcxx . . $ SoXtGLWidget#setOverlayVisual(ebbc07a6722bc54b).(XVisualInfocxx . . $ XVisualInfo# *vis); |
| 125 | // C-api: name=getOverVis |
| 126 | XVisualInfocxx . . $ XVisualInfo# * getOverlayVisualcxx . . $ SoXtGLWidget#getOverlayVisual(4470823b6d66a64).(); |
| 127 | |
| 128 | // |
| 129 | // Routine which allows to dynamically change between single and |
| 130 | // double buffering. |
| 131 | // |
| 132 | // C-api: expose |
| 133 | // C-api: name=setDblBuf |
| 134 | virtual void setDoubleBuffercxx . . $ SoXtGLWidget#setDoubleBuffer(d4f767463ce0a6b3).(SbBoolcxx . . $ SbBool# onOrOff); |
| 135 | // C-api: name=isDblBuf |
| 136 | SbBoolcxx . . $ SbBool# isDoubleBuffercxx . . $ SoXtGLWidget#isDoubleBuffer(b126dc7c1de90089).() { return (glModescxx . . $ SoXtGLWidget#glModes. & SO_GLX_DOUBLEcxx . . $ `libSoXt/include/Inventor/Xt/SoXtGLWidget.h:69:9`!); } |
| 137 | |
| 138 | // |
| 139 | // shows/hides a border of thickness 3 around the glx widgets. This |
| 140 | // if OFF by default, but turned on by the render area. |
| 141 | // |
| 142 | void setBordercxx . . $ SoXtGLWidget#setBorder(d4f767463ce0a6b3).(SbBoolcxx . . $ SbBool# onOrOff); |
| 143 | SbBoolcxx . . $ SbBool# isBordercxx . . $ SoXtGLWidget#isBorder(455f465bc33b4cdf).() const { return borderSizecxx . . $ SoXtGLWidget#borderSize. != 0; } |
| 144 | |
| 145 | // |
| 146 | // Inventor 2.1 changed the behavior of double buffered windows to |
| 147 | // redraw temporary to the front buffer when an expose event is received |
| 148 | // or when a new sceneGraph() is set on an SoXtRenderArea. This does not |
| 149 | // apply for general interactive rendering. The idea is that it is |
| 150 | // better to see something redraw (especially if it is slow) than |
| 151 | // to see garbage in the window (in the expose case) or an old invalid |
| 152 | // scene graph (in the SoXtRenderArea::setSceneGraph() case). |
| 153 | // |
| 154 | // This API enables you to turn this functionality OFF if for some reason |
| 155 | // you are unable to prevent repeated expose from causing a redraw (which |
| 156 | // is bad and should be fixed, as it gets worse for large scenes). |
| 157 | // This will be the case for example if you can't create a pulldown |
| 158 | // menu in the popup planes. |
| 159 | // |
| 160 | // NOTE: this api might be removed in some future releases and is only |
| 161 | // intended as a porting help for Inventor 2.0 to 2.1 |
| 162 | // |
| 163 | // C-api: name=setDrwFrontBuf |
| 164 | void setDrawToFrontBufferEnablecxx . . $ SoXtGLWidget#setDrawToFrontBufferEnable(d4f767463ce0a6b3).(SbBoolcxx . . $ SbBool# enableFlag); |
| 165 | // C-api: name=isDrwFrontBuf |
| 166 | SbBoolcxx . . $ SbBool# isDrawToFrontBufferEnablecxx . . $ SoXtGLWidget#isDrawToFrontBufferEnable(455f465bc33b4cdf).() const { return enableDrawToFrontBuffercxx . . $ SoXtGLWidget#enableDrawToFrontBuffer.; } |
| 167 | |
| 168 | protected: |
| 169 | |
| 170 | // Subclasses can pass in a bitwise OR specifying the GL modes |
| 171 | // (e.g. SO_GLX_RGB | SO_GLX_DOUBLE | SO_GLX_ZBUFFER | SO_GLX_OVERLAY) |
| 172 | // If buildNow is FALSE, this will not build its widget tree until |
| 173 | // buildWidget() is explicity called; else, buildWidget() is called here. |
| 174 | SoXtGLWidgetcxx . . $ SoXtGLWidget#SoXtGLWidget(1eaf1a16d3aa15cc).( |
| 175 | Widgetcxx . . $ Widget# parent = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, |
| 176 | const char *name = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!, |
| 177 | SbBoolcxx . . $ SbBool# buildInsideParent = TRUEcxx . . $ `lib/database/include/Inventor/SbBasic.h:80:12`!, |
| 178 | int glModes = SO_GLX_RGBcxx . . $ `libSoXt/include/Inventor/Xt/SoXtGLWidget.h:68:9`!, |
| 179 | SbBoolcxx . . $ SbBool# buildNow = TRUEcxx . . $ `<external>/3673480128541058774/Intrinsic.h:111:9`!); |
| 180 | virtual ~cxx . . $ SoXtGLWidget#`~SoXtGLWidget`(49f6e7a06ebc5aa8).SoXtGLWidgetcxx . . $ SoXtGLWidget#(); |
| 181 | |
| 182 | // subclasses MUST redefine redraw() to draw in the normal bit planes. |
| 183 | // redrawOverlay() should be defined if the overlay planes are being |
| 184 | // used, and processEvent() should be defined if X events are being |
| 185 | // received (see eventMask). |
| 186 | virtual void redrawcxx . . $ SoXtGLWidget#redraw(49f6e7a06ebc5aa8).() = 0; |
| 187 | virtual void redrawOverlaycxx . . $ SoXtGLWidget#redrawOverlay(49f6e7a06ebc5aa8).(); |
| 188 | virtual void processEventcxx . . $ SoXtGLWidget#processEvent(63113e41a3ee5b9d).(XAnyEventcxx . . $ XAnyEvent# *anyevent); |
| 189 | |
| 190 | // subclasses can redefine these to do something useful. |
| 191 | // initGraphic() is called whenever a GLX window gets created |
| 192 | // sizeChanged() is called whenever the window changes size |
| 193 | // widgetChanged() is called whenever the widget is changed (i.e. at |
| 194 | // initialization or after switching from single->double buffer) |
| 195 | virtual void initGraphiccxx . . $ SoXtGLWidget#initGraphic(49f6e7a06ebc5aa8).(); |
| 196 | virtual void initOverlayGraphiccxx . . $ SoXtGLWidget#initOverlayGraphic(49f6e7a06ebc5aa8).(); |
| 197 | virtual void sizeChangedcxx . . $ SoXtGLWidget#sizeChanged(8bc400dc8eb33072).(const SbVec2scxx . . $ SbVec2s# &newSize); |
| 198 | virtual void widgetChangedcxx . . $ SoXtGLWidget#widgetChanged(cfa999c5a14729dd).(Widgetcxx . . $ Widget# newWidget); |
| 199 | |
| 200 | // sets/gets the size of the glx widget(s) - Note this size could be |
| 201 | // different from the SoXtComponent::getSize() method which return |
| 202 | // the size of the component, not necessary the same as the glx widget |
| 203 | // window (because of extra stuff like the decoration in the viewers). |
| 204 | void setGlxSizecxx . . $ SoXtGLWidget#setGlxSize(edd509d4d7dd9f6).(SbVec2scxx . . $ SbVec2s# newSize); |
| 205 | const SbVec2scxx . . $ SbVec2s# & getGlxSizecxx . . $ SoXtGLWidget#getGlxSize(f469ede4e6b056fc).() const { return glxSizecxx . . $ SoXtGLWidget#glxSize.; } |
| 206 | |
| 207 | // subclasses can use this routine as the event handler for any |
| 208 | // devices they wish to get input from. |
| 209 | static void eventHandlercxx . . $ SoXtGLWidget#eventHandler(928be7aa92927306).(Widgetcxx . . $ Widget#, SoXtGLWidgetcxx . . $ SoXtGLWidget# *, XAnyEventcxx . . $ XAnyEvent# *, Booleancxx . . $ Boolean# *); |
| 210 | |
| 211 | // set/get stereo buffering visual. This routine (like setDoubleBuffer) |
| 212 | // can be called interactively, althought slower since a new window |
| 213 | // with the needed visual is always created on the fly. |
| 214 | void setStereoBuffercxx . . $ SoXtGLWidget#setStereoBuffer(d4f767463ce0a6b3).(SbBoolcxx . . $ SbBool# flag); |
| 215 | SbBoolcxx . . $ SbBool# isStereoBuffercxx . . $ SoXtGLWidget#isStereoBuffer(b126dc7c1de90089).() { return (glModescxx . . $ SoXtGLWidget#glModes. & SO_GLX_STEREOcxx . . $ `libSoXt/include/Inventor/Xt/SoXtGLWidget.h:72:9`!); } |
| 216 | |
| 217 | // returns TRUE if main window is in rgb mode (FALSE if color index) |
| 218 | SbBoolcxx . . $ SbBool# isRGBModecxx . . $ SoXtGLWidget#isRGBMode(b126dc7c1de90089).() { return (glModescxx . . $ SoXtGLWidget#glModes. & SO_GLX_RGBcxx . . $ `libSoXt/include/Inventor/Xt/SoXtGLWidget.h:68:9`!); } |
| 219 | |
| 220 | // returns the display lists share group for given context: |
| 221 | int getDisplayListShareGroupcxx . . $ SoXtGLWidget#getDisplayListShareGroup(5ced934dc1e9089a).(GLXContext ctx); |
| 222 | |
| 223 | Colormapcxx . . $ Colormap# colorMapcxx . . $ SoXtGLWidget#colorMap.; // set when color index is used |
| 224 | Colormapcxx . . $ Colormap# overlayColorMapcxx . . $ SoXtGLWidget#overlayColorMap.; // set when overlay is used |
| 225 | SbBoolcxx . . $ SbBool# waitForExposecxx . . $ SoXtGLWidget#waitForExpose.; // prevent redraws until an expose is received |
| 226 | SbBoolcxx . . $ SbBool# drawToFrontBuffercxx . . $ SoXtGLWidget#drawToFrontBuffer.; // used by RA to draw new scenes to front buffer |
| 227 | |
| 228 | // make those methods protected to enable the SoXtRenderArea to use them |
| 229 | // directly when it needs to build the widget and get its resources. |
| 230 | Widgetcxx . . $ Widget# buildWidgetcxx . . $ SoXtGLWidget#buildWidget(a686be44a4028679).(Widgetcxx . . $ Widget# parent); |
| 231 | Widgetcxx . . $ Widget# getGlxMgrWidgetcxx . . $ SoXtGLWidget#getGlxMgrWidget(5908e39d78662822).() { return mgrWidgetcxx . . $ SoXtGLWidget#mgrWidget.; } |
| 232 | |
| 233 | private: |
| 234 | // local vars |
| 235 | Widgetcxx . . $ Widget# mgrWidgetcxx . . $ SoXtGLWidget#mgrWidget.; |
| 236 | Widgetcxx . . $ Widget# doubleBufferWidgetcxx . . $ SoXtGLWidget#doubleBufferWidget., singleBufferWidgetcxx . . $ SoXtGLWidget#singleBufferWidget., overlayWidgetcxx . . $ SoXtGLWidget#overlayWidget.; |
| 237 | GLXContext ctxNormalcxx . . $ SoXtGLWidget#ctxNormal., ctxOverlaycxx . . $ SoXtGLWidget#ctxOverlay., ctxSinglecxx . . $ SoXtGLWidget#ctxSingle., ctxDoublecxx . . $ SoXtGLWidget#ctxDouble.; |
| 238 | SbVec2scxx . . $ SbVec2s# glxSizecxx . . $ SoXtGLWidget#glxSize.; // size of glx widgets which is always up to date |
| 239 | int *attribListcxx . . $ SoXtGLWidget#attribList.; |
| 240 | int glModescxx . . $ SoXtGLWidget#glModes.; |
| 241 | int borderSizecxx . . $ SoXtGLWidget#borderSize.; |
| 242 | SbBoolcxx . . $ SbBool# enableDrawToFrontBuffercxx . . $ SoXtGLWidget#enableDrawToFrontBuffer.; |
| 243 | |
| 244 | // specify if sizeChanged() should be called when an expose event |
| 245 | // is received (as opposed to when a resize event is received, where |
| 246 | // the window hasn't yet been maped to the new size). |
| 247 | // ??? a GlxDraw bug ? |
| 248 | SbBoolcxx . . $ SbBool# windowResizedcxx . . $ SoXtGLWidget#windowResized.; |
| 249 | |
| 250 | // creates a GLX widget of the correct current type and get the current |
| 251 | // set of windows, color maps, etc... |
| 252 | void buildNormalGLXWidgetcxx . . $ SoXtGLWidget#buildNormalGLXWidget(ebbc07a6722bc54b).(XVisualInfocxx . . $ XVisualInfo# *vis = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!); |
| 253 | void buildOverlayGLXWidgetcxx . . $ SoXtGLWidget#buildOverlayGLXWidget(ebbc07a6722bc54b).(XVisualInfocxx . . $ XVisualInfo# *vis = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!); |
| 254 | void destroyNormalWindowscxx . . $ SoXtGLWidget#destroyNormalWindows(49f6e7a06ebc5aa8).(); |
| 255 | void destroyGLXWidgetcxx . . $ SoXtGLWidget#destroyGLXWidget(f0d16fcdeb7e4ba9).(Widgetcxx . . $ Widget# &w, GLXContext &ctx, SbBoolcxx . . $ SbBool# normalWindow); |
| 256 | |
| 257 | // callbacks from glx widget |
| 258 | static void ginitCBcxx . . $ SoXtGLWidget#ginitCB(4f71146a5203b716).(Widgetcxx . . $ Widget#, SoXtGLWidgetcxx . . $ SoXtGLWidget# *, XtPointercxx . . $ XtPointer#); |
| 259 | static void overlayGinitCBcxx . . $ SoXtGLWidget#overlayGinitCB(4f71146a5203b716).(Widgetcxx . . $ Widget#, SoXtGLWidgetcxx . . $ SoXtGLWidget# *, XtPointercxx . . $ XtPointer#); |
| 260 | static void exposeCBcxx . . $ SoXtGLWidget#exposeCB(4f71146a5203b716).(Widgetcxx . . $ Widget#, SoXtGLWidgetcxx . . $ SoXtGLWidget# *, XtPointercxx . . $ XtPointer#); |
| 261 | static void overlayExposeCBcxx . . $ SoXtGLWidget#overlayExposeCB(4f71146a5203b716).(Widgetcxx . . $ Widget#, SoXtGLWidgetcxx . . $ SoXtGLWidget# *, XtPointercxx . . $ XtPointer#); |
| 262 | static void resizeCBcxx . . $ SoXtGLWidget#resizeCB(4f71146a5203b716).(Widgetcxx . . $ Widget#, SoXtGLWidgetcxx . . $ SoXtGLWidget# *, XtPointercxx . . $ XtPointer#); |
| 263 | }; |
| 264 | |
| 265 | |
| 266 | #endif // _SO_XT_GL_WIDGET_H_ |
| 267 |