MiniB3D and wxMax

BlitzMax Modules Forums/MiniB3D/MiniB3D and wxMax

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

My whole screen, not just the WxFrame, flashed black and white
and the app freezed under Vista.

that all meshes must be created after the GraphicsInit() or they'll get overwritten by other meshes

This was the point. ALL meshes.
Not just overwritten, it caused some more serious errors.

The cube, sphere and cylinder were created in OnInit().
The other mesh was loaded in Render()
If I move them in Render() after the second "TGlobal.GraphicsInit()"
then it works. Don't know why..

My failing Code:
SuperStrict
' WARNING Code FAILS!! 
Framework wx.wxApp
Import wx.wxFrame
Import wx.wxTimer
Import wx.wxPanel
Import wx.wxglmax2D
Import sidesign.minib3d

Const Menu_Exit:Int = 100

SetGraphicsDriver wxGLGraphicsDriver(),GRAPHICS_BACKBUFFER|GRAPHICS_DEPTHBUFFER
New Window.run()

Type Window Extends wxApp
	Field Frame:WinFrame
	Method OnInit:Int()
		Frame = WinFrame(New WinFrame.Create(Null, -1, "Terrain Editor", , , 800, 600))
		Frame.show(True)
		SetTopWindow(Frame)
		Return True
	End Method
End Type

Type WinFrame Extends wxFrame
	Field Canvas:WinCanvas
	Method OnInit()
		Local FileMenu:wxMenu = wxMenu.CreateMenu()
		Local MenuBar:wxMenuBar = wxMenuBar.CreateMenuBar()
		Local Panel:wxPanel = New wxPanel.Create( Self )
		Canvas = WinCanvas(New WinCanvas.Create(Panel, -1, GRAPHICS_BACKBUFFER|GRAPHICS_DEPTHBUFFER,0,0,800,600))
		
		
		
		ConnectAny(wxEVT_CLOSE, OnClose)
		FileMenu.Append(Menu_Exit, "Exit~tAlt-X", "Quit this program")
		MenuBar.Append(FileMenu, "&File")
		SetMenuBar(MenuBar)
		CreateStatusBar(1)
		SetStatusText("Terrain Editor")
	End Method
	Function OnClose(event:wxEvent)
		WinFrame(event.parent).Canvas.timer.Stop()
		event.Skip()
	End Function
End Type

Type WinCanvas Extends wxGLCanvas
	Field Timer:wxTimer
	
	Field cam:TCamera
	Field light:TLight
	Field cube:TMesh
	Field sphere:TMesh
	Field cylinder:TMesh
	Field cone:TMesh
	Field hd:TMesh
	'
	Field initialized_graphics:Int = False

	Method OnInit()
		SetBackgroundStyle(wxBG_STYLE_CUSTOM)
		Timer = New wxTimer.Create(Self)
		ConnectAny(wxEVT_TIMER, OnTick)
		Timer.Start(17)

		' **********
		Local width:Int, height:Int
		GetSize(width, height)

		SetGraphics CanvasGraphics2D( Self )


		TGlobal.width = width
		TGlobal.height = height

		TGlobal.depth=16
		TGlobal.mode=0
		TGlobal.rate=60

		TGlobal.GraphicsInit()
		' ************

		cam=CreateCamera()
		light=CreateLight(1)
		cube=CreateCube()
		sphere=CreateSphere()
		cylinder=CreateCylinder()
		cone = CreateCone()
	End Method
	Method OnPaint(event:wxPaintEvent)
		Render()
	End Method
	Method Render()
		If Not initialized_graphics Then	
			TGlobal.GraphicsInit()

			Local ufo:TMesh = LoadMesh ("ufo.b3d")    ' flashing screen; fails under Vista  ************************
			initialized_graphics=True
		End If
		' SetGraphics CanvasGraphics2D(Self)
		Global enabled:int
		If Not enabled Then
			enabled = True
			TGlobal.EnableStates()
		End If
		Draw()
		Flip
	End Method

	Function OnTick(event:wxEvent)
		wxWindow(event.parent).Refresh()
	End Function
	Method Draw()
		PositionEntity cam,0,0,-10
		PositionEntity cube,-6,0,0
		PositionEntity sphere,-2,0,0
		PositionEntity cylinder,2,0,0
		PositionEntity cone,6,0,0
		TurnEntity cube,0,1,0
		RenderWorld
	End Method
End Type