maxgui canvas refresh rate.
BlitzMax Forums/MaxGUI Module/maxgui canvas refresh rate.
| ||
Hi ! Is there a way to fix the canvas refresh rate to 60 fps (for example). When the canvas is included into a maxgui window. (in my case inside a panel). Thanks ! |
| ||
Create a timer (on 60 FPS) and repaint the canvas on each tick. |
| ||
could you post a pseudo-code sample. i've already a timer in my code but not work as i want ! |
| ||
i've this :Local My_timer:TTimer=CreateTimer(60) While WaitEvent() Select EventID() Case EVENT_TIMERTICK If EventSource() = Mon_timer Then RedrawGadget(Canvas_parametres_ennemi) End If Case EVENT_GADGETPAINT SetGraphics CanvasGraphics(Canvas_parametres_ennemi) ... SetColor 255,255,255 DrawText mx + "," + my, mx, my DrawOval mx-2, my-2,2,2 Flip RedrawGadget Canvas_parametres_ennemi End Select Wend |
| ||
Something like this :Select EventID() Case EVENT_TIMERTICK RedrawGadget canvas Case EVENT_GADGETPAINT SetGraphics CanvasGraphics(canvas) SetOrigin 160,120 SetLineWidth 5 Cls Local t=MilliSecs() DrawLine 0,0,120*Cos(t),120*Sin(t) DrawLine 0,0,80*Cos(t/60),80*Sin(t/60) Flip |
| ||
Does using an event hook for the EVENT_TIMERTICK event help?Global tmrRepaint:TTimer = CreateTimer(60) AddHook EmitEventHook, eventHook While WaitEvent() Select EventID() Case EVENT_WINDOWCLOSE, EVENT_APPTERMINATE End EndSelect Wend Function eventHook:Object( pID:Int, pData:Object, pContext:Object ) Local pEvent:TEvent = TEvent(pData) If pEvent Then Select pEvent.id Case EVENT_TIMERTICK If pEvent.source = tmrRepaint Then RedrawGadget(gadCanvas) Return Null EndIf Case EVENT_GADGETPAINT 'Blatant copy and pasting (thanks Brucey) SetGraphics CanvasGraphics(gadCanvas) SetOrigin 160,120 SetLineWidth 5 Cls Local t=MilliSecs() DrawLine 0,0,120*Cos(t),120*Sin(t) DrawLine 0,0,80*Cos(t/60),80*Sin(t/60) Flip EndSelect EndIf Return pData EndFunction |
| ||
Thanks ! |