Java-Gaming.org    
Featured games (78)
games approved by the League of Dukes
Games in Showcase (426)
Games in Android Showcase (89)
games submitted by our members
Games in WIP (466)
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  
  Java 2D - Resources  (Read 39551 times)
0 Members and 1 Guest are viewing this topic.
Offline kevglass

JGO Kernel


Medals: 85
Projects: 22


Coder, Trainee Pixel Artist, Game Reviewer


« Posted 2004-10-15 15:13:40 »

Note that a much more complete FAQ can be found at:

http://java.sun.com/products/java-media/2D/reference/faqs/index.html

Frequently Asked Questions:

Q: What are those properties that speed up Java 2D's rendering performance?

A: Check out this document for a full list:   http://java.sun.com/j2se/1.5.0/docs/guide/2d/flags.html
--
Q: What's the difference between BufferedImage and VolatileImage and when do I use a particular image format for displaying my sprite, jpg, png, etc?

A: http://weblogs.java.net/blog/chet/archive/2004/08/toolkitbuffered.html
or any of Chet's other excellent blogs on 2D images
http://weblogs.java.net/blog/chet/
--
Q: How do I know if my Java2D images are actually being accelerated in hardware?

A: Enable JVM profiling by setting java -Dsun.java2d.trace=count in the VM arguments before running your app.  Then, quit your application and look through the generated log file for D3DBlitLoops.

---
Q: What oses support full screen java?
 
A: Windows 2000 and XP are known to support full screen correctly. Other systems are still not fully catered for.

UPDATE: MacOSX supports full screen also.

---
Q: How do I access the pixels of a BufferedImage to do software rendering?  

A:
1  
2  
BufferedImage tex = //get it from somewhere 
byte data[] = (byte[]) tex.getRaster().getDataElements(0, 0, tex.getWidth(), tex.getHeight(), null);  


or to get a reference to the actual buffer:

1  
byte[] data=((DataBufferByte)tex.getRaster().getDataBuffer()).getData() 


---
Q: How do I access the pixels of an Image to do software rendering? (java 1.1 - optional as we don't want to perpetuate old stuff)  
 
A:
1  
2  
Image im = //get the image 
im.getSource().startProduction(ic);

 
ic is an object that implements the java.awt.image.ImageConsumer interface.  the method setPixels(...) will be called with the data that the image contains.

---
Q:  How to load images and preserve tranparency?

A: If the built in loaders are used, then transparency will automatically be preserved.  If you are manually loading the data, then putting it into an image you need to do some work.  

1  
2  
//BufferedImage im = new BufferedImage(width, height, type) 
BufferedImage im = new BufferedImage(100, 100, BufferedImage.TYPE_INT_ARGB);


This sets up the BufferedImage to be able to accept alpha values.  Then one of three methods can be called to insert pixel values:

1  
2  
3  
setData(Raster r) 
setRGB(int x, int y, int rgb)  
setRGB(int startX, int startY, int w, int h, int[] rgbArray, int offset, int scansize)


----
Q: What's accelerated by opengl pipeline in 5.0

A: Check out the Chris' blog:
  http://weblogs.java.net/blog/campbell/archive/2004/11/behind_the_grap.html

----
Q:
How do i enable profiling like  java -Dsun.java2d.trace=count when i'm running a Applet?

A:
 Either set it in the applet's ControlPanel, or set an env. variable _JAVA_OPTIONS="-Dsun.java2d.trace=log".  
 
You can also redirect the output to a file.
usage: -Dsun.java2d.trace=[log[,timestamp]],[count],[out:<filename>],[help],[verbose]
----

Q: How do I profile an Applet since I can't set the appropriate properties?

A: Use AppletViewer that comes with the SDK to test and profile applets.

----

Q: I'm trying to blit alot of sprites to the screen and I just can't get the performance I want out of Java2D. Are there any other options?

A: Yes. JOGL/LWJGL provide bindings to OpenGL which is more complicated but gives a finer level of control and in most cases gives better performance. You might also consider GTGE which gives you an abstraction above Java2D/OpenGL.

----

If you can think of extra common questions for this list post the question and answer below. I'll tidy it up as time goes on. In addition, if you think an answer here is wrong also let us know.

[Question/Answer Contributors: immudium, CaptainJester, K.I.L.E.R, nonnus29,trembovetski, trycoon, Demonpants, blahblahblahh, Tusaki]

Offline tusaki

Junior Member


Medals: 1


In a mad world only the mad are sane.


« Reply #1 - Posted 2006-03-13 22:38:04 »

Q) how do obtain real 2D performance for a game in java?

A) learn opengl (jogl / lwjgl)

(ok ok... but still... it is an often asked question, right? Grin)
Offline kevglass

JGO Kernel


Medals: 85
Projects: 22


Coder, Trainee Pixel Artist, Game Reviewer


