Mac Problems with Canvas ?

BlitzMax Forums/MaxGUI Module/Mac Problems with Canvas ?

cps(Posted 2015) [#1]
Each program I write using the canvas gadget works fine on a PC (vista, XP) but on my Mac OS X 10.6.8 Snow Leopard the program freezes.
Ie I get the spinning coloured disc.
Have tried some ideas I found on the forums but nothing solves the problem.
Is this a common problem ? Anybody have any ideas ?
Thanks Cps


Brucey(Posted 2015) [#2]
This runs fine for me on OS X :
' createcanvas.bmx
SuperStrict 

Framework MaxGui.Drivers
Import BRL.EventQueue
Import brl.glmax2d
Import brl.timer

Const GAME_WIDTH:Int=320
Const GAME_HEIGHT:Int=240

' create a centered window with client size GAME_WIDTH,GAME_HEIGHT
Local wx:Int=(ClientWidth(Desktop())-GAME_WIDTH)/2
Local wy:Int=(ClientHeight(Desktop())-GAME_HEIGHT)/2

Local window:TGadget=CreateWindow("My Canvas",wx,wy,GAME_WIDTH,GAME_HEIGHT,Null,WINDOW_TITLEBAR)'|WINDOW_CLIENTCOORDS)

' create a canvas for our game
Local canvas:TGadget=CreateCanvas(0,0,320,240,window)

' create an update timer
CreateTimer 60

While WaitEvent()
	Select EventID()
		Case EVENT_TIMERTICK
			RedrawGadget canvas

		Case EVENT_GADGETPAINT
			SetGraphics CanvasGraphics(canvas)
			SetOrigin 160,120
			SetLineWidth 5
			Cls
			Local t:Int=MilliSecs()
			DrawLine 0,0,120*Cos(t),120*Sin(t)
			DrawLine 0,0,80*Cos(t/60),80*Sin(t/60)
			Flip

		Case EVENT_MOUSEMOVE
			Print "MOVE!"

		Case EVENT_WINDOWCLOSE
			FreeGadget canvas
			End

		Case EVENT_APPTERMINATE
			End
	End Select
Wend

Does it run for you too? :-)


cps(Posted 2015) [#3]
Many Thanks. The code works fine on my Mac (and PC's), I will modify my code to match it's features. Sometimes you can't see the wood for the trees.
Have fun Cps.


cps(Posted 2015) [#4]
Have modified my approach to using canvas as suggested and everything is working fine, I was about to ask about a mouse problem but guess what my mac mouse only has one button. Good job I spotted that before making a fool of my self... Anyway many thanks for your input Cps


Brucey(Posted 2015) [#5]
Glad you got it sorted out!


AdamStrange(Posted 2015) [#6]
Brilliant code Brucey. Nice to see some well written multitasking :)