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 
67 private import glib.Str;
68 private import gdk.Screen;
69 private import gdk.Visual;
70 
71 
72 version(Tango) {
73 	private import tango.io.Stdout;
74 } else {
75 	private import std.stdio;
76 }
77 
78 
79 private import gobject.ObjectG;
80 
81 /**
82  */
83 public class GLConfig : ObjectG
84 {
85 	
86 	/** the main Gtk struct */
87 	protected GdkGLConfig* gdkGLConfig;
88 	
89 	
90 	public GdkGLConfig* getGLConfigStruct()
91 	{
92 		return gdkGLConfig;
93 	}
94 	
95 	
96 	/** the main Gtk struct as a void* */
97 	protected override void* getStruct()
98 	{
99 		return cast(void*)gdkGLConfig;
100 	}
101 	
102 	/**
103 	 * Sets our main struct and passes it to the parent class
104 	 */
105 	public this (GdkGLConfig* gdkGLConfig)
106 	{
107 		super(cast(GObject*)gdkGLConfig);
108 		this.gdkGLConfig = gdkGLConfig;
109 	}
110 	
111 	protected override void setStruct(GObject* obj)
112 	{
113 		super.setStruct(obj);
114 		gdkGLConfig = cast(GdkGLConfig*)obj;
115 	}
116 	
117 	/**
118 	 * Creates a mew OpenGL frame buffer configuration that match the specified display mode,
119 	 * or the fallback mode.
120 	 * Params:
121 	 *  mode = display mode bit mask.
122 	 *  fallback = Try this mode if first fails.
123 	 * Throws: ConstructionException if configuring GL fails
124 	 */
125 	this(GLConfigMode mode, GLConfigMode fallback)
126 	{
127 		
128 		gdkGLConfig = cast(GdkGLConfig*)gdk_gl_config_new_by_mode(mode);
129 		if ( gdkGLConfig is null )
130 		{
131 			version(Tango)
132 			{
133 				Stdout("*** Cannot find the double-buffered visual.").newline;
134 				Stdout("*** Trying single-buffered visual.").newline;
135 			}
136 			else
137 			{
138 				writefln("*** Cannot find the double-buffered visual.");
139 				writefln("*** Trying single-buffered visual.");
140 			}
141 			gdkGLConfig = cast(GdkGLConfig*)gdk_gl_config_new_by_mode(fallback);
142 		}
143 		if ( gdkGLConfig is null )
144 		{
145 			version(Tango)
146 			{
147 				Stdout("*** No appropriate OpenGL-capable visual found.").newline;
148 			}
149 			else
150 			{
151 				writefln("*** No appropriate OpenGL-capable visual found.");
152 			}
153 			throw new ConstructionException("GL configure failed");
154 		}
155 		this(gdkGLConfig);
156 	}
157 	
158 	/**
159 	 */
160 	
161 	/**
162 	 * Returns an OpenGL frame buffer configuration that match the specified
163 	 * attributes.
164 	 * attrib_list is a int array that contains the attribute/value pairs.
165 	 * Params:
166 	 * attribList = a list of attribute/value pairs. [array length=n_attribs]
167 	 * Throws: ConstructionException GTK+ fails to create the object.
168 	 */
169 	public this (int[] attribList)
170 	{
171 		// GdkGLConfig * gdk_gl_config_new (const int *attrib_list,  gsize n_attribs);
172 		auto p = gdk_gl_config_new(attribList.ptr, cast(int) attribList.length);
173 		if(p is null)
174 		{
175 			throw new ConstructionException("null returned by gdk_gl_config_new(attribList.ptr, cast(int) attribList.length)");
176 		}
177 		this(cast(GdkGLConfig*) p);
178 	}
179 	
180 	/**
181 	 * Returns an OpenGL frame buffer configuration that match the specified
182 	 * attributes.
183 	 * attrib_list is a int array that contains the attribute/value pairs.
184 	 * Params:
185 	 * screen = target screen.
186 	 * attribList = a list of attribute/value pairs. [array length=n_attribs]
187 	 * Throws: ConstructionException GTK+ fails to create the object.
188 	 */
189 	public this (Screen screen, int[] attribList)
190 	{
191 		// GdkGLConfig * gdk_gl_config_new_for_screen (GdkScreen *screen,  const int *attrib_list,  gsize n_attribs);
192 		auto p = gdk_gl_config_new_for_screen((screen is null) ? null : screen.getScreenStruct(), attribList.ptr, cast(int) attribList.length);
193 		if(p is null)
194 		{
195 			throw new ConstructionException("null returned by gdk_gl_config_new_for_screen((screen is null) ? null : screen.getScreenStruct(), attribList.ptr, cast(int) attribList.length)");
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 	 * mode = display mode bit mask.
205 	 * Throws: ConstructionException GTK+ fails to create the object.
206 	 */
207 	public this (GdkGLConfigMode mode)
208 	{
209 		// GdkGLConfig * gdk_gl_config_new_by_mode (GdkGLConfigMode mode);
210 		auto p = gdk_gl_config_new_by_mode(mode);
211 		if(p is null)
212 		{
213 			throw new ConstructionException("null returned by gdk_gl_config_new_by_mode(mode)");
214 		}
215 		this(cast(GdkGLConfig*) p);
216 	}
217 	
218 	/**
219 	 * Returns an OpenGL frame buffer configuration that match the specified
220 	 * display mode.
221 	 * Params:
222 	 * screen = target screen.
223 	 * mode = display mode bit mask.
224 	 * Throws: ConstructionException GTK+ fails to create the object.
225 	 */
226 	public this (Screen screen, GdkGLConfigMode mode)
227 	{
228 		// GdkGLConfig * gdk_gl_config_new_by_mode_for_screen  (GdkScreen *screen,  GdkGLConfigMode mode);
229 		auto p = gdk_gl_config_new_by_mode_for_screen((screen is null) ? null : screen.getScreenStruct(), mode);
230 		if(p is null)
231 		{
232 			throw new ConstructionException("null returned by gdk_gl_config_new_by_mode_for_screen((screen is null) ? null : screen.getScreenStruct(), mode)");
233 		}
234 		this(cast(GdkGLConfig*) p);
235 	}
236 	
237 	/**
238 	 * Gets GdkScreen.
239 	 * Returns: the GdkScreen.
240 	 */
241 	public Screen getScreen()
242 	{
243 		// GdkScreen * gdk_gl_config_get_screen (GdkGLConfig *glconfig);
244 		auto p = gdk_gl_config_get_screen(gdkGLConfig);
245 		
246 		if(p is null)
247 		{
248 			return null;
249 		}
250 		
251 		return ObjectG.getDObject!(Screen)(cast(GdkScreen*) p);
252 	}
253 	
254 	/**
255 	 * Gets information about a OpenGL frame buffer configuration.
256 	 * Params:
257 	 * attribute = the attribute to be returned.
258 	 * value = returns the requested value.
259 	 * Returns: TRUE if it succeeded, FALSE otherwise.
260 	 */
261 	public int getAttrib(int attribute, out int value)
262 	{
263 		// gboolean gdk_gl_config_get_attrib (GdkGLConfig *glconfig,  int attribute,  int *value);
264 		return gdk_gl_config_get_attrib(gdkGLConfig, attribute, &value);
265 	}
266 	
267 	/**
268 	 * Gets the GdkVisual that is appropriate for the OpenGL frame buffer
269 	 * configuration.
270 	 * Returns: the appropriate GdkVisual.
271 	 */
272 	public Visual getVisual()
273 	{
274 		// GdkVisual * gdk_gl_config_get_visual (GdkGLConfig *glconfig);
275 		auto p = gdk_gl_config_get_visual(gdkGLConfig);
276 		
277 		if(p is null)
278 		{
279 			return null;
280 		}
281 		
282 		return ObjectG.getDObject!(Visual)(cast(GdkVisual*) p);
283 	}
284 	
285 	/**
286 	 * Gets the color depth of the OpenGL-capable visual.
287 	 * Returns: number of bits per pixel
288 	 */
289 	public int getDepth()
290 	{
291 		// gint gdk_gl_config_get_depth (GdkGLConfig *glconfig);
292 		return gdk_gl_config_get_depth(gdkGLConfig);
293 	}
294 	
295 	/**
296 	 * Gets the layer plane (level) of the frame buffer.
297 	 * Zero is the default frame buffer.
298 	 * Positive layer planes correspond to frame buffers that overlay the default
299 	 * buffer, and negative layer planes correspond to frame buffers that underlie
300 	 * the default frame buffer.
301 	 * Returns: layer plane.
302 	 */
303 	public int getLayerPlane()
304 	{
305 		// gint gdk_gl_config_get_layer_plane (GdkGLConfig *glconfig);
306 		return gdk_gl_config_get_layer_plane(gdkGLConfig);
307 	}
308 	
309 	/**
310 	 * Gets the number of auxiliary color buffers.
311 	 * Returns: number of auxiliary color buffers.
312 	 */
313 	public int getNAuxBuffers()
314 	{
315 		// gint gdk_gl_config_get_n_aux_buffers (GdkGLConfig *glconfig);
316 		return gdk_gl_config_get_n_aux_buffers(gdkGLConfig);
317 	}
318 	
319 	/**
320 	 * Gets the number of multisample buffers.
321 	 * Returns: number of multisample buffers.
322 	 */
323 	public int getNSampleBuffers()
324 	{
325 		// gint gdk_gl_config_get_n_sample_buffers (GdkGLConfig *glconfig);
326 		return gdk_gl_config_get_n_sample_buffers(gdkGLConfig);
327 	}
328 	
329 	/**
330 	 * Returns whether the configured frame buffer is RGBA mode.
331 	 * Returns: TRUE if the configured frame buffer is RGBA mode, FALSE otherwise.
332 	 */
333 	public int isRgba()
334 	{
335 		// gboolean gdk_gl_config_is_rgba (GdkGLConfig *glconfig);
336 		return gdk_gl_config_is_rgba(gdkGLConfig);
337 	}
338 	
339 	/**
340 	 * Returns whether the configuration supports the double-buffered visual.
341 	 * Returns: TRUE if the double-buffered visual is supported, FALSE otherwise.
342 	 */
343 	public int isDoubleBuffered()
344 	{
345 		// gboolean gdk_gl_config_is_double_buffered (GdkGLConfig *glconfig);
346 		return gdk_gl_config_is_double_buffered(gdkGLConfig);
347 	}
348 	
349 	/**
350 	 * Returns whether the configuration supports the stereo visual.
351 	 * Returns: TRUE if the stereo visual is supported, FALSE otherwise.
352 	 */
353 	public int isStereo()
354 	{
355 		// gboolean gdk_gl_config_is_stereo (GdkGLConfig *glconfig);
356 		return gdk_gl_config_is_stereo(gdkGLConfig);
357 	}
358 	
359 	/**
360 	 * Returns whether the configured color buffer has alpha bits.
361 	 * Returns: TRUE if the color buffer has alpha bits, FALSE otherwise.
362 	 */
363 	public int hasAlpha()
364 	{
365 		// gboolean gdk_gl_config_has_alpha (GdkGLConfig *glconfig);
366 		return gdk_gl_config_has_alpha(gdkGLConfig);
367 	}
368 	
369 	/**
370 	 * Returns whether the configured frame buffer has depth buffer.
371 	 * Returns: TRUE if the frame buffer has depth buffer, FALSE otherwise.
372 	 */
373 	public int hasDepthBuffer()
374 	{
375 		// gboolean gdk_gl_config_has_depth_buffer (GdkGLConfig *glconfig);
376 		return gdk_gl_config_has_depth_buffer(gdkGLConfig);
377 	}
378 	
379 	/**
380 	 * Returns whether the configured frame buffer has stencil buffer.
381 	 * Returns: TRUE if the frame buffer has stencil buffer, FALSE otherwise.
382 	 */
383 	public int hasStencilBuffer()
384 	{
385 		// gboolean gdk_gl_config_has_stencil_buffer (GdkGLConfig *glconfig);
386 		return gdk_gl_config_has_stencil_buffer(gdkGLConfig);
387 	}
388 	
389 	/**
390 	 * Returns whether the configured frame buffer has accumulation buffer.
391 	 * Returns: TRUE if the frame buffer has accumulation buffer, FALSE otherwise.
392 	 */
393 	public int hasAccumBuffer()
394 	{
395 		// gboolean gdk_gl_config_has_accum_buffer (GdkGLConfig *glconfig);
396 		return gdk_gl_config_has_accum_buffer(gdkGLConfig);
397 	}
398 }