Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (541)
Games in Android Showcase (133)
games submitted by our members
Games in WIP (603)
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  
  BufferedImage for fast display?  (Read 1259 times)
0 Members and 1 Guest are viewing this topic.
Offline gojira

Senior Newbie




Java games rock!


« Posted 2005-02-05 01:56:34 »

Hi all!  I'm looking at starting a simple game, with a few sprites.  I want to make a few sprites using BufferedImage, then blit the sprites quickly to the screen.

Query: How can I match the display (bit depth, RGB, BGR, etc. ) for the fastest blit?

I want to set this up before hand, not in the paint() method.  Trying to create all the sprites in the paint() method would basically be kludgy, at best, and totaly unworkable at worst.

I want to set up the sprites in main(), or some method called by main, with images that match the screen bit depth.

Any ideas?  Thanks for the help!
Offline Smarto

Senior Newbie




Hiya!


« Reply #1 - Posted 2005-02-06 21:23:23 »

Hi there gojira!

I don't quite understand your question, but I will try to help.

It seems like what you are trying to do is implement a form of double buffering, where instead of your graphics being drawn directly to the screen, it is drawn in your computer's memory and then simply "flipped" over or copied to your screen.

If you want to set up your sprites before drawing them, I suppose you could load them in your program's initialization phase, either the constructor if you are making an Application, or init() in an Applet.

Some other solutions to this:

1) If you are looking for a full-fledged animation loop, complete with double buffering, you might want to check out Chapter 1 of this book-in-progress:
http://fivedots.coe.psu.ac.th/~ad/jg/.
This chapter also covers totally ignoring paint() altogether so you can perform your own graphics drawing whenever and wherever.


2) There are a few sections on passive vs. active rendering here at the Java Tutorial:
http://java.sun.com/docs/books/tutorial/extra/fullscreen/index.html


Sorry if this isn't what you were looking for!
Smarto

Smarto
Anger is the equivalent of grasping a hot coal in the palm of your hand
- Unkown
Offline gojira

Senior Newbie




Java games rock!


« Reply #2 - Posted 2005-02-07 01:41:01 »

Hey Smarto, thanks for those links.  They look pretty good, I'll have to check them out.  

Basically I want to do a form of double buffering.  I want to use a background image and then add seperate sprite images the background to form the final image.  I plan to use these as seperate images, not quite double buffering, and use dirty rectangles to only update the areas that I want.

But that doesn't matter.  Right now, I only want one thing.  How can I get the bit depth and color mode of the display so I can match it with my images I create?

I changed my original post to better say what I ment (you are right, I wasn't too clear the first time).  

Anyhoo, hopefully someone can answer.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Malohkan

Senior Devvie




while (true) System.out.println("WOO!!!!");


« Reply #3 - Posted 2005-02-07 02:46:59 »

http://www.gamelizard.com/JavaGameProgrammingPresentation.htm

Scroll down a bit to where I talk about how to get managed BufferedImages.  With that strategy, you can ask for a BufferedImage with Translucency.WHATEVER constants which will be compatible with the current display.

Admin and Game Developer at
GameLizard.com
Play Rimscape!    |    Play Conquer!
Offline gojira

Senior Newbie




Java games rock!


« Reply #4 - Posted 2005-02-07 15:18:41 »

1  
2  
3  
4  
5  
 GraphicsConfiguration gc = GraphicsEnvironment.getLocalGraphicsEnvironment()
     .getDefaultScreenDevice().getDefaultConfiguration();

BufferedImage image = gc.createCompatibleImage(width, height,
     Transparency.TRANSLUCENT);

Woo!  That looks like what I wanted! Thanks Mal, I'll check this out. Smiley
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.

Mr.CodeIt (24 views)
2014-12-23 03:34:11

rwatson462 (55 views)
2014-12-15 09:26:44

Mr.CodeIt (45 views)
2014-12-14 19:50:38

BurntPizza (88 views)
2014-12-09 22:41:13

BurntPizza (111 views)
2014-12-08 04:46:31

JscottyBieshaar (82 views)
2014-12-05 12:39:02

SHC (92 views)
2014-12-03 16:27:13

CopyableCougar4 (99 views)
2014-11-29 21:32:03

toopeicgaming1999 (159 views)
2014-11-26 15:22:04

toopeicgaming1999 (157 views)
2014-11-26 15:20:36
Resources for WIP games
by kpars
2014-12-18 10:26:14

Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

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