zingbat
|
 |
«
Posted
2004-09-24 10:29:25 » |
|
Lets have a little chalenge here ok ? The chalenge is to make the fastest static method wose semantics is just draw a single pixel using the interface: Graphics.drawPixel(Component c, int x, int y, int color); Whats your best shot.  PS: The semantics of the method doesn't say the pixel must be drawn immideatly and that no other methods can be used to complement the operation.
|
|
|
|
|
crystalsquid
Junior Member  
... Boing ...
|
 |
«
Reply #1 - Posted
2004-09-24 17:34:02 » |
|
Write your own software renderer, then the drawPixel becomes a multiply, an add, and a write into an array. 
|
|
|
|
|
zingbat
|
 |
«
Reply #2 - Posted
2004-09-24 20:23:31 » |
|
Don't you have a more easy solution ?  How would you put that array on screen without suffering a huge performance penality ?
|
|
|
|
|
Games published by our own members! Check 'em out!
|
|
|
|
zingbat
|
 |
«
Reply #4 - Posted
2004-09-25 10:52:13 » |
|
ok thanks well back for another round with java sdl 
|
|
|
|
|
Linuxhippy
|
 |
«
Reply #5 - Posted
2004-11-18 10:22:18 » |
|
thanks for all the info but what is for now the fast ways to draw pixels. I do not think 1mio drawLines would be more optimal that Imageproducer.
Are BufferedImage typically faster than those old 1.1 (ImageProducer) apis?
The question why I am asking is the fact that I am realizing a software renderer which has serious problems with iamge-rendering throughput.
lg Clemens
|
|
|
|
|
krausest
Junior Member  
I love YaBB 1G - SP1!
|
 |
«
Reply #6 - Posted
2004-11-18 10:53:04 » |
|
The fastest way to draw a pixel should be like that: Create an BufferedImage and specify the format. If you've chosen TYPE_3BYTE_BGR you can get the data array and set the values to your color value. Something like: byte[] data=((DataBufferByte)img.getRaster().getDataBuffer()).getData(); (There's a bit in the FAQ about that: Then take a look at the FAQ on http://www.java-gaming.org/cgi-bin/JGNetForums/YaBB.cgi?board=2D;action=display;num=1097853220 )
|
|
|
|
|
Absolution
Senior Newbie 
Java games rock!
|
 |
«
Reply #7 - Posted
2004-11-18 18:59:37 » |
|
I get a 5-10 fps increase with my software renderer if I switch from the Producer/Consumer model to the BufferedImage Model (compiled with 1.5). Do note though that getting direct access to the pixels stops any possibility of hardware acceleration. Too bad because I seem to always want access to it in my games. The speed increase seems to be mainly from avoiding that nasty newPixels call although I could be wrong. I tried implementing my own producer, but didn't notice a difference from the MemoryImageSource so I currently use that for my 1.1 needs. Anyway, on a 2Ghz system I can easily get 60fps at 500x500 for a fully textured 3D world using a producer and it's not even close to fully optimized so the throughput should be fine for most applications.
|
|
|
|
|
Abuse
|
 |
«
Reply #8 - Posted
2004-11-20 00:12:06 » |
|
Why waste time developing a software renderer?
They are only useful in Applets, and as webstart is a far superior alternative in most cases, Applets in my view are an obsolete technoogy. The sooner people stop using them, the better.
|
Make Elite IV:Dangerous happen! Pledge your backing at KICKSTARTER here! 
|
|
|
Linuxhippy
|
 |
«
Reply #9 - Posted
2004-11-20 09:40:28 » |
|
Hmm, maybe you want to do something that can not be done in Hardware? Think of Voxel engines for example, I like voxel engines very much, cause they look much more natural than texture stuff does...
however, everybody should use what he wants to!
|
|
|
|
|
Games published by our own members! Check 'em out!
|
|
princec
|
 |
«
Reply #10 - Posted
2004-11-20 11:24:59 » |
|
I think I saw a recent demo of a voxel engine implemented in OpenGL shaders on opengl.org... Back to the original question: fastest way to draw a pixel is as Dom says to supply your own Graphics implementation and write directly into a nice simple array, and when you're all done with that array, blit the whole thing straight to the screen front buffer with one call. Cas 
|
|
|
|
EgonOlsen
|
 |
«
Reply #11 - Posted
2004-11-20 15:46:03 » |
|
Why waste time developing a software renderer? People are using software renderers for various reasons: no hardware acceleration available, no OpenGL binding, old VMs, rendering takes places on a web server, etc. jPCT can do both, software and hardware, and people are still using the software renderer most of the time. So there definitly is a "market" for software rendering...just maybe not that much in this community, which covers a very tiny niche only. And arguing that way, almost everything that we're doing here is a waste of time. Who cares for the 1000000th clone of tron or tetris written in Java except for the proud author?
|
|
|
|
nonnus29
Senior Member   
Giving Java a second chance after ludumdare fiasco
|
 |
«
Reply #12 - Posted
2004-11-21 13:48:49 » |
|
Why waste time developing a software renderer? Its a good way to learn. Its fun. Its interesting. etc....
|
|
|
|
|
Absolution
Senior Newbie 
Java games rock!
|
 |
«
Reply #13 - Posted
2004-11-21 22:38:57 » |
|
This is getting off topic and this particular off topic has been discussed in extreme depth several times on this board (I can think of 3 right now).
|
|
|
|
|
Jeff
|
 |
«
Reply #14 - Posted
2004-11-22 01:20:24 » |
|
Keep in mind that the question "what is the fastest way to draw a (single) pixel" has little or mno relevance to the question "what is the fastest way to draw N pixeles, where N is at all significant in size."
Bsaically, this is the same old (everyone say it with me) microbenchmarking fallacy.
To draw a whole bunch of unique pixels to a fast frame buffer with no applicable hardware assist its likely for instance that simple mapping the frame buffer using NIO and using the main processor will be a good candidate. OTOH for a single pixel the over-head in setting it up might not be worth it.
Similarly the architecture of your platform and its capabilities will have a big impact on the answer to this question.
|
|
|
|
Abuse
|
 |
«
Reply #15 - Posted
2004-11-22 23:55:17 » |
|
In that regard, I think the fault is with the question =)
Does zingbat realy want to modify just 1 pixel, or does he want to know the fastest way to manipulate many pixels, each individually.
|
Make Elite IV:Dangerous happen! Pledge your backing at KICKSTARTER here! 
|
|
|
zingbat
|
 |
«
Reply #16 - Posted
2004-11-23 14:18:33 » |
|
The question is exactly the question i wanted to make. The fastest way to draw a pixel. This means im stuck with an atomic operation like DrawPixel(x,y).
|
|
|
|
|
Abuse
|
 |
«
Reply #17 - Posted
2004-11-23 22:28:04 » |
|
So this was a hypothetical, not practical question?
|
Make Elite IV:Dangerous happen! Pledge your backing at KICKSTARTER here! 
|
|
|
oNyx
|
 |
«
Reply #18 - Posted
2004-11-24 00:42:47 » |
|
So this was a hypothetical, not practical question? Yes. g.fillRect(x,y,0,0); 
|
|
|
|
zingbat
|
 |
«
Reply #19 - Posted
2004-11-24 08:23:22 » |
|
So this was a hypothetical, not practical question? It was a pratical question but in the sense of having restrictions that aren't pratical. Like the use of the DrawPixel method that is required for the implemention of classic algorithms like drawLine or fillPolygon.
|
|
|
|
|
Abuse
|
 |
«
Reply #20 - Posted
2004-11-24 12:04:43 » |
|
Yes. g.fillRect(x,y,0,0);  0,0? 
|
Make Elite IV:Dangerous happen! Pledge your backing at KICKSTARTER here! 
|
|
|
oNyx
|
 |
«
Reply #21 - Posted
2004-11-24 12:35:27 » |
|
0,0?  Yes. 1,1 would be a 2x2 rect. Pixel bounding stuff is funny, isn't it? 
|
|
|
|
Abuse
|
 |
«
Reply #22 - Posted
2004-11-24 13:31:00 » |
|
Fills the specified rectangle. The left and right edges of the rectangle are at x and x + width - 1. The top and bottom edges are at y and y + height - 1. The resulting rectangle covers an area width pixels wide by height pixels tall. The rectangle is filled using the graphics context's current color.
So width,height of 0,0 will (or atleast *should*) cover no pixels.
|
Make Elite IV:Dangerous happen! Pledge your backing at KICKSTARTER here! 
|
|
|
|