Accelerating images through BufferStrategy

That’s because JPanel isn’t set to be focusable in the first place. You have to call JPanel.setFocusable(true) for it to receive focus.

Java2D is slow in either situation. “exclusive graphics card functions”, I don’t know about that one. Those “functions” you seek are low level DirectX/OpenGL functions which are not accessible to you through Java2D nor are they supposed to make anything go “faster”.

I really suggest you stop worrying about tiny performance details like this. As I told you earlier, if your game/app runs at a reasonable framerate, STOP worrying and finish writing your game already! ;D

It’s about exclusive fullscreen mode. There is a clear difference in performance between fullscreen and windowed, but I’m not sure if Java2D can actually enter exclusive mode. If it can then YES, fullscreen is faster.

Thanks a lot for your time and effort :slight_smile:

For now rendering all 2D tile map in resolution 640x480 takes about 3 ms, so I think it’s quite good result and maybe it’s true that I seek for too much performance boost in places where it cannot be granted :stuck_out_tongue: Cpu usage for entire game takes 5-10% with 30fps on c2d processor, so there is much more to improvement :wink:

For example “Killer Game Programming in Java” calls it Full-Screen Exclusive Mode (FSEM) and it’s done by invoking setDisplayMode(), but for what i can see there is no performance boost between it and window mode what’s really strange for me.

It’s a really low-level thing, so it’s probably the best that Java doesn’t use it. I’ve had so much trouble with it (specifically ridiculous VM crashes on Intel graphics cards), so it’s not really worth it anyway unless you’re making a 3D game. That was with LWJGL though, which does use exclusive mode.

OT: To solve the crash I ended up creating an undecorated LWJGL window that was (width+2, height) to prevent automatic fullscreen just for Intel cards. Guess why I hate Intel?

Newer Intel integrated GPUs can now handle full screen :slight_smile:

Wow. They can handle fullscreen. I guess that’s one of their few selling points then. Maybe they’ll be able to handle actual drawing someday too! I mean, faster than a software renderer.

Java2D used to implement FSEM on Linux via a window whose viewport was the size of the desktop, though I believe as of Java 6 they have “true” full screen functionality implemented. I’m not sure if they did so because of time constraints, buggy native support, nobody cared about games on Linux, or what.

Today I tried to change the options of virtual machine to force acceleration on graphics card. After a while that give me an answer - support for DirectX/OpenGL is default enabled. When I turned off Direct3D acceleration, render time gone higher, so that solves my case :slight_smile: Java2d is trying to use platform depended acceleration and if that fail, there is switch to software rendering. That’s it - clean and simple :slight_smile:

For a really demanding game (one that runs at <10 FPS without hardware acceleration for example) this is way too unreliable though. It might work everywhere, but not be playable everywhere.

Hmm, are you drawing images with bit translucency I wonder? As far as I know those type of images cannot be accelerated under hardware rendering environments but will perform a whole lot better in a software rendering one (where they can be accelerated). You could try switching to full translucent images to see if that makes a difference with D3D/OGL enabled.

Note that I disabled hardware support by default myself; the type of games I make (simple retro remakes) generally don’t need it. Gives the least amount of cross-computer misery.