[JAVA2D] MemoryImageSource flickers when I update pixels with newPixels()...

2007-04-07 Thread Ken Warner

I'm haveing a strange problem -- I've used MemoryImageSource before with
great success.  But now, doing the same thing I've done before in Java 1.4
I'm getting flickering on newPixels() in Java 1.5...

That is, when I send new pixels to my MemoryImageSource mis and repaint() the 
image flickers badly.  Didn't do this in 1.4.

The odd thing is that --

while((status = bg.drawImage(canvasImage,0,0,thisW, thisH,this)) == false);

never breaks because bg.drawImage never returns true.  Do I have to use a 
MediaTracker
or something???

Here's what I'm doing -- I've tried it using BufferStrategy and get the same 
flicker

  //this is an AWT Canvas
  private Image canvasImage = null;
  private Image buffer = null;
  private Graphics2D bg = null;
  private MemoryImageSource mis = null;
  private ColorModel cm = null;
  init()
  {
  thisW = this.getWidth();
  thisH = this.getHeight();
  mis = new MemoryImageSource(thisW,thisH,pixels,0,thisW);
  mis.setAnimated(true);
  mis.setFullBufferUpdates(true);
  canvasImage = this.createImage(mis);
  buffer = this.createImage(thisW, thisH);
  bg = (Graphics2D)buffer.getGraphics();
   }

  public void paint(Graphics g)
  {
  g.drawImage(buffer,0,0,thisW, thisH,this);
  }
 public void newPixels(int [] newPixels)
  {
  mis.newPixels(newPixels, ColorModel.getRGBdefault(),0, thisW);
  boolean status = false;
  //while((status = bg.drawImage(canvasImage,0,0,thisW, thisH,this)) == 
false);
  bg.drawImage(canvasImage,0,0,thisW, thisH,this);
  this.repaint();
  }

===
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA2D-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".


[JAVA2D] Rendering 2D shapes in OpenGL

2007-04-07 Thread Mark McKay

Not strictly a Java2D question, but I thought I'd ask here because there
are a lot of knowledgeable people who've worked on the OpenGL 2D pipeline.

I'm writing an application in JOGL and need to draw some curved 2D
shapes (with an orthographic view, so they will appear to overlay the
rest of the scene).  Effectively, I want to emulate the
Graphics2D.draw(Shape) and Graphics2D.fill(Shape).  Some of these shapes
will be defined by connected Bezier curves (similar to a GeneralPath).
What's the best way to render such a shape in OpenGL?  I can subdivide
each of the Bezier segments into smaller segments until the resolution
is small enough to approximate it with straight line segments - but that
would lead to an extremely tessellated shape.  And how would I emulate a
stroked outline?  Convert the outline to a Shape first?  How did the
Java2D team tackle this?

Mark McKay

===
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA2D-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".