Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Borland C++ 2.x ( with Turbo C ) - <b>setviewport() set the current graphics viewport</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 setviewport()           Set the Current Graphics Viewport

 #include   <graphics.h>

 void far   setviewport(left,top,right,bottom,clflag);
 int        left;
 int        top;
 int        right;
 int        bottom;
 int        clflag;

    setviewport() defines a rectangular viewport, a "virtual screen", on
    the screen. The viewport's position is defined in terms of absolute
    screen coordinates, ('left','top'), ('right','bottom'). All
    subsequent graphics output is written to this viewport. If 'clflag'
    is set to a non-zero value, all drawings will be clipped or truncated
    at its boundaries.  initgraph() and setgraphmode() can be used to
    reset the viewport to the entire screen.

    Returns:    Nothing.

   -------------------------------- Example ---------------------------------

    The following statements establish a viewport and draw a figure with
    a specified fill style and color. The viewport is reset to the entire
    screen and another figure is drawn.

           #include <graphics.h>
           #include <conio.h>

           main()
           {
               int gdriver = DETECT;
               int gmode;
               int fig1[] =
                   {25,100, 50,50, 150,50, 175,100,  25,100};
               int fig2[] =
                   { 350,150, 300,100, 400,100, 450,150, 350,150};

               initgraph(&gdriver,&gmode,"");
               rectangle(10,10,200,200);
               setviewport(10,10,200,200,1);
               setfillstyle(SLASH_FILL,YELLOW);
               fillpoly(sizeof(fig1)/(2*sizeof(int)),fig1);
               getch();
               initgraph(&gdriver,&gmode,"");
               fillpoly(sizeof(fig1)/(2*sizeof(int)),fig2);
               getch();
               closegraph();
           }


See Also: clearviewport() getviewsettings()

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson