Re: light sources.

Patrick Scheibe <[email protected]>
Newsgroups gmane.comp.lang.haskell.hopengl
Message-ID <[email protected]>
The tutorial is fine but doesnt help me. Following (too simple) problem:
I want to look at a rotating cube. What happens is, that I'm rotating around 
the cube. That means the cube looks sometimes dark and sometimes bright like 
the day and nightside of a planet.

I've read the lighting part of the OpenGl-Redbook. They write that you have to 
put the "light position"-function different places to get different results. 
This seems totally intuitve and clear to me. E.g. to put it after a 
translation in the displayfunc produces a translation of the light source...

But in my code the  "position (Light 0) $= ..." call doesnt do anything.
It doesnt matter where I put it in the code and it makes no difference what 
position in my room the lightsource gets. Everytime the animation looks equal 
to that before.

I think I've forgotten something really important or some calls are not on the 
right place. Here is my code. The lightposition-call isnt in there but I 
tried every possible position in the code. The light-stuff is stolen from one 
of the GLUT examples. This example looks fine but doesnt have any animation.

<haskell>

myinit = do
   lighting $= Enabled
   light (Light 0) $= Enabled

main = do
  ...
  initialDisplayMode $= [GLUT.Double, GLUT.RGBA, GLUT.Depth]
  ...
  myinit
  ...

myReshape :: ReshapeCallback
myReshape size@(Size w h) = do
  viewport $= (Position 0 0, size)
  matrixMode $= Projection
  loadIdentity
  perspective 60 ((fromIntegral w)/(fromIntegral h)) 0.01 100.0
  lookAt (Vertex3  0 0 5)
	 (Vertex3  0 0 0)
	 (Vector3  0 1 0)
  matrixMode $= Modelview 0
  loadIdentity


myDisplay :: IORef GLfloat ->DisplayCallback
myDisplay arg = do
  angle <- readIORef arg
  clear [ColorBuffer, DepthBuffer]
  matrixExcursion $ do
    rotatef angle (Vector3 1 1 (1::GLfloat))
    stdCube
  swapBuffers

</haskell>

I dont know if this mailinglist supports atachments but here to pics of this 
cube at day and night :-)

Greetings
Patrick

_______________________________________________
HOpenGL mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/hopengl
grab1.jpg (image/jpeg, 3.6 KB) - not displayed
grab2.jpg (image/jpeg, 2.2 KB) - not displayed
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.