2d Blitz in Max Gui ?

BlitzMax Forums/BlitzMax Beginners Area/2d Blitz in Max Gui ?

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.

You may want to run the canvas update off a timer instead.

Strict


Local MyWindow:Tgadget = CreateWindow("Canvas",200,200,800,600)
Local MyCanvas:Tgadget = CreateCanvas(10,10,800,600, Mywindow)
SetGraphics CanvasGraphics(MyCanvas)

ActivateGadget(MyCanvas) ' enable the canvas gadget

Local timer:TTimer = TTimer.Create(60) ' 60 FPS timer (or there abouts)


Repeat

	WaitEvent()
	
	Select EventID()
		Case EVENT_TIMERTICK ' 
			RedrawGadget(MyCanvas)
			
		Case EVENT_GADGETPAINT
			Cls
			
			' draw stuff here
			
			Flip
			
		Case EVENT_KEYDOWN ' check for "gui" key down events
			If EventData() = KEY_ESCAPE Then End
			
		Case event_windowclose
			End
	End Select
	
	
	Flip
Forever

Your version sucks up 100% of my CPU time. This version appears to idle between 8 and 16% on my computer.

Just a thought :-)