From: Jefferson H. <jef...@gm...> - 2008-11-07 02:58:12
|
Ah, that's good to know. I thought initGL would create the context. Sorry to be unclear in the code I posted, but part of createGUIObject is a glDrawingAreaNew. It creates a drawing area, which is then stored in a giant UserInterface record. data UserInterface = MainWindow { ... , drawing_canvas :: GLDrawingArea } createGUIObject = do ... config <- glConfigNew ... canvas <- glDrawingAreaNew config return $ MainWindow { ... drawing_canvas = canvas .. } It seems that won't create the context? do I have to show the window first, or can I just do... withGLDrawingArea $ glGenObjects n ? Thanks! -- Jeff On Thu, Nov 6, 2008 at 9:15 PM, Bertram Felgenhauer <ber...@go...> wrote: > [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 > > ------------------------------------------------------------------------- > This SF.Net email is sponsored by the Moblin Your Move Developer's challenge > Build the coolest Linux based applications with Moblin SDK & win great prizes > Grand prize is a trip for two to an Open Source event anywhere in the world > http://moblin-contest.org/redirect.php?banner_id=100&url=/ > _______________________________________________ > Gtk2hs-users mailing list > Gtk...@li... > https://lists.sourceforge.net/lists/listinfo/gtk2hs-users > -- I try to take things like a crow; war and chaos don't always ruin a picnic, they just mean you have to be careful what you swallow. -- Jessica Edwards |