Re: Depth problem
Balazs Komuves <[email protected]> Tue, 26 Oct 2010 20:03:34 +0200
| Newsgroups | gmane.comp.lang.haskell.hopengl |
|---|---|
| Message-ID | <[email protected]> |
Hi, Without seeing the full program, I'm just guessing, but here are some possible issues: matrixMode $= Modelview 1 > loadIdentity > I think that should be Modelview 0. Also, do you have the same in the display callback? You should reset it each time you draw a frame, and then set the correct translation depending on the time. Similarly, though not required, I recommend to set the projection matrix in each frame (in the display callback); the reshape callback should just store the screen size in a global variable (some people would say global variables in Haskell are a heresy, but I disagree :) Also, the 1200 / 0.01 far/near ratio is very large; because of how the depth buffer works, you want this ratio as small as possible given your application. See e.g. http://www.opengl.org/resources/faq/technical/depthbuffer.htm for details. Balazs On Mon, Oct 25, 2010 at 12:52 AM, Ben Christy <[email protected]> wrote: > I am taking a graphics class and I have a problem I have not been able to > resolve. When I translate along the Z axis objects are clipped before their > size changes. It almost seems likes its stuck using a ortho prjojection some > how. That being said the clip plan is very close and to me does not resemble > the one I set in gluPerspective. It starts to clip after being translated > -0.6 units down the z axis. > > Attached is the code that I use to setup the projection matrix. > > main = do > (progname, _) ← getArgsAndInitialize > --initialContextVersion 3 0 > createWindow "Ben Christy Assignment 2" > windowSize $= Size 800 600 > matrixMode $= Projection > loadIdentity > depthFunc $= Just Less > viewport $= (Position 0 0, Size 800 600) > perspective 60 1.333 1 1200 > --tableModel ← initModelVBO (vertexTupleListToVertexList table) > changesRef ← newIORef Map.empty > sceneRef ← newIORef buildSSG > balloonState ← newIORef There > balloonZTarget ← newIORef 4 > balloonZStart ← newIORef 0 > balloonStep ← newIORef 0 > balloonNumSteps ← newIORef 0 > reshapeCallback $= Just reshape > displayCallback $= (displayScene sceneRef changesRef ) > --addTimerCallback 10 (animate sceneRef changesRef balloonState > balloonZTarget balloonZStart balloonStep balloonNumSteps) > keyboardMouseCallback $= Just (handleInput sceneRef changesRef) > mainLoop > reshape (Size w h) = do > print "resize" > matrixMode $= Projection > loadIdentity > depthFunc $= Just Less > viewport $= (Position 0 0, Size w h) > perspective 60 1.333 0.01 1200 > matrixMode $= Modelview 1 > loadIdentity > postRedisplay Nothing > > > _______________________________________________ > HOpenGL mailing list > [email protected] > http://www.haskell.org/mailman/listinfo/hopengl > > _______________________________________________ HOpenGL mailing list [email protected] http://www.haskell.org/mailman/listinfo/hopengl