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

  1. Attribute VB_Name = "Ray"
  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 LightSource As Point3D
  11. Global LightIar As Single
  12. Global LightIag As Single
  13. Global LightIab As Single
  14. Global LightIir As Single
  15. Global LightIig As Single
  16. Global LightIib As Single
  17. Global BackR As Long
  18. Global BackG As Long
  19. Global BackB As Long
  20.  
  21. ' Constants for the surfaces.
  22. Global LightKdist As Single ' Distance.
  23.  
  24. Type PALETTEENTRY
  25.     peRed As Byte
  26.     peGreen As Byte
  27.     peBlue As Byte
  28.     peFlags As Byte
  29. End Type
  30. Public Const PC_EXPLICIT = &H2      ' Match to system palette index.
  31. Public Const PC_NOCOLLAPSE = &H4    ' Do not match color existing entries.
  32.  
  33. ' GetDeviceCaps constants.
  34. Global Const RASTERCAPS = 38    ' Raster device capabilities.
  35. Global Const RC_PALETTE = &H100 ' Has palettes.
  36. Global Const NUMRESERVED = 106  ' # reserved entries in palette.
  37. Global Const SIZEPALETTE = 104  ' Size of system palette.
  38.  
  39. #If Win32 Then  ' 32-bit VB.
  40.     Type BITMAP ' 24 bytes
  41.         bmType As Long
  42.         bmWidth As Long
  43.         bmHeight As Long
  44.         bmWidthBytes As Long
  45.         bmPlanes As Integer
  46.         bmBitsPixel As Integer
  47.         bmBits As Long
  48.     End Type
  49.     Global Const BITMAP_SIZE = 24
  50.     Declare Function GetDeviceCaps Lib "gdi32" (ByVal hdc As Integer, ByVal nIndex As Integer) As Integer
  51.     Declare Function ResizePalette Lib "gdi32" (ByVal hPalette As Integer, ByVal nNumEntries As Integer) As Integer
  52.     Declare Function SetPaletteEntries Lib "gdi32" (ByVal hPalette As Integer, ByVal wStartIndex As Integer, ByVal wNumEntries As Integer, lpPaletteEntries As PALETTEENTRY) As Integer
  53.     Declare Function GetPaletteEntries Lib "gdi32" (ByVal hPalette As Integer, ByVal wStartIndex As Integer, ByVal wNumEntries As Integer, lpPaletteEntries As PALETTEENTRY) As Integer
  54.     Declare Function GetSystemPaletteEntries Lib "gdi32" (ByVal hdc As Integer, ByVal wStartIndex As Integer, ByVal wNumEntries As Integer, lpPaletteEntries As PALETTEENTRY) As Integer
  55.     Declare Function RealizePalette Lib "gdi32" (ByVal hdc As Long) As Long
  56.     Declare Function GetBitmapBits Lib "gdi32" (ByVal hBitmap As Integer, ByVal dwCount As Long, lpBits As Any) As Long
  57.     Declare Function SetBitmapBits Lib "gdi32" (ByVal hBitmap As Integer, ByVal dwCount As Long, lpBits As Any) As Long
  58.     Declare Function GetObject Lib "gdi32" Alias "GetObjectA" (ByVal hObject As Long, ByVal nCount As Long, lpObject As Any) As Long
  59.     Declare Function GetNearestPaletteIndex Lib "gdi32" (ByVal hPalette As Integer, ByVal crColor As Long) As Integer
  60. #Else           ' 16-bit VB.
  61.     Type BITMAP ' 14 bytes
  62.         bmType As Integer
  63.         bmWidth As Integer
  64.         bmHeight As Integer
  65.         bmWidthBytes As Integer
  66.         bmPlanes As String * 1
  67.         bmBitsPixel As String * 1
  68.         bmBits As Long
  69.     End Type
  70.     Global Const BITMAP_SIZE = 14
  71.     Declare Function GetDeviceCaps Lib "GDI" (ByVal hdc As Integer, ByVal nIndex As Integer) As Integer
  72.     Declare Function ResizePalette Lib "GDI" (ByVal hPalette As Integer, ByVal nNumEntries As Integer) As Integer
  73.     Declare Function SetPaletteEntries Lib "GDI" (ByVal hPalette As Integer, ByVal wStartIndex As Integer, ByVal wNumEntries As Integer, lpPaletteEntries As PALETTEENTRY) As Integer
  74.     Declare Function GetPaletteEntries Lib "GDI" (ByVal hPalette As Integer, ByVal wStartIndex As Integer, ByVal wNumEntries As Integer, lpPaletteEntries As PALETTEENTRY) As Integer
  75.     Declare Function GetSystemPaletteEntries Lib "GDI" (ByVal hdc As Integer, ByVal wStartIndex As Integer, ByVal wNumEntries As Integer, lpPaletteEntries As PALETTEENTRY) As Integer
  76.     Declare Function RealizePalette Lib "User" (ByVal hdc As Integer) As Integer
  77.     Declare Function GetBitmapBits Lib "GDI" (ByVal hBitmap As Integer, ByVal dwCount As Long, lpBits As Any) As Long
  78.     Declare Function SetBitmapBits Lib "GDI" (ByVal hBitmap As Integer, ByVal dwCount As Long, lpBits As Any) As Long
  79.     Declare Function GetObject Lib "GDI" (ByVal hObject As Integer, ByVal nCount As Integer, lpObject As Any) As Integer
  80.     Declare Function GetNearestPaletteIndex Lib "GDI" (ByVal hPalette As Integer, ByVal crColor As Long) As Integer
  81. #End If
  82.  
  83.