Canvas not rendering on app start on Windows
BlitzMax Forums/MaxGUI Module/Canvas not rendering on app start on Windows
| ||
I have built an app that contains two canvases, one for icons and one for a main area. When I start the app, I load icons into the first canvas, fire a redrawgadget event and it calls the draw code. It works perfectly on Mac, but on Windows the icons don't show unless I move the screen around or cover the window with another window then bring it back into view. I tried flipping several times and that works intermittently, however it's not a good fix. I have also tried before and after showing the window. Any help would be appreciated, thanks |
| ||
Can you post the bit of code where you are painting your gadget? Also are you using a hook or waitevent? |
| ||
This is a simplified version of what I am doing: My main code is: ... Global the_ui:UI = MainUI.Create() AddHook EmitEventHook, event_hook Repeat WaitEvent() Forever End Function event_hook:Object(id, data:Object, context:Object) Local event:TEvent = TEvent(data) If event = Null Then Return Null the_ui.handle_event(event) Return Null End Function ... The mainUI code: Method handle_event(event:TEvent) Select event.id Case EVENT_GADGETPAINT If TGadget(event.source) = _icon_canvas draw_icons() Endif ... The simplified draw code: Method draw_icons() SetGraphics CanvasGraphics(_icon_canvas) SetClsColor 0, 0, 0 Cls For Local s:Shape = EachIn _shapes DrawImage s._icon_img, 0, y Next ... Flip ' Note: If I put two additional Flips here, it works End Method |
| ||
Ok a few things: First of all you can put your code In a tag on this forum. <code>blah</code> replace > With ] and < with [Next in your eventhook make sure you are only returning null if you don't want anything else dealing with the event. By returning null always it can cause issues. Replace the two return nulls with Function event_hook:Object(id, data:Object, context:Object) Local event:TEvent = TEvent(data) If event = Null Then Return data If the_ui.handle_event(event) = null Then Return null 'let the handle_event method decide 'always rerun data if event is not handled Return data End Function Type the_ui_object Method handle_event:TEvent(event:TEvent) Select event.id Case EVENT_GADGETPAINT If TGadget(event.source) = _icon_canvas draw_icons() 'return null as we have acted upon it and painted Retun null End if End Select 'return that the event wasn't dealt with Return event End Method End Type The last bit is that you need to make sure to set the viewport and virtual resolution like so: SetGraphics CanvasGraphics(_icon_canvas) SetVirtualResolution(_icon_canvas.clientwidth(),_icon_canvas.clientheight()) SetViewport(0,0,_icon_canvas.clientwidth(),_icon_canvas.clientheight()) Last edited 2011 Last edited 2011 Last edited 2011 |
| ||
Are you calling GLShareContexts() before creating your graphics canvas? |
| ||
And make sure to set GLDriver. |
| ||
Could you try both the DX7 or DX9 graphic drivers on the PC? I believe I've had a similar problem with an initial Splash screen using the DX9 driver -- but not DX7 or OpenGL. |
| ||
Thank you to everyone that helped. I've fixed the event handling as suggested. I am using GLShareContexts() already And using the DX7 driver fixes appears to fix the problem. So again all of you forum members makes working with BlitzMax a fantastic experience. Paul |