CS-321 Dr. Mark L. Hornick 1 Graphics Displays Video graphics adapter Monitor
CS-321 Dr. Mark L. Hornick 2 CRT Raster Scanning No e-beam in LCD’s. However, the logical sequence of setting discrete pixel colors is similar.
CS-321 Dr. Mark L. Hornick 3
4 Early graphics adapters Bus CPU System Memory Scan Converter video, vga Frame buffer Pixel construction CPU constructs “virtual image” in Frame Buffer in System Memory Scan converter reads virtual image and converts to video or vga signals
CS-321 Dr. Mark L. Hornick 5 Memory Mapping Example a 0b … Video RAM Display
CS-321 Dr. Mark L. Hornick 6 Video Display Timing Example * 1280 = nn pixels Refresh rate = 85 Hz, n lines/s, x s/line pixels Pixel time = y s, z MHz clock
CS-321 Dr. Mark L. Hornick 7 Later graphics adapters Bus CPU System Memory Scan Converter vga Video RAM Multiple Frame buffers GPU Graphics primitives
CS-321 Dr. Mark L. Hornick 8 Today’s graphics adapters Bus CPU System Memory Scan Converter svga Multiple Frame buffers GPU DP Gr. Display cmds. Xform engine, shader, spline gen, …
CS-321 Dr. Mark L. Hornick 9 Pixel Addressing Integer coordinates Horizontal Left to right Vertical Top to bottom or bottom to top? Usually top to bottom (Windows) Memory bits map to pixels x y
CS-321 Dr. Mark L. Hornick 10 Line Drawing Algorithms (x 0, y 0 ) (x 1, y 1 ) Which pixels should be set to represent the line?
CS-321 Dr. Mark L. Hornick 11 Line Equations (x 0, y 0 ) (x 1, y 1 ) Equations implemented in lab1 sample code.
CS-321 Dr. Mark L. Hornick 12 Setting a Pixel // SetPixel - write (x,y) pixel value into the fb #define PIX_PER_LINE 24 #define PIX_PER_WORD 4 #define BITS_PER_PIX 8 #define FBSIZE 256// size of frame buffer #define FBADDR 0xffff// presumed hw addr of frame buffer int *vmem = FBADDR;// set a pointer to the frame buffer //int fb[FBSIZE]; // simulated frame buffer //int* vmem = fb; // ptr to simulated frame buffer void setPixel (int x, int y, int val) { int pix = y * PIX_PER_LINE + x; // linear pixel addr int addr = pix / PIX_PER_WORD; // base fb addr int ofst = pix % PIX_PER_WORD; // offset in fb word vmem[addr] = vmem[addr] | (val << (ofst * BITS_PER_PIX)); }