1
/**************************************************************************\
3
* This file is part of the Coin 3D visualization library.
4
* Copyright (C) 1998-2005 by Systems in Motion. All rights reserved.
6
* This library is free software; you can redistribute it and/or
7
* modify it under the terms of the GNU General Public License
8
* ("GPL") version 2 as published by the Free Software Foundation.
9
* See the file LICENSE.GPL at the root directory of this source
10
* distribution for additional information about the GNU GPL.
12
* For using Coin with software that can not be combined with the GNU
13
* GPL, and for taking advantage of the additional benefits of our
14
* support services, please contact Systems in Motion about acquiring
15
* a Coin Professional Edition License.
17
* See <URL:http://www.coin3d.org/> for more information.
19
* Systems in Motion, Postboks 1283, Pirsenteret, 7462 Trondheim, NORWAY.
20
* <URL:http://www.sim.no/>.
22
\**************************************************************************/
24
#ifndef SOQT_GLWIDGET_H
25
#define SOQT_GLWIDGET_H
27
#include <Inventor/SbBasic.h>
28
#include <Inventor/Qt/SoQtBasic.h>
29
#include <Inventor/Qt/SoQtComponent.h>
33
#endif // __COIN_SOQT__
36
* GL/glx.h includes X11/Xmd.h which contains typedefs for BOOL and
37
* INT32 that conflict with the definitions in windef.h (which is
38
* included from windows.h, which may be included from
39
* Inventor/system/gl.h). To avoid this conflict, we rename the
40
* typedefs done in X11/Xmd.h to use other names (tempbool and
41
* tempint32), and try to clean up the hack after the header has been
42
* parsed. 2003-06-25 larsa
46
#define COIN_DEFINED_BOOL
49
#define INT32 tempint32
50
#define COIN_DEFINED_INT32
54
* This is the cleanup part of the X11/Xmd.h conflict fix hack set up
55
* above. 2003-06-25 larsa
57
#ifdef COIN_DEFINED_BOOL
59
#undef COIN_DEFINED_BOOL
60
#endif /* COIN_DEFINED_BOOL */
61
#ifdef COIN_DEFINED_INT32
63
#undef COIN_DEFINED_INT32
64
#endif /* COIN_DEFINED_INT32 */
65
#endif // __COIN_SOXT__
68
#endif // __COIN_SOGTK__
70
// *************************************************************************
73
SO_GL_RGB = 0x01, SO_GLX_RGB = SO_GL_RGB,
74
SO_GL_DOUBLE = 0x02, SO_GLX_DOUBLE = SO_GL_DOUBLE,
75
SO_GL_ZBUFFER = 0x04, SO_GLX_ZBUFFER = SO_GL_ZBUFFER,
76
SO_GL_OVERLAY = 0x08, SO_GLX_OVERLAY = SO_GL_OVERLAY,
77
SO_GL_STEREO = 0x10, SO_GLX_STEREO = SO_GL_STEREO
80
// *************************************************************************
82
class SOQT_DLL_API SoQtGLWidget : public SoQtComponent {
83
SOQT_OBJECT_ABSTRACT_HEADER(SoQtGLWidget, SoQtComponent);
87
void setBorder(const SbBool enable);
88
SbBool isBorder(void) const;
90
virtual void setDoubleBuffer(const SbBool enable);
91
SbBool isDoubleBuffer(void) const;
93
void setDrawToFrontBufferEnable(const SbBool enable);
94
SbBool isDrawToFrontBufferEnable(void) const;
96
void setQuadBufferStereo(const SbBool enable);
97
SbBool isQuadBufferStereo(void) const;
99
void setAccumulationBuffer(const SbBool enable);
100
SbBool getAccumulationBuffer(void) const;
102
void setStencilBuffer(const SbBool enable);
103
SbBool getStencilBuffer(void) const;
105
void setAlphaChannel(const SbBool enable);
106
SbBool getAlphaChannel(void) const;
108
void setOverlayRender(const SbBool onoff);
109
SbBool isOverlayRender(void) const;
111
void setStealFocus(SbBool enable);
112
SbBool isStealFocus(void) const;
114
QWidget * getGLWidget(void) const;
115
QWidget * getNormalWidget(void) const;
116
QWidget * getOverlayWidget(void) const;
118
SbBool hasOverlayGLArea(void) const;
119
SbBool hasNormalGLArea(void) const;
121
unsigned long getOverlayTransparentPixel(void);
123
// OpenGL query functions.
124
void getPointSizeLimits(SbVec2f & range, float & granularity);
125
void getLineWidthLimits(SbVec2f & range, float & granularity);
128
SoQtGLWidget(QWidget * const parent = NULL,
129
const char * const name = NULL,
130
const SbBool embed = TRUE,
131
const int glmodes = SO_GL_RGB,
132
const SbBool build = TRUE);
135
virtual void processEvent(QEvent * event);
137
QWidget * buildWidget(QWidget * parent);
139
virtual void redraw(void) = 0;
140
virtual void redrawOverlay(void);
142
virtual void initGraphic(void);
143
virtual void initOverlayGraphic(void);
145
virtual void sizeChanged(const SbVec2s & size);
146
virtual void widgetChanged(QWidget * w);
148
void setGLSize(const SbVec2s size);
149
SbVec2s getGLSize(void) const;
150
float getGLAspectRatio(void) const;
153
void setGlxSize(const SbVec2s size) { this->setGLSize(size); }
154
SbVec2s getGlxSize(void) const { return this->getGLSize(); }
155
float getGlxAspectRatio(void) const { return this->getGLAspectRatio(); }
157
void setStereoBuffer(SbBool flag);
158
SbBool isStereoBuffer(void) const;
160
SbBool isRGBMode(void);
162
SbBool waitForExpose;
163
SbBool drawToFrontBuffer;
165
void glLockNormal(void);
166
void glUnlockNormal(void);
168
void glLockOverlay(void);
169
void glUnlockOverlay(void);
171
void glSwapBuffers(void);
172
void glFlushBuffer(void);
174
virtual SbBool glScheduleRedraw(void);
177
class SoQtGLWidgetP * pimpl;
178
friend class SoGuiGLWidgetP;
179
friend class SoQtGLWidgetP;
181
// FIXME: get rid of toolkit-specific stuff below. 20020613 mortene.
185
GLXContext getNormalContext(void);
186
GLXContext getOverlayContext(void);
188
Window getNormalWindow(void);
189
Window getOverlayWindow(void);
191
int getOverlayColorMapSize(void);
192
int getColorMapSize(void);
194
virtual void setNormalVisual(XVisualInfo * visual);
195
XVisualInfo * getNormalVisual(void);
196
virtual void setOverlayVisual(XVisualInfo * visual);
197
XVisualInfo * getOverlayVisual(void);
200
static void eventHandler(Widget, SoXtGLWidget *, XAnyEvent *, Boolean *);
202
int getDisplayListShareGroup(GLXContext context);
203
Widget getGlxMgrWidget(void);
204
#endif // __COIN_SOXT__
206
#ifdef __COIN_SOGTK__
208
virtual SbBool eventFilter(GtkWidget * object, GdkEvent * event);
209
#endif // __COIN_SOGTK__
213
// *************************************************************************
215
#endif // ! SOQT_GLWIDGET_H