alternative to assert
[gtkD.git] / wrap / APILookupGLt.txt
blob032c2ebaaa1a1e3a6dfcd711e16dacc4be54b316
2 # This file is part of duit.
3
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.
8
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.
13
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
21 ###
22 #####
23 # Definitions for wrapping gtk gl ext GL
24 #####
25 ###
29 addTypedefs: start
31 public import glib.glibtypes;
32 public import glgdk.glgdktypes;
33 public import gtk.gtktypes;
35 addTypedefs: end
37 addAliases: start
38 addAliases: end
40 addEnums: start
41 addEnums: end
43 addStructs: start
44 addStructs: end
46 addTypes: start
47 addTypes: end
49 addFuncts: start
50 addFuncts: end
52 addUnions: start
53 addUnions: end
55 addConstants: start
56 addConstants: end
59 # must start with wrap
61 wrap: glgtk
62 srcout: srcgl
64 ###########################################################
65 ### GL ####################################################
66 ###########################################################
68 file: /usr/share/doc/libgtkglext1-doc/html/gtkglext/gtkglext-gtkglinit.html
70 #struct: GMutex
71 class: GLtInit
72 prefix: gtk_gl_
73 outFile: GLtInit
76 file: /usr/share/doc/libgtkglext1-doc/html/gtkglext/gtkglext-gtkglwidget.html
78 #struct: GtkGLWidget
79 class: GLWidget
80 prefix: gtk_widget_
81 import: gtk.Widget
82 structWrap: GtkWidget* Widget
84 import: glgdk.GLDrawable
85 structWrap: GdkGLDrawable* Drawable
87 import: glgdk.GLConfig
88 structWrap: GdkGLConfig* GLConfig
90 import: glgdk.GLContext
91 structWrap: GdkGLContext* GLContext
93 import: glgdk.GLWindow
94 structWrap: GdkGLWindow* GLWindow
96 code: start
97         /**
98          * Gets the GL Frawable for (from???) the widget
99          * @param widget
100          * @return a new GLDrawable
101          */
102         static GLDrawable getGLDrawable(Widget widget)
103         {
104                 return new GLDrawable(cast(GdkGLDrawable*)gtk_widget_get_gl_window((widget is null) ? null : widget.getWidgetStruct()));
105         }       
107 code: end
109 outFile: GLWidget
111 file: /usr/share/doc/libgtkglext1-doc/html/gtkglext/gtkglext-gtkglversion.html
113 #struct: GtkGLVersion
114 class: GLtVersion
115 prefix: gtk_gl_version_
116 outFile: GLtVersion
118 file: 
120 code: start
122 // SNEAKY MIXIN PROBLEM:
124 // These need to be public imports
125 // or GLCompatibility will not compile
126 // as a mixin in other modules!
128 // May as well be explicit about it:
131 public import std.stdio;
132 public import glgtk.GLWidget;
133 private import glgdk.GLDrawable;
134 public import gdk.Event;
135 public import lib.gl;
138 template GLCapability()
140         
141         GLfloat width = 0;
142         GLfloat height = 0;
143         
144         GLfloat getGLWidth()
145         {
146                 return width;
147         }
148         GLfloat getGLHeight()
149         {
150                 return height;
151         }
154         /**
155          * Sets the GL capabilities for the widget
156          */
157         bit setGLCapability(GLConfig glConfig = null, int renderType = GLRenderType.RGBA_TYPE)
158         {
159                 if ( glConfig is null )
160                 {
161                         glConfig = new GLConfig(
162                         GLConfigMode.MODE_RGB
163                         | GLConfigMode.MODE_DEPTH
164                         | GLConfigMode.MODE_DOUBLE,
165                         GLConfigMode.MODE_RGB
166                         | GLConfigMode.MODE_DEPTH
167                         );
168                 }
169                 bit ok = setGLCapability(this, glConfig, null, true, renderType);
170                 
171                 return ok;
172         }
173         
174         /**
175          * Set the GL capabilities for the widget
176          */
177         bit setGLCapability(Widget widget, GLConfig glConfig, GLContext shareList, bit direct, int renderType)
178         {
179                 GLWidget.setGLCapability(widget, glConfig, shareList, direct, renderType);
180                 
181                 addOnRealize(&realizeFrame);
182                 addOnUnrealize(&realizeFrame);
183                 addOnExpose(&exposeFrame);
184                 addOnConfigure(&configureFrame);
185                 addOnMap(&mapFrame);
186                 addOnUnmap(&unmapFrame);
187                 addOnVisibilityNotify(&visibilityFrame);
188                 return true;
189         }
190         
191         /**
192          * The widget should use this method to redraw it self at any time
193          */
194         public bit glDrawFrame()
195         {
196                 return glDrawFrame(this);
197         }
198         
199         /**
200          * The application should use this method to redraw the scene at any time
201          */
202         bit glDrawFrame(Widget widget)
203         {
204                 //printf("GLCapabilityT.realizeFrame \n" );
205                 GLContext context = GLWidget.getGLContext(widget);
206                 GLDrawable drawable = GLWidget.getGLDrawable(widget);
207                 
208                 /*** OpenGL BEGIN ***/
209                 if ( !drawable.glBegin(context) )
210                 {
211                         return false;
212                 }
213                 
214                 /*** do user actions ***/
215                 bit consumeEvent = typeof(this).drawGL(null);
216                 
217                 /*** flush ***/
218                 if ( drawable.isDoubleBuffered() )
219                 {
220                         drawable.swapBuffers();
221                 }
222                 else
223                 {
224                         glFlush ();
225                 }
226                 
227                 drawable.glEnd();
228                 /*** OpenGL END ***/
229                 return true;
230                 
231         }
232         
233         bool alreadyRealized;
234         
235         bool getAlreadyRealized()
236         {
237                 return alreadyRealized;
238         }
239         
240         void realizeFrame(Widget widget)
241         {
242                 alreadyRealized = true;
243                 
244                 //printf("GLCapabilityT.realizeFrame \n" );
245                 GLContext context = GLWidget.getGLContext(widget);
246                 GLDrawable drawable = GLWidget.getGLDrawable(widget);
247                 
248                 /*** OpenGL BEGIN ***/
249                 if ( !drawable.glBegin(context) )
250                 {
251                         return false;
252                 }
253                 
254                 /*** do user actions ***/
255                 bit consumeEvent = typeof(this).initGL();
256                 
257                 /*** flush ***/
258                 if ( drawable.isDoubleBuffered() )
259                 {
260                         drawable.swapBuffers();
261                 }
262                 else
263                 {
264                         glFlush ();
265                 }
266                 
267                 drawable.glEnd();
268                 /*** OpenGL END ***/
269                 
270                 //return consumeEvent;
271         }
272         
273         int exposeFrame(GdkEventExpose* event, Widget widget)
274         {
275                 //printf("GLCapabilityT.exposeFrame exposeFrame\n" );
276                 GLContext context = GLWidget.getGLContext(widget);
277                 GLDrawable drawable = GLWidget.getGLDrawable(widget);
278                 
279                 /*** OpenGL BEGIN ***/
280                 if ( !drawable.glBegin(context) )
281                 {
282                         return false;
283                 }
284                 
285                 /*** do user actions ***/
286                 int consumeEvent = typeof(this).drawGL(event);
287                 
288                 /*** flush ***/
289                 if ( drawable.isDoubleBuffered() )
290                 {
291                         drawable.swapBuffers();
292                 }
293                 else
294                 {
295                         glFlush ();
296                 }
297                 
298                 drawable.glEnd();
299                 /*** OpenGL END ***/
300                 
301                 return consumeEvent;
302         }
303         
304         private import std.gc;
305         
306         int configureFrame(GdkEventConfigure* event, Widget widget)
307         {
308                 if ( event != null )
309                 {
310                         width = event.width;
311                         height = event.height;
312                 }
313                 std.gc.disable();
314                 //writefln("configureFrame 1");
315                 //printf("GLCapabilityT.configureFrame \n" );
316                 GLContext context = GLWidget.getGLContext(widget);
317                 GLDrawable drawable = GLWidget.getGLDrawable(widget);
318                 
319                 /*** OpenGL BEGIN ***/
320                 if ( !drawable.glBegin(context) )
321                 {
322                         return false;
323                 }
324                 
325                 //writefln("configureFrame 2");
326                 /*** do user actions ***/
327                 int consumeEvent = typeof(this).resizeGL(event);
328                 //printf("here\n");
329                 //writefln("configureFrame 3");
330                 
331                 /*** flush ***/
332                 if ( drawable.isDoubleBuffered() )
333                 {
334                         //writefln("configureFrame 4");
335                         drawable.swapBuffers();
336                         //writefln("configureFrame 5");
337                 }
338                 else
339                 {
340                         //writefln("configureFrame 6");
341                         glFlush ();
342                         //writefln("configureFrame 7");
343                 }
344                 
345                 //writefln("configureFrame 8");
346                 drawable.glEnd();
347                 //writefln("configureFrame 9");
348                 /*** OpenGL END ***/
349                 
350                 std.gc.enable();
351                 return consumeEvent;
352         }
353         
354         void mapFrame(Widget widget)
355         {
356                 //printf("GLCapabilityT.mapFrame \n" );
357                 GLContext context = GLWidget.getGLContext(widget);
358                 GLDrawable drawable = GLWidget.getGLDrawable(widget);
359                 
360                 /*** OpenGL BEGIN ***/
361                 if ( !drawable.glBegin(context) )
362                 {
363                         return false;
364                 }
365                 
366                 /*** do user actions ***/
367                 bit consumeEvent = typeof(this).onMap();
368                 
369                 /*** flush ***/
370                 if ( drawable.isDoubleBuffered() )
371                 {
372                         drawable.swapBuffers();
373                 }
374                 else
375                 {
376                         glFlush ();
377                 }
378                 
379                 drawable.glEnd();
380                 /*** OpenGL END ***/
381                 
382                 //return consumeEvent;
383         }
384         
385         void unmapFrame(Widget widget)
386         {
387                 //printf("GLCapabilityT.unmapFrame \n" );
388                 GLContext context = GLWidget.getGLContext(widget);
389                 GLDrawable drawable = GLWidget.getGLDrawable(widget);
390                 
391                 /*** OpenGL BEGIN ***/
392                 if ( !drawable.glBegin(context) )
393                 {
394                         return false;
395                 }
396                 
397                 /*** do user actions ***/
398                 bit consumeEvent = typeof(this).onUnmap();
399                 
400                 /*** flush ***/
401                 if ( drawable.isDoubleBuffered() )
402                 {
403                         drawable.swapBuffers();
404                 }
405                 else
406                 {
407                         glFlush ();
408                 }
409                 
410                 drawable.glEnd();
411                 /*** OpenGL END ***/
412                 
413                 //return consumeEvent;
414         }
415         
416         int visibilityFrame(GdkEventVisibility* event, Widget widget)
417         {
418                 //printf("GLCapabilityT.visibilityFrame \n" );
419                 GLContext context = GLWidget.getGLContext(widget);
420                 GLDrawable drawable = GLWidget.getGLDrawable(widget);
421                 
422                 /*** OpenGL BEGIN ***/
423                 if ( !drawable.glBegin(context) )
424                 {
425                         return false;
426                 }
427                 
428                 /*** do user actions ***/
429                 bool consumeEvent = typeof(this).onVisibility(event);
430                 
431                 /*** flush ***/
432                 if ( drawable.isDoubleBuffered() )
433                 {
434                         drawable.swapBuffers();
435                 }
436                 else
437                 {
438                         glFlush ();
439                 }
440                 
441                 drawable.glEnd();
442                 /*** OpenGL END ***/
443                 
444                 return consumeEvent;
445         }
446         
447         bit onMap()
448         {
449                 //printf("GLCapabilityT.map \n" );
450                 return true;
451         }
452         
453         bit onUnmap()
454         {
455                 //printf("GLCapabilityT.unmap \n" );
456                 return true;
457         }
458         
459         bool onVisibility(GdkEventVisibility* event)
460         {
461                 //printf("GLCapabilityT.visibility \n" );
462                 return true;
463         }
466 code: end
467 outFile: GLCapability