Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (711)
Games in Android Showcase (213)
games submitted by our members
Games in WIP (785)
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  
  double buffers  (Read 2140 times)
0 Members and 1 Guest are viewing this topic.
Offline jayhg99

Senior Newbie

Java games rock!

« Posted 2003-01-29 13:19:39 »

I have an application which uses double buffers to paint the screen constantly in window mode. When I place the mouse cursor on the screen, I can see that the mouse cursor is shaking as the screen gets painted, which is understandable since the screen gets refreshed constantly.  I assume that  I’m not using the page flipping feature since I’m in the window mode not full screen mode. The application uses menu bars and popup menus which prevent me from using full screen mode.

However, if I first execute the sample program at  and then run the application again ,  the mouse cursor on the screen does not shake any more as the screen gets repainted, which is what I want.  I studied the which uses BufferStrategy, DisaplyMode and full screen mode. I just do not understand why  program could have impact on my application. It has to have something to do with VRAM. How can I take some of features from and merge with my application so that I can get rid of the mouse cursor shaking  when refreshing the screen and at same time still running in window mode ?

Offline Abuse

JGO Ninja

Medals: 57

falling into the abyss of reality

« Reply #1 - Posted 2003-01-29 15:46:31 »

how are you doing the double buffering in your current app?

i *think* uses BufferStrategy (I havn't actually looked at the source).
This does indeed create the backbuffer in Vram, which may well avoid the 'shaking' cursor problem.

btw, when you say the mouse cursor is 'shaking', do you mean flickering?
I seem to remember older ATI gfx cards had this problem when doing windowed directdraw stuff.

Offline jayhg99

Senior Newbie

Java games rock!

« Reply #2 - Posted 2003-01-29 17:49:42 »

Yes, you are correct that uses BufferStrategy in full screen mode and I really mean that mouse cursor flickering.

I do  not use BufferStrategy in my current application. Here is the part of code that does the double buffering and drawing on the screen :

Image background=null;
Image background_img ;
Graphics2D background_g2;

// initial background buffer
public void initBackBuffer()
     GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment();
       GraphicsDevice device = env.getDefaultScreenDevice();
     GraphicsConfiguration gc = device.getDefaultConfiguration();

     background =  gc.createCompatibleImage(width, height,Transparency.TRANSLUCENT);
     background_g2 = (Graphics2D) background.getGraphics();


public void paint(Graphics g)

public synchronized void updateScreen(Graphics g)

           Graphics2D g2 = (Graphics2D)g;

           // Call initBackBuffer for the first time
           if (background == null) {

           if(g != null)
                 //paint the screen
                 waitingForRepaint = false;
                 // Draw the background buffer to the screen.
                 g2.drawImage(background, 0, 0, this);

                 //copy the background image to the back buffer
                 //copy all the sprite objects to the back buffer
                 for(int i=0; i< numObj; i++)

I'm going to try to use BufferStrategy in window mode to see if I can get rid of mouse cursor flickering.

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline trembovetski

Senior Devvie

If only I knew what I'm talking about!

« Reply #3 - Posted 2003-02-04 04:21:12 »

You will get mouse pointer flickering (most notably on older video boards which do not have hw support for fancy cursors, like the ones in Win2k/XP), because we actually hide the pointer before copying the bits to the screen, and then show it afterwards to avoid the cursor being overwritten by the image copy.

Unfortunately, with software cursors you will get flickering even with BufferStrategy, because of the way DirectX handles this: the cursor will be painted only on the primary surface (a documented DirectX feature), so it'll be visible only every other frame in case of one backbuffer strategy.

The way to fix this is to render the cursor by yourself - that is, set a transparent image as a cursor, track mouse position and render whatever you want as mouse pointer. This is actually the way any native DirectX game does it.
Offline jayhg99

Senior Newbie

Java games rock!

« Reply #4 - Posted 2003-02-04 18:03:45 »

Thanks guys . Yes, it must have something to do with the video card. I do not see any mouse flicking on my desktop. But the mouse cursor flicks on my laptop as the back buffer  is refreshing the screen. The bufferstrategy does not help in this case. However, the mouse flicking issue goes away after I run the demo program I commented out the codes that deal with the bufferstrategy and display mode but left along the part that sets full screen mode in  It is the setFullScreenWindow statement in somehow helps with mouse flicking issue. I do not understand why executing a setFullScreenWindow in one program could affect another.  I tried to simulate the effect by entering full screen and exiting out the full screen at beginning of application, which needs to run in window mode.  But it messes up the all screen drawings.

Pages: [1]
  ignore  |  Print  
You cannot reply to this message, because it is very, very old.

numerical (182 views)
2017-02-21 07:32:16

numerical (181 views)
2017-02-21 07:31:46

theagentd (289 views)
2017-02-18 13:42:33

theagentd (290 views)
2017-02-18 13:35:16

h.pernpeintner (1456 views)
2017-01-24 22:39:11

h.pernpeintner (1442 views)
2017-01-24 22:38:32

Galdo (2007 views)
2017-01-12 13:44:09

Archive (2050 views)
2017-01-02 05:31:41

0AndrewShepherd0 (2586 views)
2016-12-16 03:58:39

0AndrewShepherd0 (2332 views)
2016-12-15 21:50:57
List of Learning Resources
by elect
2016-09-09 09:47:55

List of Learning Resources
by elect
2016-09-08 09:47:20

List of Learning Resources
by elect
2016-09-08 09:46:51

List of Learning Resources
by elect
2016-09-08 09:46:27

List of Learning Resources
by elect
2016-09-08 09:45:41

List of Learning Resources
by elect
2016-09-08 08:39:20

List of Learning Resources
by elect
2016-09-08 08:38:19

Rendering resources
by Roquen
2016-08-08 05:55:21 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!