FAQ
Cover
This is the archive Discourse for the Processing (ALPHA) software.
Please visit the new Processing forum for current information.

   Processing 1.0 _ALPHA_
   Programming Questions & Help
   Programs
(Moderators: fry, REAS)
   optomising animation by refreshing changed rect
« Previous topic | Next topic »

Pages: 1 2 
   Author  Topic: optomising animation by refreshing changed rect  (Read 2641 times)
justo


Re: optomising animation by refreshing changed rec
« Reply #15 on: Apr 9th, 2004, 12:51am »

on Apr 8th, 2004, 7:58pm, arielm wrote:

personally, here's what i do to grab the pixels of a BufferedImage:
Code:
BufferedImage image = new BufferedImage(W, H, BufferedImage.TYPE_INT_RGB);
int[] pixels = ((DataBufferInt) image.getRaster().getDataBuffer()).getData();

 
maybe you get more than the 10-15% acceleration i was mentionning because you work in "full-screen mode"
 
(my engine is for web-use, so it can't take advantage of this mode)
 
btw, from all the articles and forum posts i could read, "full-screen-mode" is giving insane (i.e. above 100fps) framerate results, even when using MemoryImageSource.

 
nope, working in an applet window at 800x800. i am running a P4 with a radeon 9800 pro, so that is definitely helping...thats why i thought it must be accelerated, because i'm not doing anything special that you arent doing, except asking the GraphicsConfiguration for the BufferedImage.
 
do you have any links on how to get full screen mode up and running i'd like to try it out now that im working on my own "engine" but all i've ever seen are rather confusing asides about how you can do it with 1.4.
 
it might not be applicable, especially if youre targeting 1.1 users as well, but have you tried webstart
 
justo


Re: optomising animation by refreshing changed rec
« Reply #16 on: Apr 9th, 2004, 12:53am »

hehe, and sorry for hijacking your thread, ed. as i understand it, it will be rather complicated to subclass bImage without the source, as you wont be able to just call super() and then build from there. hopefully fry or someone else can help you around.
 
ed

WWW Email
time to fly the processing nest?
« Reply #17 on: Apr 12th, 2004, 9:20pm »

on Apr 9th, 2004, 12:53am, justo wrote:
hehe, and sorry for hijacking your thread, ed. as i understand it, it will be rather complicated to subclass bImage without the source, as you wont be able to just call super() and then build from there. hopefully fry or someone else can help you around.

 
A thouraghly worthwhile hijack if ever there was one, thank you . So, I've done lots of tinkering around (outside of p5) with GraphicsDevice.setDisplayMode and GraphicsDevice.setFullScreenWindow to go fullscreen, and am now using a combination of BufferStrategy (with two buffers) and BufferedImage (with buffers created using GraphicsConfiguration.createCompatibleImage) to redraw only the main portion of my 1024x768 screen that needs all the framerate it can muster (with interface elements lingering around in a less volatile buffer). The result (before implementing any fancy functionality of course) is a tenfold leap in framerate to something confidently over 50ps.
 
So now my dilema is this; to get this blistering sort-of fullscreen framerate I've left processing entirely rather than a) try to overide P5 to persuade it to do the above or b) join the p5 dev team and be initiated into the magic of compiling the bagel beasty (I wish I could, but I'm afraid that would open a can of worms that would swallow my project schedule).
 
Is it time for Moovl to fly the processing nest
 
justo


Re: optomising animation by refreshing changed rec
« Reply #18 on: Apr 12th, 2004, 11:22pm »

hey, your approach sounds interesting. are you willing to post/link to some of that code? i would really appreciate a more in depth explanation at the very least.
 
one approach to your problem, and a simple one at that, would be to just make a fullscreen java program that added the p5 applet to its frame. you would lose all your fancy stuff, though, so it may not be worth it. in any case, i just discovered this code on gamedev.net today, so i wanted to share it with someone
 
Code:

import java.awt.*;
public class fullscreen {      
 private static GraphicsEnvironment   env;    
 private static GraphicsDevice   device;    
 private static GraphicsConfiguration gc;    
 private static DisplayMode      mode;    
 private static Frame    frame;    
 
 public static void main(String[] args) {    
  env    = GraphicsEnvironment.getLocalGraphicsEnvironment();  
  device = env.getDefaultScreenDevice();    
  gc     = device.getDefaultConfiguration();  
  mode   = device.getDisplayMode();
   
  yourapplet applet = new yourapplet();  
   
  frame  = new Frame("Frame!");      
  applet.setSize(mode.getWidth(),mode.getHeight());    
  applet.init();    
  applet.start();
   
  frame.setBackground(Color.black);    
  frame.dispose();    
  frame.setResizable(false);    
  frame.setUndecorated(true);    
  frame.add(applet);    
  frame.pack();    
  frame.setVisible(true);    
  device.setFullScreenWindow(frame);    
 }  
}

 
and you replace "yourapplet" with whatever class your want to run. so...dont know if youve seen this code, but it works really well, so i thought id post it.
 
fry


WWW
Re: optomising animation by refreshing changed rec
« Reply #19 on: Apr 14th, 2004, 1:39am »

i'm not sure if the above stuff does it, but moreso than BufferedImage, the BufferStrategy class seems to allow for page-flipping and other fanciness that allows full screen java 1.4 apps to run much, much faster.  
 
erikb pointed me to this book:  
http://www.brackeen.com/javagamebook/
 
check out the example game, you won't believe it's java. we oughta be able to put this sort of wrapper on BApplet for folks that can run full screen in 1.4 (no applets, just applications) which could be really nice.
 
ed

WWW Email
Re: optomising animation by refreshing changed rec
« Reply #20 on: Apr 14th, 2004, 9:14am »

on Apr 14th, 2004, 1:39am, fry wrote:
the BufferStrategy class seems to allow for page-flipping and other fanciness that allows full screen java 1.4 apps to run much, much faster.

 
mm, page-flipping rooools for fullscreen animation. I based my code on the full-screen exclusive mode (FSEM) example in this book chapter...
 
http://fivedots.coe.psu.ac.th/~ad/jg/ch03/
 
...and while it doesn't look nearly as cute as the example Ben quoted it does have the advantage of not being accomanied by that furiously catchy off-key midi soundtrack that I've not been able to get out of my head all morning .
 
By the by, has anyone tested these flipping examples on a Mac yet At the moment my code is still running like an old dog on MacOsX for some reason
« Last Edit: Apr 14th, 2004, 9:19am by ed »  
fry


WWW
Re: optomising animation by refreshing changed rec
« Reply #21 on: Apr 14th, 2004, 7:19pm »

yeah, the example with the perverse midi music you cite runs quite zippy on my dual-g4 running the latest macosx and java.  
 
and as someone who has a tendency to get tunes stuck in their head (i was once afflicted with the theme from "CHiPs" for a period of six weeks), i apologize for not having warned you to shut the music off.
« Last Edit: Apr 14th, 2004, 7:21pm by fry »  
Pages: 1 2 

« Previous topic | Next topic »