!******************************************************************************
!*       This is a part of the Compaq Visual Fortran Source Code Samples.
!******************************************************************************
subroutine ReshapeFunction(width, height)
!DEC$ IF DEFINED(_X86_)
!DEC$ ATTRIBUTES STDCALL, ALIAS : '_ReshapeFunction@8' :: ReshapeFunction
!DEC$ ELSE
!DEC$ ATTRIBUTES STDCALL, ALIAS : 'ReshapeFunction' :: ReshapeFunction
!DEC$ ENDIF
use dfopngl
integer(4)  width, height
    call fglViewport(0, 0, width, height)
end

subroutine Key_c()
!DEC$ IF DEFINED(_X86_)
!DEC$ ATTRIBUTES STDCALL, ALIAS : '_Key_c@0' :: Key_c
!DEC$ ELSE
!DEC$ ATTRIBUTES STDCALL, ALIAS : 'Key_c' :: Key_c
!DEC$ ENDIF
use twaveinc
use dfopngl
real(4) map(4)
data map /0, 0, 20, 0/

    contouring = contouring + 1
    if (contouring == 1) then

        call fglTexImage2d(GL_TEXTURE_2D, 0, 3, 4, 4, 0, GL_LUMINANCE, &
             GL_UNSIGNED_BYTE, LOC(contourTexture1))
        call fglTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR)
        call fglTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR)
        call fglTexGenfv(GL_S, GL_OBJECT_PLANE, LOC(map))
        call fglTexGenfv(GL_T, GL_OBJECT_PLANE, LOC(map))
        call fglEnable(GL_TEXTURE_2D)
        call fglEnable(GL_TEXTURE_GEN_S)
        call fglEnable(GL_TEXTURE_GEN_T)

    else if (contouring == 2) then

        call fglTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR)
        call fglTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR)
        call fglPushMatrix()
        call fglMatrixMode(GL_MODELVIEW)
        call fglLoadIdentity()
        call fglTexGenfv(GL_S, GL_EYE_PLANE, LOC(map))
        call fglTexGenfv(GL_T, GL_EYE_PLANE, LOC(map))
        call fglPopMatrix()
    else
        contouring = 0
        call fglDisable(GL_TEXTURE_GEN_S)
        call fglDisable(GL_TEXTURE_GEN_T)
        call fglDisable(GL_TEXTURE_2D)
    end if
end


subroutine Key_s()
!DEC$ IF DEFINED(_X86_)
!DEC$ ATTRIBUTES STDCALL, ALIAS : '_Key_s@0' :: Key_s
!DEC$ ELSE
!DEC$ ATTRIBUTES STDCALL, ALIAS : 'Key_s' :: Key_s
!DEC$ ENDIF
use twaveinc
use dfopngl
    smooth = NOT(smooth)
    if (smooth) then
        call fglShadeModel(GL_SMOOTH)
    else
        call fglShadeModel(GL_FLAT)
    end if
end

