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