jonjava - he says he is using Slick2D, not Java2D.
In OpenGL you generally don't modify texture data per-pixel in real time; instead, you modify pixels as they are rasterized by GL. The former requires copying data between CPU and GPU (very slow), whereas the latter is done all on GPU (very fast).
Instead of modifying textures per-pixel, you might get faster speeds by drawing rectangles. The problem is that Slick doesn't batch calls to g.fillRect, so using it many times per frame can create a bottleneck. Instead, you might have better luck with using an Image to create an opaque coloured rectangle. So it might look like this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
| Image whitePixel = spriteSheet.getSubImage(...);
...
spriteSheet.startUse();
rectColor.bind();
for ( each filled rectangle ) { whitePixel.drawEmbedded(x, y, width, height); }
spriteSheet.endUse();
|
I also described the technique here (for a different library):
https://github.com/mattdesl/lwjgl-basics/wiki/Batching-Rectangles-and-LinesFor more info on drawEmbedded:
http://slick.cokeandcode.com/wiki/doku.php?id=performance_memory_tipsIf you want to try modifying a texture per-pixel (and deal with the performance problems of copying data from CPU to GPU), check out this page:
http://slick.cokeandcode.com/wiki/doku.php?id=per-pixel_manipulation:pixeldata_utilityIf you are more interested in the GPU approach, you might have some luck from shaders:
http://slick.cokeandcode.com/wiki/doku.php?id=shadershttps://github.com/mattdesl/lwjgl-basics/wiki/Shaders