Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (794)
Games in Android Showcase (234)
games submitted by our members
Games in WIP (864)
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 4169 times)
0 Members and 1 Guest are viewing this topic.
Offline cygnus
« Posted 2018-05-27 00:48:49 »

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:
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:

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:

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,
Pages: [1]
  ignore  |  Print  

hadezbladez (3180 views)
2018-11-16 13:46:03

hadezbladez (1149 views)
2018-11-16 13:41:33

hadezbladez (3150 views)
2018-11-16 13:35:35

hadezbladez (627 views)
2018-11-16 13:32:03

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

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

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

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

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

nelsongames (4617 views)
2018-04-24 18:14:32
Java Gaming Resources
by philfrei
2019-05-14 16:15:13

Deployment and Packaging
by philfrei
2019-05-08 15:15:36

Deployment and Packaging
by philfrei
2019-05-08 15:13:34

Deployment and Packaging
by philfrei
2019-02-17 20:25:53

Deployment and Packaging
by mudlee
2018-08-22 18:09:50

Java Gaming Resources
by gouessej
2018-08-22 08:19:41

Deployment and Packaging
by gouessej
2018-08-22 08:04:08

Deployment and Packaging
by gouessej
2018-08-22 08:03:45 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‑
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!