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