Re: [JAVA2D] Graphics Tearing Issue

2006-04-27 Thread Dmitri Trembovetski
  I just wanted to add, do you really need to have two _translucent_
  images the size of the screen? Why not render directly to the
  back-buffer?

  Thanks,
Dmitri


On Thu, Apr 27, 2006 at 02:11:23PM -0700, Chet Haase wrote:
 > Hi,
 >
 > I talked about the tearing issue in my blog entry and article
 > on choppy animations:
 > http://weblogs.java.net/blog/chet/archive/2006/02/make_your_anima.html
 > http://today.java.net/pub/a/today/2006/02/23/smooth-moves-solutions.html
 >
 > You're basically running into a vertical refresh artifact.
 >
 > Running fullscreen with a BufferStrategy is a decent way to
 > work around this; depending on the platform and the situation,
 > we will usually give you a Flip strategy, which is (usually)
 > synchronized with the vertical refresh of the display to avoid
 > tearing.
 >
 > There are some things that might contribute to this not working,
 > however:
 > - What platform are you running on?  It's possible that the
 > Flip strategy on your particular platform is actually doing a
 > copy behind the scenes, which would be the same as the BltBufferStrategy,
 > which runs smack into the refresh artifact.
 > - What pipeline are you using?  The default?  Are you specifying
 > OpenGL?  or Direct3D?  What release are you using?  These can
 > all affect how we are implementing the buffer strategy under
 > the hood.
 > - The graphics operations you do to the back buffer could
 > actually impact things as well; it's possible that we would
 > punt the buffer to system memory in some situations because
 > the operations you are doing (apart from the flip/blt) are
 > faster in software.  This is particularly the case for
 > translucency; reading from video memory is an amazingly
 > slow operation, and we do not necessarily support translucency
 > through hardware on all platforms.
 >
 > Anyway, hopefully this helps you track things down a bit...
 >
 > Chet.
 >
 >
 > [EMAIL PROTECTED] wrote:
 > >I've been trying to work around an issue involving tearing during a
 > >buffered rendering process in my code. Im using a buffer strategy to page
 > >flip to BufferedImages to conduct a animation. The problem is that on
 > >every interation of the render the square box that I render it tearing. I
 > >have purchased multiple books and have visted multiple web sites on how to
 > >solve the tearing problem. And I in NO MEANS want to copy or use someone
 > >elses code. Pasted below is the code that I developed. Any suggestions are
 > >welcome. Thanks.
 > >
 > >import java.awt.*;
 > >import java.awt.image.*;
 > >import java.awt.event.*;
 > >import javax.swing.*;
 > >import java.io.*;
 > >import java.awt.geom.*;
 > >
 > >public class GameEngine implements Runnable
 > >{
 > >
 > >private GraphicsConfiguration[] gc;
 > >private GraphicsDevice gd;
 > >private GraphicsEnvironment ge;
 > >private DisplayMode dm;
 > >private DisplayMode dms[];
 > >private JFrame frame;
 > >private Container c;
 > >private File file;
 > >private FileWriter writer;
 > >private BufferCapabilities buffercap;
 > >private ImageCapabilities imagecap;
 > >private Window window;
 > >private BufferStrategy bufstrat;
 > >private Thread t;
 > >private int x = 0;
 > >private BufferedImage back1;
 > >private BufferedImage back2;
 > >
 > >public GameEngine()
 > >{
 > >
 > >t = new Thread(this,"Game Loop");
 > >
 > >try
 > >{
 > >
 > >SwingUtilities.invokeAndWait(new Runnable(){
 > >
 > >
 > >public void run()
 > >{
 > >
 > >try
 > >{
 > >
 > >initGraphics();
 > >init();
 > >
 > >}
 > >catch(Exception e)
 > >{
 > >
 > >e.printStackTrace();
 > >}
 > >
 > >}
 > >
 > >
 > >
 > >});
 > >
 > >}
 > >catch(Exception e)
 > >{
 > >
 > >e.printStackTrace();
 > >}
 > >
 > >
 > >}
 > >
 > >public void initGraphics()
 > >{
 > >
 > >ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
 > >gd = ge.getDefaultScreenDevice();
 > >dm = gd.getDisplayMode();
 > >gc = gd.getConfigurations();
 > >dms = gd.getDisplayModes();
 > >back1 = new
 > >
 > > BufferedImage(dm.getWidth(),dm.getHeight(),BufferedImage.TYPE_INT_ARGB);
 > >back2 = new
 > >
 > > BufferedImage(dm.getWidth(),dm.getHeight(),BufferedImag

Re: [JAVA2D] Graphics Tearing Issue

2006-04-27 Thread Chet Haase

Hi,

I talked about the tearing issue in my blog entry and article
on choppy animations:
http://weblogs.java.net/blog/chet/archive/2006/02/make_your_anima.html
http://today.java.net/pub/a/today/2006/02/23/smooth-moves-solutions.html

You're basically running into a vertical refresh artifact.

Running fullscreen with a BufferStrategy is a decent way to
work around this; depending on the platform and the situation,
we will usually give you a Flip strategy, which is (usually)
synchronized with the vertical refresh of the display to avoid
tearing.

There are some things that might contribute to this not working,
however:
- What platform are you running on?  It's possible that the
Flip strategy on your particular platform is actually doing a
copy behind the scenes, which would be the same as the BltBufferStrategy,
which runs smack into the refresh artifact.
- What pipeline are you using?  The default?  Are you specifying
OpenGL?  or Direct3D?  What release are you using?  These can
all affect how we are implementing the buffer strategy under
the hood.
- The graphics operations you do to the back buffer could
actually impact things as well; it's possible that we would
punt the buffer to system memory in some situations because
the operations you are doing (apart from the flip/blt) are
faster in software.  This is particularly the case for
translucency; reading from video memory is an amazingly
slow operation, and we do not necessarily support translucency
through hardware on all platforms.

Anyway, hopefully this helps you track things down a bit...

Chet.


[EMAIL PROTECTED] wrote:

I've been trying to work around an issue involving tearing during a buffered 
rendering process in my code. Im using a buffer strategy to page flip to 
BufferedImages to conduct a animation. The problem is that on every interation 
of the render the square box that I render it tearing. I have purchased 
multiple books and have visted multiple web sites on how to solve the tearing 
problem. And I in NO MEANS want to copy or use someone elses code. Pasted below 
is the code that I developed. Any suggestions are welcome. Thanks.

import java.awt.*;
import java.awt.image.*;
import java.awt.event.*;
import javax.swing.*;
import java.io.*;
import java.awt.geom.*;

public class GameEngine implements Runnable
{

private GraphicsConfiguration[] gc;
private GraphicsDevice gd;
private GraphicsEnvironment ge;
private DisplayMode dm;
private DisplayMode dms[];
private JFrame frame;
private Container c;
private File file;
private FileWriter writer;
private BufferCapabilities buffercap;
private ImageCapabilities imagecap;
private Window window;
private BufferStrategy bufstrat;
private Thread t;
private int x = 0;
private BufferedImage back1;
private BufferedImage back2;

public GameEngine()
{

t = new Thread(this,"Game Loop");

try
{

SwingUtilities.invokeAndWait(new Runnable(){


public void run()
{

try
{

initGraphics();
init();

}
catch(Exception e)
{

e.printStackTrace();
}

}



});

}
catch(Exception e)
{

e.printStackTrace();
}


}

public void initGraphics()
{

ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
gd = ge.getDefaultScreenDevice();
dm = gd.getDisplayMode();
gc = gd.getConfigurations();
dms = gd.getDisplayModes();
back1 = new 
BufferedImage(dm.getWidth(),dm.getHeight(),BufferedImage.TYPE_INT_ARGB);
back2 = new 
BufferedImage(dm.getWidth(),dm.getHeight(),BufferedImage.TYPE_INT_ARGB);


try
{

file = new File("C:/GraphicsInfo.txt");
writer = new FileWriter(file);


writer.write("Ideology Software Corporation\n");
writer.write("Sample Game Information\n\n");
writer.write("Display Information");
writer.write("\n\n");
writer.write("Width " + dm.getWidth());
writer.write("Height " + dm.getHeight());
writer.write("\n\n");
writer.write("Supported Display Modes");
writer.write("\n\n");


for(

[JAVA2D] Graphics Tearing Issue

2006-04-27 Thread java2d
I've been trying to work around an issue involving tearing during a buffered 
rendering process in my code. Im using a buffer strategy to page flip to 
BufferedImages to conduct a animation. The problem is that on every interation 
of the render the square box that I render it tearing. I have purchased 
multiple books and have visted multiple web sites on how to solve the tearing 
problem. And I in NO MEANS want to copy or use someone elses code. Pasted below 
is the code that I developed. Any suggestions are welcome. Thanks.

import java.awt.*;
import java.awt.image.*;
import java.awt.event.*;
import javax.swing.*;
import java.io.*;
import java.awt.geom.*;

public class GameEngine implements Runnable
{

private GraphicsConfiguration[] gc;
private GraphicsDevice gd;
private GraphicsEnvironment ge;
private DisplayMode dm;
private DisplayMode dms[];
private JFrame frame;
private Container c;
private File file;
private FileWriter writer;
private BufferCapabilities buffercap;
private ImageCapabilities imagecap;
private Window window;
private BufferStrategy bufstrat;
private Thread t;
private int x = 0;
private BufferedImage back1;
private BufferedImage back2;

public GameEngine()
{

t = new Thread(this,"Game Loop");

try
{

SwingUtilities.invokeAndWait(new Runnable(){


public void run()
{

try
{

initGraphics();
init();

}
catch(Exception e)
{

e.printStackTrace();
}

}



});

}
catch(Exception e)
{

e.printStackTrace();
}


}

public void initGraphics()
{

ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
gd = ge.getDefaultScreenDevice();
dm = gd.getDisplayMode();
gc = gd.getConfigurations();
dms = gd.getDisplayModes();
back1 = new 
BufferedImage(dm.getWidth(),dm.getHeight(),BufferedImage.TYPE_INT_ARGB);
back2 = new 
BufferedImage(dm.getWidth(),dm.getHeight(),BufferedImage.TYPE_INT_ARGB);


try
{

file = new File("C:/GraphicsInfo.txt");
writer = new FileWriter(file);


writer.write("Ideology Software Corporation\n");
writer.write("Sample Game Information\n\n");
writer.write("Display Information");
writer.write("\n\n");
writer.write("Width " + dm.getWidth());
writer.write("Height " + dm.getHeight());
writer.write("\n\n");
writer.write("Supported Display Modes");
writer.write("\n\n");


for(int k = 0;k < dms.length;k++)
{
writer.write("\n\n");
writer.write("Display Mode " + k);
writer.write("\n\n");
writer.write("Width " + dms[k].getWidth());
writer.write("\n");
writer.write("Height " + dms[k].getHeight());
writer.write("\n");
writer.write("Bit Depth " + 
dms[k].getBitDepth());
writer.write("\n");
writer.write("Refresh Rate " + 
dms[k].getRefreshRate());
writer.write("\n");

}



for(int i = 0;i < gc.length;i++)
{


Rectangle rect = gc[i].getBounds();
buffercap = gc[i].getBufferCapabilities();
imagecap = gc[i].getImageCapabilities();
writer.write("\n\n");
writer.write("Graphics Configuration " + i);
writer.write("\n\n");
writer.write("Configuration Width " + 
rect.width);
writer.write("\n");
writer.write("Configuration Height " + 
rect.height);
writer.write("\n");
writer.write("Con

Re: [JAVA2D] Real Time Image Processing

2006-04-27 Thread Dmitri Trembovetski
  Hello,

  You might want to take a look at Java Media Framework:
http://java.sun.com/products/java-media/jmf/

  Thanks,
Dmitri


On Wed, Apr 26, 2006 at 10:51:27PM -0700, [EMAIL PROTECTED] wrote:
 > Can I capture real-time video to process it.
 > I wrote a program in Matlab that acquires video from a camera and detects 
 > circles by hough transform on it, so, I want to export my algorithm to JAVA, 
 > is it possible?
 > I'm a beginner in JAVA so I'd really appreciate your help!
 > [Message sent by forum member 'jpas' (jpas)]
 >
 > http://forums.java.net/jive/thread.jspa?messageID=108187
 >
 > ===
 > 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".

===
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".


Re: [JAVA2D] BreakIterator example

2006-04-27 Thread Phil Race

Phil Race wrote:


Peter,

First the delay in getting any response is because this isn't a Java2D
question so I don't
think there's a whole lot of expertise on this list in this area.

I am informed that a better place to have asked this question would have
been :

http://developers.sun.com/contact/feedback.jsp?category=j2se&mailsubject=Internationalization%20(I18N)


which I agree is obscure.


PS .. I was just informed of a Java Internationalization forum :
http://forum.java.sun.com/forum.jspa?forumID=16

that's the real best place for this question

-phil.

===
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".


Re: [JAVA2D] BreakIterator example

2006-04-27 Thread Phil Race

Peter,

First the delay in getting any response is because this isn't a Java2D
question so I don't
think there's a whole lot of expertise on this list in this area.

I am informed that a better place to have asked this question would have
been :

http://developers.sun.com/contact/feedback.jsp?category=j2se&mailsubject=Internationalization%20(I18N)

which I agree is obscure.

Anyway I asked the experts and the response I received was:

>And for the break iterator question, assuming that s/he refers to "a
non-letter supplementary character"
>by "a non-letter surrogate", I think the code happens to work even
though the loop is doing "p++",
>since a stand alone surrogate code point is always non-letter.  So it
just skips the low surrogate in the loop.

For further clarification I suggest the above mentioned web form.

-Phil.

Peter B. West wrote:

The BreakIterator description contains the following example.\

 Find the next word:

 public static int nextWordStartAfter(int pos, String text) {
 BreakIterator wb = BreakIterator.getWordInstance();
 wb.setText(text);
 int last = wb.following(pos);
 int current = wb.next();
 while (current != BreakIterator.DONE) {
 for (int p = last; p < current; p++) {
 if (Character.isLetter(text.codePointAt(p))
 return last;
 }
 last = current;
 current = wb.next();
 }
 return BreakIterator.DONE;
 }


In the inner for loop, what happens if a non-letter surrogate is found?

Peter
--
Peter B. West 
Folio 

===

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".


===
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".