[java] Direct rendering speed results ( awt vs java2d )
#1 Members - Reputation: 122
Posted 20 November 2000 - 03:34 PM
#2 Anonymous Poster_Anonymous Poster_* Guests - Reputation:
Posted 20 November 2000 - 08:36 PM
Henry
#3 Members - Reputation: 122
Posted 21 November 2000 - 12:18 AM
If others would like to see the code just shout, if I get enough people I''ll write an article for gamedev. I''m also finishing the helper chlasses so I can do...
main() {
ForcedTimingLoop test = new ForcedTimingLoop( new Component );
test.drawResultsOverImage();
test.run();
}
#4 Anonymous Poster_Anonymous Poster_* Guests - Reputation:
Posted 21 November 2000 - 05:52 AM
Btw, read in the Java2D FAQ that jdk1.4 will feature a new hardware accelerated rendering technique:
http://www.javasoft.com/products/java-media/2D/forDevelopers/java2dfaq.html#accel
Henry
#5 Members - Reputation: 122
Posted 21 November 2000 - 06:19 AM
The performace of BufferedImage is more than enough for what I''m trying to do, and with a nice wrapper interface I should be able to run transparently on java1.1 and java1.2+ platforms assuming they are fast enough. I did the math my drawing routines are pushing almost 200 MB/s not that bad for a language most people consider slow.
Now if they could only incude functional mulit-track audio mixing I would be set. Java Media 1.0 looks good I just need to sit down and play with it.
#6 Anonymous Poster_Anonymous Poster_* Guests - Reputation:
Posted 21 November 2000 - 06:53 AM
I am not entirely satisfied with the speeds that you present though. First off, you ran the tests on a very fast computer (wonder what kind of rates I''ll get on my ol'' PII 450). Second, since you can not change the screen resolution from Java you will either require some native code that changes the resolution to 640*480 or your image will be tiny (most people use 800*600 or 1024*768). If you do not want to have native code to change the resolution of the screen and choose to draw a larger image instead, your framerates will probably be divided by approx 2-4 (you will just be able to draw 1 or 2 layers instead of 4).
The combination of a slower processor and being forced to draw a 1024*768 image can lower your numbers a lot. Then the fact that one wants to do AI calculations, play music, handle input etc., all while drawing makes me realize how much I really want that accelerated image interface
Henry
#7 Members - Reputation: 122
Posted 21 November 2000 - 06:58 AM
Something that some other programs have used that may give almost free scaling is using the buffered image as the texture on a polygon that fills the screen. A little overkill, but it it gets me scaling for free on 3d accelerated platforms I''ll take it.
I''ve only been working on this for a few days now and have anready been able to signifigantly increase my speed, so just give me some more time.
#8 Members - Reputation: 122
Posted 21 November 2000 - 08:48 AM
And as anon said, if you could post a link to get the source (when you''re done of course
Smoo
#9 Members - Reputation: 122
Posted 21 November 2000 - 09:25 AM
BufferedImage = java2d ( getRaster().getData() )
I''ll clean up the 6 or so test cases I''ve developed as well as the component fps tester. If I get a chance I''ll also throw in at no additional my handy Debugging class that redirects stdout and stderr to a window at the bottom of the screen.
#10 Members - Reputation: 122
Posted 21 November 2000 - 10:16 AM
Don''t think it comes close to the fps rates you''re quoting for Java2d though. I''m impressed.
I came across some code (with source) to change the screen resolution (JNI link to a DLL). I can''t remember where I found it, but I''ll email it to anyone who wants it.
J.
PS. I''d be interested in seeing your code as well.
#11 Members - Reputation: 200
Posted 21 November 2000 - 11:53 AM
I wanrned you! Didn''t I warn you?! That colored chalk was forged by Lucifer himself!
Opere Citato
#12 Members - Reputation: 122
Posted 21 November 2000 - 01:46 PM
Anyone who would like a zip file of the sources e-mail me eric at snowmoon dot com ( figure it out ) the whole thing is 6.6k.
I''m going to give that ImageProducer trick a try to see if that can spped things up some. I have also found a much more accurate timer, it''s part of the JMF 2.1 the Time class has nanosecond accuracy so that should do just fine. It also have audio/video playback and audio mixing... hopfully this will be included in 1.4 along with some of the other things mentioned here.
Java''s really starting to kick ass.
#13 Members - Reputation: 122
Posted 22 November 2000 - 01:55 AM
I''ve managed to tweak a few frames more per second out of it, but not by much.
#14 Members - Reputation: 122
Posted 22 November 2000 - 05:35 PM
The only time in the actual code where values are being assigned to the _image var is when it''s created:
_image = Toolkit.getDefaultToolkit().createImage(this);
what I don''t understand is when it where is _image updated since nowhere in the code is it linked to the ImageConsumer so could you (or anyone else who''s seen the code or knows what I''m talking about) explain to me how it gets updated?
My only explanation of this is in the createImage(this) where the this is a pointer to the ImageProducer in which case when the ImageConsumer var is updated, the image is also.
I''m not sure if I made sense there or not... I''m hoping you have a better explanation than the one I came up with.
Thanks,
Smoo
#15 Members - Reputation: 122
Posted 23 November 2000 - 12:37 AM
creates the image with the timePTC class as it''s image producer. If you then look through the update(Object pixels) function. Update calls the necessary ImageConsumer functions to update the image and then calls paint() to put it on the screen.
It''s horrible code, because it changes update''s signature ( normally used by awt ). It attempts to pile so much into this one class you loose sight of what happening. I could be wrong, but run() calls Main(_with,_height), but the example file has it''s function declared main this will not work.
hmm.. still interesting tho.
#16 GDNet+ - Reputation: 1811
Posted 23 November 2000 - 01:59 AM
#18 Members - Reputation: 122
Posted 23 November 2000 - 09:17 AM
Thanks for your code, snowmoon. I''ve done some tests and here''s what I''ve found. Note the figures are average frames per second running in a 640x480 window.
The test programs blitTest1-6 are code provided by snowmoon. tinyptc is the code taken (and fixed) from gaffer.org. blitTest7 is snowmoon''s fastest code, modified to display the same test pattern as tinyptc.
On my work computer (which is a dual-processor P800 with 350Mb RAM):
blitTest1 20fps
blitTest2 18
blitTest3 11 (color model appears not to work)
blitTest5 32
blitTest6 55
tinyptc 40
blitTest7 (RGB cm) 55
On my laptop at home, which is a gungy P266 with 64Mb of RAM:
blitTest1 6fps
blitTest2 0.5
blitTest3 2
blitTest5 (won''t run - 32bit color not supported)
blitTest6 12
tinyptc 8
blitTest7 8
It''s interesting to note the difference between tinyptc and blitTest7 on the faster machine.
The difference between tinyptc and blitTest7 is that tinyptc implements ImageProducer to deliver the content, whereas blitTest7 uses a BufferedImage. The loop to generate a static test pattern (ala tinyptc) is exactly the same.
J.






