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-gdkglcontext.html 27 * outPack = glgdk 28 * outFile = GLContext 29 * strct = GdkGLContext 30 * realStrct= 31 * ctorStrct= 32 * clss = GLContext 33 * interf = 34 * class Code: No 35 * interface Code: No 36 * template for: 37 * extend = 38 * implements: 39 * prefixes: 40 * - gdk_gl_context_ 41 * omit structs: 42 * omit prefixes: 43 * omit code: 44 * omit signals: 45 * imports: 46 * - glgdk.GLDrawable 47 * - glgdk.GLConfig 48 * structWrap: 49 * - GdkGLConfig* -> GLConfig 50 * - GdkGLContext* -> GLContext 51 * - GdkGLDrawable* -> GLDrawable 52 * module aliases: 53 * local aliases: 54 * overrides: 55 */ 56 57 module glgdk.GLContext; 58 59 public import gtkglc.glgdktypes; 60 61 private import gtkglc.glgdk; 62 private import glib.ConstructionException; 63 private import gobject.ObjectG; 64 65 66 private import glgdk.GLDrawable; 67 private import glgdk.GLConfig; 68 69 70 71 private import gobject.ObjectG; 72 73 /** 74 * Description 75 */ 76 public class GLContext : ObjectG 77 { 78 79 /** the main Gtk struct */ 80 protected GdkGLContext* gdkGLContext; 81 82 83 public GdkGLContext* getGLContextStruct() 84 { 85 return gdkGLContext; 86 } 87 88 89 /** the main Gtk struct as a void* */ 90 protected override void* getStruct() 91 { 92 return cast(void*)gdkGLContext; 93 } 94 95 /** 96 * Sets our main struct and passes it to the parent class 97 */ 98 public this (GdkGLContext* gdkGLContext) 99 { 100 super(cast(GObject*)gdkGLContext); 101 this.gdkGLContext = gdkGLContext; 102 } 103 104 protected override void setStruct(GObject* obj) 105 { 106 super.setStruct(obj); 107 gdkGLContext = cast(GdkGLContext*)obj; 108 } 109 110 /** 111 */ 112 113 /** 114 * Creates a new OpenGL rendering context. 115 * Params: 116 * gldrawable = a GdkGLDrawable. 117 * shareList = the GdkGLContext with which to share display lists and texture 118 * objects. NULL indicates that no sharing is to take place. 119 * direct = whether rendering is to be done with a direct connection to 120 * the graphics system. 121 * renderType = GDK_GL_RGBA_TYPE or GDK_GL_COLOR_INDEX_TYPE (currently not 122 * used). 123 * Throws: ConstructionException GTK+ fails to create the object. 124 */ 125 public this (GLDrawable gldrawable, GLContext shareList, int direct, int renderType) 126 { 127 // GdkGLContext* gdk_gl_context_new (GdkGLDrawable *gldrawable, GdkGLContext *share_list, gboolean direct, int render_type); 128 auto p = gdk_gl_context_new((gldrawable is null) ? null : gldrawable.getGLDrawableStruct(), (shareList is null) ? null : shareList.getGLContextStruct(), direct, renderType); 129 if(p is null) 130 { 131 throw new ConstructionException("null returned by gdk_gl_context_new((gldrawable is null) ? null : gldrawable.getGLDrawableStruct(), (shareList is null) ? null : shareList.getGLContextStruct(), direct, renderType)"); 132 } 133 this(cast(GdkGLContext*) p); 134 } 135 136 /** 137 * Destroys the OpenGL resources associated with glcontext and 138 * decrements glcontext's reference count. 139 */ 140 public void destroy() 141 { 142 // void gdk_gl_context_destroy (GdkGLContext *glcontext); 143 gdk_gl_context_destroy(gdkGLContext); 144 } 145 146 /** 147 * Copy state from src rendering context to glcontext. 148 * mask contains the bitwise-OR of the same symbolic names that are passed to 149 * the glPushAttrib() function. You can use GL_ALL_ATTRIB_BITS to copy all the 150 * rendering state information. 151 * Params: 152 * src = the source context. 153 * Returns: FALSE if it fails, TRUE otherwise. 154 */ 155 public int copy(GLContext src, ulong mask) 156 { 157 // gboolean gdk_gl_context_copy (GdkGLContext *glcontext, GdkGLContext *src, unsigned long mask); 158 return gdk_gl_context_copy(gdkGLContext, (src is null) ? null : src.getGLContextStruct(), mask); 159 } 160 161 /** 162 * Gets GdkGLDrawable to which the glcontext is bound. 163 * Returns: the GdkGLDrawable or NULL if no GdkGLDrawable is bound. 164 */ 165 public GLDrawable getGLDrawable() 166 { 167 // GdkGLDrawable* gdk_gl_context_get_gl_drawable (GdkGLContext *glcontext); 168 auto p = gdk_gl_context_get_gl_drawable(gdkGLContext); 169 170 if(p is null) 171 { 172 return null; 173 } 174 175 return ObjectG.getDObject!(GLDrawable)(cast(GdkGLDrawable*) p); 176 } 177 178 /** 179 * Gets GdkGLConfig with which the glcontext is configured. 180 * Returns: the GdkGLConfig. 181 */ 182 public GLConfig getGLConfig() 183 { 184 // GdkGLConfig* gdk_gl_context_get_gl_config (GdkGLContext *glcontext); 185 auto p = gdk_gl_context_get_gl_config(gdkGLContext); 186 187 if(p is null) 188 { 189 return null; 190 } 191 192 return ObjectG.getDObject!(GLConfig)(cast(GdkGLConfig*) p); 193 } 194 195 /** 196 * Gets GdkGLContext with which the glcontext shares the display lists and 197 * texture objects. 198 * Returns: the GdkGLContext. 199 */ 200 public GLContext getShareList() 201 { 202 // GdkGLContext* gdk_gl_context_get_share_list (GdkGLContext *glcontext); 203 auto p = gdk_gl_context_get_share_list(gdkGLContext); 204 205 if(p is null) 206 { 207 return null; 208 } 209 210 return ObjectG.getDObject!(GLContext)(cast(GdkGLContext*) p); 211 } 212 213 /** 214 * Returns whether the glcontext is a direct rendering context. 215 * Returns: TRUE if the glcontext is a direct rendering contest. 216 */ 217 public int isDirect() 218 { 219 // gboolean gdk_gl_context_is_direct (GdkGLContext *glcontext); 220 return gdk_gl_context_is_direct(gdkGLContext); 221 } 222 223 /** 224 * Gets render_type of the glcontext. 225 * Returns: GDK_GL_RGBA_TYPE or GDK_GL_COLOR_INDEX_TYPE. 226 */ 227 public int getRenderType() 228 { 229 // int gdk_gl_context_get_render_type (GdkGLContext *glcontext); 230 return gdk_gl_context_get_render_type(gdkGLContext); 231 } 232 233 /** 234 * Returns the current GdkGLContext. 235 * Returns: the current GdkGLContext or NULL if there is no current context. <<Frame Buffer Configuration Rendering Surface>> 236 */ 237 public static GLContext getCurrent() 238 { 239 // GdkGLContext* gdk_gl_context_get_current (void); 240 auto p = gdk_gl_context_get_current(); 241 242 if(p is null) 243 { 244 return null; 245 } 246 247 return ObjectG.getDObject!(GLContext)(cast(GdkGLContext*) p); 248 } 249 }