Java-Gaming.org    
Featured games (91)
games approved by the League of Dukes
Games in Showcase (581)
games submitted by our members
Games in WIP (500)
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 1127 times)
0 Members and 1 Guest are viewing this topic.
Offline DD.Jarod

Senior Newbie




Sry for my bad english :-)


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

Moin
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();

           while(bRunning)
           {
                 if(Backbuffer.getCapabilities().getFlipContents()!=BufferCapabilities.FlipContents.BACKGROUND)
                 {
                       GrfxScreen.fillRect(0,0,nWidth, nHeight);
                 }// if(...) -> Falls die Bufferstrategier nicht selbst den Backbuffer saeubert machen wir das
                 
                 // ----  Draw here  ----
                 GrfxScreen.setColor(Color.green);
                 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.setColor(Color.blue);
                 GrfxScreen.drawString("F Fullscreen <-> Window",0,140);
                 GrfxScreen.drawString("P PageFlipping oder -Blitting",0,160);
                 GrfxScreen.drawString("Esc Ende",0,180);
                 
                 GrfxScreen.setColor(ClrBack);
                 // ---- End Drawing ----
                 
                 // Anzahl Frames der letzten Sekunde anzeigen
                 GrfxScreen.setColor(Color.red);
                 GrfxScreen.drawString("FPS: "+nOldFPS, 0,20);
                 GrfxScreen.setColor(ClrBack);
                 
                 nFPS++;
                 if(lTime+1000 <= System.currentTimeMillis())
                 {
                       lTime = System.currentTimeMillis();
                       nOldFPS = nFPS;
                       nFPS = 0;
                 }// if(...) -> Jede Sekunde Anzahl FPS der letzten Sek updaten
                 if(bRunning)Backbuffer.show();
           }// 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),
                                                                       BufferCapabilities.FlipContents.BACKGROUND);
           }// if(...) -> Soll mit PageFlipping laufen?
           else
           {
                 bFlipping = false;
                 BufferCaps = new BufferCapabilities(new ImageCapabilities(true),
                                                                        new ImageCapabilities(true),
                                                                       null);
           }// 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 http://www.tzi.de/~oherdin/java/GrfxTest.rar), 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: 1


pixels! :x


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

Welcome Smiley

> So is that normal?

Yes.

>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 20: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!

http://wiki.java.net/bin/view/Games/JeffFAQ
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 20: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  
 
 
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.

xsi3rr4x (60 views)
2014-04-15 18:08:23

BurntPizza (58 views)
2014-04-15 03:46:01

UprightPath (71 views)
2014-04-14 17:39:50

UprightPath (54 views)
2014-04-14 17:35:47

Porlus (71 views)
2014-04-14 15:48:38

tom_mai78101 (97 views)
2014-04-10 04:04:31

BurntPizza (157 views)
2014-04-08 23:06:04

tom_mai78101 (252 views)
2014-04-05 13:34:39

trollwarrior1 (207 views)
2014-04-04 12:06:45

CJLetsGame (214 views)
2014-04-01 02:16:10
List of Learning Resources
by SHC
2014-04-18 03:17:39

List of Learning Resources
by Longarmx
2014-04-08 03:14:44

Good Examples
by matheus23
2014-04-05 13:51:37

Good Examples
by Grunnt
2014-04-03 15:48:46

Good Examples
by Grunnt
2014-04-03 15:48:37

Good Examples
by matheus23
2014-04-01 18:40:51

Good Examples
by matheus23
2014-04-01 18:40:34

Anonymous/Local/Inner class gotchas
by Roquen
2014-03-11 15:22:30
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!