I have a int[] cols, and want to draw that in a grid across the screen, I currently have each color fill a 4x4 area, but I want to have it 1 pixel instead of 4. Doing that seems to cause tremendous lag. I am looking for a better way to do this.

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

//pack a small opaque white area into your sprite sheet, //e.g. 1x1 white pixel with nearest filtering //or a larger area with bilinear filtering

//get the sub-image of the white pixelImagewhitePixel = spriteSheet.getSubImage(...);

...

//now in your render loop, draw many rectangles like so:spriteSheet.startUse();

//... draw your other sprites from this sheet using drawEmbedded ... //

Thanks very much, your method is a lot faster than what I was doing, I am going to look into shaders as they would probably be the most efficient. I still get a bit of lag when alot of the screen has been changed.

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