2 * This file is part of gtkD.
4 * gtkD 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 * gtkD 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 gtkD; 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
48 module glgtk
.GLCapability
;
54 import tango
.io
.Stdout
; // use the tango loging?
58 private import gtkglc
.glgtktypes
;
60 private import gtkglc
.glgtk
;
70 // SNEAKY MIXIN PROBLEM:
72 // These need to be public imports
73 // or GLCompatibility will not compile
74 // as a mixin in other modules!
76 // May as well be explicit about it:
79 public import std
.stdio
;
80 public import glgtk
.GLWidget
;
81 private import glgdk
.GLDrawable
;
82 public import gdk
.Event
;
83 public import gtkglc
.gl
;
86 template GLCapability()
103 * Sets the GL capabilities for the widget
105 bool setGLCapability(GLConfig glConfig
= null, int renderType
= GLRenderType
.RGBA_TYPE
)
107 if ( glConfig
is null )
109 glConfig
= new GLConfig(
110 GLConfigMode
.MODE_RGB
111 | GLConfigMode
.MODE_DEPTH
112 | GLConfigMode
.MODE_DOUBLE
,
113 GLConfigMode
.MODE_RGB
114 | GLConfigMode
.MODE_DEPTH
117 bool ok
= setGLCapability(this, glConfig
, null, true, renderType
);
123 * Set the GL capabilities for the widget
125 bool setGLCapability(Widget widget
, GLConfig glConfig
, GLContext shareList
, bool direct
, int renderType
)
127 GLWidget
.setGLCapability(widget
, glConfig
, shareList
, direct
, renderType
);
129 addOnRealize(&realizeFrame
);
130 addOnUnrealize(&realizeFrame
);
131 addOnExpose(&exposeFrame
);
132 addOnConfigure(&configureFrame
);
134 addOnUnmap(&unmapFrame
);
135 addOnVisibilityNotify(&visibilityFrame
);
140 * The widget should use this method to redraw it self at any time
142 public bool glDrawFrame()
144 return glDrawFrame(this);
148 * The application should use this method to redraw the scene at any time
150 bool glDrawFrame(Widget widget
)
152 //printf("GLCapabilityT.realizeFrame \n" );
153 GLContext context
= GLWidget
.getGLContext(widget
);
154 GLDrawable drawable
= GLWidget
.getGLDrawable(widget
);
156 /*** OpenGL BEGIN ***/
157 if ( !drawable
.glBegin(context
) )
162 /*** do user actions ***/
163 bool consumeEvent
= typeof(this).drawGL(null);
166 if ( drawable
.isDoubleBuffered() )
168 drawable
.swapBuffers();
181 bool alreadyRealized
;
183 bool getAlreadyRealized()
185 return alreadyRealized
;
188 void realizeFrame(Widget widget
)
190 alreadyRealized
= true;
192 //printf("GLCapabilityT.realizeFrame \n" );
193 GLContext context
= GLWidget
.getGLContext(widget
);
194 GLDrawable drawable
= GLWidget
.getGLDrawable(widget
);
196 /*** OpenGL BEGIN ***/
197 if ( !drawable
.glBegin(context
) )
202 /*** do user actions ***/
203 bool consumeEvent
= typeof(this).initGL();
206 if ( drawable
.isDoubleBuffered() )
208 drawable
.swapBuffers();
218 //return consumeEvent;
221 int exposeFrame(GdkEventExpose
* event
, Widget widget
)
223 //printf("GLCapabilityT.exposeFrame exposeFrame\n" );
224 GLContext context
= GLWidget
.getGLContext(widget
);
225 GLDrawable drawable
= GLWidget
.getGLDrawable(widget
);
227 /*** OpenGL BEGIN ***/
228 if ( !drawable
.glBegin(context
) )
233 /*** do user actions ***/
234 int consumeEvent
= typeof(this).drawGL(event
);
237 if ( drawable
.isDoubleBuffered() )
239 drawable
.swapBuffers();
252 private import std
.gc
;
254 int configureFrame(GdkEventConfigure
* event
, Widget widget
)
259 height
= event
.height
;
262 //writefln("configureFrame 1");
263 //printf("GLCapabilityT.configureFrame \n" );
264 GLContext context
= GLWidget
.getGLContext(widget
);
265 GLDrawable drawable
= GLWidget
.getGLDrawable(widget
);
267 /*** OpenGL BEGIN ***/
268 if ( !drawable
.glBegin(context
) )
273 //writefln("configureFrame 2");
274 /*** do user actions ***/
275 int consumeEvent
= typeof(this).resizeGL(event
);
277 //writefln("configureFrame 3");
280 if ( drawable
.isDoubleBuffered() )
282 //writefln("configureFrame 4");
283 drawable
.swapBuffers();
284 //writefln("configureFrame 5");
288 //writefln("configureFrame 6");
290 //writefln("configureFrame 7");
293 //writefln("configureFrame 8");
295 //writefln("configureFrame 9");
302 void mapFrame(Widget widget
)
304 //printf("GLCapabilityT.mapFrame \n" );
305 GLContext context
= GLWidget
.getGLContext(widget
);
306 GLDrawable drawable
= GLWidget
.getGLDrawable(widget
);
308 /*** OpenGL BEGIN ***/
309 if ( !drawable
.glBegin(context
) )
314 /*** do user actions ***/
315 bool consumeEvent
= typeof(this).onMap();
318 if ( drawable
.isDoubleBuffered() )
320 drawable
.swapBuffers();
330 //return consumeEvent;
333 void unmapFrame(Widget widget
)
335 //printf("GLCapabilityT.unmapFrame \n" );
336 GLContext context
= GLWidget
.getGLContext(widget
);
337 GLDrawable drawable
= GLWidget
.getGLDrawable(widget
);
339 /*** OpenGL BEGIN ***/
340 if ( !drawable
.glBegin(context
) )
345 /*** do user actions ***/
346 bool consumeEvent
= typeof(this).onUnmap();
349 if ( drawable
.isDoubleBuffered() )
351 drawable
.swapBuffers();
361 //return consumeEvent;
364 int visibilityFrame(GdkEventVisibility
* event
, Widget widget
)
366 //printf("GLCapabilityT.visibilityFrame \n" );
367 GLContext context
= GLWidget
.getGLContext(widget
);
368 GLDrawable drawable
= GLWidget
.getGLDrawable(widget
);
370 /*** OpenGL BEGIN ***/
371 if ( !drawable
.glBegin(context
) )
376 /*** do user actions ***/
377 bool consumeEvent
= typeof(this).onVisibility(event
);
380 if ( drawable
.isDoubleBuffered() )
382 drawable
.swapBuffers();
397 //printf("GLCapabilityT.map \n" );
403 //printf("GLCapabilityT.unmap \n" );
407 bool onVisibility(GdkEventVisibility
* event
)
409 //printf("GLCapabilityT.visibility \n" );