Java-Gaming.org Java4K winners: [ by our judges | by the community ]         
Featured games (67)
games approved by the League of Dukes
Games in Showcase (∞)
games submitted by our members



News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  Print  
  AffineTransform with openGL Pipeline slower than without  (Read 1076 times)
0 Members and 1 Guest are viewing this topic.
Offline quietschie

JGO n00b
*

Posts: 2



« on: 2012-02-01 10:46:18 »

Hi Everyone,

i'm fetching bufferedImages from camera and want to scale them to whatever window-size is.
Therefore i use the AffineTransform like this
1  
AffineTransform xform2 = AffineTransform.getScaleInstance((double)getWidth() / myWidth, (double)getHeight() / myHeight);

where myWidth / myHeight hold the original Image width/height.
I draw the images via
1  
2  
g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC);
g2.drawImage(image, xform2, null);


this works fine with about 25 fps, but when i switch to fullscreen i only got about 7 fps left.
when i run the application with the openGL pipeline Option
1  
-Dsun.java2d.opengl=True
it slows down to 2 fps in small size.

Any idea highly appreciated.

quietschie
Online theagentd

JGO Wizard
****

Posts: 1391
Medals: 88



« Reply #1 on: 2012-02-01 10:55:43 »

Might be because you use bicubic interpolation. It's probably not hardware accelerated, but I'm no Java2D expert...

There is no god.
Offline quietschie

JGO n00b
*

Posts: 2



« Reply #2 on: 2012-02-01 11:08:37 »

Wow,
removing this line gave me 3 more fps with openGL and more than the camera fetches without using openGL.

Unfortunately the quality is now poor.
So thank you, theagentd, this will work for my first draft.

But i'm still open for other solutions.

quietschie
Games published by our own members! Go get 'em!
Online theagentd

JGO Wizard
****

Posts: 1391
Medals: 88



« Reply #3 on: 2012-02-01 13:23:55 »

Bicubic interpolation is really slow. Each pixel requires 4*4 samples from the image being rendered, so it's a lot of work. You can try VALUE_INTERPOLATION_BILINEAR, which is something in between nearest-neighbor (pixelized) sampling and bicubic sampling (it uses 2*2 samples). It won't look as good as bicubic of course, but it's usually much better than nothing at all.

There is no god.
Offline pitbuller

Sr. Member
**

Posts: 339
Medals: 9



« Reply #4 on: 2012-02-01 14:14:08 »

Bicubic interpolation is really slow. Each pixel requires 4*4 samples from the image being rendered, so it's a lot of work. You can try VALUE_INTERPOLATION_BILINEAR, which is something in between nearest-neighbor (pixelized) sampling and bicubic sampling (it uses 2*2 samples). It won't look as good as bicubic of course, but it's usually much better than nothing at all.
And most important it's hardware accelerated(at least very often).

Offline Cero

JGO Neuromancer
****

Posts: 1050
Medals: 18



« Reply #5 on: 2012-02-01 19:22:48 »

on windows java2D should default to directX, which is faster than opengl
generally java2d seems to work better with directx

just my impression though

Offline ra4king

JGO Kernel
*****

Posts: 3147
Medals: 196


I'm the King!


« Reply #6 on: 2012-02-01 21:17:35 »

You can't really say "DirectX is faster than OpenGL" since they are both just specs and the driver is the one that implements them. Java2D seems to use DirectX better than OpenGL, which makes it run faster on it but that does not mean DirectX is overall "faster" than OpenGL.

Offline Cero

JGO Neuromancer
****

Posts: 1050
Medals: 18



« Reply #7 on: 2012-02-02 08:44:40 »

Java2D seems to use DirectX better than OpenGL

Yes I meant this.

java2D using direct vs java2d using opengl: directx seems to win
has nothing to do with real opengl

Offline gouessej

JGO Kernel
*****

Posts: 3558
Medals: 30


TUER


« Reply #8 on: 2012-02-02 17:39:28 »

quietschie, if you want something faster, look at Slick or Agile2D.

Julien Gouesse
Pages: [1]
  Print  
 
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!
Page created in 0.135 seconds with 20 queries.