Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (497)
Games in Android Showcase (114)
games submitted by our members
Games in WIP (563)
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  
  fullscreen tearing problem  (Read 1007 times)
0 Members and 1 Guest are viewing this topic.
Offline Japheth

Junior Newbie





« Posted 2007-07-15 17:13:42 »

I have a rendering loop in a fullscreen application and I'm getting slight tearing. It's noticeable when I draw a 2d map on the screen and move around on it. The basic loop code is shown below. I would like to force the bufferStrategy to use page flipping, but I couldn't figure out how to from the java tutorial on the subject. Any advice on how to fix the problem would be appreciated.

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
public static void main(String[] args) {
         GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment();
         GraphicsDevice device = env.getDefaultScreenDevice();
         new LostHavenClient(device);
   }

public LostHavenClient(GraphicsDevice device) {
        try {
            GraphicsConfiguration gc = device.getDefaultConfiguration();
            frmMain = new Frame(gc);
            frmMain.setUndecorated(true);
            frmMain.setIgnoreRepaint(true);
            device.setFullScreenWindow(frmMain);
           
            if (device.isDisplayChangeSupported()) {
                chooseBestDisplayMode(device);
            }

            frmMain.addMouseListener(this);
            frmMain.addKeyListener(this);
            frmMain.createBufferStrategy(2);
            BufferStrategy bufferStrategy = frmMain.getBufferStrategy();
           
            while (!done) {
                Graphics g = bufferStrategy.getDrawGraphics();
                render(g);
                g.dispose();
                bufferStrategy.show();
            }
        }
        catch (Exception e) {
            e.printStackTrace();
        }
        finally {
            device.setFullScreenWindow(null);
        }
    }
Offline broumbroum

Junior Member





« Reply #1 - Posted 2007-07-15 20:55:21 »

you may perform one or two more checks for the bufferStrategy if you want the best strat' in use. There's 2 easy callable methods: isPageFlipping and isMultiBuffering available for each GraphicsConfiguration. PageFlipping is supported on most platforms while the multibuffering that use 3+ buffers is for some accelerated systems.
 Huh

::::... :..... :::::: ;;;:::™ b23:production 2006 GNU/GPL @ http://b23prodtm.webhop.info
on sf.net: /projects/sf3jswing
Java (1.6u10 plz) Web Start pool
dev' VODcast[/ur
Offline Japheth

Junior Newbie





« Reply #2 - Posted 2007-07-16 01:39:19 »

I called getBufferCapabilities().isPageFlipping() on the gc variable in the above code and it returned true. Does this mean my system supports page flipping, or that my code actually uses page flipping? If it's the former, how do I then make the graphicsConfiguration actually use page flipping?

Just to make sure I'm on the right track, what I'm getting is a black strip that sometimes flickers on the screen for a moment as I move around the map. It's sometimes horizontal and sometimes vertical. It looks like a tearing problem rather than flicker from backbuffering since it only occurs in one part of the screen each time.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline fletchergames

Senior Member





« Reply #3 - Posted 2007-07-16 02:07:28 »

If this only happens when you're scrolling around the screen, you might want to consider that it may be either an error with the scrolling code or an error with how you're drawing the screen.  For instance, you might be missing one tile at the edge of the screen because you're not taking into account that you need to draw part of the next tile.
Offline Japheth

Junior Newbie





« Reply #4 - Posted 2007-07-16 02:24:47 »

Actually, that just gave me an idea. I update the player's position based on where he clicks, so if he clicks while the images being drawn, part of the images will be drawn based on his old coordinates and part based on his new ones. Once I fix that, I'll post here and say if it worked.

EDIT: Yup, works great now. Thanks for the helping me think of that, fletchergames.
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

BurntPizza (22 views)
2014-09-19 03:14:18

Dwinin (35 views)
2014-09-12 09:08:26

Norakomi (62 views)
2014-09-10 13:57:51

TehJavaDev (90 views)
2014-09-10 06:39:09

Tekkerue (44 views)
2014-09-09 02:24:56

mitcheeb (65 views)
2014-09-08 06:06:29

BurntPizza (48 views)
2014-09-07 01:13:42

Longarmx (35 views)
2014-09-07 01:12:14

Longarmx (40 views)
2014-09-07 01:11:22

Longarmx (37 views)
2014-09-07 01:10:19
List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
java-gaming.org 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‑gaming.org
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!