joeyismusic
|
 |
«
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
|
|
|
|
ra4king
|
 |
«
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 
|
|
|
|
joeyismusic
|
 |
«
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!
|
|
ra4king
|
 |
«
Reply #3 - Posted
2012-03-12 05:35:46 » |
|
OK then describe this dirty rectangle effect. Could you show code and/or screenshot?
|
|
|
|
Stranger
|
 |
«
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
|
|
|
joeyismusic
|
 |
«
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.
|
|
|
|
joeyismusic
|
 |
«
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.
|
|
|
|
ra4king
|
 |
«
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. Then just don't use that flag. Java will automatically use hardware acceleration if it is available  
|
|
|
|
joeyismusic
|
 |
«
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.
|
|
|
|
ra4king
|
 |
«
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!
|
|
joeyismusic
|
 |
«
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?
|
|
|
|
ra4king
|
 |
«
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 
|
|
|
|
joeyismusic
|
 |
«
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.
|
|
|
|
ra4king
|
 |
«
Reply #13 - Posted
2012-03-12 22:24:11 » |
|
|
|
|
|
joeyismusic
|
 |
«
Reply #14 - Posted
2012-03-12 22:51:07 » |
|
Found this in your code  1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
| 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); |
|
|
|
|
ra4king
|
 |
«
Reply #15 - Posted
2012-03-12 22:53:59 » |
|
Found this in your code  1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
| 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
|
|
|
|
Stranger
|
 |
«
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
|
|
|
ra4king
|
 |
«
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.
|
|
|
|
|
joeyismusic
|
 |
«
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.
|
|
|
|
Orangy Tang
|
 |
«
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.
|
|
|
|
|