fullscreen sometimes partly flickering

i’m stilll working on my chopper game (http://games.rastaduck.org/ProjectEscobar/ProjectEscobar.jnlp) and ever since had that problem with the partly flickering which occurs every few seconds.
in other words, when the game is running and you are moving the chopper the background image flickers at some places (not the full screen). on my machine its mostly in the upper and lower parts of the screen, not in the middle.

my questions are: could this be a problem with my video card/monitor? do you see the same flickering?

Can see everything but no flickering.

at what framerate is the game running on your machine? (you can find the info at the bottom left corner in the game.)

Thats a rather nice game (if very hard). 1600x1200 @ ~55fps on my FX5200. Can’t see any flickering though. Are you using the new OpenGL pipeline on your machine?

thx. i know it’s hard in the beginning but after a bit of practise it’s more and more fun. who knows, maybe i can find a way to make the game easier but keeping it still as interesting as possible.
on my machines it runs at 1280x1024@85fps.
not sure what you mean with “using the openGL pipeline”, i just use plain java2D. no JOGL, LWJGL or something …

The 1.5 VM has an OpenGL pipeline which can be used under the hood for Java2d. I don’t think it’s the defaults though, you need to change some system setting so it’s unlikely you’re using it by accident.

sounds interesting! thx for the hint. i would like to try and activate it. let’s see what i can find in the forums …

i just added the line with the mark to my jnlp file, but nothing changed:

... #### new line

am i missing something?

WebStart has a list of “secure system properties” which are allowed to appear in JNLP files. In JDK 5, “sun.java2d.opengl” was not in that list of secure properties, which explains why you’re not seeing any difference. This property has been added to the list of secure properties in Mustang. But remember, there are still issues with some OGL drivers out there, so if you do force the OGL pipeline on by default, your game may be unplayable. (We’re working on some ways to detect these driver issues at runtime, but we can’t always catch them all.) Therefore, I suggest you offer two JNLP files for the time being, one with the property set to true, and one without it, so if your users have any problems, they can always try the unaccelerated version. Of course, this will only work for Mustang. For now, perhaps you should just try running your game from the command line with “-Dsun.java2d.opengl=True” on your dev machine to see if it makes a difference. If not, then you don’t have to worry about all this stuff I’ve written above.

Chris

well … yes, i see a difference now. the color depth seems to be decreased. i had a nice grey shadow around the keys in the controls image on the start screen and now there are ugly grey areas instead. btw, the flickering is still there. :’(

Are you using a MemoryImageSource? This may be totally unrelated and well known, but I recently got rid of an annoying flicker in my full screen app in a way that was news to me.

I was using newPixels() on a MemoryImageSource. That method notifies ImageConsumers when the animation frame is complete - which for me was my full screen Frame. I was getting a regular flicker when this method was called. I replaced it with newPixels(x, y, width, height, false) and now: no more flicker.

Just a random thought that is probably way off your problem!! BTW - I got no flicker with your game (nice).

thx for testing. no i don’t use a MemoryImageSource. never heard of that …

strange, my machine seems to be the only one so far showing flickering animation.

could it be some interference between the screen refresh of the monitor and the screen refresh of the game itself?
the game tries to refresh the screen at the same rate as the monitor.
eg. on my machine monitor runs at 85Hz and the game’s framerate is 85fps

???

Do you have any applications running in the background that could be causing the drawing surface to become invalidated?

also, immediately after you call show() on BufferStrategy, are you checking for BufferStrategy.contentsLost()?

What color does the screen flicker to? is it garbage, or is it white?

When calling createBufferStrategy, I presume you are passing in a value greater than 1.

Is createBufferStrategy failing? (due to insufficient gfx memory)
This would result in any calls to getBufferStrategy() returning the default BufferStrategy that has no back buffer.

is BufferStrategy.show() actually vsyncing? (driver/setting dependant)
Youcan test this by performing a tight loop on BufferStrategy.show() and seeing how many loops/second it achieves,
it should be equal to the refreshrate of your monitor/gfx card.

Do you have any applications running in the background that could be causing the drawing surface to become invalidated?

i don’t think so, the flickering looks always the same, regardless of what program are running

also, immediately after you call show() on BufferStrategy, are you checking for BufferStrategy.contentsLost()?

nope

What color does the screen flicker to? is it garbage, or is it white?

it’s not a color or something. i had a closer look and saw that it seems to be parts of the old frame.

When calling createBufferStrategy, I presume you are passing in a value greater than 1.

yes, the value is 2. with 1 i had a horrible fullscreen flicker. much worse than the actual one.

Is createBufferStrategy failing? (due to insufficient gfx memory)
This would result in any calls to getBufferStrategy() returning the default BufferStrategy that has no back buffer.

as mentioned above it appears that i do have 2 buffers. it’s just a slight flickering.

is BufferStrategy.show() actually vsyncing? (driver/setting dependant)
Youcan test this by performing a tight loop on BufferStrategy.show() and seeing how many loops/second it achieves,
it should be equal to the refreshrate of your monitor/gfx card.

don’t know if i got you right. i did this:

            long strategyStart = SystemTimer.getTime();
            int strategyCount = 0;
            while (SystemTimer.getTime() - strategyStart < 1000) {
                strategyCount++;
                strategy.show();                
            }
            System.out.println("####### strategy counter: " + strategyCount + ", time: " + (SystemTimer.getTime() - strategyStart) + " ms");
            System.exit(0);

the output was:
####### strategy counter: 2033, time: 1191 ms

any updates ???