1 /*
2  * (c) Copyright 1993, Silicon Graphics, Inc.
3  * ALL RIGHTS RESERVED
4  * Permission to use, copy, modify, and distribute this software for
5  * any purpose and without fee is hereby granted, provided that the above
6  * copyright notice appear in all copies and that both the copyright notice
7  * and this permission notice appear in supporting documentation, and that
8  * the name of Silicon Graphics, Inc. not be used in advertising
9  * or publicity pertaining to distribution of the software without specific,
10  * written prior permission.
11  *
12  * THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"
13  * AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,
14  * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR
15  * FITNESS FOR A PARTICULAR PURPOSE.  IN NO EVENT SHALL SILICON
16  * GRAPHICS, INC.  BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT,
17  * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY
18  * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION,
19  * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF
20  * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC.  HAS BEEN
21  * ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
22  * ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
23  * POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.
24  *
25  *
26  * US Government Users Restricted Rights
27  * Use, duplication, or disclosure by the Government is subject to
28  * restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
29  * (c)(1)(ii) of the Rights in Technical Data and Computer Software
30  * clause at DFARS 252.227-7013 and/or in similar or successor
31  * clauses in the FAR or the DOD or NASA FAR Supplement.
32  * Unpublished-- rights reserved under the copyright laws of the
33  * United States.  Contractor/manufacturer is Silicon Graphics,
34  * Inc., 2011 N.  Shoreline Blvd., Mountain View, CA 94039-7311.
35  *
36  * OpenGL(TM) is a trademark of Silicon Graphics, Inc.
37  */
38 
39 /*
40  * This file has been heavily modified from the original.  It has been
41  * stripped down and moved into the SoXt namespace to avoid potential
42  * name-collisions with externally installed GL widgets, and all pure
43  * Xt vs. Xt/Motif ifdef wrappers have been removed (only the Motif
44  * parts remain).  You are encouraged to rather go back to the source,
45  * which you will find with Mesa, than to base your GL widget derivation
46  * on this code.
47  *
48  *     Lars J. Aas <larsa@sim.no>,
49  *     19th may 2000
50  */
51 
52 /* $Id$ */
53 
54 #ifndef SOXT_GLAREA_H
55 #define SOXT_GLAREA_H
56 
57 /* GL/glx.h includes X11/Xmd.h which contains typedefs for BOOL and
58  * INT32 that conflict with the definitions in windef.h (which is
59  * included from windows.h, which may be included from
60  * Inventor/system/gl.h).  To avoid this conflict, we rename the
61  * typedefs done in X11/Xmd.h to use other names (tempbool and
62  * tempint32), and try to clean up the hack after the header has been
63  * parsed.  2003-06-25 larsa */
64 #ifndef BOOL
65 #define BOOL tempbool
66 #define COIN_DEFINED_BOOL
67 #endif /* !BOOL */
68 #ifndef INT32
69 #define INT32 tempint32
70 #define COIN_DEFINED_INT32
71 #endif /* !INT32 */
72 #include <GL/glx.h>
73 /* This is the cleanup part of the X11/Xmd.h conflict fix hack set up
74  * above.  2003-06-25 larsa */
75 #ifdef COIN_DEFINED_BOOL
76 #undef BOOL
77 #undef COIN_DEFINED_BOOL
78 #endif /* COIN_DEFINED_BOOL */
79 #ifdef COIN_DEFINED_INT32
80 #undef INT32
81 #undef COIN_DEFINED_INT32
82 #endif /* COIN_DEFINED_INT32 */
83 
84 #include <GL/gl.h>
85 
86 #ifdef __cplusplus
87 extern "C" {
88 #endif /* __cplusplus */
89 
90 /* ********************************************************************** */
91 
92 /* Resources:
93 
94  Name		     Class		RepType		Default Value
95  ----		     -----		-------		-------------
96  attribList	     AttribList		int *		NULL
97  visualInfo	     VisualInfo		VisualInfo	NULL
98  installColormap     InstallColormap	Boolean		TRUE
99  allocateBackground  AllocateColors	Boolean		FALSE
100  allocateOtherColors AllocateColors	Boolean		FALSE
101  installBackground   InstallBackground	Boolean		TRUE
102  exposeCallback      Callback		Pointer		NULL
103  ginitCallback       Callback		Pointer		NULL
104  inputCallback       Callback		Pointer		NULL
105  resizeCallback      Callback		Pointer		NULL
106 
107 *** The following resources all correspond to the GLX configuration
108 *** attributes and are used to create the attribList if it is NULL
109  bufferSize	     BufferSize		int		0
110  level		     Level		int		0
111  rgba		     Rgba		Boolean		FALSE
112  doublebuffer	     Doublebuffer	Boolean		FALSE
113  stereo		     Stereo		Boolean		FALSE
114  auxBuffers	     AuxBuffers		int		0
115  redSize	     ColorSize		int		1
116  greenSize	     ColorSize		int		1
117  blueSize	     ColorSize		int		1
118  alphaSize	     AlphaSize		int		0
119  depthSize	     DepthSize		int		0
120  stencilSize	     StencilSize	int		0
121  accumRedSize	     AccumColorSize	int		0
122  accumGreenSize	     AccumColorSize	int		0
123  accumBlueSize	     AccumColorSize	int		0
124  accumAlphaSize	     AccumAlphaSize	int		0
125 */
126 
127 /* ********************************************************************** */
128 
129 #define SoXtNattribList           "attribList"
130 #define SoXtCAttribList           "AttribList"
131 #define SoXtNvisualInfo           "visualInfo"
132 #define SoXtCVisualInfo           "VisualInfo"
133 #define SoXtRVisualInfo           "VisualInfo"
134 
135 #define SoXtNinstallColormap      "installColormap"
136 #define SoXtCInstallColormap      "InstallColormap"
137 #define SoXtNallocateBackground   "allocateBackground"
138 #define SoXtNallocateOtherColors  "allocateOtherColors"
139 #define SoXtCAllocateColors       "AllocateColors"
140 #define SoXtNinstallBackground    "installBackground"
141 #define SoXtCInstallBackground    "InstallBackground"
142 
143 #define SoXtCCallback             "Callback"
144 #define SoXtNexposeCallback       "exposeCallback"
145 #define SoXtNginitCallback        "ginitCallback"
146 #define SoXtNresizeCallback       "resizeCallback"
147 #define SoXtNinputCallback        "inputCallback"
148 
149 #define SoXtNbufferSize           "bufferSize"
150 #define SoXtCBufferSize           "BufferSize"
151 #define SoXtNlevel                "level"
152 #define SoXtCLevel                "Level"
153 #define SoXtNrgba                 "rgba"
154 #define SoXtCRgba                 "Rgba"
155 #define SoXtNdoublebuffer         "doublebuffer"
156 #define SoXtCDoublebuffer         "Doublebuffer"
157 #define SoXtNstereo               "stereo"
158 #define SoXtCStereo               "Stereo"
159 #define SoXtNauxBuffers           "auxBuffers"
160 #define SoXtCAuxBuffers           "AuxBuffers"
161 #define SoXtNredSize              "redSize"
162 #define SoXtNgreenSize            "greenSize"
163 #define SoXtNblueSize             "blueSize"
164 #define SoXtCColorSize            "ColorSize"
165 #define SoXtNalphaSize            "alphaSize"
166 #define SoXtCAlphaSize            "AlphaSize"
167 #define SoXtNdepthSize            "depthSize"
168 #define SoXtCDepthSize            "DepthSize"
169 #define SoXtNstencilSize          "stencilSize"
170 #define SoXtCStencilSize          "StencilSize"
171 #define SoXtNaccumRedSize         "accumRedSize"
172 #define SoXtNaccumGreenSize       "accumGreenSize"
173 #define SoXtNaccumBlueSize        "accumBlueSize"
174 #define SoXtCAccumColorSize       "AccumColorSize"
175 #define SoXtNaccumAlphaSize       "accumAlphaSize"
176 #define SoXtCAccumAlphaSize       "AccumAlphaSize"
177 
178 #ifndef SoXtNrefresh
179 #define SoXtNrefresh              "refresh"
180 #endif
181 #ifndef SoXtCRefresh
182 #define SoXtCRefresh              "Refresh"
183 #endif
184 
185 typedef  struct _SoXtGLAreaClassRec *  SoXtGLAreaWidgetClass;
186 typedef  struct _SoXtGLAreaRec *       SoXtGLAreaWidget;
187 
188 extern WidgetClass soxtGLAreaWidgetClass;
189 
190 /* Callback reasons */
191 #define SoXtCR_EXPOSE    XmCR_EXPOSE
192 #define SoXtCR_RESIZE    XmCR_RESIZE
193 #define SoXtCR_INPUT     XmCR_INPUT
194 
195 #define SoXtCR_GINIT     31975	/* Arbitrary number that should never clash */
196 
197 typedef struct {
198   int       reason;
199   XEvent  * event;
200   Dimension width;
201   Dimension height;
202 } SoXtGLAreaCallbackStruct;
203 
204 void SoXtGLAreaMakeCurrent(Widget w, GLXContext ctx);
205 void SoXtGLAreaSwapBuffers(Widget w);
206 
207 #ifndef XtIsSoXtGLArea
208 #define XtIsSoXtGLArea(w) XtIsSubclass(w, soxtGLAreaWidgetClass)
209 #endif /* ! SoXtIsGLArea */
210 
211 /* ********************************************************************** */
212 
213 #ifdef __cplusplus
214 } /* extern "C" */
215 #endif /* __cplusplus */
216 
217 #endif /* ! SOXT_GLAREA_H */
218