I´m trying to learn PureBasics approach to the OGRE 3D engine by doing it from scratch.
I have run some of the examples that came with PureBasic and tried to construct my own minimal environment from those examples.
All examples run that "Screen3DRequester.pb" file to give the user a choice but I don´t want that at all.
But I have run into a problem that someone most likely can help me solve.
This piece of code below crashes when I run it. If I comment out the "CreateCamera" line it doesn´t crash and it opens a windows and closes when I hit ESC.
So WHY does it crash when I want to create a camera?? If I had forgot to add some init code PB normally tells me that, but it shouldn´t crash right?
Code: Select all
If InitEngine3D()
InitSprite()
InitKeyboard()
InitMouse()
If OpenWindow(0, 0, 0, 640, 480, "3D Test", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
Result = OpenWindowedScreen(WindowID(0), 0, 0, WindowWidth(0), WindowHeight(0), 0, 0, 0)
EndIf
;-- 3d stuff
WorldShadows(#PB_Shadow_Additive)
AmbientColor(0)
; node for Light and Billboard (Sun)
CreateNode(0, 0, 3000, 0)
;Create light
CreateLight(0, RGB(90, 105, 132), 0, 3000, 0)
AttachNodeObject(0, LightID(0))
; Static geometry
;
; Create Entity
CreateCube(0, 1)
CreateEntity(0, MeshID(0), #PB_Material_None)
; Create Static geometry
CreateStaticGeometry(0, 1000, 1000, 1000, #True)
For z = -10 To 10
For x = -10 To 10
AddStaticGeometryEntity(0, EntityID(0), x * 1000, 0, z * 1000, 1000, 10, 1000, 0, 0, 0)
Height.f = 200 + Random(800)
AddStaticGeometryEntity(0, EntityID(0), x * 1000, Height/2, z * 1000, 200, Height, 200, 0, Random(360), 0)
Next
Next
; Build the static geometry
BuildStaticGeometry(0)
FreeEntity(0)
; Camera
;
CreateCamera(0, 0, 0, 100, 100)
;--
Repeat
Repeat
Event = WindowEvent()
ExamineKeyboard()
If Event = #PB_Event_CloseWindow Or KeyboardPushed(#PB_Key_Escape)
End
Else
Delay(1)
EndIf
Until Event = 0
RenderWorld()
FlipBuffers()
ForEver
Else
MessageRequester("Error", "The 3D Engine can't be initialized", 0)
EndIf
End