{"action":"created","issue":{"url":"https://api.github.com/repos/memononen/nanovg/issues/234","labels_url":"https://api.github.com/repos/memononen/nanovg/issues/234/labels{/name}","comments_url":"https://api.github.com/repos/memononen/nanovg/issues/234/comments","events_url":"https://api.github.com/repos/memononen/nanovg/issues/234/events","html_url":"https://github.com/memononen/nanovg/issues/234","id":94942996,"number":234,"title":"Two framebuffers conflict with each other","user":{"login":"bigfatbrowncat","id":317189,"avatar_url":"https://avatars.githubusercontent.com/u/317189?v=3","gravatar_id":"","url":"https://api.github.com/users/bigfatbrowncat","html_url":"https://github.com/bigfatbrowncat","followers_url":"https://api.github.com/users/bigfatbrowncat/followers","following_url":"https://api.github.com/users/bigfatbrowncat/following{/other_user}","gists_url":"https://api.github.com/users/bigfatbrowncat/gists{/gist_id}","starred_url":"https://api.github.com/users/bigfatbrowncat/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bigfatbrowncat/subscriptions","organizations_url":"https://api.github.com/users/bigfatbrowncat/orgs","repos_url":"https://api.github.com/users/bigfatbrowncat/repos","events_url":"https://api.github.com/users/bigfatbrowncat/events{/privacy}","received_events_url":"https://api.github.com/users/bigfatbrowncat/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":7,"created_at":"2015-07-14T13:15:59Z","updated_at":"2015-07-14T14:08:23Z","closed_at":null,"body":"I'm trying to make two dynamic framebuffer brushes and draw with them, but I have problem with color rendering - colors change and blink randomly.\r\n\r\nThe exact code:\r\n```\r\n\t// Creating framebuffer 1\r\n\t\r\n\tif (fb == NULL) fb = nvgluCreateFramebuffer(vg, 100, 100, NVG_IMAGE_REPEATX | NVG_IMAGE_REPEATY);\r\n\tif (fb == NULL) {\r\n\t\tprintf(\"Could not create FBO.\\n\");\r\n\t\treturn;\r\n\t}\r\n\r\n\tnvgluBindFramebuffer(fb);\r\n\tglViewport(0, 0, 100, 100);\r\n\tglClearColor(0, 0, 0, 0);\r\n\tglClear(GL_COLOR_BUFFER_BIT|GL_STENCIL_BUFFER_BIT);\r\n\tnvgBeginFrame(vg, 100, 100, 1);\r\n\r\n\tnvgBeginPath(vg);\r\n\tnvgRoundedRect(vg, 0, 0, 50.0f, 50.0f, 10.0f);\t\t// Round rect\r\n\tnvgFillColor(vg, nvgRGB(255, 128, 128));\t\t\t// Red color\r\n\tnvgFill(vg);\r\n\t\r\n\tnvgEndFrame(vg);\r\n\t\r\n\t// Creating framebuffer 2\r\n\t\r\n\tif (fb2 == NULL) fb2 = nvgluCreateFramebuffer(vg, 100, 100, NVG_IMAGE_REPEATX | NVG_IMAGE_REPEATY);\r\n\tif (fb2 == NULL) {\r\n\t\tprintf(\"Could not create FBO.\\n\");\r\n\t\treturn;\r\n\t}\r\n\tnvgluBindFramebuffer(fb2);\r\n\tglViewport(0, 0, 100, 100);\r\n\tglClearColor(0, 0, 0, 0);\r\n\tglClear(GL_COLOR_BUFFER_BIT|GL_STENCIL_BUFFER_BIT);\r\n\tnvgBeginFrame(vg, 100, 100, 1);\r\n\r\n\tnvgBeginPath(vg);\r\n\tnvgRect(vg, 0, 0, 50.0f, 50.0f);\t\t\t\t// Rectangle\r\n\tnvgFillColor(vg, nvgRGB(128, 255, 128));\t\t// Green color\r\n\tnvgFill(vg);\r\n\t\r\n\tnvgEndFrame(vg);\r\n\t\r\n\t// Rendering the main screen\r\n\t\r\n\tnvgluBindFramebuffer(0);\r\n\r\n\tNVGpaint fbPaint = nvgImagePattern(vg, 0, 0, 50, 50, 0, fb->image, 1.0f);\r\n\tNVGpaint fbPaint2 = nvgImagePattern(vg, 0, 0, 200, 200, 0, fb2->image, 0.5f);\r\n\r\n\tglfwGetWindowSize(window, &winWidth, &winHeight);\r\n\tglfwGetFramebufferSize(window, &fbWidth, &fbHeight);\r\n\r\n\t// Calculate pixel ration for hi-dpi devices.\r\n\tpxRatio = (float)fbWidth / (float)winWidth;\r\n\r\n\t// Update and render\r\n\tglViewport(0, 0, fbWidth, fbHeight);\r\n\tglClearColor(0.2f, 0.2f, 0.2f, 1.0f);\r\n\tglClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT|GL_STENCIL_BUFFER_BIT);\r\n\r\n\tnvgBeginFrame(vg, fbWidth, fbHeight, pxRatio);\r\n\t\r\n\tnvgBeginPath(vg);\r\n\tnvgRect(vg, 0.0f, 0.0f, winWidth, winHeight);\r\n\tnvgFillPaint(vg, fbPaint);\r\n\tnvgFill(vg);\r\n\r\n\tnvgBeginPath(vg);\r\n\tnvgRect(vg, 0.0f, 0.0f, winWidth, winHeight);\r\n\tnvgFillPaint(vg, fbPaint2);\r\n\tnvgFill(vg);\r\n\t\r\n\tnvgEndFrame(vg);\r\n```\r\n\r\nResult:\r\n![ss1](https://cloud.githubusercontent.com/assets/317189/8673929/3b0bd666-2a43-11e5-9a9f-1c402a2a052a.jpg)\r\n![ss2](https://cloud.githubusercontent.com/assets/317189/8673935/46841382-2a43-11e5-9f88-4d47557d1e3b.jpg)\r\n\r\nThe correct result (as I expect it) should be <em>big green semi-transparent squares over little pink round-rect squares</em>. \r\nThe actual result has correct shape, but colors blink and change randomly each frame between green, pink and black. Colors of both layers change independently.\r\n\r\nWhat am I doing wrong?"},"comment":{"url":"https://api.github.com/repos/memononen/nanovg/issues/comments/121248876","html_url":"https://github.com/memononen/nanovg/issues/234#issuecomment-121248876","issue_url":"https://api.github.com/repos/memononen/nanovg/issues/234","id":121248876,"user":{"login":"bigfatbrowncat","id":317189,"avatar_url":"https://avatars.githubusercontent.com/u/317189?v=3","gravatar_id":"","url":"https://api.github.com/users/bigfatbrowncat","html_url":"https://github.com/bigfatbrowncat","followers_url":"https://api.github.com/users/bigfatbrowncat/followers","following_url":"https://api.github.com/users/bigfatbrowncat/following{/other_user}","gists_url":"https://api.github.com/users/bigfatbrowncat/gists{/gist_id}","starred_url":"https://api.github.com/users/bigfatbrowncat/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bigfatbrowncat/subscriptions","organizations_url":"https://api.github.com/users/bigfatbrowncat/orgs","repos_url":"https://api.github.com/users/bigfatbrowncat/repos","events_url":"https://api.github.com/users/bigfatbrowncat/events{/privacy}","received_events_url":"https://api.github.com/users/bigfatbrowncat/received_events","type":"User","site_admin":false},"created_at":"2015-07-14T14:08:23Z","updated_at":"2015-07-14T14:08:23Z","body":"Again, the shapes look fine. The only problem is with colors."}}