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