Twinside / Juicy.Pixels

Haskell library to load & save pictures

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

`createMutableImage` seems to create only one image ever.

fhaust opened this issue · comments

What I am doing

  1. forkIO thread that runs animateIO from gloss.
  2. During each renderstep
    1. read in some data
    2. create two new images via createMutableImage
    3. write data to images with writePixel
    4. freezeImage and fromImageRGB8 (from gloss-juicy)
    5. return both images

Expected Result

Two different images are displayed per Frame.

Result

Two equal images are displayed that seem to be integrated over time.

Probable Problem

createMutableImage is somehow only called once and the reference is passed around during the run of the program.

Versions

gloss-1.9.2.1
gloss-juicy-0.2
gloss-rendering-1.9.2.1
JuicyPixels-3.2.2

Hi, do you have some working code to help me debug this issue?

I'm not able to reproduce the problem with the following code:

import Control.Monad( forM_ )
import Codec.Picture
import Codec.Picture.Types

biModif :: IO ()
biModif = do
  let size = 10
  img1 <- createMutableImage size size $ PixelRGB8 0 0 0
  img2 <- createMutableImage size size $ PixelRGB8 0 0 0

  forM_ [0 .. size - 1] $ \x ->
      writePixel img1 x x $ PixelRGB8 200 200 255

  frozen1 <- freezeImage img1
  frozen2 <- freezeImage img2

  writePng "img1.png" frozen1
  writePng "img2.png" frozen2

main :: IO ()
main = biModif

So I'll really need more information.

Won't be able to give a sample before Saturday. But your code looks very
similar to mine.

The exception is that mine is running in a different thread and my data is
read from an IORef at one point.

Probably this could be a problem with using OpenGL (via gloss) in forkIO?
Am 23.01.2015 13:34 schrieb "Vincent" notifications@github.com:

I'm not able to reproduce the problem with the following code:

import Control.Monad( forM_ )import Codec.Pictureimport Codec.Picture.Types
biModif :: IO ()
biModif = do
let size = 10
img1 <- createMutableImage size size $ PixelRGB8 0 0 0
img2 <- createMutableImage size size $ PixelRGB8 0 0 0

forM_ [0 .. size - 1] $ \x ->
writePixel img1 x x $ PixelRGB8 200 200 255

frozen1 <- freezeImage img1
frozen2 <- freezeImage img2

writePng "img1.png" frozen1
writePng "img2.png" frozen2
main :: IO ()
main = biModif

So I'll really need more information.


Reply to this email directly or view it on GitHub
#81 (comment)
.

On Fri, Jan 23, 2015 at 6:06 AM, fhaust notifications@github.com wrote:

Won't be able to give a sample before Saturday. But your code looks very
similar to mine.

The exception is that mine is running in a different thread and my data is
read from an IORef at one point.

Probably this could be a problem with using OpenGL (via gloss) in forkIO?

Yes, that could be an issue. OpenGL API calls need to happen from the
original thread for the process. As far as I can tell, this is due to
vendor implementations and not something that can be fixed from Haskell.