3
時只需更動Haskell的光澤圖書館,我寫道:錯誤「光澤/ OpenGL的堆棧溢出‘drawPicture後’,」使用基於遞歸動畫
import Graphics.Gloss
data World = World { worldBugs :: [Picture] }
bug :: Point -> Float -> Picture
bug (x, y) s =
let head = Translate x (y - s) $ Circle (s * 0.8)
body = Translate x (y + s) $ Circle (s * 1.2)
in pictures [head, body]
main = play (InWindow "Animation Test" (400, 400) (100, 100)) white 10
(World . map (\(n,b) -> Translate (n * 20) (n * 20) $ b) $ zip [0..] $ replicate 100 $ bug (0,0) 100)
(\world -> pictures $ worldBugs world)
(\event world -> world)
(\time (World bs) -> World $ map (Rotate (time * 10)) bs)
這顯示一些「錯誤」(兩個圓形成一個頭和軀幹),隨着時間的推移而旋轉。問題是,正在運行的幾秒鐘後,它與崩潰:
Gloss/OpenGL Stack Overflow "after drawPicture."
This program uses the Gloss vector graphics library, which tried to
draw a picture using more nested transforms (Translate/Rotate/Scale)
than your OpenGL implementation supports. The OpenGL spec requires
all implementations to have a transform stack depth of at least 32,
and Gloss tries not to push the stack when it doesn't have to, but
that still wasn't enough.
You should complain to your harware vendor that they don't provide
a better way to handle this situation at the OpenGL API level.
To make this program work you'll need to reduce the number of nested
transforms used when defining the Picture given to Gloss. Sorry.
,如果我理解正確的,它基本上意味着最終,過多的轉換是放到一個棧,它溢出。它指出這可能是一個硬件限制(我在Surface 2 Pro上),那麼我是SOL?它在使用animate
時不會這樣做,但這可能是由於它不會每次打勾都傳遞一個狀態。
如果我要做一個遊戲,我不得不使用play
將狀態傳遞給下一個打勾;我無法按時完成所有任務。有沒有解決的辦法?谷歌搜索的錯誤產量幾乎沒有。
我剛剛意識到通過這樣做,我基本上創建了一個嵌套的轉換列表。我會試着修改變壓器的磁場。 – Carcigenicate 2014-10-28 01:29:28