Quite a complicated one, I’m trying to render graphics with the CPU pixel by pixel. I would love to use the GPU for such things but lack the know how. Any recommendations?
BufferedImage image = "theGraphics;"
int pixels = new int[width*height];
for(int x = 0; x < width; x++){
for(int y = 0; y < height; y++){
screenPixels[x + y * width] = pixels[x + y * width];
}
}
I’m trying to find another way as I’m discovering that this isn’t very efficient the more I use it :(. I’ve tried many methods of updating the screen, refreshing only sections of the screen that change, creating a pixel array that gets updated with smaller previously generated pixels. It always takes chunks from the fps every time i add something like a menu with buttons. What could i be doing wrong :emo: ? I’ve uploaded it to github if anyone wants a gander? Stealth is just a genre not the name. Thank you!
Shows what I’m trying.
GameWindow.java
ButtonInterface.java
If I have something like a button, I have to keep it updated for the highlight when hovering over it. I’ve tried updating when necessary but it just gets so messy and harder to work with. Say if I had an animated ball bouncing around the screen. I would have to update the balls pixels and the background pixels behind the ball. Which adds pixels per cycle. The problem is when animating. You have to remove the previous pixels before adding the next.