Ooops
November 25, 2020, 04:46:02 AM

Author Topic: [bb] B3D and B+ by Xenon [ 1+ years ago ]  (Read 597 times)

Offline BlitzBot

  • Jr. Member
  • **
  • Posts: 1
[bb] B3D and B+ by Xenon [ 1+ years ago ]
« on: June 29, 2017, 12:28:42 AM »
Title : B3D and B+
Author : Xenon
Posted : 1+ years ago

Description : With this Source, you can code a Program, which uses B3D and B+!

Just try it out!


Code :
Code: BlitzBasic
  1. #------ Userlib *.decls
  2.  
  3. .lib "User32.dll"
  4. FindWindow%(class$, fenster$):"FindWindowA"
  5. SetWindowRgn%(hwnd,hrgn,redraw)
  6. GetActiveWindow%()
  7. SetParent%(hWndChild,hWndNewParent)
  8. SetWindowPos%(hWnd, hWndINsertAfter,x,y,cx,cy,flags)
  9.  
  10. .lib "Gdi32.dll"
  11. CreateRectRgn%(left,top,right,bottom)
  12.  
  13. #------ Blitz Plus Source
  14.  
  15. ;
  16. ; Constants
  17. ;
  18. Const windowwidth = 116
  19. Const windowheight = 200
  20. Const windowtitle$ = "Modeller"
  21.  
  22. Const dummy_m = 1
  23. Const beenden_m = 19
  24.  
  25. ;
  26. ; Globals
  27. ;
  28. Global window = CreateWindow(windowtitle$,(ClientWidth(Desktop())-windowwidth)/2,(ClientHeight(Desktop())-windowheight)/2,windowwidth,windowheight,Desktop(),1)
  29. Global menu = WindowMenu(window)
  30. Global datei_m = CreateMenu("&Datei",dummy_m,menu)
  31. Global beenden__m = CreateMenu("&Beenden        Alt+F4",beenden_m,datei_m)
  32. Global button = CreateButton("Farbe",5,130,100,30,window)
  33.  
  34. ;
  35. ; Fuctions
  36. ;
  37. Function resize(hwnd,xwd,yhg)
  38.         i=1
  39.         j=1
  40.         Repeat
  41.                 i=i+1
  42.                 SetGadgetShape hwnd,0,0,i,j
  43.         Until ClientWidth(hwnd) = xwd
  44.         Repeat
  45.                 j=j+1
  46.                 SetGadgetShape hwnd,0,0,i,j
  47.         Until ClientHeight(hwnd) = yhg
  48.         Notify GadgetWidth(hwnd)+" x "+GadgetHeight(hwnd)
  49. End Function
  50.  
  51. Function writemessage(name,id,evdata,source,x,y)
  52.         Repeat
  53.         Until FileType("comunicate.tmp") = 0
  54.         file = WriteFile("comunicate.tmp")
  55.         WriteInt file,name
  56.         WriteInt file,id
  57.         WriteInt file,evdata
  58.         WriteInt file,source
  59.         WriteInt file,x
  60.         WriteInt file,y
  61.         CloseFile file
  62. End Function
  63.  
  64. ;
  65. ; Startup
  66. ;
  67. UpdateWindowMenu window
  68. MainHwnd = GetActiveWindow()
  69. ExecFile("Viewport.exe")
  70. tmp=MilliSecs()
  71. Repeat
  72. Until MilliSecs()-tmp > 500
  73. Repeat
  74.         vwprt = FindWindow("Blitz Runtime Class","Viewport")
  75.         If WaitEvent() = $803 Then End
  76. Until vwprt <> 0
  77. SetParent(vwprt,mainhwnd)
  78. SetWindowPos(vwprt,0,2,-25,ClientWidth(window),ClientHeight(window)-20,0)
  79. ActivateWindow window
  80. SetGadgetLayout button,1,0,1,0
  81.  
  82. ;
  83. ; Mainloop
  84. ;
  85. Repeat
  86. event = WaitEvent()
  87. Select event
  88.         Case $401
  89.                 Select EventSource()
  90.                 Case button
  91.                         RequestColor(255,255,255)
  92.                         writemessage(event,EventID(),RequestedRed(),1,RequestedGreen(),RequestedBlue())
  93. ;               Case
  94. ;                       writemessage(event,EventID(),EventData(),EventSource(),EventX(),EventY())
  95.                 End Select
  96.         Case $803
  97.                 Select EventSource()
  98.                 Case window
  99.                         writemessage(event,EventID(),EventData(),EventSource(),EventX(),EventY())
  100.                         End
  101.                 End Select
  102.         Case $1001
  103.                 Select EventData()
  104.                 Case beenden_m
  105.                         writemessage($803,0,0,0,0,0)
  106.                         End
  107.                 End Select
  108.         End Select
  109. Forever
  110.  
  111. #------ Blitz 3D Source
  112.  
  113. ;
  114. ; Constants
  115. ;
  116. Const screenwidth = 160
  117. Const screenheight = 120
  118. Const colormode = 32
  119.  
  120. Graphics3D screenwidth,screenheight,colormode,2
  121. AppTitle("Viewport")
  122. SetBuffer BackBuffer()
  123.  
  124. ;
  125. ; Globals
  126. ;
  127. ; GUI
  128. Global eventname
  129. Global eventid
  130. Global eventdata
  131. Global eventsource
  132. Global eventx
  133. Global eventy
  134.  
  135. ; 3D
  136. Global camera = CreateCamera()
  137. Global light = CreateLight()
  138. Global cube=CreateCube()
  139.  
  140. ;
  141. ; Startup
  142. ;
  143. CameraViewport camera,0,0,100,100
  144. PositionEntity light,-3,0,3
  145. PositionEntity camera,-3,5,-1
  146. ScaleEntity cube,2,2,2
  147. PointEntity camera,cube
  148. hwnd = GetActiveWindow()
  149. result = CreateRectRgn(3,30,103,130)
  150. SetWindowRgn(hwnd,result,1)
  151. ;
  152. ; Mainloop
  153. ;
  154. Repeat
  155.         file = ReadFile("comunicate.tmp")
  156.         If file <> 0 Then
  157.                 eventname = ReadInt(file)
  158.                 eventid = ReadInt(file)
  159.                 eventdata = ReadInt(file)
  160.                 eventsource = ReadInt(file)
  161.                 eventx = ReadInt(file)
  162.                 eventy = ReadInt(file)
  163.                 CloseFile(file)
  164.                 DeleteFile "comunicate.tmp"
  165.                 Select eventname
  166.                 Case $401
  167.                         Select eventsource
  168.                         Case 1
  169.                                 EntityColor cube,eventdata,eventx,eventy
  170.                         End Select
  171.                 End Select
  172.         End If
  173.         TurnEntity cube,0.2,1,2
  174.         UpdateWorld
  175.         RenderWorld
  176.         Flip
  177. Until FindWindow("BlitzMax_Window_Class","Modeller") = 0
  178. End


Comments :


Phoenix(Posted 1+ years ago)

 How do you use it? I put it in b+ and it says "Function Graphics3d not found"...


mv333(Posted 1+ years ago)

 Phoenix, you need to remove the blitz3d part of the code, which is the bottom part, after "#------ Blitz 3D Source".


 

SimplePortal 2.3.6 © 2008-2014, SimplePortal