2 * This file is part of duit.
4 * duit is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; either version 2.1 of the License, or
7 * (at your option) any later version.
9 * duit is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with duit; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 // generated automatically - do not change
20 // find conversion definition on APILookup.txt
21 // implement new conversion functionalities on the wrap.utils pakage
24 * Conversion parameters:
27 * outFile = GLCapability
47 module glgtk
.GLCapability
;
49 private import glgtk
.glgtktypes
;
51 private import lib
.glgtk
;
57 // SNEAKY MIXIN PROBLEM:
59 // These need to be public imports
60 // or GLCompatibility will not compile
61 // as a mixin in other modules!
63 // May as well be explicit about it:
66 public import std
.stdio
;
67 public import glgtk
.GLWidget
;
68 private import glgdk
.GLDrawable
;
69 public import gdk
.Event
;
73 template GLCapability()
90 * Sets the GL capabilities for the widget
92 bit
setGLCapability(GLConfig glConfig
= null, int renderType
= GLRenderType
.RGBA_TYPE
)
94 if ( glConfig
is null )
96 glConfig
= new GLConfig(
98 | GLConfigMode
.MODE_DEPTH
99 | GLConfigMode
.MODE_DOUBLE
,
100 GLConfigMode
.MODE_RGB
101 | GLConfigMode
.MODE_DEPTH
104 bit ok
= setGLCapability(this, glConfig
, null, true, renderType
);
110 * Set the GL capabilities for the widget
112 bit
setGLCapability(Widget widget
, GLConfig glConfig
, GLContext shareList
, bit direct
, int renderType
)
114 GLWidget
.setGLCapability(widget
, glConfig
, shareList
, direct
, renderType
);
116 addOnRealize(&realizeFrame
);
117 addOnUnrealize(&realizeFrame
);
118 addOnExpose(&exposeFrame
);
119 addOnConfigure(&configureFrame
);
121 addOnUnmap(&unmapFrame
);
122 addOnVisibilityNotify(&visibilityFrame
);
127 * The widget should use this method to redraw it self at any time
129 public bit
glDrawFrame()
131 return glDrawFrame(this);
135 * The application should use this method to redraw the scene at any time
137 bit
glDrawFrame(Widget widget
)
139 //printf("GLCapabilityT.realizeFrame \n" );
140 GLContext context
= GLWidget
.getGLContext(widget
);
141 GLDrawable drawable
= GLWidget
.getGLDrawable(widget
);
143 /*** OpenGL BEGIN ***/
144 if ( !drawable
.glBegin(context
) )
149 /*** do user actions ***/
150 bit consumeEvent
= typeof(this).drawGL(null);
153 if ( drawable
.isDoubleBuffered() )
155 drawable
.swapBuffers();
168 bool alreadyRealized
;
170 bool getAlreadyRealized()
172 return alreadyRealized
;
175 void realizeFrame(Widget widget
)
177 alreadyRealized
= true;
179 //printf("GLCapabilityT.realizeFrame \n" );
180 GLContext context
= GLWidget
.getGLContext(widget
);
181 GLDrawable drawable
= GLWidget
.getGLDrawable(widget
);
183 /*** OpenGL BEGIN ***/
184 if ( !drawable
.glBegin(context
) )
189 /*** do user actions ***/
190 bit consumeEvent
= typeof(this).initGL();
193 if ( drawable
.isDoubleBuffered() )
195 drawable
.swapBuffers();
205 //return consumeEvent;
208 int exposeFrame(GdkEventExpose
* event
, Widget widget
)
210 //printf("GLCapabilityT.exposeFrame exposeFrame\n" );
211 GLContext context
= GLWidget
.getGLContext(widget
);
212 GLDrawable drawable
= GLWidget
.getGLDrawable(widget
);
214 /*** OpenGL BEGIN ***/
215 if ( !drawable
.glBegin(context
) )
220 /*** do user actions ***/
221 int consumeEvent
= typeof(this).drawGL(event
);
224 if ( drawable
.isDoubleBuffered() )
226 drawable
.swapBuffers();
239 private import std
.gc
;
241 int configureFrame(GdkEventConfigure
* event
, Widget widget
)
246 height
= event
.height
;
249 //writefln("configureFrame 1");
250 //printf("GLCapabilityT.configureFrame \n" );
251 GLContext context
= GLWidget
.getGLContext(widget
);
252 GLDrawable drawable
= GLWidget
.getGLDrawable(widget
);
254 /*** OpenGL BEGIN ***/
255 if ( !drawable
.glBegin(context
) )
260 //writefln("configureFrame 2");
261 /*** do user actions ***/
262 int consumeEvent
= typeof(this).resizeGL(event
);
264 //writefln("configureFrame 3");
267 if ( drawable
.isDoubleBuffered() )
269 //writefln("configureFrame 4");
270 drawable
.swapBuffers();
271 //writefln("configureFrame 5");
275 //writefln("configureFrame 6");
277 //writefln("configureFrame 7");
280 //writefln("configureFrame 8");
282 //writefln("configureFrame 9");
289 void mapFrame(Widget widget
)
291 //printf("GLCapabilityT.mapFrame \n" );
292 GLContext context
= GLWidget
.getGLContext(widget
);
293 GLDrawable drawable
= GLWidget
.getGLDrawable(widget
);
295 /*** OpenGL BEGIN ***/
296 if ( !drawable
.glBegin(context
) )
301 /*** do user actions ***/
302 bit consumeEvent
= typeof(this).onMap();
305 if ( drawable
.isDoubleBuffered() )
307 drawable
.swapBuffers();
317 //return consumeEvent;
320 void unmapFrame(Widget widget
)
322 //printf("GLCapabilityT.unmapFrame \n" );
323 GLContext context
= GLWidget
.getGLContext(widget
);
324 GLDrawable drawable
= GLWidget
.getGLDrawable(widget
);
326 /*** OpenGL BEGIN ***/
327 if ( !drawable
.glBegin(context
) )
332 /*** do user actions ***/
333 bit consumeEvent
= typeof(this).onUnmap();
336 if ( drawable
.isDoubleBuffered() )
338 drawable
.swapBuffers();
348 //return consumeEvent;
351 int visibilityFrame(GdkEventVisibility
* event
, Widget widget
)
353 //printf("GLCapabilityT.visibilityFrame \n" );
354 GLContext context
= GLWidget
.getGLContext(widget
);
355 GLDrawable drawable
= GLWidget
.getGLDrawable(widget
);
357 /*** OpenGL BEGIN ***/
358 if ( !drawable
.glBegin(context
) )
363 /*** do user actions ***/
364 bool consumeEvent
= typeof(this).onVisibility(event
);
367 if ( drawable
.isDoubleBuffered() )
369 drawable
.swapBuffers();
384 //printf("GLCapabilityT.map \n" );
390 //printf("GLCapabilityT.unmap \n" );
394 bool onVisibility(GdkEventVisibility
* event
)
396 //printf("GLCapabilityT.visibility \n" );