Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (476)
Games in Android Showcase (106)
games submitted by our members
Games in WIP (533)
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  
  BufferStrategy Doublebuffer  (Read 2699 times)
0 Members and 1 Guest are viewing this topic.
Offline moonpxi

Senior Newbie




Java games rock indeed!!!


« Posted 2004-01-17 18:22:24 »

Hello all,

I am having a sort of "problem" using double buffer with BufferStrategy.

Well, first of all, I am creating my strategy with two buffers (obviously) and I know, through the buffer capabilities, that it is possible to do a hardware flip.

However, my sprites animations are VERY, VERY slow, and I am clueless to why. Actually, when I use a strategy with only one buffer, the result is pretty much fast, and what I was hoping for. Unfortunetly, there are a lot of flickering in it. Tongue

So, if anyone can answer why I am getting this slowness, and how to fix it, I would be very happy!!

Moon Pxi

Moon Pxi, a NerdCorper
Offline Backmask

Junior Member




586: The average IQ needed to understand a PC


« Reply #1 - Posted 2004-01-17 19:08:40 »

Post your code that involves bufferstrategy and your rendering loop.

Offline Jeff

JGO Coder




Got any cats?


« Reply #2 - Posted 2004-01-17 20:07:45 »

Yep.  A few other things to consider:

(1) Are you sure yo uare creating both buffers in video memory?  How much video memory do you have on your card?
(if you have enough and you are saying just that you want 2 it should do them in video memory for you.)

(2) What platform is this? Apple's BufferStratgey implementation in JDK1.3 was very slow.  Theyw ere supposed to be improving it in 1.4 but i havent tested that.

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 elias4444

Junior Member





« Reply #3 - Posted 2004-01-17 21:27:32 »

I'm a complete newbie, and the following confession will attest to it:

I had the same problem, but it turned out I was doing the doublebuffering correctly afterall....my problem was that I had the read image method as part of my paintmethod (that was getting called over and over again). I just had to move it out of the loop and stick my sprites in memory first...then voila!

Yes...I'm a newbie...although I think I should have at least caught that one sooner than the hour it took me.  Tongue

Offline moonpxi

Senior Newbie




Java games rock indeed!!!


« Reply #4 - Posted 2004-01-17 23:40:40 »

Backmask:
My code is basically the same as it was presented in the Wiki part of www.java-gaming.org.

Jeff:
I believe that both buffers are in video memory. I checked through the ImageCapability of both buffers and it said it was accelerated, or something. I wonder if it means it's in the video memory

And, actually, the computer I was running is kind of old, and it was running Linux. The goal of my game is to actually be runnable on older machines. For a 2D game, I hope this is not too much to ask...


The strangest thing I noticed is that, with only one buffer, it runs quite fast. I thought page flipping was just a swap in memory pointers...am I wrong?

Moon Pxi, a NerdCorper
Offline Jeff

JGO Coder




Got any cats?


« Reply #5 - Posted 2004-01-17 23:43:31 »

Quote
And, actually, the computer I was running is kind of old, and it was running Linux.



Ah theres your problem!

Quote

The strangest thing I noticed is that, with only one buffer, it runs quite fast. I thought page flipping was just a swap in memory pointers...am I wrong?


It is, IF the platform allows it.   AWT is implemented on Linux ontop of X. X has no true full-screen mode.  Going full-screen in X just makes a screen-sized undecorated window.

X doesnt allow us to either get to video memory OR flip screen pointers, sorry Sad



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
Offline moonpxi

Senior Newbie




Java games rock indeed!!!


« Reply #6 - Posted 2004-01-18 00:11:26 »

Jeff:
Just a quick clarification. My problem is that I am running Linux, right?? So, if I was running in a windows machine, but in a slower computer, I would be able to get decent framerates and use all hardware and video stuff??

Well, and what about if I did the game in windowed mode?? Is there a mechanism, similar to BufferStrategy, that I could employ (either in Linux or Windows) to get it fast??

By the way, thanks for all your answers!!

Moon Pxi, a NerdCorper
Offline Jeff

JGO Coder




Got any cats?


« Reply #7 - Posted 2004-01-18 00:50:01 »

Quote
Jeff:
Just a quick clarification. My problem is that I am running Linux, right?? So, if I was running in a windows machine, but in a slower computer, I would be able to get decent framerates and use all hardware and video stuff??


Well assuming the machien ash the spes to handle what yo uare doing, sure.  You should get full hardware acceleration if you organize it right under Windows.


Quote

Well, and what about if I did the game in windowed mode?? Is there a mechanism, similar to BufferStrategy, that I could employ (either in Linux or Windows) to get it fast??


Well by dfinition in Windowed you can't page flip, but you CAN still use BufferStrategy.  BS will just do a BLT rather then a flip to get it to the screen.

Code-wise its almost the same whether you are doing full screen or windowed, there are 2 lines difference in set up and thats it.   Take a look at Scroller demo in exampels which runs in either mode.

