Hi !
Featured games (91)
games approved by the League of Dukes
Games in Showcase (757)
Games in Android Showcase (229)
games submitted by our members
Games in WIP (844)
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  
  Flipping < Blitting? ... or where is the error  (Read 2131 times)
0 Members and 1 Guest are viewing this topic.
Offline DD.Jarod

Senior Newbie

Sry for my bad english :-)

« Posted 2003-12-25 16:23:26 »

I started to write a 2D engine for Games/Appz a few days before.
First I did was to create a window, get the GraficsConfiguration and build some Bufferstrategy.
I read some books about 3D grafics in C for an basic understanding of technics to be used for fast and smooth moving pics, so I decided to build the BufferStrat with PageFlipping.
To do that I set the window I used to exklusiv fullscreenmode.
After that I wrote a simple FPS counter and start the application.

Code of the method which draws (and sry for german comments, but I think all of u will understand the code without them *g*):

     public void run()
           long             lTime             = System.currentTimeMillis();
           int             nOldFPS       = 0;
           int             nFPS             = 0;
           Color             ClrBack       = GrfxScreen.getColor();

                       GrfxScreen.fillRect(0,0,nWidth, nHeight);
                 }// if(...) -> Falls die Bufferstrategier nicht selbst den Backbuffer saeubert machen wir das
                 // ----  Draw here  ----
                 GrfxScreen.drawString("Pageflipping: " + this.getBufferStrategy().getCapabilities().isPageFlipping(),0,40);
                 GrfxScreen.drawString("Fullscreen: " + this.bFullscreen,0,60);
                 GrfxScreen.drawString("VRAM: " + this.getGraphicsConfiguration().getDevice().getAvailableAcceleratedMemory(),0,80);
                 GrfxScreen.drawString("FlipContent: " + Backbuffer.getCapabilities().getFlipContents(),0,100);
                 GrfxScreen.drawString("Bounds: " + this.nWidth + " x " + this.nHeight,0,120);
                 GrfxScreen.drawString("F Fullscreen <-> Window",0,140);
                 GrfxScreen.drawString("P PageFlipping oder -Blitting",0,160);
                 GrfxScreen.drawString("Esc Ende",0,180);
                 // ---- End Drawing ----
                 // Anzahl Frames der letzten Sekunde anzeigen
                 GrfxScreen.drawString("FPS: "+nOldFPS, 0,20);
                 if(lTime+1000 <= System.currentTimeMillis())
                       lTime = System.currentTimeMillis();
                       nOldFPS = nFPS;
                       nFPS = 0;
                 }// if(...) -> Jede Sekunde Anzahl FPS der letzten Sek updaten
           }// while(bRunning)
     }// public void run()

Then I wonder: it ran, but really slow (60FPS).
So I tried a few things (using a frame and not a window and such things) and finally I changed the BufferStrat from PageFlipping to PageBlitting (first the flipping, then the blitting strat):

           if(bFlipping && bFullscreen)
                 BufferCaps = new BufferCapabilities(new ImageCapabilities(true),
                                                                       new ImageCapabilities(true),
           }// if(...) -> Soll mit PageFlipping laufen?
                 bFlipping = false;
                 BufferCaps = new BufferCapabilities(new ImageCapabilities(true),
                                                                        new ImageCapabilities(true),
           }// else -> PageBlitting ... ist aus irgend einem Grund schneller als PageFlipping

And after that change the frames per minute increased to 220.

So is that normal? I thought PageFlipping is the fastest way, cause the graficcard just needs to change the pointer to a nother place in VRAM.

So finally, have i made a mistake (the full prog lists 240 lines, so I wouldn't post it completely, but here is the link, or ist PageFlipping in Java really slower then Blitting?

I use a Pentium M 1.7GHz 512MB RAM with Radeon 7500M on Windows XP SP1 with jre 1.4.2_02.

Don't try to run the code under Linux, you will run into problems with your mice and keyboard.

P.S.: I'm a first poster, but doesn't find something about that topic somewhere else in the forum, so hope it is placed correct here :-)

P.P.S.: oh, and happy Xmas
Offline oNyx

JGO Coder

Medals: 2

pixels! :x

« Reply #1 - Posted 2003-12-25 17:52:54 »

Welcome Smiley

> So is that normal?


>I thought PageFlipping is the fastest way, cause the
>graficcard just needs to change the pointer to a nother
>place in VRAM.

Yes, it's the fastest way... however it's vsych-ed therefore your framerate is <=hz (60hz in your case).

Use windowed for developing. This way you can see how much slower it gets if you add more stuff (or if you had done something stupid) - the speed difference will be obvious then.

Once you are done you can use fullscreen again (60fps is enough for a 2d game) Wink

弾幕 ☆ @mahonnaiseblog
Offline Jeff

JGO Coder

Got any cats?

« Reply #2 - Posted 2003-12-25 19:30:15 »

On some graphics cards you can disable scan-synchronization.  Check your control panel for the graphics adapter.

But remember, if you aren't scan synchronized then you are likely to see some tearing artifacts.

Got a question about Java and game programming?  Just new to the Java Game Development Community?  Try my FAQ.  Its likely you'll learn something!
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline DD.Jarod

Senior Newbie

Sry for my bad english :-)

« Reply #3 - Posted 2003-12-25 19:55:53 »

it was the scan-synchronization, if I disable it I got twice the frames with PageFlipping then I got with PageFlipping, thx guys
Pages: [1]
  ignore  |  Print  

EgonOlsen (79 views)
2018-06-10 19:43:48

EgonOlsen (59 views)
2018-06-10 19:43:44

EgonOlsen (78 views)
2018-06-10 19:43:20

DesertCoockie (261 views)
2018-05-13 18:23:11

nelsongames (159 views)
2018-04-24 18:15:36

nelsongames (158 views)
2018-04-24 18:14:32

ivj94 (901 views)
2018-03-24 14:47:39

ivj94 (162 views)
2018-03-24 14:46:31

ivj94 (813 views)
2018-03-24 14:43:53

Solater (177 views)
2018-03-17 05:04:08
Java Gaming Resources
by philfrei
2017-12-05 19:38:37

Java Gaming Resources
by philfrei
2017-12-05 19:37:39

Java Gaming Resources
by philfrei
2017-12-05 19:36:10

Java Gaming Resources
by philfrei
2017-12-05 19:33:10

List of Learning Resources
by elect
2017-03-13 14:05:44

List of Learning Resources
by elect
2017-03-13 14:04:45

SF/X Libraries
by philfrei
2017-03-02 08:45:19

SF/X Libraries
by philfrei
2017-03-02 08:44:05 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!