this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

thanks to memononen for the suggestion to use NVG_IMAGE_NODELETE

+8 -6
+8 -6
demos/nanovg/main.c
··· 11 11 12 12 /* Create a GPU_Image from a NanoVG Framebuffer */ 13 13 GPU_Image* generateFBO(NVGcontext* _vg, const float _w, const float _h, void (*draw)(NVGcontext*, const float, const float, const float, const float)) { 14 - // GPU_FlushBlitBuffer(); // you may want to call this if you're doing this in the middle of SDL_gpu blitting 15 - NVGLUframebuffer* fb = nvgluCreateFramebuffer(_vg, _w, _h, 0); // IMPORTANT: don't run nvgluDeleteFramebuffer 14 + // GPU_FlushBlitBuffer(); // call GPU_FlushBlitBuffer if you're doing this in the middle of SDL_gpu blitting 15 + NVGLUframebuffer* fb = nvgluCreateFramebuffer(_vg, _w, _h, NVG_IMAGE_NODELETE); // IMPORTANT: don't run nvgluDeleteFramebuffer 16 16 nvgluBindFramebuffer(fb); 17 17 glViewport(0, 0, _w, _h); 18 18 glClearColor(0, 0, 0, 0); ··· 23 23 /* nvgluBindFramebuffer(0); // official documentation says to unbind, but I haven't had issues not doing it */ 24 24 GPU_ResetRendererState(); // not calling GPU_ResetRendererState can cause problems with SDL_gpu depending on your order of operations 25 25 // IMPORTANT: don't run nvgluDeleteFramebuffer, GPU_CreateImageUsingTexture takes the handle 26 - return GPU_CreateImageUsingTexture(fb->texture, false); // should take_ownership be true? 26 + GPU_Image* return_image = GPU_CreateImageUsingTexture(fb->texture, false); // should take_ownership be true? 27 + nvgluDeleteFramebuffer(fb); 28 + return return_image; 27 29 } 28 30 29 31 /* Simple Drawing Example */ ··· 97 99 /* SDL_gpu + NanoVG Rendering */ 98 100 GPU_ClearRGBA(_screen, 0x00, 0x00, 0x00, 0xFF); // GPU_ClearRGBA clears GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT 99 101 glClear(GL_STENCIL_BUFFER_BIT); // IMPORTANT: GPU_ClearRGBA does not clear GL_STENCIL_BUFFER_BIT 100 - 102 + 101 103 /* SDL_gpu Blitting */ 102 104 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???) 103 105 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???) 104 - 106 + 105 107 /* NanoVG Section */ 106 108 GPU_FlushBlitBuffer(); // IMPORTANT: run GPU_FlushBlitBuffer before nvgBeginFrame 107 109 nvgBeginFrame(_vg, _screen_w, _screen_h, px_ratio); // Do your normal NanoVG stuff ··· 110 112 /* drawComplexNVG(_vg); */ 111 113 nvgEndFrame(_vg); // Finish our NanoVG pass 112 114 GPU_ResetRendererState(); // IMPORTANT: run GPU_ResetRendererState after nvgEndFrame 113 - 115 + 114 116 /* Finish */ 115 117 GPU_Flip(_screen); // Render to screen 116 118 } while (loop);