home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Graphics Programming (2nd Edition) / Visual Basic Graphics Programming 2nd Edition.iso / OldSrc / CH12 / SRC / LIGHT1.BAS < prev    next >
Encoding:
BASIC Source File  |  1997-01-08  |  4.0 KB  |  72 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.  
  10. ' K for the surfaces.
  11. Global LightKd As Single
  12.  
  13. Type PALETTEENTRY
  14.     peRed As Byte
  15.     peGreen As Byte
  16.     peBlue As Byte
  17.     peFlags As Byte
  18. End Type
  19. Public Const PC_EXPLICIT = &H2      ' Match to system palette index.
  20. Public Const PC_NOCOLLAPSE = &H4    ' Do not match color existing entries.
  21.  
  22. ' GetDeviceCaps constants.
  23. Global Const RASTERCAPS = 38    ' Raster device capabilities.
  24. Global Const RC_PALETTE = &H100 ' Has palettes.
  25. Global Const NUMRESERVED = 106  ' # reserved entries in palette.
  26. Global Const SIZEPALETTE = 104  ' Size of system palette.
  27.  
  28. #If Win32 Then  ' 32-bit VB.
  29.     Type BITMAP ' 24 bytes
  30.         bmType As Long
  31.         bmWidth As Long
  32.         bmHeight As Long
  33.         bmWidthBytes As Long
  34.         bmPlanes As Integer
  35.         bmBitsPixel As Integer
  36.         bmBits As Long
  37.     End Type
  38.     Global Const BITMAP_SIZE = 24
  39.     Declare Function GetDeviceCaps Lib "gdi32" (ByVal hdc As Integer, ByVal nIndex As Integer) As Integer
  40.     Declare Function ResizePalette Lib "gdi32" (ByVal hPalette As Integer, ByVal nNumEntries As Integer) As Integer
  41.     Declare Function SetPaletteEntries Lib "gdi32" (ByVal hPalette As Integer, ByVal wStartIndex As Integer, ByVal wNumEntries As Integer, lpPaletteEntries As PALETTEENTRY) As Integer
  42.     Declare Function GetPaletteEntries Lib "gdi32" (ByVal hPalette As Integer, ByVal wStartIndex As Integer, ByVal wNumEntries As Integer, lpPaletteEntries As PALETTEENTRY) As Integer
  43.     Declare Function GetSystemPaletteEntries Lib "gdi32" (ByVal hdc As Integer, ByVal wStartIndex As Integer, ByVal wNumEntries As Integer, lpPaletteEntries As PALETTEENTRY) As Integer
  44.     Declare Function RealizePalette Lib "gdi32" (ByVal hdc As Long) As Long
  45.     Declare Function GetBitmapBits Lib "gdi32" (ByVal hBitmap As Integer, ByVal dwCount As Long, lpBits As Any) As Long
  46.     Declare Function SetBitmapBits Lib "gdi32" (ByVal hBitmap As Integer, ByVal dwCount As Long, lpBits As Any) As Long
  47.     Declare Function GetObject Lib "gdi32" Alias "GetObjectA" (ByVal hObject As Long, ByVal nCount As Long, lpObject As Any) As Long
  48.     Declare Function GetNearestPaletteIndex Lib "gdi32" (ByVal hPalette As Integer, ByVal crColor As Long) As Integer
  49. #Else           ' 16-bit VB.
  50.     Type BITMAP ' 14 bytes
  51.         bmType As Integer
  52.         bmWidth As Integer
  53.         bmHeight As Integer
  54.         bmWidthBytes As Integer
  55.         bmPlanes As String * 1
  56.         bmBitsPixel As String * 1
  57.         bmBits As Long
  58.     End Type
  59.     Global Const BITMAP_SIZE = 14
  60.     Declare Function GetDeviceCaps Lib "GDI" (ByVal hdc As Integer, ByVal nIndex As Integer) As Integer
  61.     Declare Function ResizePalette Lib "GDI" (ByVal hPalette As Integer, ByVal nNumEntries As Integer) As Integer
  62.     Declare Function SetPaletteEntries Lib "GDI" (ByVal hPalette As Integer, ByVal wStartIndex As Integer, ByVal wNumEntries As Integer, lpPaletteEntries As PALETTEENTRY) As Integer
  63.     Declare Function GetPaletteEntries Lib "GDI" (ByVal hPalette As Integer, ByVal wStartIndex As Integer, ByVal wNumEntries As Integer, lpPaletteEntries As PALETTEENTRY) As Integer
  64.     Declare Function GetSystemPaletteEntries Lib "GDI" (ByVal hdc As Integer, ByVal wStartIndex As Integer, ByVal wNumEntries As Integer, lpPaletteEntries As PALETTEENTRY) As Integer
  65.     Declare Function RealizePalette Lib "User" (ByVal hdc As Integer) As Integer
  66.     Declare Function GetBitmapBits Lib "GDI" (ByVal hBitmap As Integer, ByVal dwCount As Long, lpBits As Any) As Long
  67.     Declare Function SetBitmapBits Lib "GDI" (ByVal hBitmap As Integer, ByVal dwCount As Long, lpBits As Any) As Long
  68.     Declare Function GetObject Lib "GDI" (ByVal hObject As Integer, ByVal nCount As Integer, lpObject As Any) As Integer
  69.     Declare Function GetNearestPaletteIndex Lib "GDI" (ByVal hPalette As Integer, ByVal crColor As Long) As Integer
  70. #End If
  71.  
  72.