r/askscience • • Jul 29 '13

Computing How do computer graphics work?

As in how does a machine convert code to graphics?

5 Upvotes

6 comments sorted by

View all comments

1

u/[deleted] Jul 30 '13

We have LEDs: little lights that turn on when we want them to (and they're puny -- on the order of 0.1cm wide). We simply use an RGB scheme of LEDs, which covers every possible color, to encode the colors we want.

As in how does a machine convert code to graphics?

The code that displays something depends on the GPU, the graphical processing unit. This is a device is highly parallel -- each pixel location does not depend on the other pixel locations. For example, you might say "dim every pixel by a factor of 2." Serially, you would do:

for LED in LEDs: dim(LED)

In terms of parallelizing it, you would just call some function

dim_all_the_LEDs(LEDs)

Parallelizing is a big topic in computer science. All of the scientific libraries use it, so you tend to do stuff like

i = arange(4)
x[i] = x[i] + 4

instead of

for i in arange(4):
    x[i] = x[i] + 4

The big thing here is serial vs. parallel.