[HOpenGL] divide the display in subwindows

Glynn Clements glynn.clements@virgin.net
Tue, 21 Jan 2003 10:15:04 +0000


mai99dnn@studserv.uni-leipzig.de wrote:

> I want to divide my window into subwindows to display different
> informations (like Nate Robins in his OpenGL Tutorials, if anyone knows).
> So I try to work out his solution in Haskell. My Main.hs has the following
> structure:
> 
> main :: ...
> 
>  mainWin<-createWindow..
> 
>  reshapeFunc (Just mainReshape)
>  displayF... mainDisplay
> 
>  sub1<-createSubWindow mainWin ...
> 
>  reshapeFunc (Just sub1Reshape)
>  ...
> 
> 
> -- here follows the interesting part
> -- in the mainReshape Nate Robins call the subReshapes...
> 
> mainReshape :: ReshapeAction
> ...
> ...
>  setWindow sub1  --!!! no sub1-Window in there :-(
>  positionWindow (...)
>  reshapeWindow (...)
> 
> 
> -----------------------------------------------------------------
> 
> 
> its clear that sub1 isnt known in the mainReshape. In C you can define
> global variables to solve this. Is that in Haskell possible too?
> I can't give the sub1 Window directly to the mainReshape 
> (mainReshape :: Window -> Resh..) because when the funtion is called in
> the main this sub1 isnt created yet (see above). 
> 
> I hope this was a clear description of the dilemma I'm in. And I pray,
> that I'm just too stupid and the solution is much more clearer to you.

Create the subwindow before registering the reshape function, then you
can pass it as an argument to the reshape function e.g.

	main :: IO ()
	main = do
	 mainWin<-createWindow..
	 sub1<-createSubWindow mainWin ...
	 reshapeFunc (Just sub1Reshape)
	 setWindow mainWin
	 reshapeFunc (Just (mainReshape sub1))
	 ...
	
	mainReshape :: Window -> ReshapeAction
	mainReshape sub1 = do
	 setWindow sub1  --!!! no sub1-Window in there :-(
	 positionWindow (...)
	 reshapeWindow (...)
	 ...

-- 
Glynn Clements <glynn.clements@virgin.net>