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