Graphics2D.drawPolygon bug ?

Hi guys !
I face an unexpected problem :o . I simply can’t draw properly a polygon thanks to the drawPolygon method …

http://tanks-game.ifrance.com/Untitled-1.bmp

g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.7f));
g2d.setColor(Color.GREEN);
int[] xVertex = {1,36,36,1,1};
int[] yVertex = {1,1,36,36,1};
g2d.drawPolygon(new Polygon(xVertex,yVertex,5));
//35X35 image
g2d.drawImage(myImage,1,1,null);

There is two problems :

  1. The green rectangle should be wrapping the image but it doesnt at all.
  2. The pixel in the top-right corner isn’t drawn …

I really don’t understand, please help me ???

This is how pixelization rules work - long story. Why don’t you use
a drawRect instead?

Dmitri

Tx to reply Dmitri.
I tryed drawRect and i get the same result :o.
Do you know what operation can lead to this ? :’(

… Well, i found the guilty thing ===> the openGL is responsible of these bugs.

Seems i need to leave that buggy thing alone now (what a shame it speeds up consequently my game).

:-\

Are you using JDK 6? There were a number of bug fixes to improve exact rasterization with the OGL pipeline in that release, not to mention all the other improvements we’ve been harping on for the last year or so.

If not, which video card are you using?

Chris

Chris Campbell Himself :stuck_out_tongue: !
For information i use a Nvidia GeForce 6800GT, driver version: 8.4.2.1
I use jdk 5 update 9.
About the JDK6, i wonder wether its dedicated JRE (JRE6) exists so people can use my program ? (I’m sorry i’m not very used to java :-[ )

there is currently a JDK6 release candidate available - however even the latest beta-builds where extremly stable.
and yes, as far as I know there are JRE versions of both.

Give it a try - there have been great enhancements to the opengl-pipeline since java-5.0.

lg Clemens

Are you using AffineTransforms? With java 1.5 I have found that the OGL pipeline does strange things if the AffineTransform translation was not an integer.

ok tx Linuxhippy, but i can’t find the jre6 :-.
@CommanderKeith : even if i don’t use any AffineTransform it behaves weirdly ???.

Unless JDK6 fixed bugs with ATI cards & openglPipeline, i will give an OGL binding a try (i don’t think i takes so long to refactor java2d into lwjgl ::)).

shitty ati opengl drivers aren’t for sun to fix

[quote]shitty ati opengl drivers aren’t for sun to fix
[/quote]
LOL ;D
Yeah i meant that Sun may have pushed ATI to fix their latest drivers.