The Problem I'm trying to make a more efficient rendering system from scratch and I've come to the conclusion that using for loops are very inefficient for larger windows.
Question So my question is, can I use BitSet to manipulate the pixels much quicker than using a for loop to set each pixel individually?
Things You May Need The rendering system is very small, as it's more a test than anything. The only thing it currently does is draw rectangles to the screen so I can test the FPS I get.
public void drawRect(int offX, int offY, int width, int height, int color)
{
for (int y = 0; y < height; y++)
for (int x = 0; x < width; x++)
pixels[x + offX + this.width * (y + offY)] = color;
}
The pixel array is just the data from a BufferedImage using pixels = ((DataBufferInt) engine.getWindow().getImage().getRaster().getDataBuffer()).getData();
I'm not sure how I would go about using the BitSet class with the pixels, but I'm hoping it's faster than the drawRect method. The FPS counter tells me that drawing a single rectangle to the screen of 1980x1080 is roughly 100-130 fps with no consistent clearing to it yet.
Any help is appreciated, please tell me if the way I have in mind is just plain stupid