1 /* 2 * This file is part of gtkD. 3 * 4 * gtkD is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU Lesser General Public License 6 * as published by the Free Software Foundation; either version 3 7 * of the License, or (at your option) any later version, with 8 * some exceptions, please read the COPYING file. 9 * 10 * gtkD is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU Lesser General Public License for more details. 14 * 15 * You should have received a copy of the GNU Lesser General Public License 16 * along with gtkD; if not, write to the Free Software 17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA 18 */ 19 20 // generated automatically - do not change 21 // find conversion definition on APILookup.txt 22 // implement new conversion functionalities on the wrap.utils pakage 23 24 /* 25 * Conversion parameters: 26 * inFile = gtkglext-gdkglconfig.html 27 * outPack = glgdk 28 * outFile = GLConfig 29 * strct = GdkGLConfig 30 * realStrct= 31 * ctorStrct= 32 * clss = GLConfig 33 * interf = 34 * class Code: Yes 35 * interface Code: No 36 * template for: 37 * extend = 38 * implements: 39 * prefixes: 40 * - gdk_gl_config_ 41 * omit structs: 42 * omit prefixes: 43 * omit code: 44 * omit signals: 45 * imports: 46 * - std.stdio 47 * - glib.Str 48 * - gdk.Screen 49 * - gdk.Visual 50 * structWrap: 51 * - GdkScreen* -> Screen 52 * - GdkVisual* -> Visual 53 * module aliases: 54 * local aliases: 55 * overrides: 56 */ 57 58 module glgdk.GLConfig; 59 60 public import gtkglc.glgdktypes; 61 62 private import gtkglc.glgdk; 63 private import glib.ConstructionException; 64 private import gobject.ObjectG; 65 66 private import std.stdio; 67 private import glib.Str; 68 private import gdk.Screen; 69 private import gdk.Visual; 70 71 72 private import gobject.ObjectG; 73 74 /** 75 */ 76 public class GLConfig : ObjectG 77 { 78 79 /** the main Gtk struct */ 80 protected GdkGLConfig* gdkGLConfig; 81 82 83 /** Get the main Gtk struct */ 84 public GdkGLConfig* getGLConfigStruct() 85 { 86 return gdkGLConfig; 87 } 88 89 90 /** the main Gtk struct as a void* */ 91 protected override void* getStruct() 92 { 93 return cast(void*)gdkGLConfig; 94 } 95 96 /** 97 * Sets our main struct and passes it to the parent class 98 */ 99 public this (GdkGLConfig* gdkGLConfig) 100 { 101 super(cast(GObject*)gdkGLConfig); 102 this.gdkGLConfig = gdkGLConfig; 103 } 104 105 protected override void setStruct(GObject* obj) 106 { 107 super.setStruct(obj); 108 gdkGLConfig = cast(GdkGLConfig*)obj; 109 } 110 111 /** 112 * Creates a mew OpenGL frame buffer configuration that match the specified display mode, 113 * or the fallback mode. 114 * Params: 115 * mode = display mode bit mask. 116 * fallback = Try this mode if first fails. 117 * Throws: ConstructionException if configuring GL fails 118 */ 119 this(GLConfigMode mode, GLConfigMode fallback) 120 { 121 gdkGLConfig = cast(GdkGLConfig*)gdk_gl_config_new_by_mode(mode); 122 123 if ( gdkGLConfig is null ) 124 { 125 writefln("*** Cannot find the double-buffered visual."); 126 writefln("*** Trying single-buffered visual."); 127 128 gdkGLConfig = cast(GdkGLConfig*)gdk_gl_config_new_by_mode(fallback); 129 } 130 if ( gdkGLConfig is null ) 131 { 132 writefln("*** No appropriate OpenGL-capable visual found."); 133 134 throw new ConstructionException("GL configure failed"); 135 } 136 137 this(gdkGLConfig); 138 } 139 140 /** 141 */ 142 143 /** 144 * Returns an OpenGL frame buffer configuration that match the specified 145 * attributes. 146 * attrib_list is a int array that contains the attribute/value pairs. 147 * Params: 148 * attribList = a list of attribute/value pairs. [array length=n_attribs] 149 * Throws: ConstructionException GTK+ fails to create the object. 150 */ 151 public this (int[] attribList) 152 { 153 // GdkGLConfig * gdk_gl_config_new (const int *attrib_list, gsize n_attribs); 154 auto p = gdk_gl_config_new(attribList.ptr, cast(int) attribList.length); 155 if(p is null) 156 { 157 throw new ConstructionException("null returned by gdk_gl_config_new(attribList.ptr, cast(int) attribList.length)"); 158 } 159 this(cast(GdkGLConfig*) p); 160 } 161 162 /** 163 * Returns an OpenGL frame buffer configuration that match the specified 164 * attributes. 165 * attrib_list is a int array that contains the attribute/value pairs. 166 * Params: 167 * screen = target screen. 168 * attribList = a list of attribute/value pairs. [array length=n_attribs] 169 * Throws: ConstructionException GTK+ fails to create the object. 170 */ 171 public this (Screen screen, int[] attribList) 172 { 173 // GdkGLConfig * gdk_gl_config_new_for_screen (GdkScreen *screen, const int *attrib_list, gsize n_attribs); 174 auto p = gdk_gl_config_new_for_screen((screen is null) ? null : screen.getScreenStruct(), attribList.ptr, cast(int) attribList.length); 175 if(p is null) 176 { 177 throw new ConstructionException("null returned by gdk_gl_config_new_for_screen((screen is null) ? null : screen.getScreenStruct(), attribList.ptr, cast(int) attribList.length)"); 178 } 179 this(cast(GdkGLConfig*) p); 180 } 181 182 /** 183 * Returns an OpenGL frame buffer configuration that match the specified 184 * display mode. 185 * Params: 186 * mode = display mode bit mask. 187 * Throws: ConstructionException GTK+ fails to create the object. 188 */ 189 public this (GdkGLConfigMode mode) 190 { 191 // GdkGLConfig * gdk_gl_config_new_by_mode (GdkGLConfigMode mode); 192 auto p = gdk_gl_config_new_by_mode(mode); 193 if(p is null) 194 { 195 throw new ConstructionException("null returned by gdk_gl_config_new_by_mode(mode)"); 196 } 197 this(cast(GdkGLConfig*) p); 198 } 199 200 /** 201 * Returns an OpenGL frame buffer configuration that match the specified 202 * display mode. 203 * Params: 204 * screen = target screen. 205 * mode = display mode bit mask. 206 * Throws: ConstructionException GTK+ fails to create the object. 207 */ 208 public this (Screen screen, GdkGLConfigMode mode) 209 { 210 // GdkGLConfig * gdk_gl_config_new_by_mode_for_screen (GdkScreen *screen, GdkGLConfigMode mode); 211 auto p = gdk_gl_config_new_by_mode_for_screen((screen is null) ? null : screen.getScreenStruct(), mode); 212 if(p is null) 213 { 214 throw new ConstructionException("null returned by gdk_gl_config_new_by_mode_for_screen((screen is null) ? null : screen.getScreenStruct(), mode)"); 215 } 216 this(cast(GdkGLConfig*) p); 217 } 218 219 /** 220 * Gets GdkScreen. 221 * Returns: the GdkScreen. 222 */ 223 public Screen getScreen() 224 { 225 // GdkScreen * gdk_gl_config_get_screen (GdkGLConfig *glconfig); 226 auto p = gdk_gl_config_get_screen(gdkGLConfig); 227 228 if(p is null) 229 { 230 return null; 231 } 232 233 return ObjectG.getDObject!(Screen)(cast(GdkScreen*) p); 234 } 235 236 /** 237 * Gets information about a OpenGL frame buffer configuration. 238 * Params: 239 * attribute = the attribute to be returned. 240 * value = returns the requested value. 241 * Returns: TRUE if it succeeded, FALSE otherwise. 242 */ 243 public int getAttrib(int attribute, out int value) 244 { 245 // gboolean gdk_gl_config_get_attrib (GdkGLConfig *glconfig, int attribute, int *value); 246 return gdk_gl_config_get_attrib(gdkGLConfig, attribute, &value); 247 } 248 249 /** 250 * Gets the GdkVisual that is appropriate for the OpenGL frame buffer 251 * configuration. 252 * Returns: the appropriate GdkVisual. 253 */ 254 public Visual getVisual() 255 { 256 // GdkVisual * gdk_gl_config_get_visual (GdkGLConfig *glconfig); 257 auto p = gdk_gl_config_get_visual(gdkGLConfig); 258 259 if(p is null) 260 { 261 return null; 262 } 263 264 return ObjectG.getDObject!(Visual)(cast(GdkVisual*) p); 265 } 266 267 /** 268 * Gets the color depth of the OpenGL-capable visual. 269 * Returns: number of bits per pixel 270 */ 271 public int getDepth() 272 { 273 // gint gdk_gl_config_get_depth (GdkGLConfig *glconfig); 274 return gdk_gl_config_get_depth(gdkGLConfig); 275 } 276 277 /** 278 * Gets the layer plane (level) of the frame buffer. 279 * Zero is the default frame buffer. 280 * Positive layer planes correspond to frame buffers that overlay the default 281 * buffer, and negative layer planes correspond to frame buffers that underlie 282 * the default frame buffer. 283 * Returns: layer plane. 284 */ 285 public int getLayerPlane() 286 { 287 // gint gdk_gl_config_get_layer_plane (GdkGLConfig *glconfig); 288 return gdk_gl_config_get_layer_plane(gdkGLConfig); 289 } 290 291 /** 292 * Gets the number of auxiliary color buffers. 293 * Returns: number of auxiliary color buffers. 294 */ 295 public int getNAuxBuffers() 296 { 297 // gint gdk_gl_config_get_n_aux_buffers (GdkGLConfig *glconfig); 298 return gdk_gl_config_get_n_aux_buffers(gdkGLConfig); 299 } 300 301 /** 302 * Gets the number of multisample buffers. 303 * Returns: number of multisample buffers. 304 */ 305 public int getNSampleBuffers() 306 { 307 // gint gdk_gl_config_get_n_sample_buffers (GdkGLConfig *glconfig); 308 return gdk_gl_config_get_n_sample_buffers(gdkGLConfig); 309 } 310 311 /** 312 * Returns whether the configured frame buffer is RGBA mode. 313 * Returns: TRUE if the configured frame buffer is RGBA mode, FALSE otherwise. 314 */ 315 public int isRgba() 316 { 317 // gboolean gdk_gl_config_is_rgba (GdkGLConfig *glconfig); 318 return gdk_gl_config_is_rgba(gdkGLConfig); 319 } 320 321 /** 322 * Returns whether the configuration supports the double-buffered visual. 323 * Returns: TRUE if the double-buffered visual is supported, FALSE otherwise. 324 */ 325 public int isDoubleBuffered() 326 { 327 // gboolean gdk_gl_config_is_double_buffered (GdkGLConfig *glconfig); 328 return gdk_gl_config_is_double_buffered(gdkGLConfig); 329 } 330 331 /** 332 * Returns whether the configuration supports the stereo visual. 333 * Returns: TRUE if the stereo visual is supported, FALSE otherwise. 334 */ 335 public int isStereo() 336 { 337 // gboolean gdk_gl_config_is_stereo (GdkGLConfig *glconfig); 338 return gdk_gl_config_is_stereo(gdkGLConfig); 339 } 340 341 /** 342 * Returns whether the configured color buffer has alpha bits. 343 * Returns: TRUE if the color buffer has alpha bits, FALSE otherwise. 344 */ 345 public int hasAlpha() 346 { 347 // gboolean gdk_gl_config_has_alpha (GdkGLConfig *glconfig); 348 return gdk_gl_config_has_alpha(gdkGLConfig); 349 } 350 351 /** 352 * Returns whether the configured frame buffer has depth buffer. 353 * Returns: TRUE if the frame buffer has depth buffer, FALSE otherwise. 354 */ 355 public int hasDepthBuffer() 356 { 357 // gboolean gdk_gl_config_has_depth_buffer (GdkGLConfig *glconfig); 358 return gdk_gl_config_has_depth_buffer(gdkGLConfig); 359 } 360 361 /** 362 * Returns whether the configured frame buffer has stencil buffer. 363 * Returns: TRUE if the frame buffer has stencil buffer, FALSE otherwise. 364 */ 365 public int hasStencilBuffer() 366 { 367 // gboolean gdk_gl_config_has_stencil_buffer (GdkGLConfig *glconfig); 368 return gdk_gl_config_has_stencil_buffer(gdkGLConfig); 369 } 370 371 /** 372 * Returns whether the configured frame buffer has accumulation buffer. 373 * Returns: TRUE if the frame buffer has accumulation buffer, FALSE otherwise. 374 */ 375 public int hasAccumBuffer() 376 { 377 // gboolean gdk_gl_config_has_accum_buffer (GdkGLConfig *glconfig); 378 return gdk_gl_config_has_accum_buffer(gdkGLConfig); 379 } 380 }