  '-------------
  'TEXTURED QUAD
  '=============
  '
  sub ProcTex1(string*texture, sys size)
  '
  sys x,y,xe,ye,w,p
  string texture
  texture=nuls 4*size*size
  xe=size-1 : ye=xe
  w=*texture
  for y=0 to ye
  for x=0 to xe
    p=(x+y*size)*4+w
    mov ecx,p
    mov eax, 0xff666644
    (
    mov edx,y
    and edx,0xf
    cmp edx,0
    jnz exit
    mov eax,0xffffffff
    )
    (
    mov edx,x
    and edx,0x6
    jnz exit
    mov eax,0xbbbbbbbb
    )
    mov [ecx],eax
  next
  next
  '
  end sub


  sub ProcTex2(string*texture, sys size)
  ======================================
  '
  sys x,y,xe,ye,w,p
  texture=nuls 4*size*size
  xe=size-1 : ye=xe
  w=*texture
  for y=0 to ye
  for x=0 to xe
    p=(x+y*size)*4+w
    rndi()
    or eax,0xff000000
    mov ecx,p
    mov [ecx],eax
  next
  next
  end sub

  sub ProcTex3(string*texture, sys size)
  =====================================
  '
  'point star
  '
  sys xe,ye,w,p
  texture=nuls 4*size*size
  xe=size-1 : ye=xe
  w=*texture
  p=w+size*4+4 : *p=0xccffffff
  end sub


  function  CompileLists(optional sys mode) as sys
  ================================================
  '
  static sys sys i,j,list,count=20
  '
  if mode=-1gg
    inc list 'adjust base
    glDeleteLists list,count
    return 0
  end if

  single ma[16] 'for specifying material: ambient4 , diffuse 4, specular 4, shininess 1
  
  list=glGenLists count
  dec list 'adjust base


  glNewList List 1, GL_COMPILE
  Torus 1.5, 0.3
  glEndlist


  glNewList List 2, GL_COMPILE
  '
  glcolor3f 1,1,0
  Cuboid  1, .5 , 1
  Cylinder 1, 1, 1.0, 10
  glpushmatrix
  gltranslatef 0,1.0,0
  hemisphere 1, 1, 10
  glpopmatrix
  glEndList


  glNewList List 3, GL_COMPILE
  '
  Cuboid  1, .5 , 1
  glEndList


  glNewList List 4, GL_COMPILE
  reqtex=1
  DrawNoisyGauss
  glEndList


  glNewList List 5, GL_COMPILE
  glpushmatrix
  gltranslatef 0,1,0
  Toroid   .2, 0.1, 1.5, .2, 4, -2
  glpopmatrix
  glEndList


  glNewList List 6, GL_COMPILE
  glPushMatrix
  PolySides 1, 6
  glTranslatef 0,1,0
  PolyCone  1, 6
  glPopMatrix
  glEndList


  glNewList List 7, GL_COMPILE
  glPushMatrix
  glTranslatef 0,0,0
  glscalef 1.0,1.0,1.0
  Spirodome2 .25, 12
  glPopMatrix
  glEndList


  glNewList List 8, GL_COMPILE
  glcolor3f 1,1,1
  glpushmatrix
  gltranslatef 0,-.3,0
  Cuboid  1, .7 , 1
  glrotatef 45,0,1,0
  glscalef 0.85,1,0.85
  Cuboid  1, .7 , 1
  glpopmatrix
  Cylinder 1, 1, 1.0, 10
  glpushmatrix
  gltranslatef 0,1.0,0
  hemisphere 1, 1.5, 10
  glpopmatrix
  glEndList


  glNewList List 9, GL_COMPILE
  glcolor3f 1,1,1
  glpushmatrix
  gltranslatef 0,-.3,0
  Cuboid  5, .5 , .5
  glpopmatrix
  glEndList


  glNewList List 10, GL_COMPILE
  '
  '--------
  'BUILDING
  '========
  '
  glpushmatrix
  glbegin GL_QUADS
  '
  '
  'FRONT
  '
  glNormal3f  0,  0,  1
  glVertex3f -1,  0,  1
  glVertex3f -1,  2,  1
  glVertex3f  1,  2,  1
  glVertex3f  1,  0,  1
  '
  'RIGHT
  '
  glNormal3f  1,  0,  0
  glVertex3f  1,  0,  1
  glVertex3f  1,  2,  1
  glVertex3f  1,  2, -1
  glVertex3f  1,  0, -1
  '
  'BACK
  '
  glNormal3f  0,  0, -1
  glVertex3f  1,  0, -1
  glVertex3f  1,  2, -1
  glVertex3f -1,  2, -1
  glVertex3f -1,  0, -1
  '
  'LEFT
  '
  glNormal3f -1,  0,  0
  glVertex3f -1,  0, -1
  glVertex3f -1,  2, -1
  glVertex3f -1,  2,  1
  glVertex3f -1,  0,  1
  '
  'TOP
  '
  glNormal3f  0,  1,  0
  glVertex3f -1,  2,  1
  glVertex3f -1,  2, -1
  glVertex3f  1,  2, -1
  glVertex3f  1,  2,  1
  glend
  glpopmatrix
  glEndList



  glNewList List 11, GL_COMPILE
  '
  '-----------
  'SIMPLE QUAD
  '===========
  '
  '
  glbegin GL_QUADS
  '
  glnormal3f 0,1,0
  glTexCoord2f 0,0 : glvertex3f -1., 0.,  1
  glTexCoord2f 0,1 : glvertex3f -1., 0., -1
  glTexCoord2f 1,1 : glvertex3f  1., 0., -1
  glTexCoord2f 1,0 : glvertex3f  1., 0.,  1
  '
  glend
  '
  glEndList


  glNewList List 12, GL_COMPILE
  '
  '------------
  'TOWER BLOCKS
  '============
  '
  'base
  '----
  '
  glpushmatrix
  gltranslatef .0, -.0001, .0
  glscalef 10,1,10
  'ma<=.4, .0, .0, 1.0,   .15, .0, .0, 1.0,  .0,  .0, .1, 1.0,  0
  'SetMaterial ma
  glCallList List 11 'quad
  glpopmatrix

  '
  '
  'ma<=.3, .0, .1, 1.0,   .15, .15, .2, 1.0,  .0,  .0, .1, 1.0,  0
  'SetMaterial ma
  '
  'roadways ahead
  '--------------
  '
  for i=1 to 7
  glpushmatrix
  gltranslatef (.8*i-1.2,0,0)  '-3.5
  glscalef .1, .005, 4.0
  glCallList List 10 'building
  glpopmatrix
  next
  '
  'roadways across
  '---------------
  '
  for i=1 to 9
  glpushmatrix
  gltranslatef 2, 0, i*.8-3.3 '-6.8
  glscalef 3, .005, .1
  glCallList List 10 'building
  glpopmatrix
  next
  '
  '
  'block of buildings
  '------------------
  '
  StandardMaterial
  '
  glTranslatef 0, 0, 3.5
  '
  for j=1 to 8
    for i=1 to 6
      '
      picklabel j*6+i
      '
      if j=2 or j=4 or j=6
        if i=2 or i=4
          'ma<=.35, .35, .0, 1.0,   .15, .15, .0, 1.0,  .0,  .0, .1, 1.0,  0
          'SetMaterial ma
          glpushmatrix
          glscalef .3, 1, .3
          glCallList List 11 'green quad
          glpopmatrix
          StandardMaterial
          '
          glPushMatrix
          glscalef .2, 1.2+rnd()*.3, .3
          PolySides 1, 8
          glTranslatef 0,1,0
          PolyCone  0, 8
          glscalef .85, .125, .9
          PolyCone  1, 8
          glPopMatrix
          '
          jmp fwd nex
        end if
      end if
      '
      'otherwise simpler square building
      '
      glpushmatrix
      glscalef .2+rnd()*.05, .5+rnd()*.2, .15+rnd()*.02
      glCallList List 10 'building
      glpopmatrix
      '
      glpushmatrix
      glscalef .15+rnd()*.05, .5+rnd()*.2, .12+rnd()*.01
      glCallList List 10 'building
      glpopmatrix
      '
      nex:
      gltranslatef .8,0,0
    next
    gltranslatef -4.8,0,-.8
  next
  '
  glEndList

  glNewList List 13, GL_COMPILE
  '

  glClearColor 0,0,0,1
  glClear GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT
  '
  string tex : sys size
  size=128
  ProcTex1 tex, size
'  MakeTexture *tex, size, size, texn[3]
  '
  size=32
  ProcTex2 tex, size
'  MakeTexture *tex, size, size, texn[4]
  '
  size=4
'  ProcTex3 tex, size
'  MakeTexture *tex, size, size, texn[5]
  '
  glEnable GL_BLEND
  glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA
  glEnable GL_TEXTURE_2D
  glBindTexture GL_TEXTURE_2D,texn[5]
  glpushmatrix
  glscalef 2,2,2
  glbegin GL_QUADS
  '
  glnormal3f 0,0,1
  glTexCoord2f 0,0 : glvertex3f -1., -1., 0
  glTexCoord2f 0,1 : glvertex3f -1.,  1., 0
  glTexCoord2f 1,1 : glvertex3f  1.,  1., 0
  glTexCoord2f 1,0 : glvertex3f  1., -1., 0
  '
  glend
  glpopmatrix
  glDisable GL_TEXTURE_2D
  glDisable GL_BLEND
  '
  glEndList

  glNewList List 14, GL_COMPILE
  '
  RenderIcosGeo 2
  glEndList


  return list

end function