[quote[
By the way, thanks for all your answers!! [/quote]

Thats what I'm here for.


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
Offline moonpxi

Senior Newbie




Java games rock indeed!!!


« Reply #8 - Posted 2004-01-18 10:05:10 »

Jeff:
I just checked out your scroller demo. So, the diference between the two modes is that you set fullscreen in one, and not in the other?? Well, that's pretty close!! Smiley

I also noticed that you set a LOT of ignoreRepaints. This would make the frame not call the paint method, right? Would this improve performance???

If I thinkered with the BufferCapabilities, could I get better results???

And, lastly, Linux is a viable solution for game development?? Of course, I was testing on a older machine, but I expected to run reasonably well....

Moon Pxi, a NerdCorper
Offline Jeff

JGO Coder




Got any cats?


« Reply #9 - Posted 2004-01-18 20:32:47 »

If you are  using active rendering (BufferStratgey) you do NOT use AWT repaint.  Therefore if you try to use AWt components with active rendering you need to disable their use of it.

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 Jeff

JGO Coder




Got any cats?


« Reply #10 - Posted 2004-01-18 20:34:44 »

Quote

If I thinkered with the BufferCapabilities, could I get better results???


Likely not, it already sets it self miximally for your environment.

Quote

And, lastly, Linux is a viable solution for game development?? Of course, I was testing on a older machine, but I expected to run reasonably well....


Well yes, but not for AWT today in any form.  If Linux is one of your targets you will likely have to use LWJGL or JOGL (3D  libraries, but you can do 2D with them.  2D is just 3D with one eye closed Wink )


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
Offline moonpxi

Senior Newbie




Java games rock indeed!!!


« Reply #11 - Posted 2004-01-18 23:58:29 »

"2D is just 3D with one eye closed"

Ha, this one was great!!! Smiley

Continuing on my endless series of question, why would I have to use LWJGL or JOGL?? They have faster mechanisms, or something??

And, by the way, should I generally use this libraries when even developing for Windows, and 2D??

Moon Pxi, a NerdCorper
Offline oNyx

JGO Coder


Medals: 1


pixels! :x


« Reply #12 - Posted 2004-01-19 07:26:19 »

Quote

Continuing on my endless series of question, why would I have to use LWJGL or JOGL?? They have faster mechanisms, or something??


The most obvious benefits are fast (linear) filtering of textures, fast full alpha and beautiful rotations. Also it's easy to add 3D effects (apparently heh).

Quote

And, by the way, should I generally use this libraries when even developing for Windows, and 2D??


Unfortunately there isn't such a thing like _the_ best API. It always depends on several factors wich API you should choose... otherwise we would all use the same APIs Smiley

If it's an (J)Applet you've to use plain Java2D.

Application (or webstart) and you are free to choose between 'em all.

Plain (fast) OpenGL -> LWJGL
Plain (fast) OpenGL (2D) -> LWJGL + SPGL
OpenGL + Swing (and the like) -> JOGL

And if you're planning to do some more complex stuff it's worth to checkout Xith3D. It's a scenegraph API, wich does most of the stuff you usually need in games. However it's overkill if you want to do a 2D game (rephrased: it won't scale that well, because the "scene" would be to simple).

That's it basically.

IMO it's a good idea to start with Java2D (it isn't that bad afterall). Once you understand the basic concepts of game programming you can move on to LWJGL or JOGL (it isn't that much work to port a game from Java2D to one of that OpenGL wrappers).

弾幕 ☆ @mahonnaiseblog
Offline Jeff

JGO Coder




Got any cats?


« Reply #13 - Posted 2004-01-31 18:03:06 »

Quote
"
Continuing on my endless series of question, why would I have to use LWJGL or JOGL?? They have faster mechanisms, or something??


The big advantage the OGL libs (LWGL and JOGL) have is that on Unix they don't have to go through X windows.  Instead they talk to the native OGL library which is generally hacked into the system to bypass all the X issues.


For an exmaple of a 2D game written using OGL try Cas's Alien Flux Smiley  Unfrotunately source isnt available but it will give you an idea of whats possible.


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
Offline trembovetski

Senior Member




If only I knew what I'm talking about!


« Reply #14 - Posted 2004-02-02 02:32:33 »

I'd like to clarify some points. Java2D on linux uses Pixmaps to accelerate some type of images (those created with createImage, or loaded with Toolkit.getImage).

Depending on the hw and the driver you're using, those Pixmaps may reside in video memory. This means that copying images to the screen will happen at hw speeds. Another good thing is that  since we use X11 to render to those images, rendering simple primitives (those backed up by X11 protocol) may too be hw accelerated.

So unless you're doing something X can't really handle (translucency, AA-rendering, non-simple transforms, etc), a typical sprite-based game should run at very decent speed on linux.
Offline Jeff

JGO Coder




Got any cats?


« Reply #15 - Posted 2004-02-02 03:36:43 »

DT's da man on these things.

But, correct me if Im wrong, it is true that you cannot do true full screen frame flipping under X?

JK

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
Offline trembovetski

Senior Member




If only I knew what I'm talking about!


« Reply #16 - Posted 2004-02-03 02:56:05 »

Nope, not with our current implementation.

As Jeff correctly pointed out, going 'fullscreen' on linux is emulated by creating a frame w/o decorations with the size of the screen.

But since we do use DBE (double-buffering extension) with the Flip BufferStrategy, buffer flipping will be hardware accelerated (where dbe is accelerated, of course).

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.

pw (22 views)
2014-07-24 01:59:36

Riven (20 views)
2014-07-23 21:16:32

Riven (17 views)
2014-07-23 21:07:15

Riven (20 views)
2014-07-23 20:56:16

ctomni231 (48 views)
2014-07-18 06:55:21

Zero Volt (44 views)
2014-07-17 23:47:54

danieldean (35 views)
2014-07-17 23:41:23

MustardPeter (38 views)
2014-07-16 23:30:00

Cero (53 views)
2014-07-16 00:42:17

Riven (53 views)
2014-07-14 18:02:53
HotSpot Options
by dleskov
2014-07-08 03:59:08

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:58:24

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:47:22

How do I start Java Game Development?
by ra4king
2014-05-17 11:13:37

HotSpot Options
by Roquen
2014-05-15 09:59:54

HotSpot Options
by Roquen
2014-05-06 15:03:10

Escape Analysis
by Roquen
2014-04-29 22:16:43

Experimental Toys
by Roquen
2014-04-28 13:24:22
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!