Scratch that, here is the code:
SuperStrict
Framework wx.wxApp
Import wx.wxFrame
Import wx.wxPanel
Import wx.wxGLCanvas
Import sidesign.minib3d
Global Cube:TMesh
Global old_ms:Int=MilliSecs()
Global renders:Int
Global fps:Int
Global prog:MyApp = New MyApp
prog.Run()
Type MyApp Extends wxAppMain
Field frame:wxFrame
Field panel:wxPanel
Field canvas:TMiniB3D
Global shouldExit:Int = False
Method OnInit:Int()
frame = New wxFrame.Create(,,"MiniB3d Sample", 0, 0, 512, 512)
frame.Center()
panel = New wxPanel.Create(frame, wxID_ANY, 0, 0, 512, 512)
canvas = TMiniB3D(New TMiniB3D.Create(panel, wxID_ANY, GRAPHICS_BACKBUFFER|GRAPHICS_DEPTHBUFFER, 0, 0, 512, 512))
frame.show()
Return True
End Method
Method MainLoop:Int()
While True
While Not Pending() And ProcessIdle() ; Wend
While Pending()
If Not Dispatch() Then
shouldExit = True
Exit
End If
Wend
If shouldExit Then
While pending()
dispatch()
Wend
Return 0
End If
TurnEntity cube, 0, 1, 0
RenderWorld
renders=renders+1
If MilliSecs()-old_ms>=1000
old_ms=MilliSecs()
fps=renders
renders=0
EndIf
Text 0, 0, "FPS: "+fps
Flip
Wend
EndMethod
End Type
Type TMiniB3D Extends wxGLCanvas
Field init:Int = 0
Method OnPaint(event:wxPaintEvent)
If init = 0 Then
SetGraphics CanvasGraphics( Self )
TGlobal.width = 512
TGlobal.height = 512
TGlobal.depth = 16
TGlobal.mode = 0
TGlobal.GraphicsInit()
init = 1
Local Camera:TCamera = CreateCamera()
PositionEntity Camera, 0, 0, -10
Local Light:TLight = CreateLight(1)
cube:TMesh=CreateCube()
Local sphere:TMesh=CreateSphere()
Local cylinder:TMesh=CreateCylinder()
Local cone:TMesh=CreateCone()
PositionEntity cube,-6,0,0
PositionEntity sphere,-2,0,0
PositionEntity cylinder,2,0,0
PositionEntity cone,6,0,0
RenderWorld
End If
End Method
End Type
btw if anyone knows what the difference is between wxApp and wxAppMain, I would really like to know. I know you cannot access a MainLoop in wxApp, but I dont know what else you can or cant access.
|