CanvasGraphics on OSX Yosemite

Archives Forums/MacOS X Discussion/CanvasGraphics on OSX Yosemite

Chalky(Posted 2015) [#1]
I am writing a music utility in BlitzMax which runs absolutely fine on Windows XP (and 7 and 8.1):


But on OSX looks like this:


I traced the problem with the main window to "HideGadget" (I originally hid the canvas while I drew it), so commented it out, resulting in this:


However, the canvases on the child window simply refuse to update - even though the code is exactly the same (using "SetGraphicsDriver GLMax2DDriver()" and "GLShareContexts()") on both Windows and OSX.

The only difference I can think of is that the child window is updated via DrawImage whereas the main window is drawn using DrawRect and DrawText. Although this suggests a failed LoadImage, the image objects are not Null. Is there something I need to do differently on OSX in order to be able to draw images to a canvas?


skidracer(Posted 2015) [#2]
If you are using EVENT_GADGETPAINT check that you are calling SetViewport before any drawing calls.

If you are using multiple windows there may be an issue as I am not aware of any MaxGUI apps that draw to both.


Chalky(Posted 2015) [#3]
Hi skidracer. I am using EVENT_GADGETPAINT so have just tried adding SetViewport but this didn't fix the issue. I'm also using multiple windows. The images are definitely loaded because I can draw them on the main window canvas without problems - it's only the child window (I'm calling it child as it has the main window as its parent) which refuses to update. In fact, no drawing commands update the child window (DrawRect, DrawText, DrawImage) at all on OSX, yet the exact same code works fine on Windows.


xlsior(Posted 2015) [#4]
don't know if it affects canvases as well or not, but... Have you tried putting a GLShareContexts() after creating the window?


Chalky(Posted 2015) [#5]
I already have GLShareContexts() at the top of my code (without it the main window graphics were corrupted).

I'm beginning to think this is not canvas-related, as I created a version of the program which only generated the child window (parent=Null) and the canvases still did not render. Maybe it's because the canvases are contained within a Type - each with a Paint() method? In the screenshots there are 4 instances of the Type - all of which update fine in Windows, but none in OSX. I have deliberately not included any OS-specific code in my program so as to make porting across systems as simple as possible, so don't understand why the same code works on one but not another.

I have now spent over a week trying to get this to work on OSX without success. Since all image objects load successfully, the canvases are created ok (i.e. not Null) and there are no errors generated, I have no clues as to what is wrong and therefore have to accept that I am unlikely to ever get it working. Thank you for the suggestions.


skidracer(Posted 2015) [#6]
GLShareContexts seems like a good suggestion.

The MaGUI example also calls SetGraphics CanvasGraphics(canvas) at the beginning of the EVENT_GADGETPAINT handler which may also be required in a multi window config.


Chalky(Posted 2015) [#7]
Hi skidracer.

I already have GLShareContexts() at the top of my code - and adding another after the creation of each window made no difference. I also have a SetGraphics CanvasGraphics(<canvasname>) at the top of every Paint() method - and these are called whenever EVENT_GADGETPAINT is raised (via a Hook).

The thing I don't understand (I know I'm sounding like a parrot here) is the fact the the code works on Windows - so why not OSX?


skidracer(Posted 2015) [#8]
I would be happy to take a closer look if you want to send me a zip.

Under neath the hood MaxGUI is a VERY different beast on each OS and yes, it still seems to have some issues.


Chalky(Posted 2015) [#9]
Wow - thank you - zip sent.


skidracer(Posted 2015) [#10]
Started looking into this last night.

Able to run and reproduce issue as described in OP.

Definitely want to fix the HideGadget side effect in which resources become unbound and the main screen fails to draw.

Hopefully will also suss why Live Set window is coming up blank tonight.