« Reply #2 - Posted 2006-03-13 22:38:53 »

Its not a fair answer tho is it, given that 1.5 Java2D is OpenGL will the performance be ways better?

Kev

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline tusaki

Junior Member


Medals: 1


In a mad world only the mad are sane.


« Reply #3 - Posted 2006-03-13 22:47:42 »

I'm not sure. altough personally I've had better performance using the opengl api's directly. Also, I feel (again, this is subjective) that I have more control over what is happening. I mean, does java2d utilize all the extensions which opengl has to offer? in an intelligent way? I have a feeling that java2d controls too many aspects... "leave it to java2d so it will work on every device" ... to be honest, I don't really care about that. I want it to work on the best way for as many people as possible. which usually means windows with a mediocre graphics card.
Offline kevglass

JGO Kernel


Medals: 85
Projects: 22


Coder, Trainee Pixel Artist, Game Reviewer


« Reply #4 - Posted 2006-03-13 22:53:47 »

[DevilsAdvocate] Windows with an average to poor graphics card - best option is normally DirectX or DirectDraw (depending on how poor). Java2D works through DirectDraw very nicely.

I see where you're coming from but I think its extremely open to debate (which I'm more than happy to see Smiley)

Kev

Offline tusaki

Junior Member


Medals: 1


In a mad world only the mad are sane.


« Reply #5 - Posted 2006-03-13 22:58:47 »

Ok, for a simple test case, 1000 alpha-blended sprites on screen, moving randomly, which will do better? LWJGL or Java2d with performance flags?  Tongue my money is on LWJGL. (disclaimer: I use java2d for a living, lwjgl/games is a hobby.)
Offline kevglass

JGO Kernel


Medals: 85
Projects: 22


Coder, Trainee Pixel Artist, Game Reviewer


« Reply #6 - Posted 2006-03-14 04:27:13 »

Since when did games have to use alpha blending or for that matter sprites? Draw 1000 pixel perfect circles on the screen in GL or Java2D. I think I'd be the other way in that contest simply due to primitives.

Tbh, I use LWJGL so I'm more than happy to accept its a better solution for high performance bitmap based gaming, but I don't think its as cut and dry as your question makes it out to be.

How about:

Q) I'm trying to blit alot of sprites to the screen and I just can't get the performance I want out of Java2D. Are there any other options?

A) Yes. JOGL/LWJGL provide bindings to OpenGL which is more complicated but gives a finer level of control and in most cases gives better performance. You might also consider GTGE which gives you an abstraction above Java2D/OpenGL.

Kev

Offline tusaki

Junior Member


Medals: 1


In a mad world only the mad are sane.


« Reply #7 - Posted 2006-03-14 17:45:54 »

I agree with the points you raised and I think I can manage to live with that Q/A entry Smiley
Offline orelero

Senior Newbie





« Reply #8 - Posted 2006-11-11 22:04:41 »

http://www.cs.umd.edu/hcil/agile2d/     Shocked
Offline keldon85

Senior Member


Medals: 1



« Reply #9 - Posted 2007-02-04 18:02:02 »

[DevilsAdvocate] Windows with an average to poor graphics card - best option is normally DirectX or DirectDraw (depending on how poor). Java2D works through DirectDraw very nicely.

I see where you're coming from but I think its extremely open to debate (which I'm more than happy to see Smiley)

Kev

Isn't DirectX only supported on Windows? Either I am pretty sure OpenGL is supported on all platforms whereas DirectX is not!

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline oNyx

JGO Coder


Medals: 1


pixels! :x


« Reply #10 - Posted 2007-02-04 20:43:17 »

The DirectX Java2D pipeline is/can obviously only used under Windows.

The OpenGL pipeline can be used pretty much everywhere. However, it still doesn't behave very well (with 1.6).

弾幕 ☆ @mahonnaiseblog
Offline keldon85

Senior Member


Medals: 1



« Reply #11 - Posted 2007-02-04 21:13:18 »

Well wouldn't it be better to compile in 1.5 with OpenGL where you have a larger audience than just windows instead of using 1.6 with DirectX and only being able to run in Windows!

Offline oNyx

JGO Coder


Medals: 1


pixels! :x


« Reply #12 - Posted 2007-02-05 00:29:57 »

You compile only once. You can use different pipelines via command line switches or through properties (set for specific operating systems) with jnlp.

弾幕 ☆ @mahonnaiseblog
Offline ra4king

JGO Kernel


Medals: 322
Projects: 2
Exp: 4 years


I'm the King!


« Reply #13 - Posted 2011-02-10 04:10:59 »

Where can I learn LWJGL? Having used Java2D for all my programs, LWJGL's javadoc looks very scary and complicated.

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 (75 views)
2014-04-15 18:08:23

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

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

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

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

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

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

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

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

CJLetsGame (220 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!