Created
February 2, 2017 10:38
-
-
Save johnfredcee/e0c384f67ca5f28e19675bf7a04f3c65 to your computer and use it in GitHub Desktop.
Nanovg - render to framebuffer
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| nvgImageSize(vg, fb->image, &fboWidth, &fboHeight); | |
| winWidth = (int)(fboWidth / pxRatio); | |
| winHeight = (int)(fboHeight / pxRatio); | |
| // Draw some stuff to an FBO as a test | |
| nvgluBindFramebuffer(fb); | |
| glViewport(0, 0, fboWidth, fboHeight); | |
| glClearColor(0, 0, 0, 0); | |
| glClear(GL_COLOR_BUFFER_BIT|GL_STENCIL_BUFFER_BIT); | |
| nvgBeginFrame(vg, winWidth, winHeight, pxRatio); | |
| pw = (int)ceilf(winWidth / s); | |
| ph = (int)ceilf(winHeight / s); | |
| nvgBeginPath(vg); | |
| for (y = 0; y < ph; y++) { | |
| for (x = 0; x < pw; x++) { | |
| float cx = (x+0.5f) * s; | |
| float cy = (y+0.5f) * s; | |
| nvgCircle(vg, cx,cy, r); | |
| } | |
| } | |
| nvgFillColor(vg, nvgRGBA(220,160,0,200)); | |
| nvgFill(vg); | |
| nvgEndFrame(vg); | |
| nvgluBindFramebuffer(NULL); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment