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

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