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();
253 private import tango
.core
.Memory
;
255 private import std
.gc
;
258 int configureFrame(GdkEventConfigure
* event
, Widget widget
)
263 height
= event
.height
;
274 //writefln("configureFrame 1");
275 //printf("GLCapabilityT.configureFrame \n" );
276 GLContext context
= GLWidget
.getGLContext(widget
);
277 GLDrawable drawable
= GLWidget
.getGLDrawable(widget
);
279 /*** OpenGL BEGIN ***/
280 if ( !drawable
.glBegin(context
) )
285 //writefln("configureFrame 2");
286 /*** do user actions ***/
287 int consumeEvent
= typeof(this).resizeGL(event
);
289 //writefln("configureFrame 3");
292 if ( drawable
.isDoubleBuffered() )
294 //writefln("configureFrame 4");
295 drawable
.swapBuffers();
296 //writefln("configureFrame 5");
300 //writefln("configureFrame 6");
302 //writefln("configureFrame 7");
305 //writefln("configureFrame 8");
307 //writefln("configureFrame 9");
320 void mapFrame(Widget widget
)
322 //printf("GLCapabilityT.mapFrame \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 bool consumeEvent
= typeof(this).onMap();
336 if ( drawable
.isDoubleBuffered() )
338 drawable
.swapBuffers();
348 //return consumeEvent;
351 void unmapFrame(Widget widget
)
353 //printf("GLCapabilityT.unmapFrame \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).onUnmap();
367 if ( drawable
.isDoubleBuffered() )
369 drawable
.swapBuffers();
379 //return consumeEvent;
382 int visibilityFrame(GdkEventVisibility
* event
, Widget widget
)
384 //printf("GLCapabilityT.visibilityFrame \n" );
385 GLContext context
= GLWidget
.getGLContext(widget
);
386 GLDrawable drawable
= GLWidget
.getGLDrawable(widget
);
388 /*** OpenGL BEGIN ***/
389 if ( !drawable
.glBegin(context
) )
394 /*** do user actions ***/
395 bool consumeEvent
= typeof(this).onVisibility(event
);
398 if ( drawable
.isDoubleBuffered() )
400 drawable
.swapBuffers();
415 //printf("GLCapabilityT.map \n" );
421 //printf("GLCapabilityT.unmap \n" );
425 bool onVisibility(GdkEventVisibility
* event
)
427 //printf("GLCapabilityT.visibility \n" );