I'm working on a simple 2D side scrolling platform game in java.

It is a canvas with a bufferstrategy which is placed inside a jframe, and that jframe is set as the fullscreenwindow on the graphics device.

Now my computer has a decent nvidia card. In the nvidia control panel on my computer, just looking at the basic settings, if I set the the mode to "Emphasize performance," the game runs as it should and renders properly. The game is not vertical synced.

If I set the mode to "Emphasize quality" or "Let the 3D application decide," the game renders lines a slight distance away from where I intended them, collision detection is also slightly off, and things are overly anti-aliased. The game is now vertical synced.

Now on my crappy laptop, the game runs fine because the card is much less sophisticated. (I think?) However, on my friends computer, he plays with his ATI control center a bit (turns every enhancement off) and then the game runs perfect, but by default its a mess just like with my nvidia card.

TLDR: Is there any way to override the settings on the graphics card or force the settings to be set a certain way from inside Java?

  • 1
    \$\begingroup\$ It seems strange that graphics settings could affect your collision logic. Are you sure you're properly decoupling your rendering rate from "game" rate? \$\endgroup\$ Aug 14, 2013 at 2:17

2 Answers 2


Use OpenGL directly to get a consistent API across graphics devices and platforms.

I've found that SDL has been extremely reliable in providing a consistent interface across varied hardware. SDL exposes control over multisampling also.

EDIT: here's a binding: http://sdljava.sourceforge.net/

You can control vsync with:

SDL_GL_SetAttribute(SDL_GL_SWAP_CONTROL, vsync_enabled);

And multisampling with::

SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, fsaa_enabled);
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, fsaa_quality); // try 2 or 4

This library has a native cross platform implementation, so it fits well with something like a Java game which (in my opinion) should be cross platform but still access low-level features.

  • \$\begingroup\$ I don't see how your answer helps him... \$\endgroup\$
    – Sidar
    Aug 13, 2013 at 16:29
  • \$\begingroup\$ I've provided a link to a Java library which addresses this functionality, and will give him a solid path to expand his game however he likes. otoh, I see how it is pretty RTFM though, so I added code examples which address the issues he stated exactly. (vsync, multisampling, drawing routines with readable specifications ;]) \$\endgroup\$
    – MickLH
    Aug 13, 2013 at 20:01

Thanks to XiaoChuan Yu who commented on my original post. This is the basic idea behind how I changed my game loop to make this problem go away:

private void gameLoop() {

    long current;
    long old = System.nanoTime();
    double nsPerUpdate = 1000000000D/60D;
    double updates = 0.0;

    while(running) {
        current = System.nanoTime();
        updates += (current - old) / nsPerUpdate;
        old = current;

        while (updates >= 1) {
            // perform all updates/logic here
            updates -= 1;
        // render/draw here


I'm still learning, but hopefully someone else will stumble upon this and it will help them. I appreciate the help.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .