2D Java graphics
by William Finlayson · in Technical Issues · 05/09/2001 (2:11 pm) · 4 replies
I am REQUIRED to make a 2D game in Java so no sugestions to use windows+directx please :)
Ok, I have made a class suitable to displaying 2D graphics in Java which gives you access to a buffer so that you can write individual colour values. Problem being it's crap and slow. It involves lots of copying - the pixel buffer is just an array of ints, which is then coppied to a BufferedImage, which is then copied to the Frame's Graphics object. SLOW!!! I can't see any other way to have per-pixel access though.
Any help would be muchly muchly appreciated. I know you can draw polygons using Graphics, but I have'nt seen how to put an image on them. Even if someone could show me how to do that - for sprites and the like, then it would be useful. But access to a frame buffer, and fast, is what I'm really after
Ok, I have made a class suitable to displaying 2D graphics in Java which gives you access to a buffer so that you can write individual colour values. Problem being it's crap and slow. It involves lots of copying - the pixel buffer is just an array of ints, which is then coppied to a BufferedImage, which is then copied to the Frame's Graphics object. SLOW!!! I can't see any other way to have per-pixel access though.
Any help would be muchly muchly appreciated. I know you can draw polygons using Graphics, but I have'nt seen how to put an image on them. Even if someone could show me how to do that - for sprites and the like, then it would be useful. But access to a frame buffer, and fast, is what I'm really after
About the author
#2
05/10/2001 (5:16 pm)
Thanx for the reply, but it looks like it is drawn using java Graphics drawing routines, there's no texturing of anything. I'm just going to have to hit the manual hard and hope there was something I missed :)
#3
06/08/2001 (10:05 pm)
Ever find it, William? If you want to go nuts, you could try the J3D library. A little overkill for 2D work, but it does use OpenGL or DX so it's accelerated.
#4
Anyway, I'm really looking into using Java for more games-related things, there are a few articles at gamedev.net all about optimizing Java, and using it in games. I was thinking it would save a lot of work if I did the scripting for an engine in Java, and using JNI to link to the engine code? I'm not all to clear on that though, and I'd need to do plennty more research/testing, but it would be cool if I could pull it off some day, it would save so much time.
06/09/2001 (4:45 pm)
HI Scott, I've looked into the Graphics object some more, and done tests and things, and it seems that it's more then fast enough for what I'm doing. J3D would be a bit of overkill though - I looked at it ages ago, and figured that it would take as long (if not longer) to learn it, as it did to learn Java :)Anyway, I'm really looking into using Java for more games-related things, there are a few articles at gamedev.net all about optimizing Java, and using it in games. I was thinking it would save a lot of work if I did the scripting for an engine in Java, and using JNI to link to the engine code? I'm not all to clear on that though, and I'd need to do plennty more research/testing, but it would be cool if I could pull it off some day, it would save so much time.
Torque Owner Rick Overman
romka.demonews.com/index_eng.htm
--Rick