Java-Gaming.org Hi !
Featured games (91)
games approved by the League of Dukes
Games in Showcase (757)
Games in Android Showcase (229)
games submitted by our members
Games in WIP (844)
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  
  Java2D not using OpenGL randomly?  (Read 712 times)
0 Members and 2 Guests are viewing this topic.
Offline cygnus
« Posted 2018-05-27 00:48:49 »

Hello,
The game I am working on uses the javafx Canvas class and the BufferStrategy you get from it to draw to the screen. Normally, this uses the GPU, but occasionally, it stops being able to and uses CPU based methods (I have determined this by using the "sun.java2d.trace" system property which shows the draw operations). It's not a per-execution thing either, as once it stops working once, no other instance of the game uses OpenGL to render until I restart the computer. After that, it will use OpenGL again.

Has anybody else had this problem, and does anybody have any ideas as to how to fix it?
Offline CommanderKeith
« Reply #1 - Posted 2018-05-27 02:45:38 »

Hi Cygnus,
It sounds like you're already knowledgeable of Java2D and it's limitations given the fact that you're aware of the 'trace' debugging option. So that probably means that I've got little new information to offer, but here are some ideas.
Not all operations in Java2D are hardware accelerated using OpenGL. I haven't looked at openGL in a number of years, but in the old days image rotation and translucent images were not hardware accelerated. Perhaps you're rotating or painting translucent images? See here for some discussion:
http://www.oracle.com/technetwork/java/javase/java2d-142140.html#gcrvb
There are other reasons why hardware acceleration may not work too, such as driver problems and running out of VRAM.
Brackeen's excellent book has some general information on this topic:
https://books.google.com.au/books?id=dOz-UK8Fl_UC&lpg=PA122&ots=ahiiWu4GnH&dq=java%202d%20rotate%20opengl%20hardware%20acceleration&pg=PA122#v=onepage&q=java%202d%20rotate%20opengl%20hardware%20acceleration&f=false

Another possibility is that it's due to your computer having two graphics cards where one supports openGL and the other doesn't. There's some info here about setting the which GPU to use with which program:
https://www.techadvisor.co.uk/how-to/pc-components/how-set-default-graphics-card-3612668/
Cheers,
Keith

Offline cygnus
« Reply #2 - Posted 2018-05-27 17:10:39 »

I am doing painting of translucent images and rotation, but the strange thing is even drawing normal textures with no rotation or translucency becomes unaccelerated. It's definitely not related to rotating images, as I've had those in the game for a long time, but it is possible that translucent images could be causing this. If Java2D accelerates transparent images but not translucent, that might make sense, as I've had images with full transparency for a while but only fairly recently have I added translucency. I'll have to test this.

It's not multiple GPUs (I have one), nor is it running out of VRAM (I have like 6GB). If it is a driver problem then I'm not sure how to verify that, maybe testing on other systems, but the problem with that is I still don't know what causes the deceleration of the game; it just happens after some time.
Thank you for your help,
cygnus
Pages: [1]
  ignore  |  Print  
 
 

 
EgonOlsen (74 views)
2018-06-10 19:43:48

EgonOlsen (55 views)
2018-06-10 19:43:44

EgonOlsen (74 views)
2018-06-10 19:43:20

DesertCoockie (254 views)
2018-05-13 18:23:11

nelsongames (154 views)
2018-04-24 18:15:36

nelsongames (154 views)
2018-04-24 18:14:32

ivj94 (895 views)
2018-03-24 14:47:39

ivj94 (156 views)
2018-03-24 14:46:31

ivj94 (808 views)
2018-03-24 14:43:53

Solater (172 views)
2018-03-17 05:04:08
Java Gaming Resources
by philfrei
2017-12-05 19:38:37

Java Gaming Resources
by philfrei
2017-12-05 19:37:39

Java Gaming Resources
by philfrei
2017-12-05 19:36:10

Java Gaming Resources
by philfrei
2017-12-05 19:33:10

List of Learning Resources
by elect
2017-03-13 14:05:44

List of Learning Resources
by elect
2017-03-13 14:04:45

SF/X Libraries
by philfrei
2017-03-02 08:45:19

SF/X Libraries
by philfrei
2017-03-02 08:44:05
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!