MiniB3D - MaxGUI vs wxMax

BlitzMax Forums/MiniB3D Module/MiniB3D - MaxGUI vs wxMax

Chapman7(Posted 2012) [#1]
I am comparing MaxGUI's and wxMax's average FPS using a small test with MiniB3D. I need someone else to look over the code (in particular with wxMax). I removed the normal '60 Timer' on both but I think the method I used for wxMax may have hindered the outcome.

MaxGUI Code:
SuperStrict


Import SideSign.MiniB3D
Import MaxGUI.Drivers
SetGraphicsDriver GLGraphicsDriver(), GRAPHICS_BACKBUFFER|GRAPHICS_DEPTHBUFFER


Local Window:TGadget = CreateWindow("MaxGUI + MiniB3D", 50, 50, 512, 512, Null, WINDOW_TITLEBAR)
Local Canvas:TGadget = CreateCanvas(0, 0, ClientWidth(Window), ClientHeight(Window), Window, 0)
SetGadgetLayout Canvas, 1, 1, 1, 1


TGlobal.Width = ClientWidth(Window)
TGlobal.Height = ClientHeight(Window)
TGlobal.Depth = 16
TGlobal.Mode = 0
TGlobal.Rate = 60

SetGraphics CanvasGraphics(Canvas)
TGlobal.GraphicsInit()


Local Camera:TCamera = CreateCamera()
PositionEntity Camera, 0, 0, -10

Local Light:TLight = CreateLight(1)
Local 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

Local old_ms:Int=MilliSecs()
Local renders:Int
Local fps:Int


While True
	SetGraphics CanvasGraphics(Canvas)
	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 0 
Wend


wxMax Code:
SuperStrict

Framework wx.wxApp
Import wx.wxFrame
Import wx.wxPanel
Import wx.wxGLCanvas
Import sidesign.minib3d

Global prog:MyApp = New MyApp
prog.Run()

Type MyApp Extends wxApp
	Field frame:wxFrame
	Field panel:wxPanel
	Field canvas:TMiniB3D
	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
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		
			InitMB3D()		
		End If
		RenderMB3D()
	End Method
End Type


Global Cube:TMesh
Global old_ms:Int=MilliSecs()
Global renders:Int
Global fps:Int


Function InitMB3D()

	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 Function

Function RenderMB3D()

	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
	prog.canvas.Refresh()

End Function


Using an AMD Radeon HD 6570 I get:
MaxGUI - 1275
wxMax - 950
This is in no way a final outcome or result. Like I mentioned above, I need someone to look at the code for me.

Cole


Midimaster(Posted 2012) [#2]
In combination with MaxGui try this additional commands:

....
SetGraphicsDriver GLMax2DDriver()
Local Canvas:TGadget = CreateCanvas(0, 0, 800, 600, Window)

SetGraphics CanvasGraphics(Canvas)

TGlobal.Width = 800	
TGlobal.Height = 600
TGlobal.Depth = 0
TGlobal.Mode = 2
TGlobal.Rate = 60
TGlobal.GraphicsInit()
....
CreateTimer(60)
While WaitEvent()
     .....



Chapman7(Posted 2012) [#3]
Does GLMax2DDriver() give better benefits over GLGraphicsDriver()? Other than that, I think the MaxGUI one is already solid. If you are familiar with wxMax though, you should check the code and see if we can do anything differently.

Last edited 2012


Midimaster(Posted 2012) [#4]
Oh, sorry, I did missunderstand you. I thought you could not get any results with combination MaxGui and MiniB3D also. So I wrote you my standard solution.

If yours is working, there is no need to change the driver....

Sorry, I'm not familiar with wxMax.


Chapman7(Posted 2012) [#5]
Okay so I was able to tweak the wxMax code a bit better and now the FPS is just shy of MaxGUI's.

MaxGUI - 1275
wxMax - 1250

I am not sure if anyone can really tweak if further, if they can awesome. But anyways, 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



You have to do this If init = 0 thing in the canvas' OnPaint method because for some reason, it works differently than if you were to put the code in the OnInit method, not sure why though.

Cole

Last edited 2012