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