home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Graphics Programming (2nd Edition) / Visual Basic Graphics Programming 2nd Edition.iso / OldSrc / CH12 / SRC / LIGHT4.BAS < prev    next >
Encoding:
BASIC Source File  |  1997-01-08  |  4.3 KB  |  82 lines

  1. Attribute VB_Name = "Light"
  2. Option Explicit
  3.  
  4. ' Viewing position.
  5. Global EyeX As Single
  6. Global EyeY As Single
  7. Global EyeZ As Single
  8.  
  9. ' Location of light source.
  10. Global Const LightX = 100
  11. Global Const LightY = 500
  12. Global Const LightZ = 1000
  13. Global Const LightIa = 128
  14. Global LightIi As Single
  15.  
  16. ' Constants for the surfaces.
  17. Global LightKd As Single    ' Diffuse reflection.
  18. Global LightKa As Single    ' Ambient light.
  19. Global LightKdist As Single ' Distance.
  20. Global LightKs As Single    ' Specular reflection.
  21. Global LightN As Single     ' Specular reflection.
  22.  
  23. Type PALETTEENTRY
  24.     peRed As Byte
  25.     peGreen As Byte
  26.     peBlue As Byte
  27.     peFlags As Byte
  28. End Type
  29. Public Const PC_EXPLICIT = &H2      ' Match to system palette index.
  30. Public Const PC_NOCOLLAPSE = &H4    ' Do not match color existing entries.
  31.  
  32. ' GetDeviceCaps constants.
  33. Global Const RASTERCAPS = 38    ' Raster device capabilities.
  34. Global Const RC_PALETTE = &H100 ' Has palettes.
  35. Global Const NUMRESERVED = 106  ' # reserved entries in palette.
  36. Global Const SIZEPALETTE = 104  ' Size of system palette.
  37.  
  38. #If Win32 Then  ' 32-bit VB.
  39.     Type BITMAP ' 24 bytes
  40.         bmType As Long
  41.         bmWidth As Long
  42.         bmHeight As Long
  43.         bmWidthBytes As Long
  44.         bmPlanes As Integer
  45.         bmBitsPixel As Integer
  46.         bmBits As Long
  47.     End Type
  48.     Global Const BITMAP_SIZE = 24
  49.     Declare Function GetDeviceCaps Lib "gdi32" (ByVal hdc As Integer, ByVal nIndex As Integer) As Integer
  50.     Declare Function ResizePalette Lib "gdi32" (ByVal hPalette As Integer, ByVal nNumEntries As Integer) As Integer
  51.     Declare Function SetPaletteEntries Lib "gdi32" (ByVal hPalette As Integer, ByVal wStartIndex As Integer, ByVal wNumEntries As Integer, lpPaletteEntries As PALETTEENTRY) As Integer
  52.     Declare Function GetPaletteEntries Lib "gdi32" (ByVal hPalette As Integer, ByVal wStartIndex As Integer, ByVal wNumEntries As Integer, lpPaletteEntries As PALETTEENTRY) As Integer
  53.     Declare Function GetSystemPaletteEntries Lib "gdi32" (ByVal hdc As Integer, ByVal wStartIndex As Integer, ByVal wNumEntries As Integer, lpPaletteEntries As PALETTEENTRY) As Integer
  54.     Declare Function RealizePalette Lib "gdi32" (ByVal hdc As Long) As Long
  55.     Declare Function GetBitmapBits Lib "gdi32" (ByVal hBitmap As Integer, ByVal dwCount As Long, lpBits As Any) As Long
  56.     Declare Function SetBitmapBits Lib "gdi32" (ByVal hBitmap As Integer, ByVal dwCount As Long, lpBits As Any) As Long
  57.     Declare Function GetObject Lib "gdi32" Alias "GetObjectA" (ByVal hObject As Long, ByVal nCount As Long, lpObject As Any) As Long
  58.     Declare Function GetNearestPaletteIndex Lib "gdi32" (ByVal hPalette As Integer, ByVal crColor As Long) As Integer
  59. #Else           ' 16-bit VB.
  60.     Type BITMAP ' 14 bytes
  61.         bmType As Integer
  62.         bmWidth As Integer
  63.         bmHeight As Integer
  64.         bmWidthBytes As Integer
  65.         bmPlanes As String * 1
  66.         bmBitsPixel As String * 1
  67.         bmBits As Long
  68.     End Type
  69.     Global Const BITMAP_SIZE = 14
  70.     Declare Function GetDeviceCaps Lib "GDI" (ByVal hdc As Integer, ByVal nIndex As Integer) As Integer
  71.     Declare Function ResizePalette Lib "GDI" (ByVal hPalette As Integer, ByVal nNumEntries As Integer) As Integer
  72.     Declare Function SetPaletteEntries Lib "GDI" (ByVal hPalette As Integer, ByVal wStartIndex As Integer, ByVal wNumEntries As Integer, lpPaletteEntries As PALETTEENTRY) As Integer
  73.     Declare Function GetPaletteEntries Lib "GDI" (ByVal hPalette As Integer, ByVal wStartIndex As Integer, ByVal wNumEntries As Integer, lpPaletteEntries As PALETTEENTRY) As Integer
  74.     Declare Function GetSystemPaletteEntries Lib "GDI" (ByVal hdc As Integer, ByVal wStartIndex As Integer, ByVal wNumEntries As Integer, lpPaletteEntries As PALETTEENTRY) As Integer
  75.     Declare Function RealizePalette Lib "User" (ByVal hdc As Integer) As Integer
  76.     Declare Function GetBitmapBits Lib "GDI" (ByVal hBitmap As Integer, ByVal dwCount As Long, lpBits As Any) As Long
  77.     Declare Function SetBitmapBits Lib "GDI" (ByVal hBitmap As Integer, ByVal dwCount As Long, lpBits As Any) As Long
  78.     Declare Function GetObject Lib "GDI" (ByVal hObject As Integer, ByVal nCount As Integer, lpObject As Any) As Integer
  79.     Declare Function GetNearestPaletteIndex Lib "GDI" (ByVal hPalette As Integer, ByVal crColor As Long) As Integer
  80. #End If
  81.  
  82.