MaxGUI bug

Archives Forums/MaxGUI Bug Reports/MaxGUI bug

JoshK(Posted 2011) [#1]
Import maxgui.drivers

Local sharedwindow:TGadget=CreateWindow("Shared context",0,0,400,300,Null,WINDOW_HIDDEN)
Local sharedcanvas:TGadget=CreateCanvas(0,0,sharedwindow.ClientWidth(),sharedwindow.ClientHeight(),sharedwindow)
SetGraphics CanvasGraphics(sharedcanvas)
End


Output:
Building untitled1
Compiling:untitled1.bmx
Linking:untitled1.debug
Executing:untitled1.debug
2011-07-01 15:55:58.780 untitled1.debug[59186:60b] invalid drawable

Process complete



AdamRedwoods(Posted 2011) [#2]
Maybe you already have tried this, but you do need to still define the Graphics driver.
SetGraphicsDriver (GLMax2DDriver(),GRAPHICS_ALPHABUFFER|GRAPHICS_BACKBUFFER|GRAPHICS_ACCUMBUFFER)



Or you could just use GadgetPixmaps, and not bother with drawing to any canvases.


skidracer(Posted 2011) [#3]
The correct behavior will be for CanvasGraphics to return null when canvas is not visible.

WIll look into it.


JoshK(Posted 2011) [#4]
There are three changes you could make to MaxGUI that would help me and anyone using Leadwerks Engine and MaxGUI.

1. Create contexts on hidden canvases. When creating the editor window, for example, I create a hidden window, build the GUI up, then show the window.

2. When SetGraphics() is called, make the graphics driver always set the OpenGL context, instead of checking to see if the context is already the current one. This is because other OpenGL contexts not controlled by BMX might be switched to, and this will make sure the context gets switched back.

3. Don't initialize a graphics context until CanvasGraphics() is called the first time. The user might want to create a canvas, and then let Leadwerks initialize the OpenGL context on it. If an OpenGL context has already been created on the canvas, a new one cannot be initialized.


Tricky(Posted 2015) [#5]
Sorry for bumping an old thread. (Yeah 3 years is long) I ended up here for googling the site because I had a similar problem and I was looking for a solution which I could not find here, but I could find one myself, and if anybody else searches the forum they can find my solution for this problem.

For me the trick was to make sure the CanvasGraphics() was not called until the very first time an "EVENT_GADGETPAINT" was generated. After that happened for the first time, it didn't matter any more if another EVENT_GADGETPAINT was generated or not as the system would do this anyway. At least it did for me.

Or you could just use GadgetPixmaps, and not bother with drawing to any canvases.

That would work indeed if I only wanted to put in a logo in my app or something, but I got this problem while setting up a new map editor for my next project and then GadgetPixmaps do not appear to be the solution, or are they?