Java-Gaming.org Hi !
Featured games (81)
games approved by the League of Dukes
Games in Showcase (513)
Games in Android Showcase (119)
games submitted by our members
Games in WIP (576)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  [Helpful list of Graphics2D RenderingHints I use]  (Read 4235 times)
0 Members and 1 Guest are viewing this topic.
Offline GabrielBailey74
« Posted 2012-08-10 22:46:36 »

Somebody should find these helpful =D

1  
2  
3  
4  
5  
6  
7  
8  
9  
      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):
1  
2  
3  
4  
5  
6  
   public void paint(Graphics g) {
      super.paint(g);
      final Graphics2D g2d = (Graphics2D) g;
      // Rendering Hints applied here
      // Game Painting here
   }

Offline ra4king

JGO Kernel


Medals: 350
Projects: 3
Exp: 5 years


I'm the King!


« Reply #1 - Posted 2012-08-10 23:03:47 »

Enjoy those 2 FPS on weak systems! Grin

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 Smiley

Offline coltonoscopy

Junior Duke


Medals: 2



« Reply #2 - Posted 2012-08-10 23:05:43 »

Enjoy those 2 FPS on weak systems! Grin
Ouch! :p

Straight flippin.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline GabrielBailey74
« Reply #3 - Posted 2012-08-10 23:13:25 »

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

Offline ReBirth
« Reply #4 - Posted 2012-08-11 02:42:08 »

I always use RenderingHints to turn off anti-alias.

Offline theagentd
« Reply #5 - Posted 2012-08-11 13:17:11 »

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

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.

Myomyomyo.
Offline Best Username Ever

Junior Duke





« Reply #6 - Posted 2012-08-11 16:34:24 »

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?
1  
g2d.setRenderingHint(RenderingHints.KEY_TEXT_LCD_CONTRAST, 100);
Offline GabrielBailey74
« Reply #7 - Posted 2012-08-12 02:44:07 »

http://docs.oracle.com/javase/6/docs/api/java/awt/RenderingHints.html#KEY_TEXT_LCD_CONTRAST
1  
2  
3  
4  
5  
6  
7  
8  
9  
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.

Offline Z-Man
« Reply #8 - Posted 2012-08-13 06:59:36 »

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 Tongue
Offline StumpyStrust
« Reply #9 - Posted 2012-08-13 08:22:46 »

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.

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline princec

JGO Kernel


Medals: 404
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #10 - Posted 2012-08-13 10:32:30 »

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 Smiley

Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

Longarmx (38 views)
2014-10-17 03:59:02

Norakomi (29 views)
2014-10-16 15:22:06

Norakomi (24 views)
2014-10-16 15:20:20

lcass (28 views)
2014-10-15 16:18:58

TehJavaDev (56 views)
2014-10-14 00:39:48

TehJavaDev (55 views)
2014-10-14 00:35:47

TehJavaDev (46 views)
2014-10-14 00:32:37

BurntPizza (64 views)
2014-10-11 23:24:42

BurntPizza (36 views)
2014-10-11 23:10:45

BurntPizza (78 views)
2014-10-11 22:30:10
Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!