I'm not at all sure but could you move

 widgetSetSizeRequest canvas 400 400

after the onRealize and see what happens?

On Wed, Feb 25, 2009 at 8:13 PM, Daneel Yaitskov <rtfm.rtfm.rtfm@gmail.com> wrote:
Hi All,

I have written a program on the base of the gtk2hs demo (RotatingCube).
There isn't a snippet of a code must change opengl Projection when
window size changes. By analog I have tought this code and it
doesn't work.


 glconfig <- glConfigNew [ GLModeRGBA, GLModeDepth, GLModeDouble ]
 canvas <- glDrawingAreaNew glconfig
 widgetSetSizeRequest canvas 400 400
 onRealize canvas $ withGLDrawingArea canvas ( myInit 400 400 )
 onExpose  canvas $ \_ -> do withGLDrawingArea canvas display1
                            return True
 onSizeAllocate  canvas $ reshape canvas

reshape canvas (Rectangle x y w h) = do
 withGLDrawingArea canvas
                   $ \_ -> do
                          matrixMode $= Projection
                          ortho 0.0 (fromIntegral w)
                                    (-(fromIntegral h))
                                    0.0 (-1000) 1000
                          depthFunc $= Just Less
                          matrixMode $= Modelview 0

 Program gives the error:
(gtk-balls:11403): GtkGLExt-CRITICAL **: gtk_widget_get_gl_context: assertion
 `GTK_WIDGET_REALIZED (widget)' failed
gtk-balls: user error (makeNewGObject: object is NULL)
If the body of the reshape function is empty then program works well.
Code which is into withGLDrawingArea havn't time to perform itself.

Daneel Yaitskov

Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
Gtk2hs-users mailing list