|
@@ -59,6 +59,7 @@ int main() |
|
|
struct NVGcontext* vg = NULL; |
|
|
struct NVGcontext* vg = NULL; |
|
|
struct PerfGraph fps; |
|
|
struct PerfGraph fps; |
|
|
double prevt = 0; |
|
|
double prevt = 0; |
|
|
|
|
|
struct NVGLUframebuffer* fb = NULL; |
|
|
|
|
|
|
|
|
if (!glfwInit()) { |
|
|
if (!glfwInit()) { |
|
|
printf("Failed to init GLFW."); |
|
|
printf("Failed to init GLFW."); |
|
@@ -110,6 +111,8 @@ int main() |
|
|
glfwSetTime(0); |
|
|
glfwSetTime(0); |
|
|
prevt = glfwGetTime(); |
|
|
prevt = glfwGetTime(); |
|
|
|
|
|
|
|
|
|
|
|
fb = nvgluCreateFramebuffer(vg, 600, 600); |
|
|
|
|
|
|
|
|
while (!glfwWindowShouldClose(window)) |
|
|
while (!glfwWindowShouldClose(window)) |
|
|
{ |
|
|
{ |
|
|
double mx, my, t, dt; |
|
|
double mx, my, t, dt; |
|
@@ -129,6 +132,20 @@ int main() |
|
|
// Calculate pixel ration for hi-dpi devices. |
|
|
// Calculate pixel ration for hi-dpi devices. |
|
|
pxRatio = (float)fbWidth / (float)winWidth; |
|
|
pxRatio = (float)fbWidth / (float)winWidth; |
|
|
|
|
|
|
|
|
|
|
|
if (fb != NULL) { |
|
|
|
|
|
int fboWidth, fboHeight; |
|
|
|
|
|
nvgImageSize(vg, fb->image, &fboWidth, &fboHeight); |
|
|
|
|
|
// Draw some stull to an FBO as a test |
|
|
|
|
|
nvgluBindFramebuffer(fb); |
|
|
|
|
|
glViewport(0, 0, fboWidth, fboHeight); |
|
|
|
|
|
glClearColor(0, 0, 0, 0); |
|
|
|
|
|
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT|GL_STENCIL_BUFFER_BIT); |
|
|
|
|
|
nvgBeginFrame(vg, fboWidth, fboHeight, pxRatio, NVG_PREMULTIPLIED_ALPHA); |
|
|
|
|
|
renderDemo(vg, mx, my, fboWidth, fboHeight, t, blowup, &data); |
|
|
|
|
|
nvgEndFrame(vg); |
|
|
|
|
|
nvgluBindFramebuffer(NULL); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
// Update and render |
|
|
// Update and render |
|
|
glViewport(0, 0, fbWidth, fbHeight); |
|
|
glViewport(0, 0, fbWidth, fbHeight); |
|
|
if (premult) |
|
|
if (premult) |
|
@@ -142,6 +159,15 @@ int main() |
|
|
renderDemo(vg, mx,my, winWidth,winHeight, t, blowup, &data); |
|
|
renderDemo(vg, mx,my, winWidth,winHeight, t, blowup, &data); |
|
|
renderGraph(vg, 5,5, &fps); |
|
|
renderGraph(vg, 5,5, &fps); |
|
|
|
|
|
|
|
|
|
|
|
if (fb != NULL) { |
|
|
|
|
|
struct NVGpaint img = nvgImagePattern(vg, 0, 0, 150, 150, 0, fb->image, NVG_NOREPEAT, 1.0f); |
|
|
|
|
|
nvgBeginPath(vg); |
|
|
|
|
|
nvgTranslate(vg, 540, 300); |
|
|
|
|
|
nvgRect(vg, 0, 0, 150, 150); |
|
|
|
|
|
nvgFillPaint(vg, img); |
|
|
|
|
|
nvgFill(vg); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
nvgEndFrame(vg); |
|
|
nvgEndFrame(vg); |
|
|
|
|
|
|
|
|
if (screenshot) { |
|
|
if (screenshot) { |
|
|