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 gdk.GLTexture;
26 
27 private import gdk.GLContext;
28 private import gdk.Texture;
29 private import gdk.c.functions;
30 public  import gdk.c.types;
31 private import glib.ConstructionException;
32 private import gobject.ObjectG;
33 
34 
35 /**
36  * A GdkTexture representing a GL texture object.
37  */
38 public class GLTexture : Texture
39 {
40 	/** the main Gtk struct */
41 	protected GdkGLTexture* gdkGLTexture;
42 
43 	/** Get the main Gtk struct */
44 	public GdkGLTexture* getGLTextureStruct(bool transferOwnership = false)
45 	{
46 		if (transferOwnership)
47 			ownedRef = false;
48 		return gdkGLTexture;
49 	}
50 
51 	/** the main Gtk struct as a void* */
52 	protected override void* getStruct()
53 	{
54 		return cast(void*)gdkGLTexture;
55 	}
56 
57 	/**
58 	 * Sets our main struct and passes it to the parent class.
59 	 */
60 	public this (GdkGLTexture* gdkGLTexture, bool ownedRef = false)
61 	{
62 		this.gdkGLTexture = gdkGLTexture;
63 		super(cast(GdkTexture*)gdkGLTexture, ownedRef);
64 	}
65 
66 
67 	/** */
68 	public static GType getType()
69 	{
70 		return gdk_gl_texture_get_type();
71 	}
72 
73 	/**
74 	 * Creates a new texture for an existing GL texture.
75 	 *
76 	 * Note that the GL texture must not be modified until @destroy is called,
77 	 * which will happen when the GdkTexture object is finalized, or due to
78 	 * an explicit call of [method@Gdk.GLTexture.release].
79 	 *
80 	 * Params:
81 	 *     context = a `GdkGLContext`
82 	 *     id = the ID of a texture that was created with @context
83 	 *     width = the nominal width of the texture
84 	 *     height = the nominal height of the texture
85 	 *     destroy = a destroy notify that will be called when the GL resources
86 	 *         are released
87 	 *     data = data that gets passed to @destroy
88 	 *
89 	 * Returns: A newly-created `GdkTexture`
90 	 *
91 	 * Throws: ConstructionException GTK+ fails to create the object.
92 	 */
93 	public this(GLContext context, uint id, int width, int height, GDestroyNotify destroy, void* data)
94 	{
95 		auto __p = gdk_gl_texture_new((context is null) ? null : context.getGLContextStruct(), id, width, height, destroy, data);
96 
97 		if(__p is null)
98 		{
99 			throw new ConstructionException("null returned by new");
100 		}
101 
102 		this(cast(GdkGLTexture*) __p, true);
103 	}
104 
105 	/**
106 	 * Releases the GL resources held by a `GdkGLTexture`.
107 	 *
108 	 * The texture contents are still available via the
109 	 * [method@Gdk.Texture.download] function, after this
110 	 * function has been called.
111 	 */
112 	public void release()
113 	{
114 		gdk_gl_texture_release(gdkGLTexture);
115 	}
116 }