Closed noughtmare closed 4 years ago
@noughtmare I'd try using the loadImage
function, if that still gives you problems I can look into it tonight. The example I have might be outdated.
@dmjio loadImage
loads an image from disk, I want to generate an image programmatically (and then show it in a window).
@noughtmare I think the type needs to be CBool
(b8
). Can confirm soon.
@dmjio If I use CBool
then I get the error:
free(): invalid size
Aborted
@noughtmare there's been some fixes (related to double free'ing of pointers) that are now in HEAD, am working on the Graphics module now with success. drawSurface
in particular.
As I inspect more with what the C++ is doing before it sends it to the C, we'll have better working visualization code, and examples !
main :: IO ()
main = do
window <- createWindow 800 600 "hey"
let x = iota [60,1] [1,60] / 29
y = iota [1,60] [60,1] / 29
go window (0 :: Array Float) x y
where
go window t x y = do
let z = 10*x*(-abs(y)) * cos(x*x*(y+t))+sin(y*(x+t))-1.5
drawSurface window x y z (Cell (-1) (-1) "there" ColorMapDefault)
closed <- isWindowClosed window
unless closed $ go window (t + 0.07) x y
@noughtmare, for drawImage
, try something like this:
main :: IO ()
main = render =<< createWindow 800 600 "hey"
where
render window = do
let x = iota [1,60] [60,1] / (30 :: Array Float)
cell = Cell (-1) (-1) "" ColorMapDefault
drawImage window x cell
closed <- isWindowClosed window
unless closed (render window)
I'll update the documentation to reflect this.
Your documentation contains an example:
I adapted it to:
That gives the error: