ID 757211
Date 7/23/2021
Public

## Activating a Graphics Mode

If you call a graphics routine without setting a graphics mode with SETWINDOWCONFIG, QuickWin automatically sets the graphics mode with default values.

The Writing a Graphics Program Overview program shown in the previous topic selects and sets the graphics mode in the subroutine graphicsmode, which selects the highest possible resolution for the current video driver:

  SUBROUTINE graphicsmode( )
USE IFQWIN
LOGICAL             modestatus
INTEGER(2)          maxx, maxy
TYPE (windowconfig) myscreen
COMMON              maxx, maxy
!  Set highest resolution graphics mode.
myscreen.numxpixels=-1
myscreen.numypixels=-1
myscreen.numtextcols=-1
myscreen.numtextrows=-1
myscreen.numcolors=-1
myscreen.fontsize=-1
myscreen.title = " "C ! blank
modestatus=SETWINDOWCONFIG(myscreen)
!  Determine the maximum dimensions.
modestatus=GETWINDOWCONFIG(myscreen)
maxx=myscreen.numxpixels - 1
maxy=myscreen.numypixels - 1
END SUBROUTINE

Pixel coordinates start at zero, so, for example, a screen with a resolution of 640 horizontal pixels has a maximum x-coordinate of 639. Thus, maxx (the highest available x-pixel coordinate) must be 1 less than the total number of pixels. The same applies to maxy.

To remain independent of the video mode set by graphicsmode, two short functions convert an arbitrary screen size of 1000x1000 pixels to whatever video mode is in effect. From now on, the program assumes it has 1000 pixels in each direction. To draw the points on the screen, newx and newy map each point to their physical (pixel) coordinates:

  ! NEWX - This function finds new x-coordinates.
INTEGER(2) FUNCTION newx( xcoord )
INTEGER(2) xcoord, maxx, maxy
REAL(4) tempx
COMMON maxx, maxy
tempx = maxx / 1000.0
tempx = xcoord * tempx + 0.5
newx = tempx
END FUNCTION
! NEWY - This function finds new y-coordinates.
!
INTEGER(2) FUNCTION newy( ycoord )
INTEGER(2) ycoord, maxx, maxy
REAL(4) tempy
COMMON maxx, maxy
tempy = maxy / 1000.0
tempy = ycoord * tempy + 0.5
newy = tempy
END FUNCTION

You can set up a similar independent coordinate system with window coordinates, described in Understanding Coordinate Systems Overview.