Main Page   Modules   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Examples  

gtkmm/gl/widget.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 /* gtkglextmm - C++ Wrapper for GtkGLExt
00003  * Copyright (C) 2002-2003  Naofumi Yasufuku
00004  *
00005  * This library is free software; you can redistribute it and/or
00006  * modify it under the terms of the GNU Lesser General Public
00007  * License as published by the Free Software Foundation; either
00008  * version 2.1 of the License, or (at your option) any later version.
00009  *
00010  * This library is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013  * Lesser General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU Lesser General Public
00016  * License along with this library; if not, write to the Free Software
00017  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA.
00018  */
00019 
00020 #ifndef _GTKMM_GL_WIDGET_H
00021 #define _GTKMM_GL_WIDGET_H
00022 
00023 #include <gtkmm/widget.h>
00024 
00025 #include <gdkmm/gl/tokens.h>
00026 #include <gdkmm/gl/config.h>
00027 #include <gdkmm/gl/context.h>
00028 #include <gdkmm/gl/window.h>
00029 
00030 namespace Gtk
00031 {
00032   namespace GL
00033   {
00034 
00035     /** OpenGL extension API to Gtk::Widget.
00036      *
00037      *
00038      */
00039 
00040     class Widget
00041     {
00042     private:
00043       Widget(const Widget&);
00044       Widget& operator=(const Widget&);
00045 
00046     protected:
00047       explicit Widget(Gtk::Widget& widget) : _M_widget(widget) {}
00048 
00049     public:
00050       virtual ~Widget() = 0;
00051 
00052     public:
00053 
00054       /** Set the OpenGL-capability to the Gtk::Widget.
00055        * The call setup the callbacks to realize a OpenGL-capable window.
00056        *
00057        * @param widget       the GtkWidget to be used as the rendering area.
00058        * @param glconfig     a Gdk::GL::Config.
00059        * @param share_list   the Gdk::GL::Context which to share display lists.
00060        * @param direct       whether rendering is to be done with a direct
00061        *                     connection to the graphics system.
00062        * @param render_type  Gdk::GL::RGBA_TYPE or Gdk::GL::COLOR_INDEX_TYPE
00063        *                     (currently not used).
00064        * @return  <tt>true</tt> if it is successful, <tt>false</tt> otherwise.
00065        */
00066       static bool set_gl_capability(Gtk::Widget& widget,
00067                                     const Glib::RefPtr<const Gdk::GL::Config>& glconfig,
00068                                     const Glib::RefPtr<const Gdk::GL::Context>& share_list,
00069                                     bool direct = true,
00070                                     int render_type = Gdk::GL::RGBA_TYPE);
00071 
00072       /** Set the OpenGL-capability to the Gtk::Widget.
00073        * The call setup the callbacks to realize a OpenGL-capable window.
00074        *
00075        * @param widget       the GtkWidget to be used as the rendering area.
00076        * @param glconfig     a Gdk::GL::Config.
00077        * @param direct       whether rendering is to be done with a direct
00078        *                     connection to the graphics system.
00079        * @param render_type  Gdk::GL::RGBA_TYPE or Gdk::GL::COLOR_INDEX_TYPE
00080        *                     (currently not used).
00081        * @return  <tt>true</tt> if it is successful, <tt>false</tt> otherwise.
00082        */
00083       static bool set_gl_capability(Gtk::Widget& widget,
00084                                     const Glib::RefPtr<const Gdk::GL::Config>& glconfig,
00085                                     bool direct = true,
00086                                     int render_type = Gdk::GL::RGBA_TYPE);
00087 
00088       /** Return whether the Gtk::Widget is OpenGL-capable.
00089        *
00090        * @param widget  a Gtk::Widget.
00091        * @return  <tt>true</tt> if the Gtk::Widget is OpenGL-capable,
00092        *          <tt>false</tt> otherwise.
00093        */
00094       static bool is_gl_capable(const Gtk::Widget& widget);
00095 
00096       /** Return the Gdk::GL::Config referred by the Gtk::Widget.
00097        *
00098        * @param widget  a Gtk::Widget.
00099        * @return  the Gdk::GL::Config.
00100        */
00101       static Glib::RefPtr<Gdk::GL::Config> get_gl_config(const Gtk::Widget& widget);
00102 
00103       /** Create a new Gdk::GL::Context with the appropriate Gdk::GL::Drawable
00104        * for this widget.
00105        *
00106        * See also get_gl_context().
00107        *
00108        * @param widget       a Gtk::Widget.
00109        * @param share_list   the Gdk::GL::Context which to share display lists.
00110        * @param direct       whether rendering is to be done with a direct
00111        *                     connection to the graphics system.
00112        * @param render_type  Gdk::GL::RGBA_TYPE or Gdk::GL::COLOR_INDEX_TYPE
00113        *                     (currently not used).
00114        * @return  the new Gdk::GL::Context.
00115        */
00116       static Glib::RefPtr<Gdk::GL::Context> create_gl_context(const Gtk::Widget& widget,
00117                                                               const Glib::RefPtr<const Gdk::GL::Context>& share_list,
00118                                                               bool direct = true,
00119                                                               int render_type = Gdk::GL::RGBA_TYPE);
00120 
00121       /** Create a new Gdk::GL::Context with the appropriate Gdk::GL::Drawable
00122        * for this widget.
00123        *
00124        * See also get_gl_context().
00125        *
00126        * @param widget       a Gtk::Widget.
00127        * @param direct       whether rendering is to be done with a direct
00128        *                     connection to the graphics system.
00129        * @param render_type  Gdk::GL::RGBA_TYPE or Gdk::GL::COLOR_INDEX_TYPE
00130        *                     (currently not used).
00131        * @return  the new Gdk::GL::Context.
00132        */
00133       static Glib::RefPtr<Gdk::GL::Context> create_gl_context(const Gtk::Widget& widget,
00134                                                               bool direct = true,
00135                                                               int render_type = Gdk::GL::RGBA_TYPE);
00136 
00137       /** Return the Gdk::GL::Context with the appropriate Gdk::GL::Drawable
00138        * for this widget.
00139        *
00140        * Unlike the GL context returned by create_gl_context(), this context
00141        * is owned by the widget.
00142        *
00143        * @param widget  a Gtk::Widget.
00144        * @return  the Gdk::GL::Context.
00145        */
00146       static Glib::RefPtr<Gdk::GL::Context> get_gl_context(const Gtk::Widget& widget);
00147 
00148       /** Return the Gdk::GL::Window owned by the Gtk::Widget.
00149        *
00150        * @param widget  a Gtk::Widget.
00151        * @return  the Gdk::GL::Window.
00152        */
00153       static Glib::RefPtr<Gdk::GL::Window> get_gl_window(const Gtk::Widget& widget);
00154 
00155       /** Return the Gdk::GL::Drawable owned by the Gtk::Widget.
00156        *
00157        * @param widget  a Gtk::Widget.
00158        * @return  the Gdk::GL::Drawable.
00159        */
00160       static Glib::RefPtr<Gdk::GL::Drawable> get_gl_drawable(const Gtk::Widget& widget);
00161 
00162     public:
00163 
00164       /** Set the OpenGL-capability to the Gtk::Widget.
00165        * The call setup the callbacks to realize a OpenGL-capable window.
00166        *
00167        * @param glconfig     a Gdk::GL::Config.
00168        * @param share_list   the Gdk::GL::Context which to share display lists.
00169        * @param direct       whether rendering is to be done with a direct
00170        *                     connection to the graphics system.
00171        * @param render_type  Gdk::GL::RGBA_TYPE or Gdk::GL::COLOR_INDEX_TYPE
00172        *                     (currently not used).
00173        * @return  <tt>true</tt> if it is successful, <tt>false</tt> otherwise.
00174        */
00175       bool set_gl_capability(const Glib::RefPtr<const Gdk::GL::Config>& glconfig,
00176                              const Glib::RefPtr<const Gdk::GL::Context>& share_list,
00177                              bool direct = true,
00178                              int render_type = Gdk::GL::RGBA_TYPE)
00179       { return set_gl_capability(_M_widget, glconfig, share_list, direct, render_type); }
00180 
00181       /** Set the OpenGL-capability to the Gtk::Widget.
00182        * The call setup the callbacks to realize a OpenGL-capable window.
00183        *
00184        * @param glconfig     a Gdk::GL::Config.
00185        * @param direct       whether rendering is to be done with a direct
00186        *                     connection to the graphics system.
00187        * @param render_type  Gdk::GL::RGBA_TYPE or Gdk::GL::COLOR_INDEX_TYPE
00188        *                     (currently not used).
00189        * @return  <tt>true</tt> if it is successful, <tt>false</tt> otherwise.
00190        */
00191       bool set_gl_capability(const Glib::RefPtr<const Gdk::GL::Config>& glconfig,
00192                              bool direct = true,
00193                              int render_type = Gdk::GL::RGBA_TYPE)
00194       { return set_gl_capability(_M_widget, glconfig, direct, render_type); }
00195 
00196       /** Return whether the Gtk::Widget is OpenGL-capable.
00197        *
00198        * @return  <tt>true</tt> if the Gtk::Widget is OpenGL-capable,
00199        *          <tt>false</tt> otherwise.
00200        */
00201       bool is_gl_capable() const
00202       { return is_gl_capable(_M_widget); }
00203 
00204       /** Return the Gdk::GL::Config referred by the Gtk::Widget.
00205        *
00206        * @return  the Gdk::GL::Config.
00207        */
00208       Glib::RefPtr<Gdk::GL::Config> get_gl_config()
00209       { return get_gl_config(_M_widget); }
00210 
00211       /** Return the Gdk::GL::Config referred by the Gtk::Widget.
00212        *
00213        * @return  the Gdk::GL::Config.
00214        */
00215       Glib::RefPtr<const Gdk::GL::Config> get_gl_config() const
00216       { return get_gl_config(_M_widget); }
00217 
00218       /** Create a new Gdk::GL::Context with the appropriate Gdk::GL::Drawable
00219        * for this widget.
00220        *
00221        * See also get_gl_context().
00222        *
00223        * @param share_list   the Gdk::GL::Context which to share display lists.
00224        * @param direct       whether rendering is to be done with a direct
00225        *                     connection to the graphics system.
00226        * @param render_type  Gdk::GL::RGBA_TYPE or Gdk::GL::COLOR_INDEX_TYPE
00227        *                     (currently not used).
00228        * @return  the new Gdk::GL::Context.
00229        */
00230       Glib::RefPtr<Gdk::GL::Context> create_gl_context(const Glib::RefPtr<const Gdk::GL::Context>& share_list,
00231                                                        bool direct = true,
00232                                                        int render_type = Gdk::GL::RGBA_TYPE)
00233       { return create_gl_context(_M_widget, share_list, direct, render_type); }
00234 
00235       /** Create a new Gdk::GL::Context with the appropriate Gdk::GL::Drawable
00236        * for this widget.
00237        *
00238        * See also get_gl_context().
00239        *
00240        * @param direct       whether rendering is to be done with a direct
00241        *                     connection to the graphics system.
00242        * @param render_type  Gdk::GL::RGBA_TYPE or Gdk::GL::COLOR_INDEX_TYPE
00243        *                     (currently not used).
00244        * @return  the new Gdk::GL::Context.
00245        */
00246       Glib::RefPtr<Gdk::GL::Context> create_gl_context(bool direct = true,
00247                                                        int render_type = Gdk::GL::RGBA_TYPE)
00248       { return create_gl_context(_M_widget, direct, render_type); }
00249 
00250       /** Return the Gdk::GL::Context with the appropriate Gdk::GL::Drawable
00251        * for this widget.
00252        *
00253        * Unlike the GL context returned by create_gl_context(), this context
00254        * is owned by the widget.
00255        *
00256        * @return  the Gdk::GL::Context.
00257        */
00258       Glib::RefPtr<Gdk::GL::Context> get_gl_context()
00259       { return get_gl_context(_M_widget); }
00260 
00261       /** Return the Gdk::GL::Window owned by the Gtk::Widget.
00262        *
00263        * @return  the Gdk::GL::Window.
00264        */
00265       Glib::RefPtr<Gdk::GL::Window> get_gl_window()
00266       { return get_gl_window(_M_widget); }
00267 
00268       /** Return the Gdk::GL::Window owned by the Gtk::Widget.
00269        *
00270        * @return  the Gdk::GL::Window.
00271        */
00272       Glib::RefPtr<const Gdk::GL::Window> get_gl_window() const
00273       { return get_gl_window(_M_widget); }
00274 
00275       /** Return the Gdk::GL::Drawable owned by the Gtk::Widget.
00276        *
00277        * @return  the Gdk::GL::Drawable.
00278        */
00279       Glib::RefPtr<Gdk::GL::Drawable> get_gl_drawable()
00280       { return get_gl_drawable(_M_widget); }
00281 
00282       /** Return the Gdk::GL::Drawable owned by the Gtk::Widget.
00283        *
00284        * @return  the Gdk::GL::Drawable.
00285        */
00286       Glib::RefPtr<const Gdk::GL::Drawable> get_gl_drawable() const
00287       { return get_gl_drawable(_M_widget); }
00288 
00289     private:
00290       Gtk::Widget& _M_widget;
00291 
00292     };
00293 
00294     /** @example simple.cc
00295      *
00296      * Simple gtkglextmm example.
00297      *
00298      */
00299 
00300     /** @example simple-mixed.cc
00301      *
00302      * Simple gtkglextmm example for mixing OpenGL and GDK rendering.
00303      *
00304      */
00305 
00306   } // namespace GL
00307 } // namespace Gtk
00308 
00309 #endif // _GTKMM_GL_WIDGET_H

Generated on Sat May 17 02:09:50 2003 for gtkglextmm by doxygen1.3