···11111212/* Create a GPU_Image from a NanoVG Framebuffer */
1313GPU_Image* generateFBO(NVGcontext* _vg, const float _w, const float _h, void (*draw)(NVGcontext*, const float, const float, const float, const float)) {
1414- // GPU_FlushBlitBuffer(); // you may want to call this if you're doing this in the middle of SDL_gpu blitting
1515- NVGLUframebuffer* fb = nvgluCreateFramebuffer(_vg, _w, _h, 0); // IMPORTANT: don't run nvgluDeleteFramebuffer
1414+ // GPU_FlushBlitBuffer(); // call GPU_FlushBlitBuffer if you're doing this in the middle of SDL_gpu blitting
1515+ NVGLUframebuffer* fb = nvgluCreateFramebuffer(_vg, _w, _h, NVG_IMAGE_NODELETE); // IMPORTANT: don't run nvgluDeleteFramebuffer
1616 nvgluBindFramebuffer(fb);
1717 glViewport(0, 0, _w, _h);
1818 glClearColor(0, 0, 0, 0);
···2323 /* nvgluBindFramebuffer(0); // official documentation says to unbind, but I haven't had issues not doing it */
2424 GPU_ResetRendererState(); // not calling GPU_ResetRendererState can cause problems with SDL_gpu depending on your order of operations
2525 // IMPORTANT: don't run nvgluDeleteFramebuffer, GPU_CreateImageUsingTexture takes the handle
2626- return GPU_CreateImageUsingTexture(fb->texture, false); // should take_ownership be true?
2626+ GPU_Image* return_image = GPU_CreateImageUsingTexture(fb->texture, false); // should take_ownership be true?
2727+ nvgluDeleteFramebuffer(fb);
2828+ return return_image;
2729}
28302931/* Simple Drawing Example */
···9799 /* SDL_gpu + NanoVG Rendering */
98100 GPU_ClearRGBA(_screen, 0x00, 0x00, 0x00, 0xFF); // GPU_ClearRGBA clears GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT
99101 glClear(GL_STENCIL_BUFFER_BIT); // IMPORTANT: GPU_ClearRGBA does not clear GL_STENCIL_BUFFER_BIT
100100-102102+101103 /* SDL_gpu Blitting */
102104 GPU_BlitRectX(fbo_complex, NULL, _screen, &fbo_complex_rect, 0.0f, 0.0f, 0.0f, GPU_FLIP_VERTICAL); // IMPORTANT: GPU_BlitRectX is required to use GPU_FLIP_VERTICAL which is required for NVGLUframebuffer data (why???)
103105 GPU_BlitRectX(fbo_simple, NULL, _screen, &fbo_simple_rect, 0.0f, 0.0f, 0.0f, GPU_FLIP_VERTICAL); // IMPORTANT: GPU_BlitRectX is required to use GPU_FLIP_VERTICAL which is required for NVGLUframebuffer data (why???)
104104-106106+105107 /* NanoVG Section */
106108 GPU_FlushBlitBuffer(); // IMPORTANT: run GPU_FlushBlitBuffer before nvgBeginFrame
107109 nvgBeginFrame(_vg, _screen_w, _screen_h, px_ratio); // Do your normal NanoVG stuff
···110112 /* drawComplexNVG(_vg); */
111113 nvgEndFrame(_vg); // Finish our NanoVG pass
112114 GPU_ResetRendererState(); // IMPORTANT: run GPU_ResetRendererState after nvgEndFrame
113113-115115+114116 /* Finish */
115117 GPU_Flip(_screen); // Render to screen
116118 } while (loop);