[Helpful list of Graphics2D RenderingHints I use]

Somebody should find these helpful =D


		g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
		g2d.setRenderingHint(RenderingHints.KEY_DITHERING, RenderingHints.VALUE_DITHER_ENABLE);
		g2d.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
		g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
		g2d.setRenderingHint(RenderingHints.KEY_TEXT_LCD_CONTRAST, 100);
		g2d.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_ON);
		g2d.setRenderingHint(RenderingHints.KEY_ALPHA_INTERPOLATION, RenderingHints.VALUE_ALPHA_INTERPOLATION_QUALITY);
		g2d.setRenderingHint(RenderingHints.KEY_COLOR_RENDERING, RenderingHints.VALUE_COLOR_RENDER_QUALITY);
		g2d.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL,RenderingHints.VALUE_STROKE_PURE);	

Obtaining the Graphics2D object from a paint(Graphics g):


	public void paint(Graphics g) {
		super.paint(g);
		final Graphics2D g2d = (Graphics2D) g;
		// Rendering Hints applied here
		// Game Painting here
	}

Enjoy those 2 FPS on weak systems! ;D

EDIT: Just to make sure, I didn’t even know any of those existed, and I learned something new today. However, I’m not making fun of you here, I’m making fun of Java2D’s performance :slight_smile:

Ouch! :stuck_out_tongue:

Only drops a few fps, still averages (on a piece of shit computer) 40 to 87fps.

I always use RenderingHints to turn off anti-alias.

I made a physics based Asteroid game with JBox2D, and had physics running in one thread and rendering in another. Worked wonders with antialiasing on dual cores, lagged to death on singles. Well, that was back when single cores actually still existed.

I had a similar experience but on a multicore and switching from one thread to two. Sometimes it wouldn’t leave time to do a good A-star search even though it didn’t lag. I wanted to do searches on multiple threads anyway, but I couldn’t figure out why it did that while still having time for multiple rendering updates per physics update.

(Edit) What does this line do?

g2d.setRenderingHint(RenderingHints.KEY_TEXT_LCD_CONTRAST, 100);

http://docs.oracle.com/javase/6/docs/api/java/awt/RenderingHints.html#KEY_TEXT_LCD_CONTRAST


KEY_TEXT_LCD_CONTRAST

public static final RenderingHints.Key KEY_TEXT_LCD_CONTRAST
LCD text contrast rendering hint key. The value is an Integer object which is used as a text contrast adjustment when used in conjunction with an LCD text anti-aliasing hint such as VALUE_TEXT_ANTIALIAS_LCD_HRGB.
Values should be a positive integer in the range 100 to 250.
A lower value (eg 100) corresponds to higher contrast text when displaying dark text on a light background.
A higher value (eg 200) corresponds to lower contrast text when displaying dark text on a light background.
A typical useful value is in the narrow range 140-180.
If no value is specified, a system or implementation default value will be applied.

I only ever use text (and sometimes regular) antialiasing just because it makes the font/shapes look cleaner. It can be disabled of course, in case your computer can’t handle it :stuck_out_tongue:

In meh game due to using Java2D these are the only real things that I can turn on and off to effect performance so I added them and really…the only thing that changed fps was the Rending hint as it would set this hint

g2d.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);

When it was set to quality. This is the only thing that changed the quality at all and that is if you are scaling anything.

Nothing else changed performance. Antialiasing only effects text and primitives I believe. So if you are using more images then it is safe to keep it on.

Never turn off antialiasing, unless you want your game to look utter crap. If it’s too slow when it’s turned on… do something else.

Cas :slight_smile: