Unformatted text preview:

Vertical Retrace IntervalThe CRT DisplayImage “persistence”Color “dithering”Timing mechanismInput Status Register Onevoid vsync( void )Animation algorithmHow much drawing time?Programming techniquesUsing off-screen VRAMOur ‘animate1.cpp’ demoVertical Retrace IntervalAn introduction to VGA techniques for smooth graphics animationThe CRT DisplayScreen’s image consists of horizontal scanlines, drawn in top-down order,and redrawn about 60-70 times per second (depending on display mode).Image “persistence”•The impression of a steady screen image is purely a mental illusion of the viewer’s •The pixels are drawn on the CRT screen too rapidly for the human eye to follow•And the screen phosphor degrades slowly•So the brain blends a rapid succession of discrete images into a continuous motion•So-called ‘motion pictures’ are based on these phenomena, too (30 frames/second)Color “dithering”•The mind’s tendency to “blend” together distinct images that appear near to one another in time can be demonstrated by using two different colors -- alternately displayed in very rapid succession•This is called “dithering”•Some early graphics applications actually used this technique, to show extra colorsTiming mechanism•Today’s computers can “redraw” screens much faster than a CRT can display them•We need to “slow down” the redrawing so that the CRT circuitry will be able keep up•Design of VGA hardware allows programs to “synchronize” drawing with CRT refresh•Use the “INPUT STATUS REGISTER 1” accessible (read-only) at I/O port 0x3DAInput Status Register One 7 6 5 4 3 2 1 0Vertical Retrace status 1 = retrace is active 0 = retrace inactiveDisplay Enabled status1 = VGA is reading (and displaying) VRAM0 = Horizontal or Vertical Retrace is activeI/O port-address: 0x3DA (color display) or 0x3BA (monochrome display)void vsync( void ){// wait for current retrace to finishwhile ( ( inb( 0x3DA ) & 8 ) != 8 );// wait until the next retrace beginswhile ( ( inb( 0x3DA ) & 8 ) == 8 );}// This function only returns at the very beginning// of a new vertical blanking interval, to maximize// the time for drawing while the screen is blankedAnimation algorithm 1) Erase the previous screen2) Draw a new screen-image3) Get ready to draw another screen4) But wait for a vertical retrace to begin5) Then go back to step 1.How much drawing time?•Screen-refresh occurs 60 times/second•So time between refreshes is 1/60 second•Vertical blanking takes about 15% of time•So “safe” drawing-time for screen-update is about: (1/60)*(15/100) = 1/400 second•What if a screen-update takes longer? •Animation will exhibit “tearing” of imagesProgramming techniques•Your application may not require that the full screen be redrawn for every frame•Maybe only a small region changes, so time to “erase-and-redraw” it is reduced•You may be able to speed up the drawing operations, by “optimizing” your code •Using assembly language can often helpUsing off-screen VRAM•You can also draw to off-screen memory, which won’t affect what’s seen on-screen•When your ‘off-screen’ image is finished, you can quickly copy it to the on-screen memory area (called a ‘BitBlit’ operation)•Both CPU and SVGA provide support for very rapid copying of large memory areasOur ‘animate1.cpp’ demo•We can demonstrate smooth animation with a “proof-of-concept” prototype•It’s based on the classic “pong” game•A moving ball bounces against a wall•The user is able to move a “paddle” by using an input-device (such as a mouse, keyboard, or joystick)•We didn’t implement user-interaction


View Full Document

USF CS 686 - Vertical Retrace Interval

Documents in this Course
Load more
Download Vertical Retrace Interval
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Vertical Retrace Interval and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Vertical Retrace Interval 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?