Hy,
I didn’t know if this is the right forum or the right category to post this thread, so please move this thread if necessary, or point me to a more relevant forum.
Anyway, here is my question:
I was doeing some research on computer graphics. I want to build a system that can render frames and display them. Herefor I made an 2D array which acts as a buffer. This way I can fill up all the pixels and afterwards display the right color data.
But here is my problem: Filling the buffer requires a double for-loop over 800x600 pixels. And this is takes an enormous amount of time. This is actually not that strange since we’re speaking of 480000 pixels. But that’s when I started wondering how this is done in current technologies. Because somehow a game, or application, even the OS is capable of refreshing the window at a framerate of 60Hz. On a fullHD screen this means calculating 124.416.000 pixels in one second, or about 8 nanoseconds per pixel. This seams to me as an enormouse speed, as this about the speed of a modern processor.
I’ve been thinking about it and I can’t seem to figure it out, my possible explenations:
GPU parallel programming:
As a GPU can execute many tasks at the same time, each pixel could be calculated in a thread. This would give an enourmous speed boost. But computers didn’t have always GPU’s and parallel programming is quite new. So how was this done before this?
partial refresh:
I somehow the computer could predict which pixels need refresh and which can stay the same, we could limit calculations to the new pixel values. This would help, but it’s clear that this is not the solution. A movie sequence with new pixels every frame can be displayed perfectly.
pixel calculations:
If the calculations for the color of a pixel could be simplified, it would increase the speed of the entire process significantly. But in my program, I had a method called pixel_calculation. And in my current implementation it just returns a constant value. So no calculations are done, and this seems to me the fastest you can get, and yet still it is incredibly slow.
These were the options I could come up with, but at the same time, I could easily counter them. I’ve been struggeling with this for a long time now. Can anyone explain to me how the color value of every pixel is calculated in such a high speed?
Thanks for the help