what is the correct way to handle textures for V2

@Vortico : The porting instructions say not to hold onto any off-screen images between draw calls. But it’s often highly desirable.

There is a squinky labs module (Colors) that generates a monochrome texture of “noise” and uses it to animate the UI. I used to create this in the widget constructor and free it in the widget destructor. That crashes in V2, although @robert.kock has got it to not crash.

@synthi shared a method he found works.

But what it the “right” way to do something like this?

1 Like

You can actually store NanoVG image handles across frames, but you must destroy them in Widget::onContextDestroy() and recreate them in Widget::onContextCreate(). Between these events, the window, OpenGL, and NanoVG contexts do not exist, and they are different when recreated and cannot be used with image handles of the previous context.

2 Likes

oh, cool. Is that a typo? maybe you re-create them in onContextCreate?

Yes, typo fixed!

2 Likes