Re: [racket-users] Time for draw-bitmap

2015-05-11 Thread Robby Findler
This definitely seems worth experimenting with. big-bang does (can,
really) create bitmaps itself. It gets 2htdp/image images from the
user's program and then it can create a bitmap to draw them into
directly, if it wants to. It may already be creating a bitmap
explicitly, I'm not sure.

Robby


On Mon, May 11, 2015 at 12:43 AM, Jens Axel Søgaard
jensa...@soegaard.net wrote:
 2015-05-11 2:24 GMT+02:00 Robby Findler ro...@eecs.northwestern.edu:

 But if you have a specific destination in mind you can make the bitmap
 first and then draw the 2htdp/image into it (or anything into it!)


 When I use my own game-loop it is easy enough to use the make-bitmap method
 of the canvas.

 I did see a significant improvement in responsiveness, so I thought maybe
 the same trick could be used in the implementation of big-bang. It's
 tricky though since the user produces the bitmaps, not the big-bang loop
 itself.

 FWIW: On OS X the difference between the two methods is so large the game
 went from unplayable to playable (due to a single call to draw-bitmap).
 I saw times between 7-9 milliseconds for the call.

 /Jens Axel


-- 
You received this message because you are subscribed to the Google Groups 
Racket Users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Time for draw-bitmap

2015-05-10 Thread Jens Axel Søgaard
2015-05-11 0:56 GMT+02:00 Matthew Flatt mfl...@cs.utah.edu:

 At Mon, 11 May 2015 00:30:05 +0200, Jens Axel Søgaard wrote:
  2015-05-11 0:07 GMT+02:00 Matthew Flatt mfl...@cs.utah.edu:
 
   If you're on OS X, try creating the bitmap with
  
(send canvas make-bitmap screen-width screen-height)
  
   instead of
  
(make-object bitmap% screen-width screen-height)
  
   Roughly, using the `make-bitmap` method creates a bitmap that's on the
   graphics card instead of main memory.
 
 
  Two thoughts:
- will make-screen-bitmap work too?

 No, only the `make-bitmap` method.

 See also
  http://docs.racket-lang.org/draw/overview.html#%28part._.Portability%29


Ok.


- If I insert images in the teaching languages,
  do they become screen-bitmaps automatically?

 No, I don't think so.

 It's possible that it would make sense for `freeze` to use
 `make-bitmap`-method bitmaps. The `pict-pre-render-pict` function is
 similar to `freeze`, except that it's for picts in Slideshow, and it
 does use the `make-bitmap` method of Slideshow's canvas. (As you might
 guess, Slideshow was the original motivation for the feature.) I'm not
 certain that using a `make-bitmap` method would make as much sense even
 for `freeze`, since those images are less tied to a specific
 destination.


Thanks.

-- 
You received this message because you are subscribed to the Google Groups 
Racket Users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Time for draw-bitmap

2015-05-10 Thread Jens Axel Søgaard
2015-05-11 2:24 GMT+02:00 Robby Findler ro...@eecs.northwestern.edu:

 But if you have a specific destination in mind you can make the bitmap
 first and then draw the 2htdp/image into it (or anything into it!)


When I use my own game-loop it is easy enough to use the make-bitmap method
of the canvas.

I did see a significant improvement in responsiveness, so I thought maybe
the same trick could be used in the implementation of big-bang. It's
tricky though since the user produces the bitmaps, not the big-bang loop
itself.

FWIW: On OS X the difference between the two methods is so large the game
went from unplayable to playable (due to a single call to draw-bitmap).
I saw times between 7-9 milliseconds for the call.

/Jens Axel

-- 
You received this message because you are subscribed to the Google Groups 
Racket Users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Time for draw-bitmap

2015-05-10 Thread Robby Findler
But if you have a specific destination in mind you can make the bitmap
first and then draw the 2htdp/image into it (or anything into it!)

Robby

On Sunday, May 10, 2015, Matthew Flatt mfl...@cs.utah.edu wrote:

 At Mon, 11 May 2015 00:30:05 +0200, Jens Axel Søgaard wrote:
  2015-05-11 0:07 GMT+02:00 Matthew Flatt mfl...@cs.utah.edu
 javascript:;:
 
   If you're on OS X, try creating the bitmap with
  
(send canvas make-bitmap screen-width screen-height)
  
   instead of
  
(make-object bitmap% screen-width screen-height)
  
   Roughly, using the `make-bitmap` method creates a bitmap that's on the
   graphics card instead of main memory.
 
 
  Two thoughts:
- will make-screen-bitmap work too?

 No, only the `make-bitmap` method.

 See also
  http://docs.racket-lang.org/draw/overview.html#%28part._.Portability%29

- If I insert images in the teaching languages,
  do they become screen-bitmaps automatically?

 No, I don't think so.

 It's possible that it would make sense for `freeze` to use
 `make-bitmap`-method bitmaps. The `pict-pre-render-pict` function is
 similar to `freeze`, except that it's for picts in Slideshow, and it
 does use the `make-bitmap` method of Slideshow's canvas. (As you might
 guess, Slideshow was the original motivation for the feature.) I'm not
 certain that using a `make-bitmap` method would make as much sense even
 for `freeze`, since those images are less tied to a specific
 destination.

 --
 You received this message because you are subscribed to the Google Groups
 Racket Users group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to racket-users+unsubscr...@googlegroups.com javascript:;.
 For more options, visit https://groups.google.com/d/optout.


-- 
You received this message because you are subscribed to the Google Groups 
Racket Users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Time for draw-bitmap

2015-05-10 Thread Matthew Flatt
If you're on OS X, try creating the bitmap with

 (send canvas make-bitmap screen-width screen-height)

instead of

 (make-object bitmap% screen-width screen-height)

Roughly, using the `make-bitmap` method creates a bitmap that's on the
graphics card instead of main memory.

At Sun, 10 May 2015 23:14:08 +0200, Jens Axel Søgaard wrote:
 Hi All,
 
 The attached files are a work-in-progress. Eventually it will become a
 remake of Cees Kramer's Snoopy for C64.
 
 Anyways, the game represents an unmoveable object as a block structure.
 Today I decided to stop rendering the blocks for every frame. Instead
 they are rendered once to a background image, and then simply
 replace (send dc clear) with (send dc draw-bitmap the-background 0 0)
 in the game loop.
 
 To my surprise the frame rate dropped. It seems draw-bitmap is more
 expensive than I thought.?  Or ... perhaps I am doing something
 that trips up draw-bitmap?
 
 Anyways, I have attached the game. To see the difference: Hold down
 the space bar.
 
 /Jens Axel

-- 
You received this message because you are subscribed to the Google Groups 
Racket Users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Time for draw-bitmap

2015-05-10 Thread Jens Axel Søgaard
Worked like a charm.

Thanks!

2015-05-11 0:07 GMT+02:00 Matthew Flatt mfl...@cs.utah.edu:

 If you're on OS X, try creating the bitmap with

  (send canvas make-bitmap screen-width screen-height)

 instead of

  (make-object bitmap% screen-width screen-height)

 Roughly, using the `make-bitmap` method creates a bitmap that's on the
 graphics card instead of main memory.

 At Sun, 10 May 2015 23:14:08 +0200, Jens Axel Søgaard wrote:
  Hi All,
 
  The attached files are a work-in-progress. Eventually it will become a
  remake of Cees Kramer's Snoopy for C64.
 
  Anyways, the game represents an unmoveable object as a block structure.
  Today I decided to stop rendering the blocks for every frame. Instead
  they are rendered once to a background image, and then simply
  replace (send dc clear) with (send dc draw-bitmap the-background 0 0)
  in the game loop.
 
  To my surprise the frame rate dropped. It seems draw-bitmap is more
  expensive than I thought.?  Or ... perhaps I am doing something
  that trips up draw-bitmap?
 
  Anyways, I have attached the game. To see the difference: Hold down
  the space bar.
 
  /Jens Axel

 --
 You received this message because you are subscribed to the Google Groups
 Racket Users group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to racket-users+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/d/optout.




-- 
-- 
Jens Axel Søgaard

-- 
You received this message because you are subscribed to the Google Groups 
Racket Users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Time for draw-bitmap

2015-05-10 Thread Jens Axel Søgaard
2015-05-11 0:07 GMT+02:00 Matthew Flatt mfl...@cs.utah.edu:

 If you're on OS X, try creating the bitmap with

  (send canvas make-bitmap screen-width screen-height)

 instead of

  (make-object bitmap% screen-width screen-height)

 Roughly, using the `make-bitmap` method creates a bitmap that's on the
 graphics card instead of main memory.


Two thoughts:
  - will make-screen-bitmap work too?
  - If I insert images in the teaching languages,
do they become screen-bitmaps automatically?

/Jens Axel

-- 
You received this message because you are subscribed to the Google Groups 
Racket Users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Time for draw-bitmap

2015-05-10 Thread Matthew Flatt
At Mon, 11 May 2015 00:30:05 +0200, Jens Axel Søgaard wrote:
 2015-05-11 0:07 GMT+02:00 Matthew Flatt mfl...@cs.utah.edu:
 
  If you're on OS X, try creating the bitmap with
 
   (send canvas make-bitmap screen-width screen-height)
 
  instead of
 
   (make-object bitmap% screen-width screen-height)
 
  Roughly, using the `make-bitmap` method creates a bitmap that's on the
  graphics card instead of main memory.
 
 
 Two thoughts:
   - will make-screen-bitmap work too?

No, only the `make-bitmap` method.

See also
 http://docs.racket-lang.org/draw/overview.html#%28part._.Portability%29

   - If I insert images in the teaching languages,
 do they become screen-bitmaps automatically?

No, I don't think so.

It's possible that it would make sense for `freeze` to use
`make-bitmap`-method bitmaps. The `pict-pre-render-pict` function is
similar to `freeze`, except that it's for picts in Slideshow, and it
does use the `make-bitmap` method of Slideshow's canvas. (As you might
guess, Slideshow was the original motivation for the feature.) I'm not
certain that using a `make-bitmap` method would make as much sense even
for `freeze`, since those images are less tied to a specific
destination.

-- 
You received this message because you are subscribed to the Google Groups 
Racket Users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.