Starg

S3d Example

Aug 30th, 2013
218
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
AutoIt 1.73 KB | None | 0 0
  1.  
  2. #include <GUIConstantsEx.au3>
  3. #include <S3d.au3>
  4.  
  5. Main()
  6.  
  7. Func Main()
  8.     ; Create a window and initialize GDI+
  9.     Local $hGUI = GUICreate("0", 650, 550)
  10.     GUISetState()
  11.     _GDIPlus_Startup()
  12.    
  13.     Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGUI)
  14.     Local $hBitmap = _GDIPlus_BitmapCreateFromGraphics(650, 550, $hGraphics)
  15.     Local $hGraphic = _GDIPlus_ImageGetGraphicsContext($hBitmap)
  16.    
  17.     ; Select a Graphic object
  18.     ; width = 650, height = 550
  19.     _S3d_SelectGraphic($hGraphic, 650, 550)
  20.    
  21.     Local $hPenB = _GDIPlus_PenCreate(0xAA0044FF, 2)
  22.     Local $hPenR = _GDIPlus_PenCreate(0xAAFF6633, 3)
  23.    
  24.     Local $i = 0, $j, $iCol = 0
  25.     Local $aPos[3] = [0, 0, 0], $aV[3] = [3, 4, 6], $iSize = 40
  26.     ; Loop until user exits
  27.     Do
  28.         ; Clear the Graphics object
  29.         _S3d_Clear(0xFFFFFFFF)
  30.        
  31.         ; Set camera
  32.         _S3d_SetCamera(350 * Cos($i), 350 * Sin($i), 150, 0, 0, 0)
  33.        
  34.         ; Select a pen obiect
  35.         _S3d_SelectPen($hPenB)
  36.         ; Draw cube
  37.         _S3d_Box(-100, -100, -100, 100, 100, 100)
  38.        
  39.         ; Select a pen obiect
  40.         _S3d_SelectPen($hPenR)
  41.         ; Draw cube
  42.         _S3d_Box($aPos[0], $aPos[1], $aPos[2], $aPos[0] + $iSize, $aPos[1] + $iSize, $aPos[2] + $iSize)
  43.        
  44.         For $j = 0 To 2
  45.             If $aPos[$j] <= -100 Or 100 <= $aPos[$j] + $iSize Then
  46.                 $aV[$j] *= -1
  47.                 $iCol += 1
  48.                 WinSetTitle($hGUI, "", $iCol)
  49.             EndIf
  50.             $aPos[$j] += $aV[$j]
  51.         Next
  52.        
  53.         ; Copy to the window
  54.         _GDIPlus_GraphicsDrawImage($hGraphics, $hBitmap, 0, 0)
  55.        
  56.         $i += 0.02
  57.         Sleep(40)
  58.     Until GUIGetMsg() = $GUI_EVENT_CLOSE
  59.    
  60.     ; Clean up resources
  61.    
  62.     _GDIPlus_PenDispose($hPenB)
  63.     _GDIPlus_PenDispose($hPenR)
  64.    
  65.     _GDIPlus_GraphicsDispose($hGraphic)
  66.     _GDIPlus_BitmapDispose($hBitmap)
  67.     _GDIPlus_GraphicsDispose($hGraphics)
  68.     _GDIPlus_Shutdown()
  69.    
  70.     GUIDelete($hGUI)
  71. EndFunc ;==>Main
Advertisement
Add Comment
Please, Sign In to add comment