Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (491)
Games in Android Showcase (112)
games submitted by our members
Games in WIP (556)
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  
  sun.java2d.opengl=true in applet with BufferStrategy  (Read 7828 times)
0 Members and 1 Guest are viewing this topic.
Offline joeyismusic

Junior Member





« Posted 2012-03-11 08:26:33 »

Whenever I supply my applet with the parameter -Dsun.java2d.opengl and a value of true, and I use a BufferStrategy for drawing, I get a "dirty" rectangle in my browser. Yet if I run as a JFrame or test applet in Eclipse it works just fine... If I remove the BufferStrategy and just use a off-screen image it works fine but isn't accelerated...

Any ideas?

TL:DR - I can't get any of my applets to use both BufferStrategy and sun.java2d.opengl=true simultaneously
Offline ra4king

JGO Kernel


Medals: 345
Projects: 3
Exp: 5 years


I'm the King!


« Reply #1 - Posted 2012-03-12 03:43:57 »

Then just don't use that flag. Java will automatically use hardware acceleration if it is available Smiley

Offline joeyismusic

Junior Member





« Reply #2 - Posted 2012-03-12 05:29:52 »

But it doesn't... There's definitely a speed increase with the flag.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline ra4king

JGO Kernel


Medals: 345
Projects: 3
Exp: 5 years


I'm the King!


« Reply #3 - Posted 2012-03-12 05:35:46 »

OK then describe this dirty rectangle effect. Could you show code and/or screenshot?

Offline Stranger

Senior Member


Medals: 6



« Reply #4 - Posted 2012-03-12 07:22:07 »

Try to specify these parameters:

• -Dsun.java2d.opengl=true
• -Dsun.java2d.d3d=false
• -Dsun.java2d.noddraw=true

Anton
Offline joeyismusic

Junior Member





« Reply #5 - Posted 2012-03-12 21:21:37 »

how can i specify more than one flag in the applet tag?

also: working on getting the examples to show. honestly though, you can write a quick app in a few minutes to demonstrate it. just use the opengl flag in your applet tag, and make the applet use a buffer strategy. it just wont work.
Offline joeyismusic

Junior Member





« Reply #6 - Posted 2012-03-12 22:01:27 »

Here's the browser run:



My engine read out, which does several tests for me to let me know capabilities of surfaces in use, etc.

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
OpenGL pipeline enabled for default config on screen 0
System information created
Graphics information created
Windows Detected, starting daemon thread
Roguelike Engine v0.0.1
OS: Windows 7 / 6.1 / x86
Java: 1.6.0_31 / 20.6-b01
Security On
startup
Preparing Buffer: Forced Buffer Strategy
Using Buffer Strategy
Back buffer is Accelerated and Non Volatile
Front buffer is Accelerated and Non Volatile


Here's it testing in Eclipse, working just fine:


Readout:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
System information created
Graphics information created
Windows Detected, starting daemon thread
Roguelike Engine v0.0.1
OS: Windows 7 / 6.1 / amd64
Java: 1.6.0_25 / 20.0-b11
Security Off
Using OpenGL: True
startup
Preparing Buffer: Forced Buffer Strategy
Using Buffer Strategy
Back buffer is Accelerated and Non Volatile
Front buffer is Accelerated and Non Volatile


Keep in mind all of this works without a buffer strategy no matter what. If i turn the buffer strategy off, it works in jframe as well as in browser but it runs at HALF the speed.
When I test in eclipse, its like 800 FPS, and in browser its like 10 - 30 fps.
Offline ra4king

JGO Kernel


Medals: 345
Projects: 3
Exp: 5 years


I'm the King!


« Reply #7 - Posted 2012-03-12 22:13:05 »

After some tests, it looks like the OpenGL backend of Java2D in Windows is sloooow. I don't get that weird dirty rectangle effect, but it runs at about 40-50FPS.
Direct3D on Windows is fast though, it goes back up to 2000-3000FPS.

Quote
Then just don't use that flag. Java will automatically use hardware acceleration if it is available Smiley

Grin

Offline joeyismusic

Junior Member





« Reply #8 - Posted 2012-03-12 22:13:45 »

So I guess mac users are screwed? You know half of my audience will be mac users.
Offline ra4king

JGO Kernel


Medals: 345
Projects: 3
Exp: 5 years


I'm the King!


« Reply #9 - Posted 2012-03-12 22:15:12 »

Nah, OpenGL on Macs and Linux is also fast, my game runs at 500-1000FPS on the MacBook Air.

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

Junior Member





« Reply #10 - Posted 2012-03-12 22:16:44 »

So do you suggest to just detect OS, and then go down the pipeline accordingly... accelerate transparent images on d3d for windows, and just use open gl for mac.

And then for the applet (since security won't let us set properties at run time), just write a dx / ogl page and detect os at browser level and redirect to correct page?
Offline ra4king

JGO Kernel


Medals: 345
Projects: 3
Exp: 5 years


I'm the King!


« Reply #11 - Posted 2012-03-12 22:18:28 »

Again: don't set any flags! Java really does automatically detect if hardware acceleration is present. Without any flags, my game still runs at 2000-3000 FPS on my machine and 1000FPS on the Air Smiley

Offline joeyismusic

Junior Member





« Reply #12 - Posted 2012-03-12 22:19:58 »

I tried that, and transparent images aren't accelerated by default... for some reason.

Perhaps I will test more, I am not 100% sure if I was doing things properly when I noticed the problems.

Edit: I need full transparency support (png format) because of roguelike vision. Otherwise, I'll need two of all things in order to be able to draw dark spots.
Offline ra4king

JGO Kernel


Medals: 345
Projects: 3
Exp: 5 years


I'm the King!


« Reply #13 - Posted 2012-03-12 22:24:11 »

Try creating compatible images (line 87). Also look at line 108 for how to transfer an image over from the old Image to the new compatible BufferedImage.

Offline joeyismusic

Junior Member





« Reply #14 - Posted 2012-03-12 22:51:07 »

Found this in your code Cheesy

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
 /**
         * Initializes and displays the window.
         * @param title The title of the window
         * @param width The width of the window
         * @param height The height of the window
         * @param resizable If true, the window will be resizable, else it will not be resizable.
         * @return The JFrame that was initialized by this method.
         */

        protected final JFrame setupFrame(String title, boolean resizable) {
                if(System.getProperty("os.name").startsWith("Win"))
                        System.setProperty("sun.java2d.d3d","true");
                else
                        System.setProperty("sun.java2d.opengl", "true");
               
                final JFrame frame = new JFrame(title);
Offline ra4king

JGO Kernel


Medals: 345
Projects: 3
Exp: 5 years


I'm the King!


« Reply #15 - Posted 2012-03-12 22:53:59 »

Found this in your code Cheesy

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
 /**
         * Initializes and displays the window.
         * @param title The title of the window
         * @param width The width of the window
         * @param height The height of the window
         * @param resizable If true, the window will be resizable, else it will not be resizable.
         * @return The JFrame that was initialized by this method.
         */

        protected final JFrame setupFrame(String title, boolean resizable) {
                if(System.getProperty("os.name").startsWith("Win"))
                        System.setProperty("sun.java2d.d3d","true");
                else
                        System.setProperty("sun.java2d.opengl", "true");
               
                final JFrame frame = new JFrame(title);

Hahahahaha I was just experimenting with that a couple days ago XD

Offline Stranger

Senior Member


Medals: 6



« Reply #16 - Posted 2012-03-13 08:40:25 »

how can i specify more than one flag in the applet tag?
For example:
1  
<param name="java_arguments" value="-Dsun.java2d.opengl=true -Dsun.java2d.d3d=false -Dsun.java2d.noddraw=true">

Here is the thread related to your problem.

Anton
Offline ra4king

JGO Kernel


Medals: 345
Projects: 3
Exp: 5 years


I'm the King!


« Reply #17 - Posted 2012-03-13 14:16:44 »

You don't really want to turn off OpenGL for all systems though, since it is necessary under Linux and Mac.

Offline gimbal

JGO Knight


Medals: 25



« Reply #18 - Posted 2012-03-16 10:00:39 »

I tried that, and transparent images aren't accelerated by default... for some reason.
Bit-transparent (bitmask) or fully translucent?

This older thread comes to mind:

http://www.java-gaming.org/index.php?topic=19561.5
Offline joeyismusic

Junior Member





« Reply #19 - Posted 2012-03-16 12:54:44 »

Trying to support the PNG format fully. In other words, I want to be able to draw 0 - 255 values of alpha.
Offline Orangy Tang

JGO Kernel


Medals: 56
Projects: 11


Monkey for a head


« Reply #20 - Posted 2012-03-16 13:22:50 »

I found the sun.java2d.opengl flag to be faaaaaar too unreliable to use by default. On some systems it was actually slower than leaving it do what it wanted to, and it's full of odd rendering glitches on non-nvidia hardware. Which is probably why it doesn't default to on.

It might be worth having it as an advanced option and just let your users find out which one works best for them.

[ TriangularPixels.com - Play Growth Spurt, Rescue Squad and Snowman Village ] [ Rebirth - game resource library ]
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.

Nickropheliac (15 views)
2014-08-31 22:59:12

TehJavaDev (23 views)
2014-08-28 18:26:30

CopyableCougar4 (29 views)
2014-08-22 19:31:30

atombrot (41 views)
2014-08-19 09:29:53

Tekkerue (39 views)
2014-08-16 06:45:27

Tekkerue (35 views)
2014-08-16 06:22:17

Tekkerue (25 views)
2014-08-16 06:20:21

Tekkerue (36 views)
2014-08-16 06:12:11

Rayexar (72 views)
2014-08-11 02:49:23

BurntPizza (49 views)
2014-08-09 21:09:32
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

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
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!