void Canvas::renderWindow(WindowPtr pWindow, MCFBOPtr pFBO, const IntRect& viewport) { GLContext* pContext = pWindow->getGLContext(); pContext->activate(); GLContextManager::get()->uploadDataForContext(); renderFX(pContext); glm::mat4 projMat; if (pFBO) { pFBO->activate(pContext); glm::vec2 size = m_pRootNode->getSize(); projMat = glm::ortho(0.f, size.x, 0.f, size.y); glViewport(0, 0, GLsizei(size.x), GLsizei(size.y)); } else { glproc::BindFramebuffer(GL_FRAMEBUFFER, 0); projMat = glm::ortho(float(viewport.tl.x), float(viewport.br.x), float(viewport.br.y), float(viewport.tl.y)); IntPoint windowSize = pWindow->getSize(); glViewport(0, 0, windowSize.x, windowSize.y); } { ScopeTimer Timer(VATransferProfilingZone); m_pVertexArray->update(pContext); } clearGLBuffers(GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT | GL_DEPTH_BUFFER_BIT, !pFBO); GLContext::checkError("Canvas::renderWindow: glViewport()"); m_pVertexArray->activate(pContext); { ScopeTimer timer(RootRenderProfilingZone); m_pRootNode->maybeRender(pContext, projMat); } renderOutlines(pContext, projMat); }
void Canvas::render(IntPoint windowSize, bool bUpsideDown, FBOPtr pFBO, ProfilingZoneID& renderProfilingZone) { { ScopeTimer Timer(PreRenderProfilingZone); m_pRootNode->preRender(); } if (pFBO) { pFBO->activate(); } else { glproc::BindFramebuffer(GL_FRAMEBUFFER_EXT, 0); GLContext::getCurrent()->checkError("Canvas::render: BindFramebuffer()"); } if (m_MultiSampleSamples > 1) { glEnable(GL_MULTISAMPLE); GLContext::getCurrent()->checkError( "Canvas::render: glEnable(GL_MULTISAMPLE)"); } else { glDisable(GL_MULTISAMPLE); GLContext::getCurrent()->checkError( "Canvas::render: glDisable(GL_MULTISAMPLE)"); } clearGLBuffers(GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glViewport(0, 0, windowSize.x, windowSize.y); GLContext::getCurrent()->checkError("Canvas::render: glViewport()"); glMatrixMode(GL_PROJECTION); GLContext::getCurrent()->checkError("Canvas::render: glMatrixMode()"); glLoadIdentity(); GLContext::getCurrent()->checkError("Canvas::render: glLoadIdentity()"); glm::vec2 size = m_pRootNode->getSize(); if (bUpsideDown) { gluOrtho2D(0, size.x, 0, size.y); } else { gluOrtho2D(0, size.x, size.y, 0); } GLContext::getCurrent()->checkError("Canvas::render: gluOrtho2D()"); glMatrixMode(GL_MODELVIEW); { ScopeTimer Timer(renderProfilingZone); m_pRootNode->maybeRender(); renderOutlines(); } }
void Canvas::render(IntPoint windowSize, bool bOffscreen) { clearGLBuffers(GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT | GL_DEPTH_BUFFER_BIT, !bOffscreen); glViewport(0, 0, windowSize.x, windowSize.y); GLContext::checkError("Canvas::render: glViewport()"); glm::vec2 size = m_pRootNode->getSize(); glm::mat4 projMat; if (bOffscreen) { projMat = glm::ortho(0.f, size.x, 0.f, size.y); } else { projMat = glm::ortho(0.f, size.x, size.y, 0.f); } m_pVertexArray->activate(); m_pRootNode->maybeRender(projMat); renderOutlines(projMat); }