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