1 // Generated by gmmproc 2.60.0 -- DO NOT MODIFY!
2 #ifndef _GDKMM_GLCONTEXT_H
3 #define _GDKMM_GLCONTEXT_H
4 
5 
6 #include <glibmm/ustring.h>
7 #include <sigc++/sigc++.h>
8 
9 /* Copyright (C) 2015 The gtkmm Development Team
10  *
11  * This library is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU Lesser General Public
13  * License as published by the Free Software Foundation; either
14  * version 2.1 of the License, or (at your option) any later version.
15  *
16  * This library is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
19  * Lesser General Public License for more details.
20  *
21  * You should have received a copy of the GNU Lesser General Public
22  * License along with this library; if not, write to the Free Software
23  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
24  */
25 
26 #include <gdkmmconfig.h>
27 #include <gdkmm/display.h>
28 #include <gdkmm/window.h>
29 
30 
31 #ifndef DOXYGEN_SHOULD_SKIP_THIS
32 using GdkGLContext = struct _GdkGLContext;
33 using GdkGLContextClass = struct _GdkGLContextClass;
34 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
35 
36 
37 #ifndef DOXYGEN_SHOULD_SKIP_THIS
38 namespace Gdk
39 { class GLContext_Class; } // namespace Gdk
40 #endif //DOXYGEN_SHOULD_SKIP_THIS
41 
42 namespace Gdk
43 {
44 
45 /**  @newin{3,18}
46  */
47 class GLError : public Glib::Error
48 {
49 public:
50   /**  @var Code NOT_AVAILABLE
51    * OpenGL support is not available.
52    *
53    *  @var Code UNSUPPORTED_FORMAT
54    * The requested visual format is not supported.
55    *
56    *  @var Code UNSUPPORTED_PROFILE
57    * The requested profile is not supported.
58    *
59    *  @enum Code
60    *
61    * Error enumeration for Gdk::GLContext.
62    *
63    * @newin{3,18}
64    */
65   enum Code
66   {
67     NOT_AVAILABLE,
68     UNSUPPORTED_FORMAT,
69     UNSUPPORTED_PROFILE
70   };
71 
72   GLError(Code error_code, const Glib::ustring& error_message);
73   explicit GLError(GError* gobject);
74   Code code() const;
75 
76 #ifndef DOXYGEN_SHOULD_SKIP_THIS
77 private:
78 
79   static void throw_func(GError* gobject);
80 
81   friend void wrap_init(); // uses throw_func()
82 
83   #endif //DOXYGEN_SHOULD_SKIP_THIS
84 };
85 
86 } // namespace Gdk
87 
88 #ifndef DOXYGEN_SHOULD_SKIP_THIS
89 namespace Glib
90 {
91 
92 template <>
93 class Value<Gdk::GLError::Code> : public Glib::Value_Enum<Gdk::GLError::Code>
94 {
95 public:
96   static GType value_type() G_GNUC_CONST;
97 };
98 
99 } // namespace Glib
100 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
101 
102 namespace Gdk
103 {
104 
105 
106 /** A Gdk::GLContext is an OpenGL context abstraction. It's a low-level object, used to implement high-level objects such
107  * as Gtk::GLArea on the GTK+ level.
108  * @newin{3,18}
109  */
110 
111 class GLContext : public Glib::Object
112 {
113 
114 #ifndef DOXYGEN_SHOULD_SKIP_THIS
115 
116 public:
117   using CppObjectType = GLContext;
118   using CppClassType = GLContext_Class;
119   using BaseObjectType = GdkGLContext;
120   using BaseClassType = GdkGLContextClass;
121 
122   // noncopyable
123   GLContext(const GLContext&) = delete;
124   GLContext& operator=(const GLContext&) = delete;
125 
126 private:  friend class GLContext_Class;
127   static CppClassType glcontext_class_;
128 
129 protected:
130   explicit GLContext(const Glib::ConstructParams& construct_params);
131   explicit GLContext(GdkGLContext* castitem);
132 
133 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
134 
135 public:
136 
137   GLContext(GLContext&& src) noexcept;
138   GLContext& operator=(GLContext&& src) noexcept;
139 
140   ~GLContext() noexcept override;
141 
142   /** Get the GType for this class, for use with the underlying GObject type system.
143    */
144   static GType get_type()      G_GNUC_CONST;
145 
146 #ifndef DOXYGEN_SHOULD_SKIP_THIS
147 
148 
149   static GType get_base_type() G_GNUC_CONST;
150 #endif
151 
152   ///Provides access to the underlying C GObject.
gobj()153   GdkGLContext*       gobj()       { return reinterpret_cast<GdkGLContext*>(gobject_); }
154 
155   ///Provides access to the underlying C GObject.
gobj()156   const GdkGLContext* gobj() const { return reinterpret_cast<GdkGLContext*>(gobject_); }
157 
158   ///Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs.
159   GdkGLContext* gobj_copy();
160 
161 private:
162 
163 
164 protected:
165   GLContext();
166 
167 public:
168 
169   /** Retrieves the Gdk::Display the @a context is created for
170    *
171    * @newin{3,18}
172    *
173    * @return A Gdk::Display or <tt>nullptr</tt>.
174    */
175   Glib::RefPtr<Display> get_display();
176 
177   /** Retrieves the Gdk::Display the @a context is created for
178    *
179    * @newin{3,18}
180    *
181    * @return A Gdk::Display or <tt>nullptr</tt>.
182    */
183   Glib::RefPtr<const Display> get_display() const;
184 
185   /** Retrieves the Gdk::Window used by the @a context.
186    *
187    * @newin{3,18}
188    *
189    * @return A Gdk::Window or <tt>nullptr</tt>.
190    */
191   Glib::RefPtr<Window> get_window();
192 
193   /** Retrieves the Gdk::Window used by the @a context.
194    *
195    * @newin{3,18}
196    *
197    * @return A Gdk::Window or <tt>nullptr</tt>.
198    */
199   Glib::RefPtr<const Window> get_window() const;
200 
201   /** Retrieves the Gdk::GLContext that this @a context share data with.
202    *
203    * @newin{3,18}
204    *
205    * @return A Gdk::GLContext or <tt>nullptr</tt>.
206    */
207   Glib::RefPtr<GLContext> get_shared_context();
208 
209   /** Retrieves the Gdk::GLContext that this @a context share data with.
210    *
211    * @newin{3,18}
212    *
213    * @return A Gdk::GLContext or <tt>nullptr</tt>.
214    */
215   Glib::RefPtr<const GLContext> get_shared_context() const;
216 
217   /** Retrieves the OpenGL version of the @a context.
218    *
219    * The @a context must be realized prior to calling this function.
220    *
221    * @newin{3,18}
222    *
223    * @param major Return location for the major version.
224    * @param minor Return location for the minor version.
225    */
226   void get_version(int& major, int& minor) const;
227 
228   /** Whether the Gdk::GLContext is in legacy mode or not.
229    *
230    * The Gdk::GLContext must be realized before calling this function.
231    *
232    * When realizing a GL context, GDK will try to use the OpenGL 3.2 core
233    * profile; this profile removes all the OpenGL API that was deprecated
234    * prior to the 3.2 version of the specification. If the realization is
235    * successful, this function will return <tt>false</tt>.
236    *
237    * If the underlying OpenGL implementation does not support core profiles,
238    * GDK will fall back to a pre-3.2 compatibility profile, and this function
239    * will return <tt>true</tt>.
240    *
241    * You can use the value returned by this function to decide which kind
242    * of OpenGL API to use, or whether to do extension discovery, or what
243    * kind of shader programs to load.
244    *
245    * @newin{3,20}
246    *
247    * @return <tt>true</tt> if the GL context is in legacy mode.
248    */
249   bool is_legacy() const;
250 
251   /** Retrieves the major and minor version requested by calling
252    * gdk_gl_context_set_required_version().
253    *
254    * @newin{3,18}
255    *
256    * @param major Return location for the major version to request.
257    * @param minor Return location for the minor version to request.
258    */
259   void get_required_version(int& major, int& minor) const;
260 
261   /** Sets the major and minor version of OpenGL to request.
262    *
263    * Setting @a major and @a minor to zero will use the default values.
264    *
265    * The Gdk::GLContext must not be realized or made current prior to calling
266    * this function.
267    *
268    * @newin{3,18}
269    *
270    * @param major The major version to request.
271    * @param minor The minor version to request.
272    */
273   void set_required_version(int major, int minor);
274 
275   /** Retrieves the value set using gdk_gl_context_set_debug_enabled().
276    *
277    * @newin{3,18}
278    *
279    * @return <tt>true</tt> if debugging is enabled.
280    */
281   bool get_debug_enabled() const;
282 
283   /** Sets whether the Gdk::GLContext should perform extra validations and
284    * run time checking. This is useful during development, but has
285    * additional overhead.
286    *
287    * The Gdk::GLContext must not be realized or made current prior to
288    * calling this function.
289    *
290    * @newin{3,18}
291    *
292    * @param enabled Whether to enable debugging in the context.
293    */
294   void set_debug_enabled(bool enabled =  true);
295 
296   /** Retrieves the value set using gdk_gl_context_set_forward_compatible().
297    *
298    * @newin{3,18}
299    *
300    * @return <tt>true</tt> if the context should be forward compatible.
301    */
302   bool get_forward_compatible() const;
303 
304   /** Sets whether the Gdk::GLContext should be forward compatible.
305    *
306    * Forward compatibile contexts must not support OpenGL functionality that
307    * has been marked as deprecated in the requested version; non-forward
308    * compatible contexts, on the other hand, must support both deprecated and
309    * non deprecated functionality.
310    *
311    * The Gdk::GLContext must not be realized or made current prior to calling
312    * this function.
313    *
314    * @newin{3,18}
315    *
316    * @param compatible Whether the context should be forward compatible.
317    */
318   void set_forward_compatible(bool compatible =  true);
319 
320 
321   /** Requests that GDK create an OpenGL ES context instead of an OpenGL one,
322    * if the platform and windowing system allows it.
323    *
324    * The %GLContext must not have been realized.
325    *
326    * By default, GDK will attempt to automatically detect whether the
327    * underlying GL implementation is OpenGL or OpenGL ES once the %GLContext
328    * is realized.
329    *
330    * You should check the return value of get_use_es() after
331    * calling realize() to decide whether to use the OpenGL or
332    * OpenGL ES API, extensions, or shaders.
333    *
334    * @newin{3,22}
335    *
336    * @param use_es Whether the context should use OpenGL ES instead of OpenGL.
337    */
338   void set_use_es(bool use_es =  true);
339 
340   /** Undo a previous call to set_use_es().
341    *
342    * GDK will attempt to automatically detect whether the underlying
343    * GL implementation is OpenGL or OpenGL ES once the %GLContext is realized.
344    *
345    * @newin{3,24}
346    */
347   void unset_use_es();
348 
349 
350   /** Checks whether the @a context is using an OpenGL or OpenGL ES profile.
351    *
352    * @newin{3,22}
353    *
354    * @return <tt>true</tt> if the Gdk::GLContext is using an OpenGL ES profile.
355    */
356   bool get_use_es() const;
357 
358   /** Realizes the given Gdk::GLContext.
359    *
360    * It is safe to call this function on a realized Gdk::GLContext.
361    *
362    * @newin{3,18}
363    *
364    * @return <tt>true</tt> if the context is realized.
365    *
366    * @throws Glib::Error
367    */
368   bool realize();
369 
370   /** Makes the @a context the current one.
371    *
372    * @newin{3,18}
373    */
374   void make_current();
375 
376   /** Retrieves the current Gdk::GLContext.
377    *
378    * @newin{3,18}
379    *
380    * @return The current Gdk::GLContext, or <tt>nullptr</tt>.
381    */
382   static Glib::RefPtr<GLContext> get_current();
383 
384   /** Clears the current Gdk::GLContext.
385    *
386    * Any OpenGL call after this function returns will be ignored
387    * until gdk_gl_context_make_current() is called.
388    *
389    * @newin{3,18}
390    */
391   static void clear_current();
392 
393   /** The Gdk::Display used to create the Gdk::GLContext.
394    *
395    * @newin{3,18}
396    *
397    * @return A PropertyProxy_ReadOnly that allows you to get the value of the property,
398    * or receive notification when the value of the property changes.
399    */
400   Glib::PropertyProxy_ReadOnly< Glib::RefPtr<Display> > property_display() const;
401 
402 
403   /** The Gdk::GLContext that this context is sharing data with, or <tt>nullptr</tt>
404    *
405    * @newin{3,18}
406    *
407    * @return A PropertyProxy_ReadOnly that allows you to get the value of the property,
408    * or receive notification when the value of the property changes.
409    */
410   Glib::PropertyProxy_ReadOnly< Glib::RefPtr<GLContext> > property_shared_context() const;
411 
412 
413   /** The Gdk::Window the gl context is bound to.
414    *
415    * @newin{3,18}
416    *
417    * @return A PropertyProxy_ReadOnly that allows you to get the value of the property,
418    * or receive notification when the value of the property changes.
419    */
420   Glib::PropertyProxy_ReadOnly< Glib::RefPtr<Window> > property_window() const;
421 
422 
423 public:
424 
425 public:
426   //C++ methods used to invoke GTK+ virtual functions:
427 
428 protected:
429   //GTK+ Virtual Functions (override these to change behaviour):
430 
431   //Default Signal Handlers::
432 
433 
434 };
435 
436 } // namespace Gdk
437 
438 
439 namespace Glib
440 {
441   /** A Glib::wrap() method for this object.
442    *
443    * @param object The C instance.
444    * @param take_copy False if the result should take ownership of the C instance. True if it should take a new copy or ref.
445    * @result A C++ instance that wraps this C instance.
446    *
447    * @relates Gdk::GLContext
448    */
449   Glib::RefPtr<Gdk::GLContext> wrap(GdkGLContext* object, bool take_copy = false);
450 }
451 
452 
453 #endif /* _GDKMM_GLCONTEXT_H */
454 
455