[CCing gtk2hs-users] Jefferson Heard wrote: > import Graphics.UI.Gtk > import Graphics.UI.Gtk.Glade > import Graphics.UI.Gtk.OpenGL > import qualified Graphics.Rendering.OpenGL as GL > import Graphics.Rendering.OpenGL (($=)) > > main = do > initGUI > initGL
"initGL" may be slightly misleading - it initialises the gtkglext gtk+ extension. It does not create a GL context. > GL.shadeModel $= GL.Flat > GL.depthFunc $= Just GL.Less > (window1,gui,dlgs) <- constructGUIObject > (sX, sY) <- liftM (mapPair fromIntegral) . widgetGetSize . > drawing_canvas $ gui -- get the canvas size for determining the part > of the widget to repaint > pb <- pixbufNew ColorspaceRgb False 8 (round pbWidth) (round pbHeight) > pixbufFill pb 0 0 0 255 > pxbufs <- initSubpixbufs pb texRows texCols > textures <- GL.genObjectNames (texRows*texCols) > print textures There is no active GL context at this point. GtkGLExt creates new GL contexts for GL enabled widgets when they're realized - I think. I'm a bit fuzzy about the exact life time of the GL context. [1] After the context was created, you have to activate it before doing any GL operations. In Gtk2hs you can use the GLDrawingArea widget, which provides withGLDrawingArea for easy activation of the GL context. There's an example in the gtk2hs sources, in examples/opengl. Enabling GL for other widgets is not supported well at the moment. (There are low level bindings (using DrawWindow), but no generic binding to the higher level gtk_widget_set_gl_capability() call. Such support wouldn't be too hard to add, I think.) HTH, Bertram [1] see http://gtkglext.sourceforge.net/reference/gtkglext/gtkglext-gtkglwidget.html#gtk-widget-get-gl-context _______________________________________________ Haskell-Cafe mailing list [email protected] http://www.haskell.org/mailman/listinfo/haskell-cafe
