120 likes | 272 Views
Graphics Displays. Video graphics adapter. Monitor. CRT Raster Scanning. No e-beam in LCD’s. However, the logical sequence of setting discrete pixel colors is similar. Early graphics adapters. Frame buffer. CPU. System Memory. Scan Converter. video, vga. Pixel construction. Bus.
E N D
Graphics Displays Video graphics adapter Monitor CS-321Dr. Mark L. Hornick
CRT Raster Scanning No e-beam in LCD’s. However, the logical sequence of setting discrete pixel colors is similar. CS-321Dr. Mark L. Hornick
Early graphics adapters Frame buffer CPU SystemMemory Scan Converter video, vga Pixel construction Bus • CPU constructs “virtual image” in Frame Buffer in System Memory • Scan converter reads virtual image and converts to video or vga signals CS-321Dr. Mark L. Hornick
Memory Mapping Example Video RAM 00 01 02 03 04 05 06 07 08 09 0a 0b … Display CS-321Dr. Mark L. Hornick
Video Display Timing Example 1280 1024 Refresh rate = 85 Hz,n lines/s, x s/line. 1024 * 1280 =nn pixels 1280 pixels Pixel time = y s,z MHz clock CS-321Dr. Mark L. Hornick
Later graphics adapters Multiple Frame buffers CPU SystemMemory Video RAM Scan Converter vga GPU Graphics primitives Bus CS-321Dr. Mark L. Hornick
Today’s graphics adapters Multiple Frame buffers CPU SystemMemory Scan Converter svga GPUDP Xform engine, shader, spline gen, … Gr. Display cmds. Bus CS-321Dr. Mark L. Hornick
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-321Dr. Mark L. Hornick
Line Drawing Algorithms (x1, y1) (x0, y0) Which pixels should be set to represent the line? CS-321Dr. Mark L. Hornick
Line Equations (x1, y1) (x0, y0) Equations implemented in lab1 sample code. CS-321Dr. Mark L. Hornick
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)); } CS-321Dr. Mark L. Hornick