Mojo2 crashes in Glfw3/Mac when setting font
Monkey Forums/Monkey Bug Reports/Mojo2 crashes in Glfw3/Mac when setting font
| ||
Provided that the font.png file is in the correct place, this code works in html5, but causes a memory violation in Glfw3 on a Mac (El Capitan, up to date Xcode). [monkeycode] Import mojo2 Function Main() New Test End Class Test Extends App Field font := Font.Load( "images/font.png", 32, 96, True ) Field canvas :Canvas Method OnCreate() SetUpdateRate( 30 ) canvas = New Canvas End Method OnRender() canvas.Clear() canvas.SetFont( font ) canvas.DrawText( "Test 0123456789 abcdefghijklmnopqrstuvwxyz", 20, 20 ) canvas.Flush() End End [/monkeycode] |
| ||
Never mind, just found out that loading the font inside OnCreate() works. Took me a while to figure it out... this will work: [monkeycode] Import mojo2 Function Main() New Test End Class Test Extends App Field font :Font Field canvas :Canvas Method OnCreate() SetUpdateRate( 30 ) canvas = New Canvas font = Font.Load( "images/font.png", 32, 96, True ) End Method OnRender() canvas.Clear() canvas.SetFont( font ) canvas.DrawText( "Test 0123456789 abcdefghijklmnopqrstuvwxyz", 20, 20 ) canvas.Flush() End End [/monkeycode] |
| ||
I think it's not a bug. In Monkey, you have always to load graphic and sound stuff after initialization, eg: OnCreate :) I don't find currently the text about this behavior in the Documentation sorry, but it's true :D |
| ||
Yeah, I tend to initialize things as I declare them, forgot about loading only inside OnCreate. Will remember next time. Thanks! |