[HOpenGL] light sources.
Patrick Scheibe
mai99dnn at studserv.uni-leipzig.de
Thu Oct 9 18:21:31 EDT 2003
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-------------- next part --------------
A non-text attachment was scrubbed...
Name: grab1.jpg
Type: image/jpeg
Size: 5042 bytes
Desc: not available
Url : http://porky.devel.redhat.com/pipermail/hopengl/attachments/20031009/6ac747a5/grab1.jpe
-------------- next part --------------
A non-text attachment was scrubbed...
Name: grab2.jpg
Type: image/jpeg
Size: 2987 bytes
Desc: not available
Url : http://porky.devel.redhat.com/pipermail/hopengl/attachments/20031009/6ac747a5/grab2.jpe
More information about the HOpenGL
mailing list