[wxhaskell-users] Where is the sample programm of wxHaskell OpenGL canvas using the HOpenGL binding?
From: shelarcy <she...@ca...> - 2004-04-03 04:06:35
|
Hello. Since wxHaskell supported for OpenGL canvas, I waited for OpenGL canvas sample programm long long time. Because document is not good, so I don't understand how to use OpenGL canvas. In Apr 2 2004, OpenGL's sample Screenshots was appeared, so I want to know how to use wxHaskell OpenGL canvas using the HOpenGL binding. -- shelarcy <she...@ca...> http://page.freett.com/shelarcy/ |
From: Daan L. <daa...@xs...> - 2004-04-03 10:28:06
|
Hi Shelarcy, > Since wxHaskell supported for OpenGL canvas, I waited for > OpenGL canvas sample programm long long time. > > Because document is not good, so I don't understand how to use OpenGL > canvas. In Apr 2 2004, OpenGL's sample Screenshots was appeared, so I > want to know how to use wxHaskell OpenGL canvas using the HOpenGL binding. I haven't used it myself as I haven't been able to get HOpenGL (the haskell binding to openGL) working yet on my windows machine. As such, using openGL with wxHaskell is still a bit experimental terrain. The best thing you can do is to ask Sean Seefried if you can send you his code so that you can see a specific example. The technology though is pretty straightforward: just create an openGL canvas and activate it -- after that, all openGL commands are directed to that window, whether you use HOpenGL or other openGL code. All the best, Daan. > > > -- > shelarcy <she...@ca...> > http://page.freett.com/shelarcy/ > > > > ------------------------------------------------------- > This SF.Net email is sponsored by: IBM Linux Tutorials > Free Linux tutorial presented by Daniel Robbins, President > and CEO of GenToo technologies. Learn everything from > fundamentals to system > administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click > _______________________________________________ > wxhaskell-users mailing list wxh...@li... > https://lists.sourceforge.net/lists/listinfo/wxhaskell-users > > |
From: shelarcy <she...@ca...> - 2004-04-07 11:58:25
|
On Sat, 3 Apr 2004 12:29:31 +0200, Daan Leijen <daa...@xs...> wrote: > I haven't used it myself as I haven't been able to get HOpenGL > (the haskell binding to openGL) working yet on my windows machine. > > As such, using openGL with wxHaskell is still a bit experimental > terrain. The best thing you can do is to ask Sean Seefried if you > can send you his code so that you can see a specific example. > > The technology though is pretty straightforward: just create an > openGL canvas and activate it -- after that, all openGL commands > are directed to that window, whether you use HOpenGL or other > openGL code. I asked him show the simplist example, and I understood how to work this. I wrote redbook example, and I checked it out. Thank you for you and him. But I don't understand everything yet, so this isn't complete work. Hide Window Once, then you see work it. module Main where import Data.List ( transpose ) import Graphics.UI.WX import Graphics.UI.WXCore import qualified Graphics.Rendering.OpenGL as GL import Graphics.Rendering.OpenGL main = start gui defaultWidth = 500 defaultHeight = 500 gui = do f <- frame [ text := "Simple OpenGL" ] glCanvas <- glCanvasCreateEx f 0 (Rect 0 0 defaultWidth defaultHeight) 0 "GLCanvas" [GL_RGBA] nullPalette let glWidgetLayout = (fill . widget) glCanvas Graphics.UI.WX.set f [ layout := glWidgetLayout , on paint := paintGL ] ctrlPoints :: [[Vertex3 GLfloat]] ctrlPoints = [ [ Vertex3 (-1.5) (-1.5) 4.0, Vertex3 (-0.5) (-1.5) 2.0, Vertex3 0.5 (-1.5) (-1.0), Vertex3 1.5 (-1.5) 2.0 ], [ Vertex3 (-1.5) (-0.5) 1.0, Vertex3 (-0.5) (-0.5) 3.0, Vertex3 0.5 (-0.5) 0.0, Vertex3 1.5 (-0.5) (-1.0) ], [ Vertex3 (-1.5) 0.5 4.0, Vertex3 (-0.5) 0.5 0.0, Vertex3 0.5 0.5 3.0, Vertex3 1.5 0.5 4.0 ], [ Vertex3 (-1.5) 1.5 (-2.0), Vertex3 (-0.5) 1.5 (-2.0), Vertex3 0.5 1.5 0.0, Vertex3 1.5 1.5 (-1.0) ]] initlights :: IO () initlights = do lighting $= Enabled light (Light 0) $= Enabled ambient (Light 0) $= Color4 0.2 0.2 0.2 1.0 GL.position (Light 0) $= Vertex4 0 0 2 1 materialDiffuse Front $= Color4 0.6 0.6 0.6 1.0 materialSpecular Front $= Color4 1.0 1.0 1.0 1.0 materialShininess Front $= 50 myInit :: IO () myInit = do clearColor $= Color4 0 0 0 0 depthFunc $= Just Less m <- newMap2 (0, 1) (0, 1) (transpose ctrlPoints) map2 $= Just (m :: GLmap2 Vertex3 GLfloat) autoNormal $= Enabled mapGrid2 $= ((20, (0, 1)), (20, (0, 1 :: GLfloat))) initlights -- for lighted version only display = do clear [ ColorBuffer, DepthBuffer ] preservingMatrix $ do rotate (85 :: GLfloat) (Vector3 1 1 1) evalMesh2 Fill (0, 20) (0, 20) flush reshape size@(GL.Size w h) = do viewport $= (Position 0 0, size) matrixMode $= Projection loadIdentity let wf = fromIntegral w hf = fromIntegral h if w <= h then ortho (-4.0) 4.0 (-4.0*hf/wf) (4.0*hf/wf) (-4.0) 4.0 else ortho (-4.0*wf/hf) (4.0*wf/hf) (-4.0) 4.0 (-4.0) 4.0 matrixMode $= Modelview 0 loadIdentity convWG (Graphics.UI.WX.Size w h) = (GL.Size (convInt32 w) (convInt32 h)) convInt32 = fromInteger . toInteger paintGL :: DC() -> Graphics.UI.WX.Rect -> IO () paintGL dc rect = do -- write your commands to do OpenGL things here. myInit display reshape $ convWG $ rectSize rect return () -- shelarcy <she...@ca...> http://page.freett.com/shelarcy/ |
From: shelarcy <she...@ca...> - 2004-04-08 10:33:16
|
On Wed, 07 Apr 2004 20:58:18 +0900, shelarcy <she...@ca...> wrote: > I wrote redbook example, and I checked it out. > Thank you for you and him. > > But I don't understand everything yet, so this isn't complete work. > Hide Window Once, then you see work it. > > paintGL :: DC() -> Graphics.UI.WX.Rect -> IO () > paintGL dc rect = do > -- write your commands to do OpenGL things here. > myInit > display > reshape $ convWG $ rectSize rect > return () I reversed this code because GLUT original code's reshape is a callback function. paintGL :: DC() -> Graphics.UI.WX.Rect -> IO () paintGL dc rect = do -- write your commands to do OpenGL things here. myInit reshape $ convWG $ rectSize rect -- or reshape (GL.Size 500 500) display return () Then this programm became better, Code works correctly. But if overlay the OpenGL canvas, then hide Graphics until hide window once. -- shelarcy <she...@ca...> http://page.freett.com/shelarcy/ |
From: Daan L. <daa...@xs...> - 2004-04-11 14:37:51
|
On Wed, 07 Apr 2004 20:58:18 +0900, shelarcy <she...@ca...> wrote: > I wrote redbook example, and I checked it out. > Thank you for you and him. > > But I don't understand everything yet, so this isn't complete work. > Hide Window Once, then you see work it. Hi Shelarcy, Great that the openGL seems to work for you. Could you send me a screenshot? (With a "little" window)? Furthermore, I would like to put your sample code in the contrib samples. Maybe you could send me minimal working source code (maybe with some comments)? All the best, Daan. > > module Main > where > > import Data.List ( transpose ) > import Graphics.UI.WX > import Graphics.UI.WXCore > import qualified Graphics.Rendering.OpenGL as GL > import Graphics.Rendering.OpenGL > > main = start gui > > > defaultWidth = 500 > defaultHeight = 500 > > gui = do > f <- frame [ text := "Simple OpenGL" ] > glCanvas <- glCanvasCreateEx f 0 (Rect 0 0 defaultWidth defaultHeight) > 0 "GLCanvas" [GL_RGBA] nullPalette > let glWidgetLayout = (fill . widget) glCanvas > Graphics.UI.WX.set f [ layout := glWidgetLayout > , on paint := paintGL > ] > > > ctrlPoints :: [[Vertex3 GLfloat]] > ctrlPoints = [ > [ Vertex3 (-1.5) (-1.5) 4.0, Vertex3 (-0.5) (-1.5) 2.0, > Vertex3 0.5 (-1.5) (-1.0), Vertex3 1.5 (-1.5) 2.0 ], > [ Vertex3 (-1.5) (-0.5) 1.0, Vertex3 (-0.5) (-0.5) 3.0, > Vertex3 0.5 (-0.5) 0.0, Vertex3 1.5 (-0.5) (-1.0) ], > [ Vertex3 (-1.5) 0.5 4.0, Vertex3 (-0.5) 0.5 0.0, > Vertex3 0.5 0.5 3.0, Vertex3 1.5 0.5 4.0 ], > [ Vertex3 (-1.5) 1.5 (-2.0), Vertex3 (-0.5) 1.5 (-2.0), > Vertex3 0.5 1.5 0.0, Vertex3 1.5 1.5 (-1.0) ]] > > initlights :: IO () > initlights = do > lighting $= Enabled > light (Light 0) $= Enabled > > ambient (Light 0) $= Color4 0.2 0.2 0.2 1.0 > GL.position (Light 0) $= Vertex4 0 0 2 1 > > materialDiffuse Front $= Color4 0.6 0.6 0.6 1.0 > materialSpecular Front $= Color4 1.0 1.0 1.0 1.0 > materialShininess Front $= 50 > > myInit :: IO () > myInit = do > clearColor $= Color4 0 0 0 0 > depthFunc $= Just Less > m <- newMap2 (0, 1) (0, 1) (transpose ctrlPoints) > map2 $= Just (m :: GLmap2 Vertex3 GLfloat) > autoNormal $= Enabled > mapGrid2 $= ((20, (0, 1)), (20, (0, 1 :: GLfloat))) > initlights -- for lighted version only > > display = do > clear [ ColorBuffer, DepthBuffer ] > preservingMatrix $ do > rotate (85 :: GLfloat) (Vector3 1 1 1) > evalMesh2 Fill (0, 20) (0, 20) > flush > > reshape size@(GL.Size w h) = do > viewport $= (Position 0 0, size) > matrixMode $= Projection > loadIdentity > let wf = fromIntegral w > hf = fromIntegral h > if w <= h > then ortho (-4.0) 4.0 (-4.0*hf/wf) (4.0*hf/wf) (-4.0) 4.0 > else ortho (-4.0*wf/hf) (4.0*wf/hf) (-4.0) 4.0 (-4.0) 4.0 > matrixMode $= Modelview 0 > loadIdentity > > convWG (Graphics.UI.WX.Size w h) = (GL.Size (convInt32 w) (convInt32 h)) > convInt32 = fromInteger . toInteger > > paintGL :: DC() -> Graphics.UI.WX.Rect -> IO () > paintGL dc rect = do > -- write your commands to do OpenGL things here. > myInit > display > reshape $ convWG $ rectSize rect > return () > > |
From: shelarcy <she...@ca...> - 2004-04-12 14:10:40
|
On Sun, 11 Apr 2004 16:37:58 +0200, Daan Leijen <daa...@xs...> wrote: > Hi Shelarcy, > > Great that the openGL seems to work for you. Could you send > me a screenshot? (With a "little" window)? > > Furthermore, I would like to put your sample code in the > contrib samples. Maybe you could send me minimal working > source code (maybe with some comments)? > > All the best, > Daan. Here are source code and screen shots. SF Mailer refused .zip file. -- shelarcy <she...@ca...> http://page.freett.com/shelarcy/ |
From: shelarcy <she...@ca...> - 2004-04-21 11:06:44
Attachments:
contribute.tar.gz
|
On Mon, 12 Apr 2004 23:10:36 +0900, shelarcy <she...@ca...> wrote: > On Sun, 11 Apr 2004 16:37:58 +0200, Daan Leijen <daa...@xs...> > wrote: >> Hi Shelarcy, >> >> Great that the openGL seems to work for you. Could you send >> me a screenshot? (With a "little" window)? >> >> Furthermore, I would like to put your sample code in the >> contrib samples. Maybe you could send me minimal working >> source code (maybe with some comments)? >> >> All the best, >> Daan. > > Here are source code and screen shots. > > SF Mailer refused .zip file. wxHaskell site and CVS doesn't update. Raw File is ugly or File is lost? I send the tar.gz file again. -- shelarcy <she...@ca...> http://page.freett.com/shelarcy/ |