Open alexefu73 opened 2 years ago
even though it may appear to be a bug the canvas actually requires a graphics context to render to, so this can be solved by simply adding in the following import
Import brl.glmax2d
this should solve your issue
even though it may appear to be a bug the canvas actually requires a graphics context to render to, so this can be solved by simply adding in the following import
Import brl.glmax2d
this should solve your issue
Thanks sir, I added this import line 'import brl.glmax2d', but it's still the error continually appearing when running the result app.
Does this sample work for you?
SuperStrict
Framework MaxGui.Drivers
Import brl.timerdefault
Import brl.eventqueue
Import brl.glmax2d
Global GAME_WIDTH:Int=320
Global 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
I should mention that I am on Win 11, and do not have any linux boxes.
I entered this example and the same error is still appear.
It could be an issue on linux then, hopefully one of the linux guru's can confirm and then assist further with bug reporting, apologies.
Ok!
Maybe a GTK3 issue? GTK3 raised some issues here and there ... and with more recent Linux Distros MaxGUI shows aging symptoms (also on MacOS).
The samples work here but I am on Mint 18 and 19. Could check in a VM - just pass me the download page of your distro (and the flavour you used).
I'm using Deepin 20.2.1, downloaded it from here: https://www.deepin.org/en/download/
I built it here - with newest BMX NG (updated bcc, modules, ...)
Does it work for you?
Ok, installed in a VM ... can replicate your issue and my testcode runs ... need to check if updating BMX will do.
OK ... if you updated complete Blitzmax, it will work ... but as there is a hen-egg issue (newer compiler needs newer brl.mod - and brl.mod needs newer compiler) I will do a "manual" update instruction here:
remove blitzmax/mod/maxgui.mod and replace it with the downloaded one (do not forget to remove the "-master" from the folder name!)
remove blitzmax/mod/brl.mod:
and replace them with the according folders from the downloaded brl.mod-master.zip (only the above ".mod" folders ... other folders might require new BCC/compiler stuff ... so do not touch them for now :D)
When then compiling ... it should work (did so in my VM) Why? We fixed some stuff meanwhile ... so next stable release would work out of the box but for now you need to make your hands a bit dirty.
This should only require you to use the latest maxgui.mod, specifically the GTK3 modules, with Blitzmax NG 0.129 release.
At least that's all I had to do to fix the same issue CreateCanvas returns Null in Linux fixed here (GTK3) Enable TGTKCanvas.
only updating maxgui wasn't enough because newer maxgui relies on changes in brl.mod ... (in graphics.mod ... and max2d.mod ) and once you update them - you also need to update the systemdefault stuff.
OK ... if you updated complete Blitzmax, it will work ... but as there is a hen-egg issue (newer compiler needs newer brl.mod - and brl.mod needs newer compiler) I will do a "manual" update instruction here:
- download https://github.com/bmx-ng/maxgui.mod
- download https://github.com/bmx-ng/brl.mod
remove blitzmax/mod/maxgui.mod and replace it with the downloaded one (do not forget to remove the "-master" from the folder name!)
remove blitzmax/mod/brl.mod:
- glgraphics.mod
- glmax2d.mod
- graphics.mod
- max2d.mod
- system.mod
- systemdefault.mod
and replace them with the according folders from the downloaded brl.mod-master.zip (only the above ".mod" folders ... other folders might require new BCC/compiler stuff ... so do not touch them for now :D)
When then compiling ... it should work (did so in my VM) Why? We fixed some stuff meanwhile ... so next stable release would work out of the box but for now you need to make your hands a bit dirty.
Thank you so much, it's now working as expected.
Thanks,
I had downloaded and installed BlitzMax (BlitzMax_linux_x64_0.129.3.45.tar.xz) on my platform (GNU/Linux Deepin 20.2.1.x64bit). And tested compiling some basic BlitzMax code. It's work as expected correctly. But when I started to test MaxGUI I had a trouble in running the tested app when creating the Canvas, with resulting in popup window contains the following message:
Unhandled Exception: Attempt to access field or method of Null object
And when I opened the debug panel, it's show me that the 'canvas' variable is (NULL) that supposed to get TGadget object from CreateCanvas function.. look at the picture down.
So, what is the problem? How could I fix the problem? Thanks for